Ejemplo n.º 1
0
function renderLatte($path, $parameters = array())
{
    global $App;
    global $View;
    global $wp_query;
    global $post;
    $fullParameters = array('App' => $App, 'baseUrl' => toPath(WP_HOME), 'basePath' => toRelativePath(WP_HOME), 'assetsUrl' => toPath(WP_HOME) . '/assets', 'assetsPath' => toRelativePath(WP_HOME) . '/assets', 'wp_query' => $wp_query, 'post' => $post, 'flashes' => getFlashSession()->flash ?: []);
    foreach ($View as $key => $val) {
        $fullParameters[$key] = $val;
    }
    foreach ($parameters as $key => $val) {
        $fullParameters[$key] = $val;
    }
    $latte = new Latte\Engine();
    $latte->setTempDirectory(TEMP_DIR . '/cache/latte');
    MangoPressTemplatingMacroSet::install($latte->getCompiler());
    Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
    MangoPressTemplatingFilterSet::install($latte);
    return $latte->render($path, (array) $fullParameters);
}
Ejemplo n.º 2
0
 /**
  * Retrieve cache value from file by key
  *
  * @false string
  * @false boolean [optional]
  * @param      $key
  * @param bool $timestamp
  * @return string
  */
 public function get($key, $timestamp = false)
 {
     if ($this->where == true) {
         $this->setCache($key)->setPath(CYGNITE_BASE . DS . toPath('public.storage.cache') . DS);
     }
     $cached = [];
     $cached = $this->getCache();
     if ($timestamp === false) {
         return $cached[$key]['data'];
     } else {
         return $cached[$key]['time'];
     }
 }
Ejemplo n.º 3
0
 /**
  * @return array
  * @throws \Exception
  */
 private function importConfigurations()
 {
     $configPath = "";
     $configPath = static::$paths['app.path'] . DS . toPath(static::$paths['app.config']['directory']);
     $files = [];
     $files = array_merge($this->files, static::$paths['app.config']['files']);
     foreach ($files as $key => $file) {
         if (!file_exists($configPath . $file . EXT)) {
             throw new \Exception("File doesn't exists in the path " . $configPath . $file . EXT);
         }
         /**
                     | We will include configuration file into array only
                     | for the first time
         */
         if (!isset(self::$config[$key])) {
             Config::set($key, include $configPath . $file . EXT);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * We will display custom error page in production mode
  *
  * @param null $e
  * @throws \Exception
  */
 public function importCustomErrorPage($e = null)
 {
     $path = CYGNITE_BASE . DS . toPath(APPPATH . '/Views/errors/');
     if ($e == null) {
         Debugger::$errorTemplate = (include $path . '500.view' . EXT);
     }
     $statusCode = 500;
     if (method_exists($e, 'getStatusCode')) {
         $statusCode = $e->getStatusCode();
     } else {
         if (method_exists($e, 'getCode')) {
             $statusCode = $e->getCode();
         }
     }
     if ($statusCode == 0) {
         $statusCode = 500;
     }
     if (file_exists($path . $statusCode . '.view' . EXT)) {
         $error = ['error.code' => $statusCode, 'message' => $e->getMessage()];
         extract($error);
         Debugger::$errorTemplate = (include $path . $statusCode . '.view' . EXT);
     } else {
         throw new \Exception("Error view file not exists " . $path . $e->getStatusCode() . '.view' . EXT);
     }
 }