Changeset 2327 for trunk/include/section_init.inc.php
- Timestamp:
- May 3, 2008, 3:52:08 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/section_init.inc.php
r2299 r2327 234 234 {// flat categories mode 235 235 if ( isset($page['category']) ) 236 { 237 $subcat_ids = get_subcat_ids( array($page['category']['id']) ); 236 { // get all allowed sub-categories 237 $query = ' 238 SELECT id 239 FROM '.CATEGORIES_TABLE.' 240 WHERE 241 uppercats LIKE "'.$page['category']['uppercats'].',%" ' 242 .get_sql_condition_FandF( 243 array 244 ( 245 'forbidden_categories' => 'id', 246 'visible_categories' => 'id', 247 ), 248 "\n AND" 249 ); 250 $subcat_ids = array_from_query($query, 'id'); 251 $subcat_ids[] = $page['category']['id']; 238 252 $where_sql = 'category_id IN ('.implode(',',$subcat_ids).')'; 253 // remove categories from forbidden because just checked above 254 $forbidden = get_sql_condition_FandF( 255 array( 'visible_images' => 'id' ), 256 'AND' 257 ); 239 258 } 240 259 else … … 503 522 SELECT id,file 504 523 FROM '.IMAGES_TABLE .' 505 WHERE id IN ('.implode(',',$page['items']).') 506 AND file LIKE "' . $page['image_file'] . '.%" ESCAPE "|"' 507 ; 524 WHERE file LIKE "' . $page['image_file'] . '.%" ESCAPE "|"'; 525 if ( count($page['items']) < 500) 526 {// for very large item sets do not add IN - because slow 527 $query .= ' 528 AND id IN ('.implode(',',$page['items']).') 529 LIMIT 0,1'; 530 } 508 531 $result = pwg_query($query); 509 if (mysql_num_rows($result)>0) 510 { 511 list($page['image_id'], $page['image_file']) = mysql_fetch_row($result); 532 switch (mysql_num_rows($result)) 533 { 534 case 0: break; 535 case 1: 536 list($page['image_id'], $page['image_file']) = mysql_fetch_row($result); 537 break; 538 default: // more than 1 file name match 539 while ($row = mysql_fetch_row($result) ) 540 { 541 if ( in_array($row[0], $page['items']) ) 542 { 543 list($page['image_id'], $page['image_file']) = $row; 544 break; 545 } 546 } 512 547 } 513 548 }
Note: See TracChangeset
for help on using the changeset viewer.