- local.lang is loaded without fallback on default language or PHPWG_DEFAULT_LANGUAGE (needed to change the signature of load_language which became a little too big)

- move a function from functions.inc.php to functions_picture.inc.php (included only when necessary)
- removed some css (not as much as I wanted)

git-svn-id: http://piwigo.org/svn/trunk@2479 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2008-08-20 00:35:22 +00:00
parent dcbaefafdf
commit 5a6298548b
15 changed files with 133 additions and 126 deletions
+1 -1
View File
@@ -177,7 +177,7 @@ if ( is_admin() || (defined('IN_ADMIN') and IN_ADMIN) )
load_language('admin.lang');
}
trigger_action('loading_lang');
load_language('local.lang');
load_language('local.lang', '', array('no_fallback'=>true) );
// only now we can set the localized username of the guest user (and not in
// include/user.inc.php)
+25 -71
View File
@@ -239,62 +239,6 @@ function mkget_thumbnail_dir($dirname, &$errors)
return $tndir;
}
// The get_picture_size function return an array containing :
// - $picture_size[0] : final width
// - $picture_size[1] : final height
// The final dimensions are calculated thanks to the original dimensions and
// the maximum dimensions given in parameters. get_picture_size respects
// the width/height ratio
function get_picture_size( $original_width, $original_height,
$max_width, $max_height )
{
$width = $original_width;
$height = $original_height;
$is_original_size = true;
if ( $max_width != "" )
{
if ( $original_width > $max_width )
{
$width = $max_width;
$height = floor( ( $width * $original_height ) / $original_width );
}
}
if ( $max_height != "" )
{
if ( $original_height > $max_height )
{
$height = $max_height;
$width = floor( ( $height * $original_width ) / $original_height );
$is_original_size = false;
}
}
if ( is_numeric( $max_width ) and is_numeric( $max_height )
and $max_width != 0 and $max_height != 0 )
{
$ratioWidth = $original_width / $max_width;
$ratioHeight = $original_height / $max_height;
if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) )
{
if ( $ratioWidth < $ratioHeight )
{
$width = floor( $original_width / $ratioHeight );
$height = $max_height;
}
else
{
$width = $max_width;
$height = floor( $original_height / $ratioWidth );
}
$is_original_size = false;
}
}
$picture_size = array();
$picture_size[0] = $width;
$picture_size[1] = $height;
return $picture_size;
}
/* Returns true if the string appears to be encoded in UTF-8. (from wordpress)
* @param string Str
*/
@@ -752,7 +696,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');
load_language('local.lang', '', array('no_fallback'=>true) );
list($tmpl, $thm) = explode('/', get_default_template());
$template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm);
}
@@ -1394,17 +1338,19 @@ function get_pwg_charset()
*
* @param string filename
* @param string dirname
* @param string language
* @param bool return_content - if true the file content is returned otherwise
* the file is evaluated as php
* @return boolean success status or a string if return_content is true
* @param mixed options can contain
* language - language to load (if empty uses user language)
* return - if true the file content is returned otherwise the file is evaluated as php
* target_charset -
* no_fallback - the language must be respected
* @return boolean success status or a string if options['return'] is true
*/
function load_language($filename, $dirname = '', $language = '',
$return_content=false, $target_charset=null)
function load_language($filename, $dirname = '',
$options = array() )
{
global $user;
if (!$return_content)
if (! @$options['return'] )
{
$filename .= '.php'; //MAYBE to do .. load .po and .mo localization files
}
@@ -1415,25 +1361,33 @@ function load_language($filename, $dirname = '', $language = '',
$dirname .= 'language/';
$languages = array();
if ( !empty($language) )
if ( !empty($options['language']) )
{
$languages[] = $language;
$languages[] = $options['language'];
}
if ( !empty($user['language']) )
{
$languages[] = $user['language'];
}
if ( defined('PHPWG_INSTALLED') )
if ( ! @$options['no_fallback'] )
{
$languages[] = get_default_language();
if ( defined('PHPWG_INSTALLED') )
{
$languages[] = get_default_language();
}
$languages[] = PHPWG_DEFAULT_LANGUAGE;
}
$languages[] = PHPWG_DEFAULT_LANGUAGE;
$languages = array_unique($languages);
if ( empty($target_charset) )
if ( empty($options['target_charset']) )
{
$target_charset = get_pwg_charset();
}
else
{
$target_charset = $options['target_charset'];
}
$target_charset = strtolower($target_charset);
$source_charset = '';
$source_file = '';
@@ -1472,7 +1426,7 @@ function load_language($filename, $dirname = '', $language = '',
if ( !empty($source_file) )
{
if (!$return_content)
if (! @$options['return'] )
{
@include($source_file);
$load_lang = @$lang;
+3 -3
View File
@@ -246,12 +246,12 @@ function switch_lang_to($language)
$lang = array();
// language files
load_language('common.lang', '', $language);
load_language('common.lang', '', array('language'=>$language) );
// No test admin because script is checked admin (user selected no)
// Translations are in admin file too
load_language('admin.lang', '', $language);
load_language('admin.lang', '', array('language'=>$language) );
trigger_action('loading_lang');
load_language('local.lang', '', $language);
load_language('local.lang', '', array('language'=>$language, 'no_fallback'=>true));
$switch_lang[$language]['lang_info'] = $lang_info;
$switch_lang[$language]['lang'] = $lang;
+56
View File
@@ -327,4 +327,60 @@ function encode_slideshow_params($decode_params = array())
return $result;
}
// The get_picture_size function return an array containing :
// - $picture_size[0] : final width
// - $picture_size[1] : final height
// The final dimensions are calculated thanks to the original dimensions and
// the maximum dimensions given in parameters. get_picture_size respects
// the width/height ratio
function get_picture_size( $original_width, $original_height,
$max_width, $max_height )
{
$width = $original_width;
$height = $original_height;
$is_original_size = true;
if ( $max_width != "" )
{
if ( $original_width > $max_width )
{
$width = $max_width;
$height = floor( ( $width * $original_height ) / $original_width );
}
}
if ( $max_height != "" )
{
if ( $original_height > $max_height )
{
$height = $max_height;
$width = floor( ( $height * $original_width ) / $original_height );
$is_original_size = false;
}
}
if ( is_numeric( $max_width ) and is_numeric( $max_height )
and $max_width != 0 and $max_height != 0 )
{
$ratioWidth = $original_width / $max_width;
$ratioHeight = $original_height / $max_height;
if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) )
{
if ( $ratioWidth < $ratioHeight )
{
$width = floor( $original_width / $ratioHeight );
$height = $max_height;
}
else
{
$width = $max_width;
$height = floor( $original_height / $ratioWidth );
}
$is_original_size = false;
}
}
$picture_size = array();
$picture_size[0] = $width;
$picture_size[1] = $height;
return $picture_size;
}
?>