Skip to content

Commit

Permalink
feature 2112 added: ability to set an additional local directory
Browse files Browse the repository at this point in the history
$conf['local_dir_site'] in local/config/multisite.inc.php


git-svn-id: http://piwigo.org/svn/trunk@8722 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Jan 17, 2011
1 parent 91fc33d commit 8ccd3a2
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 18 deletions.
18 changes: 16 additions & 2 deletions include/common.inc.php
Expand Up @@ -70,7 +70,17 @@ function sanitize_mysql_kv(&$v, $k)
$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');
Expand All @@ -92,6 +102,10 @@ function sanitize_mysql_kv(&$v, $k)

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']))
Expand Down Expand Up @@ -151,7 +165,7 @@ function sanitize_mysql_kv(&$v, $k)
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)
Expand Down
1 change: 1 addition & 0 deletions include/constants.php
Expand Up @@ -27,6 +27,7 @@
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');
Expand Down
2 changes: 1 addition & 1 deletion include/functions.inc.php
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion include/functions_mail.inc.php
Expand Up @@ -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)
);

Expand Down
6 changes: 3 additions & 3 deletions include/template.class.php
Expand Up @@ -797,13 +797,13 @@ static function prefilter_local_css($source, &$smarty)
$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}");
Expand Down Expand Up @@ -1133,7 +1133,7 @@ private static function cmp_by_mode_and_order($s1, $s2)
/*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();
Expand Down
16 changes: 15 additions & 1 deletion install.php
Expand Up @@ -114,8 +114,22 @@
$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']))
Expand Down Expand Up @@ -152,7 +166,7 @@
$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);
Expand Down
2 changes: 1 addition & 1 deletion nbm.php
Expand Up @@ -34,7 +34,7 @@
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) );



Expand Down
8 changes: 4 additions & 4 deletions plugins/LocalFilesEditor/admin.php
Expand Up @@ -130,7 +130,7 @@
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'];

Expand All @@ -145,14 +145,14 @@
$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;
}
Expand Down Expand Up @@ -247,7 +247,7 @@
$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;
Expand Down
2 changes: 1 addition & 1 deletion plugins/language_switch/language_switch.inc.php
Expand Up @@ -49,7 +49,7 @@ static public function _switch()
// 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
Expand Down
20 changes: 17 additions & 3 deletions upgrade.php
Expand Up @@ -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)
{
Expand All @@ -36,9 +46,13 @@
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');
Expand Down Expand Up @@ -308,7 +322,7 @@ function print_time($message)
$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>'
Expand Down
17 changes: 16 additions & 1 deletion upgrade_feed.php
Expand Up @@ -32,9 +32,24 @@
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');

// +-----------------------------------------------------------------------+
Expand Down

0 comments on commit 8ccd3a2

Please sign in to comment.