]> gitweb.fluxo.info Git - drupal/calendario.git/commitdiff
Building widget links
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 8 Aug 2012 22:38:05 +0000 (19:38 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 8 Aug 2012 22:38:05 +0000 (19:38 -0300)
calendario-embed-widget.tpl.php
calendario.module

index 17558cb9311734932c61f10b56e3ed08e89caf0c..58e8f3b181716be45167ad03e8f9787a26119d20 100644 (file)
@@ -1,7 +1,7 @@
 <strong>Este calendário no seu site:</strong><br />
 
 <pre>
-&lt;iframe src="https://calendario.sarava.org/pt-br/widgets/calendario/dia" width="630" height="800" style="border: none;"&gt;
-  &lt;a href="https://calendario.sarava.org/pt-br/widgets/calendario/dia"&gt;Calendário&lt;/a&gt;.
+&lt;iframe src="https://calendario.sarava.org/pt-br/widgets/calendario/<?php print $link; ?>" width="630" height="800" style="border: none;"&gt;
+  &lt;a href="https://calendario.sarava.org/pt-br/widgets/calendario/<?php print $link; ?>"&gt;Calendário&lt;/a&gt;.
 &lt;/iframe&gt;
 </pre>
index 18939b213e16d7a09b41846063779984901c894c..69677468d826dbeb33b6477d2ab5598c9625d1cc 100644 (file)
@@ -12,7 +12,7 @@ function calendario_theme($existing, $type, $theme, $path) {
   return array(
     'embed-widget' => array(
       'template'   => 'calendario-embed-widget',
-      'variables'  => array('period' => NULL, 'type' => NULL),
+      'variables'  => array('link' => NULL),
     ),
   );
 }
@@ -34,12 +34,36 @@ function calendario_entity_info_alter(&$entity_info) {
 
 /**
  * Include a calendar widget.
- *
- * @todo
- *   Set $period and $type.
  */
 function calendario_widget($view = NULL) {
-  return theme('embed-widget');
+  $display = $view->current_display;
+  $path    = explode('/', $view->display[$display]->handler->options['path']);
+
+  switch ($path[1]) {
+    case 'dia':
+    case 'semana':
+    case 'mes':
+    case 'ano':
+      $type     = NULL;
+      $period   = $path[1];
+      //$date     = isset($path[2]) ? .'/'. $path[2] : '';
+      $date     = isset($view->args[0]) ? .'/'. $view->args[0] : '';
+      $argument = NULL;
+      $link     = $period . $date;
+      break;
+
+    default:
+      $type     = $path[1];
+      $period   = $path[3];
+      //$date     = isset($path[4]) ? .'/'. $path[4] : '';
+      $date     = isset($view->args[1]) ? .'/'. $view->args[1] : '';
+      //$argument = $path[2];
+      $argument = isset($view->args[0]) ? .'/'. $view->args[0] : '';
+      $link     = $type . $argument .'/'. $period . $date
+      break;
+  }
+
+  return theme('embed-widget', array('link' => $link));
 }
 
 /**