]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/_BackendInfo.php
Finish conversion to new OO HTML generation scheme.
[SourceForge/phpwiki.git] / lib / plugin / _BackendInfo.php
1 <?php // -*-php-*-
2 rcs_id('$Id: _BackendInfo.php,v 1.10 2002-01-22 03:17:47 dairiki Exp $');
3 require_once('lib/Template.php');
4 /**
5  */
6 class WikiPlugin__BackendInfo
7 extends WikiPlugin
8 {
9     function getName () {
10         return _("DebugInfo");
11     }
12
13     function getDescription () {
14         return sprintf(_("Get debugging information for %s."),'[pagename]');
15     }
16     
17     function getDefaultArguments() {
18         return array('page'     => false);
19         
20     }
21     
22     function run($dbi, $argstr, $request) {
23         $args = $this->getArgs($argstr, $request);
24         extract($args);
25         if (empty($page))
26             return '';
27         
28         $backend = &$dbi->_backend;
29
30         $html[] = HTML::h3(fmt("Querying backend directly for '%s'", $page));
31
32         
33         $table = HTML::table(array('border' => 1,
34                                    'cellpadding' => 2,
35                                    'cellspacing' => 0));
36         $pagedata = $backend->get_pagedata($page);
37         if (!$pagedata)
38             $html[] = HTML::p(fmt("No pagedata for %s", $page));
39         else {
40             $table->pushContent($this->_showhash("get_pagedata('$page')",
41                                                  $pagedata));
42         }
43         
44         for ($version = $backend->get_latest_version($page);
45              $version;
46              $version = $backend->get_previous_version($page, $version)) {
47
48             $vdata = $backend->get_versiondata($page, $version, true);
49
50             $content = &$vdata['%content'];
51             if ($content === true)
52                 $content = '<true>';
53             elseif (strlen($content) > 40)
54                 $content = substr($content,0,40) . " ...";
55
56             $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
57             $table->pushContent($this->_showhash("get_versiondata('$page',$version)",
58                                                  $vdata));
59         }
60
61         $html[] = $table;
62         return $html;
63     }
64
65     function _showhash ($heading, $hash) {
66         $rows[] = HTML::tr(array('bgcolor' => "#ffcccc"),
67                            HTML::td(array('colspan' => 2), $heading));
68         ksort($hash);
69         foreach ($hash as $key => $val)
70             $rows[] = HTML::tr(HTML::td(array('align' => 'right',
71                                               'bgcolor' => '#cccccc'),
72                                         NBSP . $key . NBSP),
73                                HTML::td($val ? $val : NBSP));
74         return $rows;
75     }
76 };
77         
78 // (c-file-style: "gnu")
79 // Local Variables:
80 // mode: php
81 // tab-width: 8
82 // c-basic-offset: 4
83 // c-hanging-comment-ender-p: nil
84 // indent-tabs-mode: nil
85 // End:   
86 ?>