Changeset 2479 for trunk/include


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)
Location:
trunk/include
Files:
4 edited

Legend:

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

    r2476 r2479  
    178178}
    179179trigger_action('loading_lang');
    180 load_language('local.lang');
     180load_language('local.lang', '', array('no_fallback'=>true) );
    181181
    182182// only now we can set the localized username of the guest user (and not in
  • 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);
  • trunk/include/functions_mail.inc.php

    r2339 r2479  
    247247
    248248      // language files
    249       load_language('common.lang', '', $language);
     249      load_language('common.lang', '', array('language'=>$language) );
    250250      // No test admin because script is checked admin (user selected no)
    251251      // Translations are in admin file too
    252       load_language('admin.lang', '', $language);
     252      load_language('admin.lang', '', array('language'=>$language) );
    253253      trigger_action('loading_lang');
    254       load_language('local.lang', '', $language);
     254      load_language('local.lang', '', array('language'=>$language, 'no_fallback'=>true));
    255255
    256256      $switch_lang[$language]['lang_info'] = $lang_info;
  • trunk/include/functions_picture.inc.php

    r2299 r2479  
    328328}
    329329
     330// The get_picture_size function return an array containing :
     331//      - $picture_size[0] : final width
     332//      - $picture_size[1] : final height
     333// The final dimensions are calculated thanks to the original dimensions and
     334// the maximum dimensions given in parameters.  get_picture_size respects
     335// the width/height ratio
     336function get_picture_size( $original_width, $original_height,
     337                           $max_width, $max_height )
     338{
     339  $width = $original_width;
     340  $height = $original_height;
     341  $is_original_size = true;
     342
     343  if ( $max_width != "" )
     344  {
     345    if ( $original_width > $max_width )
     346    {
     347      $width = $max_width;
     348      $height = floor( ( $width * $original_height ) / $original_width );
     349    }
     350  }
     351  if ( $max_height != "" )
     352  {
     353    if ( $original_height > $max_height )
     354    {
     355      $height = $max_height;
     356      $width = floor( ( $height * $original_width ) / $original_height );
     357      $is_original_size = false;
     358    }
     359  }
     360  if ( is_numeric( $max_width ) and is_numeric( $max_height )
     361       and $max_width != 0 and $max_height != 0 )
     362  {
     363    $ratioWidth = $original_width / $max_width;
     364    $ratioHeight = $original_height / $max_height;
     365    if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) )
     366    {
     367      if ( $ratioWidth < $ratioHeight )
     368      {
     369        $width = floor( $original_width / $ratioHeight );
     370        $height = $max_height;
     371      }
     372      else
     373      {
     374        $width = $max_width;
     375        $height = floor( $original_height / $ratioWidth );
     376      }
     377      $is_original_size = false;
     378    }
     379  }
     380  $picture_size = array();
     381  $picture_size[0] = $width;
     382  $picture_size[1] = $height;
     383  return $picture_size;
     384}
     385
    330386?>
Note: See TracChangeset for help on using the changeset viewer.