]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/SyntaxHighlighter.php
Same signature for all functions handle_plugin_args_cruft
[SourceForge/phpwiki.git] / lib / plugin / SyntaxHighlighter.php
1 <?php
2
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 along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 class WikiPlugin_SyntaxHighlighter
24     extends WikiPlugin
25 {
26     function getDescription()
27     {
28         return _("Source code syntax highlighter (via http://highlightjs.org/).");
29     }
30
31     function managesValidators()
32     {
33         return true;
34     }
35
36     function getDefaultArguments()
37     {
38         return array(
39             'syntax' => null, // required argument
40             'style' => null, // optional argument ["ansi", "gnu", "kr", "java", "linux"]
41             'color' => null, // optional, see highlight/themes
42             'number' => 0,
43             'wrap' => 0,
44         );
45     }
46
47     function handle_plugin_args_cruft($argstr, $args)
48     {
49         $this->source = $argstr;
50     }
51
52     function run($dbi, $argstr, &$request, $basepage)
53     {
54         extract($this->getArgs($argstr, $request));
55         $source =& $this->source;
56         if (empty($source)) {
57             return HTML::div(array('class' => "error"),
58                    "Please provide source code to SyntaxHighlighter plugin");
59         }
60         $html = HTML();
61         $code = "\n<code>\n".htmlspecialchars($source)."\n</code>\n";
62         $pre = HTML::pre(HTML::raw($code));
63         $html->pushContent($pre);
64         return HTML($html);
65     }
66 }
67
68 // Local Variables:
69 // mode: php
70 // tab-width: 8
71 // c-basic-offset: 4
72 // c-hanging-comment-ender-p: nil
73 // indent-tabs-mode: nil
74 // End: