2 rcs_id('$Id: SemanticRelations.php,v 1.1 2005-11-21 20:14:20 rurban Exp $');
4 Copyright 2005 Reini Urban
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
24 * SemanticRelations - Display the list of relations and attributes of given page(s).
25 * Relations are stored in the link table.
26 * Attributes as simple page meta-data.
28 * @author: Reini Urban
30 class WikiPlugin_SemanticRelations
34 return _("SemanticRelations");
36 function getDescription() {
37 return _("Display the list of relations and attributes");
39 function getVersion() {
40 return preg_replace("/[Revision: $]/", '',
43 function getDefaultArguments() {
45 'page' => "", // which pages (glob allowed), default: current
46 'relations' => '', // which relations. default all
47 'attributes' => '', // which attributes. default all
53 function run ($dbi, $argstr, &$request, $basepage) {
55 $args = $this->getArgs($argstr, $request);
58 $page = $request->getArg('pagename');
60 foreach (explodePageList($page) as $pagename) {
61 $p = $dbi->getPage($pagename);
62 $links = $p->getRelations(); // iter of pagelinks
63 // TODO: merge same relations together located_in::here, located_in::there
64 while ($object = $links->next()) {
65 if ($related = $object->get('linkrelation')) { // a page name
68 // Link to a special "Relation:" InterWiki link?
69 WikiLink($related, false, $related),
70 " :: ", // use spaces?
71 WikiLink($object->_pagename),
73 // Link to SemanticSearch
74 $WikiTheme->makeActionButton(array('relation' => $related,
75 'object' => $object->_pagename),
81 if (!empty($relhtml->_content) and !$noheader)
82 $relhtml = HTML(HTML::hr(),
83 HTML::h3(fmt("Semantic relations for %s", $p->getName())),
86 if ($attributes = $p->get('attributes')) { // a hash of unique pairs
87 foreach ($attributes as $att => $val) {
89 $atthtml->pushContent("$pagename $att := $val", HTML::br());
91 $atthtml->pushContent("$att := $val", HTML::br());
94 $relhtml = HTML($relhtml,
96 HTML::h3(fmt("Attributes of %s", $p->getName())),
99 $relhtml = HTML($relhtml, $atthtml);
102 if ($nohelp) return $relhtml;
103 return HTML($relhtml,
105 WikiLink(_("Help/SemanticRelations"), false,
106 HTML::em(_("Help/SemanticRelations"))),
108 HTML::em(_("Find out how to add relations and attributes to pages.")));
113 // $Log: not supported by cvs2svn $
119 // c-hanging-comment-ender-p: nil
120 // indent-tabs-mode: nil