aboutsummaryrefslogtreecommitdiffstats
path: root/include/calendar_base.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/calendar_base.class.php')
-rw-r--r--include/calendar_base.class.php88
1 files changed, 59 insertions, 29 deletions
diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php
index 8f9d1c252..e1b24bfea 100644
--- a/include/calendar_base.class.php
+++ b/include/calendar_base.class.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -22,20 +22,41 @@
// +-----------------------------------------------------------------------+
/**
+ * @package functions\calendar
+ */
+
+
+/**
* Base class for monthly and weekly calendar styles
*/
-class CalendarBase
+abstract class CalendarBase
{
- // db column on which this calendar works
+ /** db column on which this calendar works */
var $date_field;
- // used for queries (INNER JOIN or normal)
+ /** used for queries (INNER JOIN or normal) */
var $inner_sql;
- //
+ /** used to store db fields */
var $calendar_levels;
/**
- * Initialize the calendar
- * @param string inner_sql used for queries (INNER JOIN or normal)
+ * Generate navigation bars for category page.
+ *
+ * @return boolean false indicates that thumbnails where not included
+ */
+ abstract function generate_category_content();
+
+ /**
+ * Returns a sql WHERE subquery for the date field.
+ *
+ * @param int $max_levels (e.g. 2=only year and month)
+ * @return string
+ */
+ abstract function get_date_where($max_levels);
+
+ /**
+ * Initialize the calendar.
+ *
+ * @param string $inner_sql
*/
function initialize($inner_sql)
{
@@ -51,6 +72,11 @@ class CalendarBase
$this->inner_sql = $inner_sql;
}
+ /**
+ * Returns the calendar title (with HTML).
+ *
+ * @return string
+ */
function get_display_name()
{
global $conf, $page;
@@ -82,11 +108,12 @@ class CalendarBase
return $res;
}
-//--------------------------------------------------------- private members ---
/**
- * Returns a display name for a date component optionally using labels
- */
- function get_date_component_label($level, $date_component)
+ * Returns a display name for a date component optionally using labels.
+ *
+ * @return string
+ */
+ protected function get_date_component_label($level, $date_component)
{
$label = $date_component;
if (isset($this->calendar_levels[$level]['labels'][$date_component]))
@@ -101,9 +128,12 @@ class CalendarBase
}
/**
- * Gets a nice display name for a date to be shown in previos/next links.
+ * Gets a nice display name for a date to be shown in previous/next links
+ *
+ * @param string $date
+ * @return string
*/
- function get_date_nice_name($date)
+ protected function get_date_nice_name($date)
{
$date_components = explode('-', $date);
$res = '';
@@ -125,14 +155,14 @@ class CalendarBase
/**
* Creates a calendar navigation bar.
*
- * @param array date_components
- * @param array items - hash of items to put in the bar (e.g. 2005,2006)
- * @param bool show_any - adds any link to the end of the bar
- * @param bool show_empty - shows all labels even those without items
- * @param array labels - optional labels for items (e.g. Jan,Feb,...)
- * @return string the navigation bar
+ * @param array $date_components
+ * @param array $items - hash of items to put in the bar (e.g. 2005,2006)
+ * @param bool $show_any - adds any link to the end of the bar
+ * @param bool $show_empty - shows all labels even those without items
+ * @param array $labels - optional labels for items (e.g. Jan,Feb,...)
+ * @return string
*/
- function get_nav_bar_from_items($date_components, $items,
+ protected function get_nav_bar_from_items($date_components, $items,
$show_any,
$show_empty=false, $labels=null)
{
@@ -203,10 +233,9 @@ class CalendarBase
/**
* Creates a calendar navigation bar for a given level.
*
- * @param int level - the level (0-year,1-month/week,2-day)
- * @return void
+ * @param int $level - 0-year, 1-month/week, 2-day
*/
- function build_nav_bar($level, $labels=null)
+ protected function build_nav_bar($level, $labels=null)
{
global $template, $conf, $page;
@@ -261,7 +290,7 @@ $this->get_date_where($level).'
* Assigns the next/previous link to the template with regards to
* the currently choosen date.
*/
- function build_next_prev()
+ protected function build_next_prev()
{
global $template, $page;
@@ -294,7 +323,7 @@ GROUP BY period';
$upper_items_rank = array_flip($upper_items);
if ( !isset($upper_items_rank[$current]) )
{
- array_push($upper_items, $current);// just in case (external link)
+ $upper_items[] = $current;// just in case (external link)
usort($upper_items, 'version_compare');
$upper_items_rank = array_flip($upper_items);
}
@@ -330,11 +359,11 @@ GROUP BY period';
if ( !empty($tpl_var) )
{
- $existing = & $template->get_template_vars('chronology_navigation_bars');
- if ( !empty($existing) )
+ $existing = $template->smarty->getVariable('chronology_navigation_bars');
+ if (! ($existing instanceof Undefined_Smarty_Variable))
{
- $existing[ sizeof($existing)-1 ] =
- array_merge( $existing[ sizeof($existing)-1 ], $tpl_var);
+ $existing->value[ sizeof($existing->value)-1 ] =
+ array_merge( $existing->value[ sizeof($existing->value)-1 ], $tpl_var);
}
else
{
@@ -343,4 +372,5 @@ GROUP BY period';
}
}
}
+
?> \ No newline at end of file