- Timestamp:
- Jun 21, 2005, 11:08:11 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/comments.php
r721 r796 35 35 } 36 36 37 if (isset($_GET['last_days'])) 38 { 39 define('MAX_DAYS', $_GET['last_days']); 40 } 41 else 42 { 43 define('MAX_DAYS', 0); 44 } 45 $array_cat_names = array(); 37 $sort_order = array( 38 'descending' => 'DESC', 39 'ascending' => 'ASC' 40 ); 41 42 // sort_by : database fields proposed for sorting comments list 43 $sort_by = array( 44 'date' => 'comment date', 45 'image_id' => 'image' 46 ); 47 48 // items_number : list of number of items to display per page 49 $items_number = array(5,10,20,50,'all'); 50 51 // since when display comments ? 52 // 53 $since_options = array( 54 1 => array('label' => l10n('today'), 55 'clause' => 'date > SUBDATE(CURDATE(), INTERVAL 1 DAY)'), 56 2 => array('label' => sprintf(l10n('last %d days'), 7), 57 'clause' => 'date > SUBDATE(CURDATE(), INTERVAL 7 DAY)'), 58 3 => array('label' => sprintf(l10n('last %d days'), 30), 59 'clause' => 'date > SUBDATE(CURDATE(), INTERVAL 30 DAY)'), 60 4 => array('label' => l10n('the beginning'), 61 'clause' => '1=1') // stupid but generic 62 ); 63 64 $page['since'] = isset($_GET['since']) ? $_GET['since'] : 1; 65 66 // on which field sorting 67 // 68 $page['sort_by'] = 'date'; 69 // if the form was submitted, it overloads default behaviour 70 if (isset($_GET['sort_by'])) 71 { 72 $page['sort_by'] = $_GET['sort_by']; 73 } 74 75 // order to sort 76 // 77 $page['sort_order'] = $sort_order['descending']; 78 // if the form was submitted, it overloads default behaviour 79 if (isset($_GET['sort_order'])) 80 { 81 $page['sort_order'] = $sort_order[$_GET['sort_order']]; 82 } 83 84 // number of items to display 85 // 86 $page['items_number'] = 5; 87 if (isset($_GET['items_number'])) 88 { 89 $page['items_number'] = $_GET['items_number']; 90 } 91 92 // which category to filter on ? 93 $page['cat_clause'] = '1=1'; 94 if (isset($_GET['cat']) and 0 != $_GET['cat']) 95 { 96 $page['cat_clause'] = 97 'category_id IN ('.implode(',', get_subcat_ids(array($_GET['cat']))).')'; 98 } 99 100 // search a particular author 101 $page['author_clause'] = '1=1'; 102 if (isset($_GET['author']) and !empty($_GET['author'])) 103 { 104 if (function_exists('mysql_real_escape_string')) 105 { 106 $author = mysql_real_escape_string($_GET['author']); 107 } 108 else 109 { 110 $author = mysql_escape_string($_GET['author']); 111 } 112 113 $page['author_clause'] = 'author = \''.$author.'\''; 114 } 115 116 // search a substring among comments content 117 $page['keyword_clause'] = '1=1'; 118 if (isset($_GET['keyword']) and !empty($_GET['keyword'])) 119 { 120 if (function_exists('mysql_real_escape_string')) 121 { 122 $keyword = mysql_real_escape_string($_GET['keyword']); 123 } 124 else 125 { 126 $keyword = mysql_escape_string($_GET['keyword']); 127 } 128 $page['keyword_clause'] = 129 '('. 130 implode(' AND ', 131 array_map( 132 create_function( 133 '$s', 134 'return "content LIKE \'%$s%\'";' 135 ), 136 preg_split('/[\s,;]+/', $keyword) 137 ) 138 ). 139 ')'; 140 } 141 46 142 // +-----------------------------------------------------------------------+ 47 143 // | comments management | … … 71 167 if (!defined('IN_ADMIN')) 72 168 { 73 $title= $lang['title_comments'];169 $title= l10n('title_comments'); 74 170 include(PHPWG_ROOT_PATH.'include/page_header.php'); 75 171 } … … 79 175 array( 80 176 'L_COMMENT_TITLE' => $title, 81 'L_COMMENT_STATS' => $lang['stats_last_days'], 82 'L_COMMENT_RETURN' => $lang['home'], 83 'L_COMMENT_RETURN_HINT' => $lang['home_hint'], 84 'L_DELETE' =>$lang['delete'], 85 'L_VALIDATE'=>$lang['submit'], 177 178 'F_ACTION'=>PHPWG_ROOT_PATH.'comments.php', 179 'F_KEYWORD'=>@$_GET['keyword'], 180 'F_AUTHOR'=>@$_GET['author'], 86 181 87 182 'U_HOME' => add_session_id(PHPWG_ROOT_PATH.'category.php') … … 89 184 ); 90 185 91 foreach ($conf['last_days'] as $option) 92 { 93 $url = $_SERVER['PHP_SELF'].'?last_days='.($option - 1); 94 if (defined('IN_ADMIN')) 95 { 96 $url.= '&page=comments'; 97 } 186 // +-----------------------------------------------------------------------+ 187 // | form construction | 188 // +-----------------------------------------------------------------------+ 189 190 // Search in a particular category 191 $blockname = 'category'; 192 193 $template->assign_block_vars( 194 $blockname, 195 array('SELECTED' => '', 196 'VALUE'=> 0, 197 'OPTION' => '------------' 198 )); 199 200 $query = ' 201 SELECT id,name,uppercats,global_rank 202 FROM '.CATEGORIES_TABLE; 203 if ($user['forbidden_categories'] != '') 204 { 205 $query.= ' 206 WHERE id NOT IN ('.$user['forbidden_categories'].')'; 207 } 208 $query.= ' 209 ;'; 210 display_select_cat_wrapper($query, array(@$_GET['cat']), $blockname, true); 211 212 // Filter on recent comments... 213 $blockname = 'since_option'; 214 215 foreach ($since_options as $id => $option) 216 { 217 $selected = ($id == $page['since']) ? 'selected="selected"' : ''; 218 98 219 $template->assign_block_vars( 99 'last_day_option', 100 array( 101 'OPTION'=>$option, 102 'T_STYLE'=>(($option == MAX_DAYS + 1)?'text-decoration:underline;':''), 103 'U_OPTION'=>add_session_id($url) 104 ) 105 ); 106 } 220 $blockname, 221 array('SELECTED' => $selected, 222 'VALUE'=> $id, 223 'CONTENT' => $option['label'] 224 )); 225 } 226 227 // Sort by 228 $blockname = 'sort_by_option'; 229 230 foreach ($sort_by as $key => $value) 231 { 232 $selected = ($key == $page['sort_by']) ? 'selected="selected"' : ''; 233 234 $template->assign_block_vars( 235 $blockname, 236 array('SELECTED' => $selected, 237 'VALUE'=> $key, 238 'CONTENT' => l10n($value) 239 )); 240 } 241 242 // Sorting order 243 $blockname = 'sort_order_option'; 244 245 foreach (array_keys($sort_order) as $option) 246 { 247 $selected = ($option == $page['sort_order']) ? 'selected="selected"' : ''; 248 249 $template->assign_block_vars( 250 $blockname, 251 array('SELECTED' => $selected, 252 'VALUE'=> $option, 253 'CONTENT' => l10n($option) 254 )); 255 } 256 257 // Number of items 258 $blockname = 'items_number_option'; 259 260 foreach ($items_number as $option) 261 { 262 $selected = ($option == $page['items_number']) ? 'selected="selected"' : ''; 263 264 $template->assign_block_vars( 265 $blockname, 266 array('SELECTED' => $selected, 267 'VALUE'=> $option, 268 'CONTENT' => is_numeric($option) ? $option : l10n($option) 269 )); 270 } 271 272 // +-----------------------------------------------------------------------+ 273 // | navigation bar | 274 // +-----------------------------------------------------------------------+ 275 276 if (isset($_GET['start']) and is_numeric($_GET['start'])) 277 { 278 $start = $_GET['start']; 279 } 280 else 281 { 282 $start = 0; 283 } 284 285 $query = ' 286 SELECT COUNT(DISTINCT(id)) 287 FROM '.IMAGE_CATEGORY_TABLE.' AS ic 288 INNER JOIN '.COMMENTS_TABLE.' AS com 289 ON ic.image_id = com.image_id 290 WHERE '.$since_options[$page['since']]['clause'].' 291 AND '.$page['cat_clause'].' 292 AND '.$page['author_clause'].' 293 AND '.$page['keyword_clause']; 294 if ($user['forbidden_categories'] != '') 295 { 296 $query.= ' 297 AND category_id NOT IN ('.$user['forbidden_categories'].')'; 298 } 299 $query.= ' 300 ;'; 301 list($counter) = mysql_fetch_row(pwg_query($query)); 302 303 $url = PHPWG_ROOT_PATH.'comments.php?t=1'.get_query_string_diff(array('start')); 304 305 $navbar = create_navigation_bar($url, 306 $counter, 307 $start, 308 $page['items_number'], 309 ''); 310 311 $template->assign_vars(array('NAVBAR' => $navbar)); 312 107 313 // +-----------------------------------------------------------------------+ 108 314 // | last comments display | 109 315 // +-----------------------------------------------------------------------+ 110 // 1. retrieving picture ids which have comments recently added 111 $maxdate = date('Y-m-d', strtotime('-'.MAX_DAYS.' day')); 316 317 $comments = array(); 318 $element_ids = array(); 319 $category_ids = array(); 112 320 113 321 $query = ' 114 SELECT DISTINCT(ic.image_id) AS image_id,ic.category_id, uppercats 115 FROM '.COMMENTS_TABLE.' AS c, '.IMAGE_CATEGORY_TABLE.' AS ic 116 , '.CATEGORIES_TABLE.' AS cat 117 WHERE c.image_id = ic.image_id 118 AND ic.category_id = cat.id 119 AND date >= \''.$maxdate.'\''; 120 if ($user['status'] != 'admin') 121 { 122 $query.= " 123 AND validated = 'true'"; 124 // we must not show pictures of a forbidden category 125 if ($user['forbidden_categories'] != '') 126 { 127 $query.= ' 322 SELECT com.id AS comment_id 323 , com.image_id 324 , ic.category_id 325 , com.author 326 , com.date 327 , com.content 328 , com.id AS comment_id 329 FROM '.IMAGE_CATEGORY_TABLE.' AS ic 330 INNER JOIN '.COMMENTS_TABLE.' AS com 331 ON ic.image_id = com.image_id 332 WHERE '.$since_options[$page['since']]['clause'].' 333 AND '.$page['cat_clause'].' 334 AND '.$page['author_clause'].' 335 AND '.$page['keyword_clause']; 336 if ($user['forbidden_categories'] != '') 337 { 338 $query.= ' 128 339 AND category_id NOT IN ('.$user['forbidden_categories'].')'; 129 }130 340 } 131 341 $query.= ' 132 GROUP BY ic.image_id 133 ORDER BY ic.image_id DESC 342 GROUP BY comment_id 343 ORDER BY '.$page['sort_by'].' '.$page['sort_order']; 344 if ('all' != $page['items_number']) 345 { 346 $query.= ' 347 LIMIT '.$start.','.$page['items_number']; 348 } 349 $query.= ' 134 350 ;'; 135 351 $result = pwg_query($query); 136 if ($user['status'] == 'admin')137 {138 $template->assign_block_vars('validation', array());139 }140 352 while ($row = mysql_fetch_array($result)) 141 353 { 142 $category_id = $row['category_id']; 354 array_push($comments, $row); 355 array_push($element_ids, $row['image_id']); 356 array_push($category_ids, $row['category_id']); 357 } 358 359 if (count($comments) > 0) 360 { 361 // retrieving element informations 362 $elements = array(); 363 $query = ' 364 SELECT id, name, file, path, tn_ext 365 FROM '.IMAGES_TABLE.' 366 WHERE id IN ('.implode(',', $element_ids).') 367 ;'; 368 $result = pwg_query($query); 369 while ($row = mysql_fetch_array($result)) 370 { 371 $elements[$row['id']] = $row; 372 } 373 374 // retrieving category informations 375 $categories = array(); 376 $query = ' 377 SELECT id, uppercats 378 FROM '.CATEGORIES_TABLE.' 379 WHERE id IN ('.implode(',', $category_ids).') 380 ;'; 381 $result = pwg_query($query); 382 while ($row = mysql_fetch_array($result)) 383 { 384 $categories[$row['id']] = $row; 385 } 386 387 foreach ($comments as $comment) 388 { 389 // name of the picture 390 $name = get_cat_display_name_cache( 391 $categories[$comment['category_id']]['uppercats'], '', false); 392 $name.= $conf['level_separator']; 393 if (!empty($elements[$comment['image_id']]['name'])) 394 { 395 $name.= $elements[$comment['image_id']]['name']; 396 } 397 else 398 { 399 $name.= get_name_from_file($elements[$comment['image_id']]['file']); 400 } 401 402 // source of the thumbnail picture 403 $thumbnail_src = get_thumbnail_src( 404 $elements[$comment['image_id']]['path'], 405 @$elements[$comment['image_id']]['tn_ext'] 406 ); 143 407 144 // for each picture, getting informations for displaying thumbnail and 145 // link to the full size picture 146 $query = ' 147 SELECT name,file,storage_category_id as cat_id,tn_ext,path 148 FROM '.IMAGES_TABLE.' 149 WHERE id = '.$row['image_id'].' 150 ;'; 151 $subresult = pwg_query($query); 152 $subrow = mysql_fetch_array($subresult); 153 154 // name of the picture 155 $name = get_cat_display_name_cache($row['uppercats'], '', false); 156 $name.= $conf['level_separator']; 157 if (!empty($subrow['name'])) 158 { 159 $name.= $subrow['name']; 160 } 161 else 162 { 163 $name.= str_replace('_',' ',get_filename_wo_extension($subrow['file'])); 164 } 165 166 // source of the thumbnail picture 167 $thumbnail_src = get_thumbnail_src($subrow['path'], @$subrow['tn_ext']); 168 // link to the full size picture 169 $url = PHPWG_ROOT_PATH.'picture.php?cat='.$category_id; 170 $url.= '&image_id='.$row['image_id']; 408 // link to the full size picture 409 $url = PHPWG_ROOT_PATH.'picture.php?cat='.$comment['category_id']; 410 $url.= '&image_id='.$comment['image_id']; 171 411 172 $template->assign_block_vars(173 'picture',174 array(175 'TITLE_IMG'=>$name,176 'I_THUMB'=>$thumbnail_src,177 'U_THUMB'=>add_session_id($url)178 ));412 $template->assign_block_vars( 413 'picture', 414 array( 415 'TITLE_IMG'=>$name, 416 'I_THUMB'=>$thumbnail_src, 417 'U_THUMB'=>add_session_id($url) 418 )); 179 419 180 // for each picture, retrieving all comments 181 $query = ' 182 SELECT * 183 FROM '.COMMENTS_TABLE.' 184 WHERE image_id = '.$row['image_id'].' 185 AND date >= \''.$maxdate.'\''; 186 if ($user['status'] != 'admin') 187 { 188 $query.= ' 189 AND validated = \'true\''; 190 } 191 $query.= ' 192 ORDER BY date DESC 193 ;'; 194 $handleresult = pwg_query($query); 195 while ($subrow = mysql_fetch_array($handleresult)) 196 { 197 $author = $subrow['author']; 198 if (empty($subrow['author'])) 420 $author = $comment['author']; 421 if (empty($comment['author'])) 199 422 { 200 $author = $lang['guest'];423 $author = l10n('guest'); 201 424 } 202 425 203 426 $template->assign_block_vars( 204 427 'picture.comment', 205 428 array( 206 'COMMENT_AUTHOR' =>$author,207 'COMMENT_DATE'=>format_date($ subrow['date'],'mysql_datetime',true),208 'COMMENT'=>parse_comment_content($ subrow['content']),429 'COMMENT_AUTHOR' => $author, 430 'COMMENT_DATE'=>format_date($comment['date'],'mysql_datetime',true), 431 'COMMENT'=>parse_comment_content($comment['content']), 209 432 )); 210 211 if ($user['status'] == 'admin')212 {213 $template->assign_block_vars(214 'picture.comment.validation',215 array(216 'ID'=> $subrow['id'],217 'CHECKED'=>($subrow['validated']=='false')?'checked="checked"': ''218 ));219 }220 433 } 221 434 } -
trunk/doc/ChangeLog
r794 r796 1 2005-06-21 Pierrick LE GALL 2 3 * comments page rewritten : comments are displayed one by one, 4 with filters and display options available. The list of comments 5 is paginated. 6 1 7 2005-06-21 Pierrick LE GALL 2 8 -
trunk/language/en_UK.iso-8859-1/common.lang.php
r774 r796 307 307 $lang['hello'] = 'Hello'; 308 308 309 $lang['today'] = 'today'; 310 $lang['last %d days'] = 'last %d days'; 311 $lang['the beginning'] = 'the beginning'; 312 313 $lang['comment date'] = 'comment date'; 314 $lang['image'] = 'image'; 315 $lang['descending'] = 'descending'; 316 $lang['ascending'] = 'ascending'; 317 $lang['all'] = 'all'; 318 $lang['Filter'] = 'Filter'; 319 $lang['Keyword'] = 'Keyword'; 320 $lang['Author'] = 'Author'; 321 $lang['Category'] = 'Category'; 322 $lang['Since'] = 'Since'; 323 $lang['Display'] = 'Display'; 324 $lang['Sort by'] = 'Sort by'; 325 $lang['Sort order'] = 'Sort order'; 326 $lang['Number of items'] = 'Number of items'; 327 $lang['return to homepage'] = 'return to homepage'; 328 $lang['Filter and display'] = 'Filter and display'; 309 329 ?> -
trunk/language/fr_FR.iso-8859-1/common.lang.php
r774 r796 310 310 $lang['update_wrong_dirname'] = 'Le nom des fichiers et répertoires ne doivent être composé que de lettres, de chiffres et "-", "_" ou ".".'; 311 311 $lang['hello'] = 'Bonjour'; 312 313 $lang['today'] = 'aujourd\'hui'; 314 $lang['last %d days'] = 'les %d derniers jours'; 315 $lang['the beginning'] = 'le début'; 316 $lang['comment date'] = 'date du commentaire'; 317 $lang['image'] = 'image'; 318 $lang['descending'] = 'décroissant'; 319 $lang['ascending'] = 'croissant'; 320 $lang['all'] = 'tout'; 321 $lang['Filter'] = 'Filtre'; 322 $lang['Keyword'] = 'Mot-Clef'; 323 $lang['Author'] = 'Auteur'; 324 $lang['Category'] = 'Catégorie'; 325 $lang['Since'] = 'Depuis'; 326 $lang['Display'] = 'Affichage'; 327 $lang['Sort by'] = 'Trier par'; 328 $lang['Sort order'] = 'Ordre'; 329 $lang['Number of items'] = 'Nombre d\'éléments'; 330 $lang['return to homepage'] = 'retourner à la page d\'accueil'; 331 $lang['Filter and display'] = 'Filtrer et afficher'; 312 332 ?> -
trunk/template/default/comments.tpl
r607 r796 2 2 <div class="titrePage">{L_COMMENT_TITLE}</div> 3 3 <!-- END title --> 4 <div class="admin"> 5 [ 6 <!-- BEGIN last_day_option --> 7 <a class="admin" href="{last_day_option.U_OPTION}" style="{last_day_option.T_STYLE}">{last_day_option.OPTION}</a>{T_SEPARATION} 8 <!-- END last_day_option --> 9 {L_COMMENT_STATS} 10 ] 11 <!-- BEGIN title --> 12 [ <a class="admin" href="{U_HOME}" title="{L_COMMENT_RETURN_HINT}">{L_COMMENT_RETURN}</a> ] 13 <!-- END title --> 14 </div> 4 5 <form class="filter" action="{F_ACTION}" method="get"> 6 7 <fieldset> 8 <legend>{lang:Filter}</legend> 9 10 <label>{lang:Keyword}<input type="text" name="keyword" value="{F_KEYWORD}" /></label> 11 12 <label>{lang:Author}<input type="text" name="author" value="{F_AUTHOR}" /></label> 13 14 <label> 15 {lang:Category} 16 <select name="cat"> 17 <!-- BEGIN category --> 18 <option class="{category.CLASS}" {category.SELECTED} value="{category.VALUE}">{category.OPTION}</option> 19 <!-- END category --> 20 </select> 21 </label> 22 23 <label> 24 {lang:Since} 25 <select name="since"> 26 <!-- BEGIN since_option --> 27 <option {since_option.SELECTED} value="{since_option.VALUE}">{since_option.CONTENT}</option> 28 <!-- END since_option --> 29 </select> 30 </label> 31 32 </fieldset> 33 34 <fieldset> 35 36 <legend>{lang:Display}</legend> 37 38 <label> 39 {lang:Sort by} 40 <select name="sort_by"> 41 <!-- BEGIN sort_by_option --> 42 <option value="{sort_by_option.VALUE}" {sort_by_option.SELECTED} >{sort_by_option.CONTENT}</option> 43 <!-- END sort_by_option --> 44 </select> 45 </label> 46 47 <label> 48 {lang:Sort order} 49 <select name="sort_order"> 50 <!-- BEGIN sort_order_option --> 51 <option value="{sort_order_option.VALUE}" {sort_order_option.SELECTED} >{sort_order_option.CONTENT}</option> 52 <!-- END sort_order_option --> 53 </select> 54 </label> 55 56 <label> 57 {lang:Number of items} 58 <select name="items_number"> 59 <!-- BEGIN items_number_option --> 60 <option value="{items_number_option.VALUE}" {items_number_option.SELECTED} >{items_number_option.CONTENT}</option> 61 <!-- END items_option --> 62 </select> 63 </label> 64 65 </fieldset> 66 67 <input type="submit" name="submit" value="{lang:Filter and display}" /> 68 69 </form> 70 71 <div class="navigationBar">{NAVBAR}</div> 72 <a class="admin" href="{U_HOME}" title="{lang:return to homepage}">{lang:home}</a> 73 15 74 <!-- BEGIN validation --> 16 75 <form action="{F_ACTION}" method="post"> … … 51 110 <!-- BEGIN validation --> 52 111 <div align="center"> 53 <input type="submit" name="validate" class="bouton" value="{ L_VALIDATE}" />54 <input type="submit" name="delete" class="bouton" value="{ L_DELETE}" />112 <input type="submit" name="validate" class="bouton" value="{lang:submit}" /> 113 <input type="submit" name="delete" class="bouton" value="{lang:delete}" /> 55 114 </div> 56 115 </form> -
trunk/template/default/default.css
r792 r796 414 414 padding: 10px 50px 10px 10px; 415 415 } 416 417 /** 418 * Filter forms are displayed label by label with the input (or select...) 419 * below the label 420 */ 421 form.filter FIELDSET { 422 padding: 10px; 423 } 424 425 form.filter FIELDSET LABEL { 426 display: block; 427 float: left; 428 width: auto; 429 margin-right: 10px; 430 padding: 0; 431 } 432 433 form.filter FIELDSET INPUT, form.filter FIELDSET SELECT { 434 display: block; 435 } 436 437 form.filter FIELDSET P { 438 clear: left; 439 } 440 441 form.filter FIELDSET { 442 border: 1px solid gray; 443 } 444 445 form.filter FIELDSET + INPUT { 446 margin-top: 10px; 447 }
Note: See TracChangeset
for help on using the changeset viewer.