Changeset 26677


Ignore:
Timestamp:
01/13/14 13:18:18 (5 years ago)
Author:
mistic100
Message:

compatibility with Comments on Albums for 2.6

Location:
extensions/reply_to
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/reply_to/main.inc.php

    r15645 r26677  
    44Version: auto 
    55Description: This plugin allows you to add Twitter-like reply links to comments. 
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=556 
     6Plugin URI: auto 
    77Author: Mistic 
    88Author URI: http://www.strangeplanet.fr 
    99*/ 
    1010 
    11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 
     11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 
    1212 
    1313global $page; 
    1414 
    15 define('REPLYTO_DIR' , basename(dirname(__FILE__))); 
    16 define('REPLYTO_PATH' , PHPWG_PLUGINS_PATH . REPLYTO_DIR . '/'); 
     15define('REPLYTO_ID' ,  basename(dirname(__FILE__))); 
     16define('REPLYTO_PATH' , PHPWG_PLUGINS_PATH . REPLYTO_ID . '/'); 
    1717 
    1818add_event_handler('init', 'replyto_init'); 
     
    2424 
    2525  add_event_handler('render_comment_content', 'replyto_parse', 60, 2); 
    26   if (script_basename() == 'comments') add_event_handler('loc_after_page_header', 'replyto_add_link'); 
    27   else add_event_handler('loc_end_section_init', 'replyto_add_link'); 
     26  if (script_basename() == 'comments') 
     27  { 
     28    add_event_handler('loc_end_comments', 'replyto_add_link', 60); 
     29  } 
     30  else 
     31  { 
     32    add_event_handler('loc_end_section_init', 'replyto_add_link'); 
     33  } 
    2834} 
    29      
    30 ?> 
  • extensions/reply_to/reply_to.inc.php

    r21327 r26677  
    11<?php  
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 
     2defined('REPLYTO_PATH') or die('Hacking attempt!'); 
    33 
    44define('REPLYTO_REGEX', '#\[reply=([0-9]+)\]([^\[\]]*)\[/reply\]#i'); 
     
    1111  global $pwg_loaded_plugins, $template, $page, $conf, $lang; 
    1212  $template->assign('REPLYTO_PATH', REPLYTO_PATH); 
    13   $location = null; 
    1413   
    1514  // comment form has different id 
    1615  if ( 
    17     (isset($_GET['action']) AND $_GET['action'] == 'edit_comment') OR  
    18     (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage') 
     16    (isset($_GET['action']) and $_GET['action'] == 'edit_comment') or  
     17    (isset($page['body_id']) and $page['body_id'] == 'theCommentsPage') 
    1918    )  
    2019  { 
     
    2928  if (script_basename() == 'comments')  
    3029  { 
    31     if ( !is_a_guest() OR $conf['comments_forall'] ) 
    32     { 
    33       $comments = &$template->get_template_vars('comments'); 
    34       if (!count($comments)) return; 
     30    if (!is_a_guest() or $conf['comments_forall']) 
     31    { 
     32      $comments = $template->get_template_vars('comments'); 
     33      if (!count($comments)) 
     34      { 
     35        return; 
     36      } 
    3537       
    3638      // generates urls to picture or albums with necessary url params 
     
    4648      } 
    4749       
     50      var_dump($replyto_links); 
     51       
    4852      $template->assign('replyto_links', $replyto_links); 
    4953      $template->set_prefilter('comments', 'replyto_add_link_comments_prefilter'); 
     
    5357  else if (script_basename() == 'picture')  
    5458  { 
    55     $location = 'picture'; 
    5659    add_event_handler('user_comment_insertion', 'replyto_parse_picture_mail'); 
    5760     
    58     if ( !is_a_guest() OR $conf['comments_forall'] ) 
     61    if (!is_a_guest() or $conf['comments_forall']) 
    5962    { 
    6063      $template->set_prefilter('picture', 'replyto_add_link_prefilter'); 
     
    6265  }  
    6366  /* ALBUM page */ 
    64   else if  
    65     ( 
    66       script_basename() == 'index' AND isset($page['section']) AND 
    67       isset($pwg_loaded_plugins['Comments_on_Albums']) AND  
    68       $page['section'] == 'categories' AND isset($page['category']) 
     67  else if ( 
     68      script_basename() == 'index' and isset($page['section']) and 
     69      isset($pwg_loaded_plugins['Comments_on_Albums']) and  
     70      $page['section'] == 'categories' and isset($page['category']) 
    6971    ) 
    7072  { 
    71     $location = 'album'; 
    7273    add_event_handler('user_comment_insertion', 'replyto_parse_album_mail'); 
    7374     
    74     if ( !is_a_guest() OR $conf['comments_forall'] ) 
     75    if (!is_a_guest() or $conf['comments_forall']) 
    7576    { 
    7677      $template->set_prefilter('comments_on_albums', 'replyto_add_link_prefilter'); 
     
    8081 
    8182  /* we come from comments.php page */ 
    82   if ( !empty($_GET['rt']) and !empty($_GET['rta']) ) 
    83   { 
    84     if ($location == 'picture') 
    85     { 
    86       $template->set_prefilter('picture', 'replyto_fillform_prefilter'); 
    87     } 
    88     else 
    89     { 
    90       $template->set_prefilter('comments_on_albums', 'replyto_fillform_prefilter'); 
    91     }     
    92   } 
    93 } 
    94  
    95 /** 
    96  * add reply tag from values given in url 
    97  */ 
    98 function replyto_fillform_prefilter($content, &$smarty) 
    99 { 
    100   $search = '<ul class="commentsList">'; 
    101   $replace = '{footer_script require=\'insertAtCaret\'}replyTo("'.$_GET['rt'].'", "'.$_GET['rta'].'");{/footer_script}'.$search; 
    102   return str_replace($search, $replace, $content); 
     83  if (!empty($_GET['rt']) and !empty($_GET['rta'])) 
     84  { 
     85    $template->func_combine_script(array('id'=>'insertAtCaret', 'path'=>REPLYTO_PATH.'insertAtCaret.js')); 
     86    $template->block_footer_script(array('require'=>'insertAtCaret'), 'replyTo("'.$_GET['rt'].'", "'.$_GET['rta'].'");'); 
     87  } 
    10388} 
    10489 
     
    10691 * reply buttons on comments.php page 
    10792 */ 
    108 function replyto_add_link_comments_prefilter($content, &$smarty) 
     93function replyto_add_link_comments_prefilter($content) 
    10994{  
    11095  // style 
    111   $search[0] = '<ul class="commentsList">'; 
    112   $replace[0] = ' 
    113 {html_head} 
    114 <style type="text/css"> 
    115   .replyTo {ldelim} 
    116     display:none; 
    117     background:url({$ROOT_URL}{$REPLYTO_PATH}reply.png) left top no-repeat; 
    118     height:16px; 
    119     margin-left:20px; 
    120     padding-left:20px; 
    121   } 
    122   li.commentElement:hover .replyTo {ldelim} 
    123     display:inline; 
    124   } 
    125   .replyTo:hover {ldelim} 
    126     background-position:left -16px; 
    127   } 
    128 </style> 
    129 {/html_head}' 
    130 .$search[0]; 
     96  $content.= ' 
     97{html_style} 
     98.replyTo { 
     99  display:none; 
     100  background:url({$ROOT_URL}{$REPLYTO_PATH}reply.png) left top no-repeat; 
     101  height:16px; 
     102  margin-left:20px; 
     103  padding-left:20px; 
     104} 
     105li.commentElement:hover .replyTo { 
     106  display:inline; 
     107} 
     108.replyTo:hover { 
     109  background-position:left -16px; 
     110} 
     111{/html_style}'; 
    131112 
    132113  // button 
    133   $search[1] = '<span class="commentDate">{$comment.DATE}</span>'; 
    134   $replace[1] = $search[1].'<a href="{$replyto_links[$comment.ID]}" class="replyTo">{\'Reply\'|@translate}</a>'; 
     114  $search = '<span class="commentDate">{$comment.DATE}</span>'; 
     115  $replace = $search.'<a href="{$replyto_links[$comment.ID]}" class="replyTo">{\'Reply\'|@translate}</a>'; 
    135116   
    136117  return str_replace($search, $replace, $content); 
     
    143124{ 
    144125  // script & style 
    145   $search[0] = '<ul class="commentsList">'; 
    146   $replace[0] = ' 
    147 {combine_script id=\'insertAtCaret\' require=\'jquery\' path=$REPLYTO_PATH|@cat:\'insertAtCaret.js\'} 
     126  $content.= ' 
     127{combine_script id=\'insertAtCaret\' require=\'jquery\' path=$REPLYTO_PATH|cat:\'insertAtCaret.js\'} 
    148128 
    149129{footer_script require=\'insertAtCaret\'} 
    150 function replyTo(commentID, author) {ldelim} 
    151   jQuery("#{$replyto_form_name} textarea").insertAtCaret("[reply=" + commentID + "]" + author + "[/reply] "); 
     130function replyTo(commentID, author) { 
     131  jQuery("#{$replyto_form_name} textarea").insertAtCaret("[reply=" + commentID + "]" + author + "[/reply] ").focus(); 
    152132} 
    153133{/footer_script} 
    154134 
    155 {html_head} 
    156 <style type="text/css"> 
    157   .replyTo {ldelim} 
    158     display:none; 
    159     background:url({$ROOT_URL}{$REPLYTO_PATH}reply.png) left top no-repeat; 
    160     height:16px; 
    161     margin-left:20px; 
    162     padding-left:20px; 
    163   } 
    164   li.commentElement:hover .replyTo {ldelim} 
    165     display:inline; 
    166   } 
    167   .replyTo:hover {ldelim} 
    168     background-position:left -16px; 
    169   } 
    170 </style> 
    171 {/html_head}' 
    172 .$search[0]; 
     135{html_style} 
     136.replyTo { 
     137  display:none; 
     138  background:url({$ROOT_URL}{$REPLYTO_PATH}reply.png) left top no-repeat; 
     139  height:16px; 
     140  margin-left:20px; 
     141  padding-left:20px; 
     142} 
     143li.commentElement:hover .replyTo { 
     144  display:inline; 
     145} 
     146.replyTo:hover { 
     147  background-position:left -16px; 
     148} 
     149{/html_style}'; 
    173150 
    174151  // button 
     
    188165 
    189166/** 
    190  * Replace BBcode tag by a link with absolute url 
     167 * Replace reply tag by a link with absolute url 
    191168 */ 
    192169function replyto_parse($comment, $in_album = false) 
     
    300277  return $comment; 
    301278} 
    302  
    303 ?> 
Note: See TracChangeset for help on using the changeset viewer.