aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/calendar_base.class.php2
-rw-r--r--include/calendar_monthly.class.php2
-rw-r--r--include/category_default.inc.php58
-rw-r--r--include/functions.inc.php55
-rw-r--r--include/functions_calendar.inc.php49
-rw-r--r--include/functions_html.inc.php50
-rw-r--r--include/picture_comment.inc.php18
-rw-r--r--include/picture_rate.inc.php4
-rw-r--r--include/section_init.inc.php301
9 files changed, 274 insertions, 265 deletions
diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php
index a3240e679..5d358f4ad 100644
--- a/include/calendar_base.class.php
+++ b/include/calendar_base.class.php
@@ -45,7 +45,7 @@ class CalendarBase
function initialize($inner_sql)
{
global $page;
- if ($page['chronology']['field']=='posted')
+ if ($page['chronology_field']=='posted')
{
$this->date_field = 'date_available';
}
diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php
index 556e6e976..0d70ea4c6 100644
--- a/include/calendar_monthly.class.php
+++ b/include/calendar_monthly.class.php
@@ -69,7 +69,7 @@ function generate_category_content()
{
global $conf, $page;
- $view_type = $page['chronology']['view'];
+ $view_type = $page['chronology_view'];
if ($view_type==CAL_VIEW_CALENDAR)
{
if ( count($page['chronology_date'])==0 )
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 599c527a9..e7c4b8ddc 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -28,7 +28,7 @@
/**
* This file is included by the main page to show thumbnails for the default
* case
- *
+ *
*/
$page['rank_of'] = array_flip($page['items']);
@@ -52,7 +52,7 @@ SELECT *
while ($row = mysql_fetch_array($result))
{
$row['rank'] = $page['rank_of'][ $row['id'] ];
-
+
array_push($pictures, $row);
}
@@ -72,50 +72,22 @@ if (count($pictures) > 0)
foreach ($pictures as $row)
{
$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
-
+
// message in title for the thumbnail
$thumbnail_title = $row['file'];
if (isset($row['filesize']))
{
$thumbnail_title .= ' : '.$row['filesize'].' KB';
}
-
- // url link on picture.php page
- $url_link = PHPWG_ROOT_PATH.'picture.php?/'.$row['id'];
- switch ($page['section'])
- {
- case 'categories' :
- {
- $url_link.= '/category/'.$page['category'];
- break;
- }
- case 'tags' :
- {
- // TODO
- break;
- }
- case 'search' :
- {
- $url_link.= '/search/'.$page['search'];
- break;
- }
- case 'list' :
- {
- $url_link.= '/list/'.implode(',', $page['list']);
- break;
- }
- default :
- {
- $url_link.= '/'.$page['section'];
- }
- }
-
- if (isset($page['chronology']))
- {
- $url_link.= '/chronology='.$page['chronology'];
- }
-
+ // link on picture.php page
+ $url = duplicate_picture_url(
+ array(
+ 'image_id' => $row['id'],
+ 'image_file' => $row['file']
+ )
+ );
+
$template->assign_block_vars(
'thumbnails.line.thumbnail',
array(
@@ -123,8 +95,8 @@ foreach ($pictures as $row)
'IMAGE_ALT' => $row['file'],
'IMAGE_TITLE' => $thumbnail_title,
'IMAGE_TS' => get_icon($row['date_available']),
-
- 'U_IMG_LINK' => $url_link
+
+ 'U_IMG_LINK' => $url
)
);
@@ -158,7 +130,7 @@ foreach ($pictures as $row)
break;
}
}
-
+
$template->assign_block_vars(
'thumbnails.line.thumbnail.element_name',
array(
@@ -166,7 +138,7 @@ foreach ($pictures as $row)
)
);
}
-
+
if ($user['show_nb_comments']
and isset($page['category'])
and $page['cat_commentable'])
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 948f33f44..68ba765fe 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -574,9 +574,10 @@ function get_pwg_themes()
*
* @param string path
* @param string tn_ext
+ * @param bool with_rewrite if true returned path can't be used from the script
* @return string
*/
-function get_thumbnail_src($path, $tn_ext = '')
+function get_thumbnail_src($path, $tn_ext = '', $with_rewrite = true)
{
global $conf, $user;
@@ -589,10 +590,15 @@ function get_thumbnail_src($path, $tn_ext = '')
1
);
$src.= '.'.$tn_ext;
+ if ($with_rewrite==true and !url_is_remote($src) )
+ {
+ $src = get_root_url().$src;
+ }
}
else
{
- $src = get_themeconf('mime_icon_dir');
+ $src = ($with_rewrite==true) ? get_root_url() : '';
+ $src .= get_themeconf('mime_icon_dir');
$src.= strtolower(get_extension($path)).'.png';
}
@@ -1004,6 +1010,35 @@ function get_available_upgrade_ids()
}
/**
+ * returns a prefix for each url link on displayed page
+ * @return string
+ */
+function get_root_url()
+{
+ global $page;
+ if ( isset($page['root_path']) )
+ {
+ return $page['root_path'];
+ }
+ return PHPWG_ROOT_PATH;
+}
+
+/**
+ * adds one or more _GET style parameters to an url
+ * example: add_url_param('/x', 'a=b') returns /x?a=b
+ * add_url_param('/x?cat_id=10', 'a=b') returns /x?cat_id=10&a=b
+ * @param string url
+ * @param string param
+ * @return string
+ */
+function add_url_param($url, $param)
+{
+ $url .= ( strstr($url, '?')===false ) ? '?' :'&';
+ $url .= $param;
+ return $url;
+}
+
+/**
* build an index URL for a specific section
*
* @param array
@@ -1012,7 +1047,7 @@ function get_available_upgrade_ids()
function make_index_URL($params = array())
{
$url =
- PHPWG_ROOT_PATH.'category.php?'
+ get_root_url().'category.php?'
.'/'.make_section_in_URL($params)
;
@@ -1105,7 +1140,7 @@ function make_picture_URL($params)
}
$url =
- PHPWG_ROOT_PATH.'picture.php?'
+ get_root_url().'picture.php?'
.'/'.$params['image_id']
.'/'.make_section_in_URL($params)
;
@@ -1119,15 +1154,15 @@ function make_picture_URL($params)
*/
function add_well_known_params_in_url($url, $params)
{
- if ( isset($params['chronology']) )
+ if ( isset($params['chronology_field']) )
{
- $url .= '/'. $params['chronology']['field'];
- $url .= '-'. $params['chronology']['style'];
- if ( isset($params['chronology']['view']) )
+ $url .= '/'. $params['chronology_field'];
+ $url .= '-'. $params['chronology_style'];
+ if ( isset($params['chronology_view']) )
{
- $url .= '-'. $params['chronology']['view'];
+ $url .= '-'. $params['chronology_view'];
}
- if ( isset($params['chronology_date']) )
+ if ( !empty($params['chronology_date']) )
{
$url .= '-'. implode('-', $params['chronology_date'] );
}
diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php
index e673e326a..6dc178d10 100644
--- a/include/functions_calendar.inc.php
+++ b/include/functions_calendar.inc.php
@@ -34,7 +34,8 @@ function initialize_calendar()
//------------------ initialize the condition on items to take into account ---
$inner_sql = ' FROM ' . IMAGES_TABLE;
- if (!isset($page['category']) or is_numeric($page['category']))
+ if ($page['section']=='categories' or
+ ( isset($page['category']) and is_numeric($page['category']) ) )
{ // we will regenerate the items by including subcats elements
$page['cat_nb_images'] = 0;
$page['items'] = array();
@@ -101,35 +102,34 @@ WHERE id IN (' . implode(',',$page['items']) .')';
$views = array(CAL_VIEW_LIST,CAL_VIEW_CALENDAR);
// Retrieve calendar field
- if ( !isset( $fields[ $page['chronology']['field'] ] ) )
+ if ( !isset( $fields[ $page['chronology_field'] ] ) )
{
- die('bad field');
+ die('bad chronology field');
}
// Retrieve style
- if ( !isset( $styles[ $page['chronology']['style'] ] ) )
+ if ( !isset( $styles[ $page['chronology_style'] ] ) )
{
- $page['chronology']['style'] = 'monthly';
+ $page['chronology_style'] = 'monthly';
}
- $cal_style = $page['chronology']['style'];
+ $cal_style = $page['chronology_style'];
include(PHPWG_ROOT_PATH.'include/'. $styles[$cal_style]['include']);
$calendar = new Calendar();
// Retrieve view
- if ( !isset($page['chronology']['view']) or
- !in_array( $page['chronology']['view'], $views ) )
+ if ( !isset($page['chronology_view']) or
+ !in_array( $page['chronology_view'], $views ) )
{
- $page['chronology']['view'] = CAL_VIEW_LIST;
+ $page['chronology_view'] = CAL_VIEW_LIST;
}
- if ( CAL_VIEW_CALENDAR==$page['chronology']['view'] and
+ if ( CAL_VIEW_CALENDAR==$page['chronology_view'] and
!$styles[$cal_style]['view_calendar'] )
{
- $page['chronology']['view'] = CAL_VIEW_LIST;
+ $page['chronology_view'] = CAL_VIEW_LIST;
}
- $cal_view = $page['chronology']['view'];
// perform a sanity check on $requested
if (!isset($page['chronology_date']))
@@ -146,7 +146,7 @@ WHERE id IN (' . implode(',',$page['items']) .')';
{
if ($page['chronology_date'][$i] == 'any')
{
- if ($cal_view == CAL_VIEW_CALENDAR)
+ if ($page['chronology_view'] == CAL_VIEW_CALENDAR)
{// we dont allow any in calendar view
while ($i < count($page['chronology_date']))
{
@@ -177,15 +177,8 @@ WHERE id IN (' . implode(',',$page['items']) .')';
//echo ('<pre>'. var_export($calendar, true) . '</pre>');
-/* $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')
+ if (basename($_SERVER['SCRIPT_NAME']) == 'category.php')
{
$template->assign_block_vars('calendar', array());
@@ -208,9 +201,6 @@ WHERE id IN (' . implode(',',$page['items']) .')';
if ( $style_data['view_calendar'] or $view != CAL_VIEW_CALENDAR)
{
$selected = '';
- $chronology = $page['chronology'];
- $chronology['style'] = $style;
- $chronology['view'] = $view;
if ($style!=$cal_style)
{
@@ -226,12 +216,13 @@ WHERE id IN (' . implode(',',$page['items']) .')';
}
$url = duplicate_index_url(
array(
- 'chronology' => $chronology,
+ 'chronology_style' => $style,
+ 'chronology_view' => $view,
'chronology_date' => $chronology_date,
)
);
- if ($style==$cal_style and $view==$cal_view )
+ if ($style==$cal_style and $view==$page['chronology_view'] )
{
$selected = 'SELECTED';
}
@@ -240,7 +231,7 @@ WHERE id IN (' . implode(',',$page['items']) .')';
'calendar.views.view',
array(
'VALUE' => $url,
- 'CONTENT' => l10n('calendar_'.$style.'_'.$view),
+ 'CONTENT' => l10n('chronology_'.$style.'_'.$view),
'SELECTED' => $selected,
)
);
@@ -248,10 +239,10 @@ WHERE id IN (' . implode(',',$page['items']) .')';
}
}
$url = duplicate_index_url(
- array('chronology_date'=>array()), array('start')
+ array(), array('start', 'chronology_date')
);
$calendar_title = '<a href="'.$url.'">'
- .$fields[$chronology['field']]['label'].'</a>';
+ .$fields[$page['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.
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 959153297..8cd69b5ba 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -45,7 +45,7 @@ function get_icon($date)
$page['get_icon_cache'][$date] = '';
return $page['get_icon_cache'][$date];
}
-
+
list($devnull, $year, $month, $day) = $matches;
$unixtime = mktime( 0, 0, 0, $month, $day, $year );
@@ -55,7 +55,7 @@ function get_icon($date)
$page['get_icon_cache'][$date] = '';
return $page['get_icon_cache'][$date];
}
-
+
$diff = time() - $unixtime;
$day_in_seconds = 24*60*60;
$output = '';
@@ -83,9 +83,9 @@ function create_navigation_bar(
$pages_around = $conf['paginate_pages_around'];
$start_str = $clean_url ? '/start-' : '&amp;start=';
-
+
$navbar = '';
-
+
// current page detection
if (!isset($start)
or !is_numeric($start)
@@ -93,7 +93,7 @@ function create_navigation_bar(
{
$start = 0;
}
-
+
// navigation bar useful only if more than one page to display !
if ($nb_element > $nb_element_page)
{
@@ -118,7 +118,7 @@ function create_navigation_bar(
if ($start != 0)
{
$previous = $start - $nb_element_page;
-
+
$navbar.=
'<a href="'
.$url.($previous > 0 ? $start_str.$previous : '')
@@ -135,13 +135,13 @@ function create_navigation_bar(
if ($cur_page > $pages_around + 1)
{
$navbar.= '&nbsp;<a href="'.$url.'">1</a>';
-
+
if ($cur_page > $pages_around + 2)
{
$navbar.= ' ...';
}
}
-
+
// inspired from punbb source code
for ($i = $cur_page - $pages_around, $stop = $cur_page + $pages_around + 1;
$i < $stop;
@@ -154,7 +154,7 @@ function create_navigation_bar(
else if ($i != $cur_page)
{
$temp_start = ($i - 1) * $nb_element_page;
-
+
$navbar.=
'&nbsp;'
.'<a href="'.$url
@@ -176,22 +176,22 @@ function create_navigation_bar(
if ($cur_page < ($maximum - $pages_around))
{
$temp_start = ($maximum - 1) * $nb_element_page;
-
+
if ($cur_page < ($maximum - $pages_around - 1))
{
$navbar.= ' ...';
}
-
+
$navbar.= ' <a href="'.$url.$start_str.$temp_start.'">'.$maximum.'</a>';
}
-
+
$navbar.= ' | ';
// link on next page ?
if ($nb_element > $nb_element_page
and $start + $nb_element_page < $nb_element)
{
$next = $start + $nb_element_page;
-
+
$navbar.=
'<a href="'.$url.$start_str.$next.'" rel="next">'
.$lang['next_page']
@@ -201,13 +201,13 @@ function create_navigation_bar(
{
$navbar.= $lang['next_page'];
}
-
+
$navbar.= ' | ';
// link to last page ?
if ($cur_page != $maximum)
{
$temp_start = ($maximum - 1) * $nb_element_page;
-
+
$navbar.=
'<a href="'.$url.$start_str.$temp_start.'" rel="last">'
.$lang['last_page']
@@ -257,7 +257,7 @@ function get_cat_display_name($cat_informations,
$replace_space = true)
{
global $conf;
-
+
$output = '';
$is_first = true;
foreach ($cat_informations as $id => $name)
@@ -323,13 +323,13 @@ SELECT id,name
$cat_names[$row['id']] = $row['name'];
}
}
-
+
$output = '';
$is_first = true;
foreach (explode(',', $uppercats) as $category_id)
{
$name = $cat_names[$category_id];
-
+
if ($is_first)
{
$is_first = false;
@@ -384,7 +384,7 @@ function get_html_menu_category($categories)
{
$page_cat = $page['category'];
}
-
+
foreach ($categories as $category)
{
$level = substr_count($category['global_rank'], '.') + 1;
@@ -410,9 +410,9 @@ function get_html_menu_category($categories)
$menu.= ' class="selected"';
}
$menu.= '>';
-
+
$url = make_index_url(array('category' => $category['id']));
-
+
$menu.= "\n".'<a href="'.$url.'"';
if ($page_cat != 0
and $category['id'] == $page['cat_id_uppercat'])
@@ -433,7 +433,7 @@ function get_html_menu_category($categories)
}
$menu.= str_repeat("\n</li></ul>",($level));
-
+
return $menu;
}
@@ -453,17 +453,17 @@ function parse_comment_content($content)
$content = preg_replace($pattern, $replacement, $content);
$content = nl2br($content);
-
+
// replace _word_ by an underlined word
$pattern = '/\b_(\S*)_\b/';
$replacement = '<span style="text-decoration:underline;">$1</span>';
$content = preg_replace($pattern, $replacement, $content);
-
+
// replace *word* by a bolded word
$pattern = '/\b\*(\S*)\*\b/';
$replacement = '<span style="font-weight:bold;">$1</span>';
$content = preg_replace($pattern, $replacement, $content);
-
+
// replace /word/ by an italic word
$pattern = "/\/(\S*)\/(\s)/";
$replacement = '<span style="font-style:italic;">$1$2</span>';
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index 6a40ea442..6572705dc 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -27,10 +27,10 @@
/**
* This file is included by the picture page to manage user comments
- *
+ *
*/
-if ( isset( $_POST['content'] ) && !empty($_POST['content']) )
+if ( isset( $_POST['content'] ) and !empty($_POST['content']) )
{
$register_comment = true;
$author = !empty($_POST['author'])?$_POST['author']:$lang['guest'];
@@ -133,7 +133,7 @@ if ($page['show_comments'])
{
$page['start'] = 0;
}
-
+
$page['navigation_bar'] = create_navigation_bar(
duplicate_picture_URL(array(), array('start')),
$row['nb_comments'],
@@ -141,7 +141,7 @@ if ($page['show_comments'])
$conf['nb_comment_page'],
true // We want a clean URL
);
-
+
$template->assign_block_vars(
'comments',
array(
@@ -170,12 +170,12 @@ SELECT id,author,date,image_id,content
'COMMENT_AUTHOR' => empty($row['author'])
? $lang['guest']
: $row['author'],
-
+
'COMMENT_DATE' => format_date(
$row['date'],
'mysql_datetime',
true),
-
+
'COMMENT' => parse_comment_content($row['content']),
)
);
@@ -186,9 +186,9 @@ SELECT id,author,date,image_id,content
'comments.comment.delete',
array(
'U_COMMENT_DELETE' =>
- $url_self
- .'&amp;action=delete_comment'
- .'&amp;comment_to_delete='.$row['id']
+ add_url_param( $url_self,
+ 'action=delete_comment&amp;comment_to_delete='.$row['id']
+ )
)
);
}
diff --git a/include/picture_rate.inc.php b/include/picture_rate.inc.php
index 7f765e759..e994b3e44 100644
--- a/include/picture_rate.inc.php
+++ b/include/picture_rate.inc.php
@@ -27,7 +27,7 @@
/**
* This file is included by the picture page to manage rates
- *
+ *
*/
if ($conf['rate'])
@@ -113,7 +113,7 @@ SELECT COUNT(rate) AS count
'rate.rate_option',
array(
'OPTION' => $mark,
- 'URL' => $url_self.'&amp;action=rate&amp;rate='.$mark,
+ 'URL' => add_url_param($url_self,'action=rate&amp;rate='.$mark),
'SEPARATOR' => ($num > 0 ? '|' : ''),
)
);
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index 0bb82eadf..d225e7871 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -40,7 +40,9 @@
* display
*/
-// "index.php?/category/12-foo/start-24&action=fill_caddie" must return :
+// "index.php?/category/12-foo/start-24&action=fill_caddie" or
+// "index.php/category/12-foo/start-24&action=fill_caddie"
+// must return :
//
// array(
// 'section' => 'categories',
@@ -51,174 +53,186 @@
$page['section'] = 'categories';
-foreach (array_keys($_GET) as $keynum => $key)
+if ( isset($_SERVER["PATH_INFO"]) )
{
- if (0 == $keynum)
+ $rewritten = $_SERVER["PATH_INFO"];
+ $rewritten = str_replace('//', '/', $rewritten);
+ $path_count = count( explode('/', $rewritten) );
+ $page['root_path'] = PHPWG_ROOT_PATH.str_repeat('../', $path_count-1);
+}
+else
+{
+ $rewritten = '';
+ foreach (array_keys($_GET) as $keynum => $key)
{
- // deleting first "/" if displayed
- $tokens = explode(
- '/',
- preg_replace('#^/#', '', $key)
- );
-
- // $tokens = array(
- // 0 => category,
- // 1 => 12-foo,
- // 2 => start-24
- // );
-
- $next_token = 0;
+ $rewritten = $key;
+ break;
+ }
+ $page['root_path'] = PHPWG_ROOT_PATH;
+}
+//phpinfo();
+// deleting first "/" if displayed
+$tokens = explode(
+ '/',
+ preg_replace('#^/#', '', $rewritten)
+ );
+// $tokens = array(
+// 0 => category,
+// 1 => 12-foo,
+// 2 => start-24
+// );
- if (basename($_SERVER['PHP_SELF']) == 'picture.php')
- {
- // the first token must be the numeric identifier of the picture
- preg_match('/(\d+)/', $tokens[$next_token], $matches);
- if (!isset($matches[1]))
- {
- die('Fatal: picture identifier is missing');
- }
- $page['image_id'] = $matches[1];
+$next_token = 0;
+if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php')
+{
- $next_token++;
- }
+ // the first token must be the numeric identifier of the picture
+ preg_match('/(\d+)/', $tokens[$next_token], $matches);
+ if (!isset($matches[1]))
+ {
+ die('Fatal: picture identifier is missing');
+ }
+ $page['image_id'] = $matches[1];
- if (0 === strpos($tokens[$next_token], 'cat'))
- {
- $page['section'] = 'categories';
- $next_token++;
+ $next_token++;
+}
- if (isset($tokens[$next_token])
- and preg_match('/^(\d+)/', $tokens[$next_token], $matches))
- {
- $page['category'] = $matches[1];
- $next_token++;
- }
- }
- else if (0 === strpos($tokens[$next_token], 'tag'))
- {
- $page['section'] = 'tags';
- $page['tags'] = array();
+if (0 === strpos($tokens[$next_token], 'cat'))
+{
+ $page['section'] = 'categories';
+ $next_token++;
- $next_token++;
+ if (isset($tokens[$next_token])
+ and preg_match('/^(\d+)/', $tokens[$next_token], $matches))
+ {
+ $page['category'] = $matches[1];
+ $next_token++;
+ }
+}
+else if (0 === strpos($tokens[$next_token], 'tag'))
+{
+ $page['section'] = 'tags';
+ $page['tags'] = array();
- for ($i = $next_token; ; $i++)
- {
- if (!isset($tokens[$i]))
- {
- break;
- }
-
- preg_match('/^(\d+)/', $tokens[$i], $matches);
- if (!isset($matches[1]))
- {
- if (0 == count($page['tags']))
- {
- die('Fatal: at least one tag required');
- }
- else
- {
- break;
- }
- }
- array_push($page['tags'], $matches[1]);
- }
+ $next_token++;
- $next_token = $i;
- }
- else if (0 === strpos($tokens[$next_token], 'fav'))
- {
- $page['section'] = 'favorites';
- $next_token++;
- }
- else if ('most_visited' == $tokens[$next_token])
- {
- $page['section'] = 'most_visited';
- $next_token++;
- }
- else if ('best_rated' == $tokens[$next_token])
- {
- $page['section'] = 'best_rated';
- $next_token++;
- }
- else if ('recent_pics' == $tokens[$next_token])
- {
- $page['section'] = 'recent_pics';
- $next_token++;
- }
- else if ('recent_cats' == $tokens[$next_token])
+ for ($i = $next_token; ; $i++)
+ {
+ if (!isset($tokens[$i]))
{
- $page['section'] = 'recent_cats';
- $next_token++;
+ break;
}
- else if ('search' == $tokens[$next_token])
- {
- $page['section'] = 'search';
- $next_token++;
- preg_match('/(\d+)/', $tokens[$next_token], $matches);
- if (!isset($matches[1]))
- {
- die('Fatal: search identifier is missing');
- }
- $page['search'] = $matches[1];
- $next_token++;
- }
- else if ('list' == $tokens[$next_token])
+ preg_match('/^(\d+)/', $tokens[$i], $matches);
+ if (!isset($matches[1]))
{
- $page['section'] = 'list';
- $next_token++;
-
- $page['list'] = array();
- if (!preg_match('/^\d+(,\d+)*$/', $tokens[$next_token]))
+ if (0 == count($page['tags']))
{
- die('wrong format on list GET parameter');
+ die('Fatal: at least one tag required');
}
- foreach (explode(',', $tokens[$next_token]) as $image_id)
+ else
{
- array_push($page['list'], $image_id);
+ break;
}
- $next_token++;
- }
- else
- {
- $page['section'] = 'categories';
- $next_token++;
}
+ array_push($page['tags'], $matches[1]);
+ }
- for ($i = $next_token; ; $i++)
- {
- if (!isset($tokens[$i]))
- {
- break;
- }
+ $next_token = $i;
+}
+else if (0 === strpos($tokens[$next_token], 'fav'))
+{
+ $page['section'] = 'favorites';
+ $next_token++;
+}
+else if ('most_visited' == $tokens[$next_token])
+{
+ $page['section'] = 'most_visited';
+ $next_token++;
+}
+else if ('best_rated' == $tokens[$next_token])
+{
+ $page['section'] = 'best_rated';
+ $next_token++;
+}
+else if ('recent_pics' == $tokens[$next_token])
+{
+ $page['section'] = 'recent_pics';
+ $next_token++;
+}
+else if ('recent_cats' == $tokens[$next_token])
+{
+ $page['section'] = 'recent_cats';
+ $next_token++;
+}
+else if ('search' == $tokens[$next_token])
+{
+ $page['section'] = 'search';
+ $next_token++;
- if (preg_match('/^start-(\d+)/', $tokens[$i], $matches))
- {
- $page['start'] = $matches[1];
- }
+ preg_match('/(\d+)/', $tokens[$next_token], $matches);
+ if (!isset($matches[1]))
+ {
+ die('Fatal: search identifier is missing');
+ }
+ $page['search'] = $matches[1];
+ $next_token++;
+}
+else if ('list' == $tokens[$next_token])
+{
+ $page['section'] = 'list';
+ $next_token++;
+
+ $page['list'] = array();
+ if (!preg_match('/^\d+(,\d+)*$/', $tokens[$next_token]))
+ {
+ die('wrong format on list GET parameter');
+ }
+ foreach (explode(',', $tokens[$next_token]) as $image_id)
+ {
+ array_push($page['list'], $image_id);
+ }
+ $next_token++;
+}
+else
+{
+ $page['section'] = 'categories';
+ $next_token++;
+}
- if (preg_match('/^posted|created/', $tokens[$i] ))
+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('/^posted|created/', $tokens[$i] ))
+ {
+ $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])
{
- $chronology_tokens = explode('-', $tokens[$i] );
- $page['chronology']['field'] = $chronology_tokens[0];
- array_shift($chronology_tokens);
- $page['chronology']['style'] = $chronology_tokens[0];
+ $page['chronology_view'] = $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;
- }
}
+ $page['chronology_date'] = $chronology_tokens;
}
}
}
+
// $page['nb_image_page'] is the number of picture to display on this page
// By default, it is the same as the $user['nb_image_page']
$page['nb_image_page'] = $user['nb_image_page'];
@@ -469,13 +483,10 @@ SELECT DISTINCT(id)
// | chronology |
// +-----------------------------------------------------------------------+
-if (isset($page['chronology']))
+if (isset($page['chronology_field']))
{
include_once( PHPWG_ROOT_PATH.'include/functions_calendar.inc.php' );
initialize_calendar();
}
-// echo '<pre>'; print_r($page); echo '</pre>';
-
-
?> \ No newline at end of file