Changeset 12389


Ignore:
Timestamp:
10/08/11 20:30:16 (8 years ago)
Author:
mistic100
Message:

activate replyTo button on comments.php

Location:
extensions/reply_to
Files:
2 edited

Legend:

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

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

    r11416 r12389  
    99function replyto_add_link() 
    1010{ 
    11   global $pwg_loaded_plugins, $template, $page, $conf; 
     11  global $pwg_loaded_plugins, $template, $page, $conf, $lang; 
    1212  $template->assign('REPLYTO_PATH', REPLYTO_PATH); 
    1313   
     
    2525  } 
    2626   
    27   // must check our location + some additional tests 
    28   // if (script_basename() == 'comments') 
    29   // { 
    30     // if ( !is_a_guest() OR $conf['comments_forall'] ) 
    31     // { 
    32       // $template->set_prefilter('comments', 'replyto_add_link_prefilter'); 
    33     // } 
    34   // } 
    35   // else  
    36   if (script_basename() == 'picture') 
     27  // must check our location 
     28  if (script_basename() == 'comments') /* COMMENTS page */ 
     29  { 
     30    if ( !is_a_guest() OR $conf['comments_forall'] ) 
     31    { 
     32      $template->set_prefilter('comments', 'replyto_add_link_comments_prefilter'); 
     33    } 
     34  } 
     35  else if (script_basename() == 'picture') /* PICTURE page */ 
    3736  { 
    3837    add_event_handler('user_comment_insertion', 'replyto_parse_picture_mail'); 
     
    4342    } 
    4443  }  
    45   else if  
     44  else if /* ALBUM page */ 
    4645    ( 
    4746      script_basename() == 'index' AND isset($page['section']) AND 
     
    5756    } 
    5857  } 
    59 } 
    60  
     58   
     59  /* 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 
     73 */ 
     74function replyto_add_link_comments_prefilter($content, &$smarty) 
     75{ 
     76  global $template; 
     77  $comments = $template->get_template_vars('comments'); 
     78   
     79  foreach ($comments as $tpl_var) 
     80  { 
     81    $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'; 
     82  } 
     83   
     84  $template->assign('replyto_links', $replyto_links); 
     85   
     86    // style 
     87  $search[0] = '<ul class="thumbnailCategories">'; 
     88  $replace[0] = ' 
     89{html_head} 
     90<style type="text/css"> 
     91  .replyTo {ldelim} 
     92    display:inline-block; 
     93    width:16px; 
     94    height:16px; 
     95    background:url({$REPLYTO_PATH}reply.png) center top no-repeat; 
     96  } 
     97  .replyTo:hover {ldelim} 
     98    background-position:center -16px; 
     99  } 
     100</style> 
     101{/html_head}' 
     102.$search[0]; 
     103 
     104  // button 
     105  $search[1] = '<span class="author">'; 
     106  $replace[1] = ' 
     107{if not isset($comment.IN_EDIT)} 
     108<div class="actions" style="float:right;"> 
     109  <a href="{$replyto_links[$comment.ID]}" title="{\'reply to this comment\'|@translate}" class="replyTo">&nbsp;</a> 
     110</div> 
     111{/if}' 
     112.$search[1]; 
     113   
     114  return str_replace($search, $replace, $content); 
     115} 
     116 
     117/** 
     118 * links to commentform on picture.php (and index.php) page(s) 
     119 */ 
    61120function replyto_add_link_prefilter($content, &$smarty) 
    62121{ 
    63   // script 
     122  // script & style 
    64123  $search[0] = '<ul class="thumbnailCategories">'; 
    65124  $replace[0] = ' 
     
    168227    }  
    169228    /* try to parse a ReplyTo tag link for an album */ 
    170     else 
     229    else if ( $in_album == 'album') 
    171230    {     
    172231      // retrieving category informations 
Note: See TracChangeset for help on using the changeset viewer.