From: <ma...@us...> - 2012-12-24 18:14:13
|
Revision: 10541 http://sourceforge.net/p/xoops/svn/10541 Author: mageg Date: 2012-12-24 18:14:10 +0000 (Mon, 24 Dec 2012) Log Message: ----------- add comments in page module Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/notifications.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/search.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/templates/page_viewpage.html Added Paths: ----------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/comments.php Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/comments.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/comments.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/comments.php 2012-12-24 18:14:10 UTC (rev 10541) @@ -0,0 +1,113 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * page module + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @since 2.6.0 + * @author Mage Grégory (AKA Mage) + * @version $Id$ + */ + +defined("XOOPS_ROOT_PATH") or die("XOOPS root path not defined"); + +class PageCommentsPlugin extends Xoops_Plugin_Abstract implements CommentsPluginInterface +{ + /** + * @return string + */ + public function itemName() + { + return 'id'; + } + + /** + * @return string + */ + public function pageName() + { + return 'viewpage.php'; + } + + /** + * @return array + */ + public function extraParams() + { + return array(); + } + + /** + * This method will be executed upon successful post of an approved comment. + * This includes comment posts by administrators, and change of comment status from 'pending' to 'active' state. + * An CommentsComment object that has been approved will be passed as the first and only parameter. + * This should be useful for example notifying the item submitter of a comment post. + * + * @param CommentsComment $comment + * + * @return void + */ + public function approve(CommentsComment $comment) + { + //Where are you looking at? + } + + /** + * This method will be executed whenever the total number of 'active' comments for an item is changed. + * + * @param int $item_id The unique ID of an item + * @param int $total_num The total number of active comments + * + * @return void + */ + public function update($item_id, $total_num) + { + $db = Xoops::getInstance()->db(); + $sql = 'UPDATE ' . $db->prefix('page_content') . ' SET content_comments = ' . intval($total_num) . ' WHERE content_id = ' . intval($item_id); + $db->query($sql); + } + + /** + * This method will be executed whenever a new comment form is displayed. + * You can set a default title for the comment and a header to be displayed on top of the form + * ex: return array( + * 'title' => 'My Article Title', + * 'text' => 'Content of the article'); + * 'timestamp' => time(); //Date of the article in unix format + * 'uid' => Id of the article author + * + * @param int $item_id The unique ID of an item + * + * @return array + */ + public function itemInfo($item_id) + { + + $ret = array(); + + $xoops = Xoops::getInstance(); + // Get handler + $content_Handler = $xoops->getModuleHandler('page_content', 'page'); + $view_content = $content_Handler->get($item_id); + if (count($view_content) == 0 || $view_content->getVar('content_status') == 0){ + return $ret; + } else { + $ret['title'] = $view_content->getVar('content_title'); + $ret['text'] = $view_content->getVar('content_shorttext') . $view_content->getVar('content_text'); + $ret['uid'] = $view_content->getVar('content_author'); + $ret['timestamp'] = $view_content->getVar('content_create'); + } + return $ret; + } +} + Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/comments.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Rev URL \ No newline at end of property Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/notifications.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/notifications.php 2012-12-24 17:07:42 UTC (rev 10540) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/notifications.php 2012-12-24 18:14:10 UTC (rev 10541) @@ -10,7 +10,7 @@ */ /** - * menu module + * page module * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/search.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/search.php 2012-12-24 17:07:42 UTC (rev 10540) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/search.php 2012-12-24 18:14:10 UTC (rev 10541) @@ -10,7 +10,7 @@ */ /** - * XXX + * page module * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/templates/page_viewpage.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/templates/page_viewpage.html 2012-12-24 17:07:42 UTC (rev 10540) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/templates/page_viewpage.html 2012-12-24 18:14:10 UTC (rev 10541) @@ -74,6 +74,9 @@ <{if $content_dosocial}> <{includeq file='module:xoosocialnetwork|xoosocialnetwork.html'}> <{/if}> +<{if $content_docoms == 1}> +<{include file='module:comments|comments.html'}> +<{/if}> <{if $content_donotifications}> <{include file='module:notifications|select.html'}> <{/if}> \ No newline at end of file |