Example #1
0
 public static function run()
 {
     // USE LOCALTOR INSTEAD!
     // USE STRUCTURE FROM index.php
     $locale = self::getLang();
     $arg = array();
     $crumps = explode($this->routeSeparator, $_REQUEST['page']);
     // Check the cache first
     if ($this->cacheDir) {
         $cacheFile = $this->cacheDir . $page . '-' . $locale[0] . '-' . $locale[1] . '.htm';
         if (\Xily\Config::get('opt.cache') == 1 && file_exists($cacheFile)) {
             return file_get_contents($cacheFile);
         }
     }
     // Check, if there is a controller for the view
     if (file_exists($this->controllerDir . $view . '.php')) {
         include_once 'controllers/' . $view . '.php';
     }
     $controllerClass = $view . 'Controller';
     if (class_exists($controllerClass)) {
         $controller = new $controllerClass();
         $xlyPage = $controller->getView();
     } else {
         $file = 'views/' . $view . '.xml';
         if (!file_exists($file)) {
             $file = 'views/404.xml';
         }
         $xlyPage = \Xily\Bean::create($file, 1);
     }
     $doc = $xmlDoc->attribute('doc');
     $cache = \Xily\Config::get('opt.cache') == 1 ? true : !$xmlDoc->isFalse('cache');
     // If no crump is a valid page identifier, something is fishy and the user should get the notfound page
     // Same, if the indexed document is not found
     if (!file_exists(\Xily\Config::get('app.dir') . 'views/' . $doc) || is_dir(\Xily\Config::get('app.dir') . 'views/' . $doc) || isset($crumps) && sizeof($crumps) == sizeof($arg)) {
         $doc = 'notfound.xml';
         $arg = array();
         $cache = false;
     }
     $xlyPage = \Xily\Bean::create(\Xily\Config::get('app.dir') . 'views/' . $doc, 1);
     // Dynamic parameters do not matter for cached views
     $xlyPage->setAttribute('lang', $locale[0]);
     $xlyPage->setAttribute('region', $locale[1]);
     if (array_key_exists('page', $_REQUEST)) {
         $xlyPage->setAttribute('page', $_REQUEST['page']);
     }
     if ($this->cacheDir) {
         $html = $xlyPage->run();
         xilyBase::fileWrite($cacheFile, $html);
         return $html;
     } else {
         $xlyPage->setDataset($arg, 'arg');
         $xlyPage->setDataset($_GET, 'get');
         $xlyPage->setDataset($_POST, 'post');
         $xlyPage->setDataset($_REQUEST, 'request');
         return $xlyPage->run();
     }
 }
Example #2
0
 public function getJSON($strCachePath = false)
 {
     if ($strCachePath) {
         $strCachePath = xilyBase::fileFormatDir($strCachePath);
         if (file_exists($strCachePath . $this->strCurrent . '.json')) {
             return file_get_contents($strCachePath . $this->strCurrent . '.json');
         }
     }
     return json_encode($this->arrData);
 }