]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/_BackendInfo.php
Fix background color (PageType does not provide any container formatting for DebugInf...
[SourceForge/phpwiki.git] / lib / plugin / _BackendInfo.php
1 <?php // -*-php-*-
2 rcs_id('$Id: _BackendInfo.php,v 1.13 2002-02-22 23:12:54 carstenklapp 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
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             $rows[] = HTML::tr(HTML::td(array('align' => 'right',
72                                               'bgcolor' => '#cccccc',
73                                               'style' => 'color:#000000'),
74                                         NBSP . $key . NBSP),
75                                HTML::td(array('bgcolor' => '#ffffff',
76                                               'style' => 'color:#000000'),
77                                         $val ? $val : NBSP));
78         return $rows;
79     }
80 };
81
82
83 // (c-file-style: "gnu")
84 // Local Variables:
85 // mode: php
86 // tab-width: 8
87 // c-basic-offset: 4
88 // c-hanging-comment-ender-p: nil
89 // indent-tabs-mode: nil
90 // End:
91 ?>