Changeset 1598 for trunk


Ignore:
Timestamp:
Nov 8, 2006, 5:28:30 AM (18 years ago)
Author:
rvelices
Message:
  • comments.php improvements:
    • unvalidated comments are shown only for administrators
    • added delete/validate icons for admins
    • removed some unused code
  • display of comment content performed through an event
  • replace some get_thumbnail_src with get_thumbnail_url
Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/comments.php

    r1571 r1598  
    4848
    4949  if (isset($_POST['submit']) and !is_adviser())
    50   {   
     50  {
    5151    foreach (explode(',', $_POST['list']) as $comment_id)
    5252    {
     
    142142;';
    143143$result = pwg_query($query);
    144 while ($row = mysql_fetch_array($result))
     144while ($row = mysql_fetch_assoc($result))
    145145{
     146  $thumb = get_thumbnail_url(
     147      array(
     148        'id'=>$row['image_id'],
     149        'path'=>$row['path'],
     150        'tn_ext'=>@$row['tn_ext']
     151        )
     152     );
    146153  $template->assign_block_vars(
    147154    'comment',
     
    151158          '&image_id='.$row['image_id'],
    152159      'ID' => $row['id'],
    153       'TN_SRC' => get_thumbnail_src($row['path'], @$row['tn_ext']),
     160      'TN_SRC' => $thumb,
    154161      'AUTHOR' => $row['author'],
    155162      'DATE' => format_date($row['date'],'mysql_datetime',true),
    156       'CONTENT' => parse_comment_content($row['content'])
     163      'CONTENT' => trigger_event('render_comment_content',$row['content'])
    157164      )
    158165    );
  • trunk/comments.php

    r1563 r1598  
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
    8 // | file          : $RCSfile$
     8// | file          : $Id$
    99// | last update   : $Date$
    1010// | last modifier : $Author$
     
    2929// |                           initialization                              |
    3030// +-----------------------------------------------------------------------+
    31 if (!defined('IN_ADMIN'))
    32 {
    33   define('PHPWG_ROOT_PATH','./');
    34   include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
    35 }
     31define('PHPWG_ROOT_PATH','./');
     32include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
    3633
    3734// +-----------------------------------------------------------------------+
     
    145142}
    146143
     144// which status to filter on ?
     145if ( is_admin() )
     146{
     147  $page['status_clause'] = '1=1';
     148}
     149else
     150{
     151  $page['status_clause'] = 'validated="true"';
     152}
     153
     154
    147155// +-----------------------------------------------------------------------+
    148156// |                         comments management                           |
    149157// +-----------------------------------------------------------------------+
    150 // comments deletion
    151 if (isset($_POST['delete']) and count($_POST['comment_id']) > 0 and is_admin())
    152 {
    153   $_POST['comment_id'] = array_map('intval', $_POST['comment_id']);
    154   $query = '
     158if (is_admin() and !is_adviser() )
     159{
     160  if (isset($_GET['delete']) and is_numeric($_GET['delete']) )
     161  {// comments deletion
     162    $query = '
    155163DELETE FROM '.COMMENTS_TABLE.'
    156   WHERE id IN ('.implode(',', $_POST['comment_id']).')
    157 ;';
    158   pwg_query($query);
    159 }
    160 // comments validation
    161 if (isset($_POST['validate']) and count($_POST['comment_id']) > 0
    162    and is_admin())
    163 {
    164   $_POST['comment_id'] = array_map('intval', $_POST['comment_id']);
    165   $query = '
     164  WHERE id='.$_GET['delete'].'
     165;';
     166    pwg_query($query);
     167  }
     168
     169  if (isset($_GET['validate']) and is_numeric($_GET['validate']) )
     170  {  // comments validation
     171    $query = '
    166172UPDATE '.COMMENTS_TABLE.'
    167173  SET validated = \'true\'
    168174    , validation_date = NOW()
    169   WHERE id IN ('.implode(',', $_POST['comment_id']).')
    170 ;';
    171   pwg_query($query);
     175  WHERE id='.$_GET['validate'].'
     176;';
     177    pwg_query($query);
     178  }
    172179}
    173180// +-----------------------------------------------------------------------+
     
    299306    AND '.$page['cat_clause'].'
    300307    AND '.$page['author_clause'].'
    301     AND '.$page['keyword_clause'];
     308    AND '.$page['keyword_clause'].'
     309    AND '.$page['status_clause'];
    302310if ($user['forbidden_categories'] != '')
    303311{
     
    309317list($counter) = mysql_fetch_row(pwg_query($query));
    310318
    311 $url = PHPWG_ROOT_PATH.'comments.php'.get_query_string_diff(array('start'));
     319$url = PHPWG_ROOT_PATH
     320    .'comments.php'
     321    .get_query_string_diff(array('start','delete','validate'));
    312322
    313323$navbar = create_navigation_bar($url,
     
    335345     , com.content
    336346     , com.id AS comment_id
     347     , com.validated
    337348  FROM '.IMAGE_CATEGORY_TABLE.' AS ic
    338349    INNER JOIN '.COMMENTS_TABLE.' AS com
     
    341352    AND '.$page['cat_clause'].'
    342353    AND '.$page['author_clause'].'
    343     AND '.$page['keyword_clause'];
     354    AND '.$page['keyword_clause'].'
     355    AND '.$page['status_clause'];
    344356if ($user['forbidden_categories'] != '')
    345357{
     
    358370;';
    359371$result = pwg_query($query);
    360 while ($row = mysql_fetch_array($result))
     372while ($row = mysql_fetch_assoc($result))
    361373{
    362374  array_push($comments, $row);
     
    375387;';
    376388  $result = pwg_query($query);
    377   while ($row = mysql_fetch_array($result))
     389  while ($row = mysql_fetch_assoc($result))
    378390  {
    379391    $elements[$row['id']] = $row;
     
    388400;';
    389401  $result = pwg_query($query);
    390   while ($row = mysql_fetch_array($result))
     402  while ($row = mysql_fetch_assoc($result))
    391403  {
    392404    $categories[$row['id']] = $row;
     
    395407  foreach ($comments as $comment)
    396408  {
    397     // name of the picture
    398     $name = get_cat_display_name_cache(
    399       $categories[$comment['category_id']]['uppercats'], null, false);
    400     $name.= $conf['level_separator'];
    401409    if (!empty($elements[$comment['image_id']]['name']))
    402410    {
    403       $name.= $elements[$comment['image_id']]['name'];
     411      $name=$elements[$comment['image_id']]['name'];
    404412    }
    405413    else
    406414    {
    407       $name.= get_name_from_file($elements[$comment['image_id']]['file']);
     415      $name=get_name_from_file($elements[$comment['image_id']]['file']);
    408416    }
    409417
    410418    // source of the thumbnail picture
    411     $thumbnail_src = get_thumbnail_src(
    412       $elements[$comment['image_id']]['path'],
    413       @$elements[$comment['image_id']]['tn_ext']
    414       );
     419    $thumbnail_src = get_thumbnail_url( $elements[$comment['image_id']] );
    415420
    416421    // link to the full size picture
     
    424429          );
    425430
    426     $template->assign_block_vars(
    427       'picture',
    428       array(
    429         'TITLE_IMG'=>$name,
    430         'I_THUMB'=>$thumbnail_src,
    431         'U_THUMB'=>$url
    432         ));
    433 
    434431    $author = $comment['author'];
    435432    if (empty($comment['author']))
     
    443440        'U_PICTURE' => $url,
    444441        'TN_SRC' => $thumbnail_src,
     442        'ALT' => $name,
    445443        'AUTHOR' => $author,
    446444        'DATE'=>format_date($comment['date'],'mysql_datetime',true),
    447         'CONTENT'=>parse_comment_content($comment['content']),
     445        'CONTENT'=>trigger_event('render_comment_content',$comment['content']),
    448446        ));
     447
     448    if ( is_admin() )
     449    {
     450      $url = get_root_url().'comments.php'.get_query_string_diff(array('delete','validate'));
     451      $template->assign_block_vars(
     452        'comment.action_delete',
     453        array(
     454          'U_DELETE' => add_url_params($url,
     455                          array('delete'=>$comment['comment_id'])
     456                         ),
     457          ));
     458      if ($comment['validated'] != 'true')
     459      {
     460        $template->assign_block_vars(
     461          'comment.action_validate',
     462          array(
     463            'U_VALIDATE' => add_url_params($url,
     464                            array('validate'=>$comment['comment_id'])
     465                           ),
     466            ));
     467      }
     468    }
    449469  }
    450470}
     
    452472// |                           html code display                           |
    453473// +-----------------------------------------------------------------------+
    454 if (defined('IN_ADMIN'))
    455 {
    456   $template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
    457 }
    458 else
    459 {
    460   $template->assign_block_vars('title',array());
    461   $template->parse('comments');
    462   include(PHPWG_ROOT_PATH.'include/page_tail.php');
    463 }
     474$template->assign_block_vars('title',array());
     475$template->parse('comments');
     476include(PHPWG_ROOT_PATH.'include/page_tail.php');
    464477?>
  • trunk/include/common.inc.php

    r1578 r1598  
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
    8 // | file          : $RCSfile$
     8// | file          : $Id$
    99// | last update   : $Date$
    1010// | last modifier : $Author$
     
    229229  }
    230230}
     231
     232// default event handlers
     233add_event_handler('render_comment_content', 'parse_comment_content');
     234trigger_action('init');
    231235?>
  • trunk/include/picture_comment.inc.php

    r1503 r1598  
    177177            true),
    178178
    179           'COMMENT' => parse_comment_content($row['content']),
     179          'COMMENT' => trigger_event('render_comment_content',$row['content']),
    180180          )
    181181        );
  • trunk/template/yoga/comments.tpl

    r960 r1598  
    7171  </fieldset>
    7272
    73   <p><input type="submit" name="submit" value="{lang:Filter and display}"></p>
     73  <p><input type="submit" value="{lang:Filter and display}"></p>
    7474
    7575</form>
     
    8181  <!-- BEGIN comment -->
    8282  <div class="comment">
    83     <a class="illustration" href="{comment.U_PICTURE}"><img src="{comment.TN_SRC}" /></a>
    84     <p class="commentHeader"><span class="author">{comment.AUTHOR}</span> - <span class="date">{comment.DATE}</span></p>
     83    <a class="illustration" href="{comment.U_PICTURE}"><img src="{comment.TN_SRC}" alt="{comment.ALT}" /></a>
     84    <p class="commentHeader"><span class="author">{comment.AUTHOR}</span> - <span class="date">{comment.DATE}</span>
     85    <!-- BEGIN action_delete -->
     86    <a href="{comment.action_delete.U_DELETE}" title="{lang:comments_del}">
     87      <img src="{pwg_root}{themeconf:icon_dir}/delete.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[{lang:delete}]"/>
     88    </a>
     89    <!-- END action_delete -->
     90    <!-- BEGIN action_validate -->
     91    <a href="{comment.action_validate.U_VALIDATE}" title="validate this comment">
     92      <img src="{pwg_root}{themeconf:icon_dir}/validate_s.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[validate]"/>
     93    </a>
     94    <!-- END action_validate -->
     95    </p>
    8596    <blockquote>{comment.CONTENT}</blockquote>
    8697    <hr class="separation">
Note: See TracChangeset for help on using the changeset viewer.