Skip to content

Commit 8ccd3a2

Browse files
committed
feature 2112 added: ability to set an additional local directory
$conf['local_dir_site'] in local/config/multisite.inc.php git-svn-id: http://piwigo.org/svn/trunk@8722 68402e56-0260-453c-a942-63ccdbb3a9ee
1 parent 91fc33d commit 8ccd3a2

File tree

11 files changed

+76
-18
lines changed

11 files changed

+76
-18
lines changed

include/common.inc.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,17 @@ function sanitize_mysql_kv(&$v, $k)
7070
$header_notes = array();
7171
$filter = array();
7272

73-
@include(PHPWG_ROOT_PATH .'local/config/database.inc.php');
73+
if (is_file(PHPWG_ROOT_PATH .'local/config/multisite.inc.php'))
74+
{
75+
include(PHPWG_ROOT_PATH .'local/config/multisite.inc.php');
76+
define('PWG_LOCAL_DIR', $conf['local_dir_site']);
77+
}
78+
else
79+
{
80+
define('PWG_LOCAL_DIR', 'local/');
81+
}
82+
83+
@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php');
7484
if (!defined('PHPWG_INSTALLED'))
7585
{
7686
header('Location: install.php');
@@ -92,6 +102,10 @@ function sanitize_mysql_kv(&$v, $k)
92102

93103
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
94104
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
105+
if (isset($conf['local_dir_site']))
106+
{
107+
@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
108+
}
95109
include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php');
96110

97111
if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors']))
@@ -151,7 +165,7 @@ function sanitize_mysql_kv(&$v, $k)
151165
load_language('admin.lang');
152166
}
153167
trigger_action('loading_lang');
154-
load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
168+
load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
155169

156170
// only now we can set the localized username of the guest user (and not in
157171
// include/user.inc.php)

include/constants.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
define('PHPWG_DEFAULT_TEMPLATE', 'Sylvia');
2828

2929
define('PHPWG_THEMES_PATH', $conf['themes_dir'].'/');
30+
define('PWG_COMBINED_DIR', PWG_LOCAL_DIR.'combined/');
3031

3132
// Required versions
3233
define('REQUIRED_PHP_VERSION', '5.0.0');

include/functions.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ function redirect_html( $url , $msg = '', $refresh_time = 0)
575575
$user = build_user( $conf['guest_id'], true);
576576
load_language('common.lang');
577577
trigger_action('loading_lang');
578-
load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
578+
load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
579579
$template = new Template(PHPWG_ROOT_PATH.'themes', get_default_theme());
580580
}
581581
elseif (defined('IN_ADMIN') and IN_ADMIN)

include/functions_mail.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function switch_lang_to($language)
223223
// Translations are in admin file too
224224
load_language('admin.lang', '', array('language'=>$language) );
225225
trigger_action('loading_lang');
226-
load_language('lang', PHPWG_ROOT_PATH.'local/',
226+
load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR,
227227
array('language'=>$language, 'no_fallback'=>true, 'local'=>true)
228228
);
229229

include/template.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,13 +797,13 @@ static function prefilter_local_css($source, &$smarty)
797797
$css = array();
798798
foreach ($smarty->get_template_vars('themes') as $theme)
799799
{
800-
$f = 'local/css/'.$theme['id'].'-rules.css';
800+
$f = PWG_LOCAL_DIR.'css/'.$theme['id'].'-rules.css';
801801
if (file_exists(PHPWG_ROOT_PATH.$f))
802802
{
803803
array_push($css, "{combine_css path='$f' order=10}");
804804
}
805805
}
806-
$f = 'local/css/rules.css';
806+
$f = PWG_LOCAL_DIR.'css/rules.css';
807807
if (file_exists(PHPWG_ROOT_PATH.$f))
808808
{
809809
array_push($css, "{combine_css path='$f' order=10}");
@@ -1133,7 +1133,7 @@ private static function cmp_by_mode_and_order($s1, $s2)
11331133
/*Allows merging of javascript and css files into a single one.*/
11341134
final class FileCombiner
11351135
{
1136-
const OUT_SUB_DIR = 'local/combined/';
1136+
const OUT_SUB_DIR = PWG_COMBINED_DIR;
11371137
private $type; // js or css
11381138
private $files = array();
11391139
private $versions = array();

install.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,22 @@
114114
$prefixeTable = DEFAULT_PREFIX_TABLE;
115115
}
116116

117+
if (is_file(PHPWG_ROOT_PATH .'local/config/multisite.inc.php'))
118+
{
119+
include(PHPWG_ROOT_PATH .'local/config/multisite.inc.php');
120+
define('PWG_LOCAL_DIR', $conf['local_dir_site']);
121+
}
122+
else
123+
{
124+
define('PWG_LOCAL_DIR', 'local/');
125+
}
126+
117127
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
118128
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
129+
if (isset($conf['local_dir_site']))
130+
{
131+
@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
132+
}
119133

120134
// download database config file if exists
121135
if (!empty($_GET['dl']) && file_exists($conf['local_data_dir'].'/pwg_'.$_GET['dl']))
@@ -152,7 +166,7 @@
152166
$infos = array();
153167
$errors = array();
154168

155-
$config_file = PHPWG_ROOT_PATH . 'local/config/database.inc.php';
169+
$config_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php';
156170
if (@file_exists($config_file))
157171
{
158172
include($config_file);

nbm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
load_language('admin.lang');
3535
// Need to update a second time
3636
trigger_action('loading_lang');
37-
load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
37+
load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
3838

3939

4040

plugins/LocalFilesEditor/admin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
switch ($page['tab'])
131131
{
132132
case 'localconf':
133-
$edited_file = PHPWG_ROOT_PATH . "local/config/config.inc.php";
133+
$edited_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "config/config.inc.php";
134134
$content_file = file_exists($edited_file) ?
135135
file_get_contents($edited_file) : $new_file['localconf'];
136136

@@ -145,14 +145,14 @@
145145
$selected = 0;
146146
$options[] = l10n('locfiledit_choose_file');
147147
$options[] = '----------------------';
148-
$value = PHPWG_ROOT_PATH . "local/css/rules.css";
148+
$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "css/rules.css";
149149
$options[$value] = 'local / css / rules.css';
150150
if ($edited_file == $value) $selected = $value;
151151
$options[] = '----------------------';
152152

153153
foreach (get_dirs($conf['themes_dir']) as $theme_id)
154154
{
155-
$value = PHPWG_ROOT_PATH . 'local/css/'.$theme_id.'-rules.css';
155+
$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme_id.'-rules.css';
156156
$options[$value] = 'local / css / '.$theme_id.'-rules.css';
157157
if ($edited_file == $value) $selected = $value;
158158
}
@@ -247,7 +247,7 @@
247247
$options[] = '----------------------';
248248
foreach (get_languages() as $language_code => $language_name)
249249
{
250-
$value = PHPWG_ROOT_PATH.'local/language/'.$language_code.'.lang.php';
250+
$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'language/'.$language_code.'.lang.php';
251251
if ($edited_file == $value)
252252
{
253253
$selected = $value;

plugins/language_switch/language_switch.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static public function _switch()
4949
// Reload language only if it isn't the same one
5050
if ( $same !== $user['language']) {
5151
load_language('common.lang', '', array('language'=>$user['language']) );
52-
load_language('lang', PHPWG_ROOT_PATH.'local/',
52+
load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR,
5353
array('language'=>$user['language'], 'no_fallback'=>true, 'local'=>true)
5454
);
5555
if (defined('IN_ADMIN') and IN_ADMIN) { // Never currently

upgrade.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@
2424
define('PHPWG_ROOT_PATH', './');
2525

2626
// load config file
27-
$config_file = PHPWG_ROOT_PATH.'local/config/database.inc.php';
27+
if (is_file(PHPWG_ROOT_PATH .'local/config/multisite.inc.php'))
28+
{
29+
include(PHPWG_ROOT_PATH .'local/config/multisite.inc.php');
30+
define('PWG_LOCAL_DIR', $conf['local_dir_site']);
31+
}
32+
else
33+
{
34+
define('PWG_LOCAL_DIR', 'local/');
35+
}
36+
37+
$config_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'config/database.inc.php';
2838
$config_file_contents = @file_get_contents($config_file);
2939
if ($config_file_contents === false)
3040
{
@@ -36,9 +46,13 @@
3646
die('Cannot find php end tag in '.$config_file);
3747
}
3848

39-
include(PHPWG_ROOT_PATH.'local/config/database.inc.php');
49+
include($config_file);
4050
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
4151
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
52+
if (isset($conf['local_dir_site']))
53+
{
54+
@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
55+
}
4256

4357
// $conf is not used for users tables - define cannot be re-defined
4458
define('USERS_TABLE', $prefixeTable.'users');
@@ -308,7 +322,7 @@ function print_time($message)
308322
$page['infos'],
309323
sprintf(
310324
l10n('In <i>%s</i>, before <b>?></b>, insert:'),
311-
'local/config/database.inc.php'
325+
PWG_LOCAL_DIR.'config/database.inc.php'
312326
)
313327
.'<p><textarea rows="4" cols="40">'
314328
.implode("\r\n" , $mysql_changes).'</textarea></p>'

0 commit comments

Comments
 (0)