Ignore:
Timestamp:
Feb 24, 2006, 6:58:48 AM (19 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_weekly.class.php

    r1055 r1057  
    2727include_once(PHPWG_ROOT_PATH.'include/calendar_base.class.php');
    2828
     29define ('CYEAR', 0);
     30define ('CWEEK', 1);
     31define ('CDAY',  2);
     32
    2933/**
    3034 * Weekly calendar style (composed of years/week in years and days in week)
     
    3741 * @return boolean false to indicate that thumbnails where not included here
    3842 */
    39 function generate_category_content($url_base, $view_type, &$requested)
     43function generate_category_content($url_base, $view_type)
    4044{
    41   global $lang;
     45  global $lang, $conf;
    4246
    4347  $this->url_base = $url_base;
     
    4549  assert($view_type==CAL_VIEW_LIST);
    4650
    47   $this->build_nav_bar($view_type, $requested, 0, 'YEAR'); // years
    48   if (count($requested)>0)
    49     $this->build_nav_bar($view_type, $requested, 1, 'WEEK', '+1' ); // month
    50   if (count($requested)>1)
    51     $this->build_nav_bar($view_type, $requested, 2, 'DAYOFWEEK', '-1',
     51  if ( $conf['calendar_multi_bar'] or count($this->date_components)==0 )
     52  {
     53    $this->build_nav_bar(CYEAR, 'YEAR'); // years
     54  }
     55  if ( count($this->date_components)>=1 and
     56      ( $conf['calendar_multi_bar'] or count($this->date_components)==1 )
     57     )
     58  {
     59    $this->build_nav_bar(CWEEK, 'WEEK', '+1' ); // month
     60  }
     61  if ( count($this->date_components)>=2 )
     62  {
     63    $this->build_nav_bar(CDAY, 'DAYOFWEEK', '-1',
    5264                         $lang['day'] ); // days
     65  }
    5366  return false;
    5467}
     
    5770/**
    5871 * Returns a sql where subquery for the date field
    59  * @param array requested selected levels for this calendar
    60  * (e.g. 2005,42,1 for 41st week of 2005, Monday)
    6172 * @param int max_levels return the where up to this level
    6273 * (e.g. 2=only year and week in year)
    6374 * @return string
    6475 */
    65 function get_date_where($requested, $max_levels=3)
     76function get_date_where($max_levels=3)
    6677{
    67   while (count($requested)>$max_levels)
     78  $date_components = $this->date_components;
     79  while (count($date_components)>$max_levels)
    6880  {
    69     array_pop($requested);
     81    array_pop($date_components);
    7082  }
    7183  $res = '';
    72   if (isset($requested[0]) and $requested[0]!='any')
     84  if (isset($date_components[CYEAR]) and $date_components[CYEAR]!='any')
    7385  {
    74     $y = $requested[0];
     86    $y = $date_components[CYEAR];
    7587    $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'";
    7688  }
    7789
    78   if (isset($requested[1]) and $requested[1]!='any')
     90  if (isset($date_components[CWEEK]) and $date_components[CWEEK]!='any')
    7991  {
    80     $res .= ' AND WEEK('.$this->date_field.')+1='.$requested[1];
     92    $res .= ' AND WEEK('.$this->date_field.')+1='.$date_components[CWEEK];
    8193  }
    82   if (isset($requested[2]) and $requested[2]!='any')
     94  if (isset($date_components[CDAY]) and $date_components[CDAY]!='any')
    8395  {
    84     $res .= ' AND DAYOFWEEK('.$this->date_field.')-1='.$requested[2];
     96    $res .= ' AND DAYOFWEEK('.$this->date_field.')-1='
     97            .$date_components[CDAY];
    8598  }
    8699  if (empty($res))
     
    91104}
    92105
     106function get_display_name()
     107{
     108  global $conf,$lang;
     109  $res = '';
     110  $url = $this->url_base;
     111  if ( isset($this->date_components[CYEAR]) )
     112  {
     113    $res .= $conf['level_separator'];
     114    $url .= $this->date_components[CYEAR].'-';
     115    $res .=
     116      '<a href="'.$url.'">'
     117      .$this->get_date_component_label($this->date_components[CYEAR])
     118      .'</a>';
     119  }
     120  if ( isset($this->date_components[CWEEK]) )
     121  {
     122    $res .= $conf['level_separator'];
     123    $url .= $this->date_components[CWEEK].'-';
     124    $res .=
     125      '<a href="'.$url.'">'
     126      .$this->get_date_component_label($this->date_components[CWEEK])
     127      .'</a>';
     128  }
     129  if ( isset($this->date_components[CDAY]) )
     130  {
     131    $res .= $conf['level_separator'];
     132    $url .= $this->date_components[CDAY].'-';
     133    $res .=
     134      '<a href="'.$url.'">'
     135      .$this->get_date_component_label(
     136                    $this->date_components[CDAY],
     137                    $lang['day']
     138                    )
     139      .'</a>';
     140  }
     141  return $res;
     142}
     143
    93144}
    94145
Note: See TracChangeset for help on using the changeset viewer.