Changeset 1053 for trunk/include/functions_calendar.inc.php
- Timestamp:
- Feb 23, 2006, 5:53:11 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_calendar.inc.php
r1051 r1053 25 25 // +-----------------------------------------------------------------------+ 26 26 27 define('CAL_VIEW_LIST', 'l');28 define('CAL_VIEW_CALENDAR', 'c');27 define('CAL_VIEW_LIST', 'l'); 28 define('CAL_VIEW_CALENDAR', 'c'); 29 29 30 30 function initialize_calendar() … … 34 34 //------------------ initialize the condition on items to take into account --- 35 35 $inner_sql = ' FROM ' . IMAGES_TABLE; 36 if ( !isset($page['cat']) or is_numeric($page['cat']) ) 36 37 if (!isset($page['cat']) or is_numeric($page['cat'])) 37 38 { // we will regenerate the items by including subcats elements 38 $page['cat_nb_images'] =0;39 $page['items'] =array();39 $page['cat_nb_images'] = 0; 40 $page['items'] = array(); 40 41 $inner_sql .= ' 41 42 INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; 42 if ( is_numeric($page['cat']) ) 43 { 44 $sub_ids = get_subcat_ids(array($page['cat'])); 45 $sub_ids = array_diff($sub_ids, 46 explode(',', $user['forbidden_categories']) ); 43 44 if (isset($page['cat']) and is_numeric($page['cat'])) 45 { 46 $sub_ids = array_diff( 47 get_subcat_ids(array($page['cat'])), 48 explode(',', $user['forbidden_categories']) 49 ); 50 47 51 if (empty($sub_ids)) 48 52 { … … 70 74 //-------------------------------------- initialize the calendar parameters --- 71 75 pwg_debug('start initialize_calendar'); 76 72 77 $cal_styles = array( 73 array('link'=>'m', 'default_link'=>'', 'name'=>l10n('Monthly'), 74 'include'=>'calendar_monthly.class.php', 'view_calendar'=>true ), 75 array('link'=>'w', 'default_link'=>'w-', 'name'=>l10n('Weekly'), 76 'include'=>'calendar_weekly.class.php', ), 78 // Weekly style 79 array( 80 'link' => 'm', 81 'default_link' => '', 82 'name' => l10n('Monthly'), 83 'include' => 'calendar_monthly.class.php', 84 'view_calendar' => true, 85 ), 86 // Monthly style 87 array( 88 'link' => 'w', 89 'default_link' => 'w-', 90 'name' => l10n('Weekly'), 91 'include' => 'calendar_weekly.class.php', 92 ), 77 93 ); 78 94 79 95 $requested = explode('-', $_GET['calendar']); 80 96 $calendar = null; 81 foreach ($cal_styles as $cal_style)82 { 83 if ($requested[0] ==$cal_style['link'])84 { 85 include( 97 foreach ($cal_styles as $cal_style) 98 { 99 if ($requested[0] == $cal_style['link']) 100 { 101 include(PHPWG_ROOT_PATH.'include/'.$cal_style['include']); 86 102 $calendar = new Calendar(); 87 103 array_shift($requested); … … 89 105 } 90 106 } 91 if ( !isset($calendar) ) 92 { 93 foreach( $cal_styles as $cal_style) 94 { 95 if (''==$cal_style['default_link']) 107 108 if (!isset($calendar)) 109 { 110 foreach($cal_styles as $cal_style) 111 { 112 if ('' == $cal_style['default_link']) 113 { 96 114 break; 115 } 97 116 } 98 117 include( PHPWG_ROOT_PATH.'include/'.$cal_style['include']); … … 100 119 } 101 120 102 $view_type =CAL_VIEW_LIST;103 if ($requested[0] ==CAL_VIEW_LIST)121 $view_type = CAL_VIEW_LIST; 122 if ($requested[0] == CAL_VIEW_LIST) 104 123 { 105 124 array_shift($requested); 106 125 } 107 elseif ($requested[0] ==CAL_VIEW_CALENDAR)126 elseif ($requested[0] == CAL_VIEW_CALENDAR) 108 127 { 109 128 if ($cal_style['view_calendar']) 110 129 { 111 $view_type =CAL_VIEW_CALENDAR;130 $view_type = CAL_VIEW_CALENDAR; 112 131 } 113 132 array_shift($requested); 114 133 } 115 134 // perform a sanity check on $requested 116 while (count($requested) >3)135 while (count($requested) > 3) 117 136 { 118 137 array_pop($requested); … … 120 139 121 140 $any_count = 0; 122 for ($i =0; $i<count($requested); $i++)123 { 124 if ($requested[$i] =='any')125 { 126 if ($view_type ==CAL_VIEW_CALENDAR)141 for ($i = 0; $i < count($requested); $i++) 142 { 143 if ($requested[$i] == 'any') 144 { 145 if ($view_type == CAL_VIEW_CALENDAR) 127 146 {// we dont allow any in calendar view 128 while ($i <count($requested))129 { 130 array_pop( $requested);147 while ($i < count($requested)) 148 { 149 array_pop($requested); 131 150 } 132 151 break; … … 134 153 $any_count++; 135 154 } 136 elseif ( $requested[$i]=='')137 { 138 while ($i <count($requested))139 { 140 array_pop( $requested);141 } 142 } 143 } 144 if ($any_count ==3)155 elseif ($requested[$i] == '') 156 { 157 while ($i < count($requested)) 158 { 159 array_pop($requested); 160 } 161 } 162 } 163 if ($any_count == 3) 145 164 { 146 165 array_pop($requested); … … 151 170 //echo ('<pre>'. var_export($calendar, true) . '</pre>'); 152 171 153 $category_calling = false; 172 // TODO: what makes the list view required? 173 $must_show_list = true; 174 154 175 if (basename($_SERVER["PHP_SELF"]) == 'category.php') 155 176 { 156 $category_calling = true;157 }158 159 $must_show_list = true;160 if ($category_calling)161 {162 177 $template->assign_block_vars('calendar', array()); 163 178 164 $url_base = get_query_string_diff(array('start','calendar')); 165 $url_base .= empty($url_base) ? '?' : '&'; 166 $url_base .= 'calendar='; 167 $url_base = PHPWG_ROOT_PATH.'category.php'.$url_base; 168 169 if ( $calendar->generate_category_content( 170 $url_base.$cal_style['default_link'], $view_type, $requested) ) 171 { 172 unset( $page['thumbnails_include'] ); 173 unset( $page['items'] ); 174 unset( $page['cat_nb_images'] ); 179 $url_base = 180 PHPWG_ROOT_PATH.'category.php' 181 .get_query_string_diff(array('start', 'calendar')) 182 .(empty($url_base) ? '?' : '&') 183 .'calendar=' 184 ; 185 186 if ($calendar->generate_category_content( 187 $url_base.$cal_style['default_link'], 188 $view_type, 189 $requested 190 ) 191 ) 192 { 193 unset( 194 $page['thumbnails_include'], 195 $page['items'], 196 $page['cat_nb_images'] 197 ); 198 175 199 $must_show_list = false; 176 200 } 177 201 178 202 if ($cal_style['view_calendar']) 179 { // Build bar for view modes (List/Calendar)203 { // Build bar for views (List/Calendar) 180 204 $views = array( 181 array(CAL_VIEW_LIST, l10n('List') ), 182 array(CAL_VIEW_CALENDAR, l10n('calendar') ), 183 ); 205 // list view 206 array( 207 'type' => CAL_VIEW_LIST, 208 'label' => l10n('List') 209 ), 210 // calendar view 211 array( 212 'type' => CAL_VIEW_CALENDAR, 213 'label' => l10n('calendar') 214 ), 215 ); 216 184 217 $views_bar = ''; 185 foreach( $views as $view ) 186 { 187 $v = $view[1]; 188 if ( $view_type!=$view[0] ) 189 { 190 $url = $url_base.$cal_style['default_link'].$view[0].'-'; 191 $url .= implode('-', $requested); 192 $v = '<a href="'.$url.'">'.$v.'</a> '; 218 219 foreach ($views as $view) 220 { 221 if ($view_type != $view['type']) 222 { 223 $views_bar.= 224 '<a href="' 225 .$url_base.$cal_style['default_link'].$view['type'].'-' 226 .implode('-', $requested) 227 .'">'.$view['label'].'</a> '; 193 228 } 194 229 else 195 230 { 196 $v = $v.' '; 197 } 198 $views_bar .= $v . ' '; 199 } 200 $template->assign_block_vars('calendar.views', array( 201 'BAR'=>$views_bar 202 )); 231 $views_bar.= $view['label'].' '; 232 } 233 234 $views_bar.= ' '; 235 } 236 237 $template->assign_block_vars( 238 'calendar.views', 239 array( 240 'BAR' => $views_bar, 241 ) 242 ); 203 243 } 204 244 205 245 // Build bar for calendar styles (Monthly, Weekly) 206 246 $styles_bar = ''; 207 foreach ( 208 { 209 if ($cal_style['link'] !=$style['link'])247 foreach ($cal_styles as $style) 248 { 249 if ($cal_style['link'] != $style['link']) 210 250 { 211 251 $url = $url_base.$style['default_link']; … … 222 262 } 223 263 } 224 $template->assign_block_vars( 'calendar.styles', 225 array( 'BAR' => $styles_bar) 226 ); 264 $template->assign_block_vars( 265 'calendar.styles', 266 array( 267 'BAR' => $styles_bar, 268 ) 269 ); 227 270 } // end category calling 228 271 … … 240 283 { 241 284 $order_by = str_replace( 242 243 244 285 'ORDER BY ', 286 'ORDER BY '.$calendar->date_field.',', $conf['order_by'] 287 ); 245 288 $query .= $order_by; 246 289 } 247 290 248 $page['items'] = array_from_query($query, 'id');249 $page['cat_nb_images'] = count($page['items']);291 $page['items'] = array_from_query($query, 'id'); 292 $page['cat_nb_images'] = count($page['items']); 250 293 $page['thumbnails_include'] = 'include/category_default.inc.php'; 251 294 }
Note: See TracChangeset
for help on using the changeset viewer.