]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RawHtml.php
version tag was broken
[SourceForge/phpwiki.git] / lib / plugin / RawHtml.php
1 <?php // -*-php-*-
2 rcs_id('$Id: RawHtml.php,v 1.4 2002-12-28 22:15:34 wainstead Exp $');
3
4 // Define ENABLE_RAW_HTML to true to enable the RawHtml plugin.
5 //
6 // IMPORTANT!!!: This plugin is currently insecure, as it's method of
7 // determining whether it was invoked from a locked page is flawed.
8 // (See the FIXME: comment below.)
9 //
10 // ENABLE AT YOUR OWN RISK!!!
11 //
12 if (!defined('ENABLE_RAW_HTML')) define('ENABLE_RAW_HTML', false);
13
14 /**
15  * A plugin to provide for raw HTML within wiki pages.
16  */
17 class WikiPlugin_RawHtml
18 extends WikiPlugin
19 {
20     function getName () {
21         return "RawHtml";
22     }
23     
24     function run($dbi, $argstr, $request) {
25         if (!defined('ENABLE_RAW_HTML') || ! ENABLE_RAW_HTML) {
26             return $this->error(_("Raw HTML is disabled in this wiki."));
27         }
28
29         // FIXME: this test for lockedness is badly flawed.  It checks
30         // the requested pages locked state, not the page the plugin
31         // invocation came from.  (These could be different in the
32         // case of ActionPages, or where the IncludePage plugin is
33         // used.)
34         $page = $request->getPage();
35         if (! $page->get('locked')) {
36             return $this->error(fmt(_("%s is only allowed in locked pages."),
37                                     _("Raw HTML")));
38         }
39
40         return HTML::raw($argstr);
41     }
42 }
43
44
45 // For emacs users
46 // Local Variables:
47 // mode: php
48 // tab-width: 8
49 // c-basic-offset: 4
50 // c-hanging-comment-ender-p: nil
51 // indent-tabs-mode: nil
52 // End:
53 ?>