]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AddComment.php
enable action=remove which is undoable and seeable in RecentChanges: ADODB ony for...
[SourceForge/phpwiki.git] / lib / plugin / AddComment.php
1 <?php // -*-php-*-
2 rcs_id('$Id: AddComment.php,v 1.8 2004-06-13 09:45:23 rurban Exp $');
3 /*
4  Copyright (C) 2004 $ThePhpWikiProgrammingTeam
5  
6  This file is part of PhpWiki.
7
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.
12
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.
17
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
21  */
22
23 /**
24  * This plugin allows user comments attached to a page, similar to WikiBlog.
25  * based on WikiBlog, no summary.
26  *
27  * TODO:
28  * For admin user, put checkboxes beside comments to allow for bulk removal.
29  *
30  * @author: ReiniUrban
31  */
32
33 include_once("lib/plugin/WikiBlog.php");
34
35 class WikiPlugin_AddComment
36 extends WikiPlugin_WikiBlog
37 {
38     function getName () {
39         return _("AddComment");
40     }
41
42     function getDescription () {
43         return sprintf(_("Show and add comments for %s"),'[pagename]');
44     }
45
46     function getVersion() {
47         return preg_replace("/[Revision: $]/", '',
48                             "\$Revision: 1.8 $");
49     }
50
51     // Arguments:
52     //
53     //  page - page where the comment is attached at (default current page)
54     //
55     //  order - 'normal'  - place in chronological order
56     //        - 'reverse' - place in reverse chronological order
57     //
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 
63     //                      and addcomment box
64
65     function getDefaultArguments() {
66         return array('pagename'   => '[pagename]',
67                      'order'      => 'normal',
68                      'mode'       => 'add,show',
69                      'jshide'     => '0',
70                      'noheader'   => false,
71                      //'sortby'     => '-pagename' // oldest first. reverse by order=reverse
72                     );
73     }
74
75     function run($dbi, $argstr, &$request, $basepage) {
76         $args = $this->getArgs($argstr, $request);
77         if (!$args['pagename'])
78             return $this->error(_("No pagename specified"));
79
80         // Get our form args.
81         $comment = $request->getArg("comment");
82         $request->setArg('comment', false);
83             
84         if ($request->isPost() and !empty($comment['addcomment'])) {
85             $this->add($request, $comment, 'comment'); // noreturn
86         }
87         if ($args['jshide'] and isBrowserIE() and browserDetect("Mac")) {
88             //trigger_error(_("jshide set to 0 on Mac IE"), E_USER_NOTICE);
89             $args['jshide'] = 0;
90         }
91
92         // Now we display previous comments and/or provide entry box
93         // for new comments
94         $html = HTML();
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")."';
104   } else {
105     comments.style.display='none';
106     a.title='"._("Click to display all comments")."';
107   }
108 }"));
109             $html->pushContent(HTML::h4(HTML::a(array('name'=>'comment-header',
110                                                       'class'=>'wikiaction',
111                                                       'title'=>_("Click to display"),
112                                                       'onclick'=>"togglecomments(this)"),
113                                                 _("Comments"))));
114         } else {
115             $div = HTML::div(array('id'=>'comments'));
116         }
117         foreach (explode(',', $args['mode']) as $show) {
118             if (!empty($seen[$show]))
119                 continue;
120             $seen[$show] = 1;
121             switch ($show) {
122             case 'show':
123                 $show = $this->showAll($request, $args, 'comment');
124                 //if ($args['jshide']) $show->setAttr('style','display:none;');
125                 $div->pushContent($show);
126                 break;
127             case 'add':
128                 $add = $this->showForm($request, $args, 'addcomment');
129                 //if ($args['jshide']) $add->setAttr('style','display:none;');
130                 $div->pushContent($add);
131                 break;
132             default:
133                 return $this->error(sprintf("Bad mode ('%s')", $show));
134             }
135         }
136         $html->pushContent($div);
137         return $html;
138     }
139    
140 };
141
142 // $Log: not supported by cvs2svn $
143 // Revision 1.7  2004/03/29 21:33:32  rurban
144 // possible fix for problem reported by Whit Blauvelt
145 //   Message-ID: <20040327211707.GA22374@free.transpect.com>
146 // create intermediate redirect subpages for blog/comment/forum
147 //
148 // Revision 1.6  2004/03/16 15:44:34  rurban
149 // jshide not default as in CreateToc
150 //
151 // Revision 1.5  2004/03/15 09:52:59  rurban
152 // jshide button: dynamic titles
153 //
154 // Revision 1.4  2004/03/14 20:30:21  rurban
155 // jshide button
156 //
157 // Revision 1.3  2004/03/14 16:26:21  rurban
158 // copyright line
159 //
160 // Revision 1.2  2004/03/12 20:59:18  rurban
161 // important cookie fix by Konstantin Zadorozhny
162 // new editpage feature: JS_SEARCHREPLACE
163 //
164 // Revision 1.1  2004/03/12 17:32:41  rurban
165 // new base class PageType_attach as base class for WikiBlog, Comment, and WikiForum.
166 // new plugin AddComment, which is a WikiBlog with different pagetype and template,
167 //   based on WikiBlog. WikiForum comes later.
168 //
169 //
170
171 // For emacs users
172 // Local Variables:
173 // mode: php
174 // tab-width: 8
175 // c-basic-offset: 4
176 // c-hanging-comment-ender-p: nil
177 // indent-tabs-mode: nil
178 // End:
179 ?>