diff --git a/category.php b/category.php index d8e93d1d5..4150a97c6 100644 --- a/category.php +++ b/category.php @@ -161,6 +161,17 @@ $calendar_view_link = PHPWG_ROOT_PATH.'category.php' if ( ! isset($_GET['calendar']) ) { $calendar_view_link .= (empty($_GET)? '?':'&' ) . 'calendar='; + $template->assign_block_vars( + 'calendar_view', + array( 'URL' => $calendar_view_link ) + ); +} +else +{ + $template->assign_block_vars( + 'normal_view', + array( 'URL' => $calendar_view_link ) + ); } $template->assign_vars( @@ -200,7 +211,6 @@ $template->assign_vars( 'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout', 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php', 'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php', - 'U_CALENDAR' => $calendar_view_link ) ); diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php new file mode 100644 index 000000000..1f120c811 --- /dev/null +++ b/include/calendar_base.class.php @@ -0,0 +1,165 @@ +date_field = $date_field; + $this->inner_sql = $inner_sql; +} + +//--------------------------------------------------------- private members --- +/** + * Creates a calendar navigation bar. + * @param string url_base - links start with this root + * @param array items - hash of items to put in the bar (e.g. 2005,2006) + * @param array selected_item - item currently selected (e.g. 2005) + * @param string class_prefix - html class attribute prefix for span elements + * @param bool allow_any - adds any to the end of the bar + * @param array labels - optional labels for items (e.g. Jan,Feb,...) + * @return string the navigation bar + */ +function get_nav_bar_from_items($url_base, $items, $selected_item, + $class_prefix, $allow_any, $labels=null) +{ + $nav_bar=''; + foreach ($items as $item => $nb_images) + { + $label = $item; + if (isset($labels[$item])) + { + $label = $labels[$item]; + } + if ( isset($selected_item) and $item==$selected_item ) + { + $nav_bar .= ''; + $nav_bar .= $label; + } + else + { + $nav_bar .= ''; + $url = $url_base . $item; + $nav_bar .= ''; + $nav_bar .= $label; + $nav_bar .= ''; + } + if ($nb_images>0) + { + $nav_bar .= '('.$nb_images.')'; + } + $nav_bar.= ''; + } + + if ($allow_any and count($items)>1 ) + { + $label = l10n('calendar_any'); + if ( isset($selected_item) and 'any'==$selected_item ) + { + $nav_bar .= ''; + $nav_bar .= $label; + } + else + { + $nav_bar .= ''; + $url = $url_base . 'any'; + $nav_bar .= ''; + $nav_bar .= $label; + $nav_bar .= ''; + } + $nav_bar.= ''; + } + return $nav_bar; +} + + +/** + * 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, + $sql_offset='', $labels=null) +{ + global $template; + $query = 'SELECT DISTINCT('.$sql_func.'('.$this->date_field.')'.$sql_offset + .') as period'; + $query.= $this->inner_sql; + $query.= $this->get_date_where($requested, $level); + $query.= ' + GROUP BY period'; + + $level_items=array(); + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $level_items[$row['period']] = 0; + } + + $url_base = $this->url_base; + $url_base .= $view_type.'-'; + for ($i=0; $i<$level; $i++) + { + if (isset($requested[$i])) + { + $url_base .= $requested[$i].'-'; + } + } + + $nav_bar = $this->get_nav_bar_from_items( $url_base, $level_items, + $requested[$level], 'cal', true, $labels); + + $template->assign_block_vars( 'calendar.navbar', + array( 'BAR' => $nav_bar) + ); +} +} + +?> \ No newline at end of file diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php new file mode 100644 index 000000000..cc50a6641 --- /dev/null +++ b/include/calendar_monthly.class.php @@ -0,0 +1,309 @@ +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 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 ($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 ($view_type==CAL_VIEW_LIST or count($requested)==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, 'DAY' ); // days + } + return false; +} + + +/** + * 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) +{ + while (count($requested)>$max_levels) + { + array_pop($requested); + } + $res = ''; + if (isset($requested[0]) and $requested[0]!='any') + { + $b = $requested[0] . '-'; + $e = $requested[0] . '-'; + if (isset($requested[1]) and $requested[1]!='any') + { + $b .= $requested[1] . '-'; + $e .= $requested[1] . '-'; + if (isset($requested[2]) and $requested[2]!='any') + { + $b .= $requested[2]; + $e .= $requested[2]; + } + else + { + $b .= '01'; + $e .= '31'; + } + } + else + { + $b .= '01-01'; + $e .= '12-31'; + if (isset($requested[1]) and $requested[1]!='any') + { + $res .= ' AND MONTH('.$this->date_field.')='.$requested[1]; + } + if (isset($requested[2]) and $requested[2]!='any') + { + $res .= ' AND DAY('.$this->date_field.')='.$requested[2]; + } + } + $res = " AND $this->date_field BETWEEN '$b' AND '$e'" . $res; + } + else + { + $res = ' AND '.$this->date_field.' IS NOT NULL'; + if (isset($requested[1]) and $requested[1]!='any') + { + $res .= ' AND MONTH('.$this->date_field.')='.$requested[1]; + } + if (isset($requested[2]) and $requested[2]!='any') + { + $res .= ' AND DAY('.$this->date_field.')='.$requested[2]; + } + } + return $res; +} + +//--------------------------------------------------------- private members --- +function build_nav_bar2($view_type, $requested, $level, $sql_func, $labels=null) +{ + parent::build_nav_bar($view_type, $requested, $level, $sql_func, '', $labels); +} + +function build_global_calendar(&$requested) +{ + $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, 0); + $query.= ' + GROUP BY period'; + + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $y = substr($row['period'], 0, 4); + $m = (int)substr($row['period'], 4, 2); + if ( ! isset($items[$y]) ) + { + $items[$y] = array('nb_images'=>0, 'children'=>array() ); + } + $items[$y]['children'][$m] = $row['count']; + $items[$y]['nb_images'] += $row['count']; + } + //echo ('
'. var_export($items, true) . '
'); + if (count($items)==1) + {// only one year exists so bail out to year view + list($y) = array_keys($items); + array_push($requested, $y ); + return false; + } + + global $lang, $template; + foreach ( $items as $year=>$year_data) + { + $url_base = $this->url_base .'c-'.$year; + + $nav_bar = ''.$year.''; + $nav_bar .= ' ('.$year_data['nb_images'].')'; + $nav_bar .= '
'; + + $url_base .= '-'; + $nav_bar .= $this->get_nav_bar_from_items( $url_base, $year_data['children'], $requested[0], 'calCal', false, $lang['month'] ); + + $template->assign_block_vars( 'calendar.calbar', + array( 'BAR' => $nav_bar) + ); + } + return true; +} + +function build_year_calendar(&$requested) +{ + $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, 1); + $query.= ' + GROUP BY period'; + + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $m = (int)substr($row['period'], 0, 2); + $d = substr($row['period'], 2, 2); + if ( ! isset($items[$m]) ) + { + $items[$m] = array('nb_images'=>0, 'children'=>array() ); + } + $items[$m]['children'][$d] = $row['count']; + $items[$m]['nb_images'] += $row['count']; + } + //echo ('
'. var_export($items, true) . '
'); + if (count($items)==1) + { // only one month exists so bail out to month view + list($m) = array_keys($items); + array_push($requested, $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); + } + return false; + } + global $lang, $template; + foreach ( $items as $month=>$month_data) + { + $url_base = $this->url_base.'c-'.$requested[0].'-'.$month; + + $nav_bar = ''.$lang['month'][$month].''; + $nav_bar .= ' ('.$month_data['nb_images'].')'; + $nav_bar .= '
'; + + $url_base .= '-'; + $nav_bar .= $this->get_nav_bar_from_items( $url_base, $month_data['children'], $requested[1], 'calCal', false ); + + $template->assign_block_vars( 'calendar.calbar', + array( 'BAR' => $nav_bar) + ); + } + return true; + +} + +function build_month_calendar($requested) +{ + $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.= ' + GROUP BY period'; + + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $d = $row['period']; + $items[$d] = $row['count']; + } + + global $lang, $template; + + $template->assign_block_vars('thumbnails', array()); + $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; + $query = ' +SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw'; + $query.= $this->inner_sql; + $query.= $this->get_date_where($requested); + + $row = mysql_fetch_array(pwg_query($query)); + + $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); + $thumbnail_title = $lang['day'][$row['dw']] . ' ' . $day; + $name = $thumbnail_title .' ('.$nb_images.')'; + + $template->assign_block_vars( + 'thumbnails.line.thumbnail', + array( + 'IMAGE'=>$thumbnail_src, + 'IMAGE_ALT'=>$row['file'], + 'IMAGE_TITLE'=>$thumbnail_title, + 'U_IMG_LINK'=>$url_base + ) + ); + $template->assign_block_vars( + 'thumbnails.line.thumbnail.category_name', + array( + 'NAME' => $name + ) + ); + } + return true; +} + +} + +?> \ No newline at end of file diff --git a/include/calendar_weekly.class.php b/include/calendar_weekly.class.php new file mode 100644 index 000000000..4ae65e076 --- /dev/null +++ b/include/calendar_weekly.class.php @@ -0,0 +1,95 @@ +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', + $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) +{ + while (count($requested)>$max_levels) + { + array_pop($requested); + } + $res = ''; + if (isset($requested[0]) and $requested[0]!='any') + { + $y = $requested[0]; + $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31'"; + } + + if (isset($requested[1]) and $requested[1]!='any') + { + $res .= ' AND WEEK('.$this->date_field.')+1='.$requested[1]; + } + if (isset($requested[2]) and $requested[2]!='any') + { + $res .= ' AND DAYOFWEEK('.$this->date_field.')-1='.$requested[2]; + } + if (empty($res)) + { + $res = ' AND '.$this->date_field.' IS NOT NULL'; + } + return $res; +} + +} + +?> \ No newline at end of file diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php index 9260bbbed..a5a1e87bb 100644 --- a/include/functions_calendar.inc.php +++ b/include/functions_calendar.inc.php @@ -5,9 +5,9 @@ // +-----------------------------------------------------------------------+ // | branch : BSF (Best So Far) // | file : $RCSfile$ -// | last update : $Date: 2006-02-12 16:52:16 -0500 (Sun, 12 Feb 2006) $ -// | last modifier : $Author: plg $ -// | revision : $Revision: 1036 $ +// | last update : $Date: 2006-01-27 02:11:43 +0100 (ven, 27 jan 2006) $ +// | last modifier : $Author: rvelices $ +// | revision : $Revision: 1014 $ // +-----------------------------------------------------------------------+ // | This program is free software; you can redistribute it and/or modify | // | it under the terms of the GNU General Public License as published by | @@ -24,193 +24,37 @@ // | USA. | // +-----------------------------------------------------------------------+ -class BaseCalendarLevel -{ - function BaseCalendarLevel($sql, $allow_any=true, $labels=null) - { - $this->sql = $sql; - $this->allow_any = $allow_any; - $this->labels = $labels; - } - - function sql() - { - return $this->sql; - } - function sql_equal($item) - { - return $this->sql.'='.$item; - } - function allow_any() - { - return $this->allow_any; - } - function get_label($item) - { - if ( isset($this->labels[$item]) ) - { - return $this->labels[$item]; - } - return $item; - } - - var $sql; - var $allow_any; - var $labels; -} - -class YearMonthCalendarLevel extends BaseCalendarLevel -{ - function YearMonthCalendarLevel() - { - global $conf; - parent::BaseCalendarLevel('DATE_FORMAT('.$conf['calendar_datefield'].',"%Y%m")', false); - } - - function sql_equal($item) - { - global $conf; - $y = (int)($item/100); - $m = (int)$item%100; - // There seems to be much difference in performance between these: - return $conf['calendar_datefield']." BETWEEN '$y-$m-01' AND '$y-$m-31'"; -/* return '(YEAR('.$conf['calendar_datefield'].')='.$y.' - AND MONTH('.$conf['calendar_datefield'].')='.$m.')';*/ -// return parent::sql_equal($item); - } - - function get_label($item) - { - global $lang; - if ( preg_match( '/(\d{4})(\d{2})/', $item, $matches) ) - { - return $lang['month'][(int)$matches[2]].' '.$matches[1]; - } - return $item; - } -} - -// just to optimize MySql query so that it uses the index -class YearCalendarLevel extends BaseCalendarLevel -{ - function YearCalendarLevel($sql, $allow_any=true) - { - parent::BaseCalendarLevel($sql, $allow_any); - } - - function sql_equal($item) - { - global $conf; - return $conf['calendar_datefield']." BETWEEN '$item-01-01' AND '$item-12-31'"; - } -} - -/** - * Parses $param and returns an array of calendar levels - * @param requested array of requested items for each calendar level - * @param cal_type is the requested calendar type - */ -function get_calendar_params($param, &$requested, &$cal_type) -{ - global $conf, $lang; - $requested = explode('-', $param); - $cal_struct = array(); - if ($requested[0]=='ywd') - { - array_push($cal_struct, new YearCalendarLevel( - 'YEAR('.$conf['calendar_datefield'].')' ) ); - array_push($cal_struct, new BaseCalendarLevel( - 'WEEK('.$conf['calendar_datefield'].')+1' ) ); - array_push($cal_struct, new BaseCalendarLevel( - 'DAYOFWEEK('.$conf['calendar_datefield'].')-1', true, $lang['day'] ) ); - $cal_type=array_shift($requested); - } - else if ($requested[0]=='md') - { - array_push($cal_struct, new YearMonthCalendarLevel() ); - array_push($cal_struct, new BaseCalendarLevel( - 'DAY('.$conf['calendar_datefield'].')' ) ); - $cal_type=array_shift($requested); - } - else - { - array_push($cal_struct, new YearCalendarLevel( - 'YEAR('.$conf['calendar_datefield'].')' ) ); - array_push($cal_struct, new BaseCalendarLevel( - 'MONTH('.$conf['calendar_datefield'].')', true, $lang['month'] ) ); - array_push($cal_struct, new BaseCalendarLevel( - 'DAY('.$conf['calendar_datefield'].')' ) ); - - if ($requested[0]=='ymd') - { - $cal_type=array_shift($requested); - } - else - { - $cal_type=''; - } - } - - // perform a sanity check on $requested - while (count($requested)>count($cal_struct)) - { - array_pop($requested); - } - - $any_count = 0; - for ($i=0; $iallow_any() ) - { - while ($i'm', 'default_link'=>'', 'name'=>l10n('Monthly'), + 'include'=>'calendar_monthly.class.php', 'view_calendar'=>true ), + array('link'=>'w', 'default_link'=>'w-', 'name'=>l10n('Weekly'), + 'include'=>'calendar_weekly.class.php', ), + ); - //echo ('
'. var_export($cal_struct, true) . '
'); + $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(); + } + + $view_type=CAL_VIEW_LIST; + if ($requested[0]==CAL_VIEW_LIST) + { + array_shift($requested); + } + elseif ($requested[0]==CAL_VIEW_CALENDAR) + { + if ($cal_style['view_calendar']) + { + $view_type=CAL_VIEW_CALENDAR; + } + array_shift($requested); + } + // perform a sanity check on $requested + while (count($requested)>3) + { + array_pop($requested); + } + + $any_count = 0; + for ($i=0; $iinitialize($conf['calendar_datefield'], $inner_sql); //echo ('
'. var_export($requested, true) . '
'); - + //echo ('
'. var_export($calendar, true) . '
'); + $category_calling = false; if (basename($_SERVER["PHP_SELF"]) == 'category.php') { $category_calling = true; } - + + $must_show_list = true; if ($category_calling) { $template->assign_block_vars('calendar', array()); @@ -242,191 +165,73 @@ function initialize_calendar() $url_base .= empty($url_base) ? '?' : '&'; $url_base .= 'calendar='; $url_base = PHPWG_ROOT_PATH.'category.php'.$url_base; - - // Build navigation bar for calendar styles - $nav_bar = 'Styles: '; - foreach ( array('ymd','md','ywd') as $type) + + if ( $calendar->generate_category_content( + $url_base.$cal_style['default_link'], $view_type, $requested) ) { - if ( $type==$cal_type or ($cal_type=='' and $type=='ymd') ) - { - $nav_bar .= $type.' '; - } - else - { - $nav_bar .= ''.$type.' '; - } + unset( $page['thumbnails_include'] ); + unset( $page['items'] ); + unset( $page['cat_nb_images'] ); + $must_show_list = false; } - $template->assign_block_vars( 'calendar.navbar', - array( 'BAR' => $nav_bar) - ); - - $url_base .= $cal_type; - if ($cal_type!='') - { - $url_base .= '-'; - } - - - $prev_level_query=' -AND '.$conf['calendar_datefield'].' IS NOT NULL '; - for ($i=0; $isql().') AS period, COUNT(id) as count -FROM '.IMAGES_TABLE; - if ( isset($category_restriction) ) + if ($cal_style['view_calendar']) + { // Build bar for view modes (List/Calendar) + $views = array( + array(CAL_VIEW_LIST, l10n('List') ), + array(CAL_VIEW_CALENDAR, l10n('calendar') ), + ); + $views_bar = ''; + foreach( $views as $view ) { - $query.= ' -INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id -WHERE category_id' . $category_restriction; - } - else - { - $query.= ' -WHERE id IN (' . implode(',',$page['items']) .')'; - } - $query.= $prev_level_query; - $query.= ' -GROUP BY period'; - - $level_items=array(); - $result = pwg_query($query); - $total_pics = 0; - while ($row = mysql_fetch_array($result)) - { - $level_items[$row['period']] = (int)$row['count']; - $total_pics += $row['count']; - } - //echo ('
'. var_export($level_items, true) . '
'); - - if ( $requested[$i] == 'any' and ! $crt_cal_level->allow_any() ) - { - unset($requested[$i]); - } - - // --- Build the navigation bar - if ( $crt_cal_level->allow_any() ) - { - $level_items['any'] = $total_pics; - } - $nav_bar=''; - foreach ($level_items as $item => $nb_images) - { - $label = $crt_cal_level->get_label($item); - if ( $item==$requested[$i] ) + $v = $view[1]; + if ( $view_type!=$view[0] ) { - $nav_bar .= ' '; - $nav_bar .= $label; - $nav_bar.= ''; + $url = $url_base.$cal_style['default_link'].$view[0].'-'; + $url .= implode('-', $requested); + $v = ''.$v.' '; } else { - $url = $url_base . $item; - $nav_bar .= ''; - $nav_bar .= $label; - $nav_bar .= ''; + $v = $v.' '; } - $nav_bar .= ' '; + $views_bar .= $v . ' '; } - $template->assign_block_vars( 'calendar.navbar', - array( 'BAR' => $nav_bar) - ); - - if ( !isset($requested[$i]) ) - break; - if ($requested[$i]!='any') - { - $prev_level_query.= ' AND '.$crt_cal_level->sql_equal($requested[$i]); - } - $url_base .= $requested[$i].'-'; - } // end for each calendar level - - - if ( $i < count($cal_struct) ) - { - $template->assign_block_vars('thumbnails', array()); - $template->assign_block_vars('thumbnails.line', array()); - foreach ($level_items as $level_item => $nb_pics) - { - if ($level_item=='any') - continue; - $query = ' -SELECT file,tn_ext,'.$conf['calendar_datefield'].',path -FROM '.IMAGES_TABLE; - if ( isset($category_restriction) ) - { - $query.= ' -INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id -WHERE category_id' . $category_restriction; - } - else - { - $query.= ' -WHERE id IN (' . implode(',',$page['items']) .')'; - } - $query.= $prev_level_query; - $query.= ' AND '.$crt_cal_level->sql_equal($level_item); - $query.= ' -ORDER BY RAND() -LIMIT 0,1'; - $row = mysql_fetch_array(pwg_query($query)); - - $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); - $thumbnail_title = $crt_cal_level->get_label($level_item); - $name = $thumbnail_title .' ('.$nb_pics.')'; - - $template->assign_block_vars( - 'thumbnails.line.thumbnail', - array( - 'IMAGE'=>$thumbnail_src, - 'IMAGE_ALT'=>$row['file'], - 'IMAGE_TITLE'=>$thumbnail_title, - 'U_IMG_LINK'=>$url_base.$level_item - ) - ); - $template->assign_block_vars( - 'thumbnails.line.thumbnail.category_name', - array( - 'NAME' => $name - ) - ); - } - unset( $page['thumbnails_include'] ); // maybe move everything to a new include file ? - pwg_debug('end initialize_calendar for thumbs'); - return; + $template->assign_block_vars('calendar.views', array( + 'BAR'=>$views_bar + )); } - } - - if (!$category_calling or $i==count($cal_struct) ) + + // Build bar for calendar styles (Monthly, Weekly) + $styles_bar = ''; + foreach ( $cal_styles as $style) + { + if ($cal_style['link']!=$style['link']) + { + $url = $url_base.$style['default_link']; + $url .= $view_type; + if (isset($requested[0])) + { + $url .= '-' . $requested[0]; + } + $styles_bar .= ''.$style['name'].' '; + } + else + { + $styles_bar .= $style['name'].' '; + } + } + $template->assign_block_vars( 'calendar.styles', + array( 'BAR' => $styles_bar) + ); + } // end category calling + + if ($must_show_list) { - $query = 'SELECT DISTINCT(id) FROM '.IMAGES_TABLE; - if ( isset($category_restriction) ) - { - $query.= ' -INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id -WHERE category_id' . $category_restriction; - } - else - { - $query.= ' -WHERE id IN ('.implode(',',$page['items']).')'; - } - $query.= ' -AND '.$conf['calendar_datefield'].' IS NOT NULL '; + $query = 'SELECT DISTINCT(id)'; + $query .= $calendar->inner_sql; + $query .= $calendar->get_date_where($requested); - for ($i=0; $isql_equal($requested[$i]); - } - - } - $page['items'] = array_from_query($query, 'id'); $page['cat_nb_images'] = count($page['items']); $page['thumbnails_include'] = 'include/category_default.inc.php'; diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php index b9383d624..045b5ad65 100644 --- a/language/en_UK.iso-8859-1/common.lang.php +++ b/language/en_UK.iso-8859-1/common.lang.php @@ -75,7 +75,9 @@ $lang['Identification'] = 'Identification'; $lang['Keyword'] = 'Keyword'; $lang['Keywords'] = 'Keywords'; $lang['Links'] = 'Links'; +$lang['List'] = 'List'; $lang['Mail address'] = 'Mail address'; +$lang['Monthly'] = 'Monthly'; $lang['N/A'] = 'N/A'; $lang['New on %s'] = 'New on %s'; $lang['New password confirmation does not correspond'] = 'New password confirmation does not correspond'; @@ -109,6 +111,7 @@ $lang['User comments'] = 'User comments'; $lang['Username'] = 'Username'; $lang['Visits'] = 'Visits'; $lang['Webmaster'] = 'Webmaster'; +$lang['Weekly'] = 'Weekly'; $lang['about_page_title'] = 'About PhpWebGallery'; $lang['access_forbiden'] = 'You are not authorized to access this page'; $lang['add to caddie'] = 'add to caddie'; @@ -129,6 +132,7 @@ $lang['best_rated_cat'] = 'Best rated'; $lang['best_rated_cat_hint'] = 'displays best rated items'; $lang['caddie'] = 'caddie'; $lang['calendar'] = 'Calendar'; +$lang['calendar_any'] = 'All'; $lang['calendar_hint'] = 'displays each day with pictures, month per month'; $lang['calendar_picture_hint'] = 'displays pictures added on '; $lang['categories'] = 'Categories'; diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php index 8bf262f8b..0c2d9e09f 100644 --- a/language/fr_FR.iso-8859-1/common.lang.php +++ b/language/fr_FR.iso-8859-1/common.lang.php @@ -74,7 +74,9 @@ $lang['Identification'] = 'Identification'; $lang['Keyword'] = 'Mot-clef'; $lang['Keywords'] = 'Mots-clef'; $lang['Links'] = 'Liens'; +$lang['List'] = 'Liste'; $lang['Mail address'] = $lang['Email address']; +$lang['Monthly'] = 'Mensuel'; $lang['N/A'] = 'non disponible'; $lang['New on %s'] = 'Nouveau le %s'; $lang['New password confirmation does not correspond'] = 'Erreur de confirmation de mot de passe'; @@ -108,6 +110,7 @@ $lang['User comments'] = 'Commentaires utilisateur'; $lang['Username'] = 'Nom d\'utilisateur'; $lang['Visits'] = 'Visites'; $lang['Webmaster'] = 'Webmestre'; +$lang['Weekly'] = 'Hebdomadaire'; $lang['about_page_title'] = 'À propos de PhpWebGallery'; $lang['access_forbiden'] = 'Vous n\'êtes pas autorisé sur cette page'; $lang['add to caddie'] = 'ajouter au panier'; @@ -128,6 +131,7 @@ $lang['best_rated_cat'] = 'Mieux not $lang['best_rated_cat_hint'] = 'affiche les images les mieux notées'; $lang['caddie'] = 'Panier'; $lang['calendar'] = 'Calendrier'; +$lang['calendar_any'] = 'Tout'; $lang['calendar_hint'] = 'affichage année par année, mois par mois, jour par jour'; $lang['calendar_picture_hint'] = 'affiche les images du '; $lang['categories'] = 'Catégories'; diff --git a/profile.php b/profile.php index 8c4db8fce..a05def74e 100644 --- a/profile.php +++ b/profile.php @@ -223,7 +223,7 @@ $template->assign_vars( $blockname = 'template_option'; -foreach (get_themes() as $pwg_template) +foreach (get_pwg_themes() as $pwg_template) { if (isset($_POST['submit'])) { diff --git a/template/yoga/category.tpl b/template/yoga/category.tpl index 906db4dfa..fc7d2a651 100644 --- a/template/yoga/category.tpl +++ b/template/yoga/category.tpl @@ -107,6 +107,16 @@
  •  
  • + +
  • + {lang:Sort order}: + +
  • +
  • {lang:caddie}
  • @@ -119,18 +129,13 @@
  • (?)
  • - - -
  • - {lang:Sort order}: - -
  • - - Toggle calendar + + +
  • {lang:calendar}
  • + + +
  • {lang:calendar}
  • +

{TITLE}

@@ -143,9 +148,22 @@ + + +
Style: {calendar.styles.BAR}
+ + + +
{calendar.views.BAR}
+ +
+ + +
{calendar.calbar.BAR}
+ diff --git a/template/yoga/content.css b/template/yoga/content.css index 8bb5df33d..cc85cbc1e 100644 --- a/template/yoga/content.css +++ b/template/yoga/content.css @@ -177,3 +177,41 @@ SPAN.filename:before { SPAN.filename:after { content: "]"; } + + +#content DIV.calendarStyles { + float: left; +} + +#content DIV.calendarViews { + float: right; +} + +SPAN.cal { + font-weight: bold; + border: 1px solid gray; + margin: 0 2px; +} + +SPAN.calSel { + font-weight: bold; + color: dark-gray; + border: 1px solid gray; + margin: 0 2px; +} + +#content .calendarBar { + margin: 8px 5px; + text-align: left; +} + +SPAN.calCalHead { + font-weight: bold; + font-size: 110%; + margin: 0 2px; +} + +SPAN.calCal { + margin: 0 2px; +} + diff --git a/template/yoga/icon/calendar.png b/template/yoga/icon/calendar.png new file mode 100644 index 000000000..e0a44a13d Binary files /dev/null and b/template/yoga/icon/calendar.png differ