From dac7decfb5d01ff27797ba3ba39ea8af3766b89e Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 12 Feb 2006 21:52:16 +0000 Subject: improvement: $page['where'] string replaced by $page['items']. $page['where'] was an SQL clause used to retrieve pictures in #images table. $page['items'] is the list of picture ids of the current section. improvement: function initialize_category replaced by dedicated included PHP script include/section_init.inc.php. Code was refactored to improve readibility and maintenability. $page['navigation_bar'] is now build in category.php instead of initialize_category function. Function check_cat_id was also replaced by a piece of code in the new file. The file to include to display thumbnails from category.php is now set in section_init.inc.php instead of calculated in category.php. bug fix: the test for rel="up" link for standard HTML navigation links in category menu was not working with non numeric categories, such as "favorites". improvement: function check_login_authorization removed because useless but in profile.php. git-svn-id: http://piwigo.org/svn/trunk@1036 68402e56-0260-453c-a942-63ccdbb3a9ee --- category.php | 117 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 55 insertions(+), 62 deletions(-) (limited to 'category.php') diff --git a/category.php b/category.php index d90e76886..0f0a370b5 100644 --- a/category.php +++ b/category.php @@ -41,23 +41,20 @@ if ( isset( $_GET['act'] ) $url = 'category.php'; redirect( $url ); } -//-------------------------------------------------- access authorization check -if (isset($_GET['cat'])) +//---------------------------------------------- change of image display order +if (isset($_GET['image_order'])) { - check_cat_id($_GET['cat']); -} -check_login_authorization(); -if (isset($page['cat']) and is_numeric($page['cat'])) -{ - check_restrictions($page['cat']); -} -//----------------------------------------------- change of image dispaly order -if ( isset($_GET['image_order']) ) -{ - setcookie( 'pwg_image_order', - $_GET['image_order']>0 ? $_GET['image_order'] : '', 0 ); - redirect( PHPWG_ROOT_PATH.'category.php'. - get_query_string_diff(array('image_order')) ); + setcookie( + 'pwg_image_order', + $_GET['image_order'] > 0 ? $_GET['image_order'] : '', + 0 + ); + + redirect( + PHPWG_ROOT_PATH + .'category.php' + .get_query_string_diff(array('image_order')) + ); } //-------------------------------------------------------------- initialization // detection of the start picture to display @@ -72,20 +69,51 @@ else $page['start'] = $_GET['start']; } -initialize_category(); +include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); + +// access authorization check +if (isset($page['cat']) and is_numeric($page['cat'])) +{ + check_restrictions($page['cat']); +} + +if (isset($page['cat']) + and $page['cat_nb_images'] > $user['nb_image_page']) +{ + // $nav_url is used to create the navigation bar + $nav_url = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat']; + + switch ($page['cat']) + { + case 'search': + { + $nav_url.= '&search='.$_GET['search']; + break; + } + case 'list': + { + $nav_url.= '&list='.$_GET['list']; + break; + } + } + + $page['navigation_bar'] = create_navigation_bar( + $nav_url, + $page['cat_nb_images'], + $page['start'], + $user['nb_image_page'], + 'back' + ); +} +else +{ + $page['navigation_bar'] = ''; +} // caddie filling :-) if (isset($_GET['caddie'])) { -// include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); - - $query = ' -SELECT DISTINCT(id) - FROM '.IMAGES_TABLE.' AS i - INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id - '.$page['where'].' -;'; - fill_caddie(array_from_query($query, 'id')); + fill_caddie($page['items']); } //----------------------------------------------------- template initialization @@ -324,42 +352,7 @@ if (isset($page['cat']) } //------------------------------------------------------ main part : thumbnails -if (isset($page['cat']) - and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0) - or in_array($page['cat'], - array('search' - ,'most_visited' - ,'recent_pics' - ,'best_rated' - ,'list' - ,'fav' - )))) -{ - include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); - - if ('admin' == $user['status']) - { - $template->assign_block_vars( - 'caddie', - array( - 'URL' => - PHPWG_ROOT_PATH.'category.php' - .get_query_string_diff(array('caddie')).'&caddie=1') - ); - } -} -elseif (isset($page['cat']) and $page['cat'] == 'calendar') -{ - include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php'); -} -elseif (isset($page['cat']) and $page['cat'] == 'recent_cats') -{ - include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php'); -} -else -{ - include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php'); -} +include(PHPWG_ROOT_PATH.$page['thumbnails_include']); //------------------------------------------------------- category informations if ( isset ( $page['cat'] ) ) { -- cgit v1.2.3