2 rcs_id('$Id: _BackendInfo.php,v 1.14 2002-08-22 23:32:33 rurban Exp $');
3 require_once('lib/Template.php');
6 class WikiPlugin__BackendInfo
10 return _("DebugInfo");
13 function getDescription () {
14 return sprintf(_("Get debugging information for %s."), '[pagename]');
17 function getDefaultArguments() {
18 return array('page' => '[pagename]');
21 function run($dbi, $argstr, $request) {
22 $args = $this->getArgs($argstr, $request);
27 $backend = &$dbi->_backend;
29 $html = HTML(HTML::h3(fmt("Querying backend directly for '%s'", $page)));
32 $table = HTML::table(array('border' => 1,
35 $pagedata = $backend->get_pagedata($page);
37 $html->pushContent(HTML::p(fmt("No pagedata for %s", $page)));
39 $table->pushContent($this->_showhash("get_pagedata('$page')",
43 for ($version = $backend->get_latest_version($page);
45 $version = $backend->get_previous_version($page, $version))
47 $vdata = $backend->get_versiondata($page, $version, true);
49 $content = &$vdata['%content'];
50 if ($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)",
60 $html->pushContent($table);
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));
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);
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'),
80 HTML::td(array('bgcolor' => '#ffffff',
81 'style' => 'color:#000000'),
90 // (c-file-style: "gnu")
95 // c-hanging-comment-ender-p: nil
96 // indent-tabs-mode: nil