Example #1
0
 function colesoCacheRegistry($fromInstance = '')
 {
     if ($fromInstance == '') {
         colesoErrDie('This is singleton: use getInstance instead of constructor');
     }
     $this->readConfig();
 }
Example #2
0
 function colesoToken($fromInstance = '')
 {
     if ($fromInstance == '') {
         colesoErrDie('This is singleton: use getInstance instead of constructor');
     }
     $this->Environment = colesoApplication::getEnvironment();
     $this->tokenKey = colesoApplication::getConfigVal('/system/tokenName', 'colesoToken');
     $this->tokenTimeKey = colesoApplication::getConfigVal('/system/tokenTimeName', 'colesoTokenTime');
 }
Example #3
0
 private static function getRealFilename($file)
 {
     $path_parts = pathinfo($file);
     if (isset($path_parts['extension']) && ($path_parts['extension'] == 'php' || $path_parts['extension'] == 'yml')) {
         return $file;
     }
     if (file_exists($file . '.php')) {
         return $file . '.php';
     }
     if (file_exists($file . '.yml')) {
         return $file . '.yml';
     }
     colesoErrDie('No file detected');
 }
 public function buildSection($section, $path)
 {
     foreach ($section as $topic => $params) {
         if (isset($params['type']) && $params['type'] == 'chapter') {
             $topicPath = $path . $topic . '/index.html';
         } else {
             $topicPath = $path . $topic;
         }
         $topicPath = ltrim($topicPath, '\\/');
         echo $topicPath . "\n";
         $content = $this->render->renderPage($topicPath);
         $this->saveDestFile($topicPath, $content);
         if (isset($params['type']) && $params['type'] == 'chapter') {
             if (!is_array($params['topics'])) {
                 colesoErrDie('Chapter should have topics!');
             }
             $this->buildSection($params['topics'], $path . $topic . '/');
         }
     }
 }
 function includeTemplateSet($filename, $key = '')
 {
     $templateDir = dirname($filename);
     if (!file_exists($filename)) {
         colesoErrDie("File {$filename} does not exist");
     }
     $handle = fopen($filename, "r");
     $this->curKey = $key;
     if ($key) {
         $this->namedTemplates[$key] = '';
     }
     while (!feof($handle)) {
         $buffer = fgets($handle, 4096);
         if (preg_match("/<!-- #include <(.*?)># -->/", $buffer, $matches)) {
             $this->includeTemplateSet($templateDir . '/' . $matches[1]);
         } elseif (preg_match("/<!-- #(.*?)# -->/", $buffer, $matches)) {
             $this->curKey = $matches[1];
             $this->namedTemplates[$this->curKey] = '';
         } else {
             $this->addString($buffer);
         }
     }
     fclose($handle);
 }
 public function renderPage($path, $content = null)
 {
     try {
         $pathBuilder = new pathBuilder($path);
         if (is_null($content)) {
             $content = $this->getContent($pathBuilder);
             $editMode = false;
         } else {
             $editMode = true;
         }
         $data = array('content' => $content, 'editMode' => $editMode);
         $this->buildGeneralData($pathBuilder, $data);
         $this->buildMenuData($pathBuilder, $data);
         $this->buildUrlData($pathBuilder, $data);
         return $this->renderPageData($data);
     } catch (pageNotFoundException $e) {
         colesoErrDie($e->getMessage());
     }
 }