diff options
author | rvelices <rv-github@modusoptimus.com> | 2006-03-08 03:22:25 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2006-03-08 03:22:25 +0000 |
commit | cba56c06ede13f30483ca587f0c79cb0e4d82aaa (patch) | |
tree | 7e82d6628ef115795eb13273cbae7570922ba2ec /include | |
parent | 1e7c9034ded97b32a7d79a1ba05b384028ec5081 (diff) |
calendar: removed some warnings, improved display for weekly style and
worked on css (still not perfect due to IE)
git-svn-id: http://piwigo.org/svn/trunk@1069 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | include/calendar_base.class.php | 43 | ||||
-rw-r--r-- | include/calendar_monthly.class.php | 18 | ||||
-rw-r--r-- | include/calendar_weekly.class.php | 17 |
3 files changed, 46 insertions, 32 deletions
diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php index c71940830..6f403fb4d 100644 --- a/include/calendar_base.class.php +++ b/include/calendar_base.class.php @@ -65,8 +65,11 @@ class CalendarBase for ($i=0; $i<count($this->date_components); $i++) { $res .= $conf['level_separator']; - - $url .= $this->date_components[$i].'-'; + if ($i>0) + { + $url .= '-'; + } + $url .= $this->date_components[$i]; if ( isset($this->date_components[$i+1]) ) { $res .= @@ -96,7 +99,7 @@ class CalendarBase { $label = $this->calendar_levels[$level]['labels'][$date_component]; } - elseif ($date_component == 'any' ) + elseif ('any' === $date_component ) { $label = l10n('calendar_any'); } @@ -112,14 +115,14 @@ class CalendarBase $res = ''; for ($i=count($date_components)-1; $i>=0; $i--) { - if ($date_components[$i]!='any') + if ('any' !== $date_components[$i]) { - $label = $date_components[$i]; - if (isset($this->calendar_levels[$i]['labels'][$date_components[$i]])) + $label = $this->get_date_component_label($i, $date_components[$i] ); + if ( $res!='' ) { - $label = $this->calendar_levels[$i]['labels'][$date_components[$i]]; + $res .= ' '; } - $res .= $label.' '; + $res .= $label; } } return $res; @@ -192,7 +195,7 @@ class CalendarBase if ($conf['calendar_show_any'] and $show_any and count($items) > 1) { $label = l10n('calendar_any'); - if (isset($selected_item) and 'any' == $selected_item) + if (isset($selected_item) and 'any' === $selected_item) { $nav_bar .= '<span class="'.$class_prefix.'Sel">'; $nav_bar .= $label; @@ -289,37 +292,41 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql'] $prev = $next =null; if ( empty($this->date_components) ) return; - - $current = ''; $query = 'SELECT CONCAT_WS("-"'; for ($i=0; $i<count($this->date_components); $i++) { - if ( $this->date_components[$i] != 'any' ) + if ( 'any' === $this->date_components[$i] ) { - $query .= ','.$this->calendar_levels[$i]['sql']; + $query .= ','.'"any"'; } else { - $query .= ','.'"any"'; + $query .= ','.$this->calendar_levels[$i]['sql']; } - $current .= '-' . $this->date_components[$i]; } - $current = substr($current, 1); + $current = implode('-', $this->date_components ); $query.=') as period' . $this->inner_sql .' AND ' . $this->date_field . ' IS NOT NULL GROUP BY period'; + $upper_items = array_from_query( $query, 'period'); + usort($upper_items, 'version_compare'); - //echo ('<pre>'. var_export($upper_items, true) . '</pre>'); $upper_items_rank = array_flip($upper_items); + if ( !isset($upper_items_rank[$current]) ) + { + array_push($upper_items, $current);// just in case (external link) + usort($upper_items, 'version_compare'); + $upper_items_rank = array_flip($upper_items); + } $current_rank = $upper_items_rank[$current]; + if (!$this->has_nav_bar and ($current_rank>0 or $current_rank < count($upper_items)-1 ) ) { $template->assign_block_vars( 'calendar.navbar', array() ); } - if ( $current_rank>0 ) { // has previous $prev = $upper_items[$current_rank-1]; diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php index 2bced250d..9a43b0ecd 100644 --- a/include/calendar_monthly.class.php +++ b/include/calendar_monthly.class.php @@ -139,15 +139,15 @@ function get_date_where($max_levels=3) array_pop($date); } $res = ''; - if (isset($date[CYEAR]) and $date[CYEAR]!='any') + if (isset($date[CYEAR]) and $date[CYEAR]!=='any') { $b = $date[CYEAR] . '-'; $e = $date[CYEAR] . '-'; - if (isset($date[CMONTH]) and $date[CMONTH]!='any') + if (isset($date[CMONTH]) and $date[CMONTH]!=='any') { $b .= $date[CMONTH] . '-'; $e .= $date[CMONTH] . '-'; - if (isset($date[CDAY]) and $date[CDAY]!='any') + if (isset($date[CDAY]) and $date[CDAY]!=='any') { $b .= $date[CDAY]; $e .= $date[CDAY]; @@ -162,11 +162,11 @@ function get_date_where($max_levels=3) { $b .= '01-01'; $e .= '12-31'; - if (isset($date[CMONTH]) and $date[CMONTH]!='any') + if (isset($date[CMONTH]) and $date[CMONTH]!=='any') { $res .= ' AND '.$this->calendar_levels[CMONTH]['sql'].'='.$date[CMONTH]; } - if (isset($date[CDAY]) and $date[CDAY]!='any') + if (isset($date[CDAY]) and $date[CDAY]!=='any') { $res .= ' AND '.$this->calendar_levels[CDAY]['sql'].'='.$date[CDAY]; } @@ -176,11 +176,11 @@ function get_date_where($max_levels=3) else { $res = ' AND '.$this->date_field.' IS NOT NULL'; - if (isset($date[CMONTH]) and $date[CMONTH]!='any') + if (isset($date[CMONTH]) and $date[CMONTH]!=='any') { $res .= ' AND '.$this->calendar_levels[CMONTH]['sql'].'='.$date[CMONTH]; } - if (isset($date[CDAY]) and $date[CDAY]!='any') + if (isset($date[CDAY]) and $date[CDAY]!=='any') { $res .= ' AND '.$this->calendar_levels[CDAY]['sql'].'='.$date[CDAY]; } @@ -224,7 +224,8 @@ function build_global_calendar() $query.= $this->inner_sql; $query.= $this->get_date_where(); $query.= ' - GROUP BY period'; + GROUP BY period + ORDER BY YEAR('.$this->date_field.') DESC'; $result = pwg_query($query); $items=array(); @@ -290,7 +291,6 @@ function build_year_calendar() $items[$m]['children'][$d] = $row['count']; $items[$m]['nb_images'] += $row['count']; } - //echo ('<pre>'. var_export($items, true) . '</pre>'); if (count($items)==1) { // only one month exists so bail out to month view list($m) = array_keys($items); diff --git a/include/calendar_weekly.class.php b/include/calendar_weekly.class.php index 817acb1b0..023743693 100644 --- a/include/calendar_weekly.class.php +++ b/include/calendar_weekly.class.php @@ -46,6 +46,13 @@ class Calendar extends CalendarBase { parent::initialize($date_field, $inner_sql, $date_components); global $lang; + $week_no_labels=array(); + for ($i=1; $i<=53; $i++) + { + $week_no_labels[$i] = sprintf( l10n("Week %d"), $i); + //$week_no_labels[$i] = $i; + } + $this->calendar_levels = array( array( 'sql'=> 'YEAR('.$this->date_field.')', @@ -53,7 +60,7 @@ class Calendar extends CalendarBase ), array( 'sql'=> 'WEEK('.$this->date_field.')+1', - 'labels' => null + 'labels' => $week_no_labels, ), array( 'sql'=> 'DAYOFWEEK('.$this->date_field.')-1', @@ -86,7 +93,7 @@ function generate_category_content($url_base, $view_type) } if ( count($this->date_components)==1 ) { - $this->build_nav_bar(CWEEK); // week nav bar 1-53 + $this->build_nav_bar(CWEEK, array()); // week nav bar 1-53 } if ( count($this->date_components)==2 ) { @@ -111,17 +118,17 @@ function get_date_where($max_levels=3) array_pop($date); } $res = ''; - if (isset($date[CYEAR]) and $date[CYEAR]!='any') + if (isset($date[CYEAR]) and $date[CYEAR]!=='any') { $y = $date[CYEAR]; $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'"; } - if (isset($date[CWEEK]) and $date[CWEEK]!='any') + if (isset($date[CWEEK]) and $date[CWEEK]!=='any') { $res .= ' AND '.$this->calendar_levels[CWEEK]['sql'].'='.$date[CWEEK]; } - if (isset($date[CDAY]) and $date[CDAY]!='any') + if (isset($date[CDAY]) and $date[CDAY]!=='any') { $res .= ' AND '.$this->calendar_levels[CDAY]['sql'].'='.$date[CDAY]; } |