2003-05-09 12:42:42 +00:00
|
|
|
<?php
|
2004-02-11 23:20:38 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 21:12:59 +00:00
|
|
|
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
2005-01-07 23:10:51 +00:00
|
|
|
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
2004-02-11 23:20:38 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 21:12:59 +00:00
|
|
|
// | branch : BSF (Best So Far)
|
2004-02-11 23:20:38 +00:00
|
|
|
// | file : $RCSfile$
|
|
|
|
// | last update : $Date$
|
|
|
|
// | last modifier : $Author$
|
|
|
|
// | revision : $Revision$
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-02-02 00:55:18 +00:00
|
|
|
|
2004-10-24 18:56:09 +00:00
|
|
|
if (!defined('PHPWG_ROOT_PATH'))
|
2004-03-26 17:08:09 +00:00
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
die('Hacking attempt!');
|
2004-03-26 17:08:09 +00:00
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | initialization |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2003-09-07 10:14:33 +00:00
|
|
|
$errors = array();
|
2004-10-24 18:56:09 +00:00
|
|
|
$infos = array();
|
|
|
|
$categories = array();
|
2004-11-18 14:57:00 +00:00
|
|
|
$navigation = $lang['home'];
|
2004-10-24 18:56:09 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | virtual categories management |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-13 13:43:53 +00:00
|
|
|
// request to delete a virtual category
|
2004-10-24 18:56:09 +00:00
|
|
|
if (isset($_GET['delete']) and is_numeric($_GET['delete']))
|
2004-03-26 17:08:09 +00:00
|
|
|
{
|
2004-12-27 14:30:49 +00:00
|
|
|
delete_categories(array($_GET['delete']));
|
2004-11-18 15:17:33 +00:00
|
|
|
array_push($infos, $lang['cat_virtual_deleted']);
|
2004-12-27 14:30:49 +00:00
|
|
|
ordering();
|
|
|
|
update_global_rank();
|
2004-03-26 17:08:09 +00:00
|
|
|
}
|
2004-11-13 13:43:53 +00:00
|
|
|
// request to add a virtual category
|
2004-10-24 18:56:09 +00:00
|
|
|
else if (isset($_POST['submit']))
|
2003-09-07 10:14:33 +00:00
|
|
|
{
|
2004-02-02 00:55:18 +00:00
|
|
|
// is the given category name only containing blank spaces ?
|
2004-10-24 18:56:09 +00:00
|
|
|
if (preg_match('/^\s*$/', $_POST['virtual_name']))
|
|
|
|
{
|
|
|
|
array_push($errors, $lang['cat_error_name']);
|
|
|
|
}
|
2004-03-26 17:08:09 +00:00
|
|
|
|
2004-10-24 18:56:09 +00:00
|
|
|
if (!count($errors))
|
2003-09-07 10:14:33 +00:00
|
|
|
{
|
2004-12-12 21:06:39 +00:00
|
|
|
$parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL';
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 21:28:40 +00:00
|
|
|
|
|
|
|
if ($parent_id != 'NULL')
|
|
|
|
{
|
|
|
|
$query = '
|
2004-12-12 21:06:39 +00:00
|
|
|
SELECT id,uppercats,global_rank,visible,status
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 21:28:40 +00:00
|
|
|
FROM '.CATEGORIES_TABLE.'
|
|
|
|
WHERE id = '.$parent_id.'
|
|
|
|
;';
|
2004-12-12 21:06:39 +00:00
|
|
|
$row = mysql_fetch_array(pwg_query($query));
|
|
|
|
$parent = array('id' => $row['id'],
|
|
|
|
'uppercats' => $row['uppercats'],
|
|
|
|
'visible' => $row['visible'],
|
|
|
|
'status' => $row['status'],
|
|
|
|
'global_rank' => $row['global_rank']);
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 21:28:40 +00:00
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
|
2004-12-27 14:30:49 +00:00
|
|
|
// what will be the inserted id ?
|
|
|
|
$query = '
|
2005-02-07 21:44:21 +00:00
|
|
|
SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1)
|
2004-12-27 14:30:49 +00:00
|
|
|
FROM '.CATEGORIES_TABLE.'
|
|
|
|
;';
|
|
|
|
list($next_id) = mysql_fetch_array(pwg_query($query));
|
|
|
|
|
2004-12-12 21:06:39 +00:00
|
|
|
$insert = array();
|
2004-12-27 14:30:49 +00:00
|
|
|
$insert{'id'} = $next_id++;
|
2004-12-12 21:06:39 +00:00
|
|
|
$insert{'name'} = $_POST['virtual_name'];
|
|
|
|
$insert{'rank'} = $_POST['rank'];
|
|
|
|
$insert{'commentable'} = $conf['newcat_default_commentable'];
|
2004-12-27 14:30:49 +00:00
|
|
|
|
|
|
|
// a virtual category can't be uploadable
|
|
|
|
$insert{'uploadable'} = 'false';
|
2004-12-12 21:06:39 +00:00
|
|
|
|
|
|
|
if (isset($parent))
|
2004-08-25 22:25:58 +00:00
|
|
|
{
|
2004-12-12 21:06:39 +00:00
|
|
|
$insert{'id_uppercat'} = $parent{'id'};
|
2004-12-27 14:30:49 +00:00
|
|
|
$insert{'uppercats'} = $parent{'uppercats'}.','.$insert{'id'};
|
|
|
|
$insert{'global_rank'} = $parent{'global_rank'}.'.'.$insert{'rank'};
|
2004-12-12 21:06:39 +00:00
|
|
|
// at creation, must a category be visible or not ? Warning : if
|
|
|
|
// the parent category is invisible, the category is automatically
|
|
|
|
// create invisible. (invisible = locked)
|
|
|
|
if ('false' == $parent['visible'])
|
|
|
|
{
|
|
|
|
$insert{'visible'} = 'false';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$insert{'visible'} = $conf['newcat_default_visible'];
|
|
|
|
}
|
|
|
|
// at creation, must a category be public or private ? Warning :
|
|
|
|
// if the parent category is private, the category is
|
|
|
|
// automatically create private.
|
|
|
|
if ('private' == $parent['status'])
|
|
|
|
{
|
|
|
|
$insert{'status'} = 'private';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$insert{'status'} = $conf['newcat_default_status'];
|
|
|
|
}
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 21:28:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-12 21:06:39 +00:00
|
|
|
$insert{'visible'} = $conf['newcat_default_visible'];
|
|
|
|
$insert{'status'} = $conf['newcat_default_status'];
|
2004-12-27 14:30:49 +00:00
|
|
|
$insert{'uppercats'} = $insert{'id'};
|
|
|
|
$insert{'global_rank'} = $insert{'rank'};
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 21:28:40 +00:00
|
|
|
}
|
2004-12-12 21:06:39 +00:00
|
|
|
|
|
|
|
$inserts = array($insert);
|
|
|
|
|
|
|
|
// we have then to add the virtual category
|
2004-12-27 14:30:49 +00:00
|
|
|
$dbfields = array('id','site_id','name','id_uppercat','rank',
|
|
|
|
'commentable','uploadable','visible','status',
|
|
|
|
'uppercats','global_rank');
|
2004-12-12 21:06:39 +00:00
|
|
|
mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
|
|
|
|
|
2004-11-18 15:17:33 +00:00
|
|
|
array_push($infos, $lang['cat_virtual_added']);
|
2003-09-07 10:14:33 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | Cache management |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
$query = '
|
|
|
|
SELECT *
|
|
|
|
FROM '.CATEGORIES_TABLE;
|
|
|
|
if (!isset($_GET['parent_id']))
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
$query.= '
|
|
|
|
WHERE id_uppercat IS NULL';
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
2004-03-26 17:08:09 +00:00
|
|
|
else
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
$query.= '
|
|
|
|
WHERE id_uppercat = '.$_GET['parent_id'];
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
$query.= '
|
|
|
|
ORDER BY rank ASC
|
|
|
|
;';
|
2004-10-30 15:42:29 +00:00
|
|
|
$result = pwg_query($query);
|
2004-10-24 18:56:09 +00:00
|
|
|
while ($row = mysql_fetch_assoc($result))
|
2003-09-07 10:14:33 +00:00
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
$categories[$row['rank']] = $row;
|
2004-12-12 21:06:39 +00:00
|
|
|
$categories[$row['rank']]['nb_subcats'] = 0;
|
2003-09-07 10:14:33 +00:00
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | Navigation path |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-03-26 17:08:09 +00:00
|
|
|
if (isset($_GET['parent_id']))
|
2003-09-07 10:14:33 +00:00
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list';
|
|
|
|
|
|
|
|
$navigation = '<a class="" href="'.add_session_id($base_url).'">';
|
2004-11-18 14:57:00 +00:00
|
|
|
$navigation.= $lang['home'];
|
2004-10-24 18:56:09 +00:00
|
|
|
$navigation.= '</a>';
|
2004-12-12 21:06:39 +00:00
|
|
|
$navigation.= $conf['level_separator'];
|
2004-10-24 18:56:09 +00:00
|
|
|
|
2004-03-26 17:08:09 +00:00
|
|
|
$current_category = get_cat_info($_GET['parent_id']);
|
2004-10-24 18:56:09 +00:00
|
|
|
$navigation.= get_cat_display_name($current_category['name'],
|
|
|
|
$base_url.'&parent_id=',
|
|
|
|
false);
|
2003-09-07 10:14:33 +00:00
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | rank updates |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
$current_rank = 0;
|
|
|
|
if (isset($_GET['up']) and is_numeric($_GET['up']))
|
2003-09-07 10:14:33 +00:00
|
|
|
{
|
2004-03-26 17:08:09 +00:00
|
|
|
// 1. searching the id of the category just above at the same level
|
|
|
|
while (list ($id,$current) = each($categories))
|
|
|
|
{
|
|
|
|
if ($current['id'] == $_GET['up'])
|
2004-10-24 18:56:09 +00:00
|
|
|
{
|
|
|
|
$current_rank = $current['rank'];
|
|
|
|
break;
|
2004-03-26 17:08:09 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
if ($current_rank > 1)
|
2004-03-26 17:08:09 +00:00
|
|
|
{
|
|
|
|
// 2. Exchanging ranks between the two categories
|
2004-10-24 18:56:09 +00:00
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET rank = '.($current_rank-1).'
|
|
|
|
WHERE id = '.$_GET['up'].'
|
|
|
|
;';
|
2004-10-30 15:42:29 +00:00
|
|
|
pwg_query($query);
|
2004-10-24 18:56:09 +00:00
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET rank = '.$current_rank.'
|
|
|
|
WHERE id = '.$categories[($current_rank-1)]['id'].'
|
|
|
|
;';
|
2004-10-30 15:42:29 +00:00
|
|
|
pwg_query($query);
|
2004-10-24 18:56:09 +00:00
|
|
|
// 3. Updating the cache array
|
|
|
|
$categories[$current_rank] = $categories[($current_rank-1)];
|
|
|
|
$categories[($current_rank-1)] = $current;
|
2004-03-26 17:08:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// 2. Updating the rank of our category to be after the previous max rank
|
2004-10-24 18:56:09 +00:00
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET rank = '.(count($categories) + 1).'
|
|
|
|
WHERE id = '.$_GET['up'].'
|
|
|
|
;';
|
2004-10-30 15:42:29 +00:00
|
|
|
pwg_query($query);
|
2004-10-24 18:56:09 +00:00
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET rank = rank-1
|
|
|
|
WHERE id_uppercat ';
|
|
|
|
if (empty($_GET['parent_id']))
|
|
|
|
{
|
|
|
|
$query.= 'IS NULL';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$query.= '= '.$_GET['parent_id'];
|
|
|
|
}
|
|
|
|
$query.= '
|
|
|
|
;';
|
2004-10-30 15:42:29 +00:00
|
|
|
pwg_query($query);
|
2004-10-24 18:56:09 +00:00
|
|
|
// 3. Updating the cache array
|
|
|
|
array_push($categories, $current);
|
|
|
|
array_shift($categories);
|
2004-03-26 17:08:09 +00:00
|
|
|
}
|
2004-11-30 20:45:21 +00:00
|
|
|
update_global_rank(@$_GET['parent_id']);
|
2003-09-07 10:14:33 +00:00
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
else if (isset($_GET['down']) and is_numeric($_GET['down']))
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-03-26 17:08:09 +00:00
|
|
|
// 1. searching the id of the category just above at the same level
|
|
|
|
while (list ($id,$current) = each($categories))
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-03-26 17:08:09 +00:00
|
|
|
if ($current['id'] == $_GET['down'])
|
2004-10-24 18:56:09 +00:00
|
|
|
{
|
|
|
|
$current_rank = $current['rank'];
|
|
|
|
break;
|
|
|
|
}
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
2004-03-26 17:08:09 +00:00
|
|
|
if ($current_rank < count($categories))
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-03-26 17:08:09 +00:00
|
|
|
// 2. Exchanging ranks between the two categories
|
2004-10-24 18:56:09 +00:00
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET rank = '.($current_rank+1).'
|
|
|
|
WHERE id = '.$_GET['down'].'
|
|
|
|
;';
|
2004-10-30 15:42:29 +00:00
|
|
|
pwg_query($query);
|
2004-10-24 18:56:09 +00:00
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET rank = '.$current_rank.'
|
|
|
|
WHERE id = '.$categories[($current_rank+1)]['id'].'
|
|
|
|
;';
|
2004-10-30 15:42:29 +00:00
|
|
|
pwg_query($query);
|
2004-10-24 18:56:09 +00:00
|
|
|
// 3. Updating the cache array
|
|
|
|
$categories[$current_rank]=$categories[($current_rank+1)];
|
|
|
|
$categories[($current_rank+1)] = $current;
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
2004-03-26 17:08:09 +00:00
|
|
|
else
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-03-26 17:08:09 +00:00
|
|
|
// 2. updating the rank of our category to be the first one
|
2004-10-24 18:56:09 +00:00
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET rank = 0
|
|
|
|
WHERE id = '.$_GET['down'].'
|
|
|
|
;';
|
2004-10-30 15:42:29 +00:00
|
|
|
pwg_query($query);
|
2004-10-24 18:56:09 +00:00
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET rank = rank+1
|
|
|
|
WHERE id_uppercat ';
|
|
|
|
if (empty($_GET['parent_id']))
|
|
|
|
{
|
|
|
|
$query.= 'IS NULL';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$query.= '= '.$_GET['parent_id'];
|
|
|
|
}
|
|
|
|
$query.= '
|
|
|
|
;';
|
2004-10-30 15:42:29 +00:00
|
|
|
pwg_query($query);
|
2004-10-24 18:56:09 +00:00
|
|
|
// 3. Updating the cache array
|
|
|
|
array_unshift($categories, $current);
|
|
|
|
array_pop($categories);
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
2004-11-30 20:45:21 +00:00
|
|
|
update_global_rank(@$_GET['parent_id']);
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
2004-03-26 17:08:09 +00:00
|
|
|
reset($categories);
|
2004-10-24 18:56:09 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | template initialization |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
$template->set_filenames(array('categories'=>'admin/cat_list.tpl'));
|
2004-03-26 17:08:09 +00:00
|
|
|
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 21:28:40 +00:00
|
|
|
$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_list';
|
|
|
|
if (isset($_GET['parent_id']))
|
|
|
|
{
|
|
|
|
$form_action.= '&parent_id='.$_GET['parent_id'];
|
|
|
|
}
|
|
|
|
|
2004-12-18 22:05:30 +00:00
|
|
|
if (count($categories) > 0)
|
|
|
|
{
|
|
|
|
$next_rank = max(array_keys($categories)) + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$next_rank = 1;
|
|
|
|
}
|
|
|
|
|
2004-03-26 17:08:09 +00:00
|
|
|
$template->assign_vars(array(
|
|
|
|
'CATEGORIES_NAV'=>$navigation,
|
2004-12-18 22:05:30 +00:00
|
|
|
'NEXT_RANK'=>$next_rank,
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 21:28:40 +00:00
|
|
|
'F_ACTION'=>$form_action,
|
2004-03-26 17:08:09 +00:00
|
|
|
|
|
|
|
'L_ADD_VIRTUAL'=>$lang['cat_add'],
|
|
|
|
'L_SUBMIT'=>$lang['submit'],
|
|
|
|
'L_STORAGE'=>$lang['storage'],
|
|
|
|
'L_NB_IMG'=>$lang['pictures'],
|
2004-11-25 16:44:41 +00:00
|
|
|
'L_MOVE_UP'=>$lang['up'],
|
|
|
|
'L_MOVE_DOWN'=>$lang['down'],
|
2004-03-26 17:08:09 +00:00
|
|
|
'L_EDIT'=>$lang['edit'],
|
|
|
|
'L_INFO_IMG'=>$lang['cat_image_info'],
|
2004-10-24 18:56:09 +00:00
|
|
|
'L_DELETE'=>$lang['delete'],
|
|
|
|
));
|
2004-03-26 17:08:09 +00:00
|
|
|
|
2004-10-24 18:56:09 +00:00
|
|
|
$tpl = array('cat_first','cat_last');
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | errors & infos |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
if (count($errors) != 0)
|
2003-09-07 10:14:33 +00:00
|
|
|
{
|
2004-03-26 17:08:09 +00:00
|
|
|
$template->assign_block_vars('errors',array());
|
2004-10-24 18:56:09 +00:00
|
|
|
foreach ($errors as $error)
|
2004-03-26 17:08:09 +00:00
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
$template->assign_block_vars('errors.error',array('ERROR'=>$error));
|
2003-09-07 10:14:33 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
if (count($infos) != 0)
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
$template->assign_block_vars('infos',array());
|
|
|
|
foreach ($infos as $info)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('infos.info',array('INFO'=>$info));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | Categories display |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-12-12 21:06:39 +00:00
|
|
|
$ranks = array();
|
2004-12-18 22:05:30 +00:00
|
|
|
|
|
|
|
if (count($categories) > 0)
|
2004-12-12 21:06:39 +00:00
|
|
|
{
|
2004-12-18 22:05:30 +00:00
|
|
|
foreach ($categories as $category)
|
|
|
|
{
|
|
|
|
$ranks[$category['id']] = $category['rank'];
|
|
|
|
}
|
2004-12-12 21:06:39 +00:00
|
|
|
|
2004-12-18 22:05:30 +00:00
|
|
|
$query = '
|
2004-12-12 21:06:39 +00:00
|
|
|
SELECT id_uppercat, COUNT(*) AS nb_subcats
|
|
|
|
FROM '. CATEGORIES_TABLE.'
|
|
|
|
WHERE id_uppercat IN ('.implode(',', array_keys($ranks)).')
|
|
|
|
GROUP BY id_uppercat
|
|
|
|
;';
|
2004-12-18 22:05:30 +00:00
|
|
|
$result = pwg_query($query);
|
|
|
|
while ($row = mysql_fetch_array($result))
|
|
|
|
{
|
|
|
|
$categories[$ranks[$row['id_uppercat']]]['nb_subcats']
|
|
|
|
= $row['nb_subcats'];
|
|
|
|
}
|
2004-12-12 21:06:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($categories as $category)
|
2004-10-24 18:56:09 +00:00
|
|
|
{
|
|
|
|
$images_folder = PHPWG_ROOT_PATH.'template/';
|
|
|
|
$images_folder.= $user['template'].'/admin/images';
|
|
|
|
|
2004-03-31 17:26:31 +00:00
|
|
|
if ($category['visible'] == 'false')
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
$image_src = $images_folder.'/icon_folder_lock.gif';
|
|
|
|
$image_alt = $lang['cat_private'];
|
|
|
|
$image_title = $lang['cat_private'];
|
2004-03-26 17:08:09 +00:00
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
else if (empty($category['dir']))
|
2004-03-26 17:08:09 +00:00
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
$image_src = $images_folder.'/icon_folder_link.gif';
|
|
|
|
$image_alt = $lang['cat_virtual'];
|
|
|
|
$image_title = $lang['cat_virtual'];
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-12 21:06:39 +00:00
|
|
|
if ($category['nb_subcats'] > 0)
|
2004-10-24 18:56:09 +00:00
|
|
|
{
|
|
|
|
$image_src = $images_folder.'/icon_subfolder.gif';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$image_src = $images_folder.'/icon_folder.gif';
|
|
|
|
}
|
|
|
|
$image_alt = '';
|
|
|
|
$image_title = '';
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
|
|
|
|
$base_url = PHPWG_ROOT_PATH.'admin.php?page=';
|
|
|
|
$cat_list_url = $base_url.'cat_list';
|
2004-03-26 17:08:09 +00:00
|
|
|
|
2004-10-24 18:56:09 +00:00
|
|
|
$self_url = $cat_list_url;
|
2004-03-26 17:08:09 +00:00
|
|
|
if (isset($_GET['parent_id']))
|
2004-10-24 18:56:09 +00:00
|
|
|
{
|
|
|
|
$self_url.= '&parent_id='.$_GET['parent_id'];
|
|
|
|
}
|
2004-03-26 17:08:09 +00:00
|
|
|
|
2004-10-24 18:56:09 +00:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'category',
|
|
|
|
array(
|
|
|
|
'CATEGORY_IMG_SRC'=>$image_src,
|
|
|
|
'CATEGORY_IMG_ALT'=>$image_alt,
|
|
|
|
'CATEGORY_IMG_TITLE'=>$image_title,
|
|
|
|
'CATEGORY_NAME'=>$category['name'],
|
|
|
|
'CATEGORY_DIR'=>@$category['dir'],
|
|
|
|
'CATEGORY_NB_IMG'=>$category['nb_images'],
|
|
|
|
|
|
|
|
'U_CATEGORY'=>
|
|
|
|
add_session_id($cat_list_url.'&parent_id='.$category['id']),
|
|
|
|
|
|
|
|
'U_MOVE_UP'=>add_session_id($self_url.'&up='.$category['id']),
|
|
|
|
|
|
|
|
'U_MOVE_DOWN'=>add_session_id($self_url.'&down='.$category['id']),
|
|
|
|
|
|
|
|
'U_CAT_EDIT'=>
|
|
|
|
add_session_id($base_url.'cat_modify&cat_id='.$category['id']),
|
|
|
|
|
|
|
|
'U_CAT_DELETE'=>add_session_id($self_url.'&delete='.$category['id']),
|
|
|
|
|
|
|
|
'U_INFO_IMG'
|
2004-11-01 15:01:28 +00:00
|
|
|
=> add_session_id($base_url.'infos_images&cat_id='.$category['id'])
|
2004-10-24 18:56:09 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
if (!empty($category['dir']))
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-03-26 17:08:09 +00:00
|
|
|
$template->assign_block_vars('category.storage' ,array());
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-24 18:56:09 +00:00
|
|
|
$template->assign_block_vars('category.virtual' ,array());
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
|
|
|
|
if ($category['nb_images'] > 0)
|
2003-05-09 12:42:42 +00:00
|
|
|
{
|
2004-03-26 17:08:09 +00:00
|
|
|
$template->assign_block_vars('category.image_info' ,array());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('category.no_image_info' ,array());
|
2003-05-09 12:42:42 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-24 18:56:09 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | sending html code |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-03-26 17:08:09 +00:00
|
|
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
|
2004-02-11 23:20:38 +00:00
|
|
|
?>
|