]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/PageInfo.php
Activated Revision substitution for Subversion
[SourceForge/phpwiki.git] / lib / plugin / PageInfo.php
1 <?php // -*-php-*-
2 rcs_id('$Id$');
3 /**
4  Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5
6  This file is part of PhpWiki.
7
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.
12
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.
17
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
21  */
22
23 /**
24  * An ActionPage plugin which returns extra information about a page.
25  * This plugin just passes a page revision handle to the Template
26  * 'info.tmpl', which does all the real work.
27  */
28 class WikiPlugin_PageInfo
29 extends WikiPlugin
30 {
31     function getName () {
32         return _("PageInfo");
33     }
34
35     function getDescription () {
36         return sprintf(_("Show extra page Info and statistics for %s."),
37                        '[pagename]');
38     }
39
40     function getVersion() {
41         return preg_replace("/[Revision: $]/", '',
42                             "\$Revision$");
43     }
44
45     function getDefaultArguments() {
46         return array('page' => '[pagename]',
47                      'version' => '[version]');
48     }
49
50     function run($dbi, $argstr, &$request, $basepage) {
51         $args = $this->getArgs($argstr, $request);
52         extract($args);
53
54         $pagename = $page;
55         $page = $request->getPage();
56         $current = $page->getCurrentRevision();
57         
58         if ($current->getVersion() < 1)
59             return fmt("I'm sorry, there is no such page as %s.",
60                        WikiLink($pagename, 'unknown'));
61
62         if (!empty($version)) {
63             if (!($revision = $page->getRevision($version)))
64                 NoSuchRevision($request, $page, $version);
65         }
66         else {
67             $revision = $current;
68         }
69
70         $template = new Template('info', $request,
71                                  array('revision' => $revision));
72         return $template;
73     }
74 };
75
76 // $Log: not supported by cvs2svn $
77 // Revision 1.4  2003/02/17 02:18:30  dairiki
78 // Fix so that PageInfo will work when current version of page
79 // has been "deleted".
80 //
81 // Fix so that PageInfo will work on an old version of a page.
82 //
83 // Revision 1.3  2003/01/18 21:49:01  carstenklapp
84 // Code cleanup:
85 // Reformatting & tabs to spaces;
86 // Added copyleft, getVersion, getDescription, rcs_id.
87 //
88 // Revision 1.2  2003/01/04 23:27:39  carstenklapp
89 // New: Gracefully handle non-existant pages. Added copyleft;
90 // getVersion() for PluginManager.
91 //
92
93 // (c-file-style: "gnu")
94 // Local Variables:
95 // mode: php
96 // tab-width: 8
97 // c-basic-offset: 4
98 // c-hanging-comment-ender-p: nil
99 // indent-tabs-mode: nil
100 // End:
101 ?>