4 * Copyright (C) 2010 Olaf Lenz
6 * This file is part of FusionForge.
8 * FusionForge 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 * FusionForge 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 FusionForge; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 /** This script will set up the structure required to use the
26 It is usually started from the plugin manager, but can also be
30 if ( isset( $_SERVER ) &&
31 array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
32 $command_line = false;
34 require('/etc/gforge/local.inc');
35 require_once (dirname(__FILE__) . '/../../env.inc.php');
39 if (!isset($mediawiki_var_path))
40 $mediawiki_var_path = "$sys_var_path/plugins/mediawiki";
41 if (!isset($mediawiki_projects_path))
42 $mediawiki_projects_path = "$mediawiki_var_path/projects";
43 if (!isset($mediawiki_master_path))
44 $mediawiki_master_path = "$mediawiki_var_path/master";
47 if (!is_dir($mediawiki_projects_path))
48 system("mkdir -p $mediawiki_projects_path");
49 if (!is_dir($mediawiki_master_path))
50 system("mkdir -p $mediawiki_master_path");
52 function mysymlink($from, $to) {
54 if (!@symlink($from, $to))
55 $mw_feedback[] = sprintf(_('Could not create symbolic link from %1$s to %1$s'), $from, $to);
58 $mw_feedback = array();
59 # install links in master
60 # link files from $mediawiki_src_path to $mediawiki_master_path
61 if (!($dh = opendir($mediawiki_src_path))) {
62 $mw_feedback[] = sprintf(_('Could not open mediawiki source directory %1$s!'), $mediawiki_src_path);
73 while ($file = readdir($dh)) {
74 if (!$ignore_file[$file]) {
75 $from = "$mediawiki_src_path/$file";
76 $to = "$mediawiki_master_path/$file";
77 mysymlink($from, $to);
83 # link LocalSettings.php from /etc/gforge/plugins/mediawiki/LocalSettings.php or from $sys_opt_path/plugins/mediawiki/etc/plugins/mediawiki/LocalSettings.php
84 $from = "$sys_etc_path/plugins/mediawiki/LocalSettings.php";
85 if (!file_exists($from)) {
86 $from = "$sys_opt_path/plugins/mediawiki/etc/plugins/mediawiki/LocalSettings.php";
88 $to = "$mediawiki_master_path/LocalSettings.php";
89 mysymlink($from, $to);
91 # create skin directory
92 $todir = "$mediawiki_master_path/skins";
96 # link FusionForge skin file
97 $fromdir = "$sys_opt_path/plugins/mediawiki/mediawiki-skin";
98 $from = "$fromdir/FusionForge.php";
99 $to = "$todir/FusionForge.php";
100 mysymlink($from, $to);
103 $todir = "$todir/fusionforge";
107 # link fusionforge main.css files
108 $fromdir = "$fromdir/fusionforge";
109 $from = "$fromdir/main.css";
110 $to = "$todir/main.css";
111 mysymlink($from, $to);
113 # link the rest of the files from monobook skin
114 $fromdir = "$mediawiki_src_path/skins/monobook";
116 $dh = opendir($fromdir);
117 $ignore_file = array(
122 while ($file = readdir($dh)) {
123 if (!$ignore_file[$file]) {
124 $from = "$fromdir/$file";
125 $to = "$todir/$file";
126 mysymlink($from, $to);
132 foreach ($mw_feedback as $line) {
136 foreach ($mw_feedback as $line) {
137 $feedback .= "<br />$line";
139 $feedback .= "<br />";
144 // c-file-style: "bsd"