aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2006-02-23 02:30:19 +0000
committerrvelices <rv-github@modusoptimus.com>2006-02-23 02:30:19 +0000
commit34538a62f4ac8bc6db41580058fdd040abaa3183 (patch)
treefdde1ecefd0ec41f20d3d5e2d1bcc87357d3e493 /include
parentfe8fbac3cf9af0464d2b0990c88631ff9fd803ac (diff)
new calendar completely integrated
git-svn-id: http://piwigo.org/svn/trunk@1051 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/calendar_monthly.class.php12
-rw-r--r--include/calendar_weekly.class.php2
-rw-r--r--include/category_calendar.inc.php458
-rw-r--r--include/functions_calendar.inc.php13
-rw-r--r--include/section_init.inc.php141
5 files changed, 64 insertions, 562 deletions
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.= '&amp;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&amp;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.= '&amp;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.= '&amp;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&amp;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.= '&amp;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(