mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 17:23:04 +02:00
URL rewrite for chronology: uses $page['chronology'] and
$page['chronology_date']. $page['chronology'] is an array with 'field', 'style' and 'view' keys. This is step 1. git-svn-id: http://piwigo.org/svn/trunk@1086 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -33,10 +33,6 @@ class CalendarBase
|
||||
var $date_field;
|
||||
// used for queries (INNER JOIN or normal)
|
||||
var $inner_sql;
|
||||
// base url used when generating html links
|
||||
var $url_base;
|
||||
// array of date components e.g. (2005,10,12) ...
|
||||
var $date_components;
|
||||
//
|
||||
var $calendar_levels;
|
||||
|
||||
@@ -44,44 +40,48 @@ class 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)
|
||||
function initialize($inner_sql)
|
||||
{
|
||||
$this->date_field = $date_field;
|
||||
global $page;
|
||||
if ($page['chronology']['field']=='posted')
|
||||
{
|
||||
$this->date_field = 'date_available';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->date_field = 'date_creation';
|
||||
}
|
||||
$this->inner_sql = $inner_sql;
|
||||
$this->date_components = $date_components;
|
||||
$this->has_nav_bar = false;
|
||||
}
|
||||
|
||||
function get_display_name()
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $page;
|
||||
$res = '';
|
||||
$url = $this->url_base;
|
||||
|
||||
for ($i=0; $i<count($this->date_components); $i++)
|
||||
for ($i=0; $i<count($page['chronology_date']); $i++)
|
||||
{
|
||||
$res .= $conf['level_separator'];
|
||||
if ($i>0)
|
||||
{
|
||||
$url .= '-';
|
||||
}
|
||||
$url .= $this->date_components[$i];
|
||||
if ( isset($this->date_components[$i+1]) )
|
||||
if ( isset($page['chronology_date'][$i+1]) )
|
||||
{
|
||||
$chronology_date = array_slice($page['chronology_date'],0, $i+1);
|
||||
$url = duplicate_index_url(
|
||||
array( 'chronology_date'=>$chronology_date ),
|
||||
array( 'start' )
|
||||
);
|
||||
$res .=
|
||||
'<a href="'.$url.'">'
|
||||
.$this->get_date_component_label($i, $this->date_components[$i])
|
||||
.$this->get_date_component_label($i, $page['chronology_date'][$i])
|
||||
.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$res .=
|
||||
'<span class="calInHere">'
|
||||
.$this->get_date_component_label($i, $this->date_components[$i])
|
||||
.$this->get_date_component_label($i, $page['chronology_date'][$i])
|
||||
.'</span>';
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ class CalendarBase
|
||||
/**
|
||||
* Creates a calendar navigation bar.
|
||||
*
|
||||
* @param string url_base - links start with this root
|
||||
* @param array date_components
|
||||
* @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
|
||||
@@ -140,11 +140,11 @@ class CalendarBase
|
||||
* @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,
|
||||
function get_nav_bar_from_items($date_components, $items, $selected_item,
|
||||
$class_prefix, $show_any,
|
||||
$show_empty=false, $labels=null)
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $page;
|
||||
|
||||
$nav_bar = '';
|
||||
|
||||
@@ -180,7 +180,10 @@ class CalendarBase
|
||||
else
|
||||
{
|
||||
$nav_bar .= '<span class="'.$class_prefix.'">';
|
||||
$url = $url_base . $item;
|
||||
$url = duplicate_index_url(
|
||||
array('chronology_date'=>array_merge($date_components,$item)),
|
||||
array( 'start' )
|
||||
);
|
||||
$nav_bar .= '<a href="'.$url.'">';
|
||||
$nav_bar .= $label;
|
||||
$nav_bar .= '</a>';
|
||||
@@ -203,7 +206,10 @@ class CalendarBase
|
||||
else
|
||||
{
|
||||
$nav_bar .= '<span class="'.$class_prefix.'">';
|
||||
$url = $url_base . 'any';
|
||||
$url = duplicate_index_url(
|
||||
array('chronology_date'=>array_merge($date_components,'any')),
|
||||
array( 'start' )
|
||||
);
|
||||
$nav_bar .= '<a href="'.$url.'">';
|
||||
$nav_bar .= $label;
|
||||
$nav_bar .= '</a>';
|
||||
@@ -221,7 +227,7 @@ class CalendarBase
|
||||
*/
|
||||
function build_nav_bar($level, $labels=null)
|
||||
{
|
||||
global $template, $conf;
|
||||
global $template, $conf, $page;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT('.$this->calendar_levels[$level]['sql']
|
||||
@@ -240,14 +246,14 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql']
|
||||
}
|
||||
|
||||
if ( count($level_items)==1 and
|
||||
count($this->date_components)<count($this->calendar_levels)-1)
|
||||
count($page['chronology_date'])<count($this->calendar_levels)-1)
|
||||
{
|
||||
if ( ! isset($this->date_components[$level]) )
|
||||
if ( ! isset($page['chronology_date'][$level]) )
|
||||
{
|
||||
list($key) = array_keys($level_items);
|
||||
$this->date_components[$level] = (int)$key;
|
||||
$page['chronology_date'][$level] = (int)$key;
|
||||
|
||||
if ( $level<count($this->date_components) and
|
||||
if ( $level<count($page['chronology_date']) and
|
||||
$level!=count($this->calendar_levels)-1 )
|
||||
{
|
||||
return;
|
||||
@@ -255,16 +261,8 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql']
|
||||
}
|
||||
}
|
||||
|
||||
$url_base = $this->url_base;
|
||||
for ($i=0; $i<$level; $i++)
|
||||
{
|
||||
if (isset($this->date_components[$i]))
|
||||
{
|
||||
$url_base .= $this->date_components[$i].'-';
|
||||
}
|
||||
}
|
||||
$nav_bar = $this->get_nav_bar_from_items(
|
||||
$url_base,
|
||||
$page['chronology_date'],
|
||||
$level_items,
|
||||
null,
|
||||
'calItem',
|
||||
@@ -288,14 +286,14 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql']
|
||||
*/
|
||||
function build_next_prev()
|
||||
{
|
||||
global $template;
|
||||
global $template, $page;
|
||||
$prev = $next =null;
|
||||
if ( empty($this->date_components) )
|
||||
if ( empty($page['chronology_date']) )
|
||||
return;
|
||||
$query = 'SELECT CONCAT_WS("-"';
|
||||
for ($i=0; $i<count($this->date_components); $i++)
|
||||
for ($i=0; $i<count($page['chronology_date']); $i++)
|
||||
{
|
||||
if ( 'any' === $this->date_components[$i] )
|
||||
if ( 'any' === $page['chronology_date'] )
|
||||
{
|
||||
$query .= ','.'"any"';
|
||||
}
|
||||
@@ -304,7 +302,7 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql']
|
||||
$query .= ','.$this->calendar_levels[$i]['sql'];
|
||||
}
|
||||
}
|
||||
$current = implode('-', $this->date_components );
|
||||
$current = implode('-', $page['chronology_date'] );
|
||||
|
||||
$query.=') as period' . $this->inner_sql .'
|
||||
AND ' . $this->date_field . ' IS NOT NULL
|
||||
@@ -327,26 +325,32 @@ GROUP BY period';
|
||||
{
|
||||
$template->assign_block_vars( 'calendar.navbar', array() );
|
||||
}
|
||||
|
||||
if ( $current_rank>0 )
|
||||
{ // has previous
|
||||
$prev = $upper_items[$current_rank-1];
|
||||
$chronology_date = explode('-', $prev);
|
||||
$template->assign_block_vars(
|
||||
'calendar.navbar.prev',
|
||||
array(
|
||||
'LABEL' => $this->get_date_nice_name($prev),
|
||||
'URL' => $this->url_base . $prev,
|
||||
'URL' => duplicate_index_url(
|
||||
array('chronology_date'=>$chronology_date), array('start')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
if ( $current_rank < count($upper_items)-1 )
|
||||
{
|
||||
// has next
|
||||
{ // has next
|
||||
$next = $upper_items[$current_rank+1];
|
||||
$chronology_date = explode('-', $next);
|
||||
$template->assign_block_vars(
|
||||
'calendar.navbar.next',
|
||||
array(
|
||||
'LABEL' => $this->get_date_nice_name($next),
|
||||
'URL' => $this->url_base . $next,
|
||||
'URL' => duplicate_index_url(
|
||||
array('chronology_date'=>$chronology_date), array('start')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
@@ -38,13 +38,11 @@ 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)
|
||||
function initialize($inner_sql)
|
||||
{
|
||||
parent::initialize($date_field, $inner_sql, $date_components);
|
||||
parent::initialize($inner_sql);
|
||||
global $lang;
|
||||
$this->calendar_levels = array(
|
||||
array(
|
||||
@@ -67,21 +65,20 @@ class Calendar extends CalendarBase
|
||||
* @return boolean false to indicate that thumbnails
|
||||
* where not included here, true otherwise
|
||||
*/
|
||||
function generate_category_content($url_base, $view_type)
|
||||
function generate_category_content()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->url_base = $url_base;
|
||||
global $conf, $page;
|
||||
|
||||
$view_type = $page['chronology']['view'];
|
||||
if ($view_type==CAL_VIEW_CALENDAR)
|
||||
{
|
||||
if ( count($this->date_components)==0 )
|
||||
if ( count($page['chronology_date'])==0 )
|
||||
{//case A: no year given - display all years+months
|
||||
if ($this->build_global_calendar())
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( count($this->date_components)==1 )
|
||||
if ( count($page['chronology_date'])==1 )
|
||||
{//case B: year given - display all days in given year
|
||||
if ($this->build_year_calendar())
|
||||
{
|
||||
@@ -90,7 +87,7 @@ function generate_category_content($url_base, $view_type)
|
||||
}
|
||||
}
|
||||
|
||||
if ( count($this->date_components)==2 )
|
||||
if ( count($page['chronology_date'])==2 )
|
||||
{//case C: year+month given - display a nice month calendar
|
||||
$this->build_month_calendar();
|
||||
//$this->build_nav_bar(CYEAR); // years
|
||||
@@ -100,21 +97,21 @@ function generate_category_content($url_base, $view_type)
|
||||
}
|
||||
}
|
||||
|
||||
if ($view_type==CAL_VIEW_LIST or count($this->date_components)==3)
|
||||
if ($view_type==CAL_VIEW_LIST or count($page['chronology_date'])==3)
|
||||
{
|
||||
$has_nav_bar = false;
|
||||
if ( count($this->date_components)==0 )
|
||||
if ( count($page['chronology_date'])==0 )
|
||||
{
|
||||
$this->build_nav_bar(CYEAR); // years
|
||||
}
|
||||
if ( count($this->date_components)==1)
|
||||
if ( count($page['chronology_date'])==1)
|
||||
{
|
||||
$this->build_nav_bar(CMONTH); // month
|
||||
}
|
||||
if ( count($this->date_components)==2 )
|
||||
if ( count($page['chronology_date'])==2 )
|
||||
{
|
||||
$day_labels = range( 1, $this->get_all_days_in_month(
|
||||
$this->date_components[CYEAR] ,$this->date_components[CMONTH] ) );
|
||||
$page['chronology_date'][CYEAR] ,$page['chronology_date'][CMONTH] ) );
|
||||
array_unshift($day_labels, 0);
|
||||
unset( $day_labels[0] );
|
||||
$this->build_nav_bar( CDAY, $day_labels ); // days
|
||||
@@ -133,7 +130,8 @@ function generate_category_content($url_base, $view_type)
|
||||
*/
|
||||
function get_date_where($max_levels=3)
|
||||
{
|
||||
$date = $this->date_components;
|
||||
global $page;
|
||||
$date = $page['chronology_date'];
|
||||
while (count($date)>$max_levels)
|
||||
{
|
||||
array_pop($date);
|
||||
@@ -218,7 +216,8 @@ function get_all_days_in_month($year, $month)
|
||||
|
||||
function build_global_calendar()
|
||||
{
|
||||
assert( count($this->date_components) == 0 );
|
||||
global $page;
|
||||
assert( count($page['chronology_date']) == 0 );
|
||||
$query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%Y%m")) as period,
|
||||
COUNT( DISTINCT(id) ) as count';
|
||||
$query.= $this->inner_sql;
|
||||
@@ -244,21 +243,21 @@ function build_global_calendar()
|
||||
if (count($items)==1)
|
||||
{// only one year exists so bail out to year view
|
||||
list($y) = array_keys($items);
|
||||
$this->date_components[CYEAR] = $y;
|
||||
$page['chronology_date'][CYEAR] = $y;
|
||||
return false;
|
||||
}
|
||||
|
||||
global $lang, $template;
|
||||
foreach ( $items as $year=>$year_data)
|
||||
{
|
||||
$url_base = $this->url_base.$year;
|
||||
$chronology_date = array( $year );
|
||||
$url = duplicate_index_url( array('chronology_date'=>$chronology_date) );
|
||||
|
||||
$nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">'.$year.'</a>';
|
||||
$nav_bar = '<span class="calCalHead"><a href="'.$url.'">'.$year.'</a>';
|
||||
$nav_bar .= ' ('.$year_data['nb_images'].')';
|
||||
$nav_bar .= '</span><br>';
|
||||
|
||||
$url_base .= '-';
|
||||
$nav_bar .= $this->get_nav_bar_from_items( $url_base,
|
||||
$nav_bar .= $this->get_nav_bar_from_items( $chronology_date,
|
||||
$year_data['children'], null, 'calCal', false, false, $lang['month'] );
|
||||
|
||||
$template->assign_block_vars( 'calendar.calbar',
|
||||
@@ -270,7 +269,8 @@ function build_global_calendar()
|
||||
|
||||
function build_year_calendar()
|
||||
{
|
||||
assert( count($this->date_components) == 1 );
|
||||
global $page;
|
||||
assert( count($page['chronology_date']) == 1 );
|
||||
$query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%m%d")) as period,
|
||||
COUNT( DISTINCT(id) ) as count';
|
||||
$query.= $this->inner_sql;
|
||||
@@ -294,21 +294,21 @@ function build_year_calendar()
|
||||
if (count($items)==1)
|
||||
{ // only one month exists so bail out to month view
|
||||
list($m) = array_keys($items);
|
||||
$this->date_components[CMONTH] = $m;
|
||||
$page['chronology_date'][CMONTH] = $m;
|
||||
return false;
|
||||
}
|
||||
global $lang, $template;
|
||||
foreach ( $items as $month=>$month_data)
|
||||
{
|
||||
$url_base = $this->url_base.$this->date_components[CYEAR].'-'.$month;
|
||||
$chronology_date = array( $page['chronology_date'][CYEAR], $month );
|
||||
$url = duplicate_index_url( array('chronology_date'=>$chronology_date) );
|
||||
|
||||
$nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">';
|
||||
$nav_bar = '<span class="calCalHead"><a href="'.$url.'">';
|
||||
$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,
|
||||
$nav_bar .= $this->get_nav_bar_from_items( $chronology_date,
|
||||
$month_data['children'], null, 'calCal', false );
|
||||
|
||||
$template->assign_block_vars( 'calendar.calbar',
|
||||
@@ -321,10 +321,11 @@ function build_year_calendar()
|
||||
|
||||
function build_month_calendar()
|
||||
{
|
||||
global $page;
|
||||
$query='SELECT DISTINCT(DAYOFMONTH('.$this->date_field.')) as period,
|
||||
COUNT( DISTINCT(id) ) as count';
|
||||
$query.= $this->inner_sql;
|
||||
$query.= $this->get_date_where($this->date_components);
|
||||
$query.= $this->get_date_where();
|
||||
$query.= '
|
||||
GROUP BY period';
|
||||
|
||||
@@ -337,7 +338,7 @@ function build_month_calendar()
|
||||
|
||||
foreach ( $items as $day=>$data)
|
||||
{
|
||||
$this->date_components[CDAY]=$day;
|
||||
$page['chronology_date'][CDAY]=$day;
|
||||
$query = '
|
||||
SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as dow';
|
||||
$query.= $this->inner_sql;
|
||||
@@ -345,7 +346,7 @@ SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as do
|
||||
$query.= '
|
||||
ORDER BY RAND()
|
||||
LIMIT 0,1';
|
||||
unset ( $this->date_components[CDAY] );
|
||||
unset ( $page['chronology_date'][CDAY] );
|
||||
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
$items[$day]['tn_path'] = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
@@ -416,8 +417,11 @@ SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as do
|
||||
$template->assign_block_vars('calendar.thumbnails.row.col', array());
|
||||
$template->assign_block_vars('calendar.thumbnails.row.col.blank', array());
|
||||
}
|
||||
for ($day=1; $day<=$this->get_all_days_in_month(
|
||||
$this->date_components[CYEAR] ,$this->date_components[CMONTH]); $day++)
|
||||
for ( $day = 1;
|
||||
$day <= $this->get_all_days_in_month(
|
||||
$page['chronology_date'][CYEAR], $page['chronology_date'][CMONTH]
|
||||
);
|
||||
$day++)
|
||||
{
|
||||
$dow = ($first_day_dow + $day-1)%7;
|
||||
if ($dow==0)
|
||||
@@ -486,9 +490,16 @@ SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as do
|
||||
{
|
||||
$css_style.='top:'.round(-$pos_top).'px;';
|
||||
}
|
||||
$url = $this->url_base.
|
||||
$this->date_components[CYEAR].'-'.
|
||||
$this->date_components[CMONTH].'-'.$day;
|
||||
$url = duplicate_index_url(
|
||||
array(
|
||||
'chronology_date' =>
|
||||
array(
|
||||
$page['chronology_date'][CYEAR],
|
||||
$page['chronology_date'][CMONTH],
|
||||
$day
|
||||
)
|
||||
)
|
||||
);
|
||||
$alt = $wday_labels[$dow] . ' ' . $day.
|
||||
' ('.$items[$day]['nb_images'].')';
|
||||
$template->assign_block_vars('calendar.thumbnails.row.col.full',
|
||||
@@ -519,9 +530,16 @@ SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as do
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
foreach ( $items as $day=>$data)
|
||||
{
|
||||
$url = $this->url_base.
|
||||
$this->date_components[CYEAR].'-'.
|
||||
$this->date_components[CMONTH].'-'.$day;
|
||||
$url = duplicate_index_url(
|
||||
array(
|
||||
'chronology_date' =>
|
||||
array(
|
||||
$page['chronology_date'][CYEAR],
|
||||
$page['chronology_date'][CMONTH],
|
||||
$day
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$thumbnail_title = $lang['day'][$data['dow']] . ' ' . $day;
|
||||
$name = $thumbnail_title .' ('.$data['nb_images'].')';
|
||||
|
||||
@@ -38,13 +38,11 @@ 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)
|
||||
function initialize($inner_sql)
|
||||
{
|
||||
parent::initialize($date_field, $inner_sql, $date_components);
|
||||
parent::initialize($inner_sql);
|
||||
global $lang;
|
||||
$week_no_labels=array();
|
||||
for ($i=1; $i<=53; $i++)
|
||||
@@ -79,23 +77,19 @@ class Calendar extends CalendarBase
|
||||
* 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)
|
||||
function generate_category_content()
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $page;
|
||||
|
||||
$this->url_base = $url_base;
|
||||
|
||||
assert($view_type==CAL_VIEW_LIST);
|
||||
|
||||
if ( count($this->date_components)==0 )
|
||||
if ( count($page['chronology_date'])==0 )
|
||||
{
|
||||
$this->build_nav_bar(CYEAR); // years
|
||||
}
|
||||
if ( count($this->date_components)==1 )
|
||||
if ( count($page['chronology_date'])==1 )
|
||||
{
|
||||
$this->build_nav_bar(CWEEK, array()); // week nav bar 1-53
|
||||
}
|
||||
if ( count($this->date_components)==2 )
|
||||
if ( count($page['chronology_date'])==2 )
|
||||
{
|
||||
$this->build_nav_bar(CDAY); // days nav bar Mon-Sun
|
||||
}
|
||||
@@ -112,7 +106,8 @@ function generate_category_content($url_base, $view_type)
|
||||
*/
|
||||
function get_date_where($max_levels=3)
|
||||
{
|
||||
$date = $this->date_components;
|
||||
global $page;
|
||||
$date = $page['chronology_date'];
|
||||
while (count($date)>$max_levels)
|
||||
{
|
||||
array_pop($date);
|
||||
|
||||
+78
-60
@@ -223,7 +223,7 @@ function get_picture_size( $original_width, $original_height,
|
||||
$width = $original_width;
|
||||
$height = $original_height;
|
||||
$is_original_size = true;
|
||||
|
||||
|
||||
if ( $max_width != "" )
|
||||
{
|
||||
if ( $original_width > $max_width )
|
||||
@@ -249,13 +249,13 @@ function get_picture_size( $original_width, $original_height,
|
||||
if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) )
|
||||
{
|
||||
if ( $ratioWidth < $ratioHeight )
|
||||
{
|
||||
{
|
||||
$width = floor( $original_width / $ratioHeight );
|
||||
$height = $max_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
$width = $max_width;
|
||||
{
|
||||
$width = $max_width;
|
||||
$height = floor( $original_height / $ratioWidth );
|
||||
}
|
||||
$is_original_size = false;
|
||||
@@ -330,7 +330,7 @@ function add_style( $string, $search, $style )
|
||||
'<span style="'.$style.'">\\0</span>',
|
||||
$remaining );
|
||||
$return_string.= $treatment;
|
||||
|
||||
|
||||
return $return_string;
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ function replace_search( $string, $search )
|
||||
{
|
||||
// FIXME : with new advanced search, this function needs a rewrite
|
||||
return $string;
|
||||
|
||||
|
||||
$words = explode( ',', $search );
|
||||
$style = 'background-color:white;color:red;';
|
||||
foreach ( $words as $word ) {
|
||||
@@ -359,7 +359,7 @@ function pwg_log( $file, $category, $picture = '' )
|
||||
{
|
||||
$login = ($user['id'] == $conf['guest_id'])
|
||||
? 'guest' : addslashes($user['username']);
|
||||
|
||||
|
||||
$query = '
|
||||
INSERT INTO '.HISTORY_TABLE.'
|
||||
(date,login,IP,file,category,picture)
|
||||
@@ -387,7 +387,7 @@ function format_date($date, $type = 'us', $show_time = false)
|
||||
global $lang;
|
||||
|
||||
list($year,$month,$day,$hour,$minute,$second) = array(0,0,0,0,0,0);
|
||||
|
||||
|
||||
switch ( $type )
|
||||
{
|
||||
case 'us' :
|
||||
@@ -432,10 +432,10 @@ function format_date($date, $type = 'us', $show_time = false)
|
||||
function pwg_query($query)
|
||||
{
|
||||
global $conf,$page,$debug,$t2;
|
||||
|
||||
|
||||
$start = get_moment();
|
||||
$result = mysql_query($query) or my_error($query."\n");
|
||||
|
||||
|
||||
$time = get_moment() - $start;
|
||||
|
||||
if (!isset($page['count_queries']))
|
||||
@@ -443,10 +443,10 @@ function pwg_query($query)
|
||||
$page['count_queries'] = 0;
|
||||
$page['queries_time'] = 0;
|
||||
}
|
||||
|
||||
|
||||
$page['count_queries']++;
|
||||
$page['queries_time']+= $time;
|
||||
|
||||
|
||||
if ($conf['show_queries'])
|
||||
{
|
||||
$output = '';
|
||||
@@ -459,10 +459,10 @@ function pwg_query($query)
|
||||
$output.= "\n".'(total time : ';
|
||||
$output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)';
|
||||
$output.= "</pre>\n";
|
||||
|
||||
|
||||
$debug .= $output;
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -500,10 +500,10 @@ function redirect( $url )
|
||||
$title = 'redirection';
|
||||
|
||||
include( PHPWG_ROOT_PATH.'include/page_header.php' );
|
||||
|
||||
|
||||
$template->set_filenames( array( 'redirect' => 'redirect.tpl' ) );
|
||||
$template->parse('redirect');
|
||||
|
||||
|
||||
include( PHPWG_ROOT_PATH.'include/page_tail.php' );
|
||||
|
||||
exit();
|
||||
@@ -518,10 +518,10 @@ function redirect( $url )
|
||||
function get_query_string_diff($rejects = array())
|
||||
{
|
||||
$query_string = '';
|
||||
|
||||
|
||||
$str = $_SERVER['QUERY_STRING'];
|
||||
parse_str($str, $vars);
|
||||
|
||||
|
||||
$is_first = true;
|
||||
foreach ($vars as $key => $value)
|
||||
{
|
||||
@@ -553,7 +553,7 @@ function get_pwg_themes()
|
||||
$themes = array();
|
||||
|
||||
$template_dir = PHPWG_ROOT_PATH.'template';
|
||||
|
||||
|
||||
foreach (get_dirs($template_dir) as $template)
|
||||
{
|
||||
foreach (get_dirs($template_dir.'/'.$template.'/theme') as $theme)
|
||||
@@ -595,7 +595,7 @@ function get_thumbnail_src($path, $tn_ext = '')
|
||||
$src = get_themeconf('mime_icon_dir');
|
||||
$src.= strtolower(get_extension($path)).'.png';
|
||||
}
|
||||
|
||||
|
||||
return $src;
|
||||
}
|
||||
|
||||
@@ -622,7 +622,7 @@ function my_error($header)
|
||||
function array_from_query($query, $fieldname)
|
||||
{
|
||||
$array = array();
|
||||
|
||||
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
@@ -641,10 +641,10 @@ function array_from_query($query, $fieldname)
|
||||
function get_day_list($blockname, $selection)
|
||||
{
|
||||
global $template;
|
||||
|
||||
|
||||
$template->assign_block_vars(
|
||||
$blockname, array('SELECTED' => '', 'VALUE' => 0, 'OPTION' => '--'));
|
||||
|
||||
|
||||
for ($i = 1; $i <= 31; $i++)
|
||||
{
|
||||
$selected = '';
|
||||
@@ -668,7 +668,7 @@ function get_day_list($blockname, $selection)
|
||||
function get_month_list($blockname, $selection)
|
||||
{
|
||||
global $template, $lang;
|
||||
|
||||
|
||||
$template->assign_block_vars(
|
||||
$blockname, array('SELECTED' => '',
|
||||
'VALUE' => 0,
|
||||
@@ -697,9 +697,9 @@ function get_month_list($blockname, $selection)
|
||||
function fill_caddie($elements_id)
|
||||
{
|
||||
global $user;
|
||||
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
|
||||
|
||||
$query = '
|
||||
SELECT element_id
|
||||
FROM '.CADDIE_TABLE.'
|
||||
@@ -749,7 +749,7 @@ function l10n($key)
|
||||
{
|
||||
echo '[l10n] language key "'.$key.'" is not defined<br />';
|
||||
}
|
||||
|
||||
|
||||
return isset($lang[$key]) ? $lang[$key] : $key;
|
||||
}
|
||||
|
||||
@@ -797,14 +797,14 @@ function get_search_array($search_id)
|
||||
{
|
||||
die('Search id must be an integer');
|
||||
}
|
||||
|
||||
|
||||
$query = '
|
||||
SELECT rules
|
||||
FROM '.SEARCH_TABLE.'
|
||||
WHERE id = '.$search_id.'
|
||||
;';
|
||||
list($serialized_rules) = mysql_fetch_row(pwg_query($query));
|
||||
|
||||
|
||||
return unserialize($serialized_rules);
|
||||
}
|
||||
|
||||
@@ -820,11 +820,11 @@ SELECT rules
|
||||
function get_sql_search_clause($search_id)
|
||||
{
|
||||
$search = get_search_array($search_id);
|
||||
|
||||
|
||||
// SQL where clauses are stored in $clauses array during query
|
||||
// construction
|
||||
$clauses = array();
|
||||
|
||||
|
||||
foreach (array('file','name','comment','keywords','author') as $textfield)
|
||||
{
|
||||
if (isset($search['fields'][$textfield]))
|
||||
@@ -847,7 +847,7 @@ function get_sql_search_clause($search_id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($search['fields']['allwords']))
|
||||
{
|
||||
$fields = array('file', 'name', 'comment', 'keywords', 'author');
|
||||
@@ -875,12 +875,12 @@ function get_sql_search_clause($search_id)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
array_walk(
|
||||
$word_clauses,
|
||||
create_function('&$s','$s="(".$s.")";')
|
||||
);
|
||||
|
||||
|
||||
array_push(
|
||||
$clauses,
|
||||
"\n ".
|
||||
@@ -892,7 +892,7 @@ function get_sql_search_clause($search_id)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
foreach (array('date_available', 'date_creation') as $datefield)
|
||||
{
|
||||
if (isset($search['fields'][$datefield]))
|
||||
@@ -902,26 +902,26 @@ function get_sql_search_clause($search_id)
|
||||
$datefield." = '".$search['fields'][$datefield]['date']."'"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
foreach (array('after','before') as $suffix)
|
||||
{
|
||||
$key = $datefield.'-'.$suffix;
|
||||
|
||||
|
||||
if (isset($search['fields'][$key]))
|
||||
{
|
||||
array_push(
|
||||
$clauses,
|
||||
|
||||
|
||||
$datefield.
|
||||
($suffix == 'after' ? ' >' : ' <').
|
||||
($search['fields'][$key]['inc'] ? '=' : '').
|
||||
" '".$search['fields'][$key]['date']."'"
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($search['fields']['cat']))
|
||||
{
|
||||
if ($search['fields']['cat']['sub_inc'])
|
||||
@@ -933,22 +933,22 @@ function get_sql_search_clause($search_id)
|
||||
{
|
||||
$cat_ids = $search['fields']['cat']['words'];
|
||||
}
|
||||
|
||||
|
||||
$local_clause = 'category_id IN ('.implode(',', $cat_ids).')';
|
||||
array_push($clauses, $local_clause);
|
||||
}
|
||||
|
||||
|
||||
// adds brackets around where clauses
|
||||
$clauses = prepend_append_array_items($clauses, '(', ')');
|
||||
|
||||
|
||||
$where_separator =
|
||||
implode(
|
||||
"\n ".$search['mode'].' ',
|
||||
$clauses
|
||||
);
|
||||
|
||||
|
||||
$search_clause = $where_separator;
|
||||
|
||||
|
||||
if (isset($forbidden))
|
||||
{
|
||||
$search_clause.= "\n AND ".$forbidden;
|
||||
@@ -986,7 +986,7 @@ function get_available_upgrade_ids()
|
||||
$upgrades_path = PHPWG_ROOT_PATH.'install/db';
|
||||
|
||||
$available_upgrade_ids = array();
|
||||
|
||||
|
||||
if ($contents = opendir($upgrades_path))
|
||||
{
|
||||
while (($node = readdir($contents)) !== false)
|
||||
@@ -1015,11 +1015,8 @@ function make_index_URL($params = array())
|
||||
PHPWG_ROOT_PATH.'category.php?'
|
||||
.'/'.make_section_in_URL($params)
|
||||
;
|
||||
|
||||
if (isset($params['start']) and $params['start'] > 0)
|
||||
{
|
||||
$url.= '/start-'.$params['start'];
|
||||
}
|
||||
|
||||
$url = add_well_known_params_in_url($url, $params);
|
||||
|
||||
return $url;
|
||||
}
|
||||
@@ -1106,19 +1103,40 @@ function make_picture_URL($params)
|
||||
{
|
||||
die('make_picture_URL: image_id is a required parameter');
|
||||
}
|
||||
|
||||
|
||||
$url =
|
||||
PHPWG_ROOT_PATH.'picture.php?'
|
||||
.'/'.$params['image_id']
|
||||
.'/'.make_section_in_URL($params)
|
||||
;
|
||||
|
||||
// first comment to start on
|
||||
$url = add_well_known_params_in_url($url, $params);
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
*adds to the url the chronology and start parameters
|
||||
*/
|
||||
function add_well_known_params_in_url($url, $params)
|
||||
{
|
||||
if ( isset($params['chronology']) )
|
||||
{
|
||||
$url .= '/'. $params['chronology']['field'];
|
||||
$url .= '-'. $params['chronology']['style'];
|
||||
if ( isset($params['chronology']['view']) )
|
||||
{
|
||||
$url .= '-'. $params['chronology']['view'];
|
||||
}
|
||||
if ( isset($params['chronology_date']) )
|
||||
{
|
||||
$url .= '-'. implode('-', $params['chronology_date'] );
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['start']) and $params['start'] > 0)
|
||||
{
|
||||
$url.= '/start-'.$params['start'];
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
@@ -1134,7 +1152,7 @@ function make_picture_URL($params)
|
||||
function make_section_in_URL($params)
|
||||
{
|
||||
$section_string = '';
|
||||
|
||||
|
||||
if (!isset($params['section']))
|
||||
{
|
||||
if (isset($params['category']))
|
||||
@@ -1159,7 +1177,7 @@ function make_section_in_URL($params)
|
||||
{
|
||||
$params['section'] = 'categories';
|
||||
}
|
||||
|
||||
|
||||
switch($params['section'])
|
||||
{
|
||||
case 'categories' :
|
||||
@@ -1172,7 +1190,7 @@ function make_section_in_URL($params)
|
||||
{
|
||||
$section_string.= 'category/'.$params['category'];
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case 'tags' :
|
||||
@@ -1188,7 +1206,7 @@ function make_section_in_URL($params)
|
||||
{
|
||||
$section_string.= '/'.$tag;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case 'search' :
|
||||
@@ -1197,7 +1215,7 @@ function make_section_in_URL($params)
|
||||
{
|
||||
die('make_section_in_URL: require a search identifier');
|
||||
}
|
||||
|
||||
|
||||
$section_string.= 'search/'.$params['search'];
|
||||
|
||||
break;
|
||||
@@ -1210,7 +1228,7 @@ function make_section_in_URL($params)
|
||||
}
|
||||
|
||||
$section_string.= 'list/'.implode(',', $params['list']);
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
default :
|
||||
|
||||
@@ -24,27 +24,8 @@
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
define('CAL_VIEW_LIST', 'l');
|
||||
define('CAL_VIEW_CALENDAR', 'c');
|
||||
|
||||
function get_calendar_parameter($options, &$parameters )
|
||||
{
|
||||
if ( count($parameters) and isset($options[$parameters[0]]) )
|
||||
{
|
||||
return array_shift($parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($options as $option => $data)
|
||||
{
|
||||
if ( empty( $data['default_link'] ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $option;
|
||||
}
|
||||
}
|
||||
define('CAL_VIEW_LIST', 'list');
|
||||
define('CAL_VIEW_CALENDAR', 'calendar');
|
||||
|
||||
function initialize_calendar()
|
||||
{
|
||||
@@ -53,17 +34,17 @@ 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']))
|
||||
if (!isset($page['category']) or is_numeric($page['category']))
|
||||
{ // 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']))
|
||||
if (isset($page['category']) and is_numeric($page['category']))
|
||||
{
|
||||
$sub_ids = array_diff(
|
||||
get_subcat_ids(array($page['cat'])),
|
||||
get_subcat_ids(array($page['category'])),
|
||||
explode(',', $user['forbidden_categories'])
|
||||
);
|
||||
|
||||
@@ -92,129 +73,123 @@ WHERE id IN (' . implode(',',$page['items']) .')';
|
||||
|
||||
//-------------------------------------- initialize the calendar parameters ---
|
||||
pwg_debug('start initialize_calendar');
|
||||
// the parameters look like (FIELD)?(STYLE)?(VIEW)?(DATE COMPONENTS)?
|
||||
// FIELD = (created-|posted-)
|
||||
// STYLE = (m-|w-)
|
||||
// VIEW = (l-|c-)
|
||||
// DATE COMPONENTS= YEAR(-MONTH/WEEK)?(-DAY)?
|
||||
|
||||
$fields = array(
|
||||
// Created
|
||||
'created' => array(
|
||||
'default_link' => 'created-',
|
||||
'label' => l10n('Creation date'),
|
||||
'db_field' => 'date_creation',
|
||||
),
|
||||
// Posted
|
||||
'posted' => array(
|
||||
'default_link' => 'posted-',
|
||||
'label' => l10n('Post date'),
|
||||
'db_field' => 'date_available',
|
||||
),
|
||||
);
|
||||
|
||||
$styles = array(
|
||||
// Monthly style
|
||||
'monthly' => array(
|
||||
'default_link' => '',
|
||||
'include' => 'calendar_monthly.class.php',
|
||||
'view_calendar' => true,
|
||||
),
|
||||
// Weekly style
|
||||
'weekly' => array(
|
||||
'default_link' => 'weekly-',
|
||||
'include' => 'calendar_weekly.class.php',
|
||||
'view_calendar' => false,
|
||||
),
|
||||
);
|
||||
|
||||
$views = array(
|
||||
// list view
|
||||
CAL_VIEW_LIST => array(
|
||||
'default_link' => '',
|
||||
),
|
||||
// calendar view
|
||||
CAL_VIEW_CALENDAR => array(
|
||||
'default_link' => CAL_VIEW_CALENDAR.'-',
|
||||
),
|
||||
);
|
||||
|
||||
$requested = explode('-', $_GET['calendar']);
|
||||
$views = array(CAL_VIEW_LIST,CAL_VIEW_CALENDAR);
|
||||
|
||||
// Retrieve calendar field
|
||||
$cal_field = get_calendar_parameter($fields, $requested);
|
||||
if ( !isset( $fields[ $page['chronology']['field'] ] ) )
|
||||
{
|
||||
die('bad field');
|
||||
}
|
||||
|
||||
// Retrieve style
|
||||
$cal_style = get_calendar_parameter($styles, $requested);
|
||||
if ( !isset( $styles[ $page['chronology']['style'] ] ) )
|
||||
{
|
||||
$page['chronology']['style'] = 'monthly';
|
||||
}
|
||||
$cal_style = $page['chronology']['style'];
|
||||
include(PHPWG_ROOT_PATH.'include/'. $styles[$cal_style]['include']);
|
||||
$calendar = new Calendar();
|
||||
|
||||
// Retrieve view
|
||||
$cal_view = get_calendar_parameter($views, $requested);
|
||||
if ( CAL_VIEW_CALENDAR==$cal_view and !$styles[$cal_style]['view_calendar'] )
|
||||
|
||||
if ( !isset($page['chronology']['view']) or
|
||||
!in_array( $page['chronology']['view'], $views ) )
|
||||
{
|
||||
$cal_view=CAL_VIEW_LIST;
|
||||
$page['chronology']['view'] = CAL_VIEW_LIST;
|
||||
}
|
||||
|
||||
// perform a sanity check on $requested
|
||||
while (count($requested) > 3)
|
||||
if ( CAL_VIEW_CALENDAR==$page['chronology']['view'] and
|
||||
!$styles[$cal_style]['view_calendar'] )
|
||||
{
|
||||
array_pop($requested);
|
||||
|
||||
$page['chronology']['view'] = CAL_VIEW_LIST;
|
||||
}
|
||||
$cal_view = $page['chronology']['view'];
|
||||
|
||||
// perform a sanity check on $requested
|
||||
if (!isset($page['chronology_date']))
|
||||
{
|
||||
$page['chronology_date'] = array();
|
||||
}
|
||||
while ( count($page['chronology_date']) > 3)
|
||||
{
|
||||
array_pop($page['chronology_date']);
|
||||
}
|
||||
|
||||
$any_count = 0;
|
||||
for ($i = 0; $i < count($requested); $i++)
|
||||
for ($i = 0; $i < count($page['chronology_date']); $i++)
|
||||
{
|
||||
if ($requested[$i] == 'any')
|
||||
if ($page['chronology_date'][$i] == 'any')
|
||||
{
|
||||
if ($cal_view == CAL_VIEW_CALENDAR)
|
||||
{// we dont allow any in calendar view
|
||||
while ($i < count($requested))
|
||||
while ($i < count($page['chronology_date']))
|
||||
{
|
||||
array_pop($requested);
|
||||
array_pop($page['chronology_date']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
$any_count++;
|
||||
}
|
||||
elseif ($requested[$i] == '')
|
||||
elseif ($page['chronology_date'][$i] == '')
|
||||
{
|
||||
while ($i < count($requested))
|
||||
while ($i < count($page['chronology_date']))
|
||||
{
|
||||
array_pop($requested);
|
||||
array_pop($page['chronology_date']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$requested[$i] = (int)$requested[$i];
|
||||
$page['chronology_date'][$i] = (int)$page['chronology_date'][$i];
|
||||
}
|
||||
}
|
||||
if ($any_count == 3)
|
||||
{
|
||||
array_pop($requested);
|
||||
array_pop($page['chronology_date']);
|
||||
}
|
||||
|
||||
$calendar->initialize($fields[$cal_field]['db_field'], $inner_sql, $requested);
|
||||
$calendar->initialize($inner_sql);
|
||||
|
||||
//echo ('<pre>'. var_export($calendar, true) . '</pre>');
|
||||
|
||||
$url_base = get_query_string_diff(array('start', 'calendar'));
|
||||
/* $url_base = get_query_string_diff(array('start', 'calendar'));
|
||||
$url_base =
|
||||
PHPWG_ROOT_PATH.'category.php'
|
||||
.$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')
|
||||
{
|
||||
$template->assign_block_vars('calendar', array());
|
||||
|
||||
if ($calendar->generate_category_content(
|
||||
$url_base.$cal_style.'-'.$cal_view.'-',
|
||||
$cal_view
|
||||
)
|
||||
)
|
||||
if ($calendar->generate_category_content())
|
||||
{
|
||||
unset(
|
||||
$page['thumbnails_include'],
|
||||
@@ -228,27 +203,39 @@ WHERE id IN (' . implode(',',$page['items']) .')';
|
||||
$template->assign_block_vars( 'calendar.views', array() );
|
||||
foreach ($styles as $style => $style_data)
|
||||
{
|
||||
foreach ($views as $view => $view_data)
|
||||
foreach ($views as $view)
|
||||
{
|
||||
if ( $style_data['view_calendar'] or $view != CAL_VIEW_CALENDAR)
|
||||
{
|
||||
$selected = '';
|
||||
$url = $url_base.$style.'-'.$view;
|
||||
if ($style==$cal_style)
|
||||
$chronology = $page['chronology'];
|
||||
$chronology['style'] = $style;
|
||||
$chronology['view'] = $view;
|
||||
|
||||
if ($style!=$cal_style)
|
||||
{
|
||||
$url .= '-'.implode('-', $calendar->date_components);
|
||||
if ( $view==$cal_view )
|
||||
$chronology_date = array();
|
||||
if ( isset($page['chronology_date'][0]) )
|
||||
{
|
||||
$selected = 'SELECTED';
|
||||
array_push($chronology_date, $page['chronology_date'][0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($calendar->date_components[0]))
|
||||
{
|
||||
$url .= '-' . $calendar->date_components[0];
|
||||
}
|
||||
$chronology_date = $page['chronology_date'];
|
||||
}
|
||||
$url = duplicate_index_url(
|
||||
array(
|
||||
'chronology' => $chronology,
|
||||
'chronology_date' => $chronology_date,
|
||||
)
|
||||
);
|
||||
|
||||
if ($style==$cal_style and $view==$cal_view )
|
||||
{
|
||||
$selected = 'SELECTED';
|
||||
}
|
||||
|
||||
$template->assign_block_vars(
|
||||
'calendar.views.view',
|
||||
array(
|
||||
@@ -260,9 +247,11 @@ WHERE id IN (' . implode(',',$page['items']) .')';
|
||||
}
|
||||
}
|
||||
}
|
||||
$calendar_title =
|
||||
'<a href="'.$url_base.$cal_style.'-'.$cal_view.'">'
|
||||
.$fields[$cal_field]['label'].'</a>';
|
||||
$url = duplicate_index_url(
|
||||
array('chronology_date'=>array()), array('start')
|
||||
);
|
||||
$calendar_title = '<a href="'.$url.'">'
|
||||
.$fields[$chronology['field']]['label'].'</a>';
|
||||
$calendar_title.= $calendar->get_display_name();
|
||||
//this should be an assign_block_vars, but I need to assign 'calendar'
|
||||
//above and at that point I don't have the title yet.
|
||||
|
||||
@@ -78,17 +78,17 @@ foreach (array_keys($_GET) as $keynum => $key)
|
||||
die('Fatal: picture identifier is missing');
|
||||
}
|
||||
$page['image_id'] = $matches[1];
|
||||
|
||||
|
||||
$next_token++;
|
||||
}
|
||||
|
||||
|
||||
if (0 === strpos($tokens[$next_token], 'cat'))
|
||||
{
|
||||
$page['section'] = 'categories';
|
||||
$next_token++;
|
||||
|
||||
|
||||
if (isset($tokens[$next_token])
|
||||
and preg_match('/(\d+)/', $tokens[$next_token], $matches))
|
||||
and preg_match('/^(\d+)/', $tokens[$next_token], $matches))
|
||||
{
|
||||
$page['category'] = $matches[1];
|
||||
$next_token++;
|
||||
@@ -98,16 +98,16 @@ foreach (array_keys($_GET) as $keynum => $key)
|
||||
{
|
||||
$page['section'] = 'tags';
|
||||
$page['tags'] = array();
|
||||
|
||||
|
||||
$next_token++;
|
||||
|
||||
|
||||
for ($i = $next_token; ; $i++)
|
||||
{
|
||||
if (!isset($tokens[$i]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
preg_match('/^(\d+)/', $tokens[$i], $matches);
|
||||
if (!isset($matches[1]))
|
||||
{
|
||||
@@ -122,7 +122,7 @@ foreach (array_keys($_GET) as $keynum => $key)
|
||||
}
|
||||
array_push($page['tags'], $matches[1]);
|
||||
}
|
||||
|
||||
|
||||
$next_token = $i;
|
||||
}
|
||||
else if (0 === strpos($tokens[$next_token], 'fav'))
|
||||
@@ -154,7 +154,7 @@ foreach (array_keys($_GET) as $keynum => $key)
|
||||
{
|
||||
$page['section'] = 'search';
|
||||
$next_token++;
|
||||
|
||||
|
||||
preg_match('/(\d+)/', $tokens[$next_token], $matches);
|
||||
if (!isset($matches[1]))
|
||||
{
|
||||
@@ -184,24 +184,36 @@ foreach (array_keys($_GET) as $keynum => $key)
|
||||
$page['section'] = 'categories';
|
||||
$next_token++;
|
||||
}
|
||||
|
||||
|
||||
for ($i = $next_token; ; $i++)
|
||||
{
|
||||
if (!isset($tokens[$i]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (preg_match('/^start-(\d+)/', $tokens[$i], $matches))
|
||||
{
|
||||
$page['start'] = $matches[1];
|
||||
}
|
||||
|
||||
if (preg_match('/^calendar-(.+)$/', $tokens[$i], $matches))
|
||||
if (preg_match('/^posted|created/', $tokens[$i] ))
|
||||
{
|
||||
// TODO: decide with rvelices how we name calendar/chronology is the
|
||||
// URL
|
||||
$_GET['calendar'] = $matches[1];
|
||||
$chronology_tokens = explode('-', $tokens[$i] );
|
||||
$page['chronology']['field'] = $chronology_tokens[0];
|
||||
array_shift($chronology_tokens);
|
||||
$page['chronology']['style'] = $chronology_tokens[0];
|
||||
array_shift($chronology_tokens);
|
||||
if ( count($chronology_tokens)>0 )
|
||||
{
|
||||
if ('list'==$chronology_tokens[0] or
|
||||
'calendar'==$chronology_tokens[0])
|
||||
{
|
||||
$page['chronology']['view'] = $chronology_tokens[0];
|
||||
array_shift($chronology_tokens);
|
||||
}
|
||||
$page['chronology_date'] = $chronology_tokens;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,7 +231,7 @@ if (isset($_COOKIE['pwg_image_order'])
|
||||
|
||||
$conf['order_by'] = str_replace(
|
||||
'ORDER BY ',
|
||||
'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',',
|
||||
'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',',
|
||||
$conf['order_by']
|
||||
);
|
||||
$page['super_order_by'] = true;
|
||||
@@ -233,7 +245,7 @@ if ('categories' == $page['section'])
|
||||
if (isset($page['category']))
|
||||
{
|
||||
$result = get_cat_info($page['category']);
|
||||
|
||||
|
||||
$page = array_merge(
|
||||
$page,
|
||||
array(
|
||||
@@ -246,11 +258,11 @@ if ('categories' == $page['section'])
|
||||
'cat_commentable' => $result['commentable'],
|
||||
'cat_id_uppercat' => $result['id_uppercat'],
|
||||
'uppercats' => $result['uppercats'],
|
||||
|
||||
|
||||
'title' => get_cat_display_name($result['name'], '', false),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (!isset($_GET['calendar']))
|
||||
{
|
||||
$query = '
|
||||
@@ -261,7 +273,7 @@ SELECT image_id
|
||||
'.$conf['order_by'].'
|
||||
;';
|
||||
$page['items'] = array_from_query($query, 'image_id');
|
||||
|
||||
|
||||
$page['thumbnails_include'] =
|
||||
$result['nb_images'] > 0
|
||||
? 'include/category_default.inc.php'
|
||||
@@ -387,7 +399,7 @@ SELECT DISTINCT(id)
|
||||
'.$conf['order_by'].'
|
||||
LIMIT 0, '.$conf['top_number'].'
|
||||
;';
|
||||
|
||||
|
||||
$page = array_merge(
|
||||
$page,
|
||||
array(
|
||||
@@ -404,7 +416,7 @@ SELECT DISTINCT(id)
|
||||
{
|
||||
$page['super_order_by'] = true;
|
||||
$conf['order_by'] = ' ORDER BY average_rate DESC, id ASC';
|
||||
|
||||
|
||||
$query ='
|
||||
SELECT DISTINCT(id)
|
||||
FROM '.IMAGES_TABLE.'
|
||||
@@ -436,7 +448,7 @@ SELECT DISTINCT(id)
|
||||
AND '.$forbidden.'
|
||||
'.$conf['order_by'].'
|
||||
;';
|
||||
|
||||
|
||||
$page = array_merge(
|
||||
$page,
|
||||
array(
|
||||
@@ -446,7 +458,7 @@ SELECT DISTINCT(id)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (!isset($page['cat_nb_images']))
|
||||
{
|
||||
$page['cat_nb_images'] = count($page['items']);
|
||||
@@ -457,7 +469,7 @@ SELECT DISTINCT(id)
|
||||
// | chronology |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (isset($_GET['calendar']))
|
||||
if (isset($page['chronology']))
|
||||
{
|
||||
include_once( PHPWG_ROOT_PATH.'include/functions_calendar.inc.php' );
|
||||
initialize_calendar();
|
||||
|
||||
Reference in New Issue
Block a user