]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/_Retransform.php
No underscore for private function
[SourceForge/phpwiki.git] / lib / plugin / _Retransform.php
1 <?php
2
3 /**
4  * Copyright 2007 $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 /**
24  * Only useful for link and parser debugging purposes.
25  */
26 class WikiPlugin__Retransform
27     extends WikiPlugin
28 {
29     function getName()
30     {
31         return _("Retransform CachedMarkup");
32     }
33
34     function getDescription()
35     {
36         return sprintf(_("Show a markup retransformation of page %s."), '[pagename]');
37     }
38
39     function getDefaultArguments()
40     {
41         return array('page' => '[pagename]');
42     }
43
44     function run($dbi, $argstr, &$request, $basepage)
45     {
46         $args = $this->getArgs($argstr, $request);
47         extract($args);
48         if (empty($page))
49             return '';
50
51         $html = HTML(HTML::h3(fmt("Retransform page ā€œ%sā€", $page)));
52
53         // bypass WikiDB and cache, go directly through the backend.
54         $backend = &$dbi->_backend;
55         //$pagedata = $backend->get_pagedata($page);
56         $version = $backend->get_latest_version($page);
57         $vdata = $backend->get_versiondata($page, $version, true);
58
59         include_once 'lib/PageType.php';
60         $formatted = new TransformedText($dbi->getPage($page), $vdata['%content'], $vdata);
61         $content =& $formatted->_content;
62         $html->pushContent($this->DebugPrintArray($content));
63         $links = $formatted->getWikiPageLinks();
64         if (count($links) > 0) {
65             $html->pushContent(HTML::h3("Links"));
66             $html->pushContent($this->DebugPrintArray($links));
67         }
68         return $html;
69     }
70
71     private function DebugPrintArray(&$array)
72     {
73         $html = HTML();
74         foreach ($array as $line) {
75             ob_start();
76             print_r($line);
77             $s = HTML::pre(ob_get_contents());
78             ob_end_clean();
79             $html->pushContent($s);
80         }
81         return $html;
82     }
83 }
84
85 // Local Variables:
86 // mode: php
87 // tab-width: 8
88 // c-basic-offset: 4
89 // c-hanging-comment-ender-p: nil
90 // indent-tabs-mode: nil
91 // End: