Changeset 2135 for trunk/include/ws_functions.inc.php
- Timestamp:
- Oct 12, 2007, 5:27:34 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r2126 r2135 760 760 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); 761 761 762 $where_clauses = ws_std_image_sql_filter( $params ); 763 $order_by = ws_std_image_sql_order($params); 764 765 if ( !empty($where_clauses) and !empty($order_by) ) 766 { 762 $where_clauses = ws_std_image_sql_filter( $params, 'i.' ); 763 $order_by = ws_std_image_sql_order($params, 'i.'); 764 765 if ( !empty($order_by) ) 766 { 767 global $conf; 768 $conf['order_by'] = 'ORDER BY '.$order_by; 767 769 $page['super_order_by']=1; // quick_search_result might be faster 768 770 } 769 $search_result = get_quick_search_results($params['query']); 770 771 global $image_ids; //needed for sorting by rank (usort) 772 if ( ( !isset($search_result['as_is']) 773 or !empty($where_clauses) 774 or !empty($order_by) ) 775 and !empty($search_result['items']) ) 776 { 777 $where_clauses[] = 'id IN (' 778 .wordwrap(implode(', ', $search_result['items']), 80, "\n") 779 .')'; 780 $where_clauses[] = get_sql_condition_FandF( 781 array 782 ( 783 'forbidden_categories' => 'category_id', 784 'visible_categories' => 'category_id', 785 'visible_images' => 'id' 786 ), 787 '', true 788 ); 789 $query = ' 790 SELECT DISTINCT id FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id 791 WHERE '.implode(' 792 AND ', $where_clauses); 793 if (!empty($order_by)) 794 { 795 $query .= ' 796 ORDER BY '.$order_by; 797 } 798 $image_ids = array_from_query($query, 'id'); 799 global $ranks; 800 $ranks = array_flip( $search_result['items'] ); 801 usort( 802 $image_ids, 803 create_function('$i1,$i2', 'global $ranks; return $ranks[$i1]-$ranks[$i2];') 804 ); 805 unset ($ranks); 806 } 807 else 808 { 809 $image_ids = $search_result['items']; 810 } 771 772 $search_result = get_quick_search_results($params['query'], 773 implode(',', $where_clauses) ); 774 $image_ids = $search_result['items']; 811 775 812 776 $image_ids = array_slice($image_ids,
Note: See TracChangeset
for help on using the changeset viewer.