language Class Reference

load langue More...

List of all members.

Public Member Functions

Static Public Member Functions

Public Attributes

Static Public Attributes

Static Private Member Functions

  • static check_langue ($directory, $public)
    Verifié si le repertoire est présent.

Static Private Attributes


Detailed Description

load langue

Definition at line 14 of file language.php.


Constructor & Destructor Documentation

language::__construct ( lng = ''  ) 

construct

Definition at line 32 of file language.php.

00032                                   {
00033     $this->languages = array('ar' => 'ar([-_][[:alpha:]]{2})?|arabic',
00034                               'bg' => 'bg|bulgarian',
00035                               'br' => 'pt[-_]br|brazilian portuguese',
00036                               'ca' => 'ca|catalan',
00037                               'cs' => 'cs|czech',
00038                               'da' => 'da|danish',
00039                               'de' => 'de([-_][[:alpha:]]{2})?|german',
00040                               'el' => 'el|greek',
00041                               'en' => 'en([-_][[:alpha:]]{2})?|english',
00042                               'es' => 'es([-_][[:alpha:]]{2})?|spanish',
00043                               'et' => 'et|estonian',
00044                               'fi' => 'fi|finnish',
00045                               'fr' => 'fr([-_][[:alpha:]]{2})?|french',
00046                               'gl' => 'gl|galician',
00047                               'he' => 'he|hebrew',
00048                               'hu' => 'hu|hungarian',
00049                               'id' => 'id|indonesian',
00050                               'it' => 'it|italian',
00051                               'ja' => 'ja|japanese',
00052                               'ko' => 'ko|korean',
00053                               'ka' => 'ka|georgian',
00054                               'lt' => 'lt|lithuanian',
00055                               'lv' => 'lv|latvian',
00056                               'nl' => 'nl([-_][[:alpha:]]{2})?|dutch',
00057                               'no' => 'no|norwegian',
00058                               'pl' => 'pl|polish',
00059                               'pt' => 'pt([-_][[:alpha:]]{2})?|portuguese',
00060                               'ro' => 'ro|romanian',
00061                               'ru' => 'ru|russian',
00062                               'sk' => 'sk|slovak',
00063                               'sr' => 'sr|serbian',
00064                               'sv' => 'sv|swedish',
00065                               'th' => 'th|thai',
00066                               'tr' => 'tr|turkish',
00067                               'uk' => 'uk|ukrainian',
00068                               'tw' => 'zh[-_]tw|chinese traditional',
00069                               'zh' => 'zh|chinese simplified');
00070 
00071     $this->catalog_languages = self::get_languages(true);
00072     $this->browser_languages = '';
00073     $this->language = '';
00074 
00075     $this->set_language($lng);
00076   }


Member Function Documentation

language::ArrayPullDown ( byindex = false,
public = true 
) [static]

gestiné au pulldown

Parameters:
$byindex 
$public 

Definition at line 123 of file language.php.

00123                                                                     {
00124     global $language;
00125     $languages=self::get_languages($byindex,$public);
00126     $languages_array=array();
00127     for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00128         $languages_array[] = array('id' => $languages[$i]['code'], 'text' => $languages[$i]['name']);
00129         if ($languages[$i]['code'] == $language ) self::$languages_selected = $languages[$i]['code'];
00130     }
00131 
00132     return $languages_array;
00133   }

language::check_langue ( directory,
public 
) [static, private]

Verifié si le repertoire est présent.

Parameters:
$directory string path
$public boolean false =admin
Returns:
boolean

Definition at line 173 of file language.php.

00173                                                           {
00174     $base=(!$public)? DIR_FS_ADMIN : DIR_FS_CATALOG ;
00175     if(is_dir($base.DIR_WS_LANGUAGES.$directory)) return true;
00176     return false;
00177   }

language::get_browser_language (  ) 

Recuperation de la langue do broswer.

Definition at line 95 of file language.php.

00095                                          {
00096     $this->browser_languages = explode(',', getenv('HTTP_ACCEPT_LANGUAGE'));
00097 
00098     for ($i=0, $n=sizeof($this->browser_languages); $i<$n; $i++) {
00099       reset($this->languages);
00100       while (list($key, $value) = each($this->languages)) {
00101         if (preg_match('/^(' . $value . ')(;q=[0-9]\\.[0-9])?$/i', $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) {
00102           $this->set_language($key);
00103           break 2;
00104         }
00105       }
00106     }
00107   }

language::get_languages ( byindex = false,
public = true 
) [static]
Parameters:
$byindex bool precise l'Id dans la clef de colonne
$public bool precise check public / prive

Definition at line 140 of file language.php.

Referenced by __construct(), and ArrayPullDown().

00140                                                                      {
00141     $CORE=(!$public)? 'BO' : 'FO';
00142     $ind=(($byindex)?'index':'noindex');
00143     if(!isset(self::$languages_array[$CORE][$ind]) || count(self::$languages_array[$CORE][$ind])==0) {
00144       $DB=Database::getInstance();
00145       $i=0;
00146       $lg_array=array();
00147       $languages_query = $DB->query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
00148       while ($languages = $languages_query->fetchAssoc() ) {
00149         if(self::check_langue($languages['directory'],$public) )
00150           $lg_array[(($byindex)?$languages['code']:$i++)] = array('id' => $languages['languages_id'],
00151                                                                 'name' => $languages['name'],
00152                                                                 'code' => $languages['code'],
00153                                                                 'image' => $languages['image'],
00154                                                                 'directory' => $languages['directory'],
00155                                                                 'directory_code2'=>$languages['code'].'_'.strtoupper($languages['code'])
00156                                                                   );
00157       }
00158       self::$languages_array[$CORE][$ind]=$lg_array;
00159     }
00160     else
00161       $lg_array = self::$languages_array[$CORE][$ind];
00162 
00163     return $lg_array;
00164   }

language::LangueSelected (  )  [static]
Returns:
langue code

Definition at line 113 of file language.php.

00113                                          {
00114     return (isset($_SESSION['language_iso'])? $_SESSION['language_iso'] : self::$languages_selected);
00115   }

language::set_language ( lng  ) 

defini la lanque choisie

Parameters:
$lng string code iso 2

Definition at line 83 of file language.php.

Referenced by __construct(), and get_browser_language().

00083                                      {
00084     if ( (tep_not_null($lng)) && (isset($this->catalog_languages[$lng])) ) $language = $lng;
00085     else $language = DEFAULT_LANGUAGE;
00086 
00087     $this->language = $this->catalog_languages[$language];
00088     self::$languages_selected = $this->language['code'];
00089   }


Member Data Documentation

language::$browser_languages

Definition at line 17 of file language.php.

language::$catalog_languages

Definition at line 16 of file language.php.

language::$language

Definition at line 18 of file language.php.

Referenced by ArrayPullDown(), and set_language().

language::$languages

Definition at line 15 of file language.php.

Referenced by ArrayPullDown(), and get_languages().

language::$languages_array = array() [static, private]

Definition at line 27 of file language.php.

Referenced by ArrayPullDown().

language::$languages_selected [static]

Definition at line 23 of file language.php.


The documentation for this class was generated from the following file: