Exemplo n.º 1
0
 /**
  * Przekazuje kod do szablonu Smarty
  *
  * @param string $name Nazwa pliku
  * @param string $path Ścieżka do szablonu
  *
  * @return void
  */
 public function renderInclude($name)
 {
     $pathFile = pathFile($name);
     $folder = $pathFile[0];
     $name = $pathFile[1];
     $path = $this->templateConfig->get('setTemplateDir') . '/' . $folder . $name . $this->templateConfig->get('fileExtension', '.html.php');
     try {
         if (is_file($path)) {
             include $path;
         } else {
             throw new \Exception('Can not open template ' . $name . ' in: ' . $path);
         }
     } catch (Exception $e) {
         echo $e->getMessage() . '<br />
             File: ' . $e->getFile() . '<br />
             Code line: ' . $e->getLine() . '<br />
             Trace: ' . $e->getTraceAsString();
         exit;
     }
 }
Exemplo n.º 2
0
 private function loadObject($name, $type)
 {
     if (!in_array($type, array('Model', 'View'))) {
         return false;
     }
     $pathFile = pathFile($name);
     $folder = $pathFile[0];
     $name = $pathFile[1];
     $n = str_replace($type, '', $name);
     $path = appDir . '../app/' . $type . '/' . $folder . $n . '.php';
     if (!empty($folder)) {
         $name = '\\' . $type . '\\' . str_replace(array('\\', '/'), '\\', $folder) . $name . $type;
     } else {
         $name = '\\' . $type . '\\' . $name . $type;
     }
     try {
         if (is_file($path)) {
             include_once $path;
             $ob = new $name($this->baseClass);
             $ob->init();
         } else {
             throw new BaseException('Can not open ' . $type . ' ' . $name . ' in: ' . $path);
         }
     } catch (BaseException $e) {
         if (ini_get('display_errors') == "on") {
             echo $e->getMessage() . '<br />
             File: ' . $e->getFile() . '<br />
             Code line: ' . $e->getLine() . '<br /> 
             Trace: ' . $e->getTraceAsString();
             exit;
         }
         $routerConfig = Config::load('router');
         header("HTTP/1.0 400 Bad Request");
         echo $e->getMessage();
         exit;
     }
     return $ob;
 }