Ignore:
Timestamp:
Feb 24, 2006, 6:58:48 AM (18 years ago)
Author:
rvelices
Message:

calendar: added posted/created chronology

calendar: added a where are we bar (like: created/2005/august)

calendar: possibility to hide the All/Any buttons ($confcalendar_show_any)

calendar: possibility to display a single navigation bar instead of
several navigation bars ($confcalendar_multi_bar)

calendar: tried to simplify code and improve readability
(still requires a review)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/calendar_base.class.php

    r1056 r1057  
    3636  // base url used when generating html links
    3737  var $url_base;
     38  // array of date components e.g. (2005,10,12) ...
     39  var $date_components;
    3840
    39   function get_date_where()
    40   {
    41     die("get_date_where not extended");
    42   }
    4341
    4442  /**
     
    4644   * @param string date_field db column on which this calendar works
    4745   * @param string inner_sql used for queries (INNER JOIN or normal)
     46   * @param array date_components
    4847   */
    49   function initialize($date_field, $inner_sql)
     48  function initialize($date_field, $inner_sql, $date_components)
    5049  {
    5150    $this->date_field = $date_field;
    5251    $this->inner_sql = $inner_sql;
     52    $this->date_components = $date_components;
    5353  }
    5454
    5555//--------------------------------------------------------- private members ---
    56 
     56  /**
     57   * Returns a display name for a date component optionally using labels
     58  */
     59  function get_date_component_label($date_component, $labels=null)
     60  {
     61    $label = $date_component;
     62    if (isset($labels[$date_component]))
     63    {
     64      $label = $labels[$date_component];
     65    }
     66    elseif ($date_component == 'any' )
     67    {
     68      $label = l10n('calendar_any');
     69    }
     70    return $label;
     71  }
     72 
    5773  /**
    5874   * Creates a calendar navigation bar.
     
    97113      $nav_bar.= '</span>';
    98114    }
    99 
    100     if ($allow_any and count($items) > 1)
     115    global $conf;
     116    if ($conf['calendar_show_any'] and $allow_any and count($items) > 1)
    101117    {
    102118      $label = l10n('calendar_any');
     
    122138   * Creates a calendar navigation bar for a given level.
    123139   *
    124    * @param string view_type - list or calendar (e.g. 'l' or 'c')
    125    * @param array requested - array of current selected elements (e.g. 2005,10)
    126140   * @param string sql_func - YEAR/MONTH/DAY/WEEK/DAYOFWEEK ...
    127141   * @param string sql_offset - (e.g. +1 for WEEK - first in year is 1)
     
    129143   * @return void
    130144   */
    131   function build_nav_bar($view_type, $requested, $level, $sql_func,
     145  function build_nav_bar($level, $sql_func,
    132146                         $sql_offset='', $labels=null)
    133147  {
     
    138152      .') as period';
    139153    $query.= $this->inner_sql;
    140     $query.= $this->get_date_where($requested, $level);
     154    $query.= $this->get_date_where($level);
    141155    $query.= '
    142156  GROUP BY period
     
    151165
    152166    $url_base = $this->url_base;
    153     $url_base .= $view_type.'-';
    154167    for ($i=0; $i<$level; $i++)
    155168    {
    156       if (isset($requested[$i]))
     169      if (isset($this->date_components[$i]))
    157170      {
    158         $url_base .= $requested[$i].'-';
     171        $url_base .= $this->date_components[$i].'-';
    159172      }
    160173    }
    161 
     174    $selected = null;
     175    if ( isset($this->date_components[$level]) )
     176    {
     177      $selected = $this->date_components[$level];
     178    }
    162179    $nav_bar = $this->get_nav_bar_from_items(
    163180      $url_base,
    164181      $level_items,
    165       isset($requested[$level]) ? $requested[$level] : null,
     182      $selected,
    166183      'cal',
    167184      true,
Note: See TracChangeset for help on using the changeset viewer.