URL rewriting: fix some old links, calendar simplification and prepare code

for urls without ? (added functions get_root_url and add_url_param)

git-svn-id: http://piwigo.org/svn/trunk@1090 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2006-03-21 01:27:21 +00:00
parent 0c08b2561a
commit e584310d3a
15 changed files with 387 additions and 375 deletions
+8 -6
View File
@@ -138,7 +138,7 @@ $template->assign_vars(
PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start','del')),
$nb_images,
$start,
$elements_per_page,
$elements_per_page
)
)
);
@@ -208,11 +208,13 @@ foreach ($images as $image)
{
$thumbnail_src = get_thumbnail_src($image['path'], $image['tn_ext']);
$image_url =
PHPWG_ROOT_PATH.'picture.php?'.
'cat=' . $image['storage_category_id'].
'&image_id=' . $image['id']
;
$image_url = make_picture_url(
array(
'category' => $image['storage_category_id'],
'image_id' => $image['id'],
'image_file' => $image['file'],
)
);
$query = 'SELECT *
FROM '.RATE_TABLE.' AS r
+31 -39
View File
@@ -131,29 +131,26 @@ if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
$icon_recent = get_icon(date('Y-m-d'));
if (!isset($page['chronology']))
if (!isset($page['chronology_field']))
{
$chronology =
array(
'chronology' =>
array(
'field' => 'created',
'style' => 'monthly',
'view' => 'list',
)
);
$chronology_params =
array(
'chronology_field' => 'created',
'chronology_style' => 'monthly',
'chronology_view' => 'list',
);
$template->assign_block_vars(
'mode_created',
array(
'URL' => duplicate_index_URL( $chronology, array('start') )
'URL' => duplicate_index_URL( $chronology_params, array('start') )
)
);
$chronology['chronology']['field'] = 'posted';
$chronology_params['chronology_field'] = 'posted';
$template->assign_block_vars(
'mode_posted',
array(
'URL' => duplicate_index_URL( $chronology, array('start') )
'URL' => duplicate_index_URL( $chronology_params, array('start') )
)
);
}
@@ -162,27 +159,24 @@ else
$template->assign_block_vars(
'mode_normal',
array(
'URL' => duplicate_index_URL( array(), array('chronology','start') )
'URL' => duplicate_index_URL( array(), array('chronology_field','start') )
)
);
$chronology = $page['chronology'];
if ($chronology['field'] == 'created')
if ($page['chronology_field'] == 'created')
{
$chronology['field'] = 'posted';
$chronology_field = 'posted';
}
else
{
$chronology['field'] = 'created';
$chronology_field = 'created';
}
$url = duplicate_index_URL(
array(
'chronology'=>$chronology
),
array('chronology_field'=>$chronology_field ),
array('chronology_date', 'start')
);
$template->assign_block_vars(
'mode_'.$chronology['field'],
'mode_'.$chronology_field,
array('URL' => $url )
);
}
@@ -195,15 +189,15 @@ $template->assign_vars(
'TOP_NUMBER' => $conf['top_number'],
'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
'F_IDENTIFY' => PHPWG_ROOT_PATH.'identification.php',
'F_IDENTIFY' => get_root_url().'identification.php',
'T_RECENT' => $icon_recent,
'U_HOME' => make_index_URL(),
'U_REGISTER' => PHPWG_ROOT_PATH.'register.php',
'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php',
'U_LOGOUT' => make_index_URL().'&act=logout',
'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php',
'U_REGISTER' => get_root_url().'register.php',
'U_LOST_PASSWORD' => get_root_url().'password.php',
'U_LOGOUT' => add_url_param(make_index_URL(), 'act=logout'),
'U_ADMIN'=> get_root_url().'admin.php',
'U_PROFILE'=> get_root_url().'profile.php',
)
);
@@ -298,12 +292,10 @@ $template->assign_block_vars(
'URL' =>
make_index_URL(
array(
'chronology'=>
array(
'field' => ($conf['calendar_datefield']=='date_available' ? 'posted' : 'created'),
'style' => 'monthly',
'view' => 'calendar'
)
'chronology_field' => ($conf['calendar_datefield']=='date_available'
? 'posted' : 'created'),
'chronology_style'=> 'monthly',
'chronology_view' => 'calendar'
)
),
'TITLE' => $lang['calendar_hint'],
@@ -351,7 +343,7 @@ $template->assign_block_vars(
array(
'TITLE'=>$lang['hint_search'],
'NAME'=>$lang['search'],
'U_SUMMARY'=> 'search.php',
'U_SUMMARY'=> get_root_url().'search.php',
'REL'=> 'rel="search"'
)
);
@@ -362,7 +354,7 @@ $template->assign_block_vars(
array(
'TITLE'=>$lang['hint_comments'],
'NAME'=>$lang['comments'],
'U_SUMMARY'=> 'comments.php',
'U_SUMMARY'=> get_root_url().'comments.php',
)
);
@@ -386,7 +378,7 @@ $template->assign_block_vars(
array(
'TITLE'=>l10n('notification'),
'NAME'=>l10n('Notification'),
'U_SUMMARY'=> PHPWG_ROOT_PATH.'notification.php',
'U_SUMMARY'=> get_root_url().'notification.php',
'REL'=> 'rel="nofollow"'
)
);
@@ -397,7 +389,7 @@ if (isset($page['category']) and is_admin())
'edit',
array(
'URL' =>
PHPWG_ROOT_PATH.'admin.php?page=cat_modify'
get_root_url().'admin.php?page=cat_modify'
.'&cat_id='.$page['category']
)
);
@@ -448,7 +440,7 @@ if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
'preferred_image_order.order',
array(
'DISPLAY' => $orders[$i][0],
'URL' => duplicate_index_URL().'&image_order='.$i,
'URL' => add_url_param( duplicate_index_URL(), 'image_order='.$i ),
'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
)
);
+15 -7
View File
@@ -183,7 +183,7 @@ $template->assign_vars(
'F_ACTION'=>PHPWG_ROOT_PATH.'comments.php',
'F_KEYWORD'=>@$_GET['keyword'],
'F_AUTHOR'=>@$_GET['author'],
'U_HOME' => make_index_url(),
)
);
@@ -220,7 +220,7 @@ $blockname = 'since_option';
foreach ($since_options as $id => $option)
{
$selected = ($id == $page['since']) ? 'selected="selected"' : '';
$template->assign_block_vars(
$blockname,
array('SELECTED' => $selected,
@@ -403,17 +403,25 @@ SELECT id, uppercats
{
$name.= get_name_from_file($elements[$comment['image_id']]['file']);
}
// source of the thumbnail picture
$thumbnail_src = get_thumbnail_src(
$elements[$comment['image_id']]['path'],
@$elements[$comment['image_id']]['tn_ext']
);
// link to the full size picture
$url = PHPWG_ROOT_PATH.'picture.php?cat='.$comment['category_id'];
$url.= '&image_id='.$comment['image_id'];
$url = make_picture_url(
array(
'category' => $comment['category_id'],
'image_id' => $comment['image_id'],
'image_file' => $elements[$comment['image_id']]['file'],
)
);
$template->assign_block_vars(
'picture',
array(
@@ -421,13 +429,13 @@ SELECT id, uppercats
'I_THUMB'=>$thumbnail_src,
'U_THUMB'=>$url
));
$author = $comment['author'];
if (empty($comment['author']))
{
$author = l10n('guest');
}
$template->assign_block_vars(
'comment',
array(
+1 -1
View File
@@ -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';
}
+1 -1
View File
@@ -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 )
+15 -43
View File
@@ -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'])
+45 -10
View File
@@ -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';
}
@@ -1003,6 +1009,35 @@ function get_available_upgrade_ids()
return $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
*
@@ -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'] );
}
+20 -29
View File
@@ -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.
+25 -25
View File
@@ -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>';
+9 -9
View File
@@ -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']
)
)
);
}
+2 -2
View File
@@ -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 ? '|' : ''),
)
);
+164 -153
View File
@@ -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)
);
$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
// );
// $tokens = array(
// 0 => category,
// 1 => 12-foo,
// 2 => start-24
// );
$next_token = 0;
if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php')
{
$next_token = 0;
// 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 (basename($_SERVER['PHP_SELF']) == 'picture.php')
$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))
{
$page['category'] = $matches[1];
$next_token++;
}
}
else if (0 === strpos($tokens[$next_token], 'tag'))
{
$page['section'] = 'tags';
$page['tags'] = array();
$next_token++;
for ($i = $next_token; ; $i++)
{
if (!isset($tokens[$i]))
{
// the first token must be the numeric identifier of the picture
preg_match('/(\d+)/', $tokens[$next_token], $matches);
if (!isset($matches[1]))
break;
}
preg_match('/^(\d+)/', $tokens[$i], $matches);
if (!isset($matches[1]))
{
if (0 == count($page['tags']))
{
die('Fatal: picture identifier is missing');
die('Fatal: at least one tag required');
}
$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))
{
$page['category'] = $matches[1];
$next_token++;
}
}
else if (0 === strpos($tokens[$next_token], 'tag'))
{
$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]))
{
if (0 == count($page['tags']))
{
die('Fatal: at least one tag required');
}
else
{
break;
}
}
array_push($page['tags'], $matches[1]);
}
$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++;
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++;
}
for ($i = $next_token; ; $i++)
{
if (!isset($tokens[$i]))
else
{
break;
}
}
array_push($page['tags'], $matches[1]);
}
if (preg_match('/^start-(\d+)/', $tokens[$i], $matches))
{
$page['start'] = $matches[1];
}
$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('/^posted|created/', $tokens[$i] ))
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++;
}
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];
$page['chronology_view'] = $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;
}
}
$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>';
?>
+5 -5
View File
@@ -132,11 +132,11 @@ $lang['caddie'] = 'caddie';
$lang['calendar'] = 'Calendar';
$lang['calendar_any'] = 'All';
$lang['calendar_hint'] = 'displays each day with pictures, month per month';
$lang['calendar_monthly_l'] = 'Monthly list';
$lang['calendar_monthly_c'] = 'Monthly calendar';
$lang['calendar_picture_hint'] = 'displays pictures added on ';
$lang['calendar_view'] = 'View';
$lang['calendar_weekly_l'] = 'Weekly list';
$lang['chronology_monthly_list'] = 'Monthly list';
$lang['chronology_monthly_calendar'] = 'Monthly calendar';
$lang['chronology_weekly_list'] = 'Weekly list';
$lang['click_to_redirect'] = 'Click here if your browser does not automatically forward you';
$lang['comment date'] = 'comment date';
$lang['comment'] = 'Comment';
@@ -184,7 +184,7 @@ $lang['generation_time'] = 'Page generated in';
$lang['guest'] = 'guest';
$lang['hello'] = 'Hello';
$lang['hint_admin'] = 'available for administrators only';
$lang['hint_category'] = 'shows images at the root of this categry';
$lang['hint_category'] = 'shows images at the root of this category';
$lang['hint_comments'] = 'See last users comments';
$lang['hint_customize'] = 'customize the appareance of the gallery';
$lang['hint_search'] = 'search';
@@ -289,7 +289,7 @@ $lang['search_one_clause_at_least'] = 'Empty query. No criteria has been entered
$lang['search_options'] = 'Search Options';
$lang['search_result'] = 'Search results';
$lang['search_sort'] = 'Sort results by';
$lang['search_subcats_included'] = 'Search in subcategroies';
$lang['search_subcats_included'] = 'Search in subcategories';
$lang['search_title'] = 'Search';
$lang['searched words : %s'] = 'searched words : %s';
$lang['send_mail'] = 'Contact';
+3 -3
View File
@@ -131,11 +131,11 @@ $lang['caddie'] = 'Panier';
$lang['calendar'] = 'Calendrier';
$lang['calendar_any'] = 'Tout';
$lang['calendar_hint'] = 'affichage année par année, mois par mois, jour par jour';
$lang['calendar_monthly_l'] = 'Liste mensuelle';
$lang['calendar_monthly_c'] = 'Calendrier mensuel';
$lang['calendar_picture_hint'] = 'afficher les images du ';
$lang['calendar_view'] = 'Vue';
$lang['calendar_weekly_l'] = 'Liste hebdomadaire';
$lang['chronology_monthly_list'] = 'Liste mensuelle';
$lang['chronology_monthly_calendar'] = 'Calendrier mensuel';
$lang['chronology_weekly_list'] = 'Liste hebdomadaire';
$lang['click_to_redirect'] = 'Cliquez ici si votre navigateur ne vous redirige pas.';
$lang['comment date'] = 'date du commentaire';
$lang['comment'] = 'Commentaire';
+43 -42
View File
@@ -276,9 +276,6 @@ while ($row = mysql_fetch_array($result))
$cat_directory = dirname($row['path']);
$file_wo_ext = get_filename_wo_extension($row['file']);
$icon = get_themeconf('mime_icon_dir');
$icon.= strtolower(get_extension($row['file'])).'.png';
if (isset($row['representative_ext']) and $row['representative_ext'] != '')
{
$picture[$i]['src'] =
@@ -287,6 +284,8 @@ while ($row = mysql_fetch_array($result))
}
else
{
$icon = get_themeconf('mime_icon_dir');
$icon.= strtolower(get_extension($row['file'])).'.png';
$picture[$i]['src'] = $icon;
}
// special case for picture files
@@ -300,15 +299,25 @@ while ($row = mysql_fetch_array($result))
if (($row['has_high'] == 'true') and ($user['enabled_high'] == 'true'))
{
$url_high=$cat_directory.'/pwg_high/'.$row['file'];
$picture[$i]['high'] = $url_high;
$picture[$i]['high_file_system'] = $picture[$i]['high'] = $url_high;
if ( ! url_is_remote($picture[$i]['high']) )
{
$picture[$i]['high'] = get_root_url().$picture[$i]['high'];
}
}
}
}
$picture[$i]['src_file_system'] = $picture[$i]['src'];
if ( ! url_is_remote($picture[$i]['src']) )
{
$picture[$i]['src'] = get_root_url(). $picture[$i]['src'];
}
// if picture is not a file, we need the download link
if (!$picture[$i]['is_picture'])
{
$picture[$i]['download'] = $row['path'];
$picture[$i]['download'] = url_is_remote($row['path']) ? '' : get_root_url();
$picture[$i]['download'].= $row['path'];
}
$picture[$i]['thumbnail'] = get_thumbnail_src($row['path'], @$row['tn_ext']);
@@ -325,6 +334,7 @@ while ($row = mysql_fetch_array($result))
$picture[$i]['url'] = duplicate_picture_URL(
array(
'image_id' => $row['id'],
'image_file' => $row['file'],
),
array(
'start',
@@ -342,22 +352,21 @@ while ($row = mysql_fetch_array($result))
}
$url_admin =
PHPWG_ROOT_PATH.'admin.php?page=picture_modify'
get_root_url().'admin.php?page=picture_modify'
.'&amp;cat_id='.(isset($page['category']) ? $page['category'] : '')
.'&amp;image_id='.$page['image_id']
;
$url_slide =
$picture['current']['url']
.'&amp;slideshow='.$conf['slideshow_period']
;
$url_slide = add_url_param(
$picture['current']['url'],
'slideshow='.$conf['slideshow_period'] );
$title = $picture['current']['name'];
$refresh = 0;
if ( isset( $_GET['slideshow'] ) and isset($page['next_item']) )
{
$refresh= $_GET['slideshow'];
$url_link = $picture['next']['url'].'&amp;slideshow='.$refresh;
$url_link = add_url_param($picture['next']['url'], 'slideshow='.$refresh);
}
$title_img = $picture['current']['name'];
@@ -377,7 +386,7 @@ $title_nb = ($page['current_rank'] + 1).'/'.$page['cat_nb_images'];
// calculation of width and height
if (empty($picture['current']['width']))
{
$taille_image = @getimagesize($picture['current']['src']);
$taille_image = @getimagesize($picture['current']['src_file_system']);
$original_width = $taille_image[0];
$original_height = $taille_image[1];
}
@@ -510,8 +519,8 @@ if (isset($picture['current']['high']))
$template->assign_block_vars(
'download',
array(
'U_DOWNLOAD' => PHPWG_ROOT_PATH.'action.php?dwn='
.$picture['current']['high']
'U_DOWNLOAD' => get_root_url().'action.php?dwn='
.$picture['current']['high_file_system']
)
);
}
@@ -522,7 +531,7 @@ if (is_admin() and isset($page['category']))
$template->assign_block_vars(
'representative',
array(
'URL' => $url_self.'&amp;action=set_as_representative'
'URL' => add_url_param($url_self, 'action=set_as_representative')
)
);
}
@@ -533,7 +542,7 @@ if (is_admin())
$template->assign_block_vars(
'caddie',
array(
'URL' => $url_self.'&amp;action=add_to_caddie'
'URL' => add_url_param($url_self, 'action=add_to_caddie')
)
);
}
@@ -553,15 +562,13 @@ SELECT COUNT(*) AS nb_fav
if ($row['nb_fav'] == 0)
{
$url = $url_self.'&amp;action=add_to_favorites';
$template->assign_block_vars(
'favorite',
array(
'FAVORITE_IMG' => get_themeconf('icon_dir').'/favorite.png',
'FAVORITE_IMG' => get_root_url().get_themeconf('icon_dir').'/favorite.png',
'FAVORITE_HINT' => $lang['add_favorites_hint'],
'FAVORITE_ALT' => $lang['add_favorites_alt'],
'U_FAVORITE' => $url_self.'&amp;action=add_to_favorites',
'U_FAVORITE' => add_url_param($url_self, 'action=add_to_favorites'),
)
);
}
@@ -570,10 +577,10 @@ SELECT COUNT(*) AS nb_fav
$template->assign_block_vars(
'favorite',
array(
'FAVORITE_IMG' => get_themeconf('icon_dir').'/del_favorite.png',
'FAVORITE_IMG' => get_root_url().get_themeconf('icon_dir').'/del_favorite.png',
'FAVORITE_HINT' => $lang['del_favorites_hint'],
'FAVORITE_ALT' => $lang['del_favorites_alt'],
'U_FAVORITE' => $url_self.'&amp;action=remove_from_favorites',
'U_FAVORITE' => add_url_param($url_self, 'action=remove_from_favorites'),
)
);
}
@@ -621,16 +628,13 @@ if (!empty($picture['current']['date_creation']))
{
$val = format_date($picture['current']['date_creation']);
$url = make_index_URL(
array(
'chronology' =>
array(
'field'=>'created',
'style'=>'monthly',
'view'=>'list',
),
'chronology_date' => explode('-', $picture['current']['date_creation'])
)
);
array(
'chronology_field'=>'created',
'chronology_style'=>'monthly',
'chronology_view'=>'list',
'chronology_date' => explode('-', $picture['current']['date_creation'])
)
);
$infos['INFO_CREATION_DATE'] = '<a href="'.$url.'">'.$val.'</a>';
}
else
@@ -641,16 +645,13 @@ else
// date of availability
$val = format_date($picture['current']['date_available'], 'mysql_datetime');
$url = make_index_URL(
array(
'chronology' =>
array(
'field'=>'posted',
'style'=>'monthly',
'view'=>'list',
),
'chronology_date' => explode('-', substr($picture['current']['date_available'],0,10))
)
);
array(
'chronology_field'=>'posted',
'chronology_style'=>'monthly',
'chronology_view'=>'list',
'chronology_date'=>explode('-', substr($picture['current']['date_available'],0,10))
)
);
$infos['INFO_POSTED_DATE'] = '<a href="'.$url.'">'.$val.'</a>';
// size in pixels