diff options
-rw-r--r-- | category.php | 56 | ||||
-rw-r--r-- | include/calendar_monthly.class.php | 12 | ||||
-rw-r--r-- | include/calendar_weekly.class.php | 2 | ||||
-rw-r--r-- | include/category_calendar.inc.php | 458 | ||||
-rw-r--r-- | include/functions_calendar.inc.php | 13 | ||||
-rw-r--r-- | include/section_init.inc.php | 141 | ||||
-rw-r--r-- | picture.php | 58 | ||||
-rw-r--r-- | template/yoga/category.tpl | 8 |
8 files changed, 128 insertions, 620 deletions
diff --git a/category.php b/category.php index 4150a97c6..07d15a95c 100644 --- a/category.php +++ b/category.php @@ -300,7 +300,7 @@ $template->assign_block_vars( $template->assign_block_vars( 'special_cat', array( - 'URL' => PHPWG_ROOT_PATH.'category.php?cat=calendar', + 'URL' => PHPWG_ROOT_PATH.'category.php?calendar=m-c', 'TITLE' => $lang['calendar_hint'], 'NAME' => $lang['calendar'] )); @@ -400,6 +400,35 @@ if ( $page['navigation_bar'] != '' ) array('NAV_BAR' => $page['navigation_bar']) ); } + +if ($page['cat_nb_images']>0 and + ( !isset($page['cat']) + or ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') ) + ) +{ + // image order + $template->assign_block_vars( 'preferred_image_order', array() ); + + $order_idx = isset($_COOKIE['pwg_image_order']) ? + $_COOKIE['pwg_image_order'] : 0; + + $orders = get_category_preferred_image_orders(); + for ( $i = 0; $i < count($orders); $i++) + { + if ($orders[$i][2]) + { + $url = PHPWG_ROOT_PATH.'category.php' + .get_query_string_diff(array('image_order')); + $url .= '&image_order='.$i; + $template->assign_block_vars( 'preferred_image_order.order', array( + 'DISPLAY' => $orders[$i][0], + 'URL' => $url, + 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ), + ) ); + } + } +} + if ( isset ( $page['cat'] ) ) { // upload a picture in the category @@ -422,31 +451,6 @@ if ( isset ( $page['cat'] ) ) array('COMMENTS' => $page['comment']) ); } - if ($page['cat_nb_images']>0 and - $page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') - { - // image order - $template->assign_block_vars( 'preferred_image_order', array() ); - - $order_idx = isset($_COOKIE['pwg_image_order']) ? - $_COOKIE['pwg_image_order'] : 0; - - $orders = get_category_preferred_image_orders(); - for ( $i = 0; $i < count($orders); $i++) - { - if ($orders[$i][2]) - { - $url = PHPWG_ROOT_PATH.'category.php' - .get_query_string_diff(array('image_order')); - $url .= '&image_order='.$i; - $template->assign_block_vars( 'preferred_image_order.order', array( - 'DISPLAY' => $orders[$i][0], - 'URL' => $url, - 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ), - ) ); - } - } - } } //------------------------------------------------------------ log informations pwg_log( 'category', $page['title'] ); diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php index cc50a6641..3103880c3 100644 --- a/include/calendar_monthly.class.php +++ b/include/calendar_monthly.class.php @@ -126,7 +126,7 @@ function get_date_where($requested, $max_levels=3) $res .= ' AND DAY('.$this->date_field.')='.$requested[2];
}
}
- $res = " AND $this->date_field BETWEEN '$b' AND '$e'" . $res;
+ $res = " AND $this->date_field BETWEEN '$b' AND '$e 23:59:59'" . $res;
}
else
{
@@ -235,12 +235,14 @@ function build_year_calendar(&$requested) {
$url_base = $this->url_base.'c-'.$requested[0].'-'.$month;
- $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">'.$lang['month'][$month].'</a>';
+ $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">';
+ $nav_bar .= $lang['month'][$month].'</a>';
$nav_bar .= ' ('.$month_data['nb_images'].')';
$nav_bar .= '</span><br>';
$url_base .= '-';
- $nav_bar .= $this->get_nav_bar_from_items( $url_base, $month_data['children'], $requested[1], 'calCal', false );
+ $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)
@@ -278,6 +280,9 @@ function build_month_calendar($requested) SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw';
$query.= $this->inner_sql;
$query.= $this->get_date_where($requested);
+ $query.= '
+ ORDER BY RAND()
+ LIMIT 0,1';
$row = mysql_fetch_array(pwg_query($query));
@@ -305,5 +310,4 @@ SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw'; }
}
-
?>
\ No newline at end of file diff --git a/include/calendar_weekly.class.php b/include/calendar_weekly.class.php index 4ae65e076..b85a682d5 100644 --- a/include/calendar_weekly.class.php +++ b/include/calendar_weekly.class.php @@ -72,7 +72,7 @@ function get_date_where($requested, $max_levels=3) if (isset($requested[0]) and $requested[0]!='any')
{
$y = $requested[0];
- $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31'";
+ $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'";
}
if (isset($requested[1]) and $requested[1]!='any')
diff --git a/include/category_calendar.inc.php b/include/category_calendar.inc.php deleted file mode 100644 index fb2fffd09..000000000 --- a/include/category_calendar.inc.php +++ /dev/null @@ -1,458 +0,0 @@ -<?php -// +-----------------------------------------------------------------------+ -// | PhpWebGallery - a PHP based picture gallery | -// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | -// +-----------------------------------------------------------------------+ -// | branch : BSF (Best So Far) -// | file : $RCSfile$ -// | last update : $Date$ -// | last modifier : $Author$ -// | revision : $Revision$ -// +-----------------------------------------------------------------------+ -// | 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 | -// | the Free Software Foundation | -// | | -// | This program is distributed in the hope that it will be useful, but | -// | WITHOUT ANY WARRANTY; without even the implied warranty of | -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | -// | General Public License for more details. | -// | | -// | You should have received a copy of the GNU General Public License | -// | along with this program; if not, write to the Free Software | -// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | -// | USA. | -// +-----------------------------------------------------------------------+ - -/** - * This file is included by category.php to show thumbnails for the category - * calendar - * - */ - -// years of image availability -$query = ' -SELECT YEAR('.$conf['calendar_datefield'].') AS year, COUNT(id) AS count - FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' - '.$page['where'].' - AND id = image_id - GROUP BY year -;'; -$result = pwg_query($query); -$calendar_years = array(); -while ($row = mysql_fetch_array($result)) -{ - $calendar_years[$row['year']] = $row['count']; -} - -// if the year requested is not among the available years, we unset the -// variable -if (isset($page['calendar_year']) - and !isset($calendar_years[$page['calendar_year']])) -{ - unset($page['calendar_year']); -} - -// years navigation bar creation -$years_nav_bar = ''; -foreach ($calendar_years as $calendar_year => $nb_picture_year) -{ - if (isset($page['calendar_year']) - and $calendar_year == $page['calendar_year']) - { - $years_nav_bar.= ' <span class="dateSelected">'.$calendar_year.'</span>'; - } - else - { - $url = PHPWG_ROOT_PATH.'category.php?cat=calendar'; - $url.= '&year='.$calendar_year; - $years_nav_bar.= ' <a href="'.$url.'">'.$calendar_year.'</a>'; - } -} - -$template->assign_block_vars( - 'calendar', - array('YEARS_NAV_BAR' => $years_nav_bar) - ); - -// months are calculated (to know which months are available, and how many -// pictures per month we can find) only if a year is requested. -if (isset($page['calendar_year'])) -{ - // creation of hash associating the number of the month in the year with - // the number of picture for this month : $calendar_months - $query = ' -SELECT DISTINCT(MONTH('.$conf['calendar_datefield'].')) AS month - , COUNT(id) AS count - FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id - '.$page['where'].' - AND '.$conf['calendar_datefield'].' - BETWEEN \''.$page['calendar_year'].'-1-1\' - AND \''.$page['calendar_year'].'-12-31\' - GROUP BY MONTH('.$conf['calendar_datefield'].') -;'; - $result = pwg_query($query); - $calendar_months = array(); - while ($row = mysql_fetch_array($result)) - { - $calendar_months[$row['month']] = $row['count']; - } - - // if a month is requested and is not among the available months, we unset - // the requested month - if (isset($page['calendar_month']) - and !isset($calendar_months[$page['calendar_month']])) - { - unset($page['calendar_month']); - } - - // months navigation bar creation - $months_nav_bar = ''; - foreach ($calendar_months as $calendar_month => $nb_picture_month) - { - if (isset($page['calendar_month']) - and $calendar_month == $page['calendar_month']) - { - $months_nav_bar.= ' <span class="dateSelected">'; - $months_nav_bar.= $lang['month'][(int)$calendar_month]; - $months_nav_bar.= '</span>'; - } - else - { - $url = PHPWG_ROOT_PATH.'category.php?cat=calendar&month='; - $url.= $page['calendar_year'].'.'.sprintf('%02s', $calendar_month); - $months_nav_bar.= ' '; - $months_nav_bar.= '<a href="'.$url.'">'; - $months_nav_bar.= $lang['month'][(int)$calendar_month]; - $months_nav_bar.= '</a>'; - } - } - $template->assign_block_vars( - 'calendar', - array('MONTHS_NAV_BAR' => $months_nav_bar)); -} - -/** - * 4 sub-cases are possibles for the calendar category : - * - * 1. show years if no year is requested - * 2. show months of the requested year if no month is requested - * 3. show days of the {year,month} requested if no day requested - * 4. show categories of the requested day (+ a special category gathering - * all categories) - */ - -if (!isset($page['calendar_year'])) -{ - $nb_pics = count($calendar_years); -} -elseif (!isset($page['calendar_month'])) -{ - $nb_pics = count($calendar_months); -} -elseif (!isset($page['calendar_day'])) -{ - // creation of hash associating the number of the day in the month with - // the number of picture for this day : $calendar_days - $query = ' -SELECT - DISTINCT DATE_FORMAT('.$conf['calendar_datefield'].', \'%Y-%m-%d\') AS day - , COUNT(id) AS count - FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id - '.$page['where'].' - AND '.$conf['calendar_datefield'].' - BETWEEN \''.$page['calendar_year'].'-'.$page['calendar_month'].'-1\' - AND \''.$page['calendar_year'].'-'.$page['calendar_month'].'-31\' - GROUP BY day -;'; - $result = pwg_query($query); - $calendar_days = array(); - while ($row = mysql_fetch_array($result)) - { - $calendar_days[$row['day']] = $row['count']; - } - $nb_pics = count($calendar_days); -} -elseif (isset($page['calendar_day'])) -{ - // $page['calendar_date'] is the concatenation of year-month-day. simplier - // to use in SQ queries - $page['calendar_date'] = $page['calendar_year']; - $page['calendar_date'].= '-'.$page['calendar_month']; - $page['calendar_date'].= '-'.$page['calendar_day']; - - $query = ' -SELECT category_id AS category, COUNT(id) AS count - FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id - '.$page['where'].' - AND '.$conf['calendar_datefield'].' = \''.$page['calendar_date'].'\' - GROUP BY category_id -;'; - $result = pwg_query($query); - $calendar_categories = array(); - // special category 0 : gathering all available categories (0 cannot be a - // oregular category identifier) - $calendar_categories[0] = 0; - while ($row = mysql_fetch_array($result)) - { - $calendar_categories[$row['category']] = $row['count']; - } - // update the total number of pictures for this day - $calendar_categories[0] = array_sum($calendar_categories); - - $nb_pics = count($calendar_categories); -} - -// template thumbnail initialization -if ($nb_pics > 0) -{ - $template->assign_block_vars('thumbnails', array()); - // first line - $template->assign_block_vars('thumbnails.line', array()); - // current row displayed - $row_number = 0; -} - -if (!isset($page['calendar_year'])) -{ - // for each month of this year, display a random picture - foreach ($calendar_years as $calendar_year => $nb_pics) - { - $query = ' -SELECT file,tn_ext,'.$conf['calendar_datefield'].',path - FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id - '.$page['where'].' - AND '.$conf['calendar_datefield'].' - BETWEEN \''.$calendar_year.'-1-1\' - AND \''.$calendar_year.'-12-31\' - ORDER BY RAND() - LIMIT 0,1 -;'; - $row = mysql_fetch_array(pwg_query($query)); - - $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); - - $name = $calendar_year.' ('.$nb_pics.')'; - - $thumbnail_title = $lang['calendar_picture_hint'].$name; - - $url_link = PHPWG_ROOT_PATH.'category.php?cat=calendar'; - $url_link.= '&year='.$calendar_year; - - $template->assign_block_vars( - 'thumbnails.line.thumbnail', - array( - 'IMAGE'=>$thumbnail_src, - 'IMAGE_ALT'=>$row['file'], - 'IMAGE_TITLE'=>$thumbnail_title, - - 'U_IMG_LINK'=>$url_link - ) - ); - - $template->assign_block_vars( - 'thumbnails.line.thumbnail.category_name', - array( - 'NAME' => $name - ) - ); - - // create a new line ? - if (++$row_number == $user['nb_image_line']) - { - $template->assign_block_vars('thumbnails.line', array()); - $row_number = 0; - } - } -} -elseif (!isset($page['calendar_month'])) -{ - // for each month of this year, display a random picture - foreach ($calendar_months as $calendar_month => $nb_pics) - { - $query = ' -SELECT file,tn_ext,'.$conf['calendar_datefield'].',path - FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id - '.$page['where'].' - AND '.$conf['calendar_datefield'].' - BETWEEN \''.$page['calendar_year'].'-'.$calendar_month.'-1\' - AND \''.$page['calendar_year'].'-'.$calendar_month.'-31\' - ORDER BY RAND() - LIMIT 0,1 -;'; - $row = mysql_fetch_array(pwg_query($query)); - - $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); - - $name = $lang['month'][$calendar_month]; - $name.= ' '.$page['calendar_year']; - $name.= ' ('.$nb_pics.')'; - - $thumbnail_title = $lang['calendar_picture_hint'].$name; - - $url_link = PHPWG_ROOT_PATH.'category.php?cat=calendar'; - $url_link.= '&month='.$page['calendar_year'].'.'; - if ($calendar_month < 10) - { - // adding leading zero - $url_link.= '0'; - } - $url_link.= $calendar_month; - - $template->assign_block_vars( - 'thumbnails.line.thumbnail', - array( - 'IMAGE'=>$thumbnail_src, - 'IMAGE_ALT'=>$row['file'], - 'IMAGE_TITLE'=>$thumbnail_title, - - 'U_IMG_LINK'=>$url_link - ) - ); - - $template->assign_block_vars( - 'thumbnails.line.thumbnail.category_name', - array( - 'NAME' => $name - ) - ); - - // create a new line ? - if (++$row_number == $user['nb_image_line']) - { - $template->assign_block_vars('thumbnails.line', array()); - $row_number = 0; - } - } -} -elseif (!isset($page['calendar_day'])) -{ - // for each day of the requested month, display a random picture - foreach ($calendar_days as $calendar_day => $nb_pics) - { - $query = ' -SELECT file,tn_ext,'.$conf['calendar_datefield'].',path - , DAYOFWEEK(\''.$calendar_day.'\') AS dow - FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id - '.$page['where'].' - AND '.$conf['calendar_datefield'].' = \''.$calendar_day.'\' - ORDER BY RAND() - LIMIT 0,1 -;'; - $row = mysql_fetch_array(pwg_query($query)); - - $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); - - list($year,$month,$day) = explode('-', $calendar_day); - $name = $lang['day'][$row['dow']-1]; - $name.= ' '.$day; - $name.= ' ('.$nb_pics.')'; - - $thumbnail_title = $lang['calendar_picture_hint'].$name; - - $url_link = PHPWG_ROOT_PATH.'category.php'; - $url_link.= '?cat=calendar&day='.str_replace('-', '.', $calendar_day); - - $template->assign_block_vars( - 'thumbnails.line.thumbnail', - array( - 'IMAGE'=>$thumbnail_src, - 'IMAGE_ALT'=>$row['file'], - 'IMAGE_TITLE'=>$thumbnail_title, - - 'U_IMG_LINK'=>$url_link - ) - ); - - $template->assign_block_vars( - 'thumbnails.line.thumbnail.category_name', - array( - 'NAME' => $name - ) - ); - - // create a new line ? - if (++$row_number == $user['nb_image_line']) - { - $template->assign_block_vars('thumbnails.line', array()); - $row_number = 0; - } - } -} -elseif (isset($page['calendar_day'])) -{ - $old_level_separator = $conf['level_separator']; - $conf['level_separator'] = '<br />'; - // for each category of this day, display a random picture - foreach ($calendar_categories as $calendar_category => $nb_pics) - { - if ($calendar_category == 0) - { - $name = '['.$lang['all_categories'].']'; - } - else - { - $cat_infos = get_cat_info( $calendar_category ); - - $name = get_cat_display_name($cat_infos['name'],'',false); - $name = '['.$name.']'; - } - $name.= ' ('.$nb_pics.')'; - - $query = ' -SELECT file,tn_ext,'.$conf['calendar_datefield'].',path - FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' - '.$page['where'].' - AND '.$conf['calendar_datefield'].' = \''.$page['calendar_date'].'\''; - if ($calendar_category != 0) - { - $query.= ' - AND category_id = '.$calendar_category; - } - $query.= ' - AND id = image_id - 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 = $lang['calendar_picture_hint'].$name; - - $url_link = PHPWG_ROOT_PATH.'category.php?cat=search'; - $url_link.= '&search='.$conf['calendar_datefield'].':'.$_GET['day']; - if ($calendar_category != 0) - { - $url_link.= '--cat:'.$calendar_category.'|AND'; - } - - $template->assign_block_vars( - 'thumbnails.line.thumbnail', - array( - 'IMAGE'=>$thumbnail_src, - 'IMAGE_ALT'=>$row['file'], - 'IMAGE_TITLE'=>$thumbnail_title, - - 'U_IMG_LINK'=>$url_link - ) - ); - - $template->assign_block_vars( - 'thumbnails.line.thumbnail.category_name', - array( - 'NAME' => $name - ) - ); - - // create a new line ? - if (++$row_number == $user['nb_image_line']) - { - $template->assign_block_vars('thumbnails.line', array()); - $row_number = 0; - } - } - $conf['level_separator'] = $old_level_separator; -} -?>
\ No newline at end of file diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php index a5a1e87bb..e39bbe2a0 100644 --- a/include/functions_calendar.inc.php +++ b/include/functions_calendar.inc.php @@ -231,6 +231,19 @@ WHERE id IN (' . implode(',',$page['items']) .')'; $query = 'SELECT DISTINCT(id)';
$query .= $calendar->inner_sql;
$query .= $calendar->get_date_where($requested);
+ if ( isset($page['super_order_by']) )
+ {
+ $query .= '
+ '.$conf['order_by'];
+ }
+ else
+ {
+ $order_by = str_replace(
+ 'ORDER BY ',
+ 'ORDER BY '.$calendar->date_field.',', $conf['order_by']
+ );
+ $query .= $order_by;
+ }
$page['items'] = array_from_query($query, 'id');
$page['cat_nb_images'] = count($page['items']);
diff --git a/include/section_init.inc.php b/include/section_init.inc.php index d0c9522cd..68b82d463 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -52,8 +52,7 @@ if (isset($_GET['cat'])) or $_GET['cat'] == 'most_visited' or $_GET['cat'] == 'best_rated' or $_GET['cat'] == 'recent_pics' - or $_GET['cat'] == 'recent_cats' - or $_GET['cat'] == 'calendar') + or $_GET['cat'] == 'recent_cats') { $page['cat'] = $_GET['cat']; } @@ -97,39 +96,30 @@ if (isset($_GET['cat'])) // By default, it is the same as the $user['nb_image_page'] $page['nb_image_page'] = $user['nb_image_page']; -if (isset($page['cat'])) +if (isset($_COOKIE['pwg_image_order']) + and is_numeric($_COOKIE['pwg_image_order']) + and $_COOKIE['pwg_image_order'] > 0) { - if ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') - { - if (isset($_COOKIE['pwg_image_order']) - and is_numeric($_COOKIE['pwg_image_order']) - and $_COOKIE['pwg_image_order'] > 0) - { - $orders = get_category_preferred_image_orders(); + $orders = get_category_preferred_image_orders(); - $conf['order_by'] = str_replace( - 'ORDER BY ', - 'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',', - $conf['order_by'] - ); - } - } - + $conf['order_by'] = str_replace( + 'ORDER BY ', + 'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',', + $conf['order_by'] + ); + $page['super_order_by'] = true; +} + +if (isset($page['cat'])) +{ + // +-----------------------------------------------------------------------+ // | category | // +-----------------------------------------------------------------------+ if (is_numeric($page['cat'])) { - $query = ' -SELECT image_id - FROM '.IMAGE_CATEGORY_TABLE.' - INNER JOIN '.IMAGES_TABLE.' ON id = image_id - WHERE category_id = '.$page['cat'].' - '.$conf['order_by'].' -;'; - $result = get_cat_info($page['cat']); - + $page = array_merge( $page, array( @@ -142,15 +132,25 @@ SELECT image_id 'cat_commentable' => $result['commentable'], 'cat_id_uppercat' => $result['id_uppercat'], 'uppercats' => $result['uppercats'], - + 'title' => get_cat_display_name($result['name'], '', false), - 'items' => array_from_query($query, 'image_id'), - 'thumbnails_include' => - $result['nb_images'] > 0 - ? 'include/category_default.inc.php' - : 'include/category_subcats.inc.php', ) ); + if ( !isset($_GET['calendar']) ) + { + $query = ' +SELECT image_id + FROM '.IMAGE_CATEGORY_TABLE.' + INNER JOIN '.IMAGES_TABLE.' ON id = image_id + WHERE category_id = '.$page['cat'].' + '.$conf['order_by'].' +;'; + $page['items'] = array_from_query($query, 'image_id'); + $page['thumbnails_include'] = + $result['nb_images'] > 0 + ? 'include/category_default.inc.php' + : 'include/category_subcats.inc.php'; + }//otherwise the calendar will requery all subitems } // special section else @@ -255,13 +255,15 @@ SELECT DISTINCT(id) // +-----------------------------------------------------------------------+ else if ($page['cat'] == 'most_visited') { + $page['super_order_by'] = true; + $conf['order_by'] = ' ORDER BY hit DESC, file ASC'; $query = ' SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id WHERE hit > 0 - AND '.$forbidden.' - ORDER BY hit DESC, file ASC + AND '.$forbidden. + $conf['order_by'].' LIMIT 0, '.$conf['top_number'].' ;'; @@ -275,79 +277,20 @@ SELECT DISTINCT(id) ); } // +-----------------------------------------------------------------------+ -// | calendar section | -// +-----------------------------------------------------------------------+ - else if ($page['cat'] == 'calendar') - { - $page['cat_nb_images'] = 0; - $page['title'] = $lang['calendar']; - if (isset($_GET['year']) - and preg_match('/^\d+$/', $_GET['year'])) - { - $page['calendar_year'] = (int)$_GET['year']; - } - if (isset($_GET['month']) - and preg_match('/^(\d+)\.(\d{2})$/', $_GET['month'], $matches)) - { - $page['calendar_year'] = (int)$matches[1]; - $page['calendar_month'] = (int)$matches[2]; - } - if (isset($_GET['day']) - and preg_match('/^(\d+)\.(\d{2})\.(\d{2})$/', - $_GET['day'], - $matches)) - { - $page['calendar_year'] = (int)$matches[1]; - $page['calendar_month'] = (int)$matches[2]; - $page['calendar_day'] = (int)$matches[3]; - } - if (isset($page['calendar_year'])) - { - $page['title'] .= ' ('; - if (isset($page['calendar_day'])) - { - if ($page['calendar_year'] >= 1970) - { - $unixdate = mktime( - 0, - 0, - 0, - $page['calendar_month'], - $page['calendar_day'], - $page['calendar_year'] - ); - $page['title'].= $lang['day'][date("w", $unixdate)]; - } - $page['title'].= ' '.$page['calendar_day'].', '; - } - if (isset($page['calendar_month'])) - { - $page['title'] .= $lang['month'][$page['calendar_month']].' '; - } - $page['title'] .= $page['calendar_year']; - $page['title'] .= ')'; - } - - $page['where'] = 'WHERE '.$conf['calendar_datefield'].' IS NOT NULL'; - if (isset($forbidden)) - { - $page['where'].= ' AND '.$forbidden; - } - - $page['thumbnails_include'] = 'include/category_calendar.inc.php'; - } -// +-----------------------------------------------------------------------+ // | best rated section | // +-----------------------------------------------------------------------+ else if ($page['cat'] == 'best_rated') { + $page['super_order_by'] = true; + $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC'; + $query =' SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id WHERE average_rate IS NOT NULL - AND '.$forbidden.' - ORDER BY average_rate DESC, id ASC + AND '.$forbidden. + $conf['order_by'].' LIMIT 0, '.$conf['top_number'].' ;'; $page = array_merge( diff --git a/picture.php b/picture.php index e1ed3891c..18133095a 100644 --- a/picture.php +++ b/picture.php @@ -362,7 +362,15 @@ while ($row = mysql_fetch_array($result)) .'&image_id='.$row['id']; } -$url_up = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat']; +$url_up = PHPWG_ROOT_PATH.'category.php?'; +if ( isset($page['cat']) ) +{ + $url_up .= 'cat='.$page['cat']; +} +elseif ( isset($_GET['calendar']) ) +{ + $url_up .= 'calendar='.$_GET['calendar']; +} $url_up_start = floor( $page['current_rank'] / $user['nb_image_page'] ); $url_up_start *= $user['nb_image_page']; @@ -373,11 +381,11 @@ if ($url_up_start>0) if ( $page['cat'] == 'search' ) { - $url_up.= "&search=".$_GET['search']; + $url_up.= '&search='.$_GET['search']; } if ( $page['cat'] == 'list' ) { - $url_up.= "&list=".$_GET['list']; + $url_up.= '&list='.$_GET['list']; } $url_admin = @@ -777,15 +785,17 @@ else // creation date if (!empty($picture['current']['date_creation'])) { - $infos['INFO_CREATION_DATE'] = - // FIXME because of search engine partial rewrite, giving the author - // name threw GET is not supported anymore. This feature should come - // back later, with a better design (calendar view). -// '<a href="'. -// PHPWG_ROOT_PATH.'category.php?cat=search'. -// '&search=date_creation:'.$picture['current']['date_creation'] -// .'">'.format_date($picture['current']['date_creation']).'</a>'; - format_date($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-'. + $picture['current']['date_creation'].'">'.$val.'</a>'; + } + else + { + $infos['INFO_CREATION_DATE'] = $val; + } } else { @@ -793,19 +803,17 @@ else } // date of availability -$infos['INFO_AVAILABILITY_DATE'] = -// FIXME because of search engine partial rewrite, giving the author -// name threw GET is not supported anymore. This feature should come -// back later, with a better design (calendar view). -// -// '<a href="'. -// PHPWG_ROOT_PATH.'category.php?cat=search'. -// '&search=date_available:'. -// substr($picture['current']['date_available'], 0, 10) -// .'">'. -// format_date($picture['current']['date_available'], 'mysql_datetime'). -// '</a>'; -format_date($picture['current']['date_available'], 'mysql_datetime'); +$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; +} // size in pixels if ($picture['current']['is_picture']) diff --git a/template/yoga/category.tpl b/template/yoga/category.tpl index fc7d2a651..11acfa853 100644 --- a/template/yoga/category.tpl +++ b/template/yoga/category.tpl @@ -131,7 +131,7 @@ <!-- END search_rules --> <!-- BEGIN calendar_view --> - <li><a href="{calendar_view.URL}" title="{lang:calendar}"><img src="{themeconf:icon_dir}/calendar.png" class="button" alt="{lang:calendar}"></a></li> + <li><a href="{calendar_view.URL}" title="{lang:calendar_hint}"><img src="{themeconf:icon_dir}/calendar.png" class="button" alt="{lang:calendar}"></a></li> <!-- END calendar_view --> <!-- BEGIN normal_view --> <li><a href="{normal_view.URL}" title="{lang:calendar}"><img src="{themeconf:icon_dir}/calendar.png" class="button" alt="{lang:calendar}"></a></li> @@ -143,12 +143,6 @@ </div> <!-- content --> <!-- BEGIN calendar --> -<div class="navigationBar">{calendar.YEARS_NAV_BAR}</div> -<div class="navigationBar">{calendar.MONTHS_NAV_BAR}</div> -<!-- END calendar --> - -<!-- BEGIN calendar --> - <!-- BEGIN styles --> <div class="calendarStyles">Style: {calendar.styles.BAR}</div> <!-- END styles --> |