Changeset 15108


Ignore:
Timestamp:
05/18/12 23:54:46 (8 years ago)
Author:
mistic100
Message:

update for Piwigo 2.4
fix a bug in links refresh on comments.php

Location:
extensions/reply_to
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/reply_to/index.php

    r11252 r15108  
    33// | Piwigo - a PHP based photo gallery                                    | 
    44// +-----------------------------------------------------------------------+ 
    5 // | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org | 
     5// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org | 
    66// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net | 
    77// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick | 
  • extensions/reply_to/language/en_UK/plugin.lang.php

    r11252 r15108  
    11<?php 
    22 
    3 $lang['reply to this comment'] = 'reply to this comment'; 
     3$lang['Reply'] = 'Reply'; 
    44 
    55?> 
  • extensions/reply_to/language/fr_FR/plugin.lang.php

    r11252 r15108  
    11<?php 
    22 
    3 $lang['reply to this comment'] = 'répondre à ce commentaire'; 
     3$lang['Reply'] = 'Répondre'; 
    44 
    55?> 
  • extensions/reply_to/language/it_IT/plugin.lang.php

    r11460 r15108  
    11<?php 
    22 
    3 $lang['reply to this comment'] = 'Rispondere a questo commento'; 
     3$lang['Reply'] = 'Rispondere'; 
    44 
    55?> 
  • extensions/reply_to/language/lv_LV/plugin.lang.php

    r11447 r15108  
    11<?php 
    22 
    3 $lang['reply to this comment'] = 'atbildēt uz šo komentāru'; 
     3$lang['Reply'] = 'Atbildēt'; 
    44 
    55?> 
  • extensions/reply_to/main.inc.php

    r12389 r15108  
    2020 
    2121add_event_handler('render_comment_content', 'replyto_parse', 60, 2); 
    22 if (script_basename() == 'comments') add_event_handler('init', 'replyto_add_link'); // for comments page (section_init.inc is not called on this page) 
    23 else add_event_handler('loc_end_section_init', 'replyto_add_link'); // for all other pages (we need section infos) 
     22if (script_basename() == 'comments') add_event_handler('loc_after_page_header', 'replyto_add_link'); 
     23else add_event_handler('loc_end_section_init', 'replyto_add_link'); 
    2424     
    2525?> 
  • extensions/reply_to/reply_to.inc.php

    r12563 r15108  
    1111  global $pwg_loaded_plugins, $template, $page, $conf, $lang; 
    1212  $template->assign('REPLYTO_PATH', REPLYTO_PATH); 
     13  $location = null; 
    1314   
    1415  // comment form has different id 
     
    2526  } 
    2627   
    27   // must check our location 
    28   if (script_basename() == 'comments') /* COMMENTS page */ 
     28  /* COMMENTS page */ 
     29  if (script_basename() == 'comments')  
    2930  { 
    3031    if ( !is_a_guest() OR $conf['comments_forall'] ) 
    3132    { 
     33      $comments = &$template->get_template_vars('comments'); 
     34      if (!count($comments)) return; 
     35       
     36      // generates urls to picture or albums with necessary url params 
     37      foreach ($comments as $tpl_var) 
     38      { 
     39        $replyto_links[ $tpl_var['ID'] ] = get_absolute_root_url().$tpl_var['U_PICTURE'].'&amp;rt='.$tpl_var['ID'].'&amp;rta='.$tpl_var['AUTHOR'].'#commentform'; 
     40      } 
     41       
     42      $template->assign('replyto_links', $replyto_links); 
    3243      $template->set_prefilter('comments', 'replyto_add_link_comments_prefilter'); 
    3344    } 
    3445  } 
    35   else if (script_basename() == 'picture') /* PICTURE page */ 
    36   { 
     46  /* PICTURE page */ 
     47  else if (script_basename() == 'picture')  
     48  { 
     49    $location = 'picture'; 
    3750    add_event_handler('user_comment_insertion', 'replyto_parse_picture_mail'); 
    3851     
     
    4255    } 
    4356  }  
    44   else if /* ALBUM page */ 
     57  /* ALBUM page */ 
     58  else if  
    4559    ( 
    4660      script_basename() == 'index' AND isset($page['section']) AND 
     
    4963    ) 
    5064  { 
     65    $location = 'album'; 
    5166    add_event_handler('user_comment_insertion', 'replyto_parse_album_mail'); 
    5267     
     
    5772  } 
    5873   
     74 
    5975  /* we come from comments.php page */ 
    60   if ( !empty($_GET['reply_to']) and !empty($_GET['reply_to_a']) ) 
    61   { 
    62     $lang['Comment'].= ' 
    63     <script type="text/javascript"> 
    64       $(document).ready(function(){ 
    65         jQuery("#'.$template->get_template_vars('replyto_form_name').' textarea").insertAtCaret("[reply='.$_GET['reply_to'].']'.$_GET['reply_to_a'].'[/reply] "); 
    66       }); 
    67     </script>'; 
    68   } 
    69 } 
    70  
    71 /** 
    72  * links to commentform on comments.php page 
     76  if ( !empty($_GET['rt']) and !empty($_GET['rta']) ) 
     77  { 
     78    if ($location == 'picture') 
     79    { 
     80      $template->set_prefilter('picture', 'replyto_fillform_prefilter'); 
     81    } 
     82    else 
     83    { 
     84      $template->set_prefilter('comments_on_albums', 'replyto_fillform_prefilter'); 
     85    }     
     86  } 
     87} 
     88 
     89/** 
     90 * add reply tag from values given in url 
     91 */ 
     92function replyto_fillform_prefilter($content, &$smarty) 
     93{ 
     94  $search = '<ul class="commentsList">'; 
     95  $replace = '{footer_script require=\'insertAtCaret\'}replyTo("'.$_GET['rt'].'", "'.$_GET['rta'].'");{/footer_script}'.$search; 
     96  return str_replace($search, $replace, $content); 
     97} 
     98 
     99/** 
     100 * reply buttons on comments.php page 
    73101 */ 
    74102function replyto_add_link_comments_prefilter($content, &$smarty) 
    75 { 
    76   global $template; 
    77   $comments = $template->get_template_vars('comments'); 
    78    
    79   if (!count($comments)) return $content; 
    80    
    81   foreach ($comments as $tpl_var) 
    82   { 
    83     $replyto_links[ $tpl_var['ID'] ] = get_absolute_root_url().$tpl_var['U_PICTURE'].'&reply_to='.$tpl_var['ID'].'&reply_to_a='.$tpl_var['AUTHOR'].'#commentform'; 
    84   } 
    85    
    86   $template->assign('replyto_links', $replyto_links); 
    87    
    88     // style 
    89   $search[0] = '<ul class="thumbnailCategories">'; 
     103{  
     104  // style 
     105  $search[0] = '<ul class="commentsList">'; 
    90106  $replace[0] = ' 
    91107{html_head} 
     
    93109  .replyTo {ldelim} 
    94110    display:inline-block; 
    95     width:16px; 
     111    background:url({$REPLYTO_PATH}reply.png) left top no-repeat; 
    96112    height:16px; 
    97     background:url({$REPLYTO_PATH}reply.png) center top no-repeat; 
     113    margin-left:20px; 
     114    padding-left:20px; 
    98115  } 
    99116  .replyTo:hover {ldelim} 
    100     background-position:center -16px; 
     117    background-position:left -16px; 
    101118  } 
    102119</style> 
     
    105122 
    106123  // button 
    107   $search[1] = '<span class="author">'; 
    108   $replace[1] = ' 
    109 {if not isset($comment.IN_EDIT)} 
    110 <div class="actions" style="float:right;"> 
    111   <a href="{$replyto_links[$comment.ID]}" title="{\'reply to this comment\'|@translate}" class="replyTo">&nbsp;</a> 
    112 </div> 
    113 {/if}' 
    114 .$search[1]; 
     124  $search[1] = '<span class="commentDate">{$comment.DATE}</span>'; 
     125  $replace[1] = $search[1].'<a href="{$replyto_links[$comment.ID]}" class="replyTo">{\'Reply\'|@translate}</a>'; 
    115126   
    116127  return str_replace($search, $replace, $content); 
     
    118129 
    119130/** 
    120  * links to commentform on picture.php (and index.php) page(s) 
     131 * reply buttons on picture.php and index.php pages 
    121132 */ 
    122133function replyto_add_link_prefilter($content, &$smarty) 
    123134{ 
    124135  // script & style 
    125   $search[0] = '<ul class="thumbnailCategories">'; 
     136  $search[0] = '<ul class="commentsList">'; 
    126137  $replace[0] = ' 
    127138{combine_script id=\'insertAtCaret\' require=\'jquery\' path=$REPLYTO_PATH|@cat:\'insertAtCaret.js\'} 
     
    137148  .replyTo {ldelim} 
    138149    display:inline-block; 
    139     width:16px; 
     150    background:url({$REPLYTO_PATH}reply.png) left top no-repeat; 
    140151    height:16px; 
    141     background:url({$REPLYTO_PATH}reply.png) center top no-repeat; 
     152    margin-left:20px; 
     153    padding-left:20px; 
    142154  } 
    143155  .replyTo:hover {ldelim} 
    144     background-position:center -16px; 
     156    background-position:left -16px; 
    145157  } 
    146158</style> 
     
    149161 
    150162  // button 
    151   $search[1] = '<span class="author">'; 
    152   $replace[1] = ' 
    153 {if not isset($comment.IN_EDIT)} 
    154 <div class="actions" style="float:right;"> 
    155   <a href="#commentform" title="{\'reply to this comment\'|@translate}" class="replyTo" onclick="replyTo(\'{$comment.ID}\', \'{$comment.AUTHOR}\');">&nbsp;</a> 
    156 </div> 
    157 {/if}' 
    158 .$search[1]; 
    159    
    160   // anchor 
    161   $search[2] = '<div class="thumbnailCategory'; 
    162   $replace[2] = ' 
    163 <a name="comment-{$comment.ID}"></a>' 
    164 .$search[2]; 
    165  
    166   $search[3] = '<legend>{\'Add a comment\'|@translate}</legend>'; 
    167   $replace[3] = $search[3].' 
    168 <a name="commentform"></a>'; 
     163  $search[1] = '<span class="commentDate">{$comment.DATE}</span>'; 
     164  $replace[1] = $search[1].'<a href="#commentform" class="replyTo" onclick="replyTo(\'{$comment.ID}\', \'{$comment.AUTHOR}\');">{\'Reply\'|@translate}</a>'; 
     165   
     166  // anchors 
     167  $search[2] = '<li class="commentElement'; 
     168  $replace[2] = '<a name="comment-{$comment.ID}"></a>'.$search[2]; 
     169 
     170  $search[3] = '<div id="commentAdd">'; 
     171  $replace[3] = $search[3].'<a name="commentform"></a>'; 
    169172 
    170173  return str_replace($search, $replace, $content); 
     
    185188      $query = ' 
    186189SELECT 
    187   img.id, 
    188   img.file, 
    189   cat.category_id 
    190 FROM ' . IMAGES_TABLE . ' AS img 
    191 INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS cat 
    192   ON cat.image_id = img.id 
    193 INNER JOIN ' . COMMENTS_TABLE . ' AS com 
    194   ON com.image_id = img.id 
    195 WHERE com.id = ' . $matches[1] . ' 
     190    img.id, 
     191    img.file, 
     192    cat.category_id 
     193  FROM ' . IMAGES_TABLE . ' AS img 
     194    INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS cat 
     195      ON cat.image_id = img.id 
     196    INNER JOIN ' . COMMENTS_TABLE . ' AS com 
     197      ON com.image_id = img.id 
     198  WHERE com.id = ' . $matches[1] . ' 
    196199;'; 
    197200      $result = pwg_query($query); 
     
    205208        $query = ' 
    206209SELECT  
    207   id,  
    208   name,  
    209   permalink,  
    210   uppercats 
    211 FROM ' . CATEGORIES_TABLE . ' 
    212 WHERE id = ' . $image['category_id'] . ' 
     210    id,  
     211    name,  
     212    permalink,  
     213    uppercats 
     214  FROM ' . CATEGORIES_TABLE . ' 
     215  WHERE id = ' . $image['category_id'] . ' 
    213216;'; 
    214217        $image['cat'] = pwg_db_fetch_assoc(pwg_query($query)); 
     
    234237      $query = ' 
    235238SELECT 
    236   cat.id,  
    237   cat.name,  
    238   cat.permalink,  
    239   cat.uppercats 
    240 FROM ' . COA_TABLE . ' AS com 
    241 INNER JOIN ' . CATEGORIES_TABLE . ' AS cat 
    242   ON cat.id = com.category_id 
    243 WHERE com.id = ' . $matches[1] . ' 
     239    cat.id,  
     240    cat.name,  
     241    cat.permalink,  
     242    cat.uppercats 
     243  FROM ' . COA_TABLE . ' AS com 
     244    INNER JOIN ' . CATEGORIES_TABLE . ' AS cat 
     245      ON cat.id = com.category_id 
     246  WHERE com.id = ' . $matches[1] . ' 
    244247;'; 
    245248      $result = pwg_query($query); 
Note: See TracChangeset for help on using the changeset viewer.