Changeset 2126 for trunk/include


Ignore:
Timestamp:
Oct 9, 2007, 1:46:09 AM (17 years ago)
Author:
rvelices
Message:
  • some code refactoring before upgrade to utf (only cosmetic at this point...)
Location:
trunk/include
Files:
6 edited

Legend:

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

    r2117 r2126  
    156156
    157157// language files
    158 include_once(get_language_filepath('common.lang.php'));
     158load_language('common.lang');
    159159if (defined('IN_ADMIN') and IN_ADMIN)
    160160{
    161   include_once(get_language_filepath('admin.lang.php'));
     161  load_language('admin.lang');
    162162}
    163163trigger_action('loading_lang');
    164 @include_once(get_language_filepath('local.lang.php'));
     164load_language('local.lang');
    165165
    166166// only now we can set the localized username of the guest user (and not in
  • trunk/include/functions.inc.php

    r2123 r2126  
    730730  {
    731731    $user = build_user( $conf['guest_id'], true);
    732     include_once(get_language_filepath('common.lang.php'));
     732    load_language('common.lang');
    733733    trigger_action('loading_lang');
    734     @include_once(get_language_filepath('local.lang.php'));
     734    load_language('local.lang');
    735735    list($tmpl, $thm) = explode('/', get_default_template());
    736736    $template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm);
     
    14251425}
    14261426
     1427/**
     1428 * returns the character set of data sent to browsers / received from forms
     1429 */
     1430function get_pwg_charset()
     1431{
     1432  //TEMP CODE
     1433  global $lang_info;return $lang_info['charset'];
     1434}
     1435
     1436/**
     1437 * includes a language file or returns the content of a language file
     1438 * availability of the file
     1439 *
     1440 * in descending order of preference:
     1441 *   param language, user language, default language
     1442 * PhpWebGallery default language.
     1443 *
     1444 * @param string filename
     1445 * @param string dirname
     1446 * @param string language
     1447 * @param bool return_content - if true the file content is returned otherwise
     1448 *  the file is evaluated as php
     1449 * @return boolean success status or a string if return_content is true
     1450 */
     1451function load_language($filename, $dirname = '', $language = '',
     1452    $return_content=false)
     1453{
     1454  //TEMP CODE
     1455  if (!$return_content) $filename.='.php';
     1456  $f = get_language_filepath($filename, $dirname, $language);
     1457  if ($f === false)
     1458    return false;
     1459  if ($return_content)
     1460    return @file_get_contents($f);
     1461  global $lang, $lang_info;
     1462  @include($f);
     1463  return true;
     1464}
     1465
    14271466?>
  • trunk/include/functions_mail.inc.php

    r2122 r2126  
    4949
    5050  global $lang_info;
    51   return '=?'.$lang_info['charset'].'?Q?'.$str.'?=';
     51  return '=?'.get_pwg_charset().'?Q?'.$str.'?=';
    5252}
    5353
     
    227227
    228228      // language files
    229       include(get_language_filepath('common.lang.php', '', $language));
     229      load_language('common.lang', '', $language);
    230230      // No test admin because script is checked admin (user selected no)
    231231      // Translations are in admin file too
    232       include(get_language_filepath('admin.lang.php', '', $language));
     232      load_language('admin.lang', '', $language);
    233233      trigger_action('loading_lang');
    234       @include(get_language_filepath('local.lang.php', '', $language));
     234      load_language('local.lang', '', $language);
    235235
    236236      $switch_lang[$language]['lang_info'] = $lang_info;
     
    589589  $content = '';
    590590
    591   if (!isset($conf_mail[$args['email_format']][$lang_info['charset']][$args['template']][$args['theme']]))
     591  if (!isset($conf_mail[$args['email_format']][get_pwg_charset()][$args['template']][$args['theme']]))
    592592  {
    593593    if (!isset($mail_template))
     
    604604        'BOUNDARY_KEY' => $conf_mail['boundary_key'],
    605605        'CONTENT_TYPE' => $args['email_format'],
    606         'CONTENT_ENCODING' => $lang_info['charset'],
     606        'CONTENT_ENCODING' => get_pwg_charset(),
    607607        'LANG' => $lang_info['code'],
    608608        'DIR' => $lang_info['direction'],
     
    651651    // what are displayed on the header of each mail ?
    652652    $conf_mail[$args['email_format']]
    653       [$lang_info['charset']]
     653      [get_pwg_charset()]
    654654      [$args['template']][$args['theme']]['header'] =
    655655        $mail_template->parse('mail_header', true);
     
    657657    // what are displayed on the footer of each mail ?
    658658    $conf_mail[$args['email_format']]
    659       [$lang_info['charset']]
     659      [get_pwg_charset()]
    660660      [$args['template']][$args['theme']]['footer'] =
    661661        $mail_template->parse('mail_footer', true);
     
    664664  // Header
    665665  $content.= $conf_mail[$args['email_format']]
    666               [$lang_info['charset']]
     666              [get_pwg_charset()]
    667667              [$args['template']][$args['theme']]['header'];
    668668
     
    684684  // Footer
    685685  $content.= $conf_mail[$args['email_format']]
    686               [$lang_info['charset']]
     686              [get_pwg_charset()]
    687687              [$args['template']][$args['theme']]['footer'];
    688688
  • trunk/include/page_header.php

    r1900 r2126  
    4747        $page['body_id'] : '',
    4848
    49     'CONTENT_ENCODING' => $lang_info['charset'],
     49    'CONTENT_ENCODING' => get_pwg_charset(),
    5050    'PAGE_TITLE' => strip_tags($title),
    5151    'LANG'=>$lang_info['code'],
     
    100100trigger_action('loc_end_page_header');
    101101
    102 header('Content-Type: text/html; charset='.$lang_info['charset']);
     102header('Content-Type: text/html; charset='.get_pwg_charset());
    103103$template->parse('header');
    104104
  • trunk/include/ws_functions.inc.php

    r2119 r2126  
    911911    $res[$k] = $user[$k];
    912912  }
    913   foreach ( array('charset') as $k )
    914   {
    915     $res[$k] = $lang_info[$k];
    916   }
     913  $res['charset'] = get_pwg_charset();
    917914  return $res;
    918915}
  • trunk/include/ws_protocols/rest_encoder.php

    r1900 r2126  
    169169    $this->encode($response);
    170170    $ret = $this->_writer->getOutput();
    171     $ret = '<?xml version="1.0" encoding="'.$lang_info['charset'].'" ?>
     171    $ret = '<?xml version="1.0" encoding="'.get_pwg_charset().'" ?>
    172172<rsp stat="ok">
    173173'.$ret.'
Note: See TracChangeset for help on using the changeset viewer.