- in admin menu, status option for categories is not "permissions" but

"private or public" choice = different language item

- get_cat_display_name changed : use $conf['level_separator'] to unify
  presentation

- default values for category properties commentable, uploadable, status and
  visible (set in include/config.inc.php) used for category creation
  (admin/update, admin/remote_site, admin/cat_list)

- use mass_inserts in admin/update for inserting new categories

- only one query for counting the number of sub categories in admin/cat_list


git-svn-id: http://piwigo.org/svn/trunk@642 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
plegall 2004-12-12 21:06:39 +00:00
parent 9037726f5a
commit 391fac78a8
24 changed files with 303 additions and 182 deletions

View file

@ -30,7 +30,6 @@ define('PHPWG_ROOT_PATH','./');
define('IN_ADMIN', true); define('IN_ADMIN', true);
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
//--------------------------------------- validating page and creation of title //--------------------------------------- validating page and creation of title
$page_valide = false; $page_valide = false;
$title = ''; $title = '';
@ -85,7 +84,7 @@ switch ( $_GET['page'] )
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
{ {
$result = get_cat_info( $page['cat'] ); $result = get_cat_info( $page['cat'] );
$name = get_cat_display_name( $result['name'],' > ', '' ); $name = get_cat_display_name($result['name'], '');
$title.= ' "'.$name.'"'; $title.= ' "'.$name.'"';
} }
} }
@ -202,7 +201,7 @@ $template->assign_vars(array(
'L_CAT_UPLOAD'=>$lang['upload'], 'L_CAT_UPLOAD'=>$lang['upload'],
'L_CAT_COMMENTS'=>$lang['comments'], 'L_CAT_COMMENTS'=>$lang['comments'],
'L_CAT_VISIBLE'=>$lang['lock'], 'L_CAT_VISIBLE'=>$lang['lock'],
'L_CAT_STATUS'=>$lang['permissions'], 'L_CAT_STATUS'=>$lang['admin_menu_cat_status'],
'U_CONFIG_GENERAL'=>add_session_id($conf_link.'general' ), 'U_CONFIG_GENERAL'=>add_session_id($conf_link.'general' ),
'U_CONFIG_COMMENTS'=>add_session_id($conf_link.'comments' ), 'U_CONFIG_COMMENTS'=>add_session_id($conf_link.'comments' ),

View file

@ -60,17 +60,66 @@ else if (isset($_POST['submit']))
if (!count($errors)) if (!count($errors))
{ {
$parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL'; $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL';
// As we don't create a virtual category every day, let's do (far) too
// much queries if ($parent_id != 'NULL')
{
$query = '
SELECT id,uppercats,global_rank,visible,status
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$parent_id.'
;';
$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']);
}
$insert = array();
$insert{'name'} = $_POST['virtual_name'];
$insert{'rank'} = $_POST['rank'];
$insert{'commentable'} = $conf['newcat_default_commentable'];
$insert{'uploadable'} = $conf['newcat_default_uploadable'];
if (isset($parent))
{
$insert{'id_uppercat'} = $parent{'id'};
// 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'];
}
}
else
{
$insert{'visible'} = $conf['newcat_default_visible'];
$insert{'status'} = $conf['newcat_default_status'];
}
$inserts = array($insert);
// we have then to add the virtual category // we have then to add the virtual category
$query = ' $dbfields = array('site_id','name','id_uppercat','rank','commentable',
INSERT INTO '.CATEGORIES_TABLE.' 'uploadable','visible','status');
(name,id_uppercat,rank,site_id) mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
VALUES
(\''.$_POST['virtual_name'].'\','.$parent_id.','.$_POST['rank'].',NULL)
;';
pwg_query($query);
// And last we update the uppercats // And last we update the uppercats
$query = ' $query = '
@ -79,38 +128,19 @@ SELECT MAX(id)
;'; ;';
$my_id = array_pop(mysql_fetch_array(pwg_query($query))); $my_id = array_pop(mysql_fetch_array(pwg_query($query)));
if ($parent_id != 'NULL')
{
$query = '
SELECT uppercats, global_rank
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$parent_id.'
;';
$result = pwg_query($query);
$row = mysql_fetch_array($result);
$parent_uppercats = $row['uppercats'];
$parent_global_rank = $row['global_rank'];
}
$query = ' $query = '
UPDATE '.CATEGORIES_TABLE.' UPDATE '.CATEGORIES_TABLE;
'; if (isset($parent))
if (!empty($parent_uppercats))
{ {
$query.= " SET uppercats = CONCAT('".$parent_uppercats."',',',id)"; $query.= "
SET uppercats = CONCAT('".$parent['uppercats']."',',',id)
, global_rank = CONCAT('".$parent['global_rank']."','.',rank)";
} }
else else
{ {
$query.= ' SET uppercats = id'; $query.= '
} SET uppercats = id
if (!empty($parent_global_rank)) , global_rank = id';
{
$query.= " , global_rank = CONCAT('".$parent_global_rank."','.',rank)";
}
else
{
$query.= ' , uppercats = id';
} }
$query.= ' $query.= '
WHERE id = '.$my_id.' WHERE id = '.$my_id.'
@ -142,23 +172,22 @@ $result = pwg_query($query);
while ($row = mysql_fetch_assoc($result)) while ($row = mysql_fetch_assoc($result))
{ {
$categories[$row['rank']] = $row; $categories[$row['rank']] = $row;
$categories[$row['rank']]['nb_subcats'] = 0;
} }
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | Navigation path | // | Navigation path |
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
if (isset($_GET['parent_id'])) if (isset($_GET['parent_id']))
{ {
$separator = ' <span style="font-size:15px">&rarr;</span> ';
$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list'; $base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list';
$navigation = '<a class="" href="'.add_session_id($base_url).'">'; $navigation = '<a class="" href="'.add_session_id($base_url).'">';
$navigation.= $lang['home']; $navigation.= $lang['home'];
$navigation.= '</a>'; $navigation.= '</a>';
$navigation.= $separator; $navigation.= $conf['level_separator'];
$current_category = get_cat_info($_GET['parent_id']); $current_category = get_cat_info($_GET['parent_id']);
$navigation.= get_cat_display_name($current_category['name'], $navigation.= get_cat_display_name($current_category['name'],
$separator,
$base_url.'&amp;parent_id=', $base_url.'&amp;parent_id=',
false); false);
} }
@ -337,7 +366,25 @@ if (count($infos) != 0)
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | Categories display | // | Categories display |
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
while (list($id,$category) = each($categories)) $ranks = array();
foreach ($categories as $category)
{
$ranks[$category['id']] = $category['rank'];
}
$query = '
SELECT id_uppercat, COUNT(*) AS nb_subcats
FROM '. CATEGORIES_TABLE.'
WHERE id_uppercat IN ('.implode(',', array_keys($ranks)).')
GROUP BY id_uppercat
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
{
$categories[$ranks[$row['id_uppercat']]]['nb_subcats'] = $row['nb_subcats'];
}
foreach ($categories as $category)
{ {
$images_folder = PHPWG_ROOT_PATH.'template/'; $images_folder = PHPWG_ROOT_PATH.'template/';
$images_folder.= $user['template'].'/admin/images'; $images_folder.= $user['template'].'/admin/images';
@ -356,17 +403,7 @@ while (list($id,$category) = each($categories))
} }
else else
{ {
// (Gweltas) May be should we have to introduce a computed field in the if ($category['nb_subcats'] > 0)
// table to avoid this query -> (z0rglub) no because the number of
// sub-categories depends on permissions
$query = '
SELECT COUNT(id) AS nb_sub_cats
FROM '. CATEGORIES_TABLE.'
WHERE id_uppercat = '.$category['id'].'
;';
$row = mysql_fetch_array(pwg_query($query));
if ($row['nb_sub_cats'] > 0)
{ {
$image_src = $images_folder.'/icon_subfolder.gif'; $image_src = $images_folder.'/icon_subfolder.gif';
} }

View file

@ -103,11 +103,10 @@ foreach (array('comment','dir','site_id') as $nullable)
// Navigation path // Navigation path
$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id='; $url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id=';
$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">'; $navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
$navigation.= $lang['home'].'</a> <span style="font-size:15px">&rarr;</span>'; $navigation.= $lang['home'].'</a>'.$conf['level_separator'];
$navigation.= get_cat_display_name_cache( $navigation.= get_cat_display_name_cache(
$category['uppercats'], $category['uppercats'],
' <span style="font-size:15px">&rarr;</span>',
$url); $url);
$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id']; $form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];

View file

@ -104,8 +104,7 @@ while ( $row = mysql_fetch_array( $result ) )
} }
// category name // category name
$cat_infos = get_cat_info( $row['id'] ); $cat_infos = get_cat_info( $row['id'] );
$name = get_cat_display_name( $cat_infos['name'],' &gt; ', $name = get_cat_display_name($cat_infos['name']);
'font-weight:bold;' );
$vtp->setVar( $sub, 'category.name', $name ); $vtp->setVar( $sub, 'category.name', $name );
// any subcat forbidden for this group ? // any subcat forbidden for this group ?
if ( $is_group_allowed == 2 ) if ( $is_group_allowed == 2 )

View file

@ -248,9 +248,7 @@ if (isset($page['cat']))
// Navigation path // Navigation path
$current_category = get_cat_info($_GET['cat_id']); $current_category = get_cat_info($_GET['cat_id']);
$url = PHPWG_ROOT_PATH.'admin.php?page=infos_images&amp;cat_id='; $url = PHPWG_ROOT_PATH.'admin.php?page=infos_images&amp;cat_id=';
$category_path = get_cat_display_name($current_category['name'], $category_path = get_cat_display_name($current_category['name'], $url);
'-&gt;',
$url);
$form_action = PHPWG_ROOT_PATH.'admin.php'; $form_action = PHPWG_ROOT_PATH.'admin.php';
$form_action.= '?page=infos_images&amp;cat_id='.$_GET['cat_id']; $form_action.= '?page=infos_images&amp;cat_id='.$_GET['cat_id'];

View file

@ -163,9 +163,9 @@ $url_img .= '&amp;cat='.$row['storage_category_id'];
$date = isset($_POST['date_creation']) && empty($errors) $date = isset($_POST['date_creation']) && empty($errors)
?$_POST['date_creation']:date_convert_back(@$row['date_creation']); ?$_POST['date_creation']:date_convert_back(@$row['date_creation']);
$url = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id=';
$storage_category = get_cat_display_name_cache($row['uppercats'], $storage_category = get_cat_display_name_cache($row['uppercats'],
' &rarr; ', $url,
'',
false); false);
//----------------------------------------------------- template initialization //----------------------------------------------------- template initialization
$template->set_filenames(array('picture_modify'=>'admin/picture_modify.tpl')); $template->set_filenames(array('picture_modify'=>'admin/picture_modify.tpl'));

View file

@ -176,7 +176,7 @@ function update_remote_site($listing_file, $site_id)
*/ */
function insert_remote_category($xml_content, $site_id, $id_uppercat, $level) function insert_remote_category($xml_content, $site_id, $id_uppercat, $level)
{ {
global $counts, $removes; global $counts, $removes, $conf;
$uppercats = ''; $uppercats = '';
// 0. retrieving informations on the category to display // 0. retrieving informations on the category to display
@ -184,14 +184,17 @@ function insert_remote_category($xml_content, $site_id, $id_uppercat, $level)
if (is_numeric($id_uppercat)) if (is_numeric($id_uppercat))
{ {
$query = ' $query = '
SELECT name,uppercats,dir SELECT id,name,uppercats,dir,status,visible
FROM '.CATEGORIES_TABLE.' FROM '.CATEGORIES_TABLE.'
WHERE id = '.$id_uppercat.' WHERE id = '.$id_uppercat.'
;'; ;';
$row = mysql_fetch_array(pwg_query($query)); $row = mysql_fetch_array(pwg_query($query));
$parent = array('id' => $row['id'],
$uppercats = $row['uppercats']; 'name' => $row['name'],
$name = $row['name']; 'dir' => $row['dir'],
'uppercats' => $row['uppercats'],
'visible' => $row['visible'],
'status' => $row['status']);
insert_remote_element($xml_content, $id_uppercat); insert_remote_element($xml_content, $id_uppercat);
} }
@ -224,6 +227,39 @@ SELECT name,uppercats,dir
// array of new categories to insert // array of new categories to insert
$inserts = array(); $inserts = array();
// calculate default value at category creation
$create_values = array();
if (isset($parent))
{
// 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'])
{
$create_values{'visible'} = 'false';
}
else
{
$create_values{'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'])
{
$create_values{'status'} = 'private';
}
else
{
$create_values{'status'} = $conf['newcat_default_status'];
}
}
else
{
$create_values{'visible'} = $conf['newcat_default_visible'];
$create_values{'status'} = $conf['newcat_default_status'];
}
foreach ($xml_dirs as $xml_dir) foreach ($xml_dirs as $xml_dir)
{ {
// 5. Is the category already existing ? we create a subcat if not // 5. Is the category already existing ? we create a subcat if not
@ -239,9 +275,13 @@ SELECT name,uppercats,dir
$insert{'name'} = $name; $insert{'name'} = $name;
$insert{'site_id'} = $site_id; $insert{'site_id'} = $site_id;
$insert{'uppercats'} = 'undef'; $insert{'uppercats'} = 'undef';
if (is_numeric($id_uppercat)) $insert{'commentable'} = $conf['newcat_default_commentable'];
$insert{'uploadable'} = 'false';
$insert{'status'} = $create_values{'status'};
$insert{'visible'} = $create_values{'visible'};
if (isset($parent))
{ {
$insert{'id_uppercat'} = $id_uppercat; $insert{'id_uppercat'} = $parent['id'];
} }
array_push($inserts, $insert); array_push($inserts, $insert);
} }
@ -251,31 +291,25 @@ SELECT name,uppercats,dir
if (count($inserts) > 0) if (count($inserts) > 0)
{ {
// inserts all found categories // inserts all found categories
$dbfields = array('dir','name','site_id','uppercats','id_uppercat'); $dbfields = array('dir','name','site_id','uppercats','id_uppercat',
'commentable','uploadable','status','visible');
mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts); mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
$counts{'new_categories'}+= count($inserts); $counts{'new_categories'}+= count($inserts);
// updating uppercats field // updating uppercats field
$query = ' $query = '
UPDATE '.CATEGORIES_TABLE.' UPDATE '.CATEGORIES_TABLE;
SET uppercats = '; if (isset($parent))
if ($uppercats != '')
{ {
$query.= "CONCAT('".$uppercats."',',',id)"; $query.= "
SET uppercats = CONCAT('".$parent['uppercats']."',',',id)
WHERE id_uppercat = ".$id_uppercat;
} }
else else
{ {
$query.= 'id'; $query.= '
} SET uppercats = id
$query.= ' WHERE id_uppercat IS NULL';
WHERE id_uppercat ';
if (!is_numeric($id_uppercat))
{
$query.= 'IS NULL';
}
else
{
$query.= '= '.$id_uppercat;
} }
$query.= ' $query.= '
;'; ;';

View file

@ -47,24 +47,30 @@ function insert_local_category($id_uppercat)
$cat_directory = PHPWG_ROOT_PATH.'galleries'; $cat_directory = PHPWG_ROOT_PATH.'galleries';
if (is_numeric($id_uppercat)) if (is_numeric($id_uppercat))
{ {
$query = 'SELECT name,uppercats,dir FROM '.CATEGORIES_TABLE; $query = '
$query.= ' WHERE id = '.$id_uppercat; SELECT id,name,uppercats,dir,visible,status
$query.= ';'; FROM '.CATEGORIES_TABLE.'
$row = mysql_fetch_array( pwg_query( $query)); WHERE id = '.$id_uppercat.'
$uppercats = $row['uppercats']; ;';
$name = $row['name']; $row = mysql_fetch_array(pwg_query($query));
$dir = $row['dir']; $parent = array('id' => $row['id'],
'name' => $row['name'],
'dir' => $row['dir'],
'uppercats' => $row['uppercats'],
'visible' => $row['visible'],
'status' => $row['status']);
$upper_array = explode( ',', $uppercats); $upper_array = explode( ',', $parent['uppercats']);
$local_dir = ''; $local_dir = '';
$database_dirs = array(); $database_dirs = array();
$query = ' $query = '
SELECT id,dir FROM '.CATEGORIES_TABLE.' SELECT id,dir
WHERE id IN ('.$uppercats.') FROM '.CATEGORIES_TABLE.'
WHERE id IN ('.$parent['uppercats'].')
;'; ;';
$result = pwg_query( $query); $result = pwg_query($query);
while ($row = mysql_fetch_array($result)) while ($row = mysql_fetch_array($result))
{ {
$database_dirs[$row['id']] = $row['dir']; $database_dirs[$row['id']] = $row['dir'];
@ -78,8 +84,8 @@ SELECT id,dir FROM '.CATEGORIES_TABLE.'
// 1. display the category name to update // 1. display the category name to update
$output = '<ul class="menu">'; $output = '<ul class="menu">';
$output.= '<li><strong>'.$name.'</strong>'; $output.= '<li><strong>'.$parent['name'].'</strong>';
$output.= ' [ '.$dir.' ]'; $output.= ' [ '.$parent['dir'].' ]';
$output.= '</li>'; $output.= '</li>';
// 2. we search pictures of the category only if the update is for all // 2. we search pictures of the category only if the update is for all
@ -94,7 +100,8 @@ SELECT id,dir FROM '.CATEGORIES_TABLE.'
$sub_category_dirs = array(); $sub_category_dirs = array();
$query = ' $query = '
SELECT id,dir FROM '.CATEGORIES_TABLE.' SELECT id,dir
FROM '.CATEGORIES_TABLE.'
WHERE site_id = 1 WHERE site_id = 1
'; ';
if (!is_numeric($id_uppercat)) if (!is_numeric($id_uppercat))
@ -132,6 +139,39 @@ SELECT id,dir FROM '.CATEGORIES_TABLE.'
// array of new categories to insert // array of new categories to insert
$inserts = array(); $inserts = array();
// calculate default value at category creation
$create_values = array();
if (isset($parent))
{
// 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'])
{
$create_values{'visible'} = 'false';
}
else
{
$create_values{'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'])
{
$create_values{'status'} = 'private';
}
else
{
$create_values{'status'} = $conf['newcat_default_status'];
}
}
else
{
$create_values{'visible'} = $conf['newcat_default_visible'];
$create_values{'status'} = $conf['newcat_default_status'];
}
foreach ($fs_subdirs as $fs_subdir) foreach ($fs_subdirs as $fs_subdir)
{ {
// 5. Is the category already existing ? we create a subcat if not // 5. Is the category already existing ? we create a subcat if not
@ -139,22 +179,27 @@ SELECT id,dir FROM '.CATEGORIES_TABLE.'
$category_id = array_search($fs_subdir, $sub_category_dirs); $category_id = array_search($fs_subdir, $sub_category_dirs);
if (!is_numeric($category_id)) if (!is_numeric($category_id))
{ {
$insert = array();
if (preg_match('/^[a-zA-Z0-9-_.]+$/', $fs_subdir)) if (preg_match('/^[a-zA-Z0-9-_.]+$/', $fs_subdir))
{ {
$name = str_replace('_', ' ', $fs_subdir); $name = str_replace('_', ' ', $fs_subdir);
$value = "('".$fs_subdir."','".$name."',1"; $insert{'dir'} = $fs_subdir;
if (!is_numeric($id_uppercat)) $insert{'name'} = $name;
$insert{'site_id'} = 1;
$insert{'uppercats'} = 'undef';
$insert{'commentable'} = $conf['newcat_default_commentable'];
$insert{'uploadable'} = $conf['newcat_default_uploadable'];
$insert{'status'} = $create_values{'status'};
$insert{'visible'} = $create_values{'visible'};
if (isset($parent))
{ {
$value.= ',NULL'; $insert{'id_uppercat'} = $parent['id'];
} }
else
{ array_push($inserts, $insert);
$value.= ','.$id_uppercat;
}
$value.= ",'undef'";
$value.= ')';
array_push($inserts, $value);
} }
else else
{ {
@ -167,37 +212,27 @@ SELECT id,dir FROM '.CATEGORIES_TABLE.'
// we have to create the category // we have to create the category
if (count($inserts) > 0) if (count($inserts) > 0)
{ {
$query = ' $dbfields = array(
INSERT INTO '.CATEGORIES_TABLE.' 'dir','name','site_id','id_uppercat','uppercats','commentable',
(dir,name,site_id,id_uppercat,uppercats) VALUES 'uploadable','visible','status'
'; );
$query.= implode(',', $inserts); mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
$query.= '
;';
pwg_query($query);
$counts['new_categories']+= count($inserts); $counts['new_categories']+= count($inserts);
// updating uppercats field // updating uppercats field
$query = ' $query = '
UPDATE '.CATEGORIES_TABLE.' UPDATE '.CATEGORIES_TABLE;
SET uppercats = '; if (isset($parent))
if ($uppercats != '')
{ {
$query.= "CONCAT('".$uppercats."',',',id)"; $query.= "
SET uppercats = CONCAT('".$parent['uppercats']."',',',id)
WHERE id_uppercat = ".$parent['id'];
} }
else else
{ {
$query.= 'id'; $query.= '
} SET uppercats = id
$query.= ' WHERE id_uppercat IS NULL';
WHERE id_uppercat ';
if (!is_numeric($id_uppercat))
{
$query.= 'IS NULL';
}
else
{
$query.= '= '.$id_uppercat;
} }
$query.= ' $query.= '
;'; ;';

View file

@ -220,8 +220,7 @@ while ( $row = mysql_fetch_array( $result ) )
} }
// category name // category name
$cat_infos = get_cat_info( $row['id'] ); $cat_infos = get_cat_info( $row['id'] );
$name = get_cat_display_name( $cat_infos['name'],' &gt; ', $name = get_cat_display_name($cat_infos['name']);
'font-weight:bold;' );
$vtp->setVar( $sub, 'category.name', $name ); $vtp->setVar( $sub, 'category.name', $name );
// usergroups // usergroups
if ( count( $usergroups ) > 0 ) if ( count( $usergroups ) > 0 )

View file

@ -102,13 +102,15 @@ else
$is_user_allowed = is_user_allowed( $row['id'], $restrictions ); $is_user_allowed = is_user_allowed( $row['id'], $restrictions );
$url = PHPWG_ROOT_PATH.'admin.php?page=cat_perm&amp;cat_id='.$row['id']; $url = PHPWG_ROOT_PATH.'admin.php?page=cat_perm&amp;cat_id='.$row['id'];
$cat_infos = get_cat_info( $row['id'] ); $cat_infos = get_cat_info( $row['id'] );
$template->assign_block_vars('permission.category',array( $template->assign_block_vars(
'CAT_NAME'=> get_cat_display_name($cat_infos['name'],' &gt; ', 'font-weight:bold;' ), 'permission.category',
'CAT_ID'=>$row['id'], array(
'AUTH_YES'=>!$is_user_allowed?'checked="checked"':'', 'CAT_NAME'=> get_cat_display_name($cat_infos['name']),
'AUTH_NO' =>$is_user_allowed?'checked="checked"':'', 'CAT_ID'=>$row['id'],
'CAT_URL'=>add_session_id($url) 'AUTH_YES'=>!$is_user_allowed?'checked="checked"':'',
)); 'AUTH_NO' =>$is_user_allowed?'checked="checked"':'',
'CAT_URL'=>add_session_id($url)
));
// any subcat forbidden for this user ? // any subcat forbidden for this user ?
if ( $is_user_allowed == 2 ) if ( $is_user_allowed == 2 )

View file

@ -113,7 +113,7 @@ while ( $row = mysql_fetch_array( $result ) )
$cat_names[$row['storage_category_id']]['dir'] = $cat_names[$row['storage_category_id']]['dir'] =
PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] ); PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] );
$cat_names[$row['storage_category_id']]['display_name'] = $cat_names[$row['storage_category_id']]['display_name'] =
get_cat_display_name( $cat['name'], ' &gt; ', 'font-weight:bold;' ); get_cat_display_name($cat['name']);
} }
$preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file']; $preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file'];
$class='row1'; $class='row1';

View file

@ -152,7 +152,7 @@ SELECT name,file,storage_category_id as cat_id,tn_ext,path
{ {
$cat_result = get_cat_info($subrow['cat_id']); $cat_result = get_cat_info($subrow['cat_id']);
$array_cat_names[$subrow['cat_id']] = $array_cat_names[$subrow['cat_id']] =
get_cat_display_name($cat_result['name'], ' &gt; ', ''); get_cat_display_name($cat_result['name'], '');
} }
// name of the picture // name of the picture

View file

@ -363,6 +363,8 @@ SELECT file,tn_ext,'.$conf['calendar_datefield'].',path
} }
elseif (isset($page['calendar_day'])) elseif (isset($page['calendar_day']))
{ {
$old_level_separator = $conf['level_separator'];
$conf['level_separator'] = '<br />';
// for each category of this day, display a random picture // for each category of this day, display a random picture
foreach ($calendar_categories as $calendar_category => $nb_pics) foreach ($calendar_categories as $calendar_category => $nb_pics)
{ {
@ -373,7 +375,8 @@ elseif (isset($page['calendar_day']))
else else
{ {
$cat_infos = get_cat_info( $calendar_category ); $cat_infos = get_cat_info( $calendar_category );
$name = get_cat_display_name($cat_infos['name'],'<br />','',false);
$name = get_cat_display_name($cat_infos['name'],'',false);
$name = '['.$name.']'; $name = '['.$name.']';
} }
$name.= ' ('.$nb_pics.')'; $name.= ' ('.$nb_pics.')';
@ -426,5 +429,6 @@ SELECT file,tn_ext,'.$conf['calendar_datefield'].',path
$row_number = 0; $row_number = 0;
} }
} }
$conf['level_separator'] = $old_level_separator;
} }
?> ?>

View file

@ -59,6 +59,8 @@ if (mysql_num_rows($result) > 0)
$row_number = 0; $row_number = 0;
} }
$old_level_separator = $conf['level_separator'];
$conf['level_separator'] = '<br />';
// for each category, we have to search a recent picture to display and // for each category, we have to search a recent picture to display and
// the name to display // the name to display
while ( $row = mysql_fetch_array( $result ) ) while ( $row = mysql_fetch_array( $result ) )
@ -90,4 +92,5 @@ while ( $row = mysql_fetch_array( $result ) )
$row_number = 0; $row_number = 0;
} }
} }
$conf['level_separator'] = $old_level_separator;
?> ?>

View file

@ -76,7 +76,7 @@ $conf['picture_ext'] = array('jpg','JPG','png','PNG','gif','GIF');
// top_number : number of element to display for "best rated" and "most // top_number : number of element to display for "best rated" and "most
// visited" categories // visited" categories
$conf['top_number'] = 10; $conf['top_number'] = 15;
// anti-flood_time : number of seconds between 2 comments : 0 to disable // anti-flood_time : number of seconds between 2 comments : 0 to disable
$conf['anti-flood_time'] = 60; $conf['anti-flood_time'] = 60;
@ -168,18 +168,25 @@ $conf['show_queries'] = false;
// show_gt : display generation time at the bottom of each page // show_gt : display generation time at the bottom of each page
$conf['show_gt'] = true; $conf['show_gt'] = true;
// Default options for new categories. // newcat_default_commentable : at creation, must a category be commentable
// // or not ?
// Some options for categories (commentable, uploadable, status, visible) $conf['newcat_default_commentable'] = 'true';
// must be set directly in the database by changing the corresponding
// default values of the column. Examples : // newcat_default_uploadable : at creation, must a category be uploadable or
// // not ?
// ALTER TABLE phpwebgallery_categories ALTER visible SET DEFAULT 'true'; $conf['newcat_default_uploadable'] = 'true';
// ALTER TABLE phpwebgallery_categories ALTER status SET DEFAULT 'private';
// ALTER TABLE phpwebgallery_categories ALTER uploadable SET DEFAULT 'true'; // newcat_default_visible : at creation, must a category be visible or not ?
// ALTER TABLE phpwebgallery_categories ALTER commentable SET DEFAULT 'false'; // Warning : if the parent category is invisible, the category is
// // automatically create invisible. (invisible = locked)
// MySQL default values are used when inserting a row and that no value is $conf['newcat_default_visible'] = 'true';
// given for the column. In PhpWebGallery, the above columns are not valued
// during categories insertion, so default values are important. // newcat_default_status : at creation, must a category be public or private
// ? Warning : if the parent category is private, the category is
// automatically create private.
$conf['newcat_default_status'] = 'public';
// level_separator : character string used for separating a category level
// to the sub level
$conf['level_separator'] = ' / ';
?> ?>

View file

@ -348,7 +348,6 @@ function initialize_category( $calling_page = 'category' )
$page['uppercats'] = $result['uppercats']; $page['uppercats'] = $result['uppercats'];
$page['title'] = $page['title'] =
get_cat_display_name($page['cat_name'], get_cat_display_name($page['cat_name'],
' &gt; ',
'category.php?cat=', 'category.php?cat=',
false); false);
$page['where'] = ' WHERE category_id = '.$page['cat']; $page['where'] = ' WHERE category_id = '.$page['cat'];
@ -758,7 +757,6 @@ function display_select_categories($categories,
if ($fullname) if ($fullname)
{ {
$option = get_cat_display_name_cache($category['uppercats'], $option = get_cat_display_name_cache($category['uppercats'],
' &rarr; ',
'', '',
false); false);
} }

View file

@ -159,10 +159,11 @@ function style_select($default_style, $select_name = "style")
* @return string * @return string
*/ */
function get_cat_display_name($cat_informations, function get_cat_display_name($cat_informations,
$separator,
$url = 'category.php?cat=', $url = 'category.php?cat=',
$replace_space = true) $replace_space = true)
{ {
global $conf;
$output = ''; $output = '';
$is_first = true; $is_first = true;
foreach ($cat_informations as $id => $name) foreach ($cat_informations as $id => $name)
@ -173,7 +174,7 @@ function get_cat_display_name($cat_informations,
} }
else else
{ {
$output.= $separator; $output.= $conf['level_separator'];
} }
if ($url == '') if ($url == '')
@ -205,17 +206,15 @@ function get_cat_display_name($cat_informations,
* the categories name without links. * the categories name without links.
* *
* @param string uppercats * @param string uppercats
* @param string separator
* @param string url * @param string url
* @param boolean replace_space * @param boolean replace_space
* @return string * @return string
*/ */
function get_cat_display_name_cache($uppercats, function get_cat_display_name_cache($uppercats,
$separator,
$url = 'category.php?cat=', $url = 'category.php?cat=',
$replace_space = true) $replace_space = true)
{ {
global $cat_names; global $cat_names, $conf;
if (!isset($cat_names)) if (!isset($cat_names))
{ {
@ -242,7 +241,7 @@ SELECT id,name
} }
else else
{ {
$output.= $separator; $output.= $conf['level_separator'];
} }
if ($url == '') if ($url == '')

View file

@ -51,6 +51,7 @@ function getContent( $element )
// attribute $attribute for the tag $element. // attribute $attribute for the tag $element.
function getAttribute( $element, $attribute ) function getAttribute( $element, $attribute )
{ {
// echo htmlentities($element).'<br /><br />';
$regex = '/^<\w+[^>]*'.$attribute.'\s*=\s*"('.VAL_REG.')"/i'; $regex = '/^<\w+[^>]*'.$attribute.'\s*=\s*"('.VAL_REG.')"/i';
if ( preg_match( $regex, $element, $out ) ) return $out[1]; if ( preg_match( $regex, $element, $out ) ) return $out[1];
else return ''; else return '';

View file

@ -351,4 +351,5 @@ $lang['cat_dissociated'] = 'dissociated from';
$lang['storage_category'] = 'storage category'; $lang['storage_category'] = 'storage category';
$lang['represents'] = 'represents'; $lang['represents'] = 'represents';
$lang['doesnt_represent'] = 'doesn\'t represent'; $lang['doesnt_represent'] = 'doesn\'t represent';
$lang['admin_menu_cat_status'] = 'Public / Private';
?> ?>

View file

@ -348,7 +348,12 @@ if ( isset( $_POST['content'] ) && !empty($_POST['content']) )
// notification to the administrators // notification to the administrators
if ( $conf['mail_notification'] ) if ( $conf['mail_notification'] )
{ {
$cat_name = get_cat_display_name( $page['cat_name'], ' > ', '' ); // locally, we change the $conf['level_separator']
$conf_separator = $conf['level_separator'];
$conf['level_separator'] = ' > ';
$cat_name = get_cat_display_name($page['cat_name'], '');
$conf['level_separator'] = $conf_separator;
$cat_name = strip_tags( $cat_name ); $cat_name = strip_tags( $cat_name );
notify( 'comment', $cat_name.' > '.$picture['current']['name']); notify( 'comment', $cat_name.' > '.$picture['current']['name']);
} }
@ -389,7 +394,7 @@ $title_img = $picture['current']['name'];
$title_nb = ''; $title_nb = '';
if (is_numeric( $page['cat'] )) if (is_numeric( $page['cat'] ))
{ {
$title_img = replace_space(get_cat_display_name($page['cat_name'],' &gt; ')); $title_img = replace_space(get_cat_display_name($page['cat_name']));
$n = $page['num'] + 1; $n = $page['num'] + 1;
$title_nb = $n.'/'.$page['cat_nb_images']; $title_nb = $n.'/'.$page['cat_nb_images'];
} }
@ -443,6 +448,8 @@ $template->assign_vars(array(
'WIDTH_IMG' => $picture_size[0], 'WIDTH_IMG' => $picture_size[0],
'HEIGHT_IMG' => $picture_size[1], 'HEIGHT_IMG' => $picture_size[1],
'LEVEL_SEPARATOR' => $conf['level_separator'],
'L_HOME' => $lang['home'], 'L_HOME' => $lang['home'],
'L_SLIDESHOW' => $lang['slideshow'], 'L_SLIDESHOW' => $lang['slideshow'],
'L_STOP_SLIDESHOW' => $lang['slideshow_stop'], 'L_STOP_SLIDESHOW' => $lang['slideshow_stop'],
@ -768,13 +775,12 @@ foreach ($cat_array as $category)
if (count($cat_array) > 3) if (count($cat_array) > 3)
{ {
$cat_output .= get_cat_display_name_cache($category['uppercats'], $cat_output .= get_cat_display_name_cache($category['uppercats']);
' &rarr; ');
} }
else else
{ {
$cat_info = get_cat_info($category['category_id']); $cat_info = get_cat_info($category['category_id']);
$cat_output .= get_cat_display_name($cat_info['name'], ' &rarr; '); $cat_output .= get_cat_display_name($cat_info['name']);
} }
// the picture is commentable if it belongs at least to one category which // the picture is commentable if it belongs at least to one category which
// is commentable // is commentable

View file

@ -2,7 +2,7 @@
<div class="information">{information.INFORMATION}</div> <div class="information">{information.INFORMATION}</div>
<!-- END information --> <!-- END information -->
<div class="titrePage"> <div class="titrePage">
<div id="gauche"><a href="{U_HOME}">{L_HOME}</a> &gt; {CATEGORY}</div> <div id="gauche"><a href="{U_HOME}">{L_HOME}</a>{LEVEL_SEPARATOR}{CATEGORY}</div>
<div id="centre" class="nameImage">{TITLE}</div> <div id="centre" class="nameImage">{TITLE}</div>
<div id="droite">{PHOTO}</div> <div id="droite">{PHOTO}</div>
</div> </div>

View file

@ -132,7 +132,7 @@ function clean_iptc_value($value)
// remove binary nulls // remove binary nulls
$value = str_replace(chr(0x00), ' ', $value); $value = str_replace(chr(0x00), ' ', $value);
return $value; return htmlentities($value);
} }
function get_sync_iptc_data($file) function get_sync_iptc_data($file)

View file

@ -274,7 +274,7 @@ if ( isset( $page['waiting_id'] ) )
else else
{ {
$advise_title = $lang['upload_advise']; $advise_title = $lang['upload_advise'];
$advise_title.= get_cat_display_name( $page['cat_name'], ' - ' ); $advise_title.= get_cat_display_name($page['cat_name']);
} }
$username = !empty($_POST['username'])?$_POST['username']:$user['username']; $username = !empty($_POST['username'])?$_POST['username']:$user['username'];