- Timestamp:
- Oct 15, 2011, 5:16:32 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PWG_Stuffs/trunk/modules/FeaturedPhotos/main.inc.php
r12401 r12450 4 4 5 5 global $page, $user, $conf, $template; 6 7 $page_save = $page; 8 $tpl_save = $template->get_template_vars('THUMBNAILS'); 6 9 7 10 $forbidden = get_sql_condition_FandF … … 25 28 '.$forbidden.';'; 26 29 27 $pictures = array(); 28 $selection = array_from_query($query, 'id'); 30 $page['items'] = array_from_query($query, 'id'); 31 $page['start'] = 0; 32 $page['nb_image_page'] = $datas['nb_images']; 33 $page['section'] = 'category'; 29 34 30 if (count($selection) > 0) 35 include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); 36 37 if (!empty($tpl_thumbnails_var)) 31 38 { 32 $rank_of = array_flip($selection); 33 34 $query = ' 35 SELECT * 36 FROM '.IMAGES_TABLE.' 37 WHERE id IN ('.implode(',', $selection).') 38 ;'; 39 $result = pwg_query($query); 40 while ($row = mysql_fetch_assoc($result)) 41 { 42 $row['rank'] = $rank_of[ $row['id'] ]; 43 44 array_push($pictures, $row); 45 } 46 47 usort($pictures, 'rank_compare'); 48 unset($rank_of); 49 } 50 51 if (count($pictures) > 0) 52 { 53 if ($user['show_nb_comments']) 54 { 55 $query = ' 56 SELECT image_id, COUNT(*) AS nb_comments 57 FROM '.COMMENTS_TABLE.' 58 WHERE validated = \'true\' 59 AND image_id IN ('.implode(',', $selection).') 60 GROUP BY image_id 61 ;'; 62 $nb_comments_of = simple_hash_from_query($query, 'image_id', 'nb_comments'); 63 } 64 65 // template thumbnail initialization 66 trigger_action('loc_begin_index_thumbnails', $pictures); 67 $block['thumbnails'] = array(); 68 69 foreach ($pictures as $row) 70 { 71 // link on picture.php page 72 $url = duplicate_picture_url( 73 array( 74 'image_id' => $row['id'], 75 'image_file' => $row['file'] 76 ), 77 array('start') 78 ); 79 $url = add_url_params($url, array('pwgs_ra' => implode(',',$selection))); 80 81 $tpl_var = 82 array( 83 'ID' => $row['id'], 84 'TN_SRC' => get_thumbnail_url($row), 85 'TN_ALT' => $row['file'], 86 'TN_TITLE' => get_thumbnail_title($row), 87 'ICON_TS' => get_icon($row['date_available']), 88 'URL' => $url, 89 90 /* Fields for template-extension usage */ 91 'FILE_PATH' => $row['path'], 92 'FILE_POSTED' => $row['date_available'], 93 'FILE_CREATED' => $row['date_creation'], 94 'FILE_DESC' => $row['comment'], 95 'FILE_AUTHOR' => $row['author'], 96 'FILE_HIT' => $row['hit'], 97 'FILE_SIZE' => $row['filesize'], 98 'FILE_WIDTH' => $row['width'], 99 'FILE_HEIGHT' => $row['height'], 100 'FILE_METADATE' => $row['date_metadata_update'], 101 'FILE_HAS_HD' => ($row['has_high'] and $user['enabled_high']=='true') ? 102 true:false, /* lack of include/functions_picture.inc.php */ 103 ); 104 105 if ($user['show_nb_hits']) 106 { 107 $tpl_var['NB_HITS'] = $row['hit']; 108 } 109 110 if (isset($row['name']) and $row['name'] != '') 111 { 112 $name = $row['name']; 113 } 114 else 115 { 116 $name = str_replace('_', ' ', get_filename_wo_extension($row['file'])); 117 } 118 119 $tpl_var['NAME'] = $name; 120 121 if ( isset($nb_comments_of) ) 122 { 123 $tpl_var['NB_COMMENTS'] = (int)@$nb_comments_of[$row['id']]; 124 } 125 126 $block['thumbnails'][] = $tpl_var; 127 } 128 129 $block['thumbnails'] = trigger_event('loc_end_index_thumbnails', $block['thumbnails'], $pictures); 130 39 $block['thumbnails'] = $tpl_thumbnails_var; 131 40 $block['TEMPLATE'] = 'stuffs_thumbnails.tpl'; 132 41 } 133 42 43 $page = $page_save; 44 $template->assign('THUMBNAILS', $tpl_save); 45 134 46 ?>
Note: See TracChangeset
for help on using the changeset viewer.