- Timestamp:
- Apr 26, 2008, 1:38:04 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/picture_rate.inc.php
r2299 r2309 29 29 if ($conf['rate']) 30 30 { 31 $query = ' 31 if ( NULL != $picture['current']['average_rate'] ) 32 { 33 $query = ' 32 34 SELECT COUNT(rate) AS count 33 35 , ROUND(AVG(rate),2) AS average … … 36 38 WHERE element_id = '.$picture['current']['id'].' 37 39 ;'; 38 $row = mysql_fetch_array(pwg_query($query)); 40 $row = mysql_fetch_array(pwg_query($query)); 41 } 42 else 43 { // avg rate null -> no rate -> no need to query db 44 $row = array( 'count'=>0, 'average'=>NULL, 'std'=>NULL ); 45 } 39 46 $template->assign('rate_summary', $row); 40 47 -
trunk/picture.php
r2299 r2309 613 613 614 614 'LEVEL_SEPARATOR' => $conf['level_separator'], 615 615 616 616 'FILE_PICTURE_NAV_BUTTONS' => 'picture_nav_buttons.tpl', 617 617 … … 638 638 ); 639 639 } 640 640 641 641 $template->assign( 642 642 array( … … 816 816 817 817 // related categories 818 foreach ($related_categories as $category) 819 { 818 if ( count($related_categories)==1 and 819 isset($page['category']) and 820 $related_categories[0]['category_id']==$page['category']['id'] ) 821 { // no need to go to db, we have all the info 820 822 $template->append( 821 'related_categories', 822 count($related_categories) > 3 823 ? get_cat_display_name_cache($category['uppercats']) 824 : get_cat_display_name_from_id($category['category_id']) 825 ); 823 'related_categories', 824 get_cat_display_name( $page['category']['upper_names'] ) 825 ); 826 } 827 else 828 { // use only 1 sql query to get names for all related categories 829 $ids = array(); 830 foreach ($related_categories as $category) 831 {// add all uppercats to $ids 832 $ids = array_merge($ids, explode(',', $category['uppercats']) ); 833 } 834 $ids = array_unique($ids); 835 $query = ' 836 SELECT id, name, permalink 837 FROM '.CATEGORIES_TABLE.' 838 WHERE id IN ('.implode(',',$ids).')'; 839 $cat_map = hash_from_query($query, 'id'); 840 foreach ($related_categories as $category) 841 { 842 $cats = array(); 843 foreach ( explode(',', $category['uppercats']) as $id ) 844 { 845 $cats[] = $cat_map[$id]; 846 } 847 $template->append('related_categories', get_cat_display_name($cats) ); 848 } 826 849 } 827 850
Note: See TracChangeset
for help on using the changeset viewer.