Changeset 1062
- Timestamp:
- Mar 3, 2006, 2:57:39 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/calendar_base.class.php
r1059 r1062 41 41 var $calendar_levels; 42 42 43 var $has_nav_bar; 44 43 45 /** 44 46 * Initialize the calendar … … 52 54 $this->inner_sql = $inner_sql; 53 55 $this->date_components = $date_components; 56 $this->has_nav_bar = false; 54 57 } 55 58 … … 99 102 } 100 103 return $label; 104 } 105 106 /** 107 * Gets a nice display name for a date to be shown in previos/next links. 108 */ 109 function get_date_nice_name($date) 110 { 111 $date_components = explode('-', $date); 112 $res = ''; 113 for ($i=count($date_components)-1; $i>=0; $i--) 114 { 115 if ($date_components[$i]!='any') 116 { 117 $label = $date_components[$i]; 118 if (isset($this->calendar_levels[$i]['labels'][$date_components[$i]])) 119 { 120 $label = $this->calendar_levels[$i]['labels'][$date_components[$i]]; 121 } 122 $res .= $label.' '; 123 } 124 } 125 return $res; 101 126 } 102 127 … … 212 237 } 213 238 214 if ( count($level_items)==1 ) 239 if ( count($level_items)==1 and 240 count($this->date_components)<count($this->calendar_levels)-1) 215 241 { 216 242 if ( ! isset($this->date_components[$level]) ) … … 218 244 list($key) = array_keys($level_items); 219 245 $this->date_components[$level] = (int)$key; 220 } 221 } 222 223 if ( $conf['calendar_multi_bar']==false ) 224 { 225 if ( $level<count($this->date_components) and 226 $level!=count($this->calendar_levels)-1 ) 227 { 228 return; 246 247 if ( $level<count($this->date_components) and 248 $level!=count($this->calendar_levels)-1 ) 249 { 250 return; 251 } 229 252 } 230 253 } … … 237 260 $url_base .= $this->date_components[$i].'-'; 238 261 } 239 }240 $selected = null;241 if ( isset($this->date_components[$level]) )242 {243 $selected = $this->date_components[$level];244 262 } 245 263 $nav_bar = $this->get_nav_bar_from_items( 246 264 $url_base, 247 265 $level_items, 248 $selected,266 null, 249 267 'calItem', 250 268 true, … … 256 274 'calendar.navbar', 257 275 array( 258 'BAR' => $nav_bar 276 'BAR' => $nav_bar, 259 277 ) 260 278 ); 279 $this->has_nav_bar = true; 280 } 281 282 /** 283 * Assigns the next/previous link to the template with regards to 284 * the currently choosen date. 285 */ 286 function build_next_prev() 287 { 288 global $template; 289 $prev = $next =null; 290 if ( empty($this->date_components) ) 291 return; 292 293 $current = ''; 294 $query = 'SELECT CONCAT_WS("-"'; 295 for ($i=0; $i<count($this->date_components); $i++) 296 { 297 if ( $this->date_components[$i] != 'any' ) 298 { 299 $query .= ','.$this->calendar_levels[$i]['sql']; 300 } 301 else 302 { 303 $query .= ','.'"any"'; 304 } 305 $current .= '-' . $this->date_components[$i]; 306 } 307 $current = substr($current, 1); 308 309 $query.=') as period' . $this->inner_sql .' 310 AND ' . $this->date_field . ' IS NOT NULL 311 GROUP BY period'; 312 $upper_items = array_from_query( $query, 'period'); 313 usort($upper_items, 'version_compare'); 314 //echo ('<pre>'. var_export($upper_items, true) . '</pre>'); 315 $upper_items_rank = array_flip($upper_items); 316 $current_rank = $upper_items_rank[$current]; 317 if (!$this->has_nav_bar and 318 ($current_rank>0 or $current_rank < count($upper_items)-1 ) ) 319 { 320 $template->assign_block_vars( 'calendar.navbar', array() ); 321 } 322 323 if ( $current_rank>0 ) 324 { // has previous 325 $prev = $upper_items[$current_rank-1]; 326 $template->assign_block_vars( 327 'calendar.navbar.prev', 328 array( 329 'LABEL' => $this->get_date_nice_name($prev), 330 'URL' => $this->url_base . $prev, 331 ) 332 ); 333 } 334 if ( $current_rank < count($upper_items)-1 ) 335 { 336 // has next 337 $next = $upper_items[$current_rank+1]; 338 $template->assign_block_vars( 339 'calendar.navbar.next', 340 array( 341 'LABEL' => $this->get_date_nice_name($next), 342 'URL' => $this->url_base . $next, 343 ) 344 ); 345 } 261 346 } 262 347 } -
trunk/include/calendar_monthly.class.php
r1061 r1062 94 94 {//case C: year+month given - display a nice month calendar 95 95 $this->build_month_calendar(); 96 //$this->build_nav_bar(CYEAR); // years 97 //$this->build_nav_bar(CMONTH); // month 98 $this->build_next_prev(); 99 return true; 100 } 101 } 102 103 if ($view_type==CAL_VIEW_LIST or count($this->date_components)==3) 104 { 105 $has_nav_bar = false; 106 if ( count($this->date_components)==0 ) 107 { 96 108 $this->build_nav_bar(CYEAR); // years 109 } 110 if ( count($this->date_components)==1) 111 { 97 112 $this->build_nav_bar(CMONTH); // month 98 return true; 99 } 100 } 101 102 if ($view_type==CAL_VIEW_LIST or count($this->date_components)==3) 103 { 104 if ( count($this->date_components)>=0 ) 105 { 106 $this->build_nav_bar(CYEAR); // years 107 } 108 if ( count($this->date_components)>=1) 109 { 110 $this->build_nav_bar(CMONTH); // month 111 } 112 if ( count($this->date_components)>=2 ) 113 { 114 $this->build_nav_bar( 115 CDAY, 116 range( 1, $this->get_all_days_in_month( 117 $this->date_components[CYEAR] ,$this->date_components[CMONTH] ) 118 ) 119 ); // days 120 } 113 } 114 if ( count($this->date_components)==2 ) 115 { 116 $day_labels = range( 1, $this->get_all_days_in_month( 117 $this->date_components[CYEAR] ,$this->date_components[CMONTH] ) ); 118 array_unshift($day_labels, 0); 119 unset( $day_labels[0] ); 120 $this->build_nav_bar( CDAY, $day_labels ); // days 121 } 122 $this->build_next_prev(); 121 123 } 122 124 return false; … … 294 296 list($m) = array_keys($items); 295 297 $this->date_components[CMONTH] = $m; 296 if (count($items[$m]['children'])==1)297 { // or even to day view if everything occured in one day298 list($d) = array_keys($items[$m]['children']);299 $this->date_components[CDAY] = $d;300 }301 298 return false; 302 299 } -
trunk/include/calendar_weekly.class.php
r1059 r1062 81 81 assert($view_type==CAL_VIEW_LIST); 82 82 83 $this->build_nav_bar(CYEAR); // years 84 if ( count($this->date_components)>=1 ) 83 if ( count($this->date_components)==0 ) 84 { 85 $this->build_nav_bar(CYEAR); // years 86 } 87 if ( count($this->date_components)==1 ) 85 88 { 86 89 $this->build_nav_bar(CWEEK); // week nav bar 1-53 87 90 } 88 if ( count($this->date_components) >=2 )91 if ( count($this->date_components)==2 ) 89 92 { 90 93 $this->build_nav_bar(CDAY); // days nav bar Mon-Sun 91 94 } 95 $this->build_next_prev(); 92 96 return false; 93 97 } -
trunk/include/config_default.inc.php
r1061 r1062 91 91 $conf['calendar_datefield'] = 'date_creation'; 92 92 93 // calendar_multi_bar : the calendar shows a maximum number of94 // year/month/week/day navigation bars95 $conf['calendar_multi_bar'] = true;96 97 93 // calendar_show_any : the calendar shows an aditional 'any' button in the 98 94 // year/month/week/day navigation bars -
trunk/include/functions_calendar.inc.php
r1059 r1062 261 261 } 262 262 } 263 $calendar_title = 264 '<a href="'.$url_base.$cal_style.'-'.$cal_view.'">' 265 .$fields[$cal_field]['label'].'</a>'; 266 $calendar_title.= $calendar->get_display_name(); 267 //this should be an assign_block_vars, but I need to assign 'calendar' 268 //above and at that point I don't have the title yet. 269 $template->_tpldata['calendar.'][0]['TITLE'] = $calendar_title; 263 270 } // end category calling 264 271 265 $calendar_title =266 '<a href="'.$url_base.$cal_style.'-'.$cal_view.'">'267 .$fields[$cal_field]['label'].'</a>';268 $calendar_title.= $calendar->get_display_name();269 $template->assign_block_vars(270 'calendar',271 array(272 'TITLE' => '<br/>'.$calendar_title,273 )274 );275 276 272 if ($must_show_list) 277 273 { 278 274 $query = 'SELECT DISTINCT(id)'; 279 $query .= $calendar->inner_sql ;280 $query .=$calendar->get_date_where();275 $query .= $calendar->inner_sql.' 276 '.$calendar->get_date_where(); 281 277 if ( isset($page['super_order_by']) ) 282 278 { … … 290 286 'ORDER BY '.$calendar->date_field.' DESC,', $conf['order_by'] 291 287 ); 292 $query .= $order_by; 288 $query .= ' 289 '.$order_by; 293 290 } 294 291 -
trunk/template/yoga/category.tpl
r1061 r1062 142 142 </ul> 143 143 144 <h2>{TITLE} 144 <h2>{TITLE}</h2> 145 145 <!-- BEGIN calendar --> 146 {calendar.TITLE} 146 <!-- BEGIN views --> 147 <div class="calendarViews">{lang:calendar_view}: 148 <select onchange="document.location = this.options[this.selectedIndex].value;"> 149 <!-- BEGIN view --> 150 <option value="{calendar.views.view.VALUE}" {calendar.views.view.SELECTED}>{calendar.views.view.CONTENT}</option> 151 <!-- END view --> 152 </select> 153 </div> 154 <!-- END views --> 147 155 <!-- END calendar --> 148 </h2> 156 157 <!-- BEGIN calendar --> 158 <h2>{calendar.TITLE} 159 </h2> 160 <!-- END calendar --> 161 149 162 </div> <!-- content --> 150 163 151 164 <!-- BEGIN calendar --> 152 <!-- BEGIN views --> 153 <div class="calendarViews"> 154 {lang:calendar_view}: <select onchange="document.location = this.options[this.selectedIndex].value;"> 155 <!-- BEGIN view --> 156 <option value="{calendar.views.view.VALUE}" {calendar.views.view.SELECTED}>{calendar.views.view.CONTENT}</option> 157 <!-- END view --> 158 </select> 165 <!-- BEGIN navbar --> 166 <div class="calendarBar"> 167 <!-- BEGIN prev --> 168 <div style="float:left">« <a href="{calendar.navbar.prev.URL}">{calendar.navbar.prev.LABEL}</a></div> 169 <!-- END prev --> 170 <!-- BEGIN next --> 171 <div style="float:right"><a href="{calendar.navbar.next.URL}">{calendar.navbar.next.LABEL}</a> »</div> 172 <!-- END next --> 173 {calendar.navbar.BAR} 159 174 </div> 160 <!-- END views -->161 162 <!-- BEGIN navbar -->163 <div class="calendarBar">{calendar.navbar.BAR}</div>164 175 <!-- END navbar --> 165 176 -
trunk/template/yoga/content.css
r1061 r1062 183 183 #content DIV.calendarViews { 184 184 display: block; 185 text-align: left; 186 margin: 5px 0; 187 } 188 189 #content DIV.calendarBar { 190 margin: 8px 4px; 191 } 192 193 SPAN.calItem { 185 float: right; 186 margin: 2px 2px; 187 } 188 189 #content DIV.calendarBar { margin: 8px 4px; } 190 191 SPAN.calItem, SPAN.calItemEmpty { 194 192 font-weight: bold; 195 margin: 0 2px; 196 border: 1px solid gray; 197 } 198 199 SPAN.calItemSel { 200 font-weight: bold; 201 margin: 0 2px; 202 border: 1px solid gray; 203 } 204 205 SPAN.calItemEmpty { 206 font-weight: bold; 207 margin: 0 2px; 208 border: 1px solid gray; 209 } 193 margin: 0 1px; 194 } 195 196 SPAN.calItem A { border:0 } 210 197 211 198 #content DIV.calendarCalBar { … … 220 207 } 221 208 222 SPAN.calCal { 223 margin: 0 2px; 224 } 209 SPAN.calCal { margin: 0 2px; } 225 210 226 211 /* nice looking month calendar*/ -
trunk/template/yoga/theme/clear/theme.css
r1061 r1062 79 79 80 80 /*calendar elements*/ 81 SPAN.calItem Sel { color: dark-gray; }81 SPAN.calItemEmpty { color: silver; } 82 82 83 SPAN.calItemEmpty { color: lightgray; } 84 83 SPAN.calItem, SPAN.calItemEmpty 84 { 85 border: 1px solid silver; 86 } 85 87 86 88 /* nice looking month calendar*/ 87 89 TD.calDayCellEmpty, TD.calDayCellFull { border: 1px solid #7E7262;} 88 90 89 TD.calDayCellEmpty { color: lightgray; }91 TD.calDayCellEmpty { color: silver; } 90 92 91 93 .calBackDate { color: #000; } -
trunk/template/yoga/theme/dark/theme.css
r1061 r1062 116 116 117 117 /*calendar elements*/ 118 SPAN.calItem Sel { color: #fff48e; }118 SPAN.calItemEmpty { color: silver; } 119 119 120 SPAN.calItemEmpty { color: darkgray; } 120 SPAN.calItem, SPAN.calItemEmpty 121 { 122 border: 1px solid gray; 123 } 121 124 122 125 /* nice looking month calendar*/ 123 126 TD.calDayCellEmpty, TD.calDayCellFull { border: 1px solid gray;} 124 127 125 TD.calDayCellEmpty { color: lightgray; }128 TD.calDayCellEmpty { color: silver; } 126 129 127 130 .calBackDate { color: #000; }
Note: See TracChangeset
for help on using the changeset viewer.