aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2006-02-28 04:28:06 +0000
committerrvelices <rv-github@modusoptimus.com>2006-02-28 04:28:06 +0000
commit97898b36858d5f187e9659d723c71eb04b2f0593 (patch)
tree363cfd342a409cc4f1109dbf1469c12e9090a6ff /include
parent4cd5b05d406a9820a0523ac26f254f4ce4fd5147 (diff)
calendar improvements: week on weekly list starts on Monday,
ability to show grayed months/weeks/days (without any picture in it), added icons for created/posted fields language uniformization calendar fixes: correct number of pictures in calendar view, code simplification (I hope so) git-svn-id: http://piwigo.org/svn/trunk@1059 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/calendar_base.class.php107
-rw-r--r--include/calendar_monthly.class.php170
-rw-r--r--include/calendar_weekly.class.php105
-rw-r--r--include/config_default.inc.php14
-rw-r--r--include/functions_calendar.inc.php52
-rw-r--r--include/functions_category.inc.php20
6 files changed, 267 insertions, 201 deletions
diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php
index 1a7b54989..8f9ec4bb7 100644
--- a/include/calendar_base.class.php
+++ b/include/calendar_base.class.php
@@ -37,7 +37,8 @@ class CalendarBase
var $url_base;
// array of date components e.g. (2005,10,12) ...
var $date_components;
-
+ //
+ var $calendar_levels;
/**
* Initialize the calendar
@@ -52,16 +53,45 @@ class CalendarBase
$this->date_components = $date_components;
}
+ function get_display_name()
+ {
+ global $conf;
+ $res = '';
+ $url = $this->url_base;
+
+ for ($i=0; $i<count($this->date_components); $i++)
+ {
+ $res .= $conf['level_separator'];
+
+ $url .= $this->date_components[$i].'-';
+ if ( isset($this->date_components[$i+1]) )
+ {
+ $res .=
+ '<a href="'.$url.'">'
+ .$this->get_date_component_label($i, $this->date_components[$i])
+ .'</a>';
+ }
+ else
+ {
+ $res .=
+ '<span class="calInHere">'
+ .$this->get_date_component_label($i, $this->date_components[$i])
+ .'</span>';
+ }
+ }
+ return $res;
+ }
+
//--------------------------------------------------------- private members ---
/**
* Returns a display name for a date component optionally using labels
*/
- function get_date_component_label($date_component, $labels=null)
+ function get_date_component_label($level, $date_component)
{
$label = $date_component;
- if (isset($labels[$date_component]))
+ if (isset($this->calendar_levels[$level]['labels'][$date_component]))
{
- $label = $labels[$date_component];
+ $label = $this->calendar_levels[$level]['labels'][$date_component];
}
elseif ($date_component == 'any' )
{
@@ -69,7 +99,7 @@ class CalendarBase
}
return $label;
}
-
+
/**
* Creates a calendar navigation bar.
*
@@ -77,15 +107,31 @@ class CalendarBase
* @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 bool show_any - adds any link to the end of the bar
+ * @param bool show_empty - shows all labels even those without items
* @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)
+ $class_prefix, $show_any,
+ $show_empty=false, $labels=null)
{
+ global $conf;
+
$nav_bar = '';
-
+
+ if ($conf['calendar_show_empty'] and $show_empty and !empty($labels) )
+ {
+ foreach ($labels as $item => $label)
+ {
+ if ( ! isset($items[$item]) )
+ {
+ $items[$item] = -1;
+ }
+ }
+ ksort($items);
+ }
+
foreach ($items as $item => $nb_images)
{
$label = $item;
@@ -98,6 +144,11 @@ class CalendarBase
$nav_bar .= '<span class="'.$class_prefix.'Sel">';
$nav_bar .= $label;
}
+ elseif ($nb_images==-1)
+ {
+ $nav_bar .= '<span class="'.$class_prefix.'Empty">';
+ $nav_bar .= $label;
+ }
else
{
$nav_bar .= '<span class="'.$class_prefix.'">';
@@ -112,8 +163,8 @@ class CalendarBase
}
$nav_bar.= '</span>';
}
- global $conf;
- if ($conf['calendar_show_any'] and $allow_any and count($items) > 1)
+
+ if ($conf['calendar_show_any'] and $show_any and count($items) > 1)
{
$label = l10n('calendar_any');
if (isset($selected_item) and 'any' == $selected_item)
@@ -137,18 +188,15 @@ class CalendarBase
/**
* Creates a calendar navigation bar for a given level.
*
- * @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
+ * @param int level - the level (0-year,1-month/week,2-day)
* @return void
*/
- function build_nav_bar($level, $sql_func,
- $sql_offset='', $labels=null)
+ function build_nav_bar($level, $labels=null)
{
- global $template;
-
+ global $template, $conf;
+
$query = '
-SELECT DISTINCT('.$sql_func.'('.$this->date_field.')'.$sql_offset
+SELECT DISTINCT('.$this->calendar_levels[$level]['sql']
.') as period';
$query.= $this->inner_sql;
$query.= $this->get_date_where($level);
@@ -163,6 +211,24 @@ SELECT DISTINCT('.$sql_func.'('.$this->date_field.')'.$sql_offset
$level_items[$row['period']] = 0;
}
+ if ( count($level_items)==1 )
+ {
+ if ( ! isset($this->date_components[$level]) )
+ {
+ list($key) = array_keys($level_items);
+ $this->date_components[$level] = (int)$key;
+ }
+ }
+
+ if ( $conf['calendar_multi_bar']==false )
+ {
+ if ( $level<count($this->date_components) and
+ $level!=count($this->calendar_levels)-1 )
+ {
+ return;
+ }
+ }
+
$url_base = $this->url_base;
for ($i=0; $i<$level; $i++)
{
@@ -180,9 +246,10 @@ SELECT DISTINCT('.$sql_func.'('.$this->date_field.')'.$sql_offset
$url_base,
$level_items,
$selected,
- 'cal',
+ 'calItem',
+ true,
true,
- $labels
+ isset($labels) ? $labels : $this->calendar_levels[$level]['labels']
);
$template->assign_block_vars(
diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php
index e628cd44b..3a4207076 100644
--- a/include/calendar_monthly.class.php
+++ b/include/calendar_monthly.class.php
@@ -36,6 +36,32 @@ define ('CDAY', 2);
class Calendar extends CalendarBase
{
+ /**
+ * 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, $date_components)
+ {
+ parent::initialize($date_field, $inner_sql, $date_components);
+ global $lang;
+ $this->calendar_levels = array(
+ array(
+ 'sql'=> 'YEAR('.$this->date_field.')',
+ 'labels' => null
+ ),
+ array(
+ 'sql'=> 'MONTH('.$this->date_field.')',
+ 'labels' => $lang['month']
+ ),
+ array(
+ 'sql'=> 'DAYOFMONTH('.$this->date_field.')',
+ 'labels' => null
+ ),
+ );
+ }
+
/**
* Generate navigation bars for category page
* @return boolean false to indicate that thumbnails
@@ -43,7 +69,7 @@ class Calendar extends CalendarBase
*/
function generate_category_content($url_base, $view_type)
{
- global $lang, $conf;
+ global $conf;
$this->url_base = $url_base;
@@ -59,8 +85,7 @@ function generate_category_content($url_base, $view_type)
{//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
+ $this->build_nav_bar(CYEAR); // years
return true;
}
}
@@ -68,34 +93,30 @@ function generate_category_content($url_base, $view_type)
if ( count($this->date_components)==2 )
{//case C: year+month given - display a nice month calendar
$this->build_month_calendar();
- 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
- }
+ $this->build_nav_bar(CYEAR); // years
+ $this->build_nav_bar(CMONTH); // month
return true;
}
}
if ($view_type==CAL_VIEW_LIST or count($this->date_components)==3)
{
- if ( $conf['calendar_multi_bar'] or count($this->date_components)==0 )
+ if ( count($this->date_components)>=0 )
{
- $this->build_nav_bar2(CYEAR, 'YEAR'); // years
+ $this->build_nav_bar(CYEAR); // years
}
- if ( count($this->date_components)>=1 and
- ( $conf['calendar_multi_bar'] or count($this->date_components)==1 )
- )
+ if ( count($this->date_components)>=1)
{
- $this->build_nav_bar2(CMONTH, 'MONTH', $lang['month']); // month
+ $this->build_nav_bar(CMONTH); // month
}
if ( count($this->date_components)>=2 )
{
- $this->build_nav_bar2(CDAY, 'DAYOFMONTH' ); // days
+ $this->build_nav_bar(
+ CDAY,
+ $this->get_all_days_in_month(
+ $this->date_components[CYEAR] ,$this->date_components[CMONTH]
+ )
+ ); // days
}
}
return false;
@@ -141,11 +162,11 @@ function get_date_where($max_levels=3)
$e .= '12-31';
if (isset($date[CMONTH]) and $date[CMONTH]!='any')
{
- $res .= ' AND MONTH('.$this->date_field.')='.$date[CMONTH];
+ $res .= ' AND '.$this->calendar_levels[CMONTH]['sql'].'='.$date[CMONTH];
}
- if (isset($date[2]) and $date[2]!='any')
+ if (isset($date[CDAY]) and $date[CDAY]!='any')
{
- $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$date[CDAY];
+ $res .= ' AND '.$this->calendar_levels[CDAY]['sql'].'='.$date[CDAY];
}
}
$res = " AND $this->date_field BETWEEN '$b' AND '$e 23:59:59'" . $res;
@@ -155,74 +176,56 @@ function get_date_where($max_levels=3)
$res = ' AND '.$this->date_field.' IS NOT NULL';
if (isset($date[CMONTH]) and $date[CMONTH]!='any')
{
- $res .= ' AND MONTH('.$this->date_field.')='.$date[CMONTH];
+ $res .= ' AND '.$this->calendar_levels[CMONTH]['sql'].'='.$date[CMONTH];
}
if (isset($date[CDAY]) and $date[CDAY]!='any')
{
- $res .= ' AND DAYOFMONTH('.$this->date_field.')='.$date[CDAY];
+ $res .= ' AND '.$this->calendar_levels[CDAY]['sql'].'='.$date[CDAY];
}
}
return $res;
}
-function get_display_name()
+
+//--------------------------------------------------------- private members ---
+
+// returns an array with alll the days in a given month
+function get_all_days_in_month($year, $month)
{
- global $conf, $lang;
- $res = '';
- $url = $this->url_base;
- if ( isset($this->date_components[CYEAR]) )
+ $md= array(1=>31,28,31,30,31,30,31,31,30,31,30,31);
+
+ if ( is_numeric($year) and $month==2)
{
- $res .= $conf['level_separator'];
- $url .= $this->date_components[CYEAR].'-';
- $res .=
- '<a href="'.$url.'">'
- .$this->get_date_component_label($this->date_components[CYEAR])
- .'</a>';
+ $nb_days = $md[2];
+ if ( ($year%4==0) and ( ($year%100!=0) or ($year%400!=0) ) )
+ {
+ $nb_days++;
+ }
}
- if ( isset($this->date_components[CMONTH]) )
+ elseif ( is_numeric($month) )
{
- $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>';
+ $nb_days = $md[ $month ];
}
- if ( isset($this->date_components[CDAY]) )
+ else
{
- $res .= $conf['level_separator'];
- $url .= $this->date_components[CDAY].'-';
- $res .=
- '<a href="'.$url.'">'
- .$this->get_date_component_label($this->date_components[CDAY])
- .'</a>';
+ $nb_days = 31;
}
-
- return $res;
-}
-
-
-//--------------------------------------------------------- private members ---
-function build_nav_bar2($level, $sql_func, $labels=null)
-{
- parent::build_nav_bar($level, $sql_func, '', $labels);
+ return range(1, $nb_days);
}
function build_global_calendar()
{
assert( count($this->date_components) == 0 );
$query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%Y%m")) as period,
- COUNT(id) as count';
+ COUNT( DISTINCT(id) ) as count';
$query.= $this->inner_sql;
$query.= $this->get_date_where();
$query.= '
GROUP BY period';
$result = pwg_query($query);
+ $items=array();
while ($row = mysql_fetch_array($result))
{
$y = substr($row['period'], 0, 4);
@@ -252,8 +255,8 @@ function build_global_calendar()
$nav_bar .= '</span><br>';
$url_base .= '-';
- $nav_bar .= $this->get_nav_bar_from_items( $url_base,
- $year_data['children'], null, 'calCal', false, $lang['month'] );
+ $nav_bar .= $this->get_nav_bar_from_items( $url_base,
+ $year_data['children'], null, 'calCal', false, false, $lang['month'] );
$template->assign_block_vars( 'calendar.calbar',
array( 'BAR' => $nav_bar)
@@ -266,13 +269,14 @@ function build_year_calendar()
{
assert( count($this->date_components) == 1 );
$query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%m%d")) as period,
- COUNT(id) as count';
+ COUNT( DISTINCT(id) ) as count';
$query.= $this->inner_sql;
$query.= $this->get_date_where();
$query.= '
GROUP BY period';
$result = pwg_query($query);
+ $items=array();
while ($row = mysql_fetch_array($result))
{
$m = (int)substr($row['period'], 0, 2);
@@ -307,7 +311,7 @@ function build_year_calendar()
$nav_bar .= '</span><br>';
$url_base .= '-';
- $nav_bar .= $this->get_nav_bar_from_items( $url_base,
+ $nav_bar .= $this->get_nav_bar_from_items( $url_base,
$month_data['children'], null, 'calCal', false );
$template->assign_block_vars( 'calendar.calbar',
@@ -331,18 +335,11 @@ function build_month_calendar()
while ($row = mysql_fetch_array($result))
{
$d = $row['period'];
- $items[$d] = $row['count'];
+ $items[$d] = array('nb_images'=>$row['count']);
}
- global $lang, $template;
-
- $template->assign_block_vars('thumbnails', array());
- $template->assign_block_vars('thumbnails.line', array());
- foreach ( $items as $day=>$nb_images)
+ foreach ( $items as $day=>$data)
{
- $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';
@@ -354,16 +351,28 @@ SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw';
unset ( $this->date_components[CDAY] );
$row = mysql_fetch_array(pwg_query($query));
+ $items[$day]['tn_path'] = get_thumbnail_src($row['path'], @$row['tn_ext']);
+ $items[$day]['tn_file'] = $row['file'];
+ $items[$day]['tn_dw'] = $row['dw'];
+ }
+
+ global $lang, $template;
+ $template->assign_block_vars('thumbnails', array());
+ $template->assign_block_vars('thumbnails.line', array());
+ foreach ( $items as $day=>$data)
+ {
+ $url_base = $this->url_base.
+ $this->date_components[CYEAR].'-'.
+ $this->date_components[CMONTH].'-'.$day;
- $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']);
- $thumbnail_title = $lang['day'][$row['dw']] . ' ' . $day;
- $name = $thumbnail_title .' ('.$nb_images.')';
+ $thumbnail_title = $lang['day'][$data['tn_dw']] . ' ' . $day;
+ $name = $thumbnail_title .' ('.$data['nb_images'].')';
$template->assign_block_vars(
'thumbnails.line.thumbnail',
array(
- 'IMAGE'=>$thumbnail_src,
- 'IMAGE_ALT'=>$row['file'],
+ 'IMAGE'=>$data['tn_path'],
+ 'IMAGE_ALT'=>$data['tn_file'],
'IMAGE_TITLE'=>$thumbnail_title,
'U_IMG_LINK'=>$url_base
)
@@ -375,6 +384,7 @@ SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw';
)
);
}
+
return true;
}
diff --git a/include/calendar_weekly.class.php b/include/calendar_weekly.class.php
index 5ab550e29..786f90c68 100644
--- a/include/calendar_weekly.class.php
+++ b/include/calendar_weekly.class.php
@@ -36,32 +36,58 @@ define ('CDAY', 2);
class Calendar extends CalendarBase
{
+ /**
+ * 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, $date_components)
+ {
+ parent::initialize($date_field, $inner_sql, $date_components);
+ global $lang;
+ $this->calendar_levels = array(
+ array(
+ 'sql'=> 'YEAR('.$this->date_field.')',
+ 'labels' => null
+ ),
+ array(
+ 'sql'=> 'WEEK('.$this->date_field.')+1',
+ 'labels' => null
+ ),
+ array(
+ 'sql'=> 'DAYOFWEEK('.$this->date_field.')-1',
+ 'labels' => $lang['day']
+ ),
+ );
+ //Comment next lines for week starting on Sunday or if MySQL version<4.0.17
+ //WEEK(date,5) = "0-53 - Week 1=the first week with a Monday in this year"
+ $this->calendar_levels[CWEEK]['sql'] = 'WEEK('.$this->date_field.',5)+1';
+ $this->calendar_levels[CDAY]['sql'] = 'WEEKDAY('.$this->date_field.')';
+ array_push( $this->calendar_levels[CDAY]['labels'],
+ array_shift( $this->calendar_levels[CDAY]['labels'] ) );
+ }
+
/**
* 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)
{
- global $lang, $conf;
+ global $conf;
$this->url_base = $url_base;
assert($view_type==CAL_VIEW_LIST);
- 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(CYEAR); // years
+ if ( count($this->date_components)>=1 )
{
- $this->build_nav_bar(CWEEK, 'WEEK', '+1' ); // month
+ $this->build_nav_bar(CWEEK); // week nav bar 1-53
}
if ( count($this->date_components)>=2 )
{
- $this->build_nav_bar(CDAY, 'DAYOFWEEK', '-1',
- $lang['day'] ); // days
+ $this->build_nav_bar(CDAY); // days nav bar Mon-Sun
}
return false;
}
@@ -75,26 +101,25 @@ function generate_category_content($url_base, $view_type)
*/
function get_date_where($max_levels=3)
{
- $date_components = $this->date_components;
- while (count($date_components)>$max_levels)
+ $date = $this->date_components;
+ while (count($date)>$max_levels)
{
- array_pop($date_components);
+ array_pop($date);
}
$res = '';
- if (isset($date_components[CYEAR]) and $date_components[CYEAR]!='any')
+ if (isset($date[CYEAR]) and $date[CYEAR]!='any')
{
- $y = $date_components[CYEAR];
+ $y = $date[CYEAR];
$res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'";
}
- if (isset($date_components[CWEEK]) and $date_components[CWEEK]!='any')
+ if (isset($date[CWEEK]) and $date[CWEEK]!='any')
{
- $res .= ' AND WEEK('.$this->date_field.')+1='.$date_components[CWEEK];
+ $res .= ' AND '.$this->calendar_levels[CWEEK]['sql'].'='.$date[CWEEK];
}
- if (isset($date_components[CDAY]) and $date_components[CDAY]!='any')
+ if (isset($date[CDAY]) and $date[CDAY]!='any')
{
- $res .= ' AND DAYOFWEEK('.$this->date_field.')-1='
- .$date_components[CDAY];
+ $res .= ' AND '.$this->calendar_levels[CDAY]['sql'].'='.$date[CDAY];
}
if (empty($res))
{
@@ -103,44 +128,6 @@ function get_date_where($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 a21351241..224e906b4 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -90,7 +90,7 @@ $conf['anti-flood_time'] = 60;
// catgory
$conf['calendar_datefield'] = 'date_creation';
-// calendar_multi_bar : the calendar shows a maximum number of
+// calendar_multi_bar : the calendar shows a maximum number of
// year/month/week/day navigation bars
$conf['calendar_multi_bar'] = true;
@@ -98,6 +98,10 @@ $conf['calendar_multi_bar'] = true;
// year/month/week/day navigation bars
$conf['calendar_show_any'] = true;
+// calendar_show_empty : the calendar shows month/weeks/days even if there are
+//no elements for these
+$conf['calendar_show_empty'] = true;
+
// newcat_default_commentable : at creation, must a category be commentable
// or not ?
$conf['newcat_default_commentable'] = 'true';
@@ -249,7 +253,7 @@ $conf['show_exif'] = true;
//
// for PHP version newer than 4.1.2 :
// $conf['show_exif_fields'] = array('CameraMake','CameraModel','DateTime');
-//
+//
$conf['show_exif_fields'] = array(
'Make',
'Model',
@@ -270,11 +274,11 @@ $conf['use_exif_mapping'] = array(
// | sessions |
// +-----------------------------------------------------------------------+
-// session_use_cookies: specifies to use cookie to store
+// session_use_cookies: specifies to use cookie to store
// the session id on client side
$conf['session_use_cookies'] = true;
-// session_use_only_cookies: specifies to only use cookie to store
+// session_use_only_cookies: specifies to only use cookie to store
// the session id on client side
$conf['session_use_only_cookies'] = true;
@@ -284,7 +288,7 @@ $conf['session_use_trans_sid'] = false;
// session_name: specifies the name of the session which is used as cookie name
$conf['session_name'] = 'pwg_id';
-// session_save_handler: comment the line below
+// session_save_handler: comment the line below
// to use file handler for sessions.
$conf['session_save_handler'] = 'db';
diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php
index 6f6a5f44b..1606b4307 100644
--- a/include/functions_calendar.inc.php
+++ b/include/functions_calendar.inc.php
@@ -52,21 +52,21 @@ function initialize_calendar()
//------------------ initialize the condition on items to take into account ---
$inner_sql = ' FROM ' . IMAGES_TABLE;
-
+
if (!isset($page['cat']) or is_numeric($page['cat']))
{ // we will regenerate the items by including subcats elements
$page['cat_nb_images'] = 0;
$page['items'] = array();
$inner_sql .= '
INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id';
-
+
if (isset($page['cat']) and is_numeric($page['cat']))
{
$sub_ids = array_diff(
get_subcat_ids(array($page['cat'])),
explode(',', $user['forbidden_categories'])
);
-
+
if (empty($sub_ids))
{
return; // nothing to do
@@ -101,16 +101,14 @@ WHERE id IN (' . implode(',',$page['items']) .')';
$fields = array(
// Created
'created' => array(
- // TODO change next line when calendar_datefield disapears
- 'default_link' => ( $conf['calendar_datefield']=='date_creation' ? '' : 'created-' ),
+ 'default_link' => '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'),
+ 'default_link' => 'posted-',
+ 'label' => l10n('Post date'),
'db_field' => 'date_available',
),
);
@@ -119,14 +117,12 @@ WHERE id IN (' . implode(',',$page['items']) .')';
// Monthly style
'monthly' => array(
'default_link' => '',
- 'label' => l10n('Monthly'),
'include' => 'calendar_monthly.class.php',
'view_calendar' => true,
),
- // Weekly style
+ // Weekly style
'weekly' => array(
'default_link' => 'weekly-',
- 'label' => l10n('Weekly'),
'include' => 'calendar_weekly.class.php',
'view_calendar' => false,
),
@@ -136,20 +132,18 @@ WHERE id IN (' . implode(',',$page['items']) .')';
// 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']);
-
+
// 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']);
@@ -190,23 +184,27 @@ WHERE id IN (' . implode(',',$page['items']) .')';
array_pop($requested);
}
}
+ else
+ {
+ $requested[$i] = (int)$requested[$i];
+ }
}
if ($any_count == 3)
{
array_pop($requested);
}
-
+
$calendar->initialize($fields[$cal_field]['db_field'], $inner_sql, $requested);
-
- //echo ('<pre>'. var_export($fields, true) . '</pre>');
+ //echo ('<pre>'. var_export($calendar, true) . '</pre>');
+
+ $url_base = get_query_string_diff(array('start', 'calendar'));
$url_base =
PHPWG_ROOT_PATH.'category.php'
- .get_query_string_diff(array('start', 'calendar'))
+ .$url_base
.(empty($url_base) ? '?' : '&')
.'calendar='.$cal_field.'-'
;
-
$must_show_list = true; // true until calendar generates its own display
if (basename($_SERVER["PHP_SELF"]) == 'category.php')
{
@@ -223,10 +221,10 @@ WHERE id IN (' . implode(',',$page['items']) .')';
$page['items'],
$page['cat_nb_images']
);
-
+
$must_show_list = false;
}
-
+
$template->assign_block_vars( 'calendar.views', array() );
foreach ($styles as $style => $style_data)
{
@@ -255,7 +253,7 @@ WHERE id IN (' . implode(',',$page['items']) .')';
'calendar.views.view',
array(
'VALUE' => $url,
- 'CONTENT' => $style_data['label'].' ('.$view_data['label'].')',
+ 'CONTENT' => l10n('calendar_'.$style.'_'.$view),
'SELECTED' => $selected,
)
);
@@ -264,17 +262,17 @@ WHERE id IN (' . implode(',',$page['items']) .')';
}
} // end category calling
- $calendar_title =
+ $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,
+ 'TITLE' => '<br/>'.$calendar_title,
)
);
-
+
if ($must_show_list)
{
$query = 'SELECT DISTINCT(id)';
@@ -289,7 +287,7 @@ WHERE id IN (' . implode(',',$page['items']) .')';
{
$order_by = str_replace(
'ORDER BY ',
- 'ORDER BY '.$calendar->date_field.',', $conf['order_by']
+ 'ORDER BY '.$calendar->date_field.' DESC,', $conf['order_by']
);
$query .= $order_by;
}
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index f7c5b926b..23a50b354 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -28,7 +28,7 @@
/**
* Provides functions to handle categories.
*
- *
+ *
*/
/**
@@ -67,9 +67,9 @@ function check_restrictions($category_id)
function get_categories_menu()
{
global $page,$user;
-
+
$infos = array('');
-
+
$query = '
SELECT name,id,date_last,nb_images,global_rank
FROM '.CATEGORIES_TABLE.'
@@ -119,7 +119,7 @@ SELECT COUNT(DISTINCT(image_id)) as total
WHERE category_id NOT IN ('.$user['forbidden_categories'].')
;';
list($total) = mysql_fetch_array(pwg_query($query));
-
+
return $total;
}
@@ -135,7 +135,7 @@ SELECT COUNT(DISTINCT(image_id)) as total
* - nb_images
* - id_uppercat
* - site_id
- * -
+ * -
*
* @param int category id
* @return array
@@ -145,7 +145,7 @@ function get_cat_info( $id )
$infos = array('nb_images','id_uppercat','comment','site_id'
,'dir','date_last','uploadable','status','visible'
,'representative_picture_id','uppercats','commentable');
-
+
$query = '
SELECT '.implode(',', $infos).'
FROM '.CATEGORIES_TABLE.'
@@ -196,7 +196,7 @@ SELECT name,id
{
$cat['name'][$cat_id] = $names[$cat_id];
}
-
+
return $cat;
}
@@ -274,11 +274,11 @@ function get_category_preferred_image_orders()
{
global $conf;
return array(
- array('Default', '', true),
+ array(l10n('default_sort'), '', true),
array(l10n('Average rate'), 'average_rate DESC', $conf['rate']),
array(l10n('most_visited_cat'), 'hit DESC', true),
array(l10n('Creation date'), 'date_creation DESC', true),
- array(l10n('Availability date'), 'date_available DESC', true),
+ array(l10n('Post date'), 'date_available DESC', true),
array(l10n('File name'), 'file ASC', true)
);
}
@@ -310,7 +310,7 @@ function display_select_categories($categories,
(3 * substr_count($category['global_rank'], '.')));
$option.= '- '.$category['name'];
}
-
+
$template->assign_block_vars(
$blockname,
array('SELECTED'=>$selected,