Ignore:
Timestamp:
Aug 20, 2008, 2:35:22 AM (16 years ago)
Author:
rvelices
Message:
  • 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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r2456 r2479  
    238238
    239239  return $tndir;
    240 }
    241 
    242 // The get_picture_size function return an array containing :
    243 //      - $picture_size[0] : final width
    244 //      - $picture_size[1] : final height
    245 // The final dimensions are calculated thanks to the original dimensions and
    246 // the maximum dimensions given in parameters.  get_picture_size respects
    247 // the width/height ratio
    248 function get_picture_size( $original_width, $original_height,
    249                            $max_width, $max_height )
    250 {
    251   $width = $original_width;
    252   $height = $original_height;
    253   $is_original_size = true;
    254 
    255   if ( $max_width != "" )
    256   {
    257     if ( $original_width > $max_width )
    258     {
    259       $width = $max_width;
    260       $height = floor( ( $width * $original_height ) / $original_width );
    261     }
    262   }
    263   if ( $max_height != "" )
    264   {
    265     if ( $original_height > $max_height )
    266     {
    267       $height = $max_height;
    268       $width = floor( ( $height * $original_width ) / $original_height );
    269       $is_original_size = false;
    270     }
    271   }
    272   if ( is_numeric( $max_width ) and is_numeric( $max_height )
    273        and $max_width != 0 and $max_height != 0 )
    274   {
    275     $ratioWidth = $original_width / $max_width;
    276     $ratioHeight = $original_height / $max_height;
    277     if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) )
    278     {
    279       if ( $ratioWidth < $ratioHeight )
    280       {
    281         $width = floor( $original_width / $ratioHeight );
    282         $height = $max_height;
    283       }
    284       else
    285       {
    286         $width = $max_width;
    287         $height = floor( $original_height / $ratioWidth );
    288       }
    289       $is_original_size = false;
    290     }
    291   }
    292   $picture_size = array();
    293   $picture_size[0] = $width;
    294   $picture_size[1] = $height;
    295   return $picture_size;
    296240}
    297241
     
    753697    load_language('common.lang');
    754698    trigger_action('loading_lang');
    755     load_language('local.lang');
     699    load_language('local.lang', '', array('no_fallback'=>true) );
    756700    list($tmpl, $thm) = explode('/', get_default_template());
    757701    $template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm);
     
    13951339 * @param string filename
    13961340 * @param string dirname
    1397  * @param string language
    1398  * @param bool return_content - if true the file content is returned otherwise
    1399  *  the file is evaluated as php
    1400  * @return boolean success status or a string if return_content is true
    1401  */
    1402 function load_language($filename, $dirname = '', $language = '',
    1403     $return_content=false, $target_charset=null)
     1341 * @param mixed options can contain
     1342 *     language - language to load (if empty uses user language)
     1343 *     return - if true the file content is returned otherwise the file is evaluated as php
     1344 *     target_charset -
     1345 *     no_fallback - the language must be respected
     1346 * @return boolean success status or a string if options['return'] is true
     1347 */
     1348function load_language($filename, $dirname = '',
     1349    $options = array() )
    14041350{
    14051351  global $user;
    14061352
    1407   if (!$return_content)
     1353  if (! @$options['return'] )
    14081354  {
    14091355    $filename .= '.php'; //MAYBE to do .. load .po and .mo localization files
     
    14161362
    14171363  $languages = array();
    1418   if ( !empty($language) )
    1419   {
    1420     $languages[] = $language;
     1364  if ( !empty($options['language']) )
     1365  {
     1366    $languages[] = $options['language'];
    14211367  }
    14221368  if ( !empty($user['language']) )
     
    14241370    $languages[] = $user['language'];
    14251371  }
    1426   if ( defined('PHPWG_INSTALLED') )
    1427   {
    1428     $languages[] = get_default_language();
    1429   }
    1430   $languages[] = PHPWG_DEFAULT_LANGUAGE;
     1372  if ( ! @$options['no_fallback'] )
     1373  {
     1374    if ( defined('PHPWG_INSTALLED') )
     1375    {
     1376      $languages[] = get_default_language();
     1377    }
     1378    $languages[] = PHPWG_DEFAULT_LANGUAGE;
     1379  }
     1380
    14311381  $languages = array_unique($languages);
    14321382
    1433   if ( empty($target_charset) )
     1383  if ( empty($options['target_charset']) )
    14341384  {
    14351385    $target_charset = get_pwg_charset();
     1386  }
     1387  else
     1388  {
     1389    $target_charset = $options['target_charset'];
    14361390  }
    14371391  $target_charset = strtolower($target_charset);
     
    14731427  if ( !empty($source_file) )
    14741428  {
    1475     if (!$return_content)
     1429    if (! @$options['return'] )
    14761430    {
    14771431      @include($source_file);
Note: See TracChangeset for help on using the changeset viewer.