]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/_BackendInfo.php
More infiltration of new object-based HTML generation.
[SourceForge/phpwiki.git] / lib / plugin / _BackendInfo.php
1 <?php // -*-php-*-
2 rcs_id('$Id: _BackendInfo.php,v 1.9 2002-01-21 06:55: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 WikiPlugin__BackendInfo() {
18         $html = '<tr bgcolor="#ffcccc">'."\n";
19         $html .= '  <td colspan="2"><?=$header?></td>'."\n";
20         $html .= '</tr>'."\n";
21         $html .= '<?php foreach ($hash as $key => $val) { ?>'."\n";
22         $html .= '  <tr>'."\n";
23         $html .= '    <td align="right" bgcolor="#cccccc">&nbsp;<?=$key?>&nbsp;</td>'."\n";
24         $html .= '    <td><?=$val?>&nbsp;</td>'."\n";
25         $html .= '  </tr>'."\n";
26         $html .= '<?php } ?>'."\n";
27         $this->_hashtemplate = new Template($html);
28
29     }
30     
31     function getDefaultArguments() {
32         return array('page'     => false);
33         
34     }
35     
36     function run($dbi, $argstr, $request) {
37         $args = $this->getArgs($argstr, $request);
38         extract($args);
39         if (empty($page))
40             return '';
41         
42         $backend = &$dbi->_backend;
43
44         $html = QElement('h3',
45                          sprintf(_("Querying backend directly for '%s'"), $page));
46
47         
48         $rows = '';
49         $pagedata = $backend->get_pagedata($page);
50         if (!$pagedata)
51             $html .= QElement('p', sprintf(_("No pagedata for %s"), $page) . "\n");
52         else {
53             ksort($pagedata);
54             $rows .= $this->_hashtemplate->
55                 getExpansion(array('header' => "get_pagedata('$page')",
56                                    'hash'   => $pagedata));
57         }
58         
59         for ($version = $backend->get_latest_version($page);
60              $version;
61              $version = $backend->get_previous_version($page, $version)) {
62
63             $vdata = $backend->get_versiondata($page, $version, true);
64
65             $content = &$vdata['%content'];
66             if ($content === true)
67                 $content = '<true>';
68             elseif (strlen($content) > 40)
69                 $content = substr($content,0,40) . " ...";
70
71             $rows .= Element('tr', Element('td', array('colspan' => 2))) . "\n";
72             ksort($vdata);
73             $rows .= $this->_hashtemplate->
74                 getExpansion(array('header' => "get_versiondata('$page',$version)",
75                                    'hash'   => $vdata));
76             
77         }
78
79         $html .= Element('table', array('border' => 1,
80                                         'cellpadding' => 2,
81                                         'cellspacing' => 0),
82                          $rows) . "\n";
83         return new RawXml($html); // FIXME: avoid RawXml.
84     }
85 };
86         
87 // (c-file-style: "gnu")
88 // Local Variables:
89 // mode: php
90 // tab-width: 8
91 // c-basic-offset: 4
92 // c-hanging-comment-ender-p: nil
93 // indent-tabs-mode: nil
94 // End:   
95 ?>