]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/_BackendInfo.php
Refactor $WikiPlugin::name and $WikiPlugin::description stuff.
[SourceForge/phpwiki.git] / lib / plugin / _BackendInfo.php
1 <?php // -*-php-*-
2 rcs_id('$Id: _BackendInfo.php,v 1.3 2001-12-16 18:33:25 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 _("Get debugging information for [pagename].");
15     }
16     
17     function WikiPlugin__BackendInfo() {
18         $this->_hashtemplate = new Template('
19 <tr bgcolor="#ffcccc">
20   <td colspan="2">${header}</td>
21 </tr>
22 <?php foreach ($hash as $key => $val) { ?>
23   <tr>
24     <td align="right" bgcolor="#cccccc">&nbsp;<?php echo $key;?>&nbsp;</td>
25     <td><?php echo $val;?></td>
26   </tr>
27 <?php } ?>
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\n"), $page));
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 $html;
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 ?>