Changeset 1057
- Timestamp:
- Feb 24, 2006, 6:58:48 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/category.php
r1056 r1057 302 302 'special_cat', 303 303 array( 304 'URL' => PHPWG_ROOT_PATH.'category.php?calendar=m -c',304 'URL' => PHPWG_ROOT_PATH.'category.php?calendar=monthly-c', 305 305 'TITLE' => $lang['calendar_hint'], 306 306 'NAME' => $lang['calendar'] -
trunk/include/calendar_base.class.php
r1056 r1057 36 36 // base url used when generating html links 37 37 var $url_base; 38 // array of date components e.g. (2005,10,12) ... 39 var $date_components; 38 40 39 function get_date_where()40 {41 die("get_date_where not extended");42 }43 41 44 42 /** … … 46 44 * @param string date_field db column on which this calendar works 47 45 * @param string inner_sql used for queries (INNER JOIN or normal) 46 * @param array date_components 48 47 */ 49 function initialize($date_field, $inner_sql )48 function initialize($date_field, $inner_sql, $date_components) 50 49 { 51 50 $this->date_field = $date_field; 52 51 $this->inner_sql = $inner_sql; 52 $this->date_components = $date_components; 53 53 } 54 54 55 55 //--------------------------------------------------------- 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 57 73 /** 58 74 * Creates a calendar navigation bar. … … 97 113 $nav_bar.= '</span>'; 98 114 } 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) 101 117 { 102 118 $label = l10n('calendar_any'); … … 122 138 * Creates a calendar navigation bar for a given level. 123 139 * 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)126 140 * @param string sql_func - YEAR/MONTH/DAY/WEEK/DAYOFWEEK ... 127 141 * @param string sql_offset - (e.g. +1 for WEEK - first in year is 1) … … 129 143 * @return void 130 144 */ 131 function build_nav_bar($ view_type, $requested, $level, $sql_func,145 function build_nav_bar($level, $sql_func, 132 146 $sql_offset='', $labels=null) 133 147 { … … 138 152 .') as period'; 139 153 $query.= $this->inner_sql; 140 $query.= $this->get_date_where($ requested, $level);154 $query.= $this->get_date_where($level); 141 155 $query.= ' 142 156 GROUP BY period … … 151 165 152 166 $url_base = $this->url_base; 153 $url_base .= $view_type.'-';154 167 for ($i=0; $i<$level; $i++) 155 168 { 156 if (isset($ requested[$i]))169 if (isset($this->date_components[$i])) 157 170 { 158 $url_base .= $ requested[$i].'-';171 $url_base .= $this->date_components[$i].'-'; 159 172 } 160 173 } 161 174 $selected = null; 175 if ( isset($this->date_components[$level]) ) 176 { 177 $selected = $this->date_components[$level]; 178 } 162 179 $nav_bar = $this->get_nav_bar_from_items( 163 180 $url_base, 164 181 $level_items, 165 isset($requested[$level]) ? $requested[$level] : null,182 $selected, 166 183 'cal', 167 184 true, -
trunk/include/calendar_monthly.class.php
r1056 r1057 27 27 include_once(PHPWG_ROOT_PATH.'include/calendar_base.class.php'); 28 28 29 define ('CYEAR', 0); 30 define ('CMONTH', 1); 31 define ('CDAY', 2); 32 29 33 /** 30 34 * Monthly calendar style (composed of years/months and days) … … 38 42 * where not included here, true otherwise 39 43 */ 40 function generate_category_content($url_base, $view_type , &$requested)41 { 42 global $lang ;44 function generate_category_content($url_base, $view_type) 45 { 46 global $lang, $conf; 43 47 44 48 $this->url_base = $url_base; 45 49 46 if ($view_type==CAL_VIEW_CALENDAR and count($requested)==0) 47 {//case A: no year given - display all years+months 48 if ($this->build_global_calendar($requested)) 50 if ($view_type==CAL_VIEW_CALENDAR) 51 { 52 if ( count($this->date_components)==0 ) 53 {//case A: no year given - display all years+months 54 if ($this->build_global_calendar()) 55 return true; 56 } 57 58 if ( count($this->date_components)==1 ) 59 {//case B: year given - display all days in given year 60 if ($this->build_year_calendar()) 61 { 62 if ( $conf['calendar_multi_bar'] ) 63 $this->build_nav_bar2(CYEAR, 'YEAR'); // years 64 return true; 65 } 66 } 67 68 if ( count($this->date_components)==2 ) 69 {//case C: year+month given - display a nice month calendar 70 $this->build_month_calendar(); 71 if ( $conf['calendar_multi_bar'] ) 72 { 73 $this->build_nav_bar2(CYEAR, 'YEAR'); // years 74 } 75 if (count($this->date_components)>=1 and 76 ( $conf['calendar_multi_bar'] or count($this->date_components)==1 ) ) 77 { 78 $this->build_nav_bar2(CMONTH, 'MONTH', $lang['month']); // month 79 } 49 80 return true; 50 } 51 52 if ($view_type==CAL_VIEW_CALENDAR and count($requested)==1) 53 {//case B: year given - display all days in given year 54 if ($this->build_year_calendar($requested)) 55 { 56 $this->build_nav_bar2($view_type, $requested, 0, 'YEAR'); // years 57 return true; 58 } 59 } 60 61 if ($view_type==CAL_VIEW_CALENDAR and count($requested)==2) 62 {//case C: year+month given - display a nice month calendar 63 $this->build_month_calendar($requested); 64 $this->build_nav_bar2(CAL_VIEW_CALENDAR, $requested, 0, 'YEAR'); // years 65 if (count($requested)>0) 66 $this->build_nav_bar2(CAL_VIEW_CALENDAR, $requested, 1, 'MONTH', $lang['month']); // month 67 return true; 68 } 69 70 if ($view_type==CAL_VIEW_LIST or count($requested)==3) 71 { 72 $this->build_nav_bar2($view_type, $requested, 0, 'YEAR'); // years 73 if (count($requested)>0) 74 $this->build_nav_bar2($view_type, $requested, 1, 'MONTH', $lang['month']); // month 75 if (count($requested)>1) 76 $this->build_nav_bar2($view_type, $requested, 2, 'DAYOFMONTH' ); // days 81 } 82 } 83 84 if ($view_type==CAL_VIEW_LIST or count($this->date_components)==3) 85 { 86 if ( $conf['calendar_multi_bar'] or count($this->date_components)==0 ) 87 { 88 $this->build_nav_bar2(CYEAR, 'YEAR'); // years 89 } 90 if ( count($this->date_components)>=1 and 91 ( $conf['calendar_multi_bar'] or count($this->date_components)==1 ) 92 ) 93 { 94 $this->build_nav_bar2(CMONTH, 'MONTH', $lang['month']); // month 95 } 96 if ( count($this->date_components)>=2 ) 97 { 98 $this->build_nav_bar2(CDAY, 'DAYOFMONTH' ); // days 99 } 77 100 } 78 101 return false; … … 82 105 /** 83 106 * Returns a sql where subquery for the date field 84 * @param array requested selected levels for this calendar85 * (e.g. 2005,11,5 for 5th of November 2005)86 107 * @param int max_levels return the where up to this level 87 108 * (e.g. 2=only year and month) 88 109 * @return string 89 110 */ 90 function get_date_where($requested, $max_levels=3) 91 { 92 while (count($requested)>$max_levels) 93 { 94 array_pop($requested); 111 function get_date_where($max_levels=3) 112 { 113 $date = $this->date_components; 114 while (count($date)>$max_levels) 115 { 116 array_pop($date); 95 117 } 96 118 $res = ''; 97 if (isset($ requested[0]) and $requested[0]!='any')98 { 99 $b = $ requested[0] . '-';100 $e = $ requested[0] . '-';101 if (isset($ requested[1]) and $requested[1]!='any')102 { 103 $b .= $ requested[1] . '-';104 $e .= $ requested[1] . '-';105 if (isset($ requested[2]) and $requested[2]!='any')106 { 107 $b .= $ requested[2];108 $e .= $ requested[2];119 if (isset($date[CYEAR]) and $date[CYEAR]!='any') 120 { 121 $b = $date[CYEAR] . '-'; 122 $e = $date[CYEAR] . '-'; 123 if (isset($date[CMONTH]) and $date[CMONTH]!='any') 124 { 125 $b .= $date[CMONTH] . '-'; 126 $e .= $date[CMONTH] . '-'; 127 if (isset($date[CDAY]) and $date[CDAY]!='any') 128 { 129 $b .= $date[CDAY]; 130 $e .= $date[CDAY]; 109 131 } 110 132 else … … 118 140 $b .= '01-01'; 119 141 $e .= '12-31'; 120 if (isset($ requested[1]) and $requested[1]!='any')121 { 122 $res .= ' AND MONTH('.$this->date_field.')='.$ requested[1];123 } 124 if (isset($ requested[2]) and $requested[2]!='any')125 { 126 $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$ requested[2];142 if (isset($date[CMONTH]) and $date[CMONTH]!='any') 143 { 144 $res .= ' AND MONTH('.$this->date_field.')='.$date[CMONTH]; 145 } 146 if (isset($date[2]) and $date[2]!='any') 147 { 148 $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$date[CDAY]; 127 149 } 128 150 } … … 132 154 { 133 155 $res = ' AND '.$this->date_field.' IS NOT NULL'; 134 if (isset($ requested[1]) and $requested[1]!='any')135 { 136 $res .= ' AND MONTH('.$this->date_field.')='.$ requested[1];137 } 138 if (isset($ requested[2]) and $requested[2]!='any')139 { 140 $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$ requested[2];156 if (isset($date[CMONTH]) and $date[CMONTH]!='any') 157 { 158 $res .= ' AND MONTH('.$this->date_field.')='.$date[CMONTH]; 159 } 160 if (isset($date[CDAY]) and $date[CDAY]!='any') 161 { 162 $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$date[CDAY]; 141 163 } 142 164 } … … 144 166 } 145 167 168 169 function get_display_name() 170 { 171 global $conf, $lang; 172 $res = ''; 173 $url = $this->url_base; 174 if ( isset($this->date_components[CYEAR]) ) 175 { 176 $res .= $conf['level_separator']; 177 $url .= $this->date_components[CYEAR].'-'; 178 $res .= 179 '<a href="'.$url.'">' 180 .$this->get_date_component_label($this->date_components[CYEAR]) 181 .'</a>'; 182 } 183 if ( isset($this->date_components[CMONTH]) ) 184 { 185 $res .= $conf['level_separator']; 186 $url .= $this->date_components[CMONTH].'-'; 187 $res .= 188 '<a href="'.$url.'">' 189 .$this->get_date_component_label( 190 $this->date_components[CMONTH], 191 $lang['month'] 192 ) 193 .'</a>'; 194 } 195 if ( isset($this->date_components[CDAY]) ) 196 { 197 $res .= $conf['level_separator']; 198 $url .= $this->date_components[CDAY].'-'; 199 $res .= 200 '<a href="'.$url.'">' 201 .$this->get_date_component_label($this->date_components[CDAY]) 202 .'</a>'; 203 } 204 205 return $res; 206 } 207 208 146 209 //--------------------------------------------------------- private members --- 147 function build_nav_bar2($ view_type, $requested, $level, $sql_func, $labels=null)148 { 149 parent::build_nav_bar($ view_type, $requested, $level, $sql_func, '', $labels);150 } 151 152 function build_global_calendar( &$requested)153 { 154 assert( count($ requested) == 0 );210 function build_nav_bar2($level, $sql_func, $labels=null) 211 { 212 parent::build_nav_bar($level, $sql_func, '', $labels); 213 } 214 215 function build_global_calendar() 216 { 217 assert( count($this->date_components) == 0 ); 155 218 $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%Y%m")) as period, 156 219 COUNT(id) as count'; 157 220 $query.= $this->inner_sql; 158 $query.= $this->get_date_where( $requested);221 $query.= $this->get_date_where(); 159 222 $query.= ' 160 223 GROUP BY period'; … … 176 239 {// only one year exists so bail out to year view 177 240 list($y) = array_keys($items); 178 array_push($requested, $y );241 $this->date_components[CYEAR] = $y; 179 242 return false; 180 243 } … … 183 246 foreach ( $items as $year=>$year_data) 184 247 { 185 $url_base = $this->url_base .'c-'.$year;248 $url_base = $this->url_base.$year; 186 249 187 250 $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">'.$year.'</a>'; … … 200 263 } 201 264 202 function build_year_calendar( &$requested)203 { 204 assert( count($ requested) == 1 );265 function build_year_calendar() 266 { 267 assert( count($this->date_components) == 1 ); 205 268 $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%m%d")) as period, 206 269 COUNT(id) as count'; 207 270 $query.= $this->inner_sql; 208 $query.= $this->get_date_where( $requested);271 $query.= $this->get_date_where(); 209 272 $query.= ' 210 273 GROUP BY period'; … … 226 289 { // only one month exists so bail out to month view 227 290 list($m) = array_keys($items); 228 array_push($requested, $m );291 $this->date_components[CMONTH] = $m; 229 292 if (count($items[$m]['children'])==1) 230 293 { // or even to day view if everything occured in one day 231 294 list($d) = array_keys($items[$m]['children']); 232 array_push($requested, $d);295 $this->date_components[CDAY] = $d; 233 296 } 234 297 return false; … … 237 300 foreach ( $items as $month=>$month_data) 238 301 { 239 $url_base = $this->url_base. 'c-'.$requested[0].'-'.$month;302 $url_base = $this->url_base.$this->date_components[CYEAR].'-'.$month; 240 303 241 304 $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">'; … … 256 319 } 257 320 258 function build_month_calendar( $requested)321 function build_month_calendar() 259 322 { 260 323 $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%d")) as period, 261 324 COUNT(id) as count'; 262 325 $query.= $this->inner_sql; 263 $query.= $this->get_date_where($ requested, 2);326 $query.= $this->get_date_where($this->date_components); 264 327 $query.= ' 265 328 GROUP BY period'; … … 278 341 foreach ( $items as $day=>$nb_images) 279 342 { 280 $url_base = $this->url_base.'c-'.$requested[0].'-'.$requested[1].'-'.$day; 281 $requested[2]=$day; 343 $url_base = $this->url_base. 344 $this->date_components[CYEAR].'-'. 345 $this->date_components[CMONTH].'-'.$day; 346 $this->date_components[CDAY]=$day; 282 347 $query = ' 283 348 SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw'; 284 349 $query.= $this->inner_sql; 285 $query.= $this->get_date_where( $requested);350 $query.= $this->get_date_where(); 286 351 $query.= ' 287 352 ORDER BY RAND() 288 353 LIMIT 0,1'; 354 unset ( $this->date_components[CDAY] ); 289 355 290 356 $row = mysql_fetch_array(pwg_query($query)); -
trunk/include/calendar_weekly.class.php
r1055 r1057 27 27 include_once(PHPWG_ROOT_PATH.'include/calendar_base.class.php'); 28 28 29 define ('CYEAR', 0); 30 define ('CWEEK', 1); 31 define ('CDAY', 2); 32 29 33 /** 30 34 * Weekly calendar style (composed of years/week in years and days in week) … … 37 41 * @return boolean false to indicate that thumbnails where not included here 38 42 */ 39 function generate_category_content($url_base, $view_type , &$requested)43 function generate_category_content($url_base, $view_type) 40 44 { 41 global $lang ;45 global $lang, $conf; 42 46 43 47 $this->url_base = $url_base; … … 45 49 assert($view_type==CAL_VIEW_LIST); 46 50 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', 52 64 $lang['day'] ); // days 65 } 53 66 return false; 54 67 } … … 57 70 /** 58 71 * Returns a sql where subquery for the date field 59 * @param array requested selected levels for this calendar60 * (e.g. 2005,42,1 for 41st week of 2005, Monday)61 72 * @param int max_levels return the where up to this level 62 73 * (e.g. 2=only year and week in year) 63 74 * @return string 64 75 */ 65 function get_date_where($ requested, $max_levels=3)76 function get_date_where($max_levels=3) 66 77 { 67 while (count($requested)>$max_levels) 78 $date_components = $this->date_components; 79 while (count($date_components)>$max_levels) 68 80 { 69 array_pop($ requested);81 array_pop($date_components); 70 82 } 71 83 $res = ''; 72 if (isset($ requested[0]) and $requested[0]!='any')84 if (isset($date_components[CYEAR]) and $date_components[CYEAR]!='any') 73 85 { 74 $y = $ requested[0];86 $y = $date_components[CYEAR]; 75 87 $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'"; 76 88 } 77 89 78 if (isset($ requested[1]) and $requested[1]!='any')90 if (isset($date_components[CWEEK]) and $date_components[CWEEK]!='any') 79 91 { 80 $res .= ' AND WEEK('.$this->date_field.')+1='.$ requested[1];92 $res .= ' AND WEEK('.$this->date_field.')+1='.$date_components[CWEEK]; 81 93 } 82 if (isset($ requested[2]) and $requested[2]!='any')94 if (isset($date_components[CDAY]) and $date_components[CDAY]!='any') 83 95 { 84 $res .= ' AND DAYOFWEEK('.$this->date_field.')-1='.$requested[2]; 96 $res .= ' AND DAYOFWEEK('.$this->date_field.')-1=' 97 .$date_components[CDAY]; 85 98 } 86 99 if (empty($res)) … … 91 104 } 92 105 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 93 144 } 94 145 -
trunk/include/config_default.inc.php
r1044 r1057 91 91 $conf['calendar_datefield'] = 'date_creation'; 92 92 93 // calendar_multi_bar : the calendar shows a maximum number of 94 // year/month/week/day navigation bars 95 $conf['calendar_multi_bar'] = true; 96 97 // calendar_show_any : the calendar shows an aditional 'any' button in the 98 // year/month/week/day navigation bars 99 $conf['calendar_show_any'] = true; 100 93 101 // newcat_default_commentable : at creation, must a category be commentable 94 102 // or not ? -
trunk/include/functions_calendar.inc.php
r1056 r1057 28 28 define('CAL_VIEW_CALENDAR', 'c'); 29 29 30 function get_calendar_parameter($options, &$parameters ) 31 { 32 if ( count($parameters) and isset($options[$parameters[0]]) ) 33 { 34 return array_shift($parameters); 35 } 36 else 37 { 38 foreach ($options as $option => $data) 39 { 40 if ( empty( $data['default_link'] ) ) 41 { 42 break; 43 } 44 } 45 return $option; 46 } 47 } 48 30 49 function initialize_calendar() 31 50 { … … 74 93 //-------------------------------------- initialize the calendar parameters --- 75 94 pwg_debug('start initialize_calendar'); 76 77 $cal_styles = array( 95 // the parameters look like (FIELD)?(STYLE)?(VIEW)?(DATE COMPONENTS)? 96 // FIELD = (created-|posted-) 97 // STYLE = (m-|w-) 98 // VIEW = (l-|c-) 99 // DATE COMPONENTS= YEAR(-MONTH/WEEK)?(-DAY)? 100 101 $fields = array( 102 // Created 103 'created' => array( 104 // TODO change next line when calendar_datefield disapears 105 'default_link' => ( $conf['calendar_datefield']=='date_creation' ? '' : 'created-' ), 106 'label' => l10n('Creation date'), 107 'db_field' => 'date_creation', 108 ), 109 // Posted 110 'posted' => array( 111 // TODO change next line when calendar_datefield disapears 112 'default_link' => ( $conf['calendar_datefield']=='date_available' ? '' : 'posted-' ), 113 'label' => l10n('Availability date'), 114 'db_field' => 'date_available', 115 ), 116 ); 117 118 $styles = array( 78 119 // Monthly style 79 array( 80 'link' => 'm', 120 'monthly' => array( 81 121 'default_link' => '', 82 ' name' => l10n('Monthly'),122 'label' => l10n('Monthly'), 83 123 'include' => 'calendar_monthly.class.php', 84 124 'view_calendar' => true, 85 125 ), 86 126 // Weekly style 87 array( 88 'link' => 'w', 89 'default_link' => 'w-', 90 'name' => l10n('Weekly'), 127 'weekly' => array( 128 'default_link' => 'weekly-', 129 'label' => l10n('Weekly'), 91 130 'include' => 'calendar_weekly.class.php', 92 131 'view_calendar' => false, … … 94 133 ); 95 134 135 $views = array( 136 // list view 137 CAL_VIEW_LIST => array( 138 'default_link' => '', 139 'label' => l10n('List') 140 ), 141 // calendar view 142 CAL_VIEW_CALENDAR => array( 143 'default_link' => CAL_VIEW_CALENDAR.'-', 144 'label' => l10n('calendar') 145 ), 146 ); 147 96 148 $requested = explode('-', $_GET['calendar']); 97 $calendar = null; 98 foreach ($cal_styles as $cal_style) 99 { 100 if ($requested[0] == $cal_style['link']) 101 { 102 include(PHPWG_ROOT_PATH.'include/'.$cal_style['include']); 103 $calendar = new Calendar(); 104 array_shift($requested); 105 break; 106 } 107 } 108 109 if (!isset($calendar)) 110 { 111 foreach($cal_styles as $cal_style) 112 { 113 if ('' == $cal_style['default_link']) 114 { 115 break; 116 } 117 } 118 include( PHPWG_ROOT_PATH.'include/'.$cal_style['include']); 119 $calendar = new Calendar(); 120 } 121 122 $view_type = CAL_VIEW_LIST; 123 if ($requested[0] == CAL_VIEW_LIST) 124 { 125 array_shift($requested); 126 } 127 elseif ($requested[0] == CAL_VIEW_CALENDAR) 128 { 129 if ($cal_style['view_calendar']) 130 { 131 $view_type = CAL_VIEW_CALENDAR; 132 } 133 array_shift($requested); 134 } 149 150 // Retrieve calendar field 151 $cal_field = get_calendar_parameter($fields, $requested); 152 153 // Retrieve style 154 $cal_style = get_calendar_parameter($styles, $requested); 155 include(PHPWG_ROOT_PATH.'include/'. $styles[$cal_style]['include']); 156 $calendar = new Calendar(); 157 158 // Retrieve view 159 $cal_view = get_calendar_parameter($views, $requested); 160 if ( CAL_VIEW_CALENDAR==$cal_view and !$styles[$cal_style]['view_calendar'] ) 161 { 162 $cal_view=CAL_VIEW_LIST; 163 } 164 135 165 // perform a sanity check on $requested 136 166 while (count($requested) > 3) … … 144 174 if ($requested[$i] == 'any') 145 175 { 146 if ($ view_type== CAL_VIEW_CALENDAR)176 if ($cal_view == CAL_VIEW_CALENDAR) 147 177 {// we dont allow any in calendar view 148 178 while ($i < count($requested)) … … 166 196 array_pop($requested); 167 197 } 168 169 $calendar->initialize($conf['calendar_datefield'], $inner_sql); 170 //echo ('<pre>'. var_export($requested, true) . '</pre>'); 171 //echo ('<pre>'. var_export($calendar, true) . '</pre>'); 172 173 // TODO: what makes the list view required? 174 $must_show_list = true; 175 198 199 $calendar->initialize($fields[$cal_field]['db_field'], $inner_sql, $requested); 200 201 //echo ('<pre>'. var_export($fields, true) . '</pre>'); 202 203 $url_base = 204 PHPWG_ROOT_PATH.'category.php' 205 .get_query_string_diff(array('start', 'calendar')) 206 .(empty($url_base) ? '?' : '&') 207 .'calendar='.$cal_field.'-' 208 ; 209 210 $must_show_list = true; // true until calendar generates its own display 176 211 if (basename($_SERVER["PHP_SELF"]) == 'category.php') 177 212 { 178 213 $template->assign_block_vars('calendar', array()); 179 214 180 $url_base =181 PHPWG_ROOT_PATH.'category.php'182 .get_query_string_diff(array('start', 'calendar'))183 .(empty($url_base) ? '?' : '&')184 .'calendar='185 ;186 187 215 if ($calendar->generate_category_content( 188 $url_base.$cal_style['default_link'], 189 $view_type, 190 $requested 216 $url_base.$cal_style.'-'.$cal_view.'-', 217 $cal_view 191 218 ) 192 219 ) … … 200 227 $must_show_list = false; 201 228 } 202 203 if ($cal_style['view_calendar']) 204 { // Build bar for views (List/Calendar) 205 $views = array( 206 // list view 207 array( 208 'type' => CAL_VIEW_LIST, 209 'label' => l10n('List') 210 ), 211 // calendar view 212 array( 213 'type' => CAL_VIEW_CALENDAR, 214 'label' => l10n('calendar') 215 ), 216 ); 217 218 $views_bar = ''; 219 220 foreach ($views as $view) 229 230 $template->assign_block_vars( 'calendar.views', array() ); 231 foreach ($styles as $style => $style_data) 232 { 233 foreach ($views as $view => $view_data) 221 234 { 222 if ( $view_type != $view['type'])235 if ( $style_data['view_calendar'] or $view != CAL_VIEW_CALENDAR) 223 236 { 224 $views_bar.= 225 '<a href="' 226 .$url_base.$cal_style['default_link'].$view['type'].'-' 227 .implode('-', $requested) 228 .'">'.$view['label'].'</a> '; 237 $selected = ''; 238 $url = $url_base.$style.'-'.$view; 239 if ($style==$cal_style) 240 { 241 $url .= '-'.implode('-', $calendar->date_components); 242 if ( $view==$cal_view ) 243 { 244 $selected = 'SELECTED'; 245 } 246 } 247 else 248 { 249 if (isset($calendar->date_components[0])) 250 { 251 $url .= '-' . $calendar->date_components[0]; 252 } 253 } 254 $template->assign_block_vars( 255 'calendar.views.view', 256 array( 257 'VALUE' => $url, 258 'CONTENT' => $style_data['label'].' ('.$view_data['label'].')', 259 'SELECTED' => $selected, 260 ) 261 ); 229 262 } 230 else231 {232 $views_bar.= $view['label'].' ';233 }234 235 $views_bar.= ' ';236 263 } 237 238 $template->assign_block_vars( 239 'calendar.views', 240 array( 241 'BAR' => $views_bar, 242 ) 243 ); 244 } 245 246 // Build bar for calendar styles (Monthly, Weekly) 247 $styles_bar = ''; 248 foreach ($cal_styles as $style) 249 { 250 if ($cal_style['link'] != $style['link']) 251 { 252 $url = $url_base.$style['default_link']; 253 $url .= $view_type; 254 if (isset($requested[0])) 255 { 256 $url .= '-' . $requested[0]; 257 } 258 $styles_bar .= '<a href="'. $url . '">'.$style['name'].'</a> '; 259 } 260 else 261 { 262 $styles_bar .= $style['name'].' '; 263 } 264 } 265 $template->assign_block_vars( 266 'calendar.styles', 267 array( 268 'BAR' => $styles_bar, 269 ) 270 ); 264 } 271 265 } // end category calling 272 266 267 $calendar_title = 268 '<a href="'.$url_base.$cal_style.'-'.$cal_view.'">' 269 .$fields[$cal_field]['label'].'</a>'; 270 $calendar_title.= $calendar->get_display_name(); 271 $template->assign_block_vars( 272 'calendar', 273 array( 274 'TITLE' => $calendar_title, 275 ) 276 ); 277 273 278 if ($must_show_list) 274 279 { 275 280 $query = 'SELECT DISTINCT(id)'; 276 281 $query .= $calendar->inner_sql; 277 $query .= $calendar->get_date_where( $requested);282 $query .= $calendar->get_date_where(); 278 283 if ( isset($page['super_order_by']) ) 279 284 { -
trunk/picture.php
r1056 r1057 794 794 { 795 795 $val = format_date($picture['current']['date_creation']); 796 if ( $conf['calendar_datefield'] == 'date_creation' ) 797 { 798 $infos['INFO_CREATION_DATE'] = '<a href="'. 799 PHPWG_ROOT_PATH.'category.php?calendar=c-'. 796 $infos['INFO_CREATION_DATE'] = '<a href="'. 797 PHPWG_ROOT_PATH.'category.php?calendar=created-c-'. 800 798 $picture['current']['date_creation'].'">'.$val.'</a>'; 801 }802 else803 {804 $infos['INFO_CREATION_DATE'] = $val;805 }806 799 } 807 800 else … … 812 805 // date of availability 813 806 $val = format_date($picture['current']['date_available'], 'mysql_datetime'); 814 if ( $conf['calendar_datefield'] == 'date_available' ) 815 { 816 $infos['INFO_AVAILABILITY_DATE'] = '<a href="'. 817 PHPWG_ROOT_PATH.'category.php?calendar=c-'. 818 substr($picture['current']['date_available'],0,10).'">'.$val.'</a>'; 819 } 820 else 821 { 822 $infos['INFO_AVAILABILITY_DATE'] = $val; 823 } 807 $infos['INFO_AVAILABILITY_DATE'] = '<a href="'. 808 PHPWG_ROOT_PATH.'category.php?calendar=posted-c-'. 809 substr($picture['current']['date_available'],0,10).'">'.$val.'</a>'; 824 810 825 811 // size in pixels -
trunk/template/yoga/category.tpl
r1051 r1057 139 139 </ul> 140 140 141 <h2>{TITLE}</h2> 142 141 <h2>{TITLE} 142 <!-- BEGIN calendar --> 143 <br/>{calendar.TITLE} 144 <!-- END calendar --></h2> 143 145 </div> <!-- content --> 144 146 145 147 <!-- BEGIN calendar --> 146 <!-- BEGIN styles -->147 <div class="calendarStyles">Style: {calendar.styles.BAR}</div>148 <!-- END styles -->149 150 148 <!-- BEGIN views --> 151 <div class="calendarViews">{calendar.views.BAR}</div> 149 <div class="calendarViews"> 150 <select onchange="document.location = this.options[this.selectedIndex].value;"> 151 <!-- BEGIN view --> 152 <option value="{calendar.views.view.VALUE}" {calendar.views.view.SELECTED}>{calendar.views.view.CONTENT}</option> 153 <!-- END view --> 154 </select> 155 </div><br/> 152 156 <!-- END views --> 153 <br/> 157 154 158 <!-- BEGIN navbar --> 155 159 <div class="navigationBar">{calendar.navbar.BAR}</div> -
trunk/template/yoga/content.css
r1050 r1057 180 180 181 181 182 #content DIV.calendar Styles {182 #content DIV.calendarViews { 183 183 float: left; 184 }185 186 #content DIV.calendarViews {187 float: right;188 184 } 189 185
Note: See TracChangeset
for help on using the changeset viewer.