]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AddComment.php
important cookie fix by Konstantin Zadorozhny
[SourceForge/phpwiki.git] / lib / plugin / AddComment.php
1 <?php // -*-php-*-
2 rcs_id('$Id: AddComment.php,v 1.2 2004-03-12 20:59:18 rurban Exp $');
3 /*
4  Copyright 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.2 $");
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('page'       => '[pagename]',
67                      'order'      => 'normal',
68                      'mode'       => 'add,show',
69                      'jshide'     => '1',
70                      'noheader'   => false
71                     );
72     }
73
74     function run($dbi, $argstr, &$request, $basepage) {
75         $args = $this->getArgs($argstr, $request);
76         if (!$args['page'])
77             return $this->error("No page specified");
78
79         // Get our form args.
80         $comment = $request->getArg("comment");
81         $request->setArg('comment', false);
82             
83         if ($request->isPost() and !empty($comment['addcomment'])) {
84             $this->add($request, $comment, 'comment'); // noreturn
85         }
86
87         // Now we display previous comments and/or provide entry box
88         // for new comments
89         $html = HTML();
90         foreach (explode(',', $args['mode']) as $show) {
91             if (!empty($seen[$show]))
92                 continue;
93             $seen[$show] = 1;
94             switch ($show) {
95             case 'show':
96                 $html->pushContent($this->showAll($request, $args, 'comment'));
97                 break;
98             case 'add':
99                 $html->pushContent($this->showForm($request, $args, 'addcomment'));
100                 break;
101             default:
102                 return $this->error(sprintf("Bad mode ('%s')", $show));
103             }
104         }
105         return $html;
106     }
107    
108 };
109
110 // $Log: not supported by cvs2svn $
111 // Revision 1.1  2004/03/12 17:32:41  rurban
112 // new base class PageType_attach as base class for WikiBlog, Comment, and WikiForum.
113 // new plugin AddComment, which is a WikiBlog with different pagetype and template,
114 //   based on WikiBlog. WikiForum comes later.
115 //
116 //
117
118 // For emacs users
119 // Local Variables:
120 // mode: php
121 // tab-width: 8
122 // c-basic-offset: 4
123 // c-hanging-comment-ender-p: nil
124 // indent-tabs-mode: nil
125 // End:
126 ?>