4 Copyright (C) 2004 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
8 PhpWiki is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 PhpWiki is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * This plugin allows user comments attached to a page, similar to WikiBlog.
25 * Based on WikiBlog, no summary.
28 * For admin user, put checkboxes beside comments to allow for bulk removal.
33 include_once("lib/plugin/WikiBlog.php");
35 class WikiPlugin_AddComment
36 extends WikiPlugin_WikiBlog
39 return _("AddComment");
42 function getDescription () {
43 return sprintf(_("Show and add comments for %s"),'[pagename]');
46 function getVersion() {
47 return preg_replace("/[Revision: $]/", '',
53 // page - page where the comment is attached at (default current page)
55 // order - 'normal' - place in chronological order
56 // - 'reverse' - place in reverse chronological order
58 // mode - 'show' - only show old comments
59 // 'add' - only show entry box for new comment
60 // 'show,add' - show old comments, then entry box
61 // 'add,show' - show entry box followed by list of comments
62 // jshide - boolean - quick javascript expansion of the comments
65 function getDefaultArguments() {
66 return array('pagename' => '[pagename]',
71 //'sortby' => '-pagename' // oldest first. reverse by order=reverse
75 function run($dbi, $argstr, &$request, $basepage) {
76 $args = $this->getArgs($argstr, $request);
77 if (!$args['pagename'])
78 return $this->error(_("No pagename specified"));
81 $comment = $request->getArg("comment");
82 $request->setArg('comment', false);
84 if ($request->isPost() and !empty($comment['addcomment'])) {
85 $this->add($request, $comment, 'comment'); // noreturn
87 if ($args['jshide'] and isBrowserIE() and browserDetect("Mac")) {
88 //trigger_error(_("jshide set to 0 on Mac IE"), E_USER_NOTICE);
92 // Now we display previous comments and/or provide entry box
95 if ($args['jshide']) {
96 $div = HTML::div(array('id'=>'comments','style'=>'display:none;'));
97 //$list->setAttr('style','display:none;');
98 $div->pushContent(Javascript("
99 function togglecomments(a) {
100 comments=document.getElementById('comments');
101 if (comments.style.display=='none') {
102 comments.style.display='block';
103 a.title='"._("Click to hide the comments")."';
105 comments.style.display='none';
106 a.title='"._("Click to display all comments")."';
109 $html->pushContent(HTML::h4(HTML::a(array('name'=>'comment-header',
110 'class'=>'wikiaction',
111 'title'=>_("Click to display"),
112 'onclick'=>"togglecomments(this)"),
115 $div = HTML::div(array('id'=>'comments'));
117 foreach (explode(',', $args['mode']) as $show) {
118 if (!empty($seen[$show]))
123 $show = $this->showAll($request, $args, 'comment');
124 //if ($args['jshide']) $show->setAttr('style','display:none;');
125 $div->pushContent($show);
129 if (!$WikiTheme->DUMP_MODE) {
130 $add = $this->showForm($request, $args, 'addcomment');
131 //if ($args['jshide']) $add->setAttr('style','display:none;');
132 $div->pushContent($add);
136 return $this->error(sprintf("Bad mode ('%s')", $show));
139 $html->pushContent($div);
150 // c-hanging-comment-ender-p: nil
151 // indent-tabs-mode: nil