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