summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2012-08-08 19:38:05 -0300
committerSilvio Rhatto <rhatto@riseup.net>2012-08-08 19:38:05 -0300
commit50974d181bc2788fe87132874b4e6e22206777b0 (patch)
treec381469b1a60d88b82b17785093b1a4d833d8085
parentd35cb7375ca9f88dcc69789f11e7c1a2c33d8cb9 (diff)
downloadcalendario-50974d181bc2788fe87132874b4e6e22206777b0.tar.gz
calendario-50974d181bc2788fe87132874b4e6e22206777b0.tar.bz2
Building widget links
-rw-r--r--calendario-embed-widget.tpl.php4
-rw-r--r--calendario.module34
2 files changed, 31 insertions, 7 deletions
diff --git a/calendario-embed-widget.tpl.php b/calendario-embed-widget.tpl.php
index 17558cb..58e8f3b 100644
--- a/calendario-embed-widget.tpl.php
+++ b/calendario-embed-widget.tpl.php
@@ -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>
diff --git a/calendario.module b/calendario.module
index 18939b2..6967746 100644
--- a/calendario.module
+++ b/calendario.module
@@ -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));
}
/**