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