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

Documentation generated on Thu, 03 May 2012 15:05:20 +0200 by phpDocumentor 1.4.1