[2] | 1 | <?php |
---|
[351] | 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[351] | 4 | // +-----------------------------------------------------------------------+ |
---|
[12908] | 5 | // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | |
---|
[2342] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
[351] | 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
[352] | 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
[351] | 22 | // +-----------------------------------------------------------------------+ |
---|
[2] | 23 | |
---|
[352] | 24 | //--------------------------------------------------------------------- include |
---|
[364] | 25 | define('PHPWG_ROOT_PATH','./'); |
---|
| 26 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
[1084] | 27 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
---|
[1072] | 28 | |
---|
[8401] | 29 | // Check Access and exit when user status is not ok |
---|
| 30 | check_status(ACCESS_GUEST); |
---|
| 31 | |
---|
| 32 | if (!isset($page['start'])) |
---|
| 33 | { |
---|
| 34 | $page['start'] = 0; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | // access authorization check |
---|
| 38 | if (isset($page['category'])) |
---|
| 39 | { |
---|
| 40 | check_restrictions($page['category']['id']); |
---|
| 41 | } |
---|
[13872] | 42 | if ($page['start']>0 && $page['start']>=count($page['items'])) |
---|
| 43 | { |
---|
| 44 | page_not_found('', duplicate_index_url(array('start'=>0))); |
---|
| 45 | } |
---|
[8401] | 46 | |
---|
[1604] | 47 | trigger_action('loc_begin_index'); |
---|
| 48 | |
---|
[1059] | 49 | //---------------------------------------------- change of image display order |
---|
[1036] | 50 | if (isset($_GET['image_order'])) |
---|
[614] | 51 | { |
---|
[1623] | 52 | if ( (int)$_GET['image_order'] > 0) |
---|
| 53 | { |
---|
| 54 | pwg_set_session_var('image_order', (int)$_GET['image_order']); |
---|
| 55 | } |
---|
| 56 | else |
---|
| 57 | { |
---|
| 58 | pwg_unset_session_var('image_order'); |
---|
| 59 | } |
---|
[1036] | 60 | redirect( |
---|
[1503] | 61 | duplicate_index_url( |
---|
[1084] | 62 | array(), // nothing to redefine |
---|
| 63 | array('start') // changing display order goes back to section first page |
---|
[1082] | 64 | ) |
---|
[1036] | 65 | ); |
---|
[614] | 66 | } |
---|
[12908] | 67 | if (isset($_GET['display'])) |
---|
| 68 | { |
---|
| 69 | $page['meta_robots']['noindex']=1; |
---|
| 70 | if (array_key_exists($_GET['display'], ImageStdParams::get_defined_type_map())) |
---|
| 71 | { |
---|
| 72 | pwg_set_session_var('index_deriv', $_GET['display']); |
---|
| 73 | } |
---|
| 74 | } |
---|
[2] | 75 | //-------------------------------------------------------------- initialization |
---|
[345] | 76 | |
---|
[3172] | 77 | $page['navigation_bar'] = array(); |
---|
[8432] | 78 | if (count($page['items']) > $page['nb_image_page']) |
---|
[1036] | 79 | { |
---|
| 80 | $page['navigation_bar'] = create_navigation_bar( |
---|
[1503] | 81 | duplicate_index_url(array(), array('start')), |
---|
[1820] | 82 | count($page['items']), |
---|
[1036] | 83 | $page['start'], |
---|
[3117] | 84 | $page['nb_image_page'], |
---|
[1084] | 85 | true |
---|
[1036] | 86 | ); |
---|
| 87 | } |
---|
| 88 | |
---|
[755] | 89 | // caddie filling :-) |
---|
| 90 | if (isset($_GET['caddie'])) |
---|
| 91 | { |
---|
[1036] | 92 | fill_caddie($page['items']); |
---|
[2114] | 93 | redirect(duplicate_index_url()); |
---|
[755] | 94 | } |
---|
| 95 | |
---|
[13458] | 96 | if (isset($page['is_homepage']) and $page['is_homepage']) |
---|
| 97 | { |
---|
| 98 | $canonical_url = get_gallery_home_url(); |
---|
| 99 | } |
---|
| 100 | else |
---|
| 101 | { |
---|
| 102 | $canonical_url = duplicate_index_url(); |
---|
| 103 | } |
---|
| 104 | $template->assign('U_CANONICAL', $canonical_url); |
---|
[13062] | 105 | |
---|
[2] | 106 | //----------------------------------------------------- template initialization |
---|
[345] | 107 | // |
---|
| 108 | // Start output of page |
---|
| 109 | // |
---|
| 110 | $title = $page['title']; |
---|
[850] | 111 | $page['body_id'] = 'theCategoryPage'; |
---|
[345] | 112 | |
---|
[1109] | 113 | $template->set_filenames( array('index'=>'index.tpl') ); |
---|
[351] | 114 | //-------------------------------------------------------------- category title |
---|
[1120] | 115 | $template_title = $page['title']; |
---|
[2218] | 116 | if (count($page['items']) > 0) |
---|
[428] | 117 | { |
---|
[1820] | 118 | $template_title.= ' ['.count($page['items']).']'; |
---|
[428] | 119 | } |
---|
[2231] | 120 | $template->assign('TITLE', $template_title); |
---|
[2] | 121 | |
---|
[1800] | 122 | if (isset($page['flat']) or isset($page['chronology_field'])) |
---|
[1648] | 123 | { |
---|
[2231] | 124 | $template->assign( |
---|
| 125 | 'U_MODE_NORMAL', |
---|
| 126 | duplicate_index_url( array(), array('chronology_field', 'start', 'flat') ) |
---|
[1648] | 127 | ); |
---|
| 128 | } |
---|
| 129 | |
---|
[5293] | 130 | if ($conf['index_flat_icon'] and !isset($page['flat']) and 'categories' == $page['section']) |
---|
[1651] | 131 | { |
---|
[2231] | 132 | $template->assign( |
---|
| 133 | 'U_MODE_FLAT', |
---|
| 134 | duplicate_index_url(array('flat' => ''), array('start', 'chronology_field')) |
---|
[1651] | 135 | ); |
---|
| 136 | } |
---|
| 137 | |
---|
[1090] | 138 | if (!isset($page['chronology_field'])) |
---|
[1047] | 139 | { |
---|
[1090] | 140 | $chronology_params = |
---|
| 141 | array( |
---|
| 142 | 'chronology_field' => 'created', |
---|
| 143 | 'chronology_style' => 'monthly', |
---|
| 144 | 'chronology_view' => 'list', |
---|
| 145 | ); |
---|
[5293] | 146 | if ($conf['index_created_date_icon']) |
---|
| 147 | { |
---|
| 148 | $template->assign( |
---|
| 149 | 'U_MODE_CREATED', |
---|
| 150 | duplicate_index_url( $chronology_params, array('start', 'flat') ) |
---|
| 151 | ); |
---|
| 152 | } |
---|
| 153 | if ($conf['index_posted_date_icon']) |
---|
| 154 | { |
---|
| 155 | $chronology_params['chronology_field'] = 'posted'; |
---|
| 156 | $template->assign( |
---|
| 157 | 'U_MODE_POSTED', |
---|
| 158 | duplicate_index_url( $chronology_params, array('start', 'flat') ) |
---|
| 159 | ); |
---|
| 160 | } |
---|
[1047] | 161 | } |
---|
[1050] | 162 | else |
---|
| 163 | { |
---|
[1090] | 164 | if ($page['chronology_field'] == 'created') |
---|
[1059] | 165 | { |
---|
[1090] | 166 | $chronology_field = 'posted'; |
---|
[1059] | 167 | } |
---|
| 168 | else |
---|
| 169 | { |
---|
[1090] | 170 | $chronology_field = 'created'; |
---|
[1059] | 171 | } |
---|
[5293] | 172 | if ($conf['index_'.$chronology_field.'_date_icon']) |
---|
| 173 | { |
---|
| 174 | $url = duplicate_index_url( |
---|
| 175 | array('chronology_field'=>$chronology_field ), |
---|
| 176 | array('chronology_date', 'start', 'flat') |
---|
| 177 | ); |
---|
| 178 | $template->assign( |
---|
| 179 | 'U_MODE_'.strtoupper($chronology_field), |
---|
| 180 | $url |
---|
| 181 | ); |
---|
| 182 | } |
---|
[1050] | 183 | } |
---|
[1047] | 184 | |
---|
[1082] | 185 | if ('search' == $page['section']) |
---|
[1015] | 186 | { |
---|
[2231] | 187 | $template->assign( |
---|
| 188 | 'U_SEARCH_RULES', |
---|
| 189 | get_root_url().'search_rules.php?search_id='.$page['search'] |
---|
[1015] | 190 | ); |
---|
| 191 | } |
---|
[797] | 192 | |
---|
[1082] | 193 | if (isset($page['category']) and is_admin()) |
---|
[834] | 194 | { |
---|
[2231] | 195 | $template->assign( |
---|
| 196 | 'U_EDIT', |
---|
[13025] | 197 | get_root_url().'admin.php?page=album-'.$page['category']['id'] |
---|
[834] | 198 | ); |
---|
| 199 | } |
---|
| 200 | |
---|
[2218] | 201 | if (is_admin() and !empty($page['items'])) |
---|
[1092] | 202 | { |
---|
[2231] | 203 | $template->assign( |
---|
| 204 | 'U_CADDIE', |
---|
| 205 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
---|
[2135] | 206 | ); |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | if ( $page['section']=='search' and $page['start']==0 and |
---|
| 210 | !isset($page['chronology_field']) and isset($page['qsearch_details']) ) |
---|
| 211 | { |
---|
[2231] | 212 | $template->assign('QUERY_SEARCH', |
---|
[2135] | 213 | htmlspecialchars($page['qsearch_details']['q']) ); |
---|
| 214 | |
---|
[2138] | 215 | $cats = array_merge( |
---|
[2135] | 216 | (array)@$page['qsearch_details']['matching_cats_no_images'], |
---|
| 217 | (array)@$page['qsearch_details']['matching_cats'] ); |
---|
[2138] | 218 | if (count($cats)) |
---|
[2135] | 219 | { |
---|
[2138] | 220 | usort($cats, 'name_compare'); |
---|
[2135] | 221 | $hints = array(); |
---|
[2138] | 222 | foreach ( $cats as $cat ) |
---|
[2135] | 223 | { |
---|
[2770] | 224 | $hints[] = get_cat_display_name( array($cat), '', false ); |
---|
[2135] | 225 | } |
---|
[2231] | 226 | $template->assign( 'category_search_results', $hints); |
---|
[1092] | 227 | } |
---|
| 228 | |
---|
[2138] | 229 | $tags = (array)@$page['qsearch_details']['matching_tags']; |
---|
[2135] | 230 | if (count($tags)) |
---|
[1537] | 231 | { |
---|
[2135] | 232 | usort($tags, 'name_compare'); |
---|
| 233 | $hints = array(); |
---|
| 234 | foreach ( $tags as $tag ) |
---|
[1537] | 235 | { |
---|
[2135] | 236 | $hints[] = |
---|
| 237 | '<a href="' . make_index_url(array('tags'=>array($tag))) . '">' |
---|
[12553] | 238 | .trigger_event('render_tag_name', $tag['name']) |
---|
[2135] | 239 | .'</a>'; |
---|
| 240 | } |
---|
[2231] | 241 | $template->assign( 'tag_search_results', $hints); |
---|
[1537] | 242 | } |
---|
| 243 | } |
---|
| 244 | |
---|
[1047] | 245 | // navigation bar |
---|
[3172] | 246 | $template->assign( 'navbar', $page['navigation_bar'] ); |
---|
[1051] | 247 | |
---|
[5293] | 248 | if ( $conf['index_sort_order_input'] |
---|
| 249 | and count($page['items']) > 0 |
---|
[1082] | 250 | and $page['section'] != 'most_visited' |
---|
| 251 | and $page['section'] != 'best_rated') |
---|
[1051] | 252 | { |
---|
| 253 | // image order |
---|
[1623] | 254 | $order_idx = pwg_get_session_var( 'image_order', 0 ); |
---|
[1051] | 255 | |
---|
[3146] | 256 | $url = add_url_params( |
---|
| 257 | duplicate_index_url(), |
---|
| 258 | array('image_order' => '') |
---|
| 259 | ); |
---|
| 260 | foreach (get_category_preferred_image_orders() as $order_id => $order) |
---|
[1051] | 261 | { |
---|
[2517] | 262 | if ($order[2]) |
---|
[1051] | 263 | { |
---|
[2231] | 264 | $template->append( |
---|
| 265 | 'image_orders', |
---|
[1082] | 266 | array( |
---|
[2517] | 267 | 'DISPLAY' => $order[0], |
---|
[3146] | 268 | 'URL' => $url.$order_id, |
---|
[2517] | 269 | 'SELECTED' => ($order_idx == $order_id ? true:false), |
---|
[1082] | 270 | ) |
---|
| 271 | ); |
---|
[1051] | 272 | } |
---|
| 273 | } |
---|
| 274 | } |
---|
| 275 | |
---|
[12908] | 276 | if ( count($page['items']) > 0 ) |
---|
| 277 | { |
---|
| 278 | $url = add_url_params( |
---|
| 279 | duplicate_index_url(), |
---|
| 280 | array('display' => '') |
---|
| 281 | ); |
---|
| 282 | $selected_type = pwg_get_session_var('index_deriv', IMG_THUMB); |
---|
| 283 | $type_map = ImageStdParams::get_defined_type_map(); |
---|
| 284 | unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]); |
---|
| 285 | foreach($type_map as $params) |
---|
| 286 | { |
---|
| 287 | $template->append( |
---|
| 288 | 'image_derivatives', |
---|
| 289 | array( |
---|
| 290 | 'DISPLAY' => l10n($params->type), |
---|
| 291 | 'URL' => $url.$params->type, |
---|
| 292 | 'SELECTED' => ($params->type == $selected_type ? true:false), |
---|
| 293 | ) |
---|
| 294 | ); |
---|
| 295 | } |
---|
| 296 | } |
---|
| 297 | |
---|
[1604] | 298 | // category comment |
---|
[8401] | 299 | if ($page['start']==0 and !isset($page['chronology_field']) and !empty($page['comment']) ) |
---|
[2] | 300 | { |
---|
[2231] | 301 | $template->assign('CONTENT_DESCRIPTION', $page['comment'] ); |
---|
[2] | 302 | } |
---|
[2586] | 303 | |
---|
| 304 | // include menubar |
---|
| 305 | include( PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
| 306 | |
---|
[8463] | 307 | if ( isset($page['category']['count_categories']) and $page['category']['count_categories']==0 ) |
---|
| 308 | {// count_categories might be computed by menubar - if the case unassign flat link if no sub albums |
---|
| 309 | $template->clear_assign('U_MODE_FLAT'); |
---|
| 310 | } |
---|
| 311 | |
---|
[2586] | 312 | //------------------------------------------------------ main part : thumbnails |
---|
| 313 | if ( 0==$page['start'] |
---|
| 314 | and !isset($page['flat']) |
---|
| 315 | and !isset($page['chronology_field']) |
---|
| 316 | and ('recent_cats'==$page['section'] or 'categories'==$page['section']) |
---|
| 317 | and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 ) |
---|
| 318 | ) |
---|
| 319 | { |
---|
| 320 | include(PHPWG_ROOT_PATH.'include/category_cats.inc.php'); |
---|
| 321 | } |
---|
| 322 | if ( !empty($page['items']) ) |
---|
| 323 | { |
---|
| 324 | include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); |
---|
| 325 | } |
---|
| 326 | //------------------------------------------------------- category informations |
---|
| 327 | |
---|
| 328 | // slideshow |
---|
| 329 | // execute after init thumbs in order to have all picture informations |
---|
| 330 | if (!empty($page['cat_slideshow_url'])) |
---|
| 331 | { |
---|
| 332 | if (isset($_GET['slideshow'])) |
---|
| 333 | { |
---|
| 334 | redirect($page['cat_slideshow_url']); |
---|
| 335 | } |
---|
[5293] | 336 | elseif ($conf['index_slideshow_icon']) |
---|
[2586] | 337 | { |
---|
| 338 | $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']); |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | |
---|
[1655] | 342 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[1604] | 343 | trigger_action('loc_end_index'); |
---|
[2231] | 344 | $template->pparse('index'); |
---|
[2699] | 345 | //------------------------------------------------------------ log informations |
---|
| 346 | pwg_log(); |
---|
[369] | 347 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 348 | ?> |
---|