| [ Index ] |
PHP Cross Reference of Nucleus CMS 3.32 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 4 * Copyright (C) 2002-2007 The Nucleus Group 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * (see nucleus/documentation/index.html#license for more info) 11 */ 12 /** 13 * This class is used when parsing comment templates 14 * 15 * @license http://nucleuscms.org/license.txt GNU General Public License 16 * @copyright Copyright (C) 2002-2007 The Nucleus Group 17 * @version $Id: COMMENTACTIONS.php 1156 2007-05-20 23:47:36Z kaigreve $ 18 */ 19 20 class COMMENTACTIONS extends BaseActions { 21 22 // ref to COMMENTS object which is using this object to handle 23 // its templatevars 24 var $commentsObj; 25 26 // template to use to parse the comments 27 var $template; 28 29 // comment currenlty being handled (mysql result assoc array; see COMMENTS::showComments()) 30 var $currentComment; 31 32 function COMMENTACTIONS(&$comments) { 33 // call constructor of superclass first 34 $this->BaseActions(); 35 36 // reference to the comments object 37 $this->setCommentsObj($comments); 38 } 39 40 function getDefinedActions() { 41 return array( 42 'blogurl', 43 'commentcount', 44 'commentword', 45 'email', 46 'itemlink', 47 'itemid', 48 'itemtitle', 49 'date', 50 'time', 51 'commentid', 52 'body', 53 'memberid', 54 'timestamp', 55 'host', 56 'ip', 57 'blogid', 58 'authtext', 59 'user', 60 'userid', 61 'userlinkraw', 62 'userlink', 63 'useremail', 64 'userwebsite', 65 'excerpt', 66 'short', 67 'skinfile', 68 'set', 69 'plugin', 70 'include', 71 'phpinclude', 72 'parsedinclude' 73 ); 74 } 75 76 function setParser(&$parser) { 77 $this->parser =& $parser; 78 } 79 80 function setCommentsObj(&$commentsObj) { 81 $this->commentsObj =& $commentsObj; 82 } 83 84 function setTemplate($template) { 85 $this->template =& $template; 86 } 87 88 function setCurrentComment(&$comment) { 89 global $manager; 90 if ($comment['memberid'] != 0) { 91 $comment['authtext'] = $template['COMMENTS_AUTH']; 92 93 $mem =& $manager->getMember($comment['memberid']); 94 $comment['user'] = $mem->getDisplayName(); 95 if ($mem->getURL()) 96 $comment['userid'] = $mem->getURL(); 97 else 98 $comment['userid'] = $mem->getEmail(); 99 100 $comment['userlinkraw'] = createLink( 101 'member', 102 array( 103 'memberid' => $comment['memberid'], 104 'name' => $mem->getDisplayName(), 105 'extra' => $this->commentsObj->itemActions->linkparams 106 ) 107 ); 108 109 } else { 110 111 // create smart links 112 /* if (isValidMailAddress($comment['userid'])) 113 $comment['userlinkraw'] = 'mailto:'.$comment['userid']; 114 elseif (strstr($comment['userid'],'http://') != false) 115 $comment['userlinkraw'] = $comment['userid']; 116 elseif (strstr($comment['userid'],'www') != false) 117 $comment['userlinkraw'] = 'http://'.$comment['userid'];*/ 118 if (strstr($comment['userid'],'http://') != false) 119 $comment['userlinkraw'] = $comment['userid']; 120 elseif (strstr($comment['userid'],'www') != false) 121 $comment['userlinkraw'] = 'http://'.$comment['userid']; 122 elseif (isValidMailAddress($comment['email'])) 123 $comment['userlinkraw'] = 'mailto:'.$comment['email']; 124 elseif (isValidMailAddress($comment['userid'])) 125 $comment['userlinkraw'] = 'mailto:'.$comment['userid']; 126 } 127 128 $this->currentComment =& $comment; 129 } 130 131 function parse_blogurl() { 132 global $manager; 133 $blogid = getBlogIDFromItemID($this->commentsObj->itemid); 134 $blog =& $manager->getBlog($blogid); 135 echo $blog->getURL(); 136 } 137 138 function parse_commentcount() { 139 echo $this->commentsObj->commentcount; 140 } 141 142 function parse_commentword() { 143 if ($this->commentsObj->commentcount == 1) 144 echo $this->template['COMMENTS_ONE']; 145 else 146 echo $this->template['COMMENTS_MANY']; 147 } 148 149 function parse_itemlink() { 150 echo createLink( 151 'item', 152 array( 153 'itemid' => $this->commentsObj->itemid, 154 'timestamp' => $this->commentsObj->itemActions->currentItem->timestamp, 155 'title' => $this->commentsObj->itemActions->currentItem->title, 156 'extra' => $this->commentsObj->itemActions->linkparams 157 ) 158 ); 159 } 160 161 function parse_itemid() { 162 echo $this->commentsObj->itemid; 163 } 164 165 function parse_itemtitle($maxLength = 0) { 166 if ($maxLength == 0) 167 $this->commentsObj->itemActions->parse_title(); 168 else 169 $this->commentsObj->itemActions->parse_syndicate_title($maxLength); 170 } 171 172 function parse_date($format = '') { 173 echo formatDate($format, $this->currentComment['timestamp'], $this->template['FORMAT_DATE'], $this->commentsObj->itemActions->blog); 174 } 175 176 function parse_time($format = '') { 177 echo strftime( 178 ($format == '') ? $this->template['FORMAT_TIME'] : $format, 179 $this->currentComment['timestamp'] 180 ); 181 } 182 183 function parse_commentid() { 184 echo $this->currentComment['commentid']; 185 } 186 187 function parse_body() { 188 echo $this->highlight($this->currentComment['body']); 189 } 190 191 function parse_memberid() { 192 echo $this->currentComment['memberid']; 193 } 194 195 function parse_timestamp() { 196 echo $this->currentComment['timestamp']; 197 } 198 199 function parse_host() { 200 echo $this->currentComment['host']; 201 } 202 203 function parse_ip() { 204 echo $this->currentComment['ip']; 205 } 206 207 function parse_blogid() { 208 echo $this->currentComment['blogid']; 209 } 210 211 // function parse_user() { 212 function parse_user($mode='') { 213 global $manager; 214 if ($mode == 'realname' && $this->currentComment['memberid'] > 0) { 215 $member =& $manager->getMember($this->currentComment['memberid']); 216 echo $member->getRealName(); 217 } else { 218 echo $this->currentComment['user']; 219 } 220 } 221 222 function parse_userid() { 223 echo $this->currentComment['userid']; 224 } 225 226 function parse_email() { 227 $email = $this->currentComment['email']; 228 $email = str_replace('@', ' (at) ', $email); 229 $email = str_replace('.', ' (dot) ', $email); 230 echo $email; 231 } 232 233 function parse_userlinkraw() { 234 echo $this->currentComment['userlinkraw']; 235 } 236 237 function parse_userlink() { 238 if ($this->currentComment['userlinkraw']) { 239 echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>'; 240 } else { 241 echo $this->currentComment['user']; 242 } 243 } 244 245 function parse_useremail() { 246 global $manager; 247 if ($this->currentComment['memberid'] > 0) 248 { 249 $member =& $manager->getMember($this->currentComment['memberid']); 250 251 if ($member->email != '') 252 echo $member->email; 253 } 254 else 255 { 256 if (isValidMailAddress($this->currentComment['email'])) 257 echo $this->currentComment['email']; 258 elseif (isValidMailAddress($this->currentComment['userid'])) 259 echo $this->currentComment['userid']; 260 // if (!(strpos($this->currentComment['userlinkraw'], 'mailto:') === false)) 261 // echo str_replace('mailto:', '', $this->currentComment['userlinkraw']); 262 } 263 } 264 265 function parse_userwebsite() { 266 if (!(strpos($this->currentComment['userlinkraw'], 'http://') === false)) 267 echo $this->currentComment['userlinkraw']; 268 } 269 270 function parse_excerpt() { 271 echo stringToXML(shorten($this->currentComment['body'], 60, '...')); 272 } 273 274 function parse_short() { 275 $tmp = strtok($this->currentComment['body'],"\n"); 276 $tmp = str_replace('<br />','',$tmp); 277 echo $tmp; 278 if ($tmp != $this->currentComment['body']) 279 $this->parser->parse($this->template['COMMENTS_CONTINUED']); 280 } 281 282 function parse_authtext() { 283 if ($this->currentComment['memberid'] != 0) 284 $this->parser->parse($this->template['COMMENTS_AUTH']); 285 } 286 287 /** 288 * Executes a plugin templatevar 289 * 290 * @param pluginName name of plugin (without the NP_) 291 * 292 * extra parameters can be added 293 */ 294 function parse_plugin($pluginName) { 295 global $manager; 296 297 // only continue when the plugin is really installed 298 if (!$manager->pluginInstalled('NP_' . $pluginName)) 299 return; 300 301 $plugin =& $manager->getPlugin('NP_' . $pluginName); 302 if (!$plugin) return; 303 304 // get arguments 305 $params = func_get_args(); 306 307 // remove plugin name 308 array_shift($params); 309 310 // pass info on current item and current comment as well 311 $params = array_merge(array(&$this->currentComment),$params); 312 $params = array_merge(array(&$this->commentsObj->itemActions->currentItem),$params); 313 314 call_user_func_array(array(&$plugin,'doTemplateCommentsVar'), $params); 315 } 316 } 317 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Feb 12 15:34:36 2008 | Cross-referenced by PHPXref 0.7 |