Changeset 26089


Ignore:
Timestamp:
Dec 22, 2013, 8:30:51 PM (7 years ago)
Author:
mistic100
Message:

update for 2.6 + clean

Location:
extensions/Comments_on_Albums/trunk
Files:
2 added
5 deleted
8 edited
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/Comments_on_Albums/trunk/admin.php

    r23490 r26089  
    11<?php
    22/* Code adapted from admin/comments.php */
    3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    4 
    5 global $template, $conf, $user;
    6 load_language('plugin.lang', COA_PATH);
    7 
    8 // +-----------------------------------------------------------------------+
    9 // |                               tabsheet                                |
    10 // +-----------------------------------------------------------------------+
    11 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    12 
    13 if (isset($_GET['section']) and $_GET['section'] == 'albums')
    14 {
    15   $page['tab'] = 'albums';
    16 }
    17 else
    18 {
    19   $page['tab'] = 'pictures';
    20 }
    21 
    22 $tabsheet = new tabsheet();
    23 $tabsheet->add('pictures', l10n('Comments on photos'), get_root_url().'admin.php?page=comments');
    24 $tabsheet->add('albums', l10n('Comments on albums'), get_root_url().'admin.php?page=comments&amp;section=albums');
    25 $tabsheet->select($page['tab']);
    26 $tabsheet->assign();
    27 
    28 
    29 if ($page['tab'] == 'albums')
    30 {
    31   // clear template sended by original page
    32   $template->clear_assign(array('ADMIN_CONTENT', 'comments', 'LIST', 'F_ACTION'));
    33 
    34   // +-----------------------------------------------------------------------+
    35   // |                                actions                                |
    36   // +-----------------------------------------------------------------------+
    37   if (!empty($_POST))
    38   {
    39     if (empty($_POST['comments']))
     3defined('COA_ID') or die('Hacking attempt!');
     4
     5$page['active_menu'] = get_active_menu('comments');
     6
     7include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     8
     9if (isset($_GET['start']) and is_numeric($_GET['start']))
     10{
     11  $page['start'] = $_GET['start'];
     12}
     13else
     14{
     15  $page['start'] = 0;
     16}
     17
     18// +-----------------------------------------------------------------------+
     19// | Check Access and exit when user status is not ok                      |
     20// +-----------------------------------------------------------------------+
     21
     22check_status(ACCESS_ADMINISTRATOR);
     23
     24// +-----------------------------------------------------------------------+
     25// |                                actions                                |
     26// +-----------------------------------------------------------------------+
     27if (!empty($_POST))
     28{
     29  if (empty($_POST['comments']))
     30  {
     31    $page['errors'][] = l10n('Select at least one comment');
     32  }
     33  else
     34  {
     35    include_once(COA_PATH.'include/functions_comment.inc.php');
     36    check_input_parameter('comments', $_POST, true, PATTERN_ID);
     37
     38    if (isset($_POST['validate']))
    4039    {
    41       array_push(
    42         $page['errors'],
    43         l10n('Select at least one comment')
     40      validate_user_comment_albums($_POST['comments']);
     41
     42      $page['infos'][] = l10n_dec(
     43        '%d user comment validated', '%d user comments validated',
     44        count($_POST['comments'])
    4445        );
    4546    }
    46     else
     47
     48    if (isset($_POST['reject']))
    4749    {
    48       include_once(COA_PATH.'include/functions_comment.inc.php'); // custom functions
    49       check_input_parameter('comments', $_POST, true, PATTERN_ID);
    50 
    51       if (isset($_POST['validate_albums']))
    52       {
    53         validate_user_comment_albums($_POST['comments']);
    54 
    55         array_push(
    56           $page['infos'],
    57           l10n_dec(
    58             '%d user comment validated', '%d user comments validated',
    59             count($_POST['comments'])
    60             )
    61           );
    62       }
    63 
    64       if (isset($_POST['reject_albums']))
    65       {
    66         delete_user_comment_albums($_POST['comments']);
    67 
    68         array_push(
    69           $page['infos'],
    70           l10n_dec(
    71             '%d user comment rejected', '%d user comments rejected',
    72             count($_POST['comments'])
    73             )
    74           );
    75       }
     50      delete_user_comment_albums($_POST['comments']);
     51
     52      $page['infos'][] = l10n_dec(
     53        '%d user comment rejected', '%d user comments rejected',
     54        count($_POST['comments'])
     55        );
    7656    }
    7757  }
    78 
    79   // +-----------------------------------------------------------------------+
    80   // |                             template init                             |
    81   // +-----------------------------------------------------------------------+
    82 
    83   $template->set_filename('comments', dirname(__FILE__) .'/../template/admin_comments.tpl');
    84 
    85   $template->assign(
    86     array(
    87       'F_ACTION' => get_root_url().'admin.php?page=comments&amp;section=albums'
    88       )
    89     );
    90    
    91   if (count($page['infos']) != 0)
    92   {
    93     $template->assign('infos', $page['infos']);
    94   }
    95 
    96   // +-----------------------------------------------------------------------+
    97   // |                           comments display                            |
    98   // +-----------------------------------------------------------------------+
    99   $list = array();
    100 
    101   $query = '
    102 SELECT
    103     com.id,
    104     com.category_id,
    105     com.date,
     58}
     59
     60// +-----------------------------------------------------------------------+
     61// |                             template init                             |
     62// +-----------------------------------------------------------------------+
     63
     64$template->set_filename('comments', 'comments.tpl');
     65$template->set_prefilter('comments', 'coa_admin_add_category_name');
     66
     67$template->assign('F_ACTION', COA_ADMIN);
     68
     69// +-----------------------------------------------------------------------+
     70// | Tabs                                                                  |
     71// +-----------------------------------------------------------------------+
     72
     73include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
     74
     75$tabsheet = new tabsheet();
     76$tabsheet->set_id('comments');
     77$tabsheet->select('albums');
     78$tabsheet->assign();
     79
     80// +-----------------------------------------------------------------------+
     81// |                           comments display                            |
     82// +-----------------------------------------------------------------------+
     83
     84$nb_total = 0;
     85$nb_pending = 0;
     86
     87$query = '
     88SELECT
     89    COUNT(*) AS counter,
     90    validated
     91  FROM '.COA_TABLE.'
     92  GROUP BY validated
     93;';
     94$result = pwg_query($query);
     95while ($row = pwg_db_fetch_assoc($result))
     96{
     97  $nb_total+= $row['counter'];
     98
     99  if ('false' == $row['validated'])
     100  {
     101    $nb_pending = $row['counter'];
     102  }
     103}
     104
     105if (!isset($_GET['filter']) and $nb_pending > 0)
     106{
     107  $page['filter'] = 'pending';
     108}
     109else
     110{
     111  $page['filter'] = 'all';
     112}
     113
     114if (isset($_GET['filter']) and 'pending' == $_GET['filter'])
     115{
     116  $page['filter'] = 'pending';
     117}
     118
     119$template->assign(
     120  array(
     121    'nb_total' => $nb_total,
     122    'nb_pending' => $nb_pending,
     123    'filter' => $page['filter'],
     124    )
     125  );
     126
     127$where_clauses = array('1=1');
     128
     129if ('pending' == $page['filter'])
     130{
     131  $where_clauses[] = 'validated=\'false\'';
     132}
     133
     134$query = '
     135SELECT
     136    com.id,
     137    com.category_id,
     138    com.date,
    106139    com.author,
    107     u.'.$conf['user_fields']['username'].' AS username, 
    108     com.content, 
     140    u.'.$conf['user_fields']['username'].' AS username,
     141    com.content,
    109142    cat.name,
    110143    img.id AS image_id,
    111     img.path
     144    img.path,
     145    com.validated
    112146  FROM '.COA_TABLE.' AS com
    113147    LEFT JOIN '.CATEGORIES_TABLE.' AS cat
     
    115149    LEFT JOIN '.USERS_TABLE.' AS u
    116150      ON u.'.$conf['user_fields']['id'].' = com.author_id
    117     LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc 
     151    LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc
    118152      ON ucc.cat_id = com.category_id AND ucc.user_id = '.$user['id'].'
    119153    LEFT JOIN '.IMAGES_TABLE.' AS img
    120154      ON img.id = ucc.user_representative_picture_id
    121   WHERE validated = \'false\'
     155  WHERE '.implode(' AND ', $where_clauses).'
    122156  ORDER BY com.date DESC
     157  LIMIT '.$page['start'].', '.$conf['comments_page_nb_comments'].'
    123158;';
    124   $result = pwg_query($query);
    125 
    126   while ($row = pwg_db_fetch_assoc($result))
    127   {
    128     // author
    129     if (empty($row['author_id']))
    130     {
    131       $author_name = $row['author'];
    132     }
    133     else
    134     {
    135       $author_name = stripslashes($row['username']);
    136     }
    137    
    138     // thumbnail
    139     $row['thumb'] = DerivativeImage::thumb_url(
    140       array(
    141         'id'=>$row['image_id'],
    142         'path'=>$row['path'],
    143         )
    144      );
    145 
    146     // comment content
    147     $template->append(
    148       'comments',
    149       array(
    150         'ID' => $row['id'],
    151         'CAT_URL' => PHPWG_ROOT_PATH.'admin.php?page=album-'.$row['category_id'],
    152         'CAT_NAME' => trigger_event('render_category_name', $row['name']),
    153         'TN_SRC' => $row['thumb'],
    154         'AUTHOR' => trigger_event('render_comment_author', $author_name),
    155         'DATE' => format_date($row['date'], true),
    156         'CONTENT' => trigger_event('render_comment_content', $row['content'], 'album'),
    157         )
    158       );
    159 
    160     array_push($list, $row['id']);
    161   }
    162 
    163   $template->assign('LIST', implode(',', $list));
    164 
    165   // +-----------------------------------------------------------------------+
    166   // |                           sending html code                           |
    167   // +-----------------------------------------------------------------------+
    168 
    169   $template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
    170 
    171 }
    172 
    173 ?>
     159$result = pwg_query($query);
     160
     161while ($row = pwg_db_fetch_assoc($result))
     162{
     163  $thumb = DerivativeImage::thumb_url(
     164    array(
     165      'id'=>$row['image_id'],
     166      'path'=>$row['path'],
     167      )
     168   );
     169
     170  if (empty($row['author_id']))
     171  {
     172    $author_name = $row['author'];
     173  }
     174  else
     175  {
     176    $author_name = stripslashes($row['username']);
     177  }
     178
     179  $template->append(
     180    'comments',
     181    array(
     182      'ID' => $row['id'],
     183      'U_PICTURE' => get_root_url().'admin.php?page=album-'.$row['category_id'],
     184      'CATEGORY_NAME' => trigger_change('render_category_name', $row['name']),
     185      'TN_SRC' => $thumb,
     186      'AUTHOR' => trigger_change('render_comment_author', $author_name),
     187      'DATE' => format_date($row['date'], true),
     188      'CONTENT' => trigger_change('render_comment_content', $row['content'], 'album'),
     189      'IS_PENDING' => ('false' == $row['validated']),
     190      )
     191    );
     192}
     193
     194// +-----------------------------------------------------------------------+
     195// |                            navigation bar                             |
     196// +-----------------------------------------------------------------------+
     197
     198$navbar = create_navigation_bar(
     199  get_root_url().'admin.php'.get_query_string_diff(array('start')),
     200  ('pending' == $page['filter'] ? $nb_pending : $nb_total),
     201  $page['start'],
     202  $conf['comments_page_nb_comments']
     203  );
     204
     205$template->assign('navbar', $navbar);
     206
     207// +-----------------------------------------------------------------------+
     208// |                           sending html code                           |
     209// +-----------------------------------------------------------------------+
     210
     211$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
     212
     213
     214function coa_admin_add_category_name($content)
     215{
     216  $search = '<img src="{$comment.TN_SRC}">';
     217  $add = '<br>{$comment.CATEGORY_NAME}';
     218  return str_replace($search, $search.$add, $content);
     219}
  • extensions/Comments_on_Albums/trunk/include/coa_albums.php

    r21347 r26089  
    11<?php
    22/* Code adapted from include/picture_comment.inc.php and picture.php */
    3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    4 
    5 global $conf, $user;
     3defined('COA_ID') or die('Hacking attempt!');
     4
     5global $template, $page, $conf, $pwg_loaded_plugins, $user;
    66
    77// +-----------------------------------------------------------------------+
     
    1212$url_self = duplicate_index_url(array(
    1313  'category' => array(
    14     'id' => $category['id'], 
    15     'name' => $category['name'], 
     14    'id' => $category['id'],
     15    'name' => $category['name'],
    1616    'permalink' => $category['permalink']
    17     ), 
     17    ),
    1818  array('start')
    1919  ));
     
    2323// |                                actions                                |
    2424// +-----------------------------------------------------------------------+
    25 if (isset($_GET['action'])) 
     25if (isset($_GET['action']))
    2626{
    27   switch ($_GET['action']) 
    28   {
    29     case 'edit_comment' : 
    30     {
    31       include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions
     27  switch ($_GET['action'])
     28  {
     29    case 'edit_comment' :
     30    {
     31      include_once(COA_PATH.'include/functions_comment.inc.php');
    3232      check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID);
    3333      $author_id = get_comment_author_id_albums($_GET['comment_to_edit']);
    3434
    35       if (can_manage_comment('edit', $author_id)) 
    36       {
    37         if (!empty($_POST['content'])) 
     35      if (can_manage_comment('edit', $author_id))
     36      {
     37        if (!empty($_POST['content']))
    3838        {
    3939          check_pwg_token();
     
    4242              'comment_id' => $_GET['comment_to_edit'],
    4343              'category_id' => $category['id'],
    44               'content' => $_POST['content']
     44              'content' => $_POST['content'],
     45              'website_url' => @$_POST['website_url'],
    4546              ),
    4647            $_POST['key']
    4748            );
    48          
     49
    4950          $perform_redirect = false;
    5051          switch ($comment_action)
     
    6970          }
    7071          unset($_POST['content']);
    71         } 
    72         else 
     72        }
     73        else
    7374        {
    7475          $edit_comment = $_GET['comment_to_edit'];
    7576        }
     77
     78        $template->assign('DISPLAY_COMMENTS_BLOCK', true);
    7679        break;
    7780      }
    7881    }
    79     case 'delete_comment' : 
     82    case 'delete_comment' :
    8083    {
    8184      check_pwg_token();
    82      
    83       include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions
    84      
     85
     86      include_once(COA_PATH.'include/functions_comment.inc.php');
     87
    8588      check_input_parameter('comment_to_delete', $_GET, false, PATTERN_ID);
    86      
     89
    8790      $author_id = get_comment_author_id_albums($_GET['comment_to_delete']);
    8891
    89       if (can_manage_comment('delete', $author_id)) 
     92      if (can_manage_comment('delete', $author_id))
    9093      {
    9194        delete_user_comment_albums($_GET['comment_to_delete']);
     
    9497      redirect($url_self);
    9598    }
    96     case 'validate_comment' : 
     99    case 'validate_comment' :
    97100    {
    98101      check_pwg_token();
    99      
    100       include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions
    101      
     102
     103      include_once(COA_PATH.'include/functions_comment.inc.php');
     104
    102105      check_input_parameter('comment_to_validate', $_GET, false, PATTERN_ID);
    103      
     106
    104107      $author_id = get_comment_author_id_albums($_GET['comment_to_validate']);
    105108
    106       if (can_manage_comment('validate', $author_id)) 
     109      if (can_manage_comment('validate', $author_id))
    107110      {
    108111        validate_user_comment_albums($_GET['comment_to_validate']);
     
    118121// |                            insert comment                             |
    119122// +-----------------------------------------------------------------------+
    120 if ($category['commentable'] and isset($_POST['content'])) 
     123if ($category['commentable'] and isset($_POST['content']))
    121124{
    122   if (is_a_guest() and !$conf['comments_forall']) 
     125  if (is_a_guest() and !$conf['comments_forall'])
    123126  {
    124127    die('Session expired');
    125128  }
    126  
     129
    127130  $comm = array(
    128131    'author' => trim( @$_POST['author'] ),
     
    133136   );
    134137
    135   include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions
    136  
     138  include_once(COA_PATH.'include/functions_comment.inc.php');
     139
    137140  $comment_action = insert_user_comment_albums($comm, @$_POST['key'], $page['errors']);
    138141
    139   switch ($comment_action) 
     142  switch ($comment_action)
    140143  {
    141144    case 'moderate':
    142       array_push($page['infos'], l10n('An administrator must authorize your comment before it is visible.'));
     145      $page['infos'][] = l10n('An administrator must authorize your comment before it is visible.');
    143146    case 'validate':
    144       array_push($page['infos'], l10n('Your comment has been registered'));
     147      $page['infos'][] = l10n('Your comment has been registered');
    145148      break;
    146149    case 'reject':
    147150      set_status_header(403);
    148       array_push($page['errors'], l10n('Your comment has NOT been registered because it did not pass the validation rules'));
     151      $page['errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules');
    149152      break;
    150153    default:
    151154      trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
    152155  }
    153    
     156
    154157  // allow plugins to notify what's going on
    155158  trigger_action( 'user_comment_insertion',
    156159      array_merge($comm, array('action'=>$comment_action) )
    157160    );
    158    
     161
    159162  $template->assign('DISPLAY_COMMENTS_BLOCK', true);
    160 } 
    161 else if (isset($_POST['content'])) 
     163}
     164else if (isset($_POST['content']))
    162165{
    163166  set_status_header(403);
     
    169172// |                           display comments                            |
    170173// +-----------------------------------------------------------------------+
    171 if ($category['commentable']) 
     174if ($category['commentable'])
    172175{
    173   if (!is_admin())
     176  if (isset($_GET['coa_open']))
     177  {
     178    $template->assign('DISPLAY_COMMENTS_BLOCK', true);
     179  }
     180
     181  if (!is_admin())
    174182  {
    175183    $validated_clause = " AND validated = 'true'";
    176   } 
    177   else 
     184  }
     185  else
    178186  {
    179187    $validated_clause = null;
     
    182190  // number of comments for this category
    183191  $query = '
    184 SELECT 
     192SELECT
    185193    COUNT(*) AS nb_comments
    186194  FROM '.COA_TABLE.'
     
    190198  $row = pwg_db_fetch_assoc(pwg_query($query));
    191199
    192   // navigation bar creation, can't use $_GET['start'] because used by thumbnails navigation bar
    193   if (isset($_GET['start_comments']))
     200  // navigation bar creation
     201  // can't use $_GET['start'] because used by thumbnails navigation bar
     202  if (isset($_GET['start_comments']))
    194203  {
    195204    $page['start_comments'] = $_GET['start_comments'];
    196   } 
    197   else 
     205  }
     206  else
    198207  {
    199208    $page['start_comments'] = 0;
    200209  }
    201   include_once(COA_PATH.'include/functions.inc.php'); // custom fonctions
    202 
    203   $navigation_bar = create_comment_navigation_bar(
    204     duplicate_index_url(array(), array('start')),
     210
     211  $navigation_bar = create_navigation_bar(
     212    add_url_params(duplicate_index_url(array(), array('start_comments')), array('coa_open'=>null)),
    205213    $row['nb_comments'],
    206214    $page['start_comments'],
    207     $conf['nb_comment_page']
     215    $conf['nb_comment_page'],
     216    false,
     217    'start_comments'
    208218    );
    209219
     
    215225    );
    216226
    217   if ($row['nb_comments'] > 0) 
     227  if ($row['nb_comments'] > 0)
    218228  {
    219229    // comments order (get, session, conf)
     
    225235
    226236    $template->assign(array(
    227       'COMMENTS_ORDER_URL' => add_url_params( duplicate_index_url(), array('comments_order'=> ($comments_order == 'ASC' ? 'DESC' : 'ASC') ) ),
     237      'COMMENTS_ORDER_URL' => add_url_params(duplicate_index_url(), array('comments_order'=> ($comments_order == 'ASC' ? 'DESC' : 'ASC'), 'coa_open'=>null ) ),
    228238      'COMMENTS_ORDER_TITLE' => $comments_order == 'ASC' ? l10n('Show latest comments first') : l10n('Show oldest comments first'),
    229239      ));
    230      
     240
    231241    // get comments
    232242    $query = '
     
    235245    com.author,
    236246    com.author_id,
    237     u.'.$conf['user_fields']['username'].' AS username,
    238247    u.'.$conf['user_fields']['email'].' AS user_email,
     248    com.date,
     249    com.category_id,
     250    com.website_url,
    239251    com.email,
    240     com.date,
    241     com.website_url,
    242     com.category_id,
    243252    com.content,
    244253    com.validated
     
    253262    $result = pwg_query($query);
    254263
    255     while ($row = pwg_db_fetch_assoc($result)) 
     264    while ($row = pwg_db_fetch_assoc($result))
    256265    {
    257266      if ($row['author'] == 'guest')
     
    259268        $row['author'] = l10n('guest');
    260269      }
    261      
     270
    262271      $email = null;
    263272      if (!empty($row['user_email']))
     
    269278        $email = $row['email'];
    270279      }
    271      
     280
    272281      // comment content
    273282      $tpl_comment = array(
     
    275284        'AUTHOR' => trigger_event('render_comment_author', $row['author']),
    276285        'DATE' => format_date($row['date'], true),
     286        'CONTENT' => trigger_event('render_comment_content', $row['content'], 'album'),
    277287        'WEBSITE_URL' => $row['website_url'],
    278         'CONTENT' => trigger_event('render_comment_content', $row['content'], 'album'),
    279288        );
    280      
     289
    281290      // rights
    282       if (can_manage_comment('delete', $row['author_id'])) 
     291      if (can_manage_comment('delete', $row['author_id']))
    283292      {
    284293        $tpl_comment['U_DELETE'] = add_url_params(
    285           $url_self, 
     294          $url_self,
    286295          array(
    287296            'action' => 'delete_comment',
     
    291300          );
    292301      }
    293       if (can_manage_comment('edit', $row['author_id'])) 
     302      if (can_manage_comment('edit', $row['author_id']))
    294303      {
    295304        $tpl_comment['U_EDIT'] = add_url_params(
    296           $url_self, 
     305          $url_self,
    297306          array(
    298307            'action' => 'edit_comment',
     
    300309            )
    301310          );
    302         if (isset($edit_comment) and ($row['id'] == $edit_comment)) 
     311        if (isset($edit_comment) and ($row['id'] == $edit_comment))
    303312        {
    304313          $tpl_comment['IN_EDIT'] = true;
     
    307316          $tpl_comment['CONTENT'] = $row['content'];
    308317          $tpl_comment['PWG_TOKEN'] = get_pwg_token();
     318          $tpl_comment['U_CANCEL'] = $url_self;
    309319        }
    310320      }
     
    312322      {
    313323        $tpl_comment['EMAIL'] = $email;
    314        
    315         if ($row['validated'] != 'true') 
     324
     325        if ($row['validated'] != 'true')
    316326        {
    317327          $tpl_comment['U_VALIDATE'] = add_url_params(
    318             $url_self, 
     328            $url_self,
    319329            array(
    320330              'action' => 'validate_comment',
     
    325335        }
    326336      }
    327      
     337
    328338      $template->append('comments', $tpl_comment);
    329339    }
     
    332342  // comment form
    333343  $show_add_comment_form = true;
    334   if (isset($edit_comment)) 
     344  if (isset($edit_comment))
    335345  {
    336346    $show_add_comment_form = false;
    337347  }
    338   if (is_a_guest() and !$conf['comments_forall']) 
     348  if (is_a_guest() and !$conf['comments_forall'])
    339349  {
    340350    $show_add_comment_form = false;
    341351  }
    342352
    343   if ($show_add_comment_form) 
     353  if ($show_add_comment_form)
    344354  {
    345355    $key = get_ephemeral_key(3, $category['id']);
    346    
    347     $template->assign('comment_add',
    348       array(
     356
     357    $tpl_var = array(
    349358        'F_ACTION' =>         $url_self,
    350359        'KEY' =>              $key,
    351         'CONTENT' =>          stripslashes(@$_POST['content']),
     360        'CONTENT' =>          '',
    352361        'SHOW_AUTHOR' =>      !is_classic_user(),
    353362        'AUTHOR_MANDATORY' => $conf['comments_author_mandatory'],
    354         'AUTHOR' =>           stripslashes(@$_POST['author']),
    355         'WEBSITE_URL' =>      stripslashes(@$_POST['website_url']),
     363        'AUTHOR' =>           '',
     364        'WEBSITE_URL' =>      '',
    356365        'SHOW_EMAIL' =>       !is_classic_user() or empty($user['email']),
    357366        'EMAIL_MANDATORY' =>  $conf['comments_email_mandatory'],
    358         'EMAIL' =>            stripslashes(@$_POST['email']),
    359         )
    360       );
    361   }
    362  
     367        'EMAIL' =>            '',
     368        );
     369
     370    if ('reject'==@$comment_action)
     371    {
     372      foreach (array('content', 'author', 'website_url', 'email') as $k)
     373      {
     374        $tpl_var[strtoupper($k)] = htmlspecialchars( stripslashes(@$_POST[$k]) );
     375      }
     376    }
     377    $template->assign('comment_add', $tpl_var);
     378  }
     379
    363380  // template
    364381  $template->assign(array(
    365     'COA_PATH' => COA_PATH, // for css
    366     'COA_ABSOLUTE_PATH' => dirname(__FILE__) .'/../', // for template
     382    'COA_PATH' => COA_PATH,
     383    'COA_ABSOLUTE_PATH' => realpath(COA_PATH) . '/',
    367384    ));
    368  
    369   $template->set_filename('comments_on_albums', dirname(__FILE__) .'/../template/albums.tpl');
    370   if (isset($pwg_loaded_plugins['rv_tscroller']) AND count($page['navigation_bar']) != 0)
     385
     386  $template->set_filename('comments_on_albums', realpath(COA_PATH . 'template/albums.tpl'));
     387
     388  if (isset($pwg_loaded_plugins['rv_tscroller']) and count($page['navigation_bar']) != 0)
    371389  {
    372390    $template->assign('COMMENTS_ON_TOP', true);
     
    378396  }
    379397}
    380 
    381 ?>
  • extensions/Comments_on_Albums/trunk/include/coa_comments_page.php

    r24609 r26089  
    1 <?php 
     1<?php
    22/* inspired by comments.php */
    3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    4 load_language('plugin.lang', COA_PATH);
     3defined('COA_ID') or die('Hacking attempt!');
     4
     5global $template, $page, $conf, $user;
    56
    67// +-----------------------------------------------------------------------+
     
    1011$template->set_prefilter('comments', 'coa_add_button');
    1112
    12 function coa_add_button($content, &$smarty) 
    13 {   
     13function coa_add_button($content, &$smarty)
     14{
    1415  $search ='<form class="filter" action="{$F_ACTION}" method="get">';
    15   $replacement = '
    16 <form class="filter">
     16
     17  $add = '
    1718<fieldset>
    18 <legend>{\'Display comments on\'|@translate}</legend>
    19 <span style="font-size:1.1em;"><a href="comments.php" {if $COA_MODE=="photos"}style="font-weight:bold;"{/if}>{\'Photos\'|@translate}</a> |
    20 <a href="comments.php?display_mode=albums" {if $COA_MODE=="albums"}style="font-weight:bold;"{/if}>{\'Albums\'|@translate}</a></span>
    21 </fieldset>
    22 </form>';
    23 
    24   return str_replace($search, $replacement.$search, $content);
     19  <legend>{\'Display comments on\'|@translate}</legend>
     20  <span style="font-size:1.1em;"><a href="comments.php" {if $COA_MODE=="photos"}style="font-weight:bold;"{/if}>{\'Photos\'|@translate}</a> |
     21  <a href="comments.php?display_mode=albums" {if $COA_MODE=="albums"}style="font-weight:bold;"{/if}>{\'Albums\'|@translate}</a></span>
     22</fieldset>';
     23
     24  return str_replace($search, $add.$search, $content);
    2525}
    2626
     
    2929//                        comments on albums page                          |
    3030// +-----------------------------------------------------------------------+
    31 if ( isset($_GET['display_mode']) and $_GET['display_mode'] == 'albums' )
    32 {
    33   include_once(COA_PATH.'include/functions_comment.inc.php'); // custom functions
    34  
    35   // reset some template vars
    36   $template->clear_assign(array('comments', 'navbar', 'sort_by_options'));
    37  
    38   // sort_by : database fields proposed for sorting comments list
    39   $sort_by = array(
    40     'date' => l10n('comment date'),
    41     'category_id' => l10n('album')
    42     );
    43   $template->assign('sort_by_options', $sort_by);
    44  
    45   // clean where_clauses from unknown column
    46   foreach ($page['where_clauses'] as &$cond)
    47   {
    48     if (strpos($cond, 'ic.image_id') !== false)
    49     {
    50       $cond = get_sql_condition_FandF(array(
     31if (!isset($_GET['display_mode']) or $_GET['display_mode'] != 'albums')
     32{
     33  return;
     34}
     35
     36$url_self = PHPWG_ROOT_PATH.'comments.php'
     37  .get_query_string_diff(array('edit_albums','delete_albums','validate_albums','pwg_token'));
     38
     39// reset some template vars
     40$template->clear_assign(array('F_ACTION', 'comments', 'navbar', 'sort_by_options'));
     41
     42// sort_by : database fields proposed for sorting comments list
     43global $sort_by;
     44$sort_by = array(
     45  'date' => l10n('comment date'),
     46  'category_id' => l10n('Album')
     47  );
     48$template->assign(array(
     49  'F_ACTION' => PHPWG_ROOT_PATH.'comments.php?display_mode=albums',
     50  'sort_by_options' => $sort_by,
     51  ));
     52
     53// clean where_clauses from unknown column
     54foreach ($page['where_clauses'] as &$cond)
     55{
     56  if (strpos($cond, 'ic.image_id') !== false)
     57  {
     58    $cond = get_sql_condition_FandF(
     59      array(
    5160        'forbidden_categories' => 'category_id',
    5261        'visible_categories' => 'category_id'
    5362        ),
    54         '', true);
    55     }
    56   }
    57   unset($cond);
    58 
    59   // +-----------------------------------------------------------------------+
    60   // |                         comments management                           |
    61   // +-----------------------------------------------------------------------+
    62   $comment_id = null;
    63   $action = null;
    64 
    65   $actions = array('delete_albums', 'validate_albums', 'edit_albums'); // different indexes to not interfer with the main process
    66   foreach ($actions as $loop_action)
    67   {
    68     if (isset($_GET[$loop_action]))
    69     {
    70       $action = $loop_action;
    71       check_input_parameter($action, $_GET, false, PATTERN_ID);
    72       $comment_id = $_GET[$action];
    73       break;
    74     }
    75   }
    76 
    77   if (isset($action))
    78   {
    79     $comment_author_id = get_comment_author_id_albums($comment_id);
    80    
    81     if (can_manage_comment(str_replace('_albums', null, $action), $comment_author_id))
    82     {
    83       $perform_redirect = false;
    84 
    85       if ('delete_albums' == $action)
     63      '', true
     64      );
     65  }
     66}
     67unset($cond);
     68
     69// +-----------------------------------------------------------------------+
     70// |                         comments management                           |
     71// +-----------------------------------------------------------------------+
     72
     73$comment_id = null;
     74$action = null;
     75
     76$actions = array('delete_albums', 'validate_albums', 'edit_albums');
     77foreach ($actions as $loop_action)
     78{
     79  if (isset($_GET[$loop_action]))
     80  {
     81    $action = $loop_action;
     82    check_input_parameter($action, $_GET, false, PATTERN_ID);
     83    $comment_id = $_GET[$action];
     84    break;
     85  }
     86}
     87
     88if (isset($action))
     89{
     90  include_once(COA_PATH.'include/functions_comment.inc.php');
     91
     92  $comment_author_id = get_comment_author_id_albums($comment_id);
     93
     94  if (can_manage_comment(str_replace('_albums', null, $action), $comment_author_id))
     95  {
     96    $perform_redirect = false;
     97
     98    if ('delete_albums' == $action)
     99    {
     100      check_pwg_token();
     101      delete_user_comment_albums($comment_id);
     102      $perform_redirect = true;
     103    }
     104    if ('validate_albums' == $action)
     105    {
     106      check_pwg_token();
     107      validate_user_comment_albums($comment_id);
     108      $perform_redirect = true;
     109    }
     110    if ('edit_albums' == $action)
     111    {
     112      if (!empty($_POST['content']))
    86113      {
    87114        check_pwg_token();
    88         delete_user_comment_albums($comment_id);
    89         $perform_redirect = true;
    90       }
    91       if ('validate_albums' == $action)
    92       {
    93         check_pwg_token();
    94         validate_user_comment_albums($comment_id);
    95         $perform_redirect = true;
    96       }
    97       if ('edit_albums' == $action)
    98       {
    99         if (!empty($_POST['content']))
     115        $comment_action = update_user_comment_albums(
     116          array(
     117            'comment_id' => $_GET['edit_albums'],
     118            'category_id' => $_POST['image_id'],
     119            'content' => $_POST['content'],
     120            'website_url' => @$_POST['website_url'],
     121            ),
     122          $_POST['key']
     123          );
     124
     125        switch ($comment_action)
    100126        {
    101           check_pwg_token();
    102           update_user_comment_albums(
    103             array(
    104               'comment_id' => $_GET['edit_albums'],
    105               'category_id' => $_POST['image_id'],
    106               'content' => $_POST['content']
    107               ),
    108             $_POST['key']
    109             );
    110          
    111           $perform_redirect = true;
    112         }
    113         else
    114         {
    115           $edit_comment = $_GET['edit_albums'];
     127          case 'moderate':
     128            $_SESSION['page_infos'][] = l10n('An administrator must authorize your comment before it is visible.');
     129          case 'validate':
     130            $_SESSION['page_infos'][] = l10n('Your comment has been registered');
     131            $perform_redirect = true;
     132            break;
     133          case 'reject':
     134            $_SESSION['page_errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules');
     135            break;
     136          default:
     137            trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
    116138        }
    117139      }
    118       if ($perform_redirect)
     140      else
    119141      {
    120         $redirect_url =
    121           PHPWG_ROOT_PATH
    122           .'comments.php'
    123           .get_query_string_diff(array('delete_albums','validate_albums','edit_albums','pwg_token'));
    124        
    125         redirect($redirect_url);
     142        $edit_comment = $_GET['edit_albums'];
    126143      }
    127144    }
    128   }
    129 
    130   // +-----------------------------------------------------------------------+
    131   // |                            navigation bar                             |
    132   // +-----------------------------------------------------------------------+
    133   if (isset($_GET['start']) and is_numeric($_GET['start']))
    134   {
    135     $start = $_GET['start'];
    136   }
    137   else
    138   {
    139     $start = 0;
    140   }
    141 
    142   $query = '
     145    if ($perform_redirect)
     146    {
     147      redirect($url_self);
     148    }
     149  }
     150}
     151
     152// +-----------------------------------------------------------------------+
     153// |                            navigation bar                             |
     154// +-----------------------------------------------------------------------+
     155
     156if (isset($_GET['start']) and is_numeric($_GET['start']))
     157{
     158  $start = $_GET['start'];
     159}
     160else
     161{
     162  $start = 0;
     163}
     164
     165$query = '
    143166SELECT COUNT(DISTINCT(com.id))
    144   FROM '.COA_TABLE.' AS com
    145   LEFT JOIN '.USERS_TABLE.' As u
     167  FROM '.CATEGORIES_TABLE.' AS cat
     168  INNER JOIN '.COA_TABLE.' AS com
     169    ON cat.id = com.category_id
     170  LEFT JOIN '.USERS_TABLE.' AS u
    146171    ON u.'.$conf['user_fields']['id'].' = com.author_id
    147172  WHERE '.implode('
    148173    AND ', $page['where_clauses']).'
    149174;';
    150   list($counter) = pwg_db_fetch_row(pwg_query($query));
    151 
    152   $url = PHPWG_ROOT_PATH
    153       .'comments.php'
    154     .get_query_string_diff(array('start','delete_albums','validate_albums','edit_albums','pwg_token'));
    155    
    156   $navbar = create_navigation_bar(
    157     $url,
    158     $counter,
    159     $start,
    160     $page['items_number'],
    161     ''
    162     );
    163  
    164   $template->assign('navbar', $navbar);
    165 
    166   // +-----------------------------------------------------------------------+
    167   // |                        last comments display                          |
    168   // +-----------------------------------------------------------------------+
    169   $comments = array();
    170   $element_ids = array();
    171   $category_ids = array();
    172 
    173   $query = '
     175list($counter) = pwg_db_fetch_row(pwg_query($query));
     176
     177$url = PHPWG_ROOT_PATH.'comments.php'
     178  .get_query_string_diff(array('start','delete_albums','validate_albums','edit_albums','pwg_token'));
     179
     180$navbar = create_navigation_bar(
     181  $url,
     182  $counter,
     183  $start,
     184  $page['items_number'],
     185  ''
     186  );
     187
     188$template->assign('navbar', $navbar);
     189
     190// +-----------------------------------------------------------------------+
     191// |                        last comments display                          |
     192// +-----------------------------------------------------------------------+
     193
     194$comments = array();
     195$element_ids = array();
     196$category_ids = array();
     197
     198$query = '
    174199SELECT
    175200    com.id AS comment_id,
     
    184209    com.content,
    185210    com.validated
    186   FROM '.COA_TABLE.' AS com
     211  FROM '.CATEGORIES_TABLE.' AS cat
     212    INNER JOIN '.COA_TABLE.' AS com
     213      ON cat.id = com.category_id
    187214    LEFT JOIN '.USERS_TABLE.' As u
    188215      ON u.'.$conf['user_fields']['id'].' = com.author_id
     
    198225    com.validated
    199226  ORDER BY '.$page['sort_by'].' '.$page['sort_order'];
    200 if ('all' != $page['items_number'])
    201 {
    202   $query.= '
    203   LIMIT '.$page['items_number'].' OFFSET '.$start;
    204 }
     227  if ('all' != $page['items_number'])
     228  {
     229    $query.= '
     230    LIMIT '.$page['items_number'].' OFFSET '.$start;
     231  }
    205232$query.= '
    206233;';
    207   $result = pwg_query($query);
    208 
    209   while ($row = pwg_db_fetch_assoc($result))
    210   {
    211     array_push($comments, $row);
    212     array_push($element_ids, $row['category_id']);
    213   }
    214 
    215   if (count($comments) > 0)
    216   {
    217     // retrieving category informations
    218     $query = '
    219 SELECT 
    220     cat.id, 
    221     cat.name, 
    222     cat.permalink, 
    223     cat.uppercats, 
     234$result = pwg_query($query);
     235
     236while ($row = pwg_db_fetch_assoc($result))
     237{
     238  $comments[] = $row;
     239  $element_ids[] = $row['category_id'];
     240}
     241
     242if (count($comments) > 0)
     243{
     244  // retrieving category informations
     245  $query = '
     246SELECT
     247    cat.id,
     248    cat.name,
     249    cat.permalink,
     250    cat.uppercats,
    224251    com.id as comment_id,
    225252    img.id AS image_id,
     
    228255    LEFT JOIN '.COA_TABLE.' AS com
    229256      ON com.category_id = cat.id
    230     LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc 
     257    LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc
    231258      ON ucc.cat_id = cat.id AND ucc.user_id = '.$user['id'].'
    232259    LEFT JOIN '.IMAGES_TABLE.' AS img
     
    236263      'forbidden_categories' => 'cat.id',
    237264      'visible_categories' => 'cat.id'
    238       ), 
     265      ),
    239266    'WHERE'
    240267    ).'
    241268    AND cat.id IN ('.implode(',', $element_ids).')
    242269;';
    243     $categories = hash_from_query($query, 'comment_id');
    244 
    245     foreach ($comments as $comment)
    246     {
    247       // source of the thumbnail picture
    248       $comment['src_image'] = new SrcImage($categories[$comment['comment_id']]);
    249    
    250       // category url
    251       $comment['cat_url'] = duplicate_index_url(
     270  $categories = hash_from_query($query, 'comment_id');
     271
     272  foreach ($comments as $comment)
     273  {
     274    // source of the thumbnail picture
     275    $comment['src_image'] = new SrcImage($categories[$comment['comment_id']]);
     276
     277    // category url
     278    $comment['cat_url'] = make_index_url(
     279      array(
     280        'section' => 'categories',
     281        'category' => $categories[$comment['comment_id']],
     282        )
     283      );
     284
     285    $email = null;
     286    if (!empty($comment['user_email']))
     287    {
     288      $email = $comment['user_email'];
     289    }
     290    else if (!empty($comment['email']))
     291    {
     292      $email = $comment['email'];
     293    }
     294
     295    // comment content
     296    $tpl_comment = array(
     297      'ID' => $comment['comment_id'],
     298      'U_PICTURE' => $comment['cat_url'],
     299      'src_image' => $comment['src_image'],
     300      'ALT' => trigger_event('render_category_name', $categories[$comment['comment_id']]['name']),
     301      'AUTHOR' => trigger_event('render_comment_author', $comment['author']),
     302      'WEBSITE_URL' => $comment['website_url'],
     303      'DATE' => format_date($comment['date'], true),
     304      'CONTENT' => trigger_event('render_comment_content', $comment['content'], 'album'),
     305      );
     306
     307    if (is_admin())
     308    {
     309      $tpl_comment['EMAIL'] = $email;
     310    }
     311
     312    // rights
     313    if (can_manage_comment('delete', $comment['author_id']))
     314    {
     315      $tpl_comment['U_DELETE'] = add_url_params(
     316        $url_self,
    252317        array(
    253           'category' => array(
    254             'id' => $categories[$comment['comment_id']]['id'],
    255             'name' => $categories[$comment['comment_id']]['name'],
    256             'permalink' => $categories[$comment['comment_id']]['permalink'],
    257             ),
    258           array('start')
     318          'delete_albums' => $comment['comment_id'],
     319          'pwg_token' => get_pwg_token(),
    259320          )
    260321        );
    261        
    262       $email = null;
    263       if (!empty($comment['user_email']))
     322    }
     323    if (can_manage_comment('edit', $comment['author_id']))
     324    {
     325      $tpl_comment['U_EDIT'] = add_url_params(
     326        $url_self,
     327        array(
     328          'edit_albums' => $comment['comment_id'],
     329          )
     330        );
     331
     332      if (isset($edit_comment) and ($comment['comment_id'] == $edit_comment))
    264333      {
    265         $email = $comment['user_email'];
     334        $tpl_comment['IN_EDIT'] = true;
     335        $key = get_ephemeral_key(2, $comment['category_id']);
     336        $tpl_comment['KEY'] = $key;
     337        $tpl_comment['IMAGE_ID'] = $comment['category_id'];
     338        $tpl_comment['CONTENT'] = $comment['content'];
     339        $tpl_comment['PWG_TOKEN'] = get_pwg_token();
     340        $tpl_comment['U_CANCEL'] = $url_self;
    266341      }
    267       else if (!empty($comment['email']))
     342    }
     343    if (can_manage_comment('validate', $comment['author_id']))
     344    {
     345      if ('true' != $comment['validated'])
    268346      {
    269         $email = $comment['email'];
    270       }
    271      
    272       // comment content
    273       $tpl_comment = array(
    274         'ID' => $comment['comment_id'],
    275         'U_PICTURE' => $comment['cat_url'],
    276         'ALT' => trigger_event('render_category_name', $categories[$comment['comment_id']]['name']),
    277         'src_image' => $comment['src_image'],
    278         'AUTHOR' => trigger_event('render_comment_author', $comment['author']),
    279         'WEBSITE_URL' => $comment['website_url'],
    280         'DATE' => format_date($comment['date'], true),
    281         'CONTENT' => trigger_event('render_comment_content', $comment['content'], 'album'),
    282         );
    283        
    284       if (is_admin())
    285       {
    286         $tpl_comment['EMAIL'] = $email;
    287       }
    288 
    289       // rights
    290       if (can_manage_comment('delete', $comment['author_id']))
    291       {
    292         $tpl_comment['U_DELETE'] = add_url_params(
    293           $url,
     347        $tpl_comment['U_VALIDATE'] = add_url_params(
     348          $url_self,
    294349          array(
    295             'delete_albums' => $comment['comment_id'],
     350            'validate_albums'=> $comment['comment_id'],
    296351            'pwg_token' => get_pwg_token(),
    297352            )
    298353          );
    299354      }
    300       if (can_manage_comment('edit', $comment['author_id']))
    301       {
    302         $tpl_comment['U_EDIT'] = add_url_params(
    303           $url,
    304           array(
    305             'edit_albums' => $comment['comment_id'],
    306             )
    307           );
    308 
    309         if (isset($edit_comment) and ($comment['comment_id'] == $edit_comment))
    310         {
    311           $tpl_comment['IN_EDIT'] = true;
    312           $key = get_ephemeral_key(2, $comment['category_id']);
    313           $tpl_comment['KEY'] = $key;
    314           $tpl_comment['IMAGE_ID'] = $comment['category_id'];
    315           $tpl_comment['CONTENT'] = $comment['content'];
    316           $tpl_comment['PWG_TOKEN'] = get_pwg_token();
    317         }
    318       }
    319       if (can_manage_comment('validate', $comment['author_id']))
    320       {
    321         if ('true' != $comment['validated'])
    322         {
    323           $tpl_comment['U_VALIDATE'] = add_url_params(
    324             $url,
    325             array(
    326               'validate_albums'=> $comment['comment_id'],
    327               'pwg_token' => get_pwg_token(),
    328               )
    329             );
    330         }
    331       }
    332      
    333       $template->append('comments', $tpl_comment);
    334     }
    335   }
    336 
    337   // +-----------------------------------------------------------------------+
    338   // |                            template                                   |
    339   // +-----------------------------------------------------------------------+
    340   // add a line to display category name
    341   $template->set_prefilter('comments', 'coa_change_comments_list');
    342  
    343   function coa_change_comments_list($content, &$smarty) {
    344     $search[0] = '<a href="{$comment.U_PICTURE}">';
    345     $replacement[0] = $search[0].'{$comment.ALT}<br/>';
    346     $search[1] = '<input type="submit"';
    347     $replacement[1] = '<input type=hidden name=display_mode value=albums>'.$search[1];
    348     return str_replace($search, $replacement, $content);
    349   }
    350 }
    351 
    352 ?>
     355    }
     356
     357    $template->append('comments', $tpl_comment);
     358  }
     359}
     360
     361// +-----------------------------------------------------------------------+
     362// |                            template                                   |
     363// +-----------------------------------------------------------------------+
     364// add a line to display category name
     365$template->set_prefilter('comments', 'coa_change_comments_list');
     366
     367function coa_change_comments_list($content, &$smarty) {
     368  $search = '<a href="{$comment.U_PICTURE}">';
     369  $replacement = $search.'{$comment.ALT}<br>';
     370  return str_replace($search, $replacement, $content);
     371}
  • extensions/Comments_on_Albums/trunk/include/functions_comment.inc.php

    r21347 r26089  
    11<?php
    22/* This is a copy of include/functions_comment.inc.php but adapted for Comments On Albums */
     3defined('COA_ID') or die('Hacking attempt!');
    34
    45include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
    5 add_event_handler('user_comment_check_albums', 'user_comment_check',
    6   EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    76
    87/**
    9  * Tries to insert a user comment in the database and returns one of :
    10  * validate, moderate, reject
    11  * @param array comm contains author, content, category_id
    12  * @param string key secret key sent back to the browser
    13  * @param array infos out array of messages
     8 * Tries to insert a user comment and returns action to perform.
     9 *
     10 * @param array &$comm
     11 * @param string $key secret key sent back to the browser
     12 * @param array &$infos output array of error messages
     13 * @return string validate, moderate, reject
    1414 */
    15 function insert_user_comment_albums( &$comm, $key, &$infos )
     15function insert_user_comment_albums(&$comm, $key, &$infos)
    1616{
    1717  global $conf, $user;
     
    3737  if (!is_classic_user())
    3838  {
    39     if ( empty($comm['author']) )
     39    if (empty($comm['author']))
    4040    {
    4141      if ($conf['comments_author_mandatory'])
    4242      {
    43         array_push($infos, l10n('Username is mandatory') );
     43        $infos[] = l10n('Username is mandatory');
    4444        $comment_action='reject';
    4545      }
     
    4747    }
    4848    $comm['author_id'] = $conf['guest_id'];
    49     // if a guest try to use the name of an already existing user, he must be
    50     // rejected
    51     if ( $comm['author'] != 'guest' )
     49    // if a guest try to use the name of an already existing user,
     50    // he must be rejected
     51    if ($comm['author'] != 'guest')
    5252    {
    5353      $query = '
    5454SELECT COUNT(*) AS user_exists
    5555  FROM '.USERS_TABLE.'
    56   WHERE '.$conf['user_fields']['username']." = '".addslashes($comm['author'])."'";
     56  WHERE '.$conf['user_fields']['username']." = '".addslashes($comm['author'])."'
     57;";
    5758      $row = pwg_db_fetch_assoc( pwg_query( $query ) );
    58       if ( $row['user_exists'] == 1 )
     59      if ($row['user_exists'] == 1)
    5960      {
    60         array_push($infos, l10n('This login is already used by another user') );
     61        $infos[] = l10n('This login is already used by another user');
    6162        $comment_action='reject';
    6263      }
     
    6970  }
    7071
    71   if ( empty($comm['content']) )
    72   { // empty comment content
     72  // content
     73  if (empty($comm['content']))
     74  {
    7375    $comment_action='reject';
    7476  }
    7577
    76   if ( !verify_ephemeral_key(@$key, $comm['category_id']) )
     78  // key
     79  if (!verify_ephemeral_key(@$key, $comm['category_id']))
    7780  {
    7881    $comment_action='reject';
    7982    $_POST['cr'][] = 'key';
    8083  }
    81  
     84
    8285  // website
    8386  if (!empty($comm['website_url']))
     
    8992    if (!url_check_format($comm['website_url']))
    9093    {
    91       array_push($infos, l10n('Your website URL is invalid'));
     94      $infos[] = l10n('Your website URL is invalid');
    9295      $comment_action='reject';
    9396    }
    9497  }
    95  
     98
    9699  // email
    97100  if (empty($comm['email']))
     
    103106    else if ($conf['comments_email_mandatory'])
    104107    {
    105       array_push($infos, l10n('Email address is missing. Please specify an email address.') );
     108      $infos[] = l10n('Email address is missing. Please specify an email address.');
    106109      $comment_action='reject';
    107110    }
     
    109112  else if (!email_check_format($comm['email']))
    110113  {
    111     array_push($infos, l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));
     114    $infos[] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)');
    112115    $comment_action='reject';
    113116  }
    114  
     117
    115118  // anonymous id = ip address
    116119  $ip_components = explode('.', $comm['ip']);
     
    138141
    139142    list($counter) = pwg_db_fetch_row(pwg_query($query));
    140     if ( $counter > 0 )
    141     {
    142       array_push( $infos, l10n('Anti-flood system : please wait for a moment before trying to post another comment') );
     143    if ($counter > 0)
     144    {
     145      $infos[] = l10n('Anti-flood system : please wait for a moment before trying to post another comment');
    143146      $comment_action='reject';
    144147    }
     
    146149
    147150  // perform more spam check
    148   $comment_action = trigger_event('user_comment_check_albums',
     151  $comment_action = trigger_event('user_comment_check',
    149152      $comment_action, $comm
    150153    );
    151154
    152   if ( $comment_action!='reject' )
     155  if ($comment_action!='reject')
    153156  {
    154157    $query = '
     
    168171  )
    169172';
    170 
    171173    pwg_query($query);
    172 
    173174    $comm['id'] = pwg_db_insert_id(COA_TABLE);
    174175
     
    191192      if ('moderate' == $comment_action)
    192193      {
    193         $keyargs_content[] = get_l10n_args('', '');
    194194        $keyargs_content[] = get_l10n_args('(!) This comment requires validation', '');
    195195      }
    196196
    197       pwg_mail_notification_admins
    198       (
     197      pwg_mail_notification_admins(
    199198        get_l10n_args('Comment by %s', stripslashes($comm['author']) ),
    200199        $keyargs_content
     
    202201    }
    203202  }
     203
    204204  return $comment_action;
    205205}
    206206
    207207/**
    208  * Tries to delete a user comment in the database
    209  * only admin can delete all comments
    210  * other users can delete their own comments
    211  * so to avoid a new sql request we add author in where clause
     208 * Tries to delete a (or more) user comment.
     209 *    only admin can delete all comments
     210 *    other users can delete their own comments
    212211 *
    213  * @param comment_id
     212 * @param int|int[] $comment_id
     213 * @return bool false if nothing deleted
    214214 */
    215 function delete_user_comment_albums($comment_id) 
     215function delete_user_comment_albums($comment_id)
    216216{
    217217  $user_where_clause = '';
     
    220220    $user_where_clause = '   AND author_id = \''.$GLOBALS['user']['id'].'\'';
    221221  }
    222  
     222
    223223  if (is_array($comment_id))
     224  {
    224225    $where_clause = 'id IN('.implode(',', $comment_id).')';
     226  }
    225227  else
     228  {
    226229    $where_clause = 'id = '.$comment_id;
    227  
     230  }
     231
    228232  $query = '
    229233DELETE FROM '.COA_TABLE.'
     
    231235$user_where_clause.'
    232236;';
    233   $result = pwg_query($query);
    234  
    235   if ($result)
    236   {
    237     email_admin('delete',
     237
     238  if (pwg_db_changes(pwg_query($query)))
     239  {
     240    email_admin('delete',
    238241                array('author' => $GLOBALS['user']['username'],
    239242                      'comment_id' => $comment_id
    240243                  ));
    241   }
    242  
    243   trigger_action('user_comment_deletion', $comment_id, 'category');
     244    trigger_action('user_comment_deletion', $comment_id, 'category');
     245
     246    return true;
     247  }
     248
     249  return false;
    244250}
    245251
    246252/**
    247  * Tries to update a user comment in the database
    248  * only admin can update all comments
    249  * users can edit their own comments if admin allow them
    250  * so to avoid a new sql request we add author in where clause
     253 * Tries to update a user comment
     254 *    only admin can update all comments
     255 *    users can edit their own comments if admin allow them
    251256 *
    252  * @param comment_id
    253  * @param post_key
    254  * @param content
     257 * @param array $comment
     258 * @param string $post_key secret key sent back to the browser
     259 * @return string validate, moderate, reject
    255260 */
    256261function update_user_comment_albums($comment, $post_key)
     
    260265  $comment_action = 'validate';
    261266
    262   if ( !verify_ephemeral_key($post_key, $comment['category_id']) )
     267  if (!verify_ephemeral_key($post_key, $comment['category_id']))
    263268  {
    264269    $comment_action='reject';
     
    275280  // perform more spam check
    276281  $comment_action =
    277     trigger_event('user_comment_check_albums',
     282    trigger_event('user_comment_check',
    278283      $comment_action,
    279284      array_merge($comment,
     
    282287      );
    283288
     289  // website
     290  if (!empty($comment['website_url']))
     291  {
     292    if (!preg_match('/^https?/i', $comment['website_url']))
     293    {
     294      $comment['website_url'] = 'http://'.$comment['website_url'];
     295    }
     296    if (!url_check_format($comment['website_url']))
     297    {
     298      $page['errors'][] = l10n('Your website URL is invalid');
     299      $comment_action='reject';
     300    }
     301  }
     302
    284303  if ( $comment_action!='reject' )
    285304  {
     
    294313UPDATE '.COA_TABLE.'
    295314  SET content = \''.$comment['content'].'\',
     315      website_url = '.(!empty($comment['website_url']) ? '\''.$comment['website_url'].'\'' : 'NULL').',
    296316      validated = \''.($comment_action=='validate' ? 'true':'false').'\',
    297317      validation_date = '.($comment_action=='validate' ? 'NOW()':'NULL').'
     
    300320;';
    301321    $result = pwg_query($query);
    302    
     322
    303323    // mail admin and ask to validate the comment
    304     if ($result and $conf['email_admin_on_comment_validation'] and 'moderate' == $comment_action) 
     324    if ($result and $conf['email_admin_on_comment_validation'] and 'moderate' == $comment_action)
    305325    {
    306326      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     
    314334        get_l10n_args('', ''),
    315335        get_l10n_args('Manage this user comment: %s', $comment_url),
    316         get_l10n_args('', ''),
    317336        get_l10n_args('(!) This comment requires validation', ''),
    318337      );
    319338
    320       pwg_mail_notification_admins
    321       (
     339      pwg_mail_notification_admins(
    322340        get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username']) ),
    323341        $keyargs_content
     
    331349    }
    332350  }
    333  
     351
    334352  return $comment_action;
    335353}
    336354
     355/**
     356 * Returns the author id of a comment
     357 *
     358 * @param int $comment_id
     359 * @param bool $die_on_error
     360 * @return int
     361 */
    337362function get_comment_author_id_albums($comment_id, $die_on_error=true)
    338363{
     
    355380    }
    356381  }
    357  
     382
    358383  list($author_id) = pwg_db_fetch_row($result);
    359384
     
    362387
    363388/**
    364  * Tries to validate a user comment in the database
    365  * @param int or array of int comment_id
     389 * Tries to validate a user comment.
     390 *
     391 * @param int|int[] $comment_id
    366392 */
    367393function validate_user_comment_albums($comment_id)
    368394{
    369395  if (is_array($comment_id))
     396  {
    370397    $where_clause = 'id IN('.implode(',', $comment_id).')';
     398  }
    371399  else
     400  {
    372401    $where_clause = 'id = '.$comment_id;
    373    
     402  }
     403
    374404  $query = '
    375405UPDATE '.COA_TABLE.'
     
    379409;';
    380410  pwg_query($query);
    381  
     411
    382412  trigger_action('user_comment_validation', $comment_id, 'category');
    383413}
    384 ?>
  • extensions/Comments_on_Albums/trunk/language/en_UK/plugin.lang.php

    r21347 r26089  
    66$lang['Last comments on albums'] = 'Last comments on albums';
    77$lang['Display last posted comments on albums'] = 'Display last posted comments on albums';
     8$lang['%d comment on album'] = '%d comment on album';
     9$lang['%d comments on albums'] = '%d comments on albums';
     10$lang['Photos'] = 'Photos';
    811
    912?>
  • extensions/Comments_on_Albums/trunk/language/fr_FR/plugin.lang.php

    r21347 r26089  
    66$lang['Last comments on albums'] = 'Derniers commentaires sur les albums';
    77$lang['Display last posted comments on albums'] = 'Affiche les derniers commentaires postés sur les albums';
     8$lang['%d comment on album'] = '%d commentaire sur un album';
     9$lang['%d comments on albums'] = '%d commentaires sur albums';
     10$lang['Photos'] = 'Photos';
     11
    812?>
  • extensions/Comments_on_Albums/trunk/main.inc.php

    r24545 r26089  
    99*/
    1010
    11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    1212
    1313if (mobile_theme())
     
    1818global $prefixeTable;
    1919
    20 // +-----------------------------------------------------------------------+
    21 //          Global variables
    22 // +-----------------------------------------------------------------------+
    23 defined('COA_ID') or define('COA_ID', basename(dirname(__FILE__)));
     20
     21define('COA_ID',      basename(dirname(__FILE__)));
    2422define('COA_PATH' ,   PHPWG_PLUGINS_PATH . COA_ID . '/');
    2523define('COA_TABLE' ,  $prefixeTable . 'comments_categories');
     
    2826
    2927
    30 // +-----------------------------------------------------------------------+
    31 //          Triggers
    32 // +-----------------------------------------------------------------------+
    3328add_event_handler('init', 'coa_init');
     29
    3430function coa_init()
    3531{
    3632  global $user, $conf, $pwg_loaded_plugins;
    37  
     33
     34  include_once(COA_PATH . 'maintain.inc.php');
     35  $maintain = new Comments_on_Albums_maintain(COA_ID);
     36  $maintain->autoUpdate(COA_VERSION, 'install');
     37
    3838  // luciano doesn't use comments
    3939  // incompatible with dynamic display of Stripped & Collumns
    4040  if ($user['theme'] == 'luciano' or $user['theme'] == 'stripped_black_bloc') return;
    41  
    42   // apply upgrade if needed
    43   if (
    44     COA_VERSION == 'auto' or
    45     $pwg_loaded_plugins[COA_ID]['version'] == 'auto' or
    46     version_compare($pwg_loaded_plugins[COA_ID]['version'], COA_VERSION, '<')
    47   )
    48   {
    49     // call install function
    50     include_once(COA_PATH . 'include/install.inc.php');
    51     coa_install();
    52    
    53     // update plugin version in database
    54     if ( $pwg_loaded_plugins[COA_ID]['version'] != 'auto' and COA_VERSION != 'auto' )
    55     {
    56       $query = '
    57 UPDATE '. PLUGINS_TABLE .'
    58 SET version = "'. COA_VERSION .'"
    59 WHERE id = "'. COA_ID .'"';
    60       pwg_query($query);
    61      
    62       $pwg_loaded_plugins[COA_ID]['version'] = COA_VERSION;
    63      
    64       if (defined('IN_ADMIN'))
    65       {
    66         $_SESSION['page_infos'][] = 'Comments on Albums updated to version '. COA_VERSION;
    67       }
    68     }
    69   }
    70  
    71   // add events handlers
     41
     42  include_once(COA_PATH . 'include/events.inc.php');
     43
    7244  if (defined('IN_ADMIN'))
    7345  {
     46    add_event_handler('tabsheet_before_select', 'coa_tabsheet_before_select', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    7447    add_event_handler('loc_begin_admin_page', 'coa_admin_intro');
    75     add_event_handler('loc_end_admin', 'coa_admin_comments');
    7648  }
    7749  else
    7850  {
    7951    add_event_handler('loc_after_page_header', 'coa_albums');
    80     add_event_handler('loc_after_page_header', 'coa_comments_page');
    81   } 
     52    add_event_handler('loc_end_comments', 'coa_comments');
     53  }
     54
    8255  add_event_handler('get_stuffs_modules', 'coa_register_stuffs_module');
     56
     57  load_language('plugin.lang', COA_PATH);
    8358}
    84 
    85 
    86 // +-----------------------------------------------------------------------+
    87 //          Functions
    88 // +-----------------------------------------------------------------------+
    89 
    90 function coa_albums()
    91 {
    92   global $template, $page, $conf, $pwg_loaded_plugins;
    93  
    94   if ( !empty($page['section']) AND $page['section'] == 'categories' AND isset($page['category']) AND $page['body_id'] == 'theCategoryPage' )
    95   {   
    96     trigger_action('loc_begin_coa');
    97     include(COA_PATH . 'include/coa_albums.php');
    98   }
    99 }
    100 
    101 function coa_comments_page()
    102 {
    103   global $template, $page, $conf, $user;
    104  
    105   if (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage')
    106   {
    107     include(COA_PATH . 'include/coa_comments_page.php');
    108   }
    109 }
    110 
    111 function coa_admin_intro()
    112 {
    113   global $page;
    114  
    115   if ($page['page'] == 'intro')
    116   { 
    117     include(COA_PATH . 'include/coa_admin_intro.php');
    118   }
    119 }
    120 
    121 function coa_admin_comments()
    122 {
    123   global $page;
    124  
    125   if ($page['page'] == 'comments')
    126   { 
    127     include(COA_PATH . 'include/coa_admin_comments.php');
    128   }
    129 }
    130 
    131 function coa_register_stuffs_module($modules)
    132 {
    133   load_language('plugin.lang', COA_PATH);
    134  
    135   array_push($modules, array(
    136     'path' => COA_PATH . '/stuffs_module',
    137     'name' => l10n('Last comments on albums'),
    138     'description' => l10n('Display last posted comments on albums'),
    139   ));
    140 
    141   return $modules;
    142 }
    143 
    144 ?>
  • extensions/Comments_on_Albums/trunk/maintain.inc.php

    r19991 r26089  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    33
    4 defined('COA_ID') or define('COA_ID', basename(dirname(__FILE__)));
    5 include_once(PHPWG_PLUGINS_PATH . COA_ID . '/include/install.inc.php');
     4class Comments_on_Albums_maintain extends PluginMaintain
     5{
     6  private $installed = false;
    67
    7 function plugin_install()
    8 {
    9   coa_install();
    10   define('coa_installed', true);
    11 }
     8  function install($plugin_version, &$errors=array())
     9  {
     10    global $prefixeTable;
    1211
    13 function plugin_activate()
    14 {
    15   if (!defined('coa_installed'))
     12    pwg_query('
     13CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'comments_categories` (
     14  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
     15  `category_id` mediumint(8) unsigned NOT NULL DEFAULT 0,
     16  `date` datetime NOT NULL DEFAULT "0000-00-00 00:00:00",
     17  `author` varchar(255) DEFAULT NULL,
     18  `email` varchar(255) DEFAULT NULL,
     19  `author_id` smallint(5) DEFAULT NULL,
     20  `anonymous_id` varchar(45) NOT NULL,
     21  `website_url` varchar(255) DEFAULT NULL,
     22  `content` longtext,
     23  `validated` enum("true","false") NOT NULL DEFAULT "false",
     24  `validation_date` datetime DEFAULT NULL,
     25  PRIMARY KEY (`id`),
     26  KEY `comments_i2` (`validation_date`),
     27  KEY `comments_i1` (`category_id`)
     28) ENGINE=MyISAM DEFAULT CHARSET=utf8');
     29
     30    $result = pwg_query('SHOW COLUMNS FROM `' . $prefixeTable . 'comments_categories` LIKE "anonymous_id";');
     31    if (!pwg_db_num_rows($result))
     32    {
     33      pwg_query('ALTER TABLE `' . $prefixeTable . 'comments_categories` ADD `anonymous_id` VARCHAR(45) DEFAULT NULL;');
     34    }
     35
     36    $result = pwg_query('SHOW COLUMNS FROM `' . $prefixeTable . 'comments_categories` LIKE "email";');
     37    if (!pwg_db_num_rows($result))
     38    {
     39      pwg_query('
     40ALTER TABLE `' . $prefixeTable . 'comments_categories`
     41  ADD `email` varchar(255) DEFAULT NULL,
     42  ADD `website_url` varchar(255) DEFAULT NULL,
     43  ADD KEY `comments_i2` (`validation_date`),
     44  ADD KEY `comments_i1` (`category_id`)
     45      ;');
     46    }
     47
     48    $this->installed = true;
     49  }
     50
     51  function activate($plugin_version, &$errors=array())
    1652  {
    17     coa_install();
     53    if (!$this->installed)
     54    {
     55      $this->install($plugin_version, $errors);
     56    }
     57  }
     58
     59  function deactivate()
     60  {
     61  }
     62
     63  function uninstall()
     64  {
     65    global $prefixeTable;
     66
     67    pwg_query('DROP TABLE `' . $prefixeTable . 'comments_categories`;');
    1868  }
    1969}
    20 
    21 function plugin_uninstall()
    22 {
    23   global $prefixeTable;
    24 
    25   pwg_query('DROP TABLE `' . $prefixeTable . 'comments_categories`;');
    26 }
    27 
    28 ?>
  • extensions/Comments_on_Albums/trunk/template/albums.tpl

    r18927 r26089  
    1 {* this is inspired by theme/defaults/template/picture.tpl *}
    2  
    3 {* <!-- need some css modifications, specific to each theme --> *}
    4 {html_head}
    5 <style type="text/css">
    6 #comments .commentElement {ldelim} width:98%;}
     1{*<!-- this is inspired by theme/defaults/template/picture.tpl -->*}
     2
     3{combine_script id='coa.script' load='footer' require='jquery' path=$COA_PATH|cat:'template/script.js'}
     4
     5{html_style}{strip}
     6#comments { margin:10px 0 0 0; padding: 2px 5px !important; position:relative; }
     7#comments .commentElement { width:98%; }
     8
    79{if $COMMENTS_ON_TOP}
    8 #commentAdd, #pictureCommentList {ldelim} float:none; display:inline-block; width:47.5%; vertical-align:top;}
    9 #commentsSwitcher {ldelim} float:none; display:inline-block; margin: 2px 0; cursor:pointer;}
    10 .noCommentContent #commentsSwitcher  {ldelim} display: none;}
    11 .switchArrow{ldelim} width: 16px; height: 16px; margin: 5px;}
    12 .commentshidden #pictureComments {ldelim} display: none;}
    13 .commentContent .comments_toggle   {ldelim} cursor: pointer;}
    14 {/if}
    15 {if $themeconf.name == 'Sylvia'}
    16 #comments .description {ldelim} padding: 15px 2px 6px 12px;}
    17 #comments .commentElement {ldelim} border: 1px solid #666;}
    18 {/if}
    19 {if $themeconf.name|strstr:"stripped"}
    20 #comments {ldelim} text-align: left;}
    21 #comments .description {ldelim} height:auto;}
    22 #thumbnails_block2 {ldelim} min-height:0;}
     10#comments { margin:0 0 10px 0; }
    2311{/if}
    2412
    25 </style>
    26 {/html_head}
    27 
    28 {* <!-- if RV Thumb Scroller is installed comments block is displayed on top with a drop-down --> *}
    29 {if $COMMENTS_ON_TOP}
    30 {footer_script}{literal}
    31   // comments show/hide
    32   var commentsswicther=jQuery("#commentsSwitcher");
    33   var comments=jQuery("#theCategoryPage #comments");
    34  
    35   commentsswicther.html('<div class="switchArrow">&nbsp;</div>');
    36   {/literal}{if $themeconf.name != 'elegant'}switcharrow = commentsswicther.children(".switchArrow");{else}switcharrow = $('<div></div>');{/if}{literal}
    37  
    38   if (comments.length == 1) {
    39     var comments_button=jQuery("#comments h3");
    40 
    41     if (comments_button.length == 0) {
    42       jQuery("#addComment").before('<h3>Comments</h3>');
    43       comments_button=jQuery("#comments h3");
    44     }
    45  
    46     {/literal}{if $DISPLAY_COMMENTS_BLOCK}
    47     comments.addClass("commentsshown");
    48     comments_button.addClass("comments_toggle").addClass("comments_toggle_on");
    49     switcharrow.html("&uarr;");
    50     {else}
    51     comments.addClass("commentshidden");
    52     comments_button.addClass("comments_toggle").addClass("comments_toggle_off");
    53     switcharrow.html("&darr;");
    54     {/if}{literal}
    55    
    56     comments_button.click(function() { commentsToggle() });
    57     commentsswicther.click(function() { commentsToggle() });
    58  
    59   }
    60  
    61   function commentsToggle() {
    62     var comments=jQuery("#theCategoryPage #comments");
    63     var comments_button=jQuery("#comments h3");
    64 
    65     if (comments.hasClass("commentshidden")) {
    66         comments.removeClass("commentshidden").addClass("commentsshown");
    67         comments_button.addClass("comments_toggle_off").removeClass("comments_toggle_off");
    68         switcharrow.html("&uarr;");
    69       } else {
    70         comments.addClass("commentshidden").removeClass("commentsshown");
    71         comments_button.addClass("comments_toggle_on").removeClass("comments_toggle_on");
    72         switcharrow.html("&darr;");
    73       }
    74 
    75   }
    76 {/literal}{/footer_script}
     13{if $themeconf.name == 'elegant'}
     14#content { padding-bottom:0; }
     15#comments { background-color:#333333; }
     16#comments h3 { margin: 10px 0px; }
    7717{/if}
    7818
     19{if $themeconf.name == 'Sylvia'}
     20#comments .description { padding: 15px 2px 6px 12px; }
     21#comments .commentElement { border: 1px solid #666; }
     22{/if}
     23
     24{if $themeconf.name|strstr:"stripped"}
     25#comments { text-align: left; }
     26#comments .description { height:auto; }
     27#thumbnails_block2 { min-height:0; }
     28{/if}
     29
     30{if $themeconf.name != 'elegant'}
     31#comments { background:rgba(127,127,127,0.1); }
     32#comments.commentshidden #pictureComments { display:none; }
     33#comments .comments_toggle { cursor:pointer; }
     34#commentsSwitcher { float:left; margin:2px 0; cursor:pointer; }
     35#comments .switchArrow { width:16px; height:16px; margin:8px 5px 8px 4px; }
     36#comments .switchArrow:before { content:"\BB"; display:inline-block; font-size:22px; }
     37#comments.commentshidden .switchArrow:before { -webkit-transform:rotate(90deg); transform:rotate(90deg); }
     38#comments.commentsshown .switchArrow:before { -webkit-transform:rotate(-90deg); transform:rotate(-90deg); }
     39{/if}
     40{/strip}{/html_style}
     41
     42{footer_script}
     43var coa_on_top = {intval(isset($COMMENTS_ON_TOP))}, coa_force_open = {intval(isset($DISPLAY_COMMENTS_BLOCK))};
     44{/footer_script}
     45
     46
    7947{if isset($COMMENT_COUNT)}
    80 <div id="comments" style="margin:10px 0 10px 0;" {if (!isset($comment_add) && ($COMMENT_COUNT == 0))}class="noCommentContent"{else}class="commentContent"{/if}>
    81   <h3 style="margin:0 0 0 5px;"><div id="commentsSwitcher"></div>{$pwg->l10n_dec('%d comment', '%d comments',$COMMENT_COUNT)}</h3>
     48<div id="comments" {if (!isset($comment_add) && ($COMMENT_COUNT == 0))}class="noCommentContent"{else}class="commentContent"{/if}><div id="commentsSwitcher"></div>
     49  <h3>{$COMMENT_COUNT|translate_dec:'%d comment':'%d comments'}</h3>
    8250
    83   <div id="pictureComments"><fieldset>
     51  <div id="pictureComments">
    8452    {if isset($comment_add)}
    8553    <div id="commentAdd">
    86       <h4>{'Add a comment'|@translate}</h4>
     54      <h4>{'Add a comment'|translate}</h4>
    8755      <form method="post" action="{$comment_add.F_ACTION}" id="addComment">
    8856        {if $comment_add.SHOW_AUTHOR}
    89           <p><label for="author">{'Author'|@translate}{if $comment_add.AUTHOR_MANDATORY} ({'mandatory'|@translate}){/if} :</label></p>
     57          <p><label for="author">{'Author'|translate}{if $comment_add.AUTHOR_MANDATORY} ({'mandatory'|translate}){/if} :</label></p>
    9058          <p><input type="text" name="author" id="author" value="{$comment_add.AUTHOR}"></p>
    9159        {/if}
    9260        {if $comment_add.SHOW_EMAIL}
    93           <p><label for="email">{'Email'|@translate}{if $comment_add.EMAIL_MANDATORY} ({'mandatory'|@translate}){/if} :</label></p>
     61          <p><label for="email">{'Email address'|translate}{if $comment_add.EMAIL_MANDATORY} ({'mandatory'|translate}){/if} :</label></p>
    9462          <p><input type="text" name="email" id="email" value="{$comment_add.EMAIL}"></p>
    9563        {/if}
    96         <p><label for="website_url">{'Website'|@translate} :</label></p>
     64        <p><label for="website_url">{'Website'|translate} :</label></p>
    9765        <p><input type="text" name="website_url" id="website_url" value="{$comment_add.WEBSITE_URL}"></p>
    98         <p><label for="contentid">{'Comment'|@translate} ({'mandatory'|@translate}) :</label></p>
     66        <p><label for="contentid">{'Comment'|translate} ({'mandatory'|translate}) :</label></p>
    9967        <p><textarea name="content" id="contentid" rows="5" cols="50">{$comment_add.CONTENT}</textarea></p>
    10068        <p><input type="hidden" name="key" value="{$comment_add.KEY}">
    101           <input type="submit" value="{'Submit'|@translate}"></p>
     69          <input type="submit" value="{'Submit'|translate}"></p>
    10270      </form>
    10371    </div>
     
    11078            <a href="{$COMMENTS_ORDER_URL}#comments" rel="nofollow" class="commentsOrder">{$COMMENTS_ORDER_TITLE}</a>
    11179          {/if}
    112           {if !empty($comment_navbar) }{include file=$COA_ABSOLUTE_PATH|@cat:'template/navigation_bar.tpl'|@get_extent:'navbar'}{/if}
     80          {if !empty($comment_navbar)}
     81            {include file='navigation_bar.tpl'|get_extent:'navbar' navbar=$comment_navbar}
     82          {/if}
    11383        </div>
    11484      {/if}
     
    11686    </div>
    11787    {/if}
    118     {if not $COMMENTS_ON_TOP}<div style="clear:both"></div>{/if}
    119   </fieldset></div>
     88    <div style="clear:both"></div>
     89  </div>
    12090
    12191</div>
Note: See TracChangeset for help on using the changeset viewer.