diff options
author | rvelices <rv-github@modusoptimus.com> | 2011-09-08 18:22:27 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2011-09-08 18:22:27 +0000 |
commit | 1d3fc9005f00927c19c291f33b5bfffdd81cad6e (patch) | |
tree | 549aa6fa5a11b0ab895e74e7fb97e468bcff4074 /include/calendar_monthly.class.php | |
parent | dbb3fd5a444a542ddcd730882138daca602c0923 (diff) |
- reoptimize queries for MySql
- week starts on monday/sunday applies also to weekly calendar
git-svn-id: http://piwigo.org/svn/trunk@12118 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/calendar_monthly.class.php')
-rw-r--r-- | include/calendar_monthly.class.php | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php index 4b176f85f..2c14088c9 100644 --- a/include/calendar_monthly.class.php +++ b/include/calendar_monthly.class.php @@ -224,15 +224,13 @@ function build_global_calendar(&$tpl_var) assert( count($page['chronology_date']) == 0 ); $query=' -SELECT '.pwg_db_get_date_YYYYMM($this->date_field).' as period,' - .pwg_db_get_year($this->date_field).' as year, ' - .pwg_db_get_month($this->date_field).' as month, - count(distinct id) as count'; +SELECT '.pwg_db_get_date_YYYYMM($this->date_field).' as period, + COUNT(distinct id) as count'; $query.= $this->inner_sql; $query.= $this->get_date_where(); $query.= ' - GROUP BY period, year, month - ORDER BY year DESC, month ASC'; + GROUP BY period + ORDER BY '.pwg_db_get_year($this->date_field).' DESC, '.pwg_db_get_month($this->date_field).' ASC'; $result = pwg_query($query); $items=array(); @@ -368,11 +366,6 @@ SELECT id, file,tn_ext,path, width, height, '.pwg_db_get_dayofweek($this->date_f $items[$day]['width'] = $row['width']; $items[$day]['height'] = $row['height']; $items[$day]['dow'] = $row['dow']; - - if ('sunday' == $conf['week_starts_on']) - { - $items[$day]['dow']++; - } } if ( !empty($items) @@ -389,21 +382,19 @@ SELECT id, file,tn_ext,path, width, height, '.pwg_db_get_dayofweek($this->date_f //first_day_dow = week day corresponding to the first day of this month $wday_labels = $lang['day']; - // BEGIN - pass now in week starting Monday - if ($first_day_dow==0) - { - $first_day_dow = 6; - } - else - { - $first_day_dow -= 1; - } - if ('monday' == $conf['week_starts_on']) { + if ($first_day_dow==0) + { + $first_day_dow = 6; + } + else + { + $first_day_dow -= 1; + } + array_push( $wday_labels, array_shift($wday_labels) ); } - // END - pass now in week starting Monday $cell_width = $conf['calendar_month_cell_width']; $cell_height = $conf['calendar_month_cell_height']; @@ -528,4 +519,4 @@ SELECT id, file,tn_ext,path, width, height, '.pwg_db_get_dayofweek($this->date_f } } -?> +?>
\ No newline at end of file |