2 rcs_id('$Id: LinkDatabase.php,v 1.1 2004-11-30 21:02:16 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 without intermediate text file
30 * http://hypergraph.sourceforge.net/ (not yet tested)
32 class WikiPlugin_LinkDatabase
33 extends WikiPluginCached
36 return _("LinkDatabase");
38 function getPluginType() {
39 return PLUGIN_CACHED_HTML;
41 function getDescription () {
42 return _("List all pages with all links in text-format for some Java Visualization tools");
44 function getVersion() {
45 return preg_replace("/[Revision: $]/", '',
48 function getExpire($dbi, $argarray, $request) {
49 return '+900'; // 15 minutes
52 function getDefaultArguments() {
55 PageList::supportedArgs(),
57 'format' => 'text', // or 'html'
59 'include_empty' => false,
60 'exclude_from' => false,
65 function getHtml($dbi, $argarray, $request, $basepage) {
66 $this->run($dbi, WikiPluginCached::glueArgs($argarray), $request, $basepage);
69 function run($dbi, $argstr, $request, $basepage) {
70 $args = $this->getArgs($argstr, $request);
71 $caption = _("All pages with all links in this wiki (%d total):");
73 if ( !empty($args['owner']) ) {
74 $pages = PageList::allPagesByOwner($args['owner'],$args['include_empty'],$args['sortby'],$args['limit']);
76 $caption = fmt("List of pages owned by [%s] (%d total):",
77 WikiLink($args['owner'], 'if_known'),
79 } elseif ( !empty($args['author']) ) {
80 $pages = PageList::allPagesByAuthor($args['author'],$args['include_empty'],$args['sortby'],$args['limit']);
82 $caption = fmt("List of pages last edited by [%s] (%d total):",
83 WikiLink($args['author'], 'if_known'),
85 } elseif ( !empty($args['creator']) ) {
86 $pages = PageList::allPagesByCreator($args['creator'],$args['include_empty'],$args['sortby'],$args['limit']);
88 $caption = fmt("List of pages created by [%s] (%d total):",
89 WikiLink($args['creator'], 'if_known'),
92 if (! $request->getArg('count')) $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude_from']);
93 else $args['count'] = $request->getArg('count');
94 $pages = $dbi->getAllPages($args['include_empty'], $args['sortby'], $args['limit'], $args['exclude_from']);
96 if ($args['format'] == 'html') {
97 $args['types']['links'] =
98 new _PageList_Column_LinkDatabase_links('links', _("Links"), 'left');
99 $pagelist = new PageList($args['info'], $args['exclude_from'], $args);
100 if (!$args['noheader']) $pagelist->setCaption($caption);
102 } elseif ($args['format'] == 'text') {
103 $request->discardOutput();
104 $request->buffer_output(COMPRESS_OUTPUT);
106 header("Content-Type: text/plain");
107 $request->checkValidators();
108 while ($page = $pages->next()) {
109 echo $page->getName();
110 $links = $page->getPageLinks(false, $args['sortby'], $args['limit'], $args['exclude']);
111 while ($link = $links->next()) {
112 echo " ", $link->getName();
119 return $this->error(fmt("Unsupported format argument %s", $args['format']));
124 class _PageList_Column_LinkDatabase_links extends _PageList_Column {
125 function _getValue($page, &$revision_handle) {
127 $links = $page->getPageLinks();
128 while ($link = $links->next()) {
129 $out->pushContent(" ", WikiLink($link));
135 // $Log: not supported by cvs2svn $
141 // c-hanging-comment-ender-p: nil
142 // indent-tabs-mode: nil