Ejemplo n.º 1
0
 /**
  * Get parent template
  *
  * @param string $view template string
  *
  * @return array
  */
 public function checkNext($view)
 {
     $name = array();
     preg_match('/@extends.+?\\)/', $view, $name);
     if (!$name) {
         return false;
     }
     $name = Helper::clean(array('@extends', '(', ')', '"', "'"), $name[0]);
     $path = $this->ant->settings('view') . '/' . Helper::realPath($name) . '.' . $this->ant->settings('extension');
     if (false == file_exists($path)) {
         throw new Exception(sprintf('Template file not found at %s', $path));
     }
     $io = IO::init()->in($path);
     $nextview = $io->get();
     $io->out();
     return array('path' => $path, 'view' => $nextview);
 }
Ejemplo n.º 2
0
 public static function checkNext($view)
 {
     $name = array();
     preg_match('/@extends.+?\\)/', $view, $name);
     if (!$name) {
         return false;
     }
     $name = trim(str_replace(array('@extends', '(', ')', '"', '\''), '', $name[0]));
     $path = Ant::settings('view') . DIRECTORY_SEPARATOR . Helper::realPath($name) . '.' . Ant::settings('extension');
     if (false == file_exists($path)) {
         throw new Exception(sprintf('Template file not found at %s', $path));
     }
     $io = IO::init()->in($path);
     $nextview = $io->get();
     $io->out();
     return array('path' => $path, 'view' => $nextview);
 }
Ejemplo n.º 3
0
 /**
  * Save cache file
  *
  * @return void
  */
 public function __destruct()
 {
     if (true == $this->isChanged) {
         IO::init()->in($this->cacheFile)->set(json_encode(self::$map, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT))->out();
     }
 }
Ejemplo n.º 4
0
 public function draw()
 {
     switch ($this->mode) {
         case self::MODE_STRING:
             ob_start();
             extract($this->assign);
             if ($this->logic_path and file_exists($this->logic_path)) {
                 require $this->logic_path;
             }
             eval(' ?>' . $this->fire('build', Parser::parse($this->fire('prepare', $this->string))) . '<?php ');
             $echo = ob_get_contents();
             ob_end_clean();
             return $this->fire('exec', $echo);
         case self::MODE_FILE:
             if (false === self::$settings['freeze']) {
                 if (true === self::$settings['debug'] or false == self::$cache_obj->check($this->tmpl_path)) {
                     $io = IO::init()->in($this->tmpl_path);
                     $s = $this->fire('build', Parser::parse($this->fire('prepare', $io->get()), $this->tmpl_path));
                     $io->out()->in($this->cache_path)->set($s)->out();
                 }
             }
             unset($io, $s);
             ob_start();
             extract($this->assign);
             if (file_exists($this->logic_path)) {
                 require $this->logic_path;
             }
             require $this->cache_path;
             $echo = ob_get_contents();
             ob_end_clean();
             return $this->fire('exec', $echo);
     }
 }
Ejemplo n.º 5
0
 /**
  * Необходимая инициализация и проверки(TODO)
  */
 public function Init()
 {
     // TODO првоерка параметров php и переменных среды
     //output_buffering=0 \
     // basedir&
     // safe_mode
     //  register_argc_argv="On" \
     // auto_prepend_file="" \
     // auto_append_file="" \
     // error_reporting(0);
     IO::init(ArgsHolder::get());
 }
Ejemplo n.º 6
0
 /**
  * Render template
  *
  * @return string
  */
 public function draw()
 {
     switch ($this->mode) {
         case self::MODE_STRING:
             ob_start();
             extract($this->assign);
             if ($this->logicPath and file_exists($this->logicPath)) {
                 require $this->logicPath;
             }
             set_error_handler(function ($errno, $errstr, $errfile, $errline) {
                 if (!(error_reporting() & $errno)) {
                     return;
                 }
                 throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
             });
             eval(' ?>' . $this->ant->event->fire('build', $this->parser->parse($this->ant->event->fire('prepare', $this->string))) . '<?php ');
             $echo = ob_get_contents();
             ob_end_clean();
             restore_error_handler();
             return $this->ant->event->fire('exec', $echo);
         case self::MODE_FILE:
             if (!$this->logicPath) {
                 $logicRoot = $this->ant->settings('logic');
                 if ($logicRoot) {
                     $tryLogic = $logicRoot . '/' . pathinfo($this->tmplPath, PATHINFO_FILENAME) . '.php';
                     if (file_exists($tryLogic)) {
                         $this->logicPath = $tryLogic;
                     }
                 }
             }
             if (false === $this->ant->settings('freeze')) {
                 if (true === $this->ant->settings('debug') or false == $this->ant->cache->check($this->tmplPath)) {
                     $io = IO::init()->in($this->tmplPath);
                     $s = $this->ant->event->fire('build', $this->parser->parse($this->ant->event->fire('prepare', $io->get()), $this->tmplPath));
                     $io->out()->in($this->cachePath)->set($s)->out();
                 }
             }
             unset($io, $s);
             ob_start();
             extract($this->assign);
             if ($this->logicPath and file_exists($this->logicPath)) {
                 require $this->logicPath;
             }
             require $this->cachePath;
             $echo = ob_get_contents();
             ob_end_clean();
             return $this->ant->event->fire('exec', $echo);
     }
 }