From 6e51794b3f225a01f221fcc198b7c802b70ff987 Mon Sep 17 00:00:00 2001 From: patdenice Date: Sat, 20 Mar 2010 23:14:30 +0000 Subject: feature 1522: Move local css local files and local language files to local directory. Add $conf['template_force_compile'] to help developpers. git-svn-id: http://piwigo.org/svn/trunk@5208 68402e56-0260-453c-a942-63ccdbb3a9ee --- about.php | 2 +- include/common.inc.php | 2 +- include/config_default.inc.php | 5 +++++ include/functions.inc.php | 8 +++++-- include/functions_mail.inc.php | 4 +++- include/template.class.php | 30 ++++++++++++++++++++++++- local/config/index.php | 30 +++++++++++++++++++++++++ local/css/index.php | 30 +++++++++++++++++++++++++ local/index.php | 30 +++++++++++++++++++++++++ local/language/index.php | 30 +++++++++++++++++++++++++ nbm.php | 2 +- plugins/language_switch/language_switch.inc.php | 4 +++- 12 files changed, 169 insertions(+), 8 deletions(-) create mode 100644 local/config/index.php create mode 100644 local/css/index.php create mode 100644 local/index.php create mode 100644 local/language/index.php diff --git a/about.php b/about.php index 966ca2100..c3958a5ec 100644 --- a/about.php +++ b/about.php @@ -39,7 +39,7 @@ $page['body_id'] = 'theAboutPage'; include(PHPWG_ROOT_PATH.'include/page_header.php'); /** - * set in ./language/en_UK.iso-8859-1/local.lang.php (maybe to create) + * set in ./local/language/en_UK.lang.php (maybe to create) * for example for clear theme: $lang['Theme: clear'] = 'This is the clear theme based on yoga template. '. ' A standard template/theme of PhpWebgallery.'; diff --git a/include/common.inc.php b/include/common.inc.php index 5d7bbfa58..4d405b352 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -136,7 +136,7 @@ if ( is_admin() || (defined('IN_ADMIN') and IN_ADMIN) ) load_language('admin.lang'); } trigger_action('loading_lang'); -load_language('local.lang', '', array('no_fallback'=>true) ); +load_language('lang', PHPWG_ROOT_PATH.'local/', 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/config_default.inc.php b/include/config_default.inc.php index d58f235fa..c72f460ba 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -475,6 +475,11 @@ $conf['compiled_template_cache_language'] = false; // better performance. $conf['template_compile_check'] = true; +// This forces Smarty to (re)compile templates on every invocation. This is +// handy for development and debugging. It should never be used in a +// production environment. +$conf['template_force_compile'] = false; + // this permit to show the php errors reporting (see INI 'error_reporting' // for possible values) // gives an empty value '' to deactivate diff --git a/include/functions.inc.php b/include/functions.inc.php index 72bd807d0..c837232b7 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -583,7 +583,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('local.lang', '', array('no_fallback'=>true) ); + load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); $template = new Template(PHPWG_ROOT_PATH.'themes', get_default_theme()); } else @@ -1168,6 +1168,7 @@ function get_pwg_charset() * return - if true the file content is returned otherwise the file is evaluated as php * target_charset - * no_fallback - the language must be respected + * local - if true, get local language file * @return boolean success status or a string if options['return'] is true */ function load_language($filename, $dirname = '', @@ -1217,7 +1218,10 @@ function load_language($filename, $dirname = '', $source_file = ''; foreach ($languages as $language) { - $f = $dirname.$language.'/'.$filename; + $f = @$options['local'] ? + $dirname.$language.'.'.$filename: + $dirname.$language.'/'.$filename; + if (file_exists($f)) { $source_file = $f; diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php index 4e6ee21bc..5322e2165 100644 --- a/include/functions_mail.inc.php +++ b/include/functions_mail.inc.php @@ -255,7 +255,9 @@ function switch_lang_to($language) // Translations are in admin file too load_language('admin.lang', '', array('language'=>$language) ); trigger_action('loading_lang'); - load_language('local.lang', '', array('language'=>$language, 'no_fallback'=>true)); + load_language('lang', PHPWG_ROOT_PATH.'local/', + array('language'=>$language, 'no_fallback'=>true, 'local'=>true) + ); $switch_lang['language'][$language]['lang_info'] = $lang_info; $switch_lang['language'][$language]['lang'] = $lang; diff --git a/include/template.class.php b/include/template.class.php index f20459dce..7bb328ec2 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -49,7 +49,8 @@ class Template { $this->smarty = new Smarty; $this->smarty->debugging = $conf['debug_template']; - $this->smarty->compile_check=$conf['template_compile_check']; + $this->smarty->compile_check = $conf['template_compile_check']; + $this->smarty->force_compile = $conf['template_force_compile']; $compile_dir = $conf['local_data_dir'].'/templates_c'; mkgetdir( $compile_dir ); @@ -70,7 +71,10 @@ class Template { $this->smarty->template_dir = array(); if ( !empty($theme) ) + { $this->set_theme($root, $theme, $path); + $this->set_prefilter( 'header', array('Template', 'prefilter_local_css') ); + } else $this->set_template_dir($root); @@ -545,6 +549,30 @@ class Template { return $source; } + + static function prefilter_local_css($source, &$smarty) + { + $css = array(); + + foreach ($smarty->get_template_vars('themes') as $theme) + { + if (file_exists(PHPWG_ROOT_PATH.'local/css/'.$theme['id'].'-rules.css')) + { + array_push($css, ''); + } + } + if (file_exists(PHPWG_ROOT_PATH.'local/css/rules.css')) + { + array_push($css, ''); + } + + if (!empty($css)) + { + $source = str_replace("\n", "\n".implode( "\n", $css )."\n", $source); + } + + return $source; + } } diff --git a/local/config/index.php b/local/config/index.php new file mode 100644 index 000000000..871b52b6a --- /dev/null +++ b/local/config/index.php @@ -0,0 +1,30 @@ + diff --git a/local/css/index.php b/local/css/index.php new file mode 100644 index 000000000..871b52b6a --- /dev/null +++ b/local/css/index.php @@ -0,0 +1,30 @@ + diff --git a/local/index.php b/local/index.php new file mode 100644 index 000000000..871b52b6a --- /dev/null +++ b/local/index.php @@ -0,0 +1,30 @@ + diff --git a/local/language/index.php b/local/language/index.php new file mode 100644 index 000000000..871b52b6a --- /dev/null +++ b/local/language/index.php @@ -0,0 +1,30 @@ + diff --git a/nbm.php b/nbm.php index 7bef84962..5fc5c4f48 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('local.lang', '', array('no_fallback'=>true) ); +load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); diff --git a/plugins/language_switch/language_switch.inc.php b/plugins/language_switch/language_switch.inc.php index c97ed7637..cf815036e 100644 --- a/plugins/language_switch/language_switch.inc.php +++ b/plugins/language_switch/language_switch.inc.php @@ -49,7 +49,9 @@ 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('local.lang', '', array('language'=>$user['language'], 'no_fallback'=>true) ); + load_language('lang', PHPWG_ROOT_PATH.'local/', + array('language'=>$user['language'], 'no_fallback'=>true, 'local'=>true) + ); if (defined('IN_ADMIN') and IN_ADMIN) { // Never currently load_language('admin.lang', '', array('language'=>$user['language']) ); } -- cgit v1.2.3