Exemplo n.º 1
0
 /**
  * Parse a json containing the lookup table.
  *
  * @return void
  */
 private function _fromJSON()
 {
     $uri = $this->_config->get('paths/lookup');
     try {
         $fileContent = $this->_vfs->file_get_contents($uri);
         $temp = json_decode($fileContent, true);
         self::$lookup = $temp['lookupTable'];
     } catch (Exception $e) {
         throw new KiTT_Exception($e->getMessage(), $e->getCode());
     }
 }
 /**
  * Load the given template.
  * If found in the cache it will load that template.
  * If not the following search priority is used:
  *      1: $config['paths']['extra_templates']/#countrycode#/
  *      2: $config['paths']['extra_templates']/
  *      3: $config['paths']['kitt']/html/#countrycode#/
  *      4: $config['paths']['kitt']/html/
  * First matching will be loaded.
  *
  * @param string $name template name to load
  *
  * @throws KiTT_TemplateException if template is not found.
  * @return KiTT_Template
  */
 public function load($name)
 {
     if (array_key_exists($name, $this->_cache)) {
         return $this->_cache[$name];
     }
     $paths = $this->_templatePaths($name);
     foreach ($paths as $path) {
         if ($this->_vfs->file_exists($path)) {
             $data = $this->_vfs->file_get_contents($path);
             $this->_cache[$name] = new KiTT_Template($this, $path, $data);
             return $this->_cache[$name];
         }
     }
     throw new KiTT_TemplateException("Template not found: {$name}");
 }
 /**
  * Create language pack
  *
  * @param KiTT_Config $config configuration
  * @param KiTT_VFS    $vfs    vfs object
  */
 public function __construct(KiTT_Config $config, KiTT_VFS $vfs)
 {
     $this->_config = $config;
     $path = $this->_config->get('paths/lang');
     $this->_xml = simplexml_load_string(utf8_encode($vfs->file_get_contents($path)));
 }