Changeset 4398 for trunk/include
- Timestamp:
- Nov 30, 2009, 9:41:11 PM (14 years ago)
- Location:
- trunk/include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/calendar_base.class.php
r4367 r4398 216 216 $this->inner_sql. 217 217 $this->get_date_where($level).' 218 GROUP BY period 218 GROUP BY period 219 ORDER BY period ASC 219 220 ;'; 220 221 … … 266 267 { 267 268 global $template, $page; 269 268 270 $prev = $next =null; 269 271 if ( empty($page['chronology_date']) ) 270 272 return; 271 $query = 'SELECT CONCAT_WS(\'-\''; 272 for ($i=0; $i<count($page['chronology_date']); $i++) 273 274 $sub_query = ''; 275 $nb_elements = count($page['chronology_date']); 276 for ($i=0; $i<$nb_elements; $i++) 273 277 { 274 278 if ( 'any' === $page['chronology_date'][$i] ) 275 279 { 276 $ query .= ','.'"any"';280 $sub_query .= '\'any\''; 277 281 } 278 282 else 279 283 { 280 $query .= ','.$this->calendar_levels[$i]['sql']; 281 } 282 } 283 $current = implode('-', $page['chronology_date'] ); 284 285 $query.=') as period' . $this->inner_sql .' 284 $sub_query .= pwg_db_cast_to_text($this->calendar_levels[$i]['sql']); 285 } 286 if ($i<($nb_elements-1)) 287 { 288 $sub_query .= ','; 289 } 290 } 291 $query = 'SELECT '.pwg_db_concat_ws($sub_query, '-').' AS period'; 292 $query .= $this->inner_sql .' 286 293 AND ' . $this->date_field . ' IS NOT NULL 287 294 GROUP BY period'; 288 295 296 $current = implode('-', $page['chronology_date'] ); 289 297 $upper_items = array_from_query( $query, 'period'); 290 298 -
trunk/include/calendar_monthly.class.php
r4367 r4398 44 44 $this->calendar_levels = array( 45 45 array( 46 'sql'=> 'YEAR('.$this->date_field.')',46 'sql'=> pwg_db_get_year($this->date_field), 47 47 'labels' => null 48 48 ), 49 49 array( 50 'sql'=> 'MONTH('.$this->date_field.')',51 50 'sql'=> pwg_db_get_month($this->date_field), 51 'labels' => $lang['month'] 52 52 ), 53 53 array( 54 'sql'=> 'DAYOFMONTH('.$this->date_field.')',54 'sql'=> pwg_db_get_dayofmonth($this->date_field), 55 55 'labels' => null 56 56 ), … … 135 135 { 136 136 global $page; 137 137 138 $date = $page['chronology_date']; 138 139 while (count($date)>$max_levels) … … 157 158 { 158 159 $b .= '01'; 159 $e .= '31';160 $e .= $this->get_all_days_in_month($date[CYEAR], $date[CMONTH]); 160 161 } 161 162 } … … 194 195 //--------------------------------------------------------- private members --- 195 196 196 // returns an array with all lthe days in a given month197 // returns an array with all the days in a given month 197 198 function get_all_days_in_month($year, $month) 198 199 { … … 221 222 { 222 223 global $page; 224 223 225 assert( count($page['chronology_date']) == 0 ); 224 $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%Y%m")) as period, 225 COUNT( DISTINCT(id) ) as count'; 226 $query=' 227 SELECT '.pwg_db_get_date_YYYYMM($this->date_field).' as period,' 228 .pwg_db_get_year($this->date_field).' as year, ' 229 .pwg_db_get_month($this->date_field).' as month, 230 count(distinct id) as count'; 226 231 $query.= $this->inner_sql; 227 232 $query.= $this->get_date_where(); 228 233 $query.= ' 229 GROUP BY period 230 ORDER BY YEAR('.$this->date_field.') DESC, MONTH('.$this->date_field.')';234 GROUP BY period, year, month 235 ORDER BY year DESC, month ASC'; 231 236 232 237 $result = pwg_query($query); … … 274 279 { 275 280 global $page; 281 276 282 assert( count($page['chronology_date']) == 1 ); 277 $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%m%d"))as period,278 COUNT( DISTINCT(id)) as count';283 $query='SELECT '.pwg_db_get_date_MMDD($this->date_field).' as period, 284 COUNT(DISTINCT id) as count'; 279 285 $query.= $this->inner_sql; 280 286 $query.= $this->get_date_where(); 281 287 $query.= ' 282 GROUP BY period'; 288 GROUP BY period 289 ORDER BY period ASC'; 283 290 284 291 $result = pwg_query($query); … … 325 332 { 326 333 global $page; 327 $query='SELECT DISTINCT(DAYOFMONTH('.$this->date_field.')) as period, 328 COUNT( DISTINCT(id) ) as count'; 334 335 $query='SELECT '.pwg_db_get_dayofmonth($this->date_field).' as period, 336 COUNT(DISTINCT id) as count'; 329 337 $query.= $this->inner_sql; 330 338 $query.= $this->get_date_where(); 331 339 $query.= ' 332 GROUP BY period'; 340 GROUP BY period 341 ORDER BY period ASC'; 333 342 334 343 $items=array(); … … 344 353 $page['chronology_date'][CDAY]=$day; 345 354 $query = ' 346 SELECT id, file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as dow';355 SELECT id, file,tn_ext,path, width, height, '.pwg_db_get_dayofweek($this->date_field).'-1 as dow'; 347 356 $query.= $this->inner_sql; 348 357 $query.= $this->get_date_where(); -
trunk/include/calendar_weekly.class.php
r3282 r4398 51 51 $this->calendar_levels = array( 52 52 array( 53 'sql'=> 'YEAR('.$this->date_field.')',53 'sql'=> pwg_db_get_year($this->date_field), 54 54 'labels' => null 55 55 ), 56 56 array( 57 'sql'=> 'WEEK('.$this->date_field.')+1',57 'sql'=> pwg_db_get_week($this->date_field)+1, 58 58 'labels' => $week_no_labels, 59 59 ), 60 60 array( 61 'sql'=> 'DAYOFWEEK('.$this->date_field.')-1',61 'sql'=> pwg_db_get_dayofweek($this->date_field)-1, 62 62 'labels' => $lang['day'] 63 63 ), … … 65 65 //Comment next lines for week starting on Sunday or if MySQL version<4.0.17 66 66 //WEEK(date,5) = "0-53 - Week 1=the first week with a Monday in this year" 67 $this->calendar_levels[CWEEK]['sql'] = 'WEEK('.$this->date_field.',5)+1';68 $this->calendar_levels[CDAY]['sql'] = 'WEEKDAY('.$this->date_field.')';67 $this->calendar_levels[CWEEK]['sql'] = pwg_db_get_week($this->date_field, 5).'+1'; 68 $this->calendar_levels[CDAY]['sql'] = pwg_db_get_weekday($this->date_field); 69 69 array_push( $this->calendar_levels[CDAY]['labels'], 70 70 array_shift( $this->calendar_levels[CDAY]['labels'] ) ); -
trunk/include/functions_calendar.inc.php
r4385 r4398 259 259 if ($must_show_list) 260 260 { 261 $query = 'SELECT id'; 261 $query = 'SELECT DISTINCT id '.get_extra_fields($conf['order_by']); 262 $query .= ','.$calendar->date_field; 262 263 $query .= $calendar->inner_sql.' 263 264 '.$calendar->get_date_where();
Note: See TracChangeset
for help on using the changeset viewer.