2 rcs_id('$Id: _BackendInfo.php,v 1.25 2006-09-06 06:02:36 rurban Exp $');
4 Copyright 1999,2000,2001,2002,2006 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
8 PhpWiki is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 PhpWiki is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 require_once('lib/Template.php');
26 class WikiPlugin__BackendInfo
30 return _("DebugInfo");
33 function getDescription () {
34 return sprintf(_("Get debugging information for %s."), '[pagename]');
37 function getVersion() {
38 return preg_replace("/[Revision: $]/", '',
39 "\$Revision: 1.25 $");
42 function getDefaultArguments() {
43 return array('page' => '[pagename]');
46 function run($dbi, $argstr, &$request, $basepage) {
47 $args = $this->getArgs($argstr, $request);
52 $backend = &$dbi->_backend;
54 $html = HTML(HTML::h3(fmt("Querying backend directly for '%s'",
58 $table = HTML::table(array('border' => 1,
61 $pagedata = $backend->get_pagedata($page);
63 // FIXME: invalid HTML
64 $html->pushContent(HTML::p(fmt("No pagedata for %s", $page)));
67 $this->_fixupData($pagedata);
68 $table->pushContent($this->_showhash("get_pagedata('$page')", $pagedata));
71 for ($version = $backend->get_latest_version($page);
73 $version = $backend->get_previous_version($page, $version))
75 $vdata = $backend->get_versiondata($page, $version, true);
76 $this->_fixupData($vdata);
77 $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
78 $table->pushContent($this->_showhash("get_versiondata('$page',$version)",
82 $linkdata = $backend->get_links($page, false);
83 if ($linkdata->count())
84 $table->pushContent($this->_showhash("get_links('$page')", $linkdata->asArray()));
85 $relations = $backend->get_links($page, false, false, false, false, false, true);
86 if ($relations->count()) {
87 $table->pushContent($this->_showhash("get_relations('$page')", array()));
88 while ($rel = $relations->next())
89 $table->pushContent($this->_showhash(false, $rel));
91 $linkdata = $backend->get_links($page, true);
92 if ($linkdata->count())
93 $table->pushContent($this->_showhash("get_backlinks('$page')", $linkdata->asArray()));
95 $html->pushContent($table);
100 * Really should have a _fixupPagedata and _fixupVersiondata, but this works.
102 function _fixupData(&$data) {
104 $user = $request->getUser();
106 foreach ($data as $key => $val) {
107 if (is_integer($key)) {
109 } elseif ($key == 'passwd' and !$user->isAdmin()) {
110 $data[$key] = $val ? _("<not displayed>") : _("<empty>");
111 } elseif ($key and $key == '_cached_html') {
112 $val = TransformedText::unpack($val);
115 $data[$key] = HTML::pre(ob_get_contents());
118 elseif (is_bool($val)) {
119 $data[$key] = $val ? "<true>" : "<false>";
121 elseif (is_string($val) && (substr($val, 0, 2) == 'a:')) {
122 // how to indent this table?
123 $val = unserialize($val);
124 $this->_fixupData($val);
125 $data[$key] = HTML::table(array('border' => 1,
128 $this->_showhash(false, $val));
130 elseif (is_array($val)) {
131 // how to indent this table?
132 $this->_fixupData($val);
133 $data[$key] = HTML::table(array('border' => 1,
136 $this->_showhash(false, $val));
138 elseif ($key and $key == '%content') {
141 elseif (strlen($val) > 40)
142 $val = substr($val,0,40) . " ...";
146 unset($data['%pagedata']); // problem in backend
149 function _showhash ($heading, $hash, $pagename = '') {
152 $rows[] = HTML::tr(array('bgcolor' => '#ffcccc',
153 'style' => 'color:#000000'),
154 HTML::td(array('colspan' => 2,
155 'style' => 'color:#000000'),
158 foreach ($hash as $key => $val) {
159 $rows[] = HTML::tr(HTML::td(array('align' => 'right',
160 'bgcolor' => '#cccccc',
161 'style' => 'color:#000000'),
162 HTML(HTML::raw(' '), $key,
163 HTML::raw(' '))),
164 HTML::td(array('bgcolor' => '#ffffff',
165 'style' => 'color:#000000'),
166 $val ? $val : HTML::raw(' '))
173 // $Log: not supported by cvs2svn $
174 // Revision 1.24 2005/01/29 19:47:43 rurban
177 // Revision 1.23 2005/01/21 14:13:23 rurban
178 // stabilize on numeric keys (strange php problem)
180 // Revision 1.22 2004/02/17 12:11:36 rurban
181 // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...)
183 // Revision 1.21 2003/02/21 04:22:28 dairiki
184 // Make this work for array-valued data. Make display of cached markup
185 // readable. Some code cleanups. (This still needs more work.)
187 // Revision 1.20 2003/01/18 21:19:24 carstenklapp
189 // Reformatting; added copyleft, getVersion, getDescription
192 // (c-file-style: "gnu")
197 // c-hanging-comment-ender-p: nil
198 // indent-tabs-mode: nil