From 88e4e1e60adf660651f9276ab2b19bffcc72d9d3 Mon Sep 17 00:00:00 2001 From: plegall Date: Sat, 13 Nov 2004 13:43:53 +0000 Subject: - admin/cat_options page added : manage options for the whole categories tree (uploadable, commentable). status and visible will be soon added - admin.php : $conf_link var to avoid lines longer than 79 characters - config.upload_available configuration parameter disappear : it's simpler to manage with cat_options - config.show_comments idem : new column categories.commentable, each categories can be commentable or not - categories.site_id becomes a nullable column : a virtual category does belong to no site - function display_select_categories has a new argument : $CSS_classes array to optionnaly assign a CSS class to each category in the select field - added informations in include/config.inc.php for setting default value of : - categories.visible - categories.status - categories.uploadable - categories.commentable - 2 new indexes images_i3(average_rate) and images_i4(hit) : optimizes best rated and most visited categories git-svn-id: http://piwigo.org/svn/trunk@602 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/category_default.inc.php | 4 +++- include/config.inc.php | 15 +++++++++++++++ include/functions_category.inc.php | 19 ++++++++++++++++--- 3 files changed, 34 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/category_default.inc.php b/include/category_default.inc.php index 9ecc4bded..983ec66be 100644 --- a/include/category_default.inc.php +++ b/include/category_default.inc.php @@ -120,7 +120,9 @@ while ($row = mysql_fetch_array($result)) ) ); - if ($conf['show_comments'] and $user['show_nb_comments']) + if ($user['show_nb_comments'] + and is_numeric($page['cat']) + and $page['cat_commentable']) { $query = ' SELECT COUNT(*) AS nb_comments diff --git a/include/config.inc.php b/include/config.inc.php index c60c46ca5..4d9d0428d 100644 --- a/include/config.inc.php +++ b/include/config.inc.php @@ -167,4 +167,19 @@ $conf['show_queries'] = false; // show_gt : display generation time at the bottom of each page $conf['show_gt'] = true; + +// Default options for new categories. +// +// Some options for categories (commentable, uploadable, status, visible) +// must be set directly in the database by changing the corresponding +// default values of the column. Examples : +// +// ALTER TABLE phpwebgallery_categories ALTER visible SET DEFAULT 'true'; +// ALTER TABLE phpwebgallery_categories ALTER status SET DEFAULT 'private'; +// ALTER TABLE phpwebgallery_categories ALTER uploadable SET DEFAULT 'true'; +// ALTER TABLE phpwebgallery_categories ALTER commentable SET DEFAULT 'false'; +// +// MySQL default values are used when inserting a row and that no value is +// given for the column. In PhpWebGallery, the above columns are not valued +// during categories insertion, so default values are important. ?> diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 569115479..ffbabbe35 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -308,7 +308,7 @@ function get_cat_info( $id ) { $infos = array( 'nb_images','id_uppercat','comment','site_id','galleries_url' ,'dir','date_last','uploadable','status','visible' - ,'representative_picture_id','uppercats' ); + ,'representative_picture_id','uppercats','commentable' ); $query = 'SELECT '.implode( ',', $infos ); $query.= ' FROM '.CATEGORIES_TABLE.' AS a'; @@ -454,6 +454,7 @@ function initialize_category( $calling_page = 'category' ) $page['cat_nb_images'] = $result['nb_images']; $page['cat_site_id'] = $result['site_id']; $page['cat_uploadable'] = $result['uploadable']; + $page['cat_commentable'] = $result['commentable']; $page['uppercats'] = $result['uppercats']; $page['title'] = get_cat_display_name( $page['cat_name'],' - ','',false); $page['where'] = ' WHERE category_id = '.$page['cat']; @@ -911,7 +912,8 @@ function get_first_non_empty_cat_id( $id_uppercat ) function display_select_categories($categories, $indent, $selecteds, - $blockname) + $blockname, + $CSS_classes) { global $template,$user; @@ -925,17 +927,28 @@ function display_select_categories($categories, $selected = ' selected="selected"'; } + $class = ''; + foreach (array_keys($CSS_classes) as $CSS_class) + { + if (in_array($category['id'], $CSS_classes[$CSS_class])) + { + $class = $CSS_class; + } + } + $template->assign_block_vars( $blockname, array('SELECTED'=>$selected, 'VALUE'=>$category['id'], + 'CLASS'=>$class, 'OPTION'=>$indent.'- '.$category['name'] )); display_select_categories($category['subcats'], $indent.str_repeat(' ',3), $selecteds, - $blockname); + $blockname, + $CSS_classes); } } } -- cgit v1.2.3