aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2011-01-17 18:48:13 +0000
committerplegall <plg@piwigo.org>2011-01-17 18:48:13 +0000
commit8ccd3a203d407f549cd8697a5fa66181e90d9871 (patch)
tree5d0e203c02905f157316683aa0bc75126fb5f171
parent91fc33dc8eea8bfd38f36f34c1abaa389b7e92e5 (diff)
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
-rw-r--r--include/common.inc.php18
-rw-r--r--include/constants.php1
-rw-r--r--include/functions.inc.php2
-rw-r--r--include/functions_mail.inc.php2
-rw-r--r--include/template.class.php6
-rw-r--r--install.php16
-rw-r--r--nbm.php2
-rw-r--r--plugins/LocalFilesEditor/admin.php8
-rw-r--r--plugins/language_switch/language_switch.inc.php2
-rw-r--r--upgrade.php20
-rw-r--r--upgrade_feed.php17
11 files changed, 76 insertions, 18 deletions
diff --git a/include/common.inc.php b/include/common.inc.php
index c898ec546..a67433000 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -70,7 +70,17 @@ $header_msgs = array();
$header_notes = array();
$filter = array();
-@include(PHPWG_ROOT_PATH .'local/config/database.inc.php');
+if (is_file(PHPWG_ROOT_PATH .'local/config/multisite.inc.php'))
+{
+ include(PHPWG_ROOT_PATH .'local/config/multisite.inc.php');
+ define('PWG_LOCAL_DIR', $conf['local_dir_site']);
+}
+else
+{
+ define('PWG_LOCAL_DIR', 'local/');
+}
+
+@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php');
if (!defined('PHPWG_INSTALLED'))
{
header('Location: install.php');
@@ -92,6 +102,10 @@ foreach( array(
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
+if (isset($conf['local_dir_site']))
+{
+ @include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
+}
include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php');
if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors']))
@@ -151,7 +165,7 @@ if ( is_admin() || (defined('IN_ADMIN') and IN_ADMIN) )
load_language('admin.lang');
}
trigger_action('loading_lang');
-load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
+load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
// only now we can set the localized username of the guest user (and not in
// include/user.inc.php)
diff --git a/include/constants.php b/include/constants.php
index 8135147eb..a3885da8c 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -27,6 +27,7 @@ define('PHPWG_DEFAULT_LANGUAGE', 'en_UK');
define('PHPWG_DEFAULT_TEMPLATE', 'Sylvia');
define('PHPWG_THEMES_PATH', $conf['themes_dir'].'/');
+define('PWG_COMBINED_DIR', PWG_LOCAL_DIR.'combined/');
// Required versions
define('REQUIRED_PHP_VERSION', '5.0.0');
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 653031ab6..d8f3da32f 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -575,7 +575,7 @@ function redirect_html( $url , $msg = '', $refresh_time = 0)
$user = build_user( $conf['guest_id'], true);
load_language('common.lang');
trigger_action('loading_lang');
- load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
+ load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
$template = new Template(PHPWG_ROOT_PATH.'themes', get_default_theme());
}
elseif (defined('IN_ADMIN') and IN_ADMIN)
diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php
index 5443781a7..27da2cf3b 100644
--- a/include/functions_mail.inc.php
+++ b/include/functions_mail.inc.php
@@ -223,7 +223,7 @@ function switch_lang_to($language)
// Translations are in admin file too
load_language('admin.lang', '', array('language'=>$language) );
trigger_action('loading_lang');
- load_language('lang', PHPWG_ROOT_PATH.'local/',
+ load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR,
array('language'=>$language, 'no_fallback'=>true, 'local'=>true)
);
diff --git a/include/template.class.php b/include/template.class.php
index 9e8a6231f..0cccace81 100644
--- a/include/template.class.php
+++ b/include/template.class.php
@@ -797,13 +797,13 @@ var s;';
$css = array();
foreach ($smarty->get_template_vars('themes') as $theme)
{
- $f = 'local/css/'.$theme['id'].'-rules.css';
+ $f = PWG_LOCAL_DIR.'css/'.$theme['id'].'-rules.css';
if (file_exists(PHPWG_ROOT_PATH.$f))
{
array_push($css, "{combine_css path='$f' order=10}");
}
}
- $f = 'local/css/rules.css';
+ $f = PWG_LOCAL_DIR.'css/rules.css';
if (file_exists(PHPWG_ROOT_PATH.$f))
{
array_push($css, "{combine_css path='$f' order=10}");
@@ -1133,7 +1133,7 @@ class ScriptLoader
/*Allows merging of javascript and css files into a single one.*/
final class FileCombiner
{
- const OUT_SUB_DIR = 'local/combined/';
+ const OUT_SUB_DIR = PWG_COMBINED_DIR;
private $type; // js or css
private $files = array();
private $versions = array();
diff --git a/install.php b/install.php
index 5850e9180..661598f04 100644
--- a/install.php
+++ b/install.php
@@ -114,8 +114,22 @@ else
$prefixeTable = DEFAULT_PREFIX_TABLE;
}
+if (is_file(PHPWG_ROOT_PATH .'local/config/multisite.inc.php'))
+{
+ include(PHPWG_ROOT_PATH .'local/config/multisite.inc.php');
+ define('PWG_LOCAL_DIR', $conf['local_dir_site']);
+}
+else
+{
+ define('PWG_LOCAL_DIR', 'local/');
+}
+
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
+if (isset($conf['local_dir_site']))
+{
+ @include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
+}
// download database config file if exists
if (!empty($_GET['dl']) && file_exists($conf['local_data_dir'].'/pwg_'.$_GET['dl']))
@@ -152,7 +166,7 @@ if (isset($_POST['install']))
$infos = array();
$errors = array();
-$config_file = PHPWG_ROOT_PATH . 'local/config/database.inc.php';
+$config_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php';
if (@file_exists($config_file))
{
include($config_file);
diff --git a/nbm.php b/nbm.php
index 5fc5c4f48..3862f0a8f 100644
--- a/nbm.php
+++ b/nbm.php
@@ -34,7 +34,7 @@ include_once(PHPWG_ROOT_PATH.'admin/include/functions_notification_by_mail.inc.p
load_language('admin.lang');
// Need to update a second time
trigger_action('loading_lang');
-load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
+load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) );
diff --git a/plugins/LocalFilesEditor/admin.php b/plugins/LocalFilesEditor/admin.php
index 7d32ad061..236b6aa9c 100644
--- a/plugins/LocalFilesEditor/admin.php
+++ b/plugins/LocalFilesEditor/admin.php
@@ -130,7 +130,7 @@ if (isset($_POST['create_tpl']))
switch ($page['tab'])
{
case 'localconf':
- $edited_file = PHPWG_ROOT_PATH . "local/config/config.inc.php";
+ $edited_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "config/config.inc.php";
$content_file = file_exists($edited_file) ?
file_get_contents($edited_file) : $new_file['localconf'];
@@ -145,14 +145,14 @@ switch ($page['tab'])
$selected = 0;
$options[] = l10n('locfiledit_choose_file');
$options[] = '----------------------';
- $value = PHPWG_ROOT_PATH . "local/css/rules.css";
+ $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "css/rules.css";
$options[$value] = 'local / css / rules.css';
if ($edited_file == $value) $selected = $value;
$options[] = '----------------------';
foreach (get_dirs($conf['themes_dir']) as $theme_id)
{
- $value = PHPWG_ROOT_PATH . 'local/css/'.$theme_id.'-rules.css';
+ $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme_id.'-rules.css';
$options[$value] = 'local / css / '.$theme_id.'-rules.css';
if ($edited_file == $value) $selected = $value;
}
@@ -247,7 +247,7 @@ switch ($page['tab'])
$options[] = '----------------------';
foreach (get_languages() as $language_code => $language_name)
{
- $value = PHPWG_ROOT_PATH.'local/language/'.$language_code.'.lang.php';
+ $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'language/'.$language_code.'.lang.php';
if ($edited_file == $value)
{
$selected = $value;
diff --git a/plugins/language_switch/language_switch.inc.php b/plugins/language_switch/language_switch.inc.php
index 500e07d91..9e9a3ca56 100644
--- a/plugins/language_switch/language_switch.inc.php
+++ b/plugins/language_switch/language_switch.inc.php
@@ -49,7 +49,7 @@ class language_controler {
// Reload language only if it isn't the same one
if ( $same !== $user['language']) {
load_language('common.lang', '', array('language'=>$user['language']) );
- load_language('lang', PHPWG_ROOT_PATH.'local/',
+ load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR,
array('language'=>$user['language'], 'no_fallback'=>true, 'local'=>true)
);
if (defined('IN_ADMIN') and IN_ADMIN) { // Never currently
diff --git a/upgrade.php b/upgrade.php
index eb2d57646..1bfe3d44a 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -24,7 +24,17 @@
define('PHPWG_ROOT_PATH', './');
// load config file
-$config_file = PHPWG_ROOT_PATH.'local/config/database.inc.php';
+if (is_file(PHPWG_ROOT_PATH .'local/config/multisite.inc.php'))
+{
+ include(PHPWG_ROOT_PATH .'local/config/multisite.inc.php');
+ define('PWG_LOCAL_DIR', $conf['local_dir_site']);
+}
+else
+{
+ define('PWG_LOCAL_DIR', 'local/');
+}
+
+$config_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'config/database.inc.php';
$config_file_contents = @file_get_contents($config_file);
if ($config_file_contents === false)
{
@@ -36,9 +46,13 @@ if ($php_end_tag === false)
die('Cannot find php end tag in '.$config_file);
}
-include(PHPWG_ROOT_PATH.'local/config/database.inc.php');
+include($config_file);
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
+if (isset($conf['local_dir_site']))
+{
+ @include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
+}
// $conf is not used for users tables - define cannot be re-defined
define('USERS_TABLE', $prefixeTable.'users');
@@ -308,7 +322,7 @@ if ((isset($_POST['submit']) or isset($_GET['now']))
$page['infos'],
sprintf(
l10n('In <i>%s</i>, before <b>?></b>, insert:'),
- 'local/config/database.inc.php'
+ PWG_LOCAL_DIR.'config/database.inc.php'
)
.'<p><textarea rows="4" cols="40">'
.implode("\r\n" , $mysql_changes).'</textarea></p>'
diff --git a/upgrade_feed.php b/upgrade_feed.php
index 5ddfa0dc6..bfcb3401f 100644
--- a/upgrade_feed.php
+++ b/upgrade_feed.php
@@ -32,9 +32,24 @@ define('PHPWG_ROOT_PATH', './');
include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php');
-include(PHPWG_ROOT_PATH.'local/config/database.inc.php');
+
+if (is_file(PHPWG_ROOT_PATH .'local/config/multisite.inc.php'))
+{
+ include(PHPWG_ROOT_PATH .'local/config/multisite.inc.php');
+ define('PWG_LOCAL_DIR', $conf['local_dir_site']);
+}
+else
+{
+ define('PWG_LOCAL_DIR', 'local/');
+}
+
+include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php');
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
+if (isset($conf['local_dir_site']))
+{
+ @include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
+}
include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php');
// +-----------------------------------------------------------------------+