Changeset 1059 for trunk/include/calendar_weekly.class.php
- Timestamp:
- Feb 28, 2006, 5:28:06 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/calendar_weekly.class.php
r1057 r1059 37 37 { 38 38 39 /** 40 * Initialize the calendar 41 * @param string date_field db column on which this calendar works 42 * @param string inner_sql used for queries (INNER JOIN or normal) 43 * @param array date_components 44 */ 45 function initialize($date_field, $inner_sql, $date_components) 46 { 47 parent::initialize($date_field, $inner_sql, $date_components); 48 global $lang; 49 $this->calendar_levels = array( 50 array( 51 'sql'=> 'YEAR('.$this->date_field.')', 52 'labels' => null 53 ), 54 array( 55 'sql'=> 'WEEK('.$this->date_field.')+1', 56 'labels' => null 57 ), 58 array( 59 'sql'=> 'DAYOFWEEK('.$this->date_field.')-1', 60 'labels' => $lang['day'] 61 ), 62 ); 63 //Comment next lines for week starting on Sunday or if MySQL version<4.0.17 64 //WEEK(date,5) = "0-53 - Week 1=the first week with a Monday in this year" 65 $this->calendar_levels[CWEEK]['sql'] = 'WEEK('.$this->date_field.',5)+1'; 66 $this->calendar_levels[CDAY]['sql'] = 'WEEKDAY('.$this->date_field.')'; 67 array_push( $this->calendar_levels[CDAY]['labels'], 68 array_shift( $this->calendar_levels[CDAY]['labels'] ) ); 69 } 70 39 71 /** 40 72 * Generate navigation bars for category page … … 43 75 function generate_category_content($url_base, $view_type) 44 76 { 45 global $ lang, $conf;77 global $conf; 46 78 47 79 $this->url_base = $url_base; … … 49 81 assert($view_type==CAL_VIEW_LIST); 50 82 51 if ( $conf['calendar_multi_bar'] or count($this->date_components)==0 ) 83 $this->build_nav_bar(CYEAR); // years 84 if ( count($this->date_components)>=1 ) 52 85 { 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 86 $this->build_nav_bar(CWEEK); // week nav bar 1-53 60 87 } 61 88 if ( count($this->date_components)>=2 ) 62 89 { 63 $this->build_nav_bar(CDAY, 'DAYOFWEEK', '-1', 64 $lang['day'] ); // days 90 $this->build_nav_bar(CDAY); // days nav bar Mon-Sun 65 91 } 66 92 return false; … … 76 102 function get_date_where($max_levels=3) 77 103 { 78 $date _components= $this->date_components;79 while (count($date _components)>$max_levels)104 $date = $this->date_components; 105 while (count($date)>$max_levels) 80 106 { 81 array_pop($date _components);107 array_pop($date); 82 108 } 83 109 $res = ''; 84 if (isset($date _components[CYEAR]) and $date_components[CYEAR]!='any')110 if (isset($date[CYEAR]) and $date[CYEAR]!='any') 85 111 { 86 $y = $date _components[CYEAR];112 $y = $date[CYEAR]; 87 113 $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'"; 88 114 } 89 115 90 if (isset($date _components[CWEEK]) and $date_components[CWEEK]!='any')116 if (isset($date[CWEEK]) and $date[CWEEK]!='any') 91 117 { 92 $res .= ' AND WEEK('.$this->date_field.')+1='.$date_components[CWEEK];118 $res .= ' AND '.$this->calendar_levels[CWEEK]['sql'].'='.$date[CWEEK]; 93 119 } 94 if (isset($date _components[CDAY]) and $date_components[CDAY]!='any')120 if (isset($date[CDAY]) and $date[CDAY]!='any') 95 121 { 96 $res .= ' AND DAYOFWEEK('.$this->date_field.')-1=' 97 .$date_components[CDAY]; 122 $res .= ' AND '.$this->calendar_levels[CDAY]['sql'].'='.$date[CDAY]; 98 123 } 99 124 if (empty($res)) … … 104 129 } 105 130 106 function 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 144 131 } 145 132
Note: See TracChangeset
for help on using the changeset viewer.