aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/functions_calendar.inc.php30
1 files changed, 21 insertions, 9 deletions
diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php
index 2f71e5d94..30cdb0db0 100644
--- a/include/functions_calendar.inc.php
+++ b/include/functions_calendar.inc.php
@@ -36,7 +36,7 @@ define('CAL_VIEW_CALENDAR', 'calendar');
*/
function initialize_calendar()
{
- global $page, $conf, $user, $template, $filter;
+ global $page, $conf, $user, $template, $persistent_cache, $filter;
//------------------ initialize the condition on items to take into account ---
$inner_sql = ' FROM ' . IMAGES_TABLE;
@@ -269,14 +269,9 @@ WHERE id IN (' . implode(',',$page['items']) .')';
if ($must_show_list)
{
- $query = 'SELECT DISTINCT id ';
- $query .= ','.$calendar->date_field;
- $query .= $calendar->inner_sql.'
- '.$calendar->get_date_where();
if ( isset($page['super_order_by']) )
{
- $query .= '
- '.$conf['order_by'];
+ $order_by = $conf['order_by'];
}
else
{
@@ -293,10 +288,27 @@ WHERE id IN (' . implode(',',$page['items']) .')';
'ORDER BY ',
'ORDER BY '.$calendar->date_field.$order, $conf['order_by']
);
- $query .= '
+ }
+
+ if ('categories'==$page['section'] && !isset($page['category'])
+ && ( count($page['chronology_date'])==0
+ OR ($page['chronology_date'][0]=='any' && count($page['chronology_date'])==1) )
+ )
+ {
+ $cache_key = $persistent_cache->make_key($user['id'].$user['cache_update_time']
+ .$calendar->date_field.$order_by);
+ }
+
+ if ( !isset($cache_key) || !$persistent_cache->get($cache_key, $page['items']))
+ {
+ $query = 'SELECT DISTINCT id '
+ .$calendar->inner_sql.'
+ '.$calendar->get_date_where().'
'.$order_by;
+ $page['items'] = array_from_query($query, 'id');
+ if ( isset($cache_key) )
+ $persistent_cache->set($cache_key, $page['items']);
}
- $page['items'] = array_from_query($query, 'id');
}
pwg_debug('end initialize_calendar');
}