Esempio n. 1
0
 public function output($panadaViewfile, $data = [])
 {
     $panadaFilePath = APP . 'views/' . $panadaViewfile;
     if ($this->childClass['namespaceArray'][0] == 'Modules') {
         $panadaFilePath = $this->configMain['module']['path'] . $this->childClass['namespaceArray'][0] . '/' . $this->childClass['namespaceArray'][1] . '/views/' . $panadaViewfile;
     }
     try {
         if (!file_exists($this->viewFile = $panadaFilePath . '.php')) {
             throw new RunException('View file in ' . $this->viewFile . ' does not exits');
         }
     } catch (RunException $e) {
         $arr = $e->getTrace();
         RunException::outputError($e->getMessage(), $arr[0]['file'], $arr[0]['line']);
     }
     if (!empty($data)) {
         $this->viewCache = array('data' => $data, 'prefix' => $this->childClass['namespaceString']);
     }
     // We don't need this variables anymore.
     unset($panadaViewFile, $data, $panadaFilePath);
     if (!empty($this->viewCache) && $this->viewCache['prefix'] == $this->childClass['namespaceString']) {
         extract($this->viewCache['data'], EXTR_SKIP);
     }
     ob_start();
     include $this->viewFile;
     $return = ob_get_contents();
     ob_end_clean();
     return $return;
 }
Esempio n. 2
0
 public function parse($viewFile, $data = array(), $isReturnValue = false)
 {
     $themePath = 'themes/' . $this->themeName . '/' . $viewFile;
     try {
         if (!file_exists($this->viewFile = $themePath . '.php')) {
             throw new RunException('View file in ' . $this->{$viewFile} . ' does not exits');
         }
     } catch (RunException $e) {
         $arr = $e->getTrace();
         RunException::outputError($e->getMessage(), $arr[0]['file'], $arr[0]['line']);
     }
     if (!empty($data)) {
         $this->viewCache = array('data' => $data, 'prefix' => $this->childClass['namespaceString']);
     }
     // We don't need this variables anymore.
     unset($viewFile, $data, $themePath);
     if (!empty($this->viewCache) && $this->viewCache['prefix'] == $this->childClass['namespaceString']) {
         extract($this->viewCache['data'], EXTR_SKIP);
     }
     if ($isReturnValue) {
         ob_start();
         include_once $this->viewFile;
         $return = ob_get_contents();
         ob_end_clean();
         return $return;
     }
     include_once $this->viewFile;
 }
Esempio n. 3
0
 /**
  * Handler for user defined config.
  */
 public static function __callStatic($name, $arguments = array())
 {
     // Does cache for this config exists?
     if (isset(self::$config[$name])) {
         return self::$config[$name];
     }
     // Does the config file exists?
     try {
         if (!file_exists($file = APP . 'config/' . $name . '.php')) {
             throw new RunException('Config file in ' . $file . ' does not exits');
         }
     } catch (RunException $e) {
         RunException::outputError($e->getMessage());
     }
     return self::_cache($name);
 }
 /**
  * Dynamic finder method handler
  *
  * @param string $name Method name
  * @param array $arguments Method arguments
  */
 public function __call($name, $arguments = array())
 {
     $cacheKey = 'select' . $this->select . $this->table;
     $this->db->select($this->select)->from($this->table);
     if ($name == 'first') {
         $cacheKey .= $this->primaryKey . 'ASC';
         return $this->db->orderBy($this->primaryKey, 'ASC')->limit(1)->getOne();
     }
     if ($name == 'last') {
         $cacheKey .= $this->primaryKey . 'DESC';
         return $this->db->orderBy($this->primaryKey, 'DESC')->limit(1)->getOne();
     }
     $splitedName = substr($name, 5, strlen($name));
     if ($splitedName) {
         try {
             if (empty($arguments)) {
                 throw new RunException('getBy<b>' . $splitedName . '</b>() in Active Record method expects 1 parameter and you dont given anything yet.');
             }
         } catch (RunException $e) {
             $arr = $e->getTrace();
             RunException::outputError($e->getMessage(), $arr[1]['file'], $arr[1]['line']);
         }
         $cacheKey .= $splitedName . '=' . $arguments[0];
         $this->db->where($splitedName, '=', $arguments[0]);
         if (!is_null($this->limit)) {
             $cacheKey .= $this->limit . $this->offset;
             $this->db->limit($this->limit, $this->offset);
         }
         if ($this->setInstantiateClass) {
             $this->db->instantiateClass = $this->setInstantiateClass;
         }
         $cacheKey = md5($cacheKey);
         if ($cached = $this->cache->getValue($cacheKey)) {
             return $cached;
         }
         if (!($results = $this->db->getAll())) {
             return false;
         }
         $this->setInstantiateClass = false;
         if (count($results) == 1) {
             $pk = $this->primaryKey;
             $this->{$pk} = $results[0]->{$pk};
             $this->cache->setValue($cacheKey, $results[0]);
             return $results[0];
         }
         $this->cache->setValue($cacheKey, $results);
         return $results;
     }
 }
Esempio n. 5
0
 public function __construct(RunException $runException, $file, $line)
 {
     $message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);
     parent::__construct($message, 0, $runException->getPrevious());
 }