- Timestamp:
- Apr 29, 2012, 5:09:28 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Comments_on_Albums/include/coa_comments_page.php
r12562 r14528 2 2 /* inspired by comments.php */ 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 5 4 load_language('plugin.lang', COA_PATH); 6 $conf['comments_on_albums'] = unserialize($conf['comments_on_albums']);7 8 $template->assign(9 array(10 'COA_PATH' => COA_PATH,11 'ICON_COLOR' => $conf['comments_on_albums']['icon_color'],12 'ICON_COLOR_OVER' => $conf['comments_on_albums']['icon_color_over'],13 )14 );15 16 5 17 6 // +-----------------------------------------------------------------------+ … … 19 8 // +-----------------------------------------------------------------------+ 20 9 21 if ( !isset($_GET['display_mode']))10 if ( !isset($_GET['display_mode']) or $_GET['display_mode'] != 'albums' ) 22 11 { 23 12 // adds a button for switch page … … 25 14 26 15 function coa_add_button($content, &$smarty) 27 { 28 $search = '<ul class="categoryActions">'; 29 30 $replacement = ' 31 {html_head} 32 <style type="text/css"> 33 .pwg-icon-comments-albums {ldelim} 34 background-image: url({$COA_PATH}template/s26/{$ICON_COLOR}); 35 background-position: -26px 0; 36 } 37 a:hover .pwg-icon-comments-albums {ldelim} 38 background-image: url({$COA_PATH}template/s26/{$ICON_COLOR_OVER}); 39 background-position: -26px 0; 40 } 41 </style> 42 {/html_head} 43 44 '.$search.' 45 <li><a href="comments.php?display_mode=albums" title="' . l10n('Comments on albums') . '" class="pwg-state-default pwg-button"> 46 <span class="pwg-icon pwg-icon-comments-albums"> </span><span class="pwg-button-text">' . l10n('Comments on albums') . '</span> 47 </a></li>'; 16 { 17 $search ="{include file='infos_errors.tpl'}"; 18 $replacement = $search.' 19 <form class="filter"> 20 <fieldset> 21 <legend>{\'Display comments on\'|@translate}</legend> 22 <span style="font-size:1.1em;"><a href="#" style="font-weight:bold;">{\'Photos\'|@translate}</a> | <a href="comments.php?display_mode=albums">{\'Albums\'|@translate}</a></span> 23 </fieldset> 24 </form>'; 48 25 49 26 return str_replace($search, $replacement, $content); … … 58 35 else if ($_GET['display_mode'] == 'albums') 59 36 { 37 include_once(COA_PATH.'include/functions_comment.inc.php'); // custom functions 38 60 39 // reset some template vars 61 40 $template->clear_assign(array('comments', 'navbar', 'sort_by_options')); … … 88 67 if (isset($action)) 89 68 { 90 include_once(COA_PATH.'include/functions_comment.inc.php');91 92 check_pwg_token();93 94 69 $comment_author_id = get_comment_author_id_albums($comment_id); 95 70 96 $true_action = str_replace('_albums', null, $action); // but we must check true action names 97 98 if (can_manage_comment($true_action, $comment_author_id)) 71 if (can_manage_comment(str_replace('_albums', null, $action), $comment_author_id)) 99 72 { 100 73 $perform_redirect = false; … … 102 75 if ('delete_albums' == $action) 103 76 { 77 check_pwg_token(); 104 78 delete_user_comment_albums($comment_id); 105 79 $perform_redirect = true; … … 107 81 if ('validate_albums' == $action) 108 82 { 83 check_pwg_token(); 109 84 validate_user_comment_albums($comment_id); 110 85 $perform_redirect = true; … … 114 89 if (!empty($_POST['content'])) 115 90 { 91 check_pwg_token(); 116 92 update_user_comment_albums( 117 93 array( … … 122 98 $_POST['key'] 123 99 ); 124 //$perform_redirect = true;125 $ edit_comment = null;100 101 $perform_redirect = true; 126 102 } 127 103 else … … 155 131 156 132 $query = ' 157 SELECT 158 COUNT(DISTINCT(com.id)) 133 SELECT COUNT(DISTINCT(com.id)) 159 134 FROM '.COA_TABLE.' AS com 160 135 LEFT JOIN '.USERS_TABLE.' As u … … 165 140 list($counter) = pwg_db_fetch_row(pwg_query($query)); 166 141 167 $url = 168 PHPWG_ROOT_PATH 169 .'comments.php' 142 $url = PHPWG_ROOT_PATH 143 .'comments.php' 170 144 .get_query_string_diff(array('start','delete_albums','validate_albums','edit_albums','pwg_token')); 171 145 … … 177 151 '' 178 152 ); 153 179 154 $template->assign('navbar', $navbar); 180 155 … … 210 185 com.validated 211 186 ORDER BY '.$page['sort_by'].' '.$page['sort_order']; 212 213 214 187 if ('all' != $page['items_number']) 188 { 189 $query.= ' 215 190 LIMIT '.$page['items_number'].' OFFSET '.$start; 216 217 191 } 192 $query.= ' 218 193 ;'; 219 194 $result = pwg_query($query); … … 258 233 foreach ($comments as $comment) 259 234 { 235 // source of the thumbnail picture 236 $comment['src_image'] = new SrcImage($categories[$comment['comment_id']]); 237 260 238 // category url 261 239 $comment['cat_url'] = duplicate_index_url( … … 269 247 ) 270 248 ); 271 272 // category thumbnail273 $comment['thumb'] = get_thumbnail_url(274 array(275 'id' => $categories[$comment['comment_id']]['image_id'],276 'path' => $categories[$comment['comment_id']]['path'],277 'tn_ext' => @$categories[$comment['comment_id']]['tn_ext'],278 )279 );280 249 281 250 // comment content … … 284 253 'U_PICTURE' => $comment['cat_url'], 285 254 'ALT' => trigger_event('render_category_name', $categories[$comment['comment_id']]['name']), 286 ' TN_SRC' => $comment['thumb'],255 'src_image' => $comment['src_image'], 287 256 'AUTHOR' => trigger_event('render_comment_author', $comment['author']), 288 257 'DATE' => format_date($comment['date'], true), … … 293 262 if (can_manage_comment('delete', $comment['author_id'])) 294 263 { 295 $url =296 get_root_url()297 .'comments.php'298 .get_query_string_diff(array('delete','validate','edit', 'pwg_token'));299 300 264 $tpl_comment['U_DELETE'] = add_url_params( 301 265 $url, … … 308 272 if (can_manage_comment('edit', $comment['author_id'])) 309 273 { 310 $url =311 get_root_url()312 .'comments.php'313 .get_query_string_diff(array('edit', 'delete','validate', 'pwg_token'));314 315 274 $tpl_comment['U_EDIT'] = add_url_params( 316 275 $url, 317 276 array( 318 277 'edit_albums' => $comment['comment_id'], 319 'pwg_token' => get_pwg_token(),320 278 ) 321 279 ); … … 323 281 if (isset($edit_comment) and ($comment['comment_id'] == $edit_comment)) 324 282 { 283 $tpl_comment['IN_EDIT'] = true; 325 284 $key = get_ephemeral_key(2, $comment['category_id']); 326 $tpl_comment['IN_EDIT'] = true;327 285 $tpl_comment['KEY'] = $key; 328 286 $tpl_comment['IMAGE_ID'] = $comment['category_id']; 329 287 $tpl_comment['CONTENT'] = $comment['content']; 288 $tpl_comment['PWG_TOKEN'] = get_pwg_token(); 330 289 } 331 290 } … … 357 316 358 317 function coa_change_comments_list($content, &$smarty) { 359 $search = '<img src="{$ comment.TN_SRC}" alt="{$comment.ALT}">';318 $search = '<img src="{$pwg->derivative_url($derivative_params, $comment.src_image)}" alt="{$comment.ALT}">'; 360 319 $replacement = $search.'<br/>{$comment.ALT}'; 361 320 return str_replace($search, $replacement, $content);
Note: See TracChangeset
for help on using the changeset viewer.