* @version $Id$
* @version $NucleusJP: COMMENTACTIONS.php,v 1.5.2.1 2007/08/08 05:31:31 kimitake Exp $
*/
-\r
-class COMMENTACTIONS extends BaseActions {\r
-\r
- // ref to COMMENTS object which is using this object to handle\r
- // its templatevars\r
- var $commentsObj;\r
-\r
- // template to use to parse the comments\r
- var $template;\r
-\r
- // comment currenlty being handled (mysql result assoc array; see COMMENTS::showComments())\r
- var $currentComment;\r
-\r
- function COMMENTACTIONS(&$comments) {\r
- // call constructor of superclass first\r
- $this->BaseActions();\r
-\r
- // reference to the comments object\r
- $this->setCommentsObj($comments);\r
- }\r
-\r
- function getDefinedActions() {\r
- return array(\r
- 'blogurl',\r
- 'commentcount',\r
- 'commentword',\r
- 'email',\r
- 'itemlink',\r
- 'itemid',\r
- 'itemtitle',\r
- 'date',\r
- 'time',\r
- 'commentid',\r
- 'body',\r
- 'memberid',\r
- 'timestamp',\r
- 'host',\r
- 'ip',\r
- 'blogid',\r
- 'authtext',\r
- 'user',\r
- 'userid',\r
- 'userlinkraw',\r
- 'userlink',\r
- 'useremail',\r
- 'userwebsite',\r
- 'excerpt',\r
- 'short',\r
- 'skinfile',\r
- 'set',\r
- 'plugin',\r
- 'include',\r
- 'phpinclude',\r
- 'parsedinclude'\r
- );\r
- }\r
-\r
- function setParser(&$parser) {\r
- $this->parser =& $parser;\r
- }\r
- \r
- function setCommentsObj(&$commentsObj) {\r
- $this->commentsObj =& $commentsObj;\r
- }\r
- \r
- function setTemplate($template) {\r
- $this->template =& $template;\r
- }\r
- \r
- function setCurrentComment(&$comment) {\r
- global $manager;\r
- if ($comment['memberid'] != 0) {\r
- $comment['authtext'] = $template['COMMENTS_AUTH'];\r
-\r
- $mem =& $manager->getMember($comment['memberid']);\r
- $comment['user'] = $mem->getDisplayName();\r
- if ($mem->getURL())\r
- $comment['userid'] = $mem->getURL();\r
- else\r
- $comment['userid'] = $mem->getEmail();\r
-\r
- $comment['userlinkraw'] = createLink(\r
- 'member',\r
- array(\r
- 'memberid' => $comment['memberid'],\r
- 'name' => $mem->getDisplayName(),\r
- 'extra' => $this->commentsObj->itemActions->linkparams\r
- )\r
- );\r
-\r
- } else {\r
-\r
- // create smart links\r
-/* if (isValidMailAddress($comment['userid']))\r
- $comment['userlinkraw'] = 'mailto:'.$comment['userid'];\r
- elseif (strstr($comment['userid'],'http://') != false)\r
- $comment['userlinkraw'] = $comment['userid'];\r
- elseif (strstr($comment['userid'],'www') != false)\r
- $comment['userlinkraw'] = 'http://'.$comment['userid'];*/\r
- if (strstr($comment['userid'],'http://') != false)\r
- $comment['userlinkraw'] = $comment['userid'];\r
- elseif (strstr($comment['userid'],'www') != false)\r
- $comment['userlinkraw'] = 'http://'.$comment['userid'];\r
- elseif (isValidMailAddress($comment['email']))\r
- $comment['userlinkraw'] = 'mailto:'.$comment['email'];\r
- elseif (isValidMailAddress($comment['userid']))\r
- $comment['userlinkraw'] = 'mailto:'.$comment['userid'];\r
- }\r
-\r
- $this->currentComment =& $comment;\r
- }\r
-\r
- /**\r
- * Parse templatevar authtext\r
- */\r
- function parse_authtext() {\r
- if ($this->currentComment['memberid'] != 0)\r
- $this->parser->parse($this->template['COMMENTS_AUTH']);\r
- }\r
-\r
- /**\r
- * Parse templatevar blogid\r
- */\r
- function parse_blogid() {\r
- echo $this->currentComment['blogid'];\r
- }\r
-\r
- /**\r
- * Parse templatevar blogurl\r
- */\r
- function parse_blogurl() {\r
- global $manager;\r
- $blogid = getBlogIDFromItemID($this->commentsObj->itemid);\r
- $blog =& $manager->getBlog($blogid);\r
- echo $blog->getURL();\r
- }\r
-\r
- /**\r
- * Parse templatevar body\r
- */\r
- function parse_body() {\r
- echo $this->highlight($this->currentComment['body']);\r
- }\r
-\r
- /**\r
- * Parse templatevar commentcount\r
- */\r
- function parse_commentcount() {\r
- echo $this->commentsObj->commentcount;\r
- }\r
-\r
- /**\r
- * Parse templatevar commentid\r
- */\r
- function parse_commentid() {\r
- echo $this->currentComment['commentid'];\r
- }\r
-\r
- /**\r
- * Parse templatevar commentword\r
- */\r
- function parse_commentword() {\r
- if ($this->commentsObj->commentcount == 1)\r
- echo $this->template['COMMENTS_ONE'];\r
- else\r
- echo $this->template['COMMENTS_MANY'];\r
- }\r
-\r
- /**\r
- * Parse templatevar date\r
- */\r
- function parse_date($format = '') {\r
- echo formatDate($format, $this->currentComment['timestamp'], $this->template['FORMAT_DATE'], $this->commentsObj->itemActions->blog);\r
- }\r
- \r
- /**\r
- * Parse templatevar email\r
- */\r
- function parse_email() {\r
- $email = $this->currentComment['email'];\r
- $email = str_replace('@', ' (at) ', $email);\r
- $email = str_replace('.', ' (dot) ', $email);\r
- echo $email;\r
- }\r
-\r
- /**\r
- * Parse templatevar excerpt\r
- */\r
- function parse_excerpt() {\r
- echo stringToXML(shorten($this->currentComment['body'], 60, '...'));\r
- }\r
-\r
- /**\r
- * Parse templatevar host\r
- */\r
- function parse_host() {\r
- echo $this->currentComment['host'];\r
- }\r
-\r
- /**\r
- * Parse templatevar ip\r
- */\r
- function parse_ip() {\r
- echo $this->currentComment['ip'];\r
- }\r
-\r
- /**\r
- * Parse templatevar itemid\r
- */\r
- function parse_itemid() {\r
- echo $this->commentsObj->itemid;\r
- }\r
-\r
- /**\r
- * Parse templatevar itemlink\r
- */\r
- function parse_itemlink() {\r
- echo createLink(\r
- 'item',\r
- array(\r
- 'itemid' => $this->commentsObj->itemid,\r
- 'timestamp' => $this->commentsObj->itemActions->currentItem->timestamp,\r
- 'title' => $this->commentsObj->itemActions->currentItem->title,\r
- 'extra' => $this->commentsObj->itemActions->linkparams\r
- )\r
- );\r
- }\r
-\r
- /**\r
- * Parse templatevar itemtitle\r
- */\r
- function parse_itemtitle($maxLength = 0) {\r
- if ($maxLength == 0)\r
- $this->commentsObj->itemActions->parse_title();\r
- else\r
- $this->commentsObj->itemActions->parse_syndicate_title($maxLength);\r
- }\r
-\r
- /**\r
- * Parse templatevar memberid\r
- */\r
- function parse_memberid() {\r
- echo $this->currentComment['memberid'];\r
- }\r
-\r
- /**\r
- * Parse templatevar short\r
- */\r
- function parse_short() {\r
- $tmp = strtok($this->currentComment['body'],"\n");\r
- $tmp = str_replace('<br />','',$tmp);\r
- echo $tmp;\r
- if ($tmp != $this->currentComment['body'])\r
- $this->parser->parse($this->template['COMMENTS_CONTINUED']);\r
- }\r
-\r
- /**\r
- * Parse templatevar time\r
- */\r
- function parse_time($format = '') {\r
- echo strftime(\r
- ($format == '') ? $this->template['FORMAT_TIME'] : $format,\r
- $this->currentComment['timestamp']\r
- );\r
- }\r
-\r
- /**\r
- * Parse templatevar timestamp\r
- */\r
- function parse_timestamp() {\r
- echo $this->currentComment['timestamp'];\r
- }\r
-\r
- /**\r
- * Executes a plugin templatevar\r
- *\r
- * @param pluginName name of plugin (without the NP_)\r
- *\r
- * extra parameters can be added\r
- */\r
- function parse_plugin($pluginName) {\r
- global $manager;\r
-\r
- // only continue when the plugin is really installed\r
- if (!$manager->pluginInstalled('NP_' . $pluginName))\r
- return;\r
-\r
- $plugin =& $manager->getPlugin('NP_' . $pluginName);\r
- if (!$plugin) return;\r
-\r
- // get arguments\r
- $params = func_get_args();\r
-\r
- // remove plugin name\r
- array_shift($params);\r
-\r
- // pass info on current item and current comment as well\r
- $params = array_merge(array(&$this->currentComment),$params);\r
- $params = array_merge(array(&$this->commentsObj->itemActions->currentItem),$params);\r
-\r
- call_user_func_array(array(&$plugin,'doTemplateCommentsVar'), $params);\r
- }\r
-\r
- /**\r
- * Parse templatevar user\r
- */\r
- function parse_user($mode='') {\r
- global $manager;\r
- if ($mode == 'realname' && $this->currentComment['memberid'] > 0) {\r
- $member =& $manager->getMember($this->currentComment['memberid']);\r
- echo $member->getRealName();\r
- } else {\r
- echo $this->currentComment['user'];\r
- }\r
- }\r
-\r
- /**\r
- * Parse templatevar useremail\r
- */\r
- function parse_useremail() {\r
- global $manager;\r
- if ($this->currentComment['memberid'] > 0)\r
- {\r
- $member =& $manager->getMember($this->currentComment['memberid']);\r
-\r
- if ($member->email != '')\r
- echo $member->email;\r
- }\r
- else\r
- {\r
- if (isValidMailAddress($this->currentComment['email']))\r
- echo $this->currentComment['email'];\r
- elseif (isValidMailAddress($this->currentComment['userid']))\r
- echo $this->currentComment['userid'];\r
-// if (!(strpos($this->currentComment['userlinkraw'], 'mailto:') === false))\r
-// echo str_replace('mailto:', '', $this->currentComment['userlinkraw']);\r
- }\r
- }\r
-\r
- /**\r
- * Parse templatevar userid\r
- */\r
- function parse_userid() {\r
- echo $this->currentComment['userid'];\r
- }\r
-\r
-\r
- /**\r
- * Parse templatevar userlink\r
- */\r
- function parse_userlink() {\r
- if ($this->currentComment['userlinkraw']) {\r
- echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';\r
- } else {\r
- echo $this->currentComment['user'];\r
- }\r
- }\r
-\r
- /**\r
- * Parse templatevar userlinkraw\r
- */\r
- function parse_userlinkraw() {\r
- echo $this->currentComment['userlinkraw'];\r
- }\r
- \r
- /**\r
- * Parse templatevar userwebsite\r
- */\r
- function parse_userwebsite() {\r
- if (!(strpos($this->currentComment['userlinkraw'], 'http://') === false))\r
- echo $this->currentComment['userlinkraw'];\r
- }\r
-\r
-}\r
+
+class COMMENTACTIONS extends BaseActions {
+
+ // ref to COMMENTS object which is using this object to handle
+ // its templatevars
+ var $commentsObj;
+
+ // template to use to parse the comments
+ var $template;
+
+ // comment currenlty being handled (mysql result assoc array; see COMMENTS::showComments())
+ var $currentComment;
+
+ function COMMENTACTIONS(&$comments) {
+ // call constructor of superclass first
+ $this->BaseActions();
+
+ // reference to the comments object
+ $this->setCommentsObj($comments);
+ }
+
+ function getDefinedActions() {
+ return array(
+ 'blogurl',
+ 'commentcount',
+ 'commentword',
+ 'email',
+ 'itemlink',
+ 'itemid',
+ 'itemtitle',
+ 'date',
+ 'time',
+ 'commentid',
+ 'body',
+ 'memberid',
+ 'timestamp',
+ 'host',
+ 'ip',
+ 'blogid',
+ 'authtext',
+ 'user',
+ 'userid',
+ 'userlinkraw',
+ 'userlink',
+ 'useremail',
+ 'userwebsite',
+ 'userwebsitelink',
+ 'excerpt',
+ 'short',
+ 'skinfile',
+ 'set',
+ 'plugin',
+ 'include',
+ 'phpinclude',
+ 'parsedinclude'
+ );
+ }
+
+ function setParser(&$parser) {
+ $this->parser =& $parser;
+ }
+
+ function setCommentsObj(&$commentsObj) {
+ $this->commentsObj =& $commentsObj;
+ }
+
+ function setTemplate($template) {
+ $this->template =& $template;
+ }
+
+ function setCurrentComment(&$comment) {
+ global $manager;
+ if ($comment['memberid'] != 0) {
+ $comment['authtext'] = $template['COMMENTS_AUTH'];
+
+ $mem =& $manager->getMember($comment['memberid']);
+ $comment['user'] = $mem->getDisplayName();
+ if ($mem->getURL())
+ $comment['userid'] = $mem->getURL();
+ else
+ $comment['userid'] = $mem->getEmail();
+
+ $comment['userlinkraw'] = createLink(
+ 'member',
+ array(
+ 'memberid' => $comment['memberid'],
+ 'name' => $mem->getDisplayName(),
+ 'extra' => $this->commentsObj->itemActions->linkparams
+ )
+ );
+
+ } else {
+
+ // create smart links
+/* if (isValidMailAddress($comment['userid']))
+ $comment['userlinkraw'] = 'mailto:'.$comment['userid'];
+ elseif (strstr($comment['userid'],'http://') != false)
+ $comment['userlinkraw'] = $comment['userid'];
+ elseif (strstr($comment['userid'],'www') != false)
+ $comment['userlinkraw'] = 'http://'.$comment['userid'];*/
+ if (strstr($comment['userid'],'http://') != false)
+ $comment['userlinkraw'] = $comment['userid'];
+ elseif (strstr($comment['userid'],'www') != false)
+ $comment['userlinkraw'] = 'http://'.$comment['userid'];
+ elseif (isValidMailAddress($comment['email']))
+ $comment['userlinkraw'] = 'mailto:'.$comment['email'];
+ elseif (isValidMailAddress($comment['userid']))
+ $comment['userlinkraw'] = 'mailto:'.$comment['userid'];
+ }
+
+ $this->currentComment =& $comment;
+ }
+
+ /**
+ * Parse templatevar authtext
+ */
+ function parse_authtext() {
+ if ($this->currentComment['memberid'] != 0)
+ $this->parser->parse($this->template['COMMENTS_AUTH']);
+ }
+
+ /**
+ * Parse templatevar blogid
+ */
+ function parse_blogid() {
+ echo $this->currentComment['blogid'];
+ }
+
+ /**
+ * Parse templatevar blogurl
+ */
+ function parse_blogurl() {
+ global $manager;
+ $blogid = getBlogIDFromItemID($this->commentsObj->itemid);
+ $blog =& $manager->getBlog($blogid);
+ echo $blog->getURL();
+ }
+
+ /**
+ * Parse templatevar body
+ */
+ function parse_body() {
+ echo $this->highlight($this->currentComment['body']);
+ }
+
+ /**
+ * Parse templatevar commentcount
+ */
+ function parse_commentcount() {
+ echo $this->commentsObj->commentcount;
+ }
+
+ /**
+ * Parse templatevar commentid
+ */
+ function parse_commentid() {
+ echo $this->currentComment['commentid'];
+ }
+
+ /**
+ * Parse templatevar commentword
+ */
+ function parse_commentword() {
+ if ($this->commentsObj->commentcount == 1)
+ echo $this->template['COMMENTS_ONE'];
+ else
+ echo $this->template['COMMENTS_MANY'];
+ }
+
+ /**
+ * Parse templatevar date
+ */
+ function parse_date($format = '') {
+ echo formatDate($format, $this->currentComment['timestamp'], $this->template['FORMAT_DATE'], $this->commentsObj->itemActions->blog);
+ }
+
+ /**
+ * Parse templatevar email
+ */
+ function parse_email() {
+ $email = $this->currentComment['email'];
+ $email = str_replace('@', ' (at) ', $email);
+ $email = str_replace('.', ' (dot) ', $email);
+ echo $email;
+ }
+
+ /**
+ * Parse templatevar excerpt
+ */
+ function parse_excerpt() {
+ echo stringToXML(shorten($this->currentComment['body'], 60, '...'));
+ }
+
+ /**
+ * Parse templatevar host
+ */
+ function parse_host() {
+ echo $this->currentComment['host'];
+ }
+
+ /**
+ * Parse templatevar ip
+ */
+ function parse_ip() {
+ echo $this->currentComment['ip'];
+ }
+
+ /**
+ * Parse templatevar itemid
+ */
+ function parse_itemid() {
+ echo $this->commentsObj->itemid;
+ }
+
+ /**
+ * Parse templatevar itemlink
+ */
+ function parse_itemlink() {
+ echo createLink(
+ 'item',
+ array(
+ 'itemid' => $this->commentsObj->itemid,
+ 'timestamp' => $this->commentsObj->itemActions->currentItem->timestamp,
+ 'title' => $this->commentsObj->itemActions->currentItem->title,
+ 'extra' => $this->commentsObj->itemActions->linkparams
+ )
+ );
+ }
+
+ /**
+ * Parse templatevar itemtitle
+ */
+ function parse_itemtitle($maxLength = 0) {
+ if ($maxLength == 0)
+ $this->commentsObj->itemActions->parse_title();
+ else
+ $this->commentsObj->itemActions->parse_syndicate_title($maxLength);
+ }
+
+ /**
+ * Parse templatevar memberid
+ */
+ function parse_memberid() {
+ echo $this->currentComment['memberid'];
+ }
+
+ /**
+ * Parse templatevar short
+ */
+ function parse_short() {
+ $tmp = strtok($this->currentComment['body'],"\n");
+ $tmp = str_replace('<br />','',$tmp);
+ echo $tmp;
+ if ($tmp != $this->currentComment['body'])
+ $this->parser->parse($this->template['COMMENTS_CONTINUED']);
+ }
+
+ /**
+ * Parse templatevar time
+ */
+ function parse_time($format = '') {
+ echo strftime(
+ ($format == '') ? $this->template['FORMAT_TIME'] : $format,
+ $this->currentComment['timestamp']
+ );
+ }
+
+ /**
+ * Parse templatevar timestamp
+ */
+ function parse_timestamp() {
+ echo $this->currentComment['timestamp'];
+ }
+
+ /**
+ * Executes a plugin templatevar
+ *
+ * @param pluginName name of plugin (without the NP_)
+ *
+ * extra parameters can be added
+ */
+ function parse_plugin($pluginName) {
+ global $manager;
+
+ // only continue when the plugin is really installed
+ if (!$manager->pluginInstalled('NP_' . $pluginName))
+ return;
+
+ $plugin =& $manager->getPlugin('NP_' . $pluginName);
+ if (!$plugin) return;
+
+ // get arguments
+ $params = func_get_args();
+
+ // remove plugin name
+ array_shift($params);
+
+ // pass info on current item and current comment as well
+ $params = array_merge(array(&$this->currentComment),$params);
+ $params = array_merge(array(&$this->commentsObj->itemActions->currentItem),$params);
+
+ call_user_func_array(array(&$plugin,'doTemplateCommentsVar'), $params);
+ }
+
+ /**
+ * Parse templatevar user
+ */
+ function parse_user($mode='') {
+ global $manager;
+ if ($mode == 'realname' && $this->currentComment['memberid'] > 0) {
+ $member =& $manager->getMember($this->currentComment['memberid']);
+ echo $member->getRealName();
+ } else {
+ echo $this->currentComment['user'];
+ }
+ }
+
+ /**
+ * Parse templatevar useremail
+ */
+ function parse_useremail() {
+ global $manager;
+ if ($this->currentComment['memberid'] > 0)
+ {
+ $member =& $manager->getMember($this->currentComment['memberid']);
+
+ if ($member->email != '')
+ echo $member->email;
+ }
+ else
+ {
+ if (isValidMailAddress($this->currentComment['email']))
+ echo $this->currentComment['email'];
+ elseif (isValidMailAddress($this->currentComment['userid']))
+ echo $this->currentComment['userid'];
+// if (!(strpos($this->currentComment['userlinkraw'], 'mailto:') === false))
+// echo str_replace('mailto:', '', $this->currentComment['userlinkraw']);
+ }
+ }
+
+ /**
+ * Parse templatevar userid
+ */
+ function parse_userid() {
+ echo $this->currentComment['userid'];
+ }
+
+
+ /**
+ * Parse templatevar userlink
+ */
+ function parse_userlink() {
+ if ($this->currentComment['userlinkraw']) {
+ echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';
+ } else {
+ echo $this->currentComment['user'];
+ }
+ }
+
+ /**
+ * Parse templatevar userlinkraw
+ */
+ function parse_userlinkraw() {
+ echo $this->currentComment['userlinkraw'];
+ }
+
+ /**
+ * Parse templatevar userwebsite
+ */
+ function parse_userwebsite() {
+ if (!(strpos($this->currentComment['userlinkraw'], 'http://') === false))
+ echo $this->currentComment['userlinkraw'];
+ }
+
+ /**
+ * Parse templatevar userwebsitelink
+ */
+ function parse_userwebsitelink() {
+ if (!(strpos($this->currentComment['userlinkraw'], 'http://') === false)) {
+ echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';
+ } else {
+ echo $this->currentComment['user'];
+ }
+ }
+
+}
?>
\ No newline at end of file