]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/PluginManager.php
Added copyleft and plugin description & version, tweaked default
[SourceForge/phpwiki.git] / lib / plugin / PluginManager.php
1 <?php // -*-php-*-
2 rcs_id('$Id: PluginManager.php,v 1.2 2002-12-30 23:49:35 carstenklapp Exp $');
3 /**
4  */
5
6 class WikiPlugin_PluginManager
7 extends WikiPlugin
8 {
9     function getName () {
10         return _("PluginManager");
11     }
12
13     function getDescription () {
14         return _("Overview of the available PhpWikiPlugins");
15     }
16
17     function getVersion() {
18         return preg_replace("/[Revision: $]/", '',
19                             "\$Revision: 1.2 $");
20     }
21
22     function getDefaultArguments() {
23         return array();
24     }
25
26     function run($dbi, $argstr, $request) {
27         //extract($this->getArgs($argstr, $request));
28
29         $msg = HTML::p("PluginManager provides the WikiAdmin the list of PhpWikiPlugin~s on this wiki.");
30
31         if (! $request->_user->isadmin()) {
32             return $msg; // early return
33         }
34
35
36         $pd = new fileSet(PHPWIKI_DIR . '/lib/plugin', '*.php');
37         $plugins = $pd->getFiles();
38
39         $h = HTML();
40         $h->pushContent($msg);
41         $h->pushContent(HTML::h2(_("Plugins")));
42         $row_no = 0;
43
44         $table = HTML::table(array('class' => "pagelist"));
45         global $WikiNameRegexp;
46         foreach($plugins as $pname) {
47             $pname = str_replace(".php", "", $pname);
48             $temppluginclass = "<? plugin " . /*"WikiPlugin_" .*/ $pname . " ?>";
49             $w = new WikiPluginLoader;
50             $p = $w->getPlugin($pname);
51             $desc = $p->getDescription();
52             if (method_exists($p, 'getVersion')) {
53                 $ver = $p->getVersion();
54             }
55             else {
56                 $ver = "--";
57             }
58
59             $pnamelink = $pname;
60             $plink = false;
61             if (preg_match("/^$WikiNameRegexp\$/", $pname) && $dbi->isWikiPage($pname))
62                 $pnamelink = WikiLink($pname);
63
64             $ppname = $pname . "Plugin";
65             if (preg_match("/^$WikiNameRegexp\$/", $ppname) && $dbi->isWikiPage($ppname))
66                 $plink = WikiLink($ppname);
67             else {
68                 // exclude actionpages and plugins starting with _ from page list
69                 if ( !preg_match("/^_/", $pname) && !(@$request->isActionPage($pname))) //FIXME
70                     $plink = WikiLink($ppname, 'unknown');
71                 else
72                     $plink = false;
73             }
74             $row_no++;
75             $group = (int)($row_no / 2); //_group_rows
76             $class = ($group % 2) ? 'oddrow' : 'evenrow';
77
78             $tr = HTML::tr(array('class' => $class));
79             if ($plink) {
80                 $tr->pushContent(HTML::td($plink), HTML::td($ver), HTML::td($desc));
81                 $tr2 = HTML::tr(array('class' => $class));
82                 $tr2->pushContent(HTML::td($pnamelink), HTML::td(" "), HTML::td(" "));
83                 $plink = false;
84                 $table->pushContent($tr, $tr2);
85                 $row_no++;
86             }
87             else {
88                 $tr->pushContent(HTML::td($pnamelink), HTML::td($ver), HTML::td($desc));
89                 $table->pushContent($tr);
90             }
91         }
92         $h->pushContent($table);
93
94         //$h->pushContent(HTML::h2(_("Disabled Plugins")));
95
96         return $h;
97     }
98 };
99
100 // Local Variables:
101 // mode: php
102 // tab-width: 8
103 // c-basic-offset: 4
104 // c-hanging-comment-ender-p: nil
105 // indent-tabs-mode: nil
106 // End:
107 ?>