Пример #1
0
 /**
  * Výsledný textový výstup
  *
  * @param string
  * @return string
  */
 protected function compile($input)
 {
     $locale = setlocale(LC_NUMERIC, 0);
     setlocale(LC_NUMERIC, "C");
     $tree = $this->parser->parse($input);
     $reduced = $this->analyzer->analyze($tree, $this->variables);
     $output = $this->generator->generate($reduced, $this->defaultUnit);
     setlocale(LC_NUMERIC, $locale);
     return $output;
 }
Пример #2
0
 /**
  * Vložení souboru
  *
  * @param string
  * @param string
  * @return void
  */
 protected function callInclude(array $include)
 {
     $value = $this->reduceValue($include[2]);
     if ($value[0] !== 'string') {
         throw new CompileException("Název vkládaného souboru musí být řetězec");
     }
     $file = Compiler::stringDecode($value[1]);
     $path = ($this->files->isEmpty() ? '' : dirname($this->files->top()) . DIRECTORY_SEPARATOR) . $file;
     $extension = pathinfo($file, PATHINFO_EXTENSION);
     if (!is_file($path) || !is_readable($path)) {
         throw new CompileException("Soubor '{$path}' neexistuje nebo jej nelze přečíst");
     } elseif ($extension == 'iss') {
         $this->addFile($path);
         try {
             $tree = $this->parser->parse(file_get_contents($this->getFile()));
             if ($include[3] !== NULL) {
                 $block = new Media($include[3], $include[4]);
                 $block->properties = $tree->properties;
                 $this->reduceBlock($block);
             } else {
                 $this->reduceBlock($tree);
             }
         } catch (CompileException $e) {
             throw $e->setFile($this->getFile());
         }
         $this->removeFile($path);
         return;
     } elseif ($extension == 'css') {
         $this->addFile($path);
         $context =& $this->getReducedContext();
         $context[] = file_get_contents($path);
         $this->removeFile($path);
         return;
     }
     throw new CompileException("Soubor '{$path}' nemá koncovku .css ani .iss");
 }