| 1 | <?php |
|---|
| 2 | // +-----------------------------------------------------------------------+ |
|---|
| 3 | // | Piwigo - a PHP based picture gallery | |
|---|
| 4 | // +-----------------------------------------------------------------------+ |
|---|
| 5 | // | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org | |
|---|
| 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
|---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
|---|
| 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 | |
|---|
| 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. | |
|---|
| 22 | // +-----------------------------------------------------------------------+ |
|---|
| 23 | |
|---|
| 24 | //--------------------------------------------------------------------- include |
|---|
| 25 | define('PHPWG_ROOT_PATH','./'); |
|---|
| 26 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
|---|
| 27 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
|---|
| 28 | |
|---|
| 29 | trigger_action('loc_begin_index'); |
|---|
| 30 | |
|---|
| 31 | // +-----------------------------------------------------------------------+ |
|---|
| 32 | // | Check Access and exit when user status is not ok | |
|---|
| 33 | // +-----------------------------------------------------------------------+ |
|---|
| 34 | check_status(ACCESS_GUEST); |
|---|
| 35 | |
|---|
| 36 | //---------------------------------------------- change of image display order |
|---|
| 37 | if (isset($_GET['image_order'])) |
|---|
| 38 | { |
|---|
| 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 | } |
|---|
| 47 | redirect( |
|---|
| 48 | duplicate_index_url( |
|---|
| 49 | array(), // nothing to redefine |
|---|
| 50 | array('start') // changing display order goes back to section first page |
|---|
| 51 | ) |
|---|
| 52 | ); |
|---|
| 53 | } |
|---|
| 54 | //-------------------------------------------------------------- initialization |
|---|
| 55 | // detection of the start picture to display |
|---|
| 56 | if (!isset($page['start'])) |
|---|
| 57 | { |
|---|
| 58 | $page['start'] = 0; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | // access authorization check |
|---|
| 62 | if (isset($page['category'])) |
|---|
| 63 | { |
|---|
| 64 | check_restrictions($page['category']['id']); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | $page['navigation_bar'] = array(); |
|---|
| 68 | if (count($page['items']) > $user['nb_image_page']) |
|---|
| 69 | { |
|---|
| 70 | $page['navigation_bar'] = create_navigation_bar( |
|---|
| 71 | duplicate_index_url(array(), array('start')), |
|---|
| 72 | count($page['items']), |
|---|
| 73 | $page['start'], |
|---|
| 74 | $page['nb_image_page'], |
|---|
| 75 | true |
|---|
| 76 | ); |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | // caddie filling :-) |
|---|
| 80 | if (isset($_GET['caddie'])) |
|---|
| 81 | { |
|---|
| 82 | fill_caddie($page['items']); |
|---|
| 83 | redirect(duplicate_index_url()); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | //----------------------------------------------------- template initialization |
|---|
| 87 | // |
|---|
| 88 | // Start output of page |
|---|
| 89 | // |
|---|
| 90 | $title = $page['title']; |
|---|
| 91 | $page['body_id'] = 'theCategoryPage'; |
|---|
| 92 | |
|---|
| 93 | $template->set_filenames( array('index'=>'index.tpl') ); |
|---|
| 94 | //-------------------------------------------------------------- category title |
|---|
| 95 | $template_title = $page['title']; |
|---|
| 96 | if (count($page['items']) > 0) |
|---|
| 97 | { |
|---|
| 98 | $template_title.= ' ['.count($page['items']).']'; |
|---|
| 99 | } |
|---|
| 100 | $template->assign('TITLE', $template_title); |
|---|
| 101 | |
|---|
| 102 | if (isset($page['flat']) or isset($page['chronology_field'])) |
|---|
| 103 | { |
|---|
| 104 | $template->assign( |
|---|
| 105 | 'U_MODE_NORMAL', |
|---|
| 106 | duplicate_index_url( array(), array('chronology_field', 'start', 'flat') ) |
|---|
| 107 | ); |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | if ($conf['index_flat_icon'] and !isset($page['flat']) and 'categories' == $page['section']) |
|---|
| 111 | { |
|---|
| 112 | $template->assign( |
|---|
| 113 | 'U_MODE_FLAT', |
|---|
| 114 | duplicate_index_url(array('flat' => ''), array('start', 'chronology_field')) |
|---|
| 115 | ); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | if (!isset($page['chronology_field'])) |
|---|
| 119 | { |
|---|
| 120 | $chronology_params = |
|---|
| 121 | array( |
|---|
| 122 | 'chronology_field' => 'created', |
|---|
| 123 | 'chronology_style' => 'monthly', |
|---|
| 124 | 'chronology_view' => 'list', |
|---|
| 125 | ); |
|---|
| 126 | if ($conf['index_created_date_icon']) |
|---|
| 127 | { |
|---|
| 128 | $template->assign( |
|---|
| 129 | 'U_MODE_CREATED', |
|---|
| 130 | duplicate_index_url( $chronology_params, array('start', 'flat') ) |
|---|
| 131 | ); |
|---|
| 132 | } |
|---|
| 133 | if ($conf['index_posted_date_icon']) |
|---|
| 134 | { |
|---|
| 135 | $chronology_params['chronology_field'] = 'posted'; |
|---|
| 136 | $template->assign( |
|---|
| 137 | 'U_MODE_POSTED', |
|---|
| 138 | duplicate_index_url( $chronology_params, array('start', 'flat') ) |
|---|
| 139 | ); |
|---|
| 140 | } |
|---|
| 141 | } |
|---|
| 142 | else |
|---|
| 143 | { |
|---|
| 144 | if ($page['chronology_field'] == 'created') |
|---|
| 145 | { |
|---|
| 146 | $chronology_field = 'posted'; |
|---|
| 147 | } |
|---|
| 148 | else |
|---|
| 149 | { |
|---|
| 150 | $chronology_field = 'created'; |
|---|
| 151 | } |
|---|
| 152 | if ($conf['index_'.$chronology_field.'_date_icon']) |
|---|
| 153 | { |
|---|
| 154 | $url = duplicate_index_url( |
|---|
| 155 | array('chronology_field'=>$chronology_field ), |
|---|
| 156 | array('chronology_date', 'start', 'flat') |
|---|
| 157 | ); |
|---|
| 158 | $template->assign( |
|---|
| 159 | 'U_MODE_'.strtoupper($chronology_field), |
|---|
| 160 | $url |
|---|
| 161 | ); |
|---|
| 162 | } |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | if ('search' == $page['section']) |
|---|
| 166 | { |
|---|
| 167 | $template->assign( |
|---|
| 168 | 'U_SEARCH_RULES', |
|---|
| 169 | get_root_url().'search_rules.php?search_id='.$page['search'] |
|---|
| 170 | ); |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | if (isset($page['category']) and is_admin()) |
|---|
| 174 | { |
|---|
| 175 | $template->assign( |
|---|
| 176 | 'U_EDIT', |
|---|
| 177 | get_root_url().'admin.php?page=cat_modify' |
|---|
| 178 | .'&cat_id='.$page['category']['id'] |
|---|
| 179 | ); |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | if (is_admin() and !empty($page['items'])) |
|---|
| 183 | { |
|---|
| 184 | $template->assign( |
|---|
| 185 | 'U_CADDIE', |
|---|
| 186 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
|---|
| 187 | ); |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | if ( $page['section']=='search' and $page['start']==0 and |
|---|
| 191 | !isset($page['chronology_field']) and isset($page['qsearch_details']) ) |
|---|
| 192 | { |
|---|
| 193 | $template->assign('QUERY_SEARCH', |
|---|
| 194 | htmlspecialchars($page['qsearch_details']['q']) ); |
|---|
| 195 | |
|---|
| 196 | $cats = array_merge( |
|---|
| 197 | (array)@$page['qsearch_details']['matching_cats_no_images'], |
|---|
| 198 | (array)@$page['qsearch_details']['matching_cats'] ); |
|---|
| 199 | if (count($cats)) |
|---|
| 200 | { |
|---|
| 201 | usort($cats, 'name_compare'); |
|---|
| 202 | $hints = array(); |
|---|
| 203 | foreach ( $cats as $cat ) |
|---|
| 204 | { |
|---|
| 205 | $hints[] = get_cat_display_name( array($cat), '', false ); |
|---|
| 206 | } |
|---|
| 207 | $template->assign( 'category_search_results', $hints); |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | $tags = (array)@$page['qsearch_details']['matching_tags']; |
|---|
| 211 | if (count($tags)) |
|---|
| 212 | { |
|---|
| 213 | usort($tags, 'name_compare'); |
|---|
| 214 | $hints = array(); |
|---|
| 215 | foreach ( $tags as $tag ) |
|---|
| 216 | { |
|---|
| 217 | $hints[] = |
|---|
| 218 | '<a href="' . make_index_url(array('tags'=>array($tag))) . '">' |
|---|
| 219 | .$tag['name'] |
|---|
| 220 | .'</a>'; |
|---|
| 221 | } |
|---|
| 222 | $template->assign( 'tag_search_results', $hints); |
|---|
| 223 | } |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | // navigation bar |
|---|
| 227 | $template->assign( 'navbar', $page['navigation_bar'] ); |
|---|
| 228 | |
|---|
| 229 | if ( $conf['index_sort_order_input'] |
|---|
| 230 | and count($page['items']) > 0 |
|---|
| 231 | and $page['section'] != 'most_visited' |
|---|
| 232 | and $page['section'] != 'best_rated') |
|---|
| 233 | { |
|---|
| 234 | // image order |
|---|
| 235 | $order_idx = pwg_get_session_var( 'image_order', 0 ); |
|---|
| 236 | |
|---|
| 237 | $url = add_url_params( |
|---|
| 238 | duplicate_index_url(), |
|---|
| 239 | array('image_order' => '') |
|---|
| 240 | ); |
|---|
| 241 | foreach (get_category_preferred_image_orders() as $order_id => $order) |
|---|
| 242 | { |
|---|
| 243 | if ($order[2]) |
|---|
| 244 | { |
|---|
| 245 | $template->append( |
|---|
| 246 | 'image_orders', |
|---|
| 247 | array( |
|---|
| 248 | 'DISPLAY' => $order[0], |
|---|
| 249 | 'URL' => $url.$order_id, |
|---|
| 250 | 'SELECTED' => ($order_idx == $order_id ? true:false), |
|---|
| 251 | ) |
|---|
| 252 | ); |
|---|
| 253 | } |
|---|
| 254 | } |
|---|
| 255 | } |
|---|
| 256 | |
|---|
| 257 | // category comment |
|---|
| 258 | if (isset($page['comment']) and $page['comment'] != '') |
|---|
| 259 | { |
|---|
| 260 | $template->assign('CONTENT_DESCRIPTION', $page['comment'] ); |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | // include menubar |
|---|
| 264 | include( PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
|---|
| 265 | |
|---|
| 266 | //------------------------------------------------------ main part : thumbnails |
|---|
| 267 | if ( 0==$page['start'] |
|---|
| 268 | and !isset($page['flat']) |
|---|
| 269 | and !isset($page['chronology_field']) |
|---|
| 270 | and ('recent_cats'==$page['section'] or 'categories'==$page['section']) |
|---|
| 271 | and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 ) |
|---|
| 272 | ) |
|---|
| 273 | { |
|---|
| 274 | include(PHPWG_ROOT_PATH.'include/category_cats.inc.php'); |
|---|
| 275 | } |
|---|
| 276 | if ( !empty($page['items']) ) |
|---|
| 277 | { |
|---|
| 278 | include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); |
|---|
| 279 | } |
|---|
| 280 | //------------------------------------------------------- category informations |
|---|
| 281 | |
|---|
| 282 | // slideshow |
|---|
| 283 | // execute after init thumbs in order to have all picture informations |
|---|
| 284 | if (!empty($page['cat_slideshow_url'])) |
|---|
| 285 | { |
|---|
| 286 | if (isset($_GET['slideshow'])) |
|---|
| 287 | { |
|---|
| 288 | redirect($page['cat_slideshow_url']); |
|---|
| 289 | } |
|---|
| 290 | elseif ($conf['index_slideshow_icon']) |
|---|
| 291 | { |
|---|
| 292 | $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']); |
|---|
| 293 | } |
|---|
| 294 | } |
|---|
| 295 | |
|---|
| 296 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
|---|
| 297 | trigger_action('loc_end_index'); |
|---|
| 298 | $template->pparse('index'); |
|---|
| 299 | //------------------------------------------------------------ log informations |
|---|
| 300 | pwg_log(); |
|---|
| 301 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
|---|
| 302 | ?> |
|---|