[2] | 1 | <?php |
---|
[351] | 2 | // +-----------------------------------------------------------------------+ |
---|
[2342] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
[351] | 4 | // +-----------------------------------------------------------------------+ |
---|
[3049] | 5 | // | Copyright(C) 2008-2009 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 | |
---|
[1604] | 29 | trigger_action('loc_begin_index'); |
---|
| 30 | |
---|
[1072] | 31 | // +-----------------------------------------------------------------------+ |
---|
| 32 | // | Check Access and exit when user status is not ok | |
---|
| 33 | // +-----------------------------------------------------------------------+ |
---|
| 34 | check_status(ACCESS_GUEST); |
---|
| 35 | |
---|
[1059] | 36 | //---------------------------------------------- change of image display order |
---|
[1036] | 37 | if (isset($_GET['image_order'])) |
---|
[614] | 38 | { |
---|
[1623] | 39 | if ( (int)$_GET['image_order'] > 0) |
---|
| 40 | { |
---|
| 41 | pwg_set_session_var('image_order', (int)$_GET['image_order']); |
---|
| 42 | } |
---|
| 43 | else |
---|
| 44 | { |
---|
| 45 | pwg_unset_session_var('image_order'); |
---|
| 46 | } |
---|
[1036] | 47 | redirect( |
---|
[1503] | 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 | { |
---|
[1861] | 64 | check_restrictions($page['category']['id']); |
---|
[1036] | 65 | } |
---|
| 66 | |
---|
[3172] | 67 | $page['navigation_bar'] = array(); |
---|
[2218] | 68 | if (count($page['items']) > $user['nb_image_page']) |
---|
[1036] | 69 | { |
---|
| 70 | $page['navigation_bar'] = create_navigation_bar( |
---|
[1503] | 71 | duplicate_index_url(array(), array('start')), |
---|
[1820] | 72 | count($page['items']), |
---|
[1036] | 73 | $page['start'], |
---|
[3117] | 74 | $page['nb_image_page'], |
---|
[1084] | 75 | true |
---|
[1036] | 76 | ); |
---|
| 77 | } |
---|
| 78 | |
---|
[755] | 79 | // caddie filling :-) |
---|
| 80 | if (isset($_GET['caddie'])) |
---|
| 81 | { |
---|
[1036] | 82 | fill_caddie($page['items']); |
---|
[2114] | 83 | redirect(duplicate_index_url()); |
---|
[755] | 84 | } |
---|
| 85 | |
---|
[2] | 86 | //----------------------------------------------------- template initialization |
---|
[345] | 87 | // |
---|
| 88 | // Start output of page |
---|
| 89 | // |
---|
| 90 | $title = $page['title']; |
---|
[850] | 91 | $page['body_id'] = 'theCategoryPage'; |
---|
[345] | 92 | |
---|
[1109] | 93 | $template->set_filenames( array('index'=>'index.tpl') ); |
---|
[351] | 94 | //-------------------------------------------------------------- category title |
---|
[1120] | 95 | $template_title = $page['title']; |
---|
[2218] | 96 | if (count($page['items']) > 0) |
---|
[428] | 97 | { |
---|
[1820] | 98 | $template_title.= ' ['.count($page['items']).']'; |
---|
[428] | 99 | } |
---|
[2231] | 100 | $template->assign('TITLE', $template_title); |
---|
[2] | 101 | |
---|
[1800] | 102 | if (isset($page['flat']) or isset($page['chronology_field'])) |
---|
[1648] | 103 | { |
---|
[2231] | 104 | $template->assign( |
---|
| 105 | 'U_MODE_NORMAL', |
---|
| 106 | duplicate_index_url( array(), array('chronology_field', 'start', 'flat') ) |
---|
[1648] | 107 | ); |
---|
| 108 | } |
---|
| 109 | |
---|
[1800] | 110 | if (!isset($page['flat']) and 'categories' == $page['section']) |
---|
[1651] | 111 | { |
---|
[2231] | 112 | $template->assign( |
---|
| 113 | 'U_MODE_FLAT', |
---|
| 114 | duplicate_index_url(array('flat' => ''), array('start', 'chronology_field')) |
---|
[1651] | 115 | ); |
---|
| 116 | } |
---|
| 117 | |
---|
[1090] | 118 | if (!isset($page['chronology_field'])) |
---|
[1047] | 119 | { |
---|
[1090] | 120 | $chronology_params = |
---|
| 121 | array( |
---|
| 122 | 'chronology_field' => 'created', |
---|
| 123 | 'chronology_style' => 'monthly', |
---|
| 124 | 'chronology_view' => 'list', |
---|
| 125 | ); |
---|
[2231] | 126 | $template->assign( |
---|
| 127 | 'U_MODE_CREATED', |
---|
| 128 | duplicate_index_url( $chronology_params, array('start', 'flat') ) |
---|
[1050] | 129 | ); |
---|
[1083] | 130 | |
---|
[1090] | 131 | $chronology_params['chronology_field'] = 'posted'; |
---|
[2231] | 132 | $template->assign( |
---|
| 133 | 'U_MODE_POSTED', |
---|
| 134 | duplicate_index_url( $chronology_params, array('start', 'flat') ) |
---|
[1059] | 135 | ); |
---|
[1047] | 136 | } |
---|
[1050] | 137 | else |
---|
| 138 | { |
---|
[1090] | 139 | if ($page['chronology_field'] == 'created') |
---|
[1059] | 140 | { |
---|
[1090] | 141 | $chronology_field = 'posted'; |
---|
[1059] | 142 | } |
---|
| 143 | else |
---|
| 144 | { |
---|
[1090] | 145 | $chronology_field = 'created'; |
---|
[1059] | 146 | } |
---|
[1503] | 147 | $url = duplicate_index_url( |
---|
[1090] | 148 | array('chronology_field'=>$chronology_field ), |
---|
[1800] | 149 | array('chronology_date', 'start', 'flat') |
---|
[1086] | 150 | ); |
---|
[2231] | 151 | $template->assign( |
---|
| 152 | 'U_MODE_'.strtoupper($chronology_field), |
---|
| 153 | $url |
---|
[1086] | 154 | ); |
---|
[1050] | 155 | } |
---|
[1047] | 156 | |
---|
[1082] | 157 | if ('search' == $page['section']) |
---|
[1015] | 158 | { |
---|
[2231] | 159 | $template->assign( |
---|
| 160 | 'U_SEARCH_RULES', |
---|
| 161 | get_root_url().'search_rules.php?search_id='.$page['search'] |
---|
[1015] | 162 | ); |
---|
| 163 | } |
---|
[797] | 164 | |
---|
[1082] | 165 | if (isset($page['category']) and is_admin()) |
---|
[834] | 166 | { |
---|
[2231] | 167 | $template->assign( |
---|
| 168 | 'U_EDIT', |
---|
| 169 | get_root_url().'admin.php?page=cat_modify' |
---|
[1861] | 170 | .'&cat_id='.$page['category']['id'] |
---|
[834] | 171 | ); |
---|
| 172 | } |
---|
| 173 | |
---|
[2218] | 174 | if (is_admin() and !empty($page['items'])) |
---|
[1092] | 175 | { |
---|
[2231] | 176 | $template->assign( |
---|
| 177 | 'U_CADDIE', |
---|
| 178 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
---|
[2135] | 179 | ); |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | if ( $page['section']=='search' and $page['start']==0 and |
---|
| 183 | !isset($page['chronology_field']) and isset($page['qsearch_details']) ) |
---|
| 184 | { |
---|
[2231] | 185 | $template->assign('QUERY_SEARCH', |
---|
[2135] | 186 | htmlspecialchars($page['qsearch_details']['q']) ); |
---|
| 187 | |
---|
[2138] | 188 | $cats = array_merge( |
---|
[2135] | 189 | (array)@$page['qsearch_details']['matching_cats_no_images'], |
---|
| 190 | (array)@$page['qsearch_details']['matching_cats'] ); |
---|
[2138] | 191 | if (count($cats)) |
---|
[2135] | 192 | { |
---|
[2138] | 193 | usort($cats, 'name_compare'); |
---|
[2135] | 194 | $hints = array(); |
---|
[2138] | 195 | foreach ( $cats as $cat ) |
---|
[2135] | 196 | { |
---|
[2770] | 197 | $hints[] = get_cat_display_name( array($cat), '', false ); |
---|
[2135] | 198 | } |
---|
[2231] | 199 | $template->assign( 'category_search_results', $hints); |
---|
[1092] | 200 | } |
---|
| 201 | |
---|
[2138] | 202 | $tags = (array)@$page['qsearch_details']['matching_tags']; |
---|
[2135] | 203 | if (count($tags)) |
---|
[1537] | 204 | { |
---|
[2135] | 205 | usort($tags, 'name_compare'); |
---|
| 206 | $hints = array(); |
---|
| 207 | foreach ( $tags as $tag ) |
---|
[1537] | 208 | { |
---|
[2135] | 209 | $hints[] = |
---|
| 210 | '<a href="' . make_index_url(array('tags'=>array($tag))) . '">' |
---|
| 211 | .$tag['name'] |
---|
| 212 | .'</a>'; |
---|
| 213 | } |
---|
[2231] | 214 | $template->assign( 'tag_search_results', $hints); |
---|
[1537] | 215 | } |
---|
| 216 | } |
---|
| 217 | |
---|
[1047] | 218 | // navigation bar |
---|
[3172] | 219 | $template->assign( 'navbar', $page['navigation_bar'] ); |
---|
[1051] | 220 | |
---|
[1820] | 221 | if ( count($page['items']) > 0 |
---|
[1082] | 222 | and $page['section'] != 'most_visited' |
---|
| 223 | and $page['section'] != 'best_rated') |
---|
[1051] | 224 | { |
---|
| 225 | // image order |
---|
[1623] | 226 | $order_idx = pwg_get_session_var( 'image_order', 0 ); |
---|
[1051] | 227 | |
---|
[3146] | 228 | $url = add_url_params( |
---|
| 229 | duplicate_index_url(), |
---|
| 230 | array('image_order' => '') |
---|
| 231 | ); |
---|
| 232 | foreach (get_category_preferred_image_orders() as $order_id => $order) |
---|
[1051] | 233 | { |
---|
[2517] | 234 | if ($order[2]) |
---|
[1051] | 235 | { |
---|
[2231] | 236 | $template->append( |
---|
| 237 | 'image_orders', |
---|
[1082] | 238 | array( |
---|
[2517] | 239 | 'DISPLAY' => $order[0], |
---|
[3146] | 240 | 'URL' => $url.$order_id, |
---|
[2517] | 241 | 'SELECTED' => ($order_idx == $order_id ? true:false), |
---|
[1082] | 242 | ) |
---|
| 243 | ); |
---|
[1051] | 244 | } |
---|
| 245 | } |
---|
| 246 | } |
---|
| 247 | |
---|
[1604] | 248 | // category comment |
---|
| 249 | if (isset($page['comment']) and $page['comment'] != '') |
---|
[2] | 250 | { |
---|
[2231] | 251 | $template->assign('CONTENT_DESCRIPTION', $page['comment'] ); |
---|
[2] | 252 | } |
---|
[2586] | 253 | |
---|
| 254 | // include menubar |
---|
| 255 | include( PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
| 256 | |
---|
| 257 | //------------------------------------------------------ main part : thumbnails |
---|
| 258 | if ( 0==$page['start'] |
---|
| 259 | and !isset($page['flat']) |
---|
| 260 | and !isset($page['chronology_field']) |
---|
| 261 | and ('recent_cats'==$page['section'] or 'categories'==$page['section']) |
---|
| 262 | and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 ) |
---|
| 263 | ) |
---|
| 264 | { |
---|
| 265 | include(PHPWG_ROOT_PATH.'include/category_cats.inc.php'); |
---|
| 266 | } |
---|
| 267 | if ( !empty($page['items']) ) |
---|
| 268 | { |
---|
| 269 | include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); |
---|
| 270 | } |
---|
| 271 | //------------------------------------------------------- category informations |
---|
| 272 | |
---|
| 273 | // slideshow |
---|
| 274 | // execute after init thumbs in order to have all picture informations |
---|
| 275 | if (!empty($page['cat_slideshow_url'])) |
---|
| 276 | { |
---|
| 277 | if (isset($_GET['slideshow'])) |
---|
| 278 | { |
---|
| 279 | redirect($page['cat_slideshow_url']); |
---|
| 280 | } |
---|
| 281 | else |
---|
| 282 | { |
---|
| 283 | $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']); |
---|
| 284 | } |
---|
| 285 | } |
---|
| 286 | |
---|
[1655] | 287 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[1604] | 288 | trigger_action('loc_end_index'); |
---|
[2231] | 289 | $template->pparse('index'); |
---|
[2699] | 290 | //------------------------------------------------------------ log informations |
---|
| 291 | pwg_log(); |
---|
[369] | 292 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 293 | ?> |
---|