diff options
Diffstat (limited to '')
-rw-r--r-- | category.php | 2 | ||||
-rw-r--r-- | include/calendar_base.class.php | 51 | ||||
-rw-r--r-- | include/calendar_monthly.class.php | 200 | ||||
-rw-r--r-- | include/calendar_weekly.class.php | 87 | ||||
-rw-r--r-- | include/config_default.inc.php | 8 | ||||
-rw-r--r-- | include/functions_calendar.inc.php | 253 | ||||
-rw-r--r-- | picture.php | 24 | ||||
-rw-r--r-- | template/yoga/category.tpl | 20 | ||||
-rw-r--r-- | template/yoga/content.css | 6 |
9 files changed, 392 insertions, 259 deletions
diff --git a/category.php b/category.php index e466a5bb2..38d18e11f 100644 --- a/category.php +++ b/category.php @@ -301,7 +301,7 @@ $template->assign_block_vars( $template->assign_block_vars( 'special_cat', array( - 'URL' => PHPWG_ROOT_PATH.'category.php?calendar=m-c', + 'URL' => PHPWG_ROOT_PATH.'category.php?calendar=monthly-c', 'TITLE' => $lang['calendar_hint'], 'NAME' => $lang['calendar'] )); diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php index e9194eb90..1a7b54989 100644 --- a/include/calendar_base.class.php +++ b/include/calendar_base.class.php @@ -35,25 +35,41 @@ class CalendarBase var $inner_sql; // base url used when generating html links var $url_base; + // array of date components e.g. (2005,10,12) ... + var $date_components; - function get_date_where() - { - die("get_date_where not extended"); - } /** * Initialize the calendar * @param string date_field db column on which this calendar works * @param string inner_sql used for queries (INNER JOIN or normal) + * @param array date_components */ - function initialize($date_field, $inner_sql) + function initialize($date_field, $inner_sql, $date_components) { $this->date_field = $date_field; $this->inner_sql = $inner_sql; + $this->date_components = $date_components; } //--------------------------------------------------------- private members --- - + /** + * Returns a display name for a date component optionally using labels + */ + function get_date_component_label($date_component, $labels=null) + { + $label = $date_component; + if (isset($labels[$date_component])) + { + $label = $labels[$date_component]; + } + elseif ($date_component == 'any' ) + { + $label = l10n('calendar_any'); + } + return $label; + } + /** * Creates a calendar navigation bar. * @@ -96,8 +112,8 @@ class CalendarBase } $nav_bar.= '</span>'; } - - if ($allow_any and count($items) > 1) + global $conf; + if ($conf['calendar_show_any'] and $allow_any and count($items) > 1) { $label = l10n('calendar_any'); if (isset($selected_item) and 'any' == $selected_item) @@ -121,14 +137,12 @@ class CalendarBase /** * Creates a calendar navigation bar for a given level. * - * @param string view_type - list or calendar (e.g. 'l' or 'c') - * @param array requested - array of current selected elements (e.g. 2005,10) * @param string sql_func - YEAR/MONTH/DAY/WEEK/DAYOFWEEK ... * @param string sql_offset - (e.g. +1 for WEEK - first in year is 1) * @param array labels - optional labels to show in the navigation bar * @return void */ - function build_nav_bar($view_type, $requested, $level, $sql_func, + function build_nav_bar($level, $sql_func, $sql_offset='', $labels=null) { global $template; @@ -137,7 +151,7 @@ class CalendarBase SELECT DISTINCT('.$sql_func.'('.$this->date_field.')'.$sql_offset .') as period'; $query.= $this->inner_sql; - $query.= $this->get_date_where($requested, $level); + $query.= $this->get_date_where($level); $query.= ' GROUP BY period ;'; @@ -150,19 +164,22 @@ SELECT DISTINCT('.$sql_func.'('.$this->date_field.')'.$sql_offset } $url_base = $this->url_base; - $url_base .= $view_type.'-'; for ($i=0; $i<$level; $i++) { - if (isset($requested[$i])) + if (isset($this->date_components[$i])) { - $url_base .= $requested[$i].'-'; + $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, - isset($requested[$level]) ? $requested[$level] : null, + $selected, 'cal', true, $labels diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php index 8d6b60393..e628cd44b 100644 --- a/include/calendar_monthly.class.php +++ b/include/calendar_monthly.class.php @@ -26,6 +26,10 @@ include_once(PHPWG_ROOT_PATH.'include/calendar_base.class.php'); +define ('CYEAR', 0); +define ('CMONTH', 1); +define ('CDAY', 2); + /** * Monthly calendar style (composed of years/months and days) */ @@ -37,43 +41,62 @@ class Calendar extends CalendarBase * @return boolean false to indicate that thumbnails * where not included here, true otherwise */ -function generate_category_content($url_base, $view_type, &$requested) +function generate_category_content($url_base, $view_type) { - global $lang; + global $lang, $conf; $this->url_base = $url_base; - if ($view_type==CAL_VIEW_CALENDAR and count($requested)==0) - {//case A: no year given - display all years+months - if ($this->build_global_calendar($requested)) - return true; - } + if ($view_type==CAL_VIEW_CALENDAR) + { + if ( count($this->date_components)==0 ) + {//case A: no year given - display all years+months + if ($this->build_global_calendar()) + return true; + } - if ($view_type==CAL_VIEW_CALENDAR and count($requested)==1) - {//case B: year given - display all days in given year - if ($this->build_year_calendar($requested)) - { - $this->build_nav_bar2($view_type, $requested, 0, 'YEAR'); // years - return true; + if ( count($this->date_components)==1 ) + {//case B: year given - display all days in given year + if ($this->build_year_calendar()) + { + if ( $conf['calendar_multi_bar'] ) + $this->build_nav_bar2(CYEAR, 'YEAR'); // years + return true; + } } - } - if ($view_type==CAL_VIEW_CALENDAR and count($requested)==2) - {//case C: year+month given - display a nice month calendar - $this->build_month_calendar($requested); - $this->build_nav_bar2(CAL_VIEW_CALENDAR, $requested, 0, 'YEAR'); // years - if (count($requested)>0) - $this->build_nav_bar2(CAL_VIEW_CALENDAR, $requested, 1, 'MONTH', $lang['month']); // month - return true; + if ( count($this->date_components)==2 ) + {//case C: year+month given - display a nice month calendar + $this->build_month_calendar(); + if ( $conf['calendar_multi_bar'] ) + { + $this->build_nav_bar2(CYEAR, 'YEAR'); // years + } + if (count($this->date_components)>=1 and + ( $conf['calendar_multi_bar'] or count($this->date_components)==1 ) ) + { + $this->build_nav_bar2(CMONTH, 'MONTH', $lang['month']); // month + } + return true; + } } - if ($view_type==CAL_VIEW_LIST or count($requested)==3) + if ($view_type==CAL_VIEW_LIST or count($this->date_components)==3) { - $this->build_nav_bar2($view_type, $requested, 0, 'YEAR'); // years - if (count($requested)>0) - $this->build_nav_bar2($view_type, $requested, 1, 'MONTH', $lang['month']); // month - if (count($requested)>1) - $this->build_nav_bar2($view_type, $requested, 2, 'DAYOFMONTH' ); // days + if ( $conf['calendar_multi_bar'] or count($this->date_components)==0 ) + { + $this->build_nav_bar2(CYEAR, 'YEAR'); // years + } + if ( count($this->date_components)>=1 and + ( $conf['calendar_multi_bar'] or count($this->date_components)==1 ) + ) + { + $this->build_nav_bar2(CMONTH, 'MONTH', $lang['month']); // month + } + if ( count($this->date_components)>=2 ) + { + $this->build_nav_bar2(CDAY, 'DAYOFMONTH' ); // days + } } return false; } @@ -81,31 +104,30 @@ function generate_category_content($url_base, $view_type, &$requested) /** * Returns a sql where subquery for the date field - * @param array requested selected levels for this calendar - * (e.g. 2005,11,5 for 5th of November 2005) * @param int max_levels return the where up to this level * (e.g. 2=only year and month) * @return string */ -function get_date_where($requested, $max_levels=3) +function get_date_where($max_levels=3) { - while (count($requested)>$max_levels) + $date = $this->date_components; + while (count($date)>$max_levels) { - array_pop($requested); + array_pop($date); } $res = ''; - if (isset($requested[0]) and $requested[0]!='any') + if (isset($date[CYEAR]) and $date[CYEAR]!='any') { - $b = $requested[0] . '-'; - $e = $requested[0] . '-'; - if (isset($requested[1]) and $requested[1]!='any') + $b = $date[CYEAR] . '-'; + $e = $date[CYEAR] . '-'; + if (isset($date[CMONTH]) and $date[CMONTH]!='any') { - $b .= $requested[1] . '-'; - $e .= $requested[1] . '-'; - if (isset($requested[2]) and $requested[2]!='any') + $b .= $date[CMONTH] . '-'; + $e .= $date[CMONTH] . '-'; + if (isset($date[CDAY]) and $date[CDAY]!='any') { - $b .= $requested[2]; - $e .= $requested[2]; + $b .= $date[CDAY]; + $e .= $date[CDAY]; } else { @@ -117,13 +139,13 @@ function get_date_where($requested, $max_levels=3) { $b .= '01-01'; $e .= '12-31'; - if (isset($requested[1]) and $requested[1]!='any') + if (isset($date[CMONTH]) and $date[CMONTH]!='any') { - $res .= ' AND MONTH('.$this->date_field.')='.$requested[1]; + $res .= ' AND MONTH('.$this->date_field.')='.$date[CMONTH]; } - if (isset($requested[2]) and $requested[2]!='any') + if (isset($date[2]) and $date[2]!='any') { - $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$requested[2]; + $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$date[CDAY]; } } $res = " AND $this->date_field BETWEEN '$b' AND '$e 23:59:59'" . $res; @@ -131,31 +153,72 @@ function get_date_where($requested, $max_levels=3) else { $res = ' AND '.$this->date_field.' IS NOT NULL'; - if (isset($requested[1]) and $requested[1]!='any') + if (isset($date[CMONTH]) and $date[CMONTH]!='any') { - $res .= ' AND MONTH('.$this->date_field.')='.$requested[1]; + $res .= ' AND MONTH('.$this->date_field.')='.$date[CMONTH]; } - if (isset($requested[2]) and $requested[2]!='any') + if (isset($date[CDAY]) and $date[CDAY]!='any') { - $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$requested[2]; + $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$date[CDAY]; } } return $res; } + +function get_display_name() +{ + global $conf, $lang; + $res = ''; + $url = $this->url_base; + if ( isset($this->date_components[CYEAR]) ) + { + $res .= $conf['level_separator']; + $url .= $this->date_components[CYEAR].'-'; + $res .= + '<a href="'.$url.'">' + .$this->get_date_component_label($this->date_components[CYEAR]) + .'</a>'; + } + if ( isset($this->date_components[CMONTH]) ) + { + $res .= $conf['level_separator']; + $url .= $this->date_components[CMONTH].'-'; + $res .= + '<a href="'.$url.'">' + .$this->get_date_component_label( + $this->date_components[CMONTH], + $lang['month'] + ) + .'</a>'; + } + if ( isset($this->date_components[CDAY]) ) + { + $res .= $conf['level_separator']; + $url .= $this->date_components[CDAY].'-'; + $res .= + '<a href="'.$url.'">' + .$this->get_date_component_label($this->date_components[CDAY]) + .'</a>'; + } + + return $res; +} + + //--------------------------------------------------------- private members --- -function build_nav_bar2($view_type, $requested, $level, $sql_func, $labels=null) +function build_nav_bar2($level, $sql_func, $labels=null) { - parent::build_nav_bar($view_type, $requested, $level, $sql_func, '', $labels); + parent::build_nav_bar($level, $sql_func, '', $labels); } -function build_global_calendar(&$requested) +function build_global_calendar() { - assert( count($requested) == 0 ); + assert( count($this->date_components) == 0 ); $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%Y%m")) as period, COUNT(id) as count'; $query.= $this->inner_sql; - $query.= $this->get_date_where($requested); + $query.= $this->get_date_where(); $query.= ' GROUP BY period'; @@ -175,14 +238,14 @@ function build_global_calendar(&$requested) if (count($items)==1) {// only one year exists so bail out to year view list($y) = array_keys($items); - array_push($requested, $y ); + $this->date_components[CYEAR] = $y; return false; } global $lang, $template; foreach ( $items as $year=>$year_data) { - $url_base = $this->url_base .'c-'.$year; + $url_base = $this->url_base.$year; $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">'.$year.'</a>'; $nav_bar .= ' ('.$year_data['nb_images'].')'; @@ -199,13 +262,13 @@ function build_global_calendar(&$requested) return true; } -function build_year_calendar(&$requested) +function build_year_calendar() { - assert( count($requested) == 1 ); + assert( count($this->date_components) == 1 ); $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%m%d")) as period, COUNT(id) as count'; $query.= $this->inner_sql; - $query.= $this->get_date_where($requested); + $query.= $this->get_date_where(); $query.= ' GROUP BY period'; @@ -225,18 +288,18 @@ function build_year_calendar(&$requested) if (count($items)==1) { // only one month exists so bail out to month view list($m) = array_keys($items); - array_push($requested, $m ); + $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']); - array_push($requested, $d); + $this->date_components[CDAY] = $d; } return false; } global $lang, $template; foreach ( $items as $month=>$month_data) { - $url_base = $this->url_base.'c-'.$requested[0].'-'.$month; + $url_base = $this->url_base.$this->date_components[CYEAR].'-'.$month; $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">'; $nav_bar .= $lang['month'][$month].'</a>'; @@ -255,12 +318,12 @@ function build_year_calendar(&$requested) } -function build_month_calendar($requested) +function build_month_calendar() { $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%d")) as period, COUNT(id) as count'; $query.= $this->inner_sql; - $query.= $this->get_date_where($requested, 2); + $query.= $this->get_date_where($this->date_components); $query.= ' GROUP BY period'; @@ -277,15 +340,18 @@ function build_month_calendar($requested) $template->assign_block_vars('thumbnails.line', array()); foreach ( $items as $day=>$nb_images) { - $url_base = $this->url_base.'c-'.$requested[0].'-'.$requested[1].'-'.$day; - $requested[2]=$day; + $url_base = $this->url_base. + $this->date_components[CYEAR].'-'. + $this->date_components[CMONTH].'-'.$day; + $this->date_components[CDAY]=$day; $query = ' SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw'; $query.= $this->inner_sql; - $query.= $this->get_date_where($requested); + $query.= $this->get_date_where(); $query.= ' ORDER BY RAND() LIMIT 0,1'; + unset ( $this->date_components[CDAY] ); $row = mysql_fetch_array(pwg_query($query)); diff --git a/include/calendar_weekly.class.php b/include/calendar_weekly.class.php index 3e591eecd..5ab550e29 100644 --- a/include/calendar_weekly.class.php +++ b/include/calendar_weekly.class.php @@ -26,6 +26,10 @@ include_once(PHPWG_ROOT_PATH.'include/calendar_base.class.php'); +define ('CYEAR', 0); +define ('CWEEK', 1); +define ('CDAY', 2); + /** * Weekly calendar style (composed of years/week in years and days in week) */ @@ -36,52 +40,61 @@ class Calendar extends CalendarBase * Generate navigation bars for category page * @return boolean false to indicate that thumbnails where not included here */ -function generate_category_content($url_base, $view_type, &$requested) +function generate_category_content($url_base, $view_type) { - global $lang; + global $lang, $conf; $this->url_base = $url_base; assert($view_type==CAL_VIEW_LIST); - $this->build_nav_bar($view_type, $requested, 0, 'YEAR'); // years - if (count($requested)>0) - $this->build_nav_bar($view_type, $requested, 1, 'WEEK', '+1' ); // month - if (count($requested)>1) - $this->build_nav_bar($view_type, $requested, 2, 'DAYOFWEEK', '-1', + if ( $conf['calendar_multi_bar'] or count($this->date_components)==0 ) + { + $this->build_nav_bar(CYEAR, 'YEAR'); // years + } + if ( count($this->date_components)>=1 and + ( $conf['calendar_multi_bar'] or count($this->date_components)==1 ) + ) + { + $this->build_nav_bar(CWEEK, 'WEEK', '+1' ); // month + } + if ( count($this->date_components)>=2 ) + { + $this->build_nav_bar(CDAY, 'DAYOFWEEK', '-1', $lang['day'] ); // days + } return false; } /** * Returns a sql where subquery for the date field - * @param array requested selected levels for this calendar - * (e.g. 2005,42,1 for 41st week of 2005, Monday) * @param int max_levels return the where up to this level * (e.g. 2=only year and week in year) * @return string */ -function get_date_where($requested, $max_levels=3) +function get_date_where($max_levels=3) { - while (count($requested)>$max_levels) + $date_components = $this->date_components; + while (count($date_components)>$max_levels) { - array_pop($requested); + array_pop($date_components); } $res = ''; - if (isset($requested[0]) and $requested[0]!='any') + if (isset($date_components[CYEAR]) and $date_components[CYEAR]!='any') { - $y = $requested[0]; + $y = $date_components[CYEAR]; $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'"; } - if (isset($requested[1]) and $requested[1]!='any') + if (isset($date_components[CWEEK]) and $date_components[CWEEK]!='any') { - $res .= ' AND WEEK('.$this->date_field.')+1='.$requested[1]; + $res .= ' AND WEEK('.$this->date_field.')+1='.$date_components[CWEEK]; } - if (isset($requested[2]) and $requested[2]!='any') + if (isset($date_components[CDAY]) and $date_components[CDAY]!='any') { - $res .= ' AND DAYOFWEEK('.$this->date_field.')-1='.$requested[2]; + $res .= ' AND DAYOFWEEK('.$this->date_field.')-1=' + .$date_components[CDAY]; } if (empty($res)) { @@ -90,6 +103,44 @@ function get_date_where($requested, $max_levels=3) return $res; } +function get_display_name() +{ + global $conf,$lang; + $res = ''; + $url = $this->url_base; + if ( isset($this->date_components[CYEAR]) ) + { + $res .= $conf['level_separator']; + $url .= $this->date_components[CYEAR].'-'; + $res .= + '<a href="'.$url.'">' + .$this->get_date_component_label($this->date_components[CYEAR]) + .'</a>'; + } + if ( isset($this->date_components[CWEEK]) ) + { + $res .= $conf['level_separator']; + $url .= $this->date_components[CWEEK].'-'; + $res .= + '<a href="'.$url.'">' + .$this->get_date_component_label($this->date_components[CWEEK]) + .'</a>'; + } + if ( isset($this->date_components[CDAY]) ) + { + $res .= $conf['level_separator']; + $url .= $this->date_components[CDAY].'-'; + $res .= + '<a href="'.$url.'">' + .$this->get_date_component_label( + $this->date_components[CDAY], + $lang['day'] + ) + .'</a>'; + } + return $res; +} + } ?>
\ No newline at end of file diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 78121af0f..a21351241 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -90,6 +90,14 @@ $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; + // newcat_default_commentable : at creation, must a category be commentable // or not ? $conf['newcat_default_commentable'] = 'true'; diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php index 43ca188ef..6f6a5f44b 100644 --- a/include/functions_calendar.inc.php +++ b/include/functions_calendar.inc.php @@ -27,6 +27,25 @@ define('CAL_VIEW_LIST', 'l'); define('CAL_VIEW_CALENDAR', 'c'); +function get_calendar_parameter($options, &$parameters ) +{ + if ( count($parameters) and isset($options[$parameters[0]]) ) + { + return array_shift($parameters); + } + else + { + foreach ($options as $option => $data) + { + if ( empty( $data['default_link'] ) ) + { + break; + } + } + return $option; + } +} + function initialize_calendar() { global $page, $conf, $user, $template; @@ -73,65 +92,76 @@ WHERE id IN (' . implode(',',$page['items']) .')'; //-------------------------------------- initialize the calendar parameters --- pwg_debug('start initialize_calendar'); - - $cal_styles = array( + // the parameters look like (FIELD)?(STYLE)?(VIEW)?(DATE COMPONENTS)? + // FIELD = (created-|posted-) + // STYLE = (m-|w-) + // VIEW = (l-|c-) + // DATE COMPONENTS= YEAR(-MONTH/WEEK)?(-DAY)? + + $fields = array( + // Created + 'created' => array( + // TODO change next line when calendar_datefield disapears + 'default_link' => ( $conf['calendar_datefield']=='date_creation' ? '' : 'created-' ), + 'label' => l10n('Creation date'), + 'db_field' => 'date_creation', + ), + // Posted + 'posted' => array( + // TODO change next line when calendar_datefield disapears + 'default_link' => ( $conf['calendar_datefield']=='date_available' ? '' : 'posted-' ), + 'label' => l10n('Availability date'), + 'db_field' => 'date_available', + ), + ); + + $styles = array( // Monthly style - array( - 'link' => 'm', + 'monthly' => array( 'default_link' => '', - 'name' => l10n('Monthly'), + 'label' => l10n('Monthly'), 'include' => 'calendar_monthly.class.php', 'view_calendar' => true, ), // Weekly style - array( - 'link' => 'w', - 'default_link' => 'w-', - 'name' => l10n('Weekly'), + 'weekly' => array( + 'default_link' => 'weekly-', + 'label' => l10n('Weekly'), 'include' => 'calendar_weekly.class.php', 'view_calendar' => false, ), ); + $views = array( + // list view + CAL_VIEW_LIST => array( + 'default_link' => '', + 'label' => l10n('List') + ), + // calendar view + CAL_VIEW_CALENDAR => array( + 'default_link' => CAL_VIEW_CALENDAR.'-', + 'label' => l10n('calendar') + ), + ); + $requested = explode('-', $_GET['calendar']); - $calendar = null; - foreach ($cal_styles as $cal_style) - { - if ($requested[0] == $cal_style['link']) - { - include(PHPWG_ROOT_PATH.'include/'.$cal_style['include']); - $calendar = new Calendar(); - array_shift($requested); - break; - } - } - if (!isset($calendar)) - { - foreach($cal_styles as $cal_style) - { - if ('' == $cal_style['default_link']) - { - break; - } - } - include( PHPWG_ROOT_PATH.'include/'.$cal_style['include']); - $calendar = new Calendar(); - } + // Retrieve calendar field + $cal_field = get_calendar_parameter($fields, $requested); + + // Retrieve style + $cal_style = get_calendar_parameter($styles, $requested); + include(PHPWG_ROOT_PATH.'include/'. $styles[$cal_style]['include']); + $calendar = new Calendar(); - $view_type = CAL_VIEW_LIST; - if ($requested[0] == CAL_VIEW_LIST) - { - array_shift($requested); - } - elseif ($requested[0] == CAL_VIEW_CALENDAR) + // Retrieve view + $cal_view = get_calendar_parameter($views, $requested); + if ( CAL_VIEW_CALENDAR==$cal_view and !$styles[$cal_style]['view_calendar'] ) { - if ($cal_style['view_calendar']) - { - $view_type = CAL_VIEW_CALENDAR; - } - array_shift($requested); + $cal_view=CAL_VIEW_LIST; } + // perform a sanity check on $requested while (count($requested) > 3) { @@ -143,7 +173,7 @@ WHERE id IN (' . implode(',',$page['items']) .')'; { if ($requested[$i] == 'any') { - if ($view_type == CAL_VIEW_CALENDAR) + if ($cal_view == CAL_VIEW_CALENDAR) {// we dont allow any in calendar view while ($i < count($requested)) { @@ -165,29 +195,26 @@ WHERE id IN (' . implode(',',$page['items']) .')'; { array_pop($requested); } + + $calendar->initialize($fields[$cal_field]['db_field'], $inner_sql, $requested); + + //echo ('<pre>'. var_export($fields, true) . '</pre>'); - $calendar->initialize($conf['calendar_datefield'], $inner_sql); - //echo ('<pre>'. var_export($requested, true) . '</pre>'); - //echo ('<pre>'. var_export($calendar, true) . '</pre>'); + $url_base = + PHPWG_ROOT_PATH.'category.php' + .get_query_string_diff(array('start', 'calendar')) + .(empty($url_base) ? '?' : '&') + .'calendar='.$cal_field.'-' + ; - // TODO: what makes the list view required? - $must_show_list = true; - + $must_show_list = true; // true until calendar generates its own display if (basename($_SERVER["PHP_SELF"]) == 'category.php') { $template->assign_block_vars('calendar', array()); - $url_base = - PHPWG_ROOT_PATH.'category.php' - .get_query_string_diff(array('start', 'calendar')) - .(empty($url_base) ? '?' : '&') - .'calendar=' - ; - if ($calendar->generate_category_content( - $url_base.$cal_style['default_link'], - $view_type, - $requested + $url_base.$cal_style.'-'.$cal_view.'-', + $cal_view ) ) { @@ -199,82 +226,60 @@ WHERE id IN (' . implode(',',$page['items']) .')'; $must_show_list = false; } - - if ($cal_style['view_calendar']) - { // Build bar for views (List/Calendar) - $views = array( - // list view - array( - 'type' => CAL_VIEW_LIST, - 'label' => l10n('List') - ), - // calendar view - array( - 'type' => CAL_VIEW_CALENDAR, - 'label' => l10n('calendar') - ), - ); - - $views_bar = ''; - - foreach ($views as $view) - { - if ($view_type != $view['type']) - { - $views_bar.= - '<a href="' - .$url_base.$cal_style['default_link'].$view['type'].'-' - .implode('-', $requested) - .'">'.$view['label'].'</a> '; - } - else - { - $views_bar.= $view['label'].' '; - } - - $views_bar.= ' '; - } - - $template->assign_block_vars( - 'calendar.views', - array( - 'BAR' => $views_bar, - ) - ); - } - - // Build bar for calendar styles (Monthly, Weekly) - $styles_bar = ''; - foreach ($cal_styles as $style) + + $template->assign_block_vars( 'calendar.views', array() ); + foreach ($styles as $style => $style_data) { - if ($cal_style['link'] != $style['link']) + foreach ($views as $view => $view_data) { - $url = $url_base.$style['default_link']; - $url .= $view_type; - if (isset($requested[0])) + if ( $style_data['view_calendar'] or $view != CAL_VIEW_CALENDAR) { - $url .= '-' . $requested[0]; + $selected = ''; + $url = $url_base.$style.'-'.$view; + if ($style==$cal_style) + { + $url .= '-'.implode('-', $calendar->date_components); + if ( $view==$cal_view ) + { + $selected = 'SELECTED'; + } + } + else + { + if (isset($calendar->date_components[0])) + { + $url .= '-' . $calendar->date_components[0]; + } + } + $template->assign_block_vars( + 'calendar.views.view', + array( + 'VALUE' => $url, + 'CONTENT' => $style_data['label'].' ('.$view_data['label'].')', + 'SELECTED' => $selected, + ) + ); } - $styles_bar .= '<a href="'. $url . '">'.$style['name'].'</a> '; - } - else - { - $styles_bar .= $style['name'].' '; } } - $template->assign_block_vars( - 'calendar.styles', - array( - 'BAR' => $styles_bar, - ) - ); } // 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' => $calendar_title, + ) + ); + if ($must_show_list) { $query = 'SELECT DISTINCT(id)'; $query .= $calendar->inner_sql; - $query .= $calendar->get_date_where($requested); + $query .= $calendar->get_date_where(); if ( isset($page['super_order_by']) ) { $query .= ' diff --git a/picture.php b/picture.php index 000af4caf..2ae8e01b9 100644 --- a/picture.php +++ b/picture.php @@ -793,16 +793,9 @@ else if (!empty($picture['current']['date_creation'])) { $val = format_date($picture['current']['date_creation']); - if ( $conf['calendar_datefield'] == 'date_creation' ) - { - $infos['INFO_CREATION_DATE'] = '<a href="'. - PHPWG_ROOT_PATH.'category.php?calendar=c-'. + $infos['INFO_CREATION_DATE'] = '<a href="'. + PHPWG_ROOT_PATH.'category.php?calendar=created-c-'. $picture['current']['date_creation'].'">'.$val.'</a>'; - } - else - { - $infos['INFO_CREATION_DATE'] = $val; - } } else { @@ -811,16 +804,9 @@ else // date of availability $val = format_date($picture['current']['date_available'], 'mysql_datetime'); -if ( $conf['calendar_datefield'] == 'date_available' ) -{ - $infos['INFO_AVAILABILITY_DATE'] = '<a href="'. - PHPWG_ROOT_PATH.'category.php?calendar=c-'. - substr($picture['current']['date_available'],0,10).'">'.$val.'</a>'; -} -else -{ - $infos['INFO_AVAILABILITY_DATE'] = $val; -} +$infos['INFO_AVAILABILITY_DATE'] = '<a href="'. + PHPWG_ROOT_PATH.'category.php?calendar=posted-c-'. + substr($picture['current']['date_available'],0,10).'">'.$val.'</a>'; // size in pixels if ($picture['current']['is_picture']) diff --git a/template/yoga/category.tpl b/template/yoga/category.tpl index 11acfa853..0942a0f2d 100644 --- a/template/yoga/category.tpl +++ b/template/yoga/category.tpl @@ -138,19 +138,23 @@ <!-- END normal_view --> </ul> - <h2>{TITLE}</h2> - + <h2>{TITLE} + <!-- BEGIN calendar --> + <br/>{calendar.TITLE} + <!-- END calendar --></h2> </div> <!-- content --> <!-- BEGIN calendar --> -<!-- BEGIN styles --> -<div class="calendarStyles">Style: {calendar.styles.BAR}</div> -<!-- END styles --> - <!-- BEGIN views --> -<div class="calendarViews">{calendar.views.BAR}</div> +<div class="calendarViews"> +<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><br/> <!-- END views --> -<br/> + <!-- BEGIN navbar --> <div class="navigationBar">{calendar.navbar.BAR}</div> <!-- END navbar --> diff --git a/template/yoga/content.css b/template/yoga/content.css index cc85cbc1e..fa45ab676 100644 --- a/template/yoga/content.css +++ b/template/yoga/content.css @@ -179,12 +179,8 @@ SPAN.filename:after { } -#content DIV.calendarStyles { - float: left; -} - #content DIV.calendarViews { - float: right; + float: left; } SPAN.cal { |