Ignore:
Timestamp:
Apr 29, 2012, 5:09:28 PM (12 years ago)
Author:
mistic100
Message:

update for 2.4
delete useless admin page
now compatible with RV Thumb Scroller

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Comments_on_Albums/include/coa_comments_page.php

    r12562 r14528  
    22/* inspired by comments.php */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    4 
    54load_language('plugin.lang', COA_PATH);
    6 $conf['comments_on_albums'] = unserialize($conf['comments_on_albums']);
    7 
    8 $template->assign(
    9   array(
    10     'COA_PATH' => COA_PATH,
    11     'ICON_COLOR' => $conf['comments_on_albums']['icon_color'],
    12     'ICON_COLOR_OVER' => $conf['comments_on_albums']['icon_color_over'],
    13     )
    14   );
    15 
    165
    176// +-----------------------------------------------------------------------+
     
    198// +-----------------------------------------------------------------------+
    209
    21 if (!isset($_GET['display_mode']))
     10if ( !isset($_GET['display_mode']) or $_GET['display_mode'] != 'albums' )
    2211
    2312  // adds a button for switch page
     
    2514 
    2615  function coa_add_button($content, &$smarty)
    27   {
    28     $search = '<ul class="categoryActions">';
    29 
    30 $replacement = '
    31 {html_head}
    32   <style type="text/css">
    33     .pwg-icon-comments-albums {ldelim}
    34       background-image: url({$COA_PATH}template/s26/{$ICON_COLOR});
    35       background-position: -26px 0;
    36     }
    37     a:hover .pwg-icon-comments-albums {ldelim}
    38       background-image: url({$COA_PATH}template/s26/{$ICON_COLOR_OVER});
    39       background-position: -26px 0;
    40     }
    41   </style>
    42 {/html_head}
    43 
    44   '.$search.'
    45     <li><a href="comments.php?display_mode=albums" title="' . l10n('Comments on albums') . '" class="pwg-state-default pwg-button">
    46       <span class="pwg-icon pwg-icon-comments-albums">&nbsp;</span><span class="pwg-button-text">' . l10n('Comments on albums') . '</span>
    47     </a></li>';
     16  {   
     17    $search ="{include file='infos_errors.tpl'}";
     18    $replacement = $search.'
     19<form class="filter">
     20<fieldset>
     21  <legend>{\'Display comments on\'|@translate}</legend>
     22  <span style="font-size:1.1em;"><a href="#" style="font-weight:bold;">{\'Photos\'|@translate}</a> | <a href="comments.php?display_mode=albums">{\'Albums\'|@translate}</a></span>
     23</fieldset>
     24</form>';
    4825
    4926    return str_replace($search, $replacement, $content);
     
    5835else if ($_GET['display_mode'] == 'albums')
    5936{
     37  include_once(COA_PATH.'include/functions_comment.inc.php'); // custom functions
     38 
    6039  // reset some template vars
    6140  $template->clear_assign(array('comments', 'navbar', 'sort_by_options'));
     
    8867  if (isset($action))
    8968  {
    90     include_once(COA_PATH.'include/functions_comment.inc.php');
    91    
    92     check_pwg_token();
    93    
    9469    $comment_author_id = get_comment_author_id_albums($comment_id);
    9570   
    96     $true_action = str_replace('_albums', null, $action); // but we must check true action names
    97 
    98     if (can_manage_comment($true_action, $comment_author_id))
     71    if (can_manage_comment(str_replace('_albums', null, $action), $comment_author_id))
    9972    {
    10073      $perform_redirect = false;
     
    10275      if ('delete_albums' == $action)
    10376      {
     77        check_pwg_token();
    10478        delete_user_comment_albums($comment_id);
    10579        $perform_redirect = true;
     
    10781      if ('validate_albums' == $action)
    10882      {
     83        check_pwg_token();
    10984        validate_user_comment_albums($comment_id);
    11085        $perform_redirect = true;
     
    11489        if (!empty($_POST['content']))
    11590        {
     91          check_pwg_token();
    11692          update_user_comment_albums(
    11793            array(
     
    12298            $_POST['key']
    12399            );
    124           //$perform_redirect = true;
    125           $edit_comment = null;
     100         
     101          $perform_redirect = true;
    126102        }
    127103        else
     
    155131
    156132  $query = '
    157 SELECT
    158     COUNT(DISTINCT(com.id))
     133SELECT COUNT(DISTINCT(com.id))
    159134  FROM '.COA_TABLE.' AS com
    160135  LEFT JOIN '.USERS_TABLE.' As u
     
    165140  list($counter) = pwg_db_fetch_row(pwg_query($query));
    166141
    167   $url =
    168     PHPWG_ROOT_PATH
    169     .'comments.php'
     142  $url = PHPWG_ROOT_PATH
     143      .'comments.php'
    170144    .get_query_string_diff(array('start','delete_albums','validate_albums','edit_albums','pwg_token'));
    171145   
     
    177151    ''
    178152    );
     153 
    179154  $template->assign('navbar', $navbar);
    180155
     
    210185    com.validated
    211186  ORDER BY '.$page['sort_by'].' '.$page['sort_order'];
    212   if ('all' != $page['items_number'])
    213   {
    214     $query.= '
     187if ('all' != $page['items_number'])
     188{
     189  $query.= '
    215190  LIMIT '.$page['items_number'].' OFFSET '.$start;
    216   }
    217   $query.= '
     191}
     192$query.= '
    218193;';
    219194  $result = pwg_query($query);
     
    258233    foreach ($comments as $comment)
    259234    {
     235      // source of the thumbnail picture
     236      $comment['src_image'] = new SrcImage($categories[$comment['comment_id']]);
     237   
    260238      // category url
    261239      $comment['cat_url'] = duplicate_index_url(
     
    269247          )
    270248        );
    271        
    272       // category thumbnail
    273       $comment['thumb'] = get_thumbnail_url(
    274         array(
    275           'id' => $categories[$comment['comment_id']]['image_id'],
    276           'path' => $categories[$comment['comment_id']]['path'],
    277           'tn_ext' => @$categories[$comment['comment_id']]['tn_ext'],
    278           )
    279        );
    280249     
    281250      // comment content
     
    284253        'U_PICTURE' => $comment['cat_url'],
    285254        'ALT' => trigger_event('render_category_name', $categories[$comment['comment_id']]['name']),
    286         'TN_SRC' => $comment['thumb'],
     255        'src_image' => $comment['src_image'],
    287256        'AUTHOR' => trigger_event('render_comment_author', $comment['author']),
    288257        'DATE' => format_date($comment['date'], true),
     
    293262      if (can_manage_comment('delete', $comment['author_id']))
    294263      {
    295         $url =
    296           get_root_url()
    297           .'comments.php'
    298           .get_query_string_diff(array('delete','validate','edit', 'pwg_token'));
    299 
    300264        $tpl_comment['U_DELETE'] = add_url_params(
    301265          $url,
     
    308272      if (can_manage_comment('edit', $comment['author_id']))
    309273      {
    310         $url =
    311           get_root_url()
    312           .'comments.php'
    313           .get_query_string_diff(array('edit', 'delete','validate', 'pwg_token'));
    314 
    315274        $tpl_comment['U_EDIT'] = add_url_params(
    316275          $url,
    317276          array(
    318277            'edit_albums' => $comment['comment_id'],
    319             'pwg_token' => get_pwg_token(),
    320278            )
    321279          );
     
    323281        if (isset($edit_comment) and ($comment['comment_id'] == $edit_comment))
    324282        {
     283          $tpl_comment['IN_EDIT'] = true;
    325284          $key = get_ephemeral_key(2, $comment['category_id']);
    326           $tpl_comment['IN_EDIT'] = true;
    327285          $tpl_comment['KEY'] = $key;
    328286          $tpl_comment['IMAGE_ID'] = $comment['category_id'];
    329287          $tpl_comment['CONTENT'] = $comment['content'];
     288          $tpl_comment['PWG_TOKEN'] = get_pwg_token();
    330289        }
    331290      }
     
    357316 
    358317  function coa_change_comments_list($content, &$smarty) {
    359     $search = '<img src="{$comment.TN_SRC}" alt="{$comment.ALT}">';
     318    $search = '<img src="{$pwg->derivative_url($derivative_params, $comment.src_image)}" alt="{$comment.ALT}">';
    360319    $replacement = $search.'<br/>{$comment.ALT}';
    361320    return str_replace($search, $replacement, $content);
Note: See TracChangeset for help on using the changeset viewer.