aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/cat_list.php14
-rw-r--r--admin/cat_modify.php8
-rw-r--r--admin/element_set.php10
-rw-r--r--admin/picture_modify.php8
-rw-r--r--admin/waiting.php7
-rw-r--r--category.php7
-rw-r--r--comments.php5
-rw-r--r--include/category_cats.inc.php12
-rw-r--r--include/category_default.inc.php2
-rw-r--r--include/functions.inc.php3
-rw-r--r--include/functions_calendar.inc.php12
-rw-r--r--include/functions_category.inc.php47
-rw-r--r--include/functions_html.inc.php59
-rw-r--r--include/functions_url.inc.php34
-rw-r--r--include/menubar.inc.php5
-rw-r--r--include/section_init.inc.php23
-rw-r--r--include/ws_functions.inc.php17
-rw-r--r--index.php4
-rw-r--r--picture.php6
-rw-r--r--upload.php17
20 files changed, 128 insertions, 172 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php
index 82a272639..c34754f87 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -2,10 +2,9 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
-// | file : $RCSfile$
+// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
// | revision : $Revision$
@@ -172,10 +171,8 @@ if (isset($_GET['parent_id']))
{
$navigation.= $conf['level_separator'];
- $current_category = get_cat_info($_GET['parent_id']);
-
- $navigation.= get_cat_display_name(
- $current_category['name'],
+ $navigation.= get_cat_display_name_from_id(
+ $_GET['parent_id'],
$base_url.'&parent_id=',
false
);
@@ -277,8 +274,7 @@ foreach ($categories as $category)
'U_JUMPTO' => make_index_url(
array(
- 'category' => $category['id'],
- 'cat_name' => $category['name'],
+ 'category' => $category
)
),
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index e87a6aee5..065983070 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -2,10 +2,9 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
-// | file : $RCSfile$
+// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
// | revision : $Revision$
@@ -279,8 +278,7 @@ $template->assign_vars(
'U_JUMPTO' => make_index_url(
array(
- 'category' => $category['id'],
- 'cat_name' => $category['name'],
+ 'category' => $category
)
),
diff --git a/admin/element_set.php b/admin/element_set.php
index ee9884e31..fe005ee44 100644
--- a/admin/element_set.php
+++ b/admin/element_set.php
@@ -2,10 +2,9 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
-// | file : $RCSfile$
+// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
// | revision : $Revision$
@@ -109,10 +108,9 @@ DELETE
if (is_numeric($_GET['cat']))
{
- $cat_infos = get_cat_info($_GET['cat']);
$page['title'] =
- get_cat_display_name(
- $cat_infos['name'],
+ get_cat_display_name_from_id(
+ $_GET['cat'],
PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id=',
false
);
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index 9f6877167..0dd6a237b 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -253,8 +253,8 @@ $template->assign_vars(
'TAG_SELECTION' => $tag_selection,
'DESCRIPTION' =>
- isset($_POST['description']) ?
- stripslashes($_POST['description']) : @$row['comment'],
+ htmlspecialchars( isset($_POST['description']) ?
+ stripslashes($_POST['description']) : @$row['comment'] ),
'F_ACTION' =>
PHPWG_ROOT_PATH.'admin.php'
@@ -347,7 +347,7 @@ if (isset($_GET['cat_id'])
array(
'image_id' => $_GET['image_id'],
'image_file' => $image_file,
- 'category' => $_GET['cat_id'],
+ 'category' => $cache['cat_names'][ $_GET['cat_id'] ],
)
);
}
@@ -359,7 +359,7 @@ else
array(
'image_id' => $_GET['image_id'],
'image_file' => $image_file,
- 'category' => $category,
+ 'category' => $cache['cat_names'][ $category ],
)
);
break;
diff --git a/admin/waiting.php b/admin/waiting.php
index 8a63ac17a..30bd6f37c 100644
--- a/admin/waiting.php
+++ b/admin/waiting.php
@@ -2,10 +2,9 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
-// | file : $RCSfile$
+// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
// | revision : $Revision$
@@ -161,7 +160,7 @@ while ( $row = mysql_fetch_array( $result ) )
$cat_names[$row['storage_category_id']]['dir'] =
PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] );
$cat_names[$row['storage_category_id']]['display_name'] =
- get_cat_display_name($cat['name']);
+ get_cat_display_name($cat['upper_names']);
}
$preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file'];
$class='row1';
diff --git a/category.php b/category.php
index 8b0ade406..16d7a127e 100644
--- a/category.php
+++ b/category.php
@@ -38,10 +38,11 @@ if ( isset($_GET['cat']) )
if ( is_numeric($_GET['cat']) )
{
$url_params['section'] = 'categories';
- $url_params['category'] = $_GET['cat'];
- $result = get_cat_info($url_params['category']);
+ $result = get_cat_info( $_GET['cat'] );
if ( !empty($result) )
- $url_params['cat_name'] = $result['name'];
+ {
+ $url_params['category'] = $result;
+ }
}
elseif ( in_array($_GET['cat'],
array('best_rated','most_visited','recent_pics','recent_cats')
diff --git a/comments.php b/comments.php
index 0c0735447..9a41dcb2b 100644
--- a/comments.php
+++ b/comments.php
@@ -205,7 +205,7 @@ $template->assign_block_vars(
));
$query = '
-SELECT id,name,uppercats,global_rank
+SELECT id, name, uppercats, global_rank
FROM '.CATEGORIES_TABLE.'
'.get_sql_condition_FandF
(
@@ -398,8 +398,7 @@ SELECT id, name, uppercats
// link to the full size picture
$url = make_picture_url(
array(
- 'category' => $comment['category_id'],
- 'cat_name' => $categories[ $comment['category_id']] ['name'],
+ 'category' => $categories[ $comment['category_id'] ],
'image_id' => $comment['image_id'],
'image_file' => $elements[$comment['image_id']]['file'],
)
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index 2acb05f13..e9549ba44 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -35,7 +35,7 @@ if ($page['section']=='recent_cats')
// $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
$query = '
SELECT
- id,name, representative_picture_id, comment, nb_images, uppercats,
+ id, name, representative_picture_id, comment, nb_images, uppercats,
date_last, max_date_last, count_images, count_categories, global_rank
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'].'
@@ -57,12 +57,12 @@ else
// $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
$query = '
SELECT
- id,name, representative_picture_id, comment, nb_images,
+ id, name, representative_picture_id, comment, nb_images,
date_last, max_date_last, count_images, count_categories
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'].'
WHERE id_uppercat '.
- (!isset($page['category']) ? 'is NULL' : '= '.$page['category']).'
+ (!isset($page['category']) ? 'is NULL' : '= '.$page['category']['id']).'
'.get_sql_condition_FandF
(
array
@@ -206,8 +206,7 @@ if (count($categories) > 0)
'URL' => make_index_url(
array(
- 'category' => $category['id'],
- 'cat_name' => $category['name'],
+ 'category' => $category
)
),
'CAPTION_NB_IMAGES' => get_display_images_count
@@ -258,8 +257,7 @@ if (count($categories) > 0)
'U_IMG_LINK' => make_index_url(
array(
- 'category' => $category['id'],
- 'cat_name' => $category['name'],
+ 'category' => $category
)
),
'CLASS' => 'thumbCat',
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index bb6b5a089..1d8438d93 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -157,7 +157,7 @@ foreach ($pictures as $row)
if ($user['show_nb_comments']
and isset($page['category'])
- and $page['cat_commentable'])
+ and $page['category']['commentable'])
{
$query = '
SELECT COUNT(*) AS nb_comments
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 4666c0fcb..50f247a47 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -4,7 +4,6 @@
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
@@ -482,7 +481,7 @@ INSERT INTO '.HISTORY_TABLE.'
'.$user['id'].',
\''.$_SERVER['REMOTE_ADDR'].'\',
'.(isset($page['section']) ? "'".$page['section']."'" : 'NULL').',
- '.(isset($page['category']) ? $page['category'] : 'NULL').',
+ '.(isset($page['category']) ? $page['category']['id'] : 'NULL').',
'.(isset($image_id) ? $image_id : 'NULL').',
'.(isset($image_id) ? "'".$image_type."'" : 'NULL').',
'.(isset($tags_string) ? "'".$tags_string."'" : 'NULL').'
diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php
index a29536c71..86ef40837 100644
--- a/include/functions_calendar.inc.php
+++ b/include/functions_calendar.inc.php
@@ -1,10 +1,9 @@
<?php
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
-// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
-// | file : $RCSfile$
+// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
// | revision : $Revision$
@@ -34,17 +33,16 @@ function initialize_calendar()
//------------------ initialize the condition on items to take into account ---
$inner_sql = ' FROM ' . IMAGES_TABLE;
- if ($page['section']=='categories' or
- ( isset($page['category']) and is_numeric($page['category']) ) )
+ if ($page['section']=='categories')
{ // we will regenerate the items by including subcats elements
$page['items'] = array();
$inner_sql .= '
INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id';
- if (isset($page['category']) and is_numeric($page['category']))
+ if ( isset($page['category']) )
{
$sub_ids = array_diff(
- get_subcat_ids(array($page['category'])),
+ get_subcat_ids(array($page['category']['id'])),
explode(',', $user['forbidden_categories'])
);
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 8ed10de3e..66b8865da 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -77,7 +77,7 @@ WHERE
(id_uppercat is NULL';
if (isset($page['category']))
{
- $query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
+ $query.= ' OR id_uppercat IN ('.$page['category']['uppercats'].')';
}
$query.= ')';
}
@@ -111,7 +111,7 @@ WHERE
update_cats_with_filtered_data($cats);
}
- return get_html_menu_category($cats);
+ return get_html_menu_category($cats, @$page['category'] );
}
@@ -134,62 +134,48 @@ WHERE
*/
function get_cat_info( $id )
{
- $infos = array('nb_images','id_uppercat','comment','site_id'
- ,'dir','date_last','uploadable','status','visible'
- ,'representative_picture_id','uppercats','commentable'
- ,'image_order');
-
$query = '
-SELECT '.implode(',', $infos).'
+SELECT *
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$id.'
;';
- $row = mysql_fetch_array(pwg_query($query));
- if (empty($row))
+ $cat = mysql_fetch_assoc(pwg_query($query));
+ if (empty($cat))
return null;
- $cat = array();
- foreach ($infos as $info)
+ foreach ($cat as $k => $v)
{
- if (isset($row[$info]))
- {
- $cat[$info] = $row[$info];
- }
- else
- {
- $cat[$info] = '';
- }
// If the field is true or false, the variable is transformed into a
// boolean value.
- if ($cat[$info] == 'true' or $cat[$info] == 'false')
+ if ($cat[$k] == 'true' or $cat[$k] == 'false')
{
- $cat[$info] = get_boolean( $cat[$info] );
+ $cat[$k] = get_boolean( $cat[$k] );
}
}
global $conf;
if ( !( $conf['allow_html_descriptions'] and
preg_match('/<(div|br|img|script).*>/i', $cat['comment']) ) )
{
- $cat['comment'] = nl2br($cat['comment']);
+ $cat['comment'] = nl2br(@$cat['comment']);
}
$names = array();
$query = '
-SELECT name,id
+SELECT id, name
FROM '.CATEGORIES_TABLE.'
WHERE id IN ('.$cat['uppercats'].')
;';
$result = pwg_query($query);
- while($row = mysql_fetch_array($result))
+ while($row = mysql_fetch_assoc($result))
{
- $names[$row['id']] = $row['name'];
+ $names[$row['id']] = $row;
}
// category names must be in the same order than uppercats list
- $cat['name'] = array();
+ $cat['upper_names'] = array();
foreach (explode(',', $cat['uppercats']) as $cat_id)
{
- $cat['name'][$cat_id] = $names[$cat_id];
+ $cat['upper_names'][$cat_id] = $names[$cat_id];
}
return $cat;
@@ -345,6 +331,11 @@ SELECT DISTINCT(id)
WHERE ';
foreach ($ids as $num => $category_id)
{
+ is_numeric($category_id)
+ or trigger_error(
+ 'get_subcat_ids expecting numeric, not '.gettype($category_id),
+ E_USER_WARNING
+ );
if ($num > 0)
{
$query.= '
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 60f26a45a..dcb42cdb1 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -235,7 +235,7 @@ function create_navigation_bar(
*
* categories string returned contains categories as given in the input
* array $cat_informations. $cat_informations array must be an association
- * of {category_id => category_name}. If url input parameter is null,
+ * of {category_id => array( id, name) }. If url input parameter is null,
* returns only the categories name without links.
*
* @param array cat_informations
@@ -251,8 +251,11 @@ function get_cat_display_name($cat_informations,
$output = '';
$is_first = true;
- foreach ($cat_informations as $id => $name)
+ foreach ($cat_informations as $id => $cat)
{
+ is_array($cat) or trigger_error(
+ 'get_cat_display_name wrong type for cat '.$id, E_USER_WARNING
+ );
if ($is_first)
{
$is_first = false;
@@ -264,24 +267,23 @@ function get_cat_display_name($cat_informations,
if ( !isset($url) )
{
- $output.= $name;
+ $output.= $cat['name'];
}
elseif ($url == '')
{
$output.= '<a href="'
.make_index_url(
array(
- 'category'=>$id,
- 'cat_name'=>$name
+ 'category' => $cat,
)
)
.'">';
- $output.= $name.'</a>';
+ $output.= $cat['name'].'</a>';
}
else
{
$output.= '<a href="'.PHPWG_ROOT_PATH.$url.$id.'">';
- $output.= $name.'</a>';
+ $output.= $cat['name'].'</a>';
}
}
if ($replace_space)
@@ -311,18 +313,18 @@ function get_cat_display_name_cache($uppercats,
$url = '',
$replace_space = true)
{
- global $cat_names, $conf;
+ global $cache, $conf;
- if (!isset($cat_names))
+ if (!isset($cache['cat_names']))
{
$query = '
-SELECT id,name
+SELECT id, name
FROM '.CATEGORIES_TABLE.'
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
- $cat_names[$row['id']] = $row['name'];
+ $cache['cat_names'][$row['id']] = $row;
}
}
@@ -330,7 +332,7 @@ SELECT id,name
$is_first = true;
foreach (explode(',', $uppercats) as $category_id)
{
- $name = $cat_names[$category_id];
+ $cat = $cache['cat_names'][$category_id];
if ($is_first)
{
@@ -343,7 +345,7 @@ SELECT id,name
if ( !isset($url) )
{
- $output.= $name;
+ $output.= $cat['name'];
}
elseif ($url == '')
{
@@ -351,16 +353,15 @@ SELECT id,name
<a href="'
.make_index_url(
array(
- 'category'=>$category_id,
- 'cat_name'=>$name
+ 'category' => $cat,
)
)
- .'">'.$name.'</a>';
+ .'">'.$cat['name'].'</a>';
}
else
{
$output.= '
-<a href="'.PHPWG_ROOT_PATH.$url.$category_id.'">'.$name.'</a>';
+<a href="'.PHPWG_ROOT_PATH.$url.$category_id.'">'.$cat['name'].'</a>';
}
}
if ($replace_space)
@@ -384,21 +385,14 @@ SELECT id,name
* @param array categories
* @return string
*/
-function get_html_menu_category($categories)
+function get_html_menu_category($categories, $selected_category)
{
- global $page, $lang;
+ global $lang;
$ref_level = 0;
$level = 0;
$menu = '';
- // $page_cat value remains 0 for special sections
- $page_cat = 0;
- if (isset($page['category']))
- {
- $page_cat = $page['category'];
- }
-
foreach ($categories as $category)
{
$level = substr_count($category['global_rank'], '.') + 1;
@@ -419,7 +413,7 @@ function get_html_menu_category($categories)
$ref_level = $level;
$menu.= "\n\n".'<li';
- if ($category['id'] == $page_cat)
+ if ($category['id'] == @$selected_category['id'])
{
$menu.= ' class="selected"';
}
@@ -427,14 +421,13 @@ function get_html_menu_category($categories)
$url = make_index_url(
array(
- 'category'=>$category['id'],
- 'cat_name'=>$category['name']
+ 'category' => $category
)
);
$menu.= "\n".'<a href="'.$url.'"';
- if ($page_cat != 0
- and $category['id'] == $page['cat_id_uppercat'])
+ if ($selected_category!=null
+ and $category['id'] == $selected_category['id_uppercat'])
{
$menu.= ' rel="up"';
}
@@ -509,7 +502,7 @@ function get_cat_display_name_from_id($cat_id,
$replace_space = true)
{
$cat_info = get_cat_info($cat_id);
- return get_cat_display_name($cat_info['name'], $url, $replace_space);
+ return get_cat_display_name($cat_info['upper_names'], $url, $replace_space);
}
/**
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index 4f9b15b4b..b96ed82b7 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -3,7 +3,6 @@
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
@@ -133,9 +132,11 @@ function make_index_url($params = array())
* build an index URL with current page parameters, but with redefinitions
* and removes.
*
- * duplicate_index_url(array('category' => 12), array('start')) will create
- * an index URL on the current section (categories), but on a redefined
- * category and without the start URL parameter.
+ * duplicate_index_url( array(
+ * 'category' => array('id'=>12, 'name'=>'toto'),
+ * array('start')
+ * ) will create an index URL on the current section (categories), but on
+ * a redefined category and without the start URL parameter.
*
* @param array redefined keys
* @param array removed keys
@@ -325,19 +326,20 @@ function make_section_in_url($params)
}
else
{
- $section_string.= '/category/'.$params['category'];
- if ($conf['category_url_style']=='id-name' and isset($params['cat_name']) )
+ is_array($params['category']) or trigger_error(
+ 'make_section_in_url wrong type for category', E_USER_WARNING
+ );
+ is_numeric($params['category']['id']) or trigger_error(
+ 'make_section_in_url category id not numeric', E_USER_WARNING
+ );
+ isset($params['category']['name']) or trigger_error(
+ 'make_section_in_url category name not set', E_USER_WARNING
+ );
+
+ $section_string.= '/category/'.$params['category']['id'];
+ if ( $conf['category_url_style']=='id-name' )
{
- if ( is_string($params['cat_name']) )
- {
- $section_string.= '-'.str2url($params['cat_name']);
- }
- elseif ( is_array( $params['cat_name'] ) and
- isset( $params['cat_name'][$params['category']] ) )
- {
- $section_string.= '-'
- .str2url($params['cat_name'][$params['category']]);
- }
+ $section_string.= '-'.str2url($params['category']['name']);
}
}
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index d38290704..1ddc59882 100644
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -4,7 +4,6 @@
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
@@ -333,9 +332,9 @@ $template->assign_block_vars(
)
);
-if (isset($page['category']) and $page['cat_uploadable'] )
+if (isset($page['category']) and $page['category']['uploadable'] )
{ // upload a picture in the category
- $url = get_root_url().'upload.php?cat='.$page['category'];
+ $url = get_root_url().'upload.php?cat='.$page['category']['id'];
$template->assign_block_vars(
'upload',
array(
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index 4239ebd93..4434ec542 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -34,15 +34,14 @@
*
*/
-// "index.php?/category/12-foo/start-24&action=fill_caddie" or
-// "index.php/category/12-foo/start-24&action=fill_caddie"
+// "index.php?/category/12-foo/start-24" or
+// "index.php/category/12-foo/start-24"
// must return :
//
// array(
// 'section' => 'categories',
-// 'category' => 12,
+// 'category' => array('id'=>12, ...),
// 'start' => 24
-// 'action' => 'fill_caddie'
// );
$page['items'] = array();
@@ -87,7 +86,7 @@ if (script_basename() == 'picture') // basename without file extention
{// url compatibility with versions below 1.6
$url = make_picture_url( array(
'section' => 'categories',
- 'category' => $_GET['cat'],
+ 'category' => get_cat_info($_GET['cat']),
'image_id' => $_GET['image_id']
) );
redirect($url);
@@ -360,15 +359,9 @@ if ('categories' == $page['section'])
$page,
array(
'comment' => $result['comment'],
- 'cat_dir' => $result['dir'],
- 'cat_name' => $result['name'],
- 'cat_site_id' => $result['site_id'],
- 'cat_uploadable' => $result['uploadable'],
- 'cat_commentable' => $result['commentable'],
- 'cat_id_uppercat' => $result['id_uppercat'],
- 'uppercats' => $result['uppercats'],
+ 'category' => $result,
'title' =>
- get_cat_display_name($result['name'], '', false),
+ get_cat_display_name($result['upper_names'], '', false),
)
);
}
@@ -395,7 +388,7 @@ if ('categories' == $page['section'])
{// flat categories mode
if ( isset($page['category']) )
{
- $subcat_ids = get_subcat_ids( array($page['category']) );
+ $subcat_ids = get_subcat_ids( array($page['category']['id']) );
$where_sql = 'category_id IN ('.implode(',',$subcat_ids).')';
}
else
@@ -405,7 +398,7 @@ if ('categories' == $page['section'])
}
else
{// Normal mode
- $where_sql = 'category_id = '.$page['category'];
+ $where_sql = 'category_id = '.$page['category']['id'];
}
// Main query
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index e19966673..c8e2a0fe0 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -386,14 +386,12 @@ LIMIT '.$params['per_page']*$params['page'].','.$params['per_page'];
{
$url = make_index_url(
array(
- 'category' => $cat_id,
- 'cat_name' => $cats[$cat_id]['name'],
+ 'category' => $cats[$cat_id],
)
);
$page_url = make_picture_url(
array(
- 'category' => $cat_id,
- 'cat_name' => $cats[$cat_id]['name'],
+ 'category' => $cats[$cat_id],
'image_id' => $row['id'],
'image_file' => $row['file'],
)
@@ -484,8 +482,7 @@ ORDER BY global_rank';
{
$row['url'] = make_index_url(
array(
- 'category' => $row['id'],
- 'cat_name' => $row['name'],
+ 'category' => $row
)
);
foreach( array('id','nb_images','total_nb_images','nb_categories') as $key)
@@ -599,7 +596,7 @@ LIMIT 1;';
//-------------------------------------------------------- related categories
$query = '
-SELECT id,name,uppercats,global_rank,commentable
+SELECT id, name, uppercats, global_rank, commentable
FROM '.IMAGE_CATEGORY_TABLE.'
INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
WHERE image_id = '.$image_row['id'].'
@@ -617,8 +614,7 @@ SELECT id,name,uppercats,global_rank,commentable
unset($row['commentable']);
$row['url'] = make_index_url(
array(
- 'category' => $row['id'],
- 'cat_name' => $row['name'],
+ 'category' => $row
)
);
@@ -626,8 +622,7 @@ SELECT id,name,uppercats,global_rank,commentable
array(
'image_id' => $image_row['id'],
'image_file' => $image_row['file'],
- 'category' => $row['id'],
- 'cat_name' => $row['name'],
+ 'category' => $row
)
);
$row['id']=(int)$row['id'];
diff --git a/index.php b/index.php
index e138e4681..ef0f00c5a 100644
--- a/index.php
+++ b/index.php
@@ -65,7 +65,7 @@ if (!isset($page['start']))
// access authorization check
if (isset($page['category']))
{
- check_restrictions($page['category']);
+ check_restrictions($page['category']['id']);
}
if ( count($page['items']) > $user['nb_image_page'])
@@ -193,7 +193,7 @@ if (isset($page['category']) and is_admin())
array(
'URL' =>
get_root_url().'admin.php?page=cat_modify'
- .'&amp;cat_id='.$page['category']
+ .'&amp;cat_id='.$page['category']['id']
)
);
}
diff --git a/picture.php b/picture.php
index a917d0888..2366987c6 100644
--- a/picture.php
+++ b/picture.php
@@ -36,7 +36,7 @@ check_status(ACCESS_GUEST);
// access authorization check
if (isset($page['category']))
{
- check_restrictions($page['category']);
+ check_restrictions($page['category']['id']);
}
// if this image_id doesn't correspond to this category, an error message is
@@ -199,7 +199,7 @@ DELETE FROM '.FAVORITES_TABLE.'
$query = '
UPDATE '.CATEGORIES_TABLE.'
SET representative_picture_id = '.$page['image_id'].'
- WHERE id = '.$page['category'].'
+ WHERE id = '.$page['category']['id'].'
;';
pwg_query($query);
}
@@ -420,7 +420,7 @@ if (!empty($picture['current']['width']))
$url_admin =
get_root_url().'admin.php?page=picture_modify'
- .'&amp;cat_id='.(isset($page['category']) ? $page['category'] : '')
+ .'&amp;cat_id='.(isset($page['category']) ? $page['category']['id'] : '')
.'&amp;image_id='.$page['image_id']
;
diff --git a/upload.php b/upload.php
index 16dba838b..380abc46d 100644
--- a/upload.php
+++ b/upload.php
@@ -132,13 +132,10 @@ if (is_numeric($_GET['cat']))
if (isset($page['category']))
{
check_restrictions( $page['category'] );
- $result = get_cat_info( $page['category'] );
- $page['cat_dir'] = get_complete_dir( $page['category'] );
- $page['cat_site_id'] = $result['site_id'];
- $page['cat_name'] = $result['name'];
- $page['cat_uploadable'] = $result['uploadable'];
+ $category = get_cat_info( $page['category'] );
+ $category['cat_dir'] = get_complete_dir( $page['category'] );
- if (url_is_remote($page['cat_dir']) or !$page['cat_uploadable'])
+ if (url_is_remote($category['cat_dir']) or !$category['uploadable'])
{
die('Fatal: you take a wrong way, bye bye');
}
@@ -154,7 +151,7 @@ if ( isset( $_GET['waiting_id'] ) )
// verfying fields
if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) )
{
- $path = $page['cat_dir'].$_FILES['picture']['name'];
+ $path = $category['cat_dir'].$_FILES['picture']['name'];
if ( @is_file( $path ) )
{
array_push( $error, l10n('upload_file_exists') );
@@ -241,7 +238,7 @@ if ( isset( $_POST['submit'] ) and isset( $_GET['waiting_id'] ) )
$file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") );
$extension = get_extension( $_FILES['picture']['name'] );
- if (($path = mkget_thumbnail_dir($page['cat_dir'], $error)) != false)
+ if (($path = mkget_thumbnail_dir($category['cat_dir'], $error)) != false)
{
$path.= '/'.$conf['prefix_thumbnail'].$file.'.'.$extension;
$result = validate_upload( $path, $conf['upload_maxfilesize'],
@@ -285,7 +282,7 @@ if ( isset( $page['waiting_id'] ) )
else
{
$advise_title = l10n('upload_advise');
- $advise_title.= get_cat_display_name($page['cat_name']);
+ $advise_title.= get_cat_display_name($category['upper_names']);
}
$template->assign_vars(
@@ -302,7 +299,7 @@ $template->assign_vars(
'F_ACTION' => $u_form,
- 'U_RETURN' => make_index_url(array('category' => $page['category'])),
+ 'U_RETURN' => make_index_url(array('category' => $category)),
)
);