[2] | 1 | <?php |
---|
[351] | 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[1058] | 5 | // | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[351] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[351] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2006-10-04 20:48:18 +0000 (Wed, 04 Oct 2006) $ |
---|
| 10 | // | last modifier : $Author: nikrou $ |
---|
| 11 | // | revision : $Revision: 1553 $ |
---|
| 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 14 | // | it under the terms of the GNU General Public License as published by | |
---|
[352] | 15 | // | the Free Software Foundation | |
---|
| 16 | // | | |
---|
| 17 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 20 | // | General Public License for more details. | |
---|
| 21 | // | | |
---|
| 22 | // | You should have received a copy of the GNU General Public License | |
---|
| 23 | // | along with this program; if not, write to the Free Software | |
---|
| 24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 25 | // | USA. | |
---|
[351] | 26 | // +-----------------------------------------------------------------------+ |
---|
[2] | 27 | |
---|
[352] | 28 | //--------------------------------------------------------------------- include |
---|
[364] | 29 | define('PHPWG_ROOT_PATH','./'); |
---|
| 30 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
[1084] | 31 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
---|
[1072] | 32 | |
---|
| 33 | // +-----------------------------------------------------------------------+ |
---|
| 34 | // | Check Access and exit when user status is not ok | |
---|
| 35 | // +-----------------------------------------------------------------------+ |
---|
| 36 | check_status(ACCESS_GUEST); |
---|
| 37 | |
---|
[1059] | 38 | //---------------------------------------------- change of image display order |
---|
[1036] | 39 | if (isset($_GET['image_order'])) |
---|
[614] | 40 | { |
---|
[1036] | 41 | setcookie( |
---|
[1059] | 42 | 'pwg_image_order', |
---|
[1036] | 43 | $_GET['image_order'] > 0 ? $_GET['image_order'] : '', |
---|
[1113] | 44 | 0, cookie_path() |
---|
[1036] | 45 | ); |
---|
[1059] | 46 | |
---|
[1036] | 47 | redirect( |
---|
[1504] | 48 | duplicate_index_url( |
---|
[1084] | 49 | array(), // nothing to redefine |
---|
| 50 | array('start') // changing display order goes back to section first page |
---|
[1082] | 51 | ) |
---|
[1036] | 52 | ); |
---|
[614] | 53 | } |
---|
[2] | 54 | //-------------------------------------------------------------- initialization |
---|
[345] | 55 | // detection of the start picture to display |
---|
[1082] | 56 | if (!isset($page['start'])) |
---|
[514] | 57 | { |
---|
[345] | 58 | $page['start'] = 0; |
---|
[514] | 59 | } |
---|
[345] | 60 | |
---|
[1036] | 61 | // access authorization check |
---|
[1082] | 62 | if (isset($page['category'])) |
---|
[1036] | 63 | { |
---|
[1082] | 64 | check_restrictions($page['category']); |
---|
[1036] | 65 | } |
---|
| 66 | |
---|
[1082] | 67 | if (isset($page['cat_nb_images']) |
---|
[1036] | 68 | and $page['cat_nb_images'] > $user['nb_image_page']) |
---|
| 69 | { |
---|
| 70 | $page['navigation_bar'] = create_navigation_bar( |
---|
[1504] | 71 | duplicate_index_url(array(), array('start')), |
---|
[1036] | 72 | $page['cat_nb_images'], |
---|
| 73 | $page['start'], |
---|
| 74 | $user['nb_image_page'], |
---|
[1084] | 75 | true |
---|
[1036] | 76 | ); |
---|
| 77 | } |
---|
| 78 | else |
---|
| 79 | { |
---|
| 80 | $page['navigation_bar'] = ''; |
---|
| 81 | } |
---|
| 82 | |
---|
[755] | 83 | // caddie filling :-) |
---|
| 84 | if (isset($_GET['caddie'])) |
---|
| 85 | { |
---|
[1036] | 86 | fill_caddie($page['items']); |
---|
[1082] | 87 | // redirect(); |
---|
[755] | 88 | } |
---|
| 89 | |
---|
[2] | 90 | //----------------------------------------------------- template initialization |
---|
[345] | 91 | // |
---|
| 92 | // Start output of page |
---|
| 93 | // |
---|
| 94 | $title = $page['title']; |
---|
[850] | 95 | $page['body_id'] = 'theCategoryPage'; |
---|
[369] | 96 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[345] | 97 | |
---|
[1109] | 98 | $template->set_filenames( array('index'=>'index.tpl') ); |
---|
[351] | 99 | //-------------------------------------------------------------- category title |
---|
[1120] | 100 | $template_title = $page['title']; |
---|
[1082] | 101 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0) |
---|
[428] | 102 | { |
---|
| 103 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
| 104 | } |
---|
[2] | 105 | |
---|
[452] | 106 | $icon_recent = get_icon(date('Y-m-d')); |
---|
[436] | 107 | |
---|
[1090] | 108 | if (!isset($page['chronology_field'])) |
---|
[1047] | 109 | { |
---|
[1090] | 110 | $chronology_params = |
---|
| 111 | array( |
---|
| 112 | 'chronology_field' => 'created', |
---|
| 113 | 'chronology_style' => 'monthly', |
---|
| 114 | 'chronology_view' => 'list', |
---|
| 115 | ); |
---|
[1050] | 116 | $template->assign_block_vars( |
---|
[1059] | 117 | 'mode_created', |
---|
[1082] | 118 | array( |
---|
[1504] | 119 | 'URL' => duplicate_index_url( $chronology_params, array('start') ) |
---|
[1082] | 120 | ) |
---|
[1050] | 121 | ); |
---|
[1083] | 122 | |
---|
[1090] | 123 | $chronology_params['chronology_field'] = 'posted'; |
---|
[1059] | 124 | $template->assign_block_vars( |
---|
| 125 | 'mode_posted', |
---|
[1082] | 126 | array( |
---|
[1504] | 127 | 'URL' => duplicate_index_url( $chronology_params, array('start') ) |
---|
[1082] | 128 | ) |
---|
[1059] | 129 | ); |
---|
[1047] | 130 | } |
---|
[1050] | 131 | else |
---|
| 132 | { |
---|
| 133 | $template->assign_block_vars( |
---|
[1059] | 134 | 'mode_normal', |
---|
[1082] | 135 | array( |
---|
[1504] | 136 | 'URL' => duplicate_index_url( array(), array('chronology_field','start') ) |
---|
[1082] | 137 | ) |
---|
[1050] | 138 | ); |
---|
[1059] | 139 | |
---|
[1090] | 140 | if ($page['chronology_field'] == 'created') |
---|
[1059] | 141 | { |
---|
[1090] | 142 | $chronology_field = 'posted'; |
---|
[1059] | 143 | } |
---|
| 144 | else |
---|
| 145 | { |
---|
[1090] | 146 | $chronology_field = 'created'; |
---|
[1059] | 147 | } |
---|
[1504] | 148 | $url = duplicate_index_url( |
---|
[1090] | 149 | array('chronology_field'=>$chronology_field ), |
---|
[1086] | 150 | array('chronology_date', 'start') |
---|
| 151 | ); |
---|
| 152 | $template->assign_block_vars( |
---|
[1090] | 153 | 'mode_'.$chronology_field, |
---|
[1086] | 154 | array('URL' => $url ) |
---|
| 155 | ); |
---|
[1050] | 156 | } |
---|
[1367] | 157 | // include menubar |
---|
| 158 | include(PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
[1047] | 159 | |
---|
[850] | 160 | $template->assign_vars( |
---|
| 161 | array( |
---|
[1082] | 162 | 'TITLE' => $template_title, |
---|
[1367] | 163 | 'TOP_NUMBER' => $conf['top_number'], // still used ? |
---|
| 164 | 'T_RECENT' => $icon_recent, // still used ? |
---|
[1082] | 165 | ) |
---|
| 166 | ); |
---|
[1059] | 167 | |
---|
[1082] | 168 | if ('search' == $page['section']) |
---|
[1015] | 169 | { |
---|
| 170 | $template->assign_block_vars( |
---|
| 171 | 'search_rules', |
---|
| 172 | array( |
---|
[1092] | 173 | 'URL' => get_root_url().'search_rules.php?search_id='.$page['search'], |
---|
[1015] | 174 | ) |
---|
| 175 | ); |
---|
| 176 | } |
---|
[797] | 177 | |
---|
[1082] | 178 | if (isset($page['category']) and is_admin()) |
---|
[834] | 179 | { |
---|
| 180 | $template->assign_block_vars( |
---|
| 181 | 'edit', |
---|
| 182 | array( |
---|
| 183 | 'URL' => |
---|
[1090] | 184 | get_root_url().'admin.php?page=cat_modify' |
---|
[1082] | 185 | .'&cat_id='.$page['category'] |
---|
[834] | 186 | ) |
---|
| 187 | ); |
---|
| 188 | } |
---|
| 189 | |
---|
[1092] | 190 | if (is_admin() and !empty($page['items']) ) |
---|
| 191 | { |
---|
| 192 | $template->assign_block_vars( |
---|
| 193 | 'caddie', |
---|
| 194 | array( |
---|
| 195 | 'URL' => |
---|
[1094] | 196 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
---|
[1092] | 197 | ) |
---|
| 198 | ); |
---|
| 199 | } |
---|
| 200 | |
---|
[441] | 201 | //------------------------------------------------------ main part : thumbnails |
---|
[1082] | 202 | if (isset($page['thumbnails_include'])) |
---|
[1047] | 203 | { |
---|
| 204 | include(PHPWG_ROOT_PATH.$page['thumbnails_include']); |
---|
| 205 | } |
---|
[2] | 206 | //------------------------------------------------------- category informations |
---|
[1082] | 207 | if ( |
---|
| 208 | $page['navigation_bar'] != '' |
---|
| 209 | or (isset($page['comment']) and $page['comment'] != '') |
---|
| 210 | ) |
---|
[1047] | 211 | { |
---|
| 212 | $template->assign_block_vars('cat_infos',array()); |
---|
| 213 | } |
---|
| 214 | // navigation bar |
---|
[1082] | 215 | if ($page['navigation_bar'] != '') |
---|
[1059] | 216 | { |
---|
[1047] | 217 | $template->assign_block_vars( |
---|
| 218 | 'cat_infos.navigation', |
---|
[1082] | 219 | array( |
---|
| 220 | 'NAV_BAR' => $page['navigation_bar'], |
---|
| 221 | ) |
---|
[1047] | 222 | ); |
---|
| 223 | } |
---|
[1051] | 224 | |
---|
[1082] | 225 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0 |
---|
| 226 | and $page['section'] != 'most_visited' |
---|
| 227 | and $page['section'] != 'best_rated') |
---|
[1051] | 228 | { |
---|
| 229 | // image order |
---|
| 230 | $template->assign_block_vars( 'preferred_image_order', array() ); |
---|
| 231 | |
---|
[1082] | 232 | $order_idx = isset($_COOKIE['pwg_image_order']) |
---|
| 233 | ? $_COOKIE['pwg_image_order'] |
---|
| 234 | : 0 |
---|
| 235 | ; |
---|
[1051] | 236 | |
---|
| 237 | $orders = get_category_preferred_image_orders(); |
---|
[1082] | 238 | for ($i = 0; $i < count($orders); $i++) |
---|
[1051] | 239 | { |
---|
| 240 | if ($orders[$i][2]) |
---|
| 241 | { |
---|
[1082] | 242 | $template->assign_block_vars( |
---|
| 243 | 'preferred_image_order.order', |
---|
| 244 | array( |
---|
| 245 | 'DISPLAY' => $orders[$i][0], |
---|
[1504] | 246 | 'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ), |
---|
[1082] | 247 | 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''), |
---|
| 248 | ) |
---|
| 249 | ); |
---|
[1051] | 250 | } |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | |
---|
[1082] | 254 | if (isset($page['category'])) |
---|
[2] | 255 | { |
---|
[351] | 256 | // category comment |
---|
[1082] | 257 | if (isset($page['comment']) and $page['comment'] != '') |
---|
[351] | 258 | { |
---|
[428] | 259 | $template->assign_block_vars( |
---|
| 260 | 'cat_infos.comment', |
---|
[1082] | 261 | array( |
---|
| 262 | 'COMMENTS' => $page['comment'] |
---|
| 263 | ) |
---|
[428] | 264 | ); |
---|
[351] | 265 | } |
---|
[2] | 266 | } |
---|
| 267 | //------------------------------------------------------------ log informations |
---|
[1082] | 268 | pwg_log('category', $page['title']); |
---|
[345] | 269 | |
---|
[1109] | 270 | $template->parse('index'); |
---|
[369] | 271 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 272 | ?> |
---|