Changeset 26677 for extensions/reply_to/reply_to.inc.php
- Timestamp:
- Jan 13, 2014, 1:18:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/reply_to/reply_to.inc.php
r21327 r26677 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('REPLYTO_PATH') or die('Hacking attempt!'); 3 3 4 4 define('REPLYTO_REGEX', '#\[reply=([0-9]+)\]([^\[\]]*)\[/reply\]#i'); … … 11 11 global $pwg_loaded_plugins, $template, $page, $conf, $lang; 12 12 $template->assign('REPLYTO_PATH', REPLYTO_PATH); 13 $location = null;14 13 15 14 // comment form has different id 16 15 if ( 17 (isset($_GET['action']) AND $_GET['action'] == 'edit_comment') OR18 (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') 19 18 ) 20 19 { … … 29 28 if (script_basename() == 'comments') 30 29 { 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 } 35 37 36 38 // generates urls to picture or albums with necessary url params … … 46 48 } 47 49 50 var_dump($replyto_links); 51 48 52 $template->assign('replyto_links', $replyto_links); 49 53 $template->set_prefilter('comments', 'replyto_add_link_comments_prefilter'); … … 53 57 else if (script_basename() == 'picture') 54 58 { 55 $location = 'picture';56 59 add_event_handler('user_comment_insertion', 'replyto_parse_picture_mail'); 57 60 58 if ( !is_a_guest() OR $conf['comments_forall'])61 if (!is_a_guest() or $conf['comments_forall']) 59 62 { 60 63 $template->set_prefilter('picture', 'replyto_add_link_prefilter'); … … 62 65 } 63 66 /* 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']) 69 71 ) 70 72 { 71 $location = 'album';72 73 add_event_handler('user_comment_insertion', 'replyto_parse_album_mail'); 73 74 74 if ( !is_a_guest() OR $conf['comments_forall'])75 if (!is_a_guest() or $conf['comments_forall']) 75 76 { 76 77 $template->set_prefilter('comments_on_albums', 'replyto_add_link_prefilter'); … … 80 81 81 82 /* 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 } 103 88 } 104 89 … … 106 91 * reply buttons on comments.php page 107 92 */ 108 function replyto_add_link_comments_prefilter($content , &$smarty)93 function replyto_add_link_comments_prefilter($content) 109 94 { 110 95 // 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 } 105 li.commentElement:hover .replyTo { 106 display:inline; 107 } 108 .replyTo:hover { 109 background-position:left -16px; 110 } 111 {/html_style}'; 131 112 132 113 // 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>'; 135 116 136 117 return str_replace($search, $replace, $content); … … 143 124 { 144 125 // 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\'} 148 128 149 129 {footer_script require=\'insertAtCaret\'} 150 function replyTo(commentID, author) { ldelim}151 jQuery("#{$replyto_form_name} textarea").insertAtCaret("[reply=" + commentID + "]" + author + "[/reply] ") ;130 function replyTo(commentID, author) { 131 jQuery("#{$replyto_form_name} textarea").insertAtCaret("[reply=" + commentID + "]" + author + "[/reply] ").focus(); 152 132 } 153 133 {/footer_script} 154 134 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 } 143 li.commentElement:hover .replyTo { 144 display:inline; 145 } 146 .replyTo:hover { 147 background-position:left -16px; 148 } 149 {/html_style}'; 173 150 174 151 // button … … 188 165 189 166 /** 190 * Replace BBcodetag by a link with absolute url167 * Replace reply tag by a link with absolute url 191 168 */ 192 169 function replyto_parse($comment, $in_album = false) … … 300 277 return $comment; 301 278 } 302 303 ?>
Note: See TracChangeset
for help on using the changeset viewer.