2 rcs_id('$Id: SemanticSearch.php,v 1.1 2006-03-07 20:52:01 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 * @author: Reini Urban
26 class WikiPlugin_SemanticSearch
30 return _("SemanticSearch");
32 function getDescription() {
33 return _("Search relations and attributes");
35 function getVersion() {
36 return preg_replace("/[Revision: $]/", '',
39 function getDefaultArguments() {
41 's' => "", // query string
42 'page' => "", // which pages (glob allowed), default: current
43 'relation' => '', // which relations. default all
44 'attribute' => '', // which attributes. default all
50 function run ($dbi, $argstr, &$request, $basepage) {
52 $args = $this->getArgs($argstr, $request);
55 $page = $request->getArg('pagename');
57 foreach (explodePageList($page) as $pagename) {
58 $p = $dbi->getPage($pagename);
59 $links = $p->getRelations(); // iter of pagelinks
60 // TODO: merge same relations together located_in::here, located_in::there
61 while ($object = $links->next()) {
62 if ($related = $object->get('linkrelation')) { // a page name
65 // Link to a special "Relation:" InterWiki link?
66 WikiLink($related, false, $related),
67 " :: ", // use spaces?
68 WikiLink($object->_pagename),
70 // Link to SemanticSearch
71 $WikiTheme->makeActionButton(array('relation' => $related,
72 'object' => $object->_pagename),
78 if (!empty($relhtml->_content) and !$noheader)
79 $relhtml = HTML(HTML::hr(),
80 HTML::h3(fmt("Semantic relations for %s", $p->getName())),
83 if ($attributes = $p->get('attributes')) { // a hash of unique pairs
84 foreach ($attributes as $att => $val) {
86 $atthtml->pushContent("$pagename $att := $val", HTML::br());
88 $atthtml->pushContent("$att := $val", HTML::br());
91 $relhtml = HTML($relhtml,
93 HTML::h3(fmt("Attributes of %s", $p->getName())),
96 $relhtml = HTML($relhtml, $atthtml);
99 if ($nohelp) return $relhtml;
100 return HTML($relhtml,
102 WikiLink(_("Help/SemanticRelations"), false,
103 HTML::em(_("Help/SemanticRelations"))),
105 HTML::em(_("Find out how to add relations and attributes to pages.")));
110 // $Log: not supported by cvs2svn $
116 // c-hanging-comment-ender-p: nil
117 // indent-tabs-mode: nil