Exemple #1
0
 public function find($templateName, $currentSkin = null)
 {
     assert('\\de\\toxa\\txf\\txf::current()');
     $folders = array(TXF_APPLICATION_PATH . '/skins/', dirname(dirname(__FILE__)) . '/skins/' . TXF_APPLICATION, dirname(dirname(__FILE__)) . '/skins/default');
     $skins = array('default');
     if ($currentSkin !== null) {
         $currentSkin = data::isKeyword($currentSkin);
     }
     if ($currentSkin) {
         if ($currentSkin != 'default') {
             array_unshift($skins, $currentSkin);
         }
     }
     foreach ($folders as $folder) {
         foreach ($skins as $skin) {
             $pathname = path::glue($folder, $skin, $templateName . '.phpt');
             if (is_file($pathname)) {
                 return $pathname;
             }
         }
     }
     throw new \UnexpectedValueException(sprintf('template not found: %s (%s)', $templateName, $currentSkin));
 }
Exemple #2
0
 public function onLoad()
 {
     // select language to use (this must be listed in server's locale -a)
     $this->language = config::get('locale.language', 'en_US.utf8');
     $this->domain = config::get('locale.domain', TXF_APPLICATION);
     putenv('LANGUAGE=' . $this->language);
     putenv('LANG=' . $this->language);
     putenv('LC_ALL=' . $this->language);
     if (!setlocale(LC_ALL, $this->language)) {
         log::error('could not select locale %s', $this->language);
     }
     if (\extension_loaded('gettext')) {
         // bind configured domain to configured path containing l10n files
         $path = config::get('locale.path', path::glue(TXF_APPLICATION_PATH, 'locale'));
         bindtextdomain($this->domain, $path);
         textdomain($this->domain);
         bind_textdomain_codeset($this->domain, 'UTF-8');
         if ($this->domain !== 'txf') {
             // bind domain "txf" to l10n path included with current extension
             $path = path::glue(dirname(__DIR__), 'locale');
             bindtextdomain('txf', $path);
             bind_textdomain_codeset('txf', 'UTF-8');
         }
     }
     self::$collectionMode = config::get('locale.collect.mode', '');
     self::$collectionFile = config::get('locale.collect.file');
 }