diff options
author | rvelices <rv-github@modusoptimus.com> | 2006-03-03 01:57:39 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2006-03-03 01:57:39 +0000 |
commit | 2a3d5012138715952add2f69e9b3253353ea419d (patch) | |
tree | 0edda816004ca51c4781bf12517f0c95ad422eae | |
parent | 8f33338fed3809c2b964cbe610658b143c96b6c9 (diff) |
improvement: calendar navigation now uses at maximum one navigation bar
together with a next/previous date links
improvement: calendar view styles now shown in DIV.titrePage (I still need
to move padding from H2 to DIV.titrePage ...)
fix: moved all calendar css colors from template to the theme
git-svn-id: http://piwigo.org/svn/trunk@1062 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | include/calendar_base.class.php | 117 | ||||
-rw-r--r-- | include/calendar_monthly.class.php | 29 | ||||
-rw-r--r-- | include/calendar_weekly.class.php | 10 | ||||
-rw-r--r-- | include/config_default.inc.php | 4 | ||||
-rw-r--r-- | include/functions_calendar.inc.php | 25 | ||||
-rw-r--r-- | template/yoga/category.tpl | 39 | ||||
-rw-r--r-- | template/yoga/content.css | 29 | ||||
-rw-r--r-- | template/yoga/theme/clear/theme.css | 10 | ||||
-rw-r--r-- | template/yoga/theme/dark/theme.css | 9 |
9 files changed, 176 insertions, 96 deletions
diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php index 8f9ec4bb7..c71940830 100644 --- a/include/calendar_base.class.php +++ b/include/calendar_base.class.php @@ -40,6 +40,8 @@ class CalendarBase // var $calendar_levels; + var $has_nav_bar; + /** * Initialize the calendar * @param string date_field db column on which this calendar works @@ -51,6 +53,7 @@ class CalendarBase $this->date_field = $date_field; $this->inner_sql = $inner_sql; $this->date_components = $date_components; + $this->has_nav_bar = false; } function get_display_name() @@ -101,6 +104,28 @@ class CalendarBase } /** + * Gets a nice display name for a date to be shown in previos/next links. + */ + function get_date_nice_name($date) + { + $date_components = explode('-', $date); + $res = ''; + for ($i=count($date_components)-1; $i>=0; $i--) + { + if ($date_components[$i]!='any') + { + $label = $date_components[$i]; + if (isset($this->calendar_levels[$i]['labels'][$date_components[$i]])) + { + $label = $this->calendar_levels[$i]['labels'][$date_components[$i]]; + } + $res .= $label.' '; + } + } + return $res; + } + + /** * Creates a calendar navigation bar. * * @param string url_base - links start with this root @@ -211,21 +236,19 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql'] $level_items[$row['period']] = 0; } - if ( count($level_items)==1 ) + if ( count($level_items)==1 and + count($this->date_components)<count($this->calendar_levels)-1) { if ( ! isset($this->date_components[$level]) ) { list($key) = array_keys($level_items); $this->date_components[$level] = (int)$key; - } - } - if ( $conf['calendar_multi_bar']==false ) - { - if ( $level<count($this->date_components) and - $level!=count($this->calendar_levels)-1 ) - { - return; + if ( $level<count($this->date_components) and + $level!=count($this->calendar_levels)-1 ) + { + return; + } } } @@ -237,15 +260,10 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql'] $url_base .= $this->date_components[$i].'-'; } } - $selected = null; - if ( isset($this->date_components[$level]) ) - { - $selected = $this->date_components[$level]; - } $nav_bar = $this->get_nav_bar_from_items( $url_base, $level_items, - $selected, + null, 'calItem', true, true, @@ -255,9 +273,76 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql'] $template->assign_block_vars( 'calendar.navbar', array( - 'BAR' => $nav_bar + 'BAR' => $nav_bar, ) ); + $this->has_nav_bar = true; + } + + /** + * Assigns the next/previous link to the template with regards to + * the currently choosen date. + */ + function build_next_prev() + { + global $template; + $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' ) + { + $query .= ','.$this->calendar_levels[$i]['sql']; + } + else + { + $query .= ','.'"any"'; + } + $current .= '-' . $this->date_components[$i]; + } + $current = substr($current, 1); + + $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); + $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]; + $template->assign_block_vars( + 'calendar.navbar.prev', + array( + 'LABEL' => $this->get_date_nice_name($prev), + 'URL' => $this->url_base . $prev, + ) + ); + } + if ( $current_rank < count($upper_items)-1 ) + { + // has next + $next = $upper_items[$current_rank+1]; + $template->assign_block_vars( + 'calendar.navbar.next', + array( + 'LABEL' => $this->get_date_nice_name($next), + 'URL' => $this->url_base . $next, + ) + ); + } } } ?>
\ No newline at end of file diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php index 107c98634..81978f963 100644 --- a/include/calendar_monthly.class.php +++ b/include/calendar_monthly.class.php @@ -93,31 +93,33 @@ function generate_category_content($url_base, $view_type) if ( count($this->date_components)==2 ) {//case C: year+month given - display a nice month calendar $this->build_month_calendar(); - $this->build_nav_bar(CYEAR); // years - $this->build_nav_bar(CMONTH); // month + //$this->build_nav_bar(CYEAR); // years + //$this->build_nav_bar(CMONTH); // month + $this->build_next_prev(); return true; } } if ($view_type==CAL_VIEW_LIST or count($this->date_components)==3) { - if ( count($this->date_components)>=0 ) + $has_nav_bar = false; + if ( count($this->date_components)==0 ) { $this->build_nav_bar(CYEAR); // years } - if ( count($this->date_components)>=1) + if ( count($this->date_components)==1) { $this->build_nav_bar(CMONTH); // month } - if ( count($this->date_components)>=2 ) + if ( count($this->date_components)==2 ) { - $this->build_nav_bar( - CDAY, - range( 1, $this->get_all_days_in_month( - $this->date_components[CYEAR] ,$this->date_components[CMONTH] ) - ) - ); // days + $day_labels = range( 1, $this->get_all_days_in_month( + $this->date_components[CYEAR] ,$this->date_components[CMONTH] ) ); + array_unshift($day_labels, 0); + unset( $day_labels[0] ); + $this->build_nav_bar( CDAY, $day_labels ); // days } + $this->build_next_prev(); } return false; } @@ -293,11 +295,6 @@ function build_year_calendar() { // only one month exists so bail out to month view list($m) = array_keys($items); $this->date_components[CMONTH] = $m; - if (count($items[$m]['children'])==1) - { // or even to day view if everything occured in one day - list($d) = array_keys($items[$m]['children']); - $this->date_components[CDAY] = $d; - } return false; } global $lang, $template; diff --git a/include/calendar_weekly.class.php b/include/calendar_weekly.class.php index 786f90c68..817acb1b0 100644 --- a/include/calendar_weekly.class.php +++ b/include/calendar_weekly.class.php @@ -80,15 +80,19 @@ function generate_category_content($url_base, $view_type) assert($view_type==CAL_VIEW_LIST); - $this->build_nav_bar(CYEAR); // years - if ( count($this->date_components)>=1 ) + if ( count($this->date_components)==0 ) + { + $this->build_nav_bar(CYEAR); // years + } + if ( count($this->date_components)==1 ) { $this->build_nav_bar(CWEEK); // week nav bar 1-53 } - if ( count($this->date_components)>=2 ) + if ( count($this->date_components)==2 ) { $this->build_nav_bar(CDAY); // days nav bar Mon-Sun } + $this->build_next_prev(); return false; } diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 5a61c12e3..c9c0f80af 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -90,10 +90,6 @@ $conf['anti-flood_time'] = 60; // catgory $conf['calendar_datefield'] = 'date_creation'; -// calendar_multi_bar : the calendar shows a maximum number of -// year/month/week/day navigation bars -$conf['calendar_multi_bar'] = true; - // calendar_show_any : the calendar shows an aditional 'any' button in the // year/month/week/day navigation bars $conf['calendar_show_any'] = true; diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php index 1606b4307..f9404467a 100644 --- a/include/functions_calendar.inc.php +++ b/include/functions_calendar.inc.php @@ -260,24 +260,20 @@ WHERE id IN (' . implode(',',$page['items']) .')'; } } } + $calendar_title = + '<a href="'.$url_base.$cal_style.'-'.$cal_view.'">' + .$fields[$cal_field]['label'].'</a>'; + $calendar_title.= $calendar->get_display_name(); + //this should be an assign_block_vars, but I need to assign 'calendar' + //above and at that point I don't have the title yet. + $template->_tpldata['calendar.'][0]['TITLE'] = $calendar_title; } // end category calling - $calendar_title = - '<a href="'.$url_base.$cal_style.'-'.$cal_view.'">' - .$fields[$cal_field]['label'].'</a>'; - $calendar_title.= $calendar->get_display_name(); - $template->assign_block_vars( - 'calendar', - array( - 'TITLE' => '<br/>'.$calendar_title, - ) - ); - if ($must_show_list) { $query = 'SELECT DISTINCT(id)'; - $query .= $calendar->inner_sql; - $query .= $calendar->get_date_where(); + $query .= $calendar->inner_sql.' + '.$calendar->get_date_where(); if ( isset($page['super_order_by']) ) { $query .= ' @@ -289,7 +285,8 @@ WHERE id IN (' . implode(',',$page['items']) .')'; 'ORDER BY ', 'ORDER BY '.$calendar->date_field.' DESC,', $conf['order_by'] ); - $query .= $order_by; + $query .= ' + '.$order_by; } $page['items'] = array_from_query($query, 'id'); diff --git a/template/yoga/category.tpl b/template/yoga/category.tpl index 379004e73..7d75751c2 100644 --- a/template/yoga/category.tpl +++ b/template/yoga/category.tpl @@ -141,26 +141,37 @@ <!-- END mode_created --> </ul> - <h2>{TITLE} + <h2>{TITLE}</h2> <!-- BEGIN calendar --> - {calendar.TITLE} + <!-- BEGIN views --> + <div class="calendarViews">{lang:calendar_view}: + <select onchange="document.location = this.options[this.selectedIndex].value;"> + <!-- BEGIN view --> + <option value="{calendar.views.view.VALUE}" {calendar.views.view.SELECTED}>{calendar.views.view.CONTENT}</option> + <!-- END view --> + </select> + </div> + <!-- END views --> <!-- END calendar --> - </h2> + + <!-- BEGIN calendar --> + <h2>{calendar.TITLE} +</h2> + <!-- END calendar --> + </div> <!-- content --> <!-- BEGIN calendar --> -<!-- BEGIN views --> -<div class="calendarViews"> -{lang:calendar_view}: <select onchange="document.location = this.options[this.selectedIndex].value;"> -<!-- BEGIN view --> - <option value="{calendar.views.view.VALUE}" {calendar.views.view.SELECTED}>{calendar.views.view.CONTENT}</option> -<!-- END view --> -</select> -</div> -<!-- END views --> - <!-- BEGIN navbar --> -<div class="calendarBar">{calendar.navbar.BAR}</div> +<div class="calendarBar"> +<!-- BEGIN prev --> + <div style="float:left">« <a href="{calendar.navbar.prev.URL}">{calendar.navbar.prev.LABEL}</a></div> +<!-- END prev --> +<!-- BEGIN next --> + <div style="float:right"><a href="{calendar.navbar.next.URL}">{calendar.navbar.next.LABEL}</a> »</div> +<!-- END next --> + {calendar.navbar.BAR} +</div> <!-- END navbar --> <!-- BEGIN calbar --> diff --git a/template/yoga/content.css b/template/yoga/content.css index 6f3c440c4..6decb64f4 100644 --- a/template/yoga/content.css +++ b/template/yoga/content.css @@ -182,31 +182,18 @@ SPAN.filename:after { /* begin chronology/calendar elements*/ #content DIV.calendarViews { display: block; - text-align: left; - margin: 5px 0; + float: right; + margin: 2px 2px; } -#content DIV.calendarBar { - margin: 8px 4px; -} +#content DIV.calendarBar { margin: 8px 4px; } -SPAN.calItem { +SPAN.calItem, SPAN.calItemEmpty { font-weight: bold; - margin: 0 2px; - border: 1px solid gray; + margin: 0 1px; } -SPAN.calItemSel { - font-weight: bold; - margin: 0 2px; - border: 1px solid gray; -} - -SPAN.calItemEmpty { - font-weight: bold; - margin: 0 2px; - border: 1px solid gray; -} +SPAN.calItem A { border:0 } #content DIV.calendarCalBar { margin: 10px 10px; @@ -219,9 +206,7 @@ SPAN.calCalHead { margin: 0 2px; } -SPAN.calCal { - margin: 0 2px; -} +SPAN.calCal { margin: 0 2px; } /* nice looking month calendar*/ .calMonth { border: none; border-collapse: collapse; } diff --git a/template/yoga/theme/clear/theme.css b/template/yoga/theme/clear/theme.css index 92216df92..07cdffabb 100644 --- a/template/yoga/theme/clear/theme.css +++ b/template/yoga/theme/clear/theme.css @@ -78,15 +78,17 @@ A.navThumb, A.navThumb:hover { } /*calendar elements*/ -SPAN.calItemSel { color: dark-gray; } - -SPAN.calItemEmpty { color: lightgray; } +SPAN.calItemEmpty { color: silver; } +SPAN.calItem, SPAN.calItemEmpty +{ + border: 1px solid silver; +} /* nice looking month calendar*/ TD.calDayCellEmpty, TD.calDayCellFull { border: 1px solid #7E7262;} -TD.calDayCellEmpty { color: lightgray; } +TD.calDayCellEmpty { color: silver; } .calBackDate { color: #000; } .calForeDate { color: #fff; } diff --git a/template/yoga/theme/dark/theme.css b/template/yoga/theme/dark/theme.css index 746e57bc3..157c7c371 100644 --- a/template/yoga/theme/dark/theme.css +++ b/template/yoga/theme/dark/theme.css @@ -115,14 +115,17 @@ A.navThumb, A.navThumb:hover { } /*calendar elements*/ -SPAN.calItemSel { color: #fff48e; } +SPAN.calItemEmpty { color: silver; } -SPAN.calItemEmpty { color: darkgray; } +SPAN.calItem, SPAN.calItemEmpty +{ + border: 1px solid gray; +} /* nice looking month calendar*/ TD.calDayCellEmpty, TD.calDayCellFull { border: 1px solid gray;} -TD.calDayCellEmpty { color: lightgray; } +TD.calDayCellEmpty { color: silver; } .calBackDate { color: #000; } .calForeDate { color: #fff; } |