Source for file Locale.php

Documentation is available at Locale.php

  1. <?php
  2. /**
  3. * Return text based on language and domain name
  4. *
  5. * PHP versions 5
  6. @category  PHP
  7. @package   GeoPrisma
  8. @author    Pascal Martin
  9. @copyright 2009, Boreal - Information Strategies
  10. @license   http://www.geoprisma.org/license BSD License
  11. @link      http://www.geoprisma.org
  12. */
  13.  
  14. /**
  15. * Return text based on language and domain name
  16. *  
  17. @category   PHP
  18. @package    GeoPrisma
  19. @subpackage UI
  20. @author     Pascal Martin
  21. */      
  22.   
  23. abstract class org_geoprisma_locale_Locale implements com_borealis_foundation_util_Singleton
  24. {
  25.     private $m_strLanguage 'en_US';
  26.     
  27.     /**
  28.     * Return the current use langage for traduction (e.g. en_US , fr_CA)
  29.     * 
  30.     * @return string 
  31.     */
  32.     public function getLanguage()
  33.     {
  34.         return $this->m_strLanguage;   
  35.     }
  36.  
  37.     /**
  38.     * Set the current use langage for traduction (e.g. en_US , fr_CA)
  39.     * 
  40.     * @param string $pstrLanguage Language
  41.     * 
  42.     * @return void 
  43.     */
  44.     public function setLanguage($pstrLanguage)
  45.     {
  46.         $this->m_strLanguage $pstrLanguage
  47.     }
  48.     
  49.     /**
  50.     * Retourne le language par défaut
  51.     * 
  52.     * @return string 
  53.     */
  54.     public function getDefaultLanguage()
  55.     {
  56.         if (!session_id()) 
  57.         {
  58.             session_start();
  59.         }
  60.         $strRequest org_geoprisma_SettingImpl::getLocaleLanguageRequest();
  61.         if (isset($_REQUEST&& isset($_REQUEST[$strRequest])) 
  62.         {
  63.             $_SESSION[$strRequest$_REQUEST[$strRequest];            
  64.             return $_REQUEST[$strRequest]
  65.         }
  66.         else if (isset($_SESSION&& isset($_SESSION[$strRequest])) 
  67.         {
  68.             return $_SESSION[$strRequest]
  69.         }   
  70.         else
  71.         {
  72.             return org_geoprisma_SettingImpl::getLocaleLanguageDefault();
  73.         }           
  74.     }
  75.     
  76.     /**
  77.     * Return text based on domainName for right language
  78.     * 
  79.     * @param string $pstrMsg        Message Key
  80.     * @param string $pstrDomainName Name of the
  81.     *
  82.     * @return string 
  83.     */  
  84.     abstract public function getTranslation($pstrMsg$pstrDomainName);
  85.     
  86.     /**
  87.     * Return text based on domainName for right language
  88.     * 
  89.     * @param string $pstrMsg        Message Key
  90.     * @param string $pstrDomainName Name of the
  91.     * @param string $pstrType       Type encoding "JS" "HTML"
  92.     *
  93.     * @return string 
  94.     */  
  95.     static public function getText($pstrMsg$pstrDomainName$pstrType null
  96.     {
  97.         $strResult org_geoprisma_locale_LocaleFactory::getLocale()->getTranslation($pstrMsg$pstrDomainName);
  98.         
  99.         switch (strtolower($pstrType)) 
  100.         {
  101.             case 'js':
  102.                 $strResult self::jsEncode($strResult);
  103.                 break;
  104.             case 'html':
  105.                 $strResult self::htmlEncode($strResult);
  106.                 break;   
  107.         }
  108.         
  109.         return $strResult;    
  110.     }
  111.     
  112.     /**
  113.     * Encode la string recu pour être imprimer dans du code Javascritp
  114.     * 
  115.     * @param string $pstrText Chaine de texte
  116.     * 
  117.     * @return string 
  118.     */
  119.     static public function jsEncode($pstrText)
  120.     {
  121.         return json_encode($pstrText);     
  122.     }
  123.     
  124.     /**
  125.     * Encode la string recu pour être imprimer dans du code Html
  126.     * 
  127.     * @param string $pstrText Chaine de texte
  128.     * 
  129.     * @return string 
  130.     */
  131.     static private function htmlEncode($pstrText)
  132.     {
  133.         return htmlspecialchars($pstrTextENT_QUOTES);     
  134.     }
  135. }
  136. ?>

Documentation generated on Mon, 20 Feb 2012 13:46:23 -0500 by phpDocumentor 1.4.1