2 rcs_id('$Id: LinkDatabase.php,v 1.2 2004-11-30 23:02:45 rurban Exp $');
4 Copyright 2004 $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 by ?format=text) or the
29 * Hypergraph applet should use format=xml
30 * http://hypergraph.sourceforge.net/
32 * Currently the meta-head tags disturb the java browser a bit.
33 * Maybe add theme without much header tags.
35 class WikiPlugin_LinkDatabase
36 extends WikiPluginCached
39 return _("LinkDatabase");
41 function getPluginType() {
42 return PLUGIN_CACHED_HTML;
44 function getDescription () {
45 return _("List all pages with all links in text-format for some Java Visualization tools");
47 function getVersion() {
48 return preg_replace("/[Revision: $]/", '',
51 function getExpire($dbi, $argarray, $request) {
52 return '+900'; // 15 minutes
55 function getDefaultArguments() {
58 PageList::supportedArgs(),
60 'format' => 'text', // or 'html', 'xml'
62 'include_empty' => false,
63 'exclude_from' => false,
68 function getHtml($dbi, $argarray, $request, $basepage) {
69 $this->run($dbi, WikiPluginCached::glueArgs($argarray), $request, $basepage);
72 function run($dbi, $argstr, $request, $basepage) {
73 $args = $this->getArgs($argstr, $request);
74 $caption = _("All pages with all links in this wiki (%d total):");
76 if ( !empty($args['owner']) ) {
77 $pages = PageList::allPagesByOwner($args['owner'],$args['include_empty'],$args['sortby'],$args['limit']);
79 $caption = fmt("List of pages owned by [%s] (%d total):",
80 WikiLink($args['owner'], 'if_known'),
82 } elseif ( !empty($args['author']) ) {
83 $pages = PageList::allPagesByAuthor($args['author'],$args['include_empty'],$args['sortby'],$args['limit']);
85 $caption = fmt("List of pages last edited by [%s] (%d total):",
86 WikiLink($args['author'], 'if_known'),
88 } elseif ( !empty($args['creator']) ) {
89 $pages = PageList::allPagesByCreator($args['creator'],$args['include_empty'],$args['sortby'],$args['limit']);
91 $caption = fmt("List of pages created by [%s] (%d total):",
92 WikiLink($args['creator'], 'if_known'),
95 if (! $request->getArg('count')) $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude_from']);
96 else $args['count'] = $request->getArg('count');
97 $pages = $dbi->getAllPages($args['include_empty'], $args['sortby'], $args['limit'], $args['exclude_from']);
99 if ($args['format'] == 'html') {
100 $args['types']['links'] =
101 new _PageList_Column_LinkDatabase_links('links', _("Links"), 'left');
102 $pagelist = new PageList($args['info'], $args['exclude_from'], $args);
103 if (!$args['noheader']) $pagelist->setCaption($caption);
105 } elseif ($args['format'] == 'text') {
106 $request->discardOutput();
107 $request->buffer_output(COMPRESS_OUTPUT);
109 header("Content-Type: text/plain");
110 $request->checkValidators();
111 while ($page = $pages->next()) {
112 echo $page->getName();
113 $links = $page->getPageLinks(false, $args['sortby'], $args['limit'], $args['exclude']);
114 while ($link = $links->next()) {
115 echo " ", $link->getName();
121 } elseif ($args['format'] == 'xml') {
122 // for hypergraph.jar. best dump it to a sitemap.xml
123 global $WikiTheme, $charset;
124 $currpage = $request->getArg('pagename');
125 $request->discardOutput();
126 $request->buffer_output(false);
128 header("Content-Type: text/xml");
129 $request->checkValidators();
130 echo "<?xml version=\"1.0\" encoding=\"$charset\"?>\n";
131 $dtd = SERVER_URL . $WikiTheme->_findData("GraphXML.dtd");
132 echo "<!DOCTYPE GraphXML SYSTEM \"$dtd\">\n";
133 echo "<GraphXML xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
134 echo "<graph id=\"",WIKI_NAME,"\">\n";
135 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";
136 while ($page = $pages->next()) {
137 $pageid = MangleXmlIdentifier($page->getName());
138 $pagename = $page->getName();
139 echo "<node name=\"$pageid\"";
140 if ($pagename == $currpage) echo " class=\"main\"";
141 echo "><label>$pagename</label>";
142 echo "<dataref><ref xlink:href=\"",WikiURL($pagename,'',true),"\"/></dataref></node>\n";
143 $links = $page->getPageLinks(false, $args['sortby'], $args['limit'], $args['exclude']);
144 while ($link = $links->next()) {
145 $edge = MangleXmlIdentifier($link->getName());
146 echo "<edge source=\"$pageid\" target=\"$edge\" />\n";
151 echo "</GraphXML>\n\n";
152 unset($GLOBALS['ErrorManager']->_postponed_errors);
155 return $this->error(fmt("Unsupported format argument %s", $args['format']));
160 class _PageList_Column_LinkDatabase_links extends _PageList_Column {
161 function _getValue($page, &$revision_handle) {
163 $links = $page->getPageLinks();
164 while ($link = $links->next()) {
165 $out->pushContent(" ", WikiLink($link));
171 // $Log: not supported by cvs2svn $
172 // Revision 1.1 2004/11/30 21:02:16 rurban
173 // A simple plugin for WikiBrowser at http://touchgraph.sourceforge.net/
174 // List all pages with all links as text file (with some caching tricks).
175 // format=html currently unstable.
182 // c-hanging-comment-ender-p: nil
183 // indent-tabs-mode: nil