]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RawHtml.php
Minor internal change: Removed redundant call to gettext within
[SourceForge/phpwiki.git] / lib / plugin / RawHtml.php
1 <?php // -*-php-*-
2 rcs_id('$Id: RawHtml.php,v 1.8 2003-11-22 17:50:32 carstenklapp Exp $');
3 /**
4  Copyright 1999, 2000, 2001, 2002 $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 // Define ENABLE_RAW_HTML to false (in index.php) to disable the RawHtml plugin.
24 //
25 if (!defined('ENABLE_RAW_HTML'))
26     define('ENABLE_RAW_HTML', true);
27
28 /**
29  * A plugin to provide for raw HTML within wiki pages.
30  */
31 class WikiPlugin_RawHtml
32 extends WikiPlugin
33 {
34     function getName () {
35         return "RawHtml";
36     }
37
38     function getDescription () {
39         return _("A plugin to provide for raw HTML within wiki pages.");
40     }
41
42     function getVersion() {
43         return preg_replace("/[Revision: $]/", '',
44                             "\$Revision: 1.8 $");
45     }
46
47     function managesValidators() {
48         // The plugin output will only change if the plugin
49         // invocation (page text) changes --- so the necessary
50         // validators have already been handled by displayPage.
51         return true;
52     }
53     
54     function run($dbi, $argstr, &$request, $basepage) {
55         if (!defined('ENABLE_RAW_HTML') || ! ENABLE_RAW_HTML) {
56             return $this->disabled(_("Raw HTML is disabled in this wiki."));
57         }
58         if (!$basepage) {
59             return $this->error("$basepage unset?");
60         }
61         
62         $page = $request->getPage($basepage);
63
64         if (! $page->get('locked')) {
65             return $this->disabled(fmt("%s is only allowed in locked pages.",
66                                        _("Raw HTML")));
67         }
68
69         return HTML::raw($argstr);
70     }
71 }
72
73 // $Log: not supported by cvs2svn $
74 // Revision 1.7  2003/03/17 22:32:26  dairiki
75 // Minor HTTP caching fix.
76 //
77 // Revision 1.6  2003/03/17 21:24:53  dairiki
78 // Fix security bugs in the RawHtml plugin.
79 //
80 // Change the default configuration to allow use of plugin, since
81 // I believe the plugin is now safe for general use. (Raw HTML will only
82 // work on locked pages.)
83 //
84 // Revision 1.5  2003/01/18 22:01:43  carstenklapp
85 // Code cleanup:
86 // Reformatting & tabs to spaces;
87 // Added copyleft, getVersion, getDescription, rcs_id.
88 //
89
90 // For emacs users
91 // Local Variables:
92 // mode: php
93 // tab-width: 8
94 // c-basic-offset: 4
95 // c-hanging-comment-ender-p: nil
96 // indent-tabs-mode: nil
97 // End:
98 ?>