4 Copyright 2004,2007 $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/PageList.php');
24 require_once('lib/WikiPluginCached.php');
27 * - To be used by WikiBrowser at http://touchgraph.sourceforge.net/
28 * Only via a static text file yet. (format=text)
29 * - Or the Hypergraph applet (format=xml)
30 * http://hypergraph.sourceforge.net/
31 * So far also only for a static xml file, but I'll fix the applet and test
34 * TODO: Currently the meta-head tags disturb the touchgraph java browser a bit.
35 * Maybe add a theme without that much header tags.
36 * DONE: Convert " " to %20
38 class WikiPlugin_LinkDatabase
39 extends WikiPluginCached
42 return _("LinkDatabase");
44 function getPluginType() {
45 return PLUGIN_CACHED_HTML;
47 function getDescription () {
48 return _("List all pages with all links in various formats for some Java Visualization tools");
50 function getVersion() {
51 return preg_replace("/[Revision: $]/", '',
54 function getExpire($dbi, $argarray, $request) {
55 return '+900'; // 15 minutes
58 function getDefaultArguments() {
61 PageList::supportedArgs(),
63 'format' => 'html', // 'html', 'text', 'xml'
65 'include_empty' => false,
66 'exclude_from' => false,
71 function getHtml($dbi, $argarray, $request, $basepage) {
72 $this->run($dbi, WikiPluginCached::glueArgs($argarray), $request, $basepage);
75 function run($dbi, $argstr, $request, $basepage) {
77 $args = $this->getArgs($argstr, $request);
78 $caption = _("All pages with all links in this wiki (%d total):");
80 if ( !empty($args['owner']) ) {
81 $pages = PageList::allPagesByOwner($args['owner'],$args['include_empty'],
82 $args['sortby'],$args['limit']);
84 $caption = fmt("List of pages owned by [%s] (%d total):",
85 WikiLink($args['owner'], 'if_known'),
87 } elseif ( !empty($args['author']) ) {
88 $pages = PageList::allPagesByAuthor($args['author'],$args['include_empty'],
89 $args['sortby'],$args['limit']);
91 $caption = fmt("List of pages last edited by [%s] (%d total):",
92 WikiLink($args['author'], 'if_known'),
94 } elseif ( !empty($args['creator']) ) {
95 $pages = PageList::allPagesByCreator($args['creator'],$args['include_empty'],
96 $args['sortby'],$args['limit']);
98 $caption = fmt("List of pages created by [%s] (%d total):",
99 WikiLink($args['creator'], 'if_known'),
102 if (! $request->getArg('count'))
103 $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude_from']);
105 $args['count'] = $request->getArg('count');
106 $pages = $dbi->getAllPages($args['include_empty'], $args['sortby'],
107 $args['limit'], $args['exclude_from']);
109 if ($args['format'] == 'html') {
110 $args['types']['links'] =
111 new _PageList_Column_LinkDatabase_links('links', _("Links"), 'left');
112 $pagelist = new PageList($args['info'], $args['exclude_from'], $args);
113 //$pagelist->_addColumn("links");
114 if (!$args['noheader']) $pagelist->setCaption($caption);
115 $pagelist->addPages($pages);
117 } elseif ($args['format'] == 'text') {
118 $request->discardOutput();
119 $request->buffer_output(false);
121 header("Content-Type: text/plain");
122 $request->checkValidators();
123 while ($page = $pages->next()) {
124 echo preg_replace("/ /","%20",$page->getName());
125 $links = $page->getPageLinks(false, $args['sortby'], $args['limit'],
127 while ($link = $links->next()) {
128 echo " ", preg_replace("/ /","%20",$link->getName());
133 if (empty($WikiTheme->DUMP_MODE))
136 } elseif ($args['format'] == 'xml') {
137 // For hypergraph.jar. Best dump it to a local sitemap.xml periodically
138 global $WikiTheme, $charset;
139 $currpage = $request->getArg('pagename');
140 $request->discardOutput();
141 $request->buffer_output(false);
143 header("Content-Type: text/xml");
144 $request->checkValidators();
145 echo "<?xml version=\"1.0\" encoding=\"$charset\"?>";
146 // As applet it prefers only "GraphXML.dtd", but then we must copy it to the webroot.
147 $dtd = $WikiTheme->_findData("GraphXML.dtd");
148 echo "<!DOCTYPE GraphXML SYSTEM \"$dtd\">\n";
149 echo "<GraphXML xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
150 echo "<graph id=\"",MangleXmlIdentifier(WIKI_NAME),"\">\n";
151 echo '<style><line tag="node" class="main" colour="#ffffff"/><line tag="node" class="child" colour="blue"/><line tag="node" class="relation" colour="green"/></style>',"\n\n";
152 while ($page = $pages->next()) {
153 $pageid = MangleXmlIdentifier($page->getName());
154 $pagename = $page->getName();
155 echo "<node name=\"$pageid\"";
156 if ($pagename == $currpage) echo " class=\"main\"";
157 echo "><label>$pagename</label>";
158 echo "<dataref><ref xlink:href=\"",WikiURL($pagename,'',true),"\"/></dataref></node>\n";
159 $links = $page->getPageLinks(false, $args['sortby'], $args['limit'], $args['exclude']);
160 while ($link = $links->next()) {
161 $edge = MangleXmlIdentifier($link->getName());
162 echo "<edge source=\"$pageid\" target=\"$edge\" />\n";
167 echo "</GraphXML>\n";
168 if (empty($WikiTheme->DUMP_MODE)) {
169 unset($GLOBALS['ErrorManager']->_postponed_errors);
173 return $this->error(fmt("Unsupported format argument %s", $args['format']));
178 class _PageList_Column_LinkDatabase_links extends _PageList_Column {
179 function _getValue($page, &$revision_handle) {
181 $links = $page->getPageLinks();
182 while ($link = $links->next()) {
183 $out->pushContent(" ", WikiLink($link));
189 // $Log: not supported by cvs2svn $
190 // Revision 1.7 2004/12/26 17:17:25 rurban
191 // announce dumps - mult.requests to avoid request::finish, e.g. LinkDatabase, PdfOut, ...
193 // Revision 1.6 2004/12/22 18:48:10 rurban
194 // default format=html for unit-tests and DumpHtml/Zip breakage
196 // Revision 1.5 2004/12/17 16:39:03 rurban
197 // minor reformatting
199 // Revision 1.4 2004/12/06 19:50:05 rurban
200 // enable action=remove which is undoable and seeable in RecentChanges: ADODB ony for now.
201 // renamed delete_page to purge_page.
202 // enable action=edit&version=-1 to force creation of a new version.
203 // added BABYCART_PATH config
204 // fixed magiqc in adodb.inc.php
205 // and some more docs
207 // Revision 1.3 2004/11/30 23:44:00 rurban
210 // Revision 1.2 2004/11/30 23:02:45 rurban
211 // format=xml for hypergraph.sf.net applet
213 // Revision 1.1 2004/11/30 21:02:16 rurban
214 // A simple plugin for WikiBrowser at http://touchgraph.sourceforge.net/
215 // List all pages with all links as text file (with some caching tricks).
216 // format=html currently unstable.
223 // c-hanging-comment-ender-p: nil
224 // indent-tabs-mode: nil