Changeset 879


Ignore:
Timestamp:
09/27/05 23:57:14 (15 years ago)
Author:
plg
Message:
  • bug 168 fixed: crash when language file does not exists. Constant PHPWG_DEFAULT_LANGUAGE added. New function get_language_filepath always used to find language files.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/help.php

    r862 r879  
    2828include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); 
    2929 
    30 // language files 
    31 $user_langdir = PHPWG_ROOT_PATH.'language/'.$user['language']; 
    32 $conf_langdir = PHPWG_ROOT_PATH.'language/'.$conf['default_language']; 
    33  
    34 if (file_exists($user_langdir.'/help.html')) 
    35 { 
    36   $html_file = $user_langdir.'/help.html'; 
    37 } 
    38 else 
    39 { 
    40   $html_file = $conf_langdir.'/help.html'; 
    41 } 
    42  
    43 $template->set_filenames(array('help_content' => $html_file)); 
     30$template->set_filenames( 
     31  array( 
     32    'help_content' => get_language_filepath('help.html') 
     33    ) 
     34  ); 
     35   
    4436$template->assign_var_from_handle('ADMIN_CONTENT', 'help_content'); 
    4537?> 
  • trunk/doc/ChangeLog

    r878 r879  
     12005-09-27 Pierrick LE GALL 
     2         
     3        * bug 168 fixed: crash when language file does not 
     4        exists. Constant PHPWG_DEFAULT_LANGUAGE added. New function 
     5        get_language_filepath always used to find language files. 
     6 
    172005-09-26 Pierrick LE GALL 
    28 
  • trunk/include/common.inc.php

    r862 r879  
    167167 
    168168// language files 
    169 $user_langdir = PHPWG_ROOT_PATH.'language/'.$user['language']; 
    170 $conf_langdir = PHPWG_ROOT_PATH.'language/'.$conf['default_language']; 
     169include_once(get_language_filepath('common.lang.php')); 
    171170 
    172 if (file_exists($user_langdir.'/common.lang.php')) 
    173 { 
    174   include_once($user_langdir.'/common.lang.php'); 
    175 } 
    176 else 
    177 { 
    178   include_once($conf_langdir.'/common.lang.php'); 
    179 } 
    180  
    181 // The administration section requires 2 more language files 
    182171if (defined('IN_ADMIN') and IN_ADMIN) 
    183172{ 
    184   foreach (array('admin') as $section) 
    185   { 
    186     if (file_exists($user_langdir.'/'.$section.'.lang.php')) 
    187     { 
    188       include_once($user_langdir.'/'.$section.'.lang.php'); 
    189     } 
    190     else 
    191     { 
    192       include_once($conf_langdir.'/'.$section.'.lang.php'); 
    193     } 
    194   } 
     173  include_once(get_language_filepath('admin.lang.php')); 
    195174} 
    196175 
  • trunk/include/constants.php

    r833 r879  
    3030define('PHPWG_URL', 'http://www.phpwebgallery.net'); 
    3131define('PHPWG_FORUM_URL', 'http://forum.phpwebgallery.net'); 
     32define('PHPWG_DEFAULT_LANGUAGE', 'en_UK.iso-8859-1'); 
    3233 
    3334// Error codes 
  • trunk/include/functions_user.inc.php

    r865 r879  
    498498  return $groupname; 
    499499} 
     500 
     501/** 
     502 * return the file path of the given language filename, depending on the 
     503 * availability of the file 
     504 * 
     505 * in descending order of preference: user language, default language, 
     506 * PhpWebGallery default language. 
     507 * 
     508 * @param string filename 
     509 * @return string filepath 
     510 */ 
     511function get_language_filepath($filename) 
     512{ 
     513  global $user, $conf; 
     514   
     515  $directories = 
     516    array( 
     517      PHPWG_ROOT_PATH.'language/'.$user['language'], 
     518      PHPWG_ROOT_PATH.'language/'.$conf['default_language'], 
     519      PHPWG_ROOT_PATH.'language/'.PHPWG_DEFAULT_LANGUAGE 
     520      ); 
     521 
     522  foreach ($directories as $directory) 
     523  { 
     524    $filepath = $directory.'/'.$filename; 
     525     
     526    if (file_exists($filepath)) 
     527    { 
     528      return $filepath; 
     529    } 
     530  } 
     531   
     532  return false; 
     533} 
    500534?> 
  • trunk/popuphelp.php

    r858 r879  
    3333include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); 
    3434 
    35 // language files 
    36 $user_langdir = PHPWG_ROOT_PATH.'language/'.$user['language']; 
    37 $conf_langdir = PHPWG_ROOT_PATH.'language/'.$conf['default_language']; 
    38  
    39 if (file_exists($user_langdir.'/help/'.$_GET['page'].'.html')) 
    40 { 
    41   $html_file = $user_langdir.'/help/'.$_GET['page'].'.html'; 
    42 } 
    43 else 
    44 { 
    45   $html_file = $conf_langdir.'/help/'.$_GET['page'].'.html'; 
    46 } 
    47  
    4835$page['body_id'] = 'thePopuphelpPage'; 
    4936$page['gallery_title'] = $title = l10n('PhpWebGallery Help'); 
    5037include(PHPWG_ROOT_PATH.'include/page_header.php'); 
    51 $template->set_filenames(array('help_content' => $html_file)); 
     38 
     39$template->set_filenames( 
     40  array( 
     41    'help_content' => get_language_filepath('help/'.$_GET['page'].'.html') 
     42    ) 
     43  ); 
    5244 
    5345$template->set_filenames(array('popuphelp' => 'popuphelp.tpl')); 
Note: See TracChangeset for help on using the changeset viewer.