]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/_BackendInfo.php
Jeff's hacks II, continued:
[SourceForge/phpwiki.git] / lib / plugin / _BackendInfo.php
1 <?php // -*-php-*-
2 rcs_id('$Id: _BackendInfo.php,v 1.1 2001-09-18 19:19:05 dairiki Exp $');
3 require_once('lib/Template.php');
4 /**
5  */
6 class WikiPlugin__BackendInfo
7 extends WikiPlugin
8 {
9     var $name = '_BackendInfo';
10     
11     function WikiPlugin__BackendInfo() {
12         $this->_hashtemplate = new Template('
13 <tr bgcolor="#ffcccc">
14   <td colspan="2">${header}</td>
15 </tr>
16 <?php foreach ($hash as $key => $val) { ?>
17   <tr>
18     <td align="right" bgcolor="#cccccc">&nbsp;<?php echo $key;?>&nbsp;</td>
19     <td><?php echo $val;?></td>
20   </tr>
21 <?php } ?>
22 ');
23     }
24     
25     function getDefaultArguments() {
26         return array('page'     => false);
27         
28     }
29     
30     function run($dbi, $argstr, $request) {
31         $args = $this->getArgs($argstr, $request);
32         extract($args);
33         if (empty($page))
34             return '';
35         
36         $backend = &$dbi->_backend;
37
38         $html = QElement('h3',
39                          "Querying backend directly for '$page'");
40
41         
42         $rows = '';
43         $pagedata = $backend->get_pagedata($page);
44         if (!$pagedata)
45             $html .= QElement('p', "No pagedata for $page\n");
46         else {
47             ksort($pagedata);
48             $rows .= $this->_hashtemplate->
49                 getExpansion(array('header' => "get_pagedata('$page')",
50                                    'hash'   => $pagedata));
51         }
52         
53         for ($version = $backend->get_latest_version($page);
54              $version;
55              $version = $backend->get_previous_version($page, $version)) {
56
57             $vdata = $backend->get_versiondata($page, $version, true);
58
59             $content = &$vdata['%content'];
60             if ($content === true)
61                 $content = '<true>';
62             elseif (strlen($content) > 40)
63                 $content = substr($content,0,40) . " ...";
64
65             $rows .= Element('tr', Element('td', array('colspan' => 2))) . "\n";
66             ksort($vdata);
67             $rows .= $this->_hashtemplate->
68                 getExpansion(array('header' => "get_versiondata('$page',$version)",
69                                    'hash'   => $vdata));
70             
71         }
72
73         $html .= Element('table', array('border' => 1,
74                                         'cellpadding' => 2,
75                                         'cellspacing' => 0),
76                          $rows) . "\n";
77         return $html;
78     }
79 };
80         
81 // (c-file-style: "gnu")
82 // Local Variables:
83 // mode: php
84 // tab-width: 8
85 // c-basic-offset: 4
86 // c-hanging-comment-ender-p: nil
87 // indent-tabs-mode: nil
88 // End:   
89 ?>