4 * MediaWikiPlugin Class
7 * This file is part of GForge.
9 * GForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * GForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with GForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 class MediaWikiPlugin extends Plugin {
25 function MediaWikiPlugin () {
27 $this->name = "mediawiki" ;
28 $this->text = "Mediawiki" ; // To show in the tabs, use...
29 $this->hooks[] = "groupmenu" ; // To put into the project tabs
30 $this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
31 $this->hooks[] = "groupisactivecheckboxpost" ; //
32 $this->hooks[] = "project_public_area";
35 function CallHook ($hookname, $params) {
36 global $use_mediawikiplugin,$G_SESSION,$HTML;
38 if (isset($params['group_id'])) {
39 $group_id=$params['group_id'];
40 } elseif (isset($params['group'])) {
41 $group_id=$params['group'];
45 if ($hookname == "groupmenu") {
46 $project = &group_get_object($group_id);
47 if (!$project || !is_object($project)) {
50 if ($project->isError()) {
53 if (!$project->isProject()) {
56 if ( $project->usesPlugin ( $this->name ) ) {
57 $params['TITLES'][]=$this->text;
58 if ($GLOBALS['sys_use_mwframe']){
59 $params['DIRS'][]=util_make_url ('/plugins/mediawiki/frame.php?group_id=' . $project->getID()) ;
61 $params['DIRS'][]=util_make_url('/plugins/mediawiki/wiki/'.$project->getUnixName().'/index.php');
64 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
65 } elseif ($hookname == "groupisactivecheckbox") {
66 //Check if the group is active
67 // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
68 $group = &group_get_object($group_id);
71 echo ' <input type="checkbox" name="use_mediawikiplugin" value="1" ';
72 // checked or unchecked?
73 if ( $group->usesPlugin ( $this->name ) ) {
79 echo "<strong>Use ".$this->text." Plugin</strong>";
82 } elseif ($hookname == "groupisactivecheckboxpost") {
83 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
84 $group = &group_get_object($group_id);
85 $use_mediawikiplugin = getStringFromRequest('use_mediawikiplugin');
86 if ( $use_mediawikiplugin == 1 ) {
87 $group->setPluginUse ( $this->name );
89 $group->setPluginUse ( $this->name, false );
91 } elseif ($hookname == "project_public_area") {
92 $project = &group_get_object($group_id);
93 if (!$project || !is_object($project)) {
96 if ($project->isError()) {
99 if (!$project->isProject()) {
102 if ( $project->usesPlugin ( $this->name ) ) {
103 print '<a href='. util_make_url ('/plugins/mediawiki/wiki/'.$project->getUnixName().'/index.php').'>';
104 print html_abs_image(util_make_url ('/plugins/mediawiki/wiki/'.$project->getUnixName().'/skins/fusionforge/wiki.png'),'20','20',array('alt'=>'Mediawiki'));
108 } elseif ($hookname == "blahblahblah") {
116 // c-file-style: "bsd"