]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/_BackendInfo.php
oops. some missing plugin changes
[SourceForge/phpwiki.git] / lib / plugin / _BackendInfo.php
1 <?php // -*-php-*-
2 rcs_id('$Id: _BackendInfo.php,v 1.14 2002-08-22 23:32:33 rurban 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' => '[pagename]');
19     }
20
21     function run($dbi, $argstr, $request) {
22         $args = $this->getArgs($argstr, $request);
23         extract($args);
24         if (empty($page))
25             return '';
26
27         $backend = &$dbi->_backend;
28
29         $html = HTML(HTML::h3(fmt("Querying backend directly for '%s'", $page)));
30
31
32         $table = HTML::table(array('border' => 1,
33                                    'cellpadding' => 2,
34                                    'cellspacing' => 0));
35         $pagedata = $backend->get_pagedata($page);
36         if (!$pagedata)
37             $html->pushContent(HTML::p(fmt("No pagedata for %s", $page)));
38         else {
39             $table->pushContent($this->_showhash("get_pagedata('$page')",
40                                                  $pagedata));
41         }
42
43         for ($version = $backend->get_latest_version($page);
44              $version;
45              $version = $backend->get_previous_version($page, $version))
46         {
47             $vdata = $backend->get_versiondata($page, $version, true);
48
49             $content = &$vdata['%content'];
50             if ($content === true)
51                 $content = '<true>';
52             elseif (strlen($content) > 40)
53                 $content = substr($content,0,40) . " ...";
54             unset($vdata['%pagedata']); // problem in backend
55             $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
56             $table->pushContent($this->_showhash("get_versiondata('$page',$version)",
57                                                  $vdata));
58         }
59
60         $html->pushContent($table);
61         return $html;
62     }
63
64     function _showhash ($heading, $hash) {
65         $rows[] = HTML::tr(array('bgcolor' => '#ffcccc',
66                                  'style' => 'color:#000000'),
67                            HTML::td(array('colspan' => 2,
68                                           'style' => 'color:#000000'), $heading));
69         ksort($hash);
70         foreach ($hash as $key => $val) {
71             if (is_string($val) and (substr($val,0,2) == 'a:')) {
72                 $val = unserialize($val);
73                 $rows[] = $this->_showhash (NBSP . NBSP . "%pagedata '$key' array" , $val);
74             } else {
75                 if ($key == 'passwd') $val = $val ? '<not displayed>' : '<empty>';
76                 $rows[] = HTML::tr(HTML::td(array('align' => 'right',
77                                               'bgcolor' => '#cccccc',
78                                               'style' => 'color:#000000'),
79                                         NBSP . $key . NBSP),
80                                HTML::td(array('bgcolor' => '#ffffff',
81                                               'style' => 'color:#000000'),
82                                         $val ? $val : NBSP));
83             }
84         }
85         return $rows;
86     }
87 };
88
89
90 // (c-file-style: "gnu")
91 // Local Variables:
92 // mode: php
93 // tab-width: 8
94 // c-basic-offset: 4
95 // c-hanging-comment-ender-p: nil
96 // indent-tabs-mode: nil
97 // End:
98 ?>