Changeset 20453 for trunk/include/section_init.inc.php
- Timestamp:
- Jan 29, 2013, 7:46:23 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/section_init.inc.php
r19703 r20453 84 84 85 85 $next_token = 0; 86 if (script_basename() == 'picture') // basename without file extention 87 { // the first token must be the identifier for the picture 86 87 // +-----------------------------------------------------------------------+ 88 // | picture page | 89 // +-----------------------------------------------------------------------+ 90 // the first token must be the identifier for the picture 91 if (script_basename() == 'picture') 92 { 93 // url compatibility with versions below 1.6 88 94 if ( isset($_GET['image_id']) 89 and isset($_GET['cat']) and is_numeric($_GET['cat']) ) 90 {// url compatibility with versions below 1.6 95 and isset($_GET['cat']) 96 and is_numeric($_GET['cat']) ) 97 { 91 98 $url = make_picture_url( array( 92 99 'section' => 'categories', … … 96 103 redirect($url); 97 104 } 105 98 106 $token = $tokens[$next_token]; 99 107 $next_token++; … … 132 140 } 133 141 142 134 143 $page = array_merge( $page, parse_section_url( $tokens, $next_token) ); 135 144 … … 144 153 case 'index': 145 154 { 146 // No section defined, go to selectedurl147 if ( !empty($conf['random_index_redirect']) and empty($tokens[$next_token]) )155 // No section defined, go to random url 156 if ( !empty($conf['random_index_redirect']) and empty($tokens[$next_token]) ) 148 157 { 149 158 $random_index_redirect = array(); … … 170 179 171 180 $page = array_merge( $page, parse_well_known_params_url( $tokens, $next_token) ); 181 182 //access a picture only by id, file or id-file without given section 172 183 if ( script_basename()=='picture' and 'categories'==$page['section'] and 173 184 !isset($page['category']) and !isset($page['chronology_field']) ) 174 { //access a picture only by id, file or id-file without given section175 $page['flat'] =true;185 { 186 $page['flat'] = true; 176 187 } 177 188 … … 202 213 { 203 214 $conf['order_by'] = str_replace( 204 'ORDER BY ',205 'ORDER BY '.$orders[$image_order_id][1].',',206 $conf['order_by']207 );215 'ORDER BY ', 216 'ORDER BY '.$orders[$image_order_id][1].',', 217 $conf['order_by'] 218 ); 208 219 $page['super_order_by'] = true; 209 210 220 } 211 221 else … … 217 227 218 228 $forbidden = get_sql_condition_FandF( 219 array 220 ( 221 'forbidden_categories' => 'category_id', 222 'visible_categories' => 'category_id', 223 'visible_images' => 'id' 229 array( 230 'forbidden_categories' => 'category_id', 231 'visible_categories' => 'category_id', 232 'visible_images' => 'id' 224 233 ), 225 234 'AND' … … 234 243 { 235 244 $page = array_merge( 236 $page, 237 array( 238 'comment' => 239 trigger_event( 240 'render_category_description', 241 $page['category']['comment'], 242 'main_page_category_description' 245 $page, 246 array( 247 'comment' => trigger_event( 248 'render_category_description', 249 $page['category']['comment'], 250 'main_page_category_description' 243 251 ), 244 'title' 252 'title' => get_cat_display_name($page['category']['upper_names'], '', false), 245 253 ) 246 254 ); 247 255 } 248 256 else 257 { 249 258 $page['title'] = ''; // will be set later 250 251 259 } 260 252 261 // GET IMAGES LIST 253 262 if 254 263 ( 255 264 $page['startcat'] == 0 and 256 (!isset($page['chronology_field'])) and 265 (!isset($page['chronology_field'])) and // otherwise the calendar will requery all subitems 257 266 ( 258 267 (isset($page['category'])) or … … 266 275 } 267 276 277 // flat categories mode 268 278 if (isset($page['flat'])) 269 {// flat categories mode 279 { 280 // get all allowed sub-categories 270 281 if ( isset($page['category']) ) 271 { // get all allowed sub-categories282 { 272 283 $query = ' 273 284 SELECT id … … 276 287 uppercats LIKE \''.$page['category']['uppercats'].',%\' ' 277 288 .get_sql_condition_FandF( 278 array 279 ( 289 array( 280 290 'forbidden_categories' => 'id', 281 291 'visible_categories' => 'id', 282 ), 283 "\n AND" 284 ); 292 ), 293 "\n AND" 294 ); 295 285 296 $subcat_ids = array_from_query($query, 'id'); 286 297 $subcat_ids[] = $page['category']['id']; … … 298 309 } 299 310 } 311 // normal mode 300 312 else 301 { // Normal mode313 { 302 314 $where_sql = 'category_id = '.$page['category']['id']; 303 315 } 304 316 305 // Main query317 // main query 306 318 $query = ' 307 319 SELECT DISTINCT(image_id) … … 315 327 316 328 $page['items'] = array_from_query($query, 'image_id'); 317 } //otherwise the calendar will requery all subitems329 } 318 330 } 319 331 // special sections … … 344 356 // | search section | 345 357 // +-----------------------------------------------------------------------+ 346 if ($page['section'] == 'search')358 else if ($page['section'] == 'search') 347 359 { 348 360 include_once( PHPWG_ROOT_PATH .'include/functions_search.inc.php' ); 349 361 350 362 $search_result = get_search_results($page['search'], @$page['super_order_by'] ); 363 //save the details of the query search 351 364 if ( isset($search_result['qs']) ) 352 { //save the details of the query search365 { 353 366 $page['qsearch_details'] = $search_result['qs']; 354 367 } … … 359 372 'items' => $search_result['items'], 360 373 'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">' 361 .l10n('Search results').'</a>',374 .l10n('Search results').'</a>', 362 375 ) 363 376 ); … … 393 406 INNER JOIN '.IMAGES_TABLE.' ON image_id = id 394 407 WHERE user_id = '.$user['id'].' 395 '.get_sql_condition_FandF 396 ( 397 array 398 ( 408 '.get_sql_condition_FandF( 409 array( 399 410 'visible_images' => 'id' 400 ),401 'AND'402 ).'411 ), 412 'AND' 413 ).' 403 414 '.$conf['order_by'].' 404 415 ;'; 405 416 $page = array_merge( 406 407 408 409 )410 );417 $page, 418 array( 419 'items' => array_from_query($query, 'image_id'), 420 ) 421 ); 411 422 412 423 if (count($page['items'])>0) 413 424 { 414 415 416 417 'U_FAVORITE'=> add_url_params(418 419 420 421 422 );425 $template->assign( 426 'favorite', 427 array( 428 'U_FAVORITE' => add_url_params( 429 make_index_url( array('section'=>'favorites') ), 430 array('action'=>'remove_all_from_favorites') 431 ), 432 ) 433 ); 423 434 } 424 435 } … … 432 443 { 433 444 $conf['order_by'] = str_replace( 434 'ORDER BY ',435 'ORDER BY date_available DESC,',436 $conf['order_by']437 );445 'ORDER BY ', 446 'ORDER BY date_available DESC,', 447 $conf['order_by'] 448 ); 438 449 } 439 450 … … 452 463 array( 453 464 'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">' 454 .l10n('Recent photos').'</a>',465 .l10n('Recent photos').'</a>', 455 466 'items' => array_from_query($query, 'id'), 456 467 ) … … 476 487 $page['super_order_by'] = true; 477 488 $conf['order_by'] = ' ORDER BY hit DESC, id DESC'; 489 478 490 $query = ' 479 491 SELECT DISTINCT(id) … … 490 502 array( 491 503 'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">' 492 .$conf['top_number'].' '.l10n('Most visited').'</a>',504 .$conf['top_number'].' '.l10n('Most visited').'</a>', 493 505 'items' => array_from_query($query, 'id'), 494 506 ) … … 516 528 array( 517 529 'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">' 518 .$conf['top_number'].' '.l10n('Best rated').'</a>',530 .$conf['top_number'].' '.l10n('Best rated').'</a>', 519 531 'items' => array_from_query($query, 'id'), 520 532 ) … … 549 561 // | chronology | 550 562 // +-----------------------------------------------------------------------+ 551 552 563 if (isset($page['chronology_field'])) 553 564 { … … 586 597 $page['meta_robots']=array('noindex'=>1, 'nofollow'=>1); 587 598 } 588 elseif ('tags' ==$page['section'])599 elseif ('tags'==$page['section']) 589 600 { 590 601 if ( count($page['tag_ids'])>1 ) … … 628 639 if ($need_redirect) 629 640 { 630 $redirect_url = ( script_basename()=='picture' 631 ? duplicate_picture_url() 632 : duplicate_index_url() 633 ); 641 $redirect_url = script_basename()=='picture' ? duplicate_picture_url() : duplicate_index_url(); 642 634 643 if (!headers_sent()) 635 644 { // this is a permanent redirection
Note: See TracChangeset
for help on using the changeset viewer.