linea21-utils
[ class tree: linea21-utils ] [ index: linea21-utils ] [ all elements ]

Source for file lang.php

Documentation is available at lang.php

  1. <?php
  2. /**
  3.  * @package linea21.utils
  4.  * @subpackage lib
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. /**
  12.  * IncludeLang()
  13.  * Fait les includes de fichiers de langue en fonction de la rubrique active ( partie publique )
  14.  *
  15.  * @return void (include)
  16.  */
  17. function IncludeLang()
  18. {
  19.     global $lang;
  20.     
  21.   $language U_L;
  22.   include_once('../languages/' $language '/lang_common.' CHARSET '.php');
  23.   
  24.   if(MOD_COMMENT == 1)
  25.     include_once('../languages/' $language '/lang_comment.' CHARSET '.php');
  26.  
  27.   if (ActiveItemAlias($GLOBALS['activeitem']== 'directory'{
  28.     include_once('../languages/' $language '/lang_yellowpages.' CHARSET '.php');
  29.   }
  30.   if (ActiveItemAlias($GLOBALS['activeitem']== 'dashboard'{
  31.     include_once('../languages/' $language '/lang_sdi.' CHARSET '.php');
  32.     include_once('../languages/' $language '/lang_dashboard.' CHARSET '.php');
  33.   }
  34.   if (ActiveItemAlias($GLOBALS['activeitem']== 'workgroup'{
  35.     include_once('../languages/' $language '/lang_workshop.' CHARSET '.php');
  36.     include_once('../languages/' $language '/lang_workshoprep.' CHARSET '.php');
  37.     include_once('../languages/' $language '/lang_publication.' CHARSET '.php');
  38.     include_once('../languages/' $language '/lang_system.' CHARSET '.php');
  39.   }
  40.   if (ActiveItemAlias($GLOBALS['activeitem']== 'project'{
  41.     include_once('../languages/' $language '/lang_project.' CHARSET '.php');
  42.     include_once('../languages/' $language '/lang_dashboard.' CHARSET '.php');
  43.     include_once('../languages/' $language '/lang_sdi.' CHARSET '.php');
  44.   }
  45.   if (ActiveItemAlias($GLOBALS['activeitem']== 'publication'{
  46.     include_once('../languages/' $language '/lang_publication.' CHARSET '.php');
  47.   }
  48.   if (ActiveItemAlias($GLOBALS['activeitem']== 'user-prefs'{
  49.     include_once('../languages/' $language '/lang_user.' CHARSET '.php');
  50.   }
  51.   if (ActiveItemAlias($GLOBALS['activeitem']== 'news'{
  52.     include_once('../languages/' $language '/lang_news.' CHARSET '.php');
  53.   }
  54.   if (ActiveItemAlias($GLOBALS['activeitem']== 'page'{
  55.       include_once('../languages/' $language '/lang_page.' CHARSET '.php');
  56.   }
  57.   if (ActiveItemAlias($GLOBALS['activeitem']== 'subscribe-newsletter'{
  58.     include_once('../languages/' $language '/lang_newsletter.' CHARSET '.php');
  59.   }
  60.   if (ActiveItemAlias($GLOBALS['activeitem']== 'search'{
  61.     include_once('../languages/' $language '/lang_search.' CHARSET '.php');
  62.   }
  63.   if (ActiveItemAlias($GLOBALS['activeitem']== 'workgroup-subscription'{
  64.     include_once('../languages/' $language '/lang_workshop.' CHARSET '.php');
  65.     include_once('../languages/' $language '/lang_user.' CHARSET '.php');
  66.   }
  67.  
  68. }
  69.  
  70. /**
  71.  * IncludeAdminLang()
  72.  * Fait les includes de fichiers de langue en fonction de la rubrique active ( partie admin )
  73.  *
  74.  * @return void (include)
  75.  */
  76. function IncludeAdminLang($rubrique)
  77. {
  78.     global $lang;
  79.     
  80.   $language U_L;
  81.   include_once('../languages/' $language '/lang_common.' CHARSET '.php');
  82.   include_once('../languages/' $language '/lang_' $rubrique '.' CHARSET '.php');
  83.  
  84.   if ($rubrique === 'dashboard'{
  85.     include_once('../languages/' $language '/lang_sdi.' CHARSET '.php');
  86.   }
  87.   if ($rubrique === 'sdi'{
  88.     include_once('../languages/' $language '/lang_dashboard.' CHARSET '.php');
  89.   }
  90.   if($rubrique === 'project')  {
  91.       include_once('../languages/' $language '/lang_dashboard.' CHARSET '.php');
  92.       include_once('../languages/' $language '/lang_sdi.' CHARSET '.php');
  93.   }
  94.   if($rubrique === 'home' && MOD_COMMENT == 1{
  95.     include_once('../languages/' $language '/lang_comment.' CHARSET '.php');
  96.   }
  97.  
  98.  
  99. }
  100.  
  101. /**
  102.  * _t()
  103.  * Translate item
  104.  * @param string $scope 
  105.  * @param string $item 
  106.  * @return string 
  107.  ***/
  108. function _t($scope$item)
  109. {
  110.   if(isset($GLOBALS['lang'][$scope][$item])) {
  111.     return $GLOBALS['lang'][$scope][$item];
  112.   }
  113.   else {
  114.     if(MOD_DEBUG == 1{
  115.       return '<span class="debug_alert">_t(\''.$scope."', '".$item.'\') does not exist</span>';
  116.     else {
  117.       return $scope." ".$item;
  118.     }
  119.   }
  120. }
  121.  
  122. /**
  123.  * _def()
  124.  * Define a user language variable
  125.  * override previous value if already defined
  126.  * @param string $scope 
  127.  * @param string $item 
  128.  * @param string $str 
  129.  * @return string 
  130.  ***/
  131. function _def($scope$item$str)
  132. {
  133.   if(isset($GLOBALS['lang'][$scope][$item])) unset($GLOBALS['lang'][$scope][$item]);
  134.  
  135.   $GLOBALS['lang'][$scope][$item$str;
  136. }
  137.  
  138. /**
  139.  * IncludeUserfiles()
  140.  * Include user files prefixed by '_' from languages folders
  141.  *
  142.  * @return void (include)
  143.  */
  144. function IncludeUserfiles({
  145.   $language U_L;
  146.   $paths glob('../languages/' $language '/_*.php');
  147.   if(CURRENT_APP == 'admin'{
  148.     $pattern THEME_ADMIN_PATH.'override/languages/' $language '/_*.php';
  149.   else {
  150.     $pattern THEME_PUBLIC_PATH.'override/languages/' $language '/_*.php';
  151.   }
  152.   $pattern2 OVERRIDE_FOLDER.'languages/' $language '/_*.php';
  153.   
  154.   $paths array_merge($pathsglob($pattern)glob($pattern2));
  155.   if($paths != false{
  156.     foreach ($paths as $filename{
  157.       _debug('Including user defined language files : '$filename);
  158.       include_once($filename);
  159.     }
  160.   }
  161. }
  162.  
  163. /**
  164.  * IncludeLanguagesPluginfiles()
  165.  * Include plugin files from specific plugin languages folders
  166.  * @param object $plugin 
  167.  * @return void (include)
  168.  */
  169. function IncludeLanguagesPluginfiles($plugin{
  170.  
  171.   // we try to include the current culture
  172.   $paths glob('../plugins/'.$plugin->getVar('name').'/languages/' U_L '/*.php');
  173.   // if current culture not found, we include default language files
  174.   if(count($paths)==0$paths glob('../plugins/'.$plugin->getVar('name').'/languages/' $plugin->getVar('default_language''/*.php');
  175.  
  176.   if($paths != false{
  177.     foreach ($paths as $filename{
  178.       _debug('Including <em>'.$plugin.'</em> plugin language files : '$filename);
  179.       include_once($filename);
  180.     }
  181.   }
  182.  
  183.   return true;
  184. }
  185. ?>

Documentation generated on Thu, 20 Mar 2014 16:48:11 +0100 by phpDocumentor 1.4.1