Exemple #1
0
 public function __construct($path)
 {
     $realPath = FileSystem::getRealPath($path);
     if (FileSystem::exists($realPath) && FileSystem::isFile($realPath)) {
         $this->path = $realPath;
     }
 }
 public function __construct()
 {
     //Not self::$context because Contexts have $context self has null
     $path = "Models/.model-cache/" . self::getContext() . ".rln";
     if (FileSystem::exists($path)) {
         $data = FileSystem::get($path);
         $relations = (array) @json_decode($data);
         $this->linkRelations($relations);
     }
 }
Exemple #3
0
 public function __construct($path)
 {
     $realPath = FileSystem::getRealPath($path);
     if (!FileSystem::exists($realPath)) {
         FileSystem::makeDirectory($realPath);
     }
     if (FileSystem::exists($realPath) && FileSystem::isDirectory($realPath)) {
         $this->path = $realPath;
     } else {
         die("Invalid Directory " . $realPath);
     }
 }
Exemple #4
0
 public function printView($filePath)
 {
     if (!FileSystem::exists(BASE_DIR . "/Views/.cache")) {
         FileSystem::makeDirectory(BASE_DIR . "/Views/.cache");
     }
     $razr = new Engine(new FileSystemLoader(), BASE_DIR . "/Views/.cache");
     $page = new \stdClass();
     $page->title = $this->title;
     $page->author = $this->author;
     $page->metaContent = $this->metaContent;
     $this->registeredVariables["MetaPageDetails"] = $page;
     echo $razr->render($filePath, $this->registeredVariables);
 }
Exemple #5
0
 public function parseClass()
 {
     $class = get_class($this);
     $re = "/Controllers\\\\([A-Z0-9_]*)Controller/i";
     preg_match($re, $class, $matches);
     if (isset($matches[1])) {
         $cls = $matches[1];
         $fullCls = "Models\\Context\\" . $cls;
         if (FileSystem::exists("Models/Context/" . $cls . ".php") && class_exists("Models\\Context\\" . $cls)) {
             return $fullCls;
         }
     }
     return null;
 }
Exemple #6
0
 public static function getColumns($table)
 {
     $file = "Models/.model-cache/" . $table . ".cols";
     if (FileSystem::exists($file)) {
         $data = FileSystem::get($file);
         try {
             return json_decode($data);
         } catch (\Exception $e) {
             new Error($e->getMessage(), 0);
         }
     }
     $sql = "SHOW COLUMNS FROM " . $table;
     $query = new SQLQuery($sql);
     $results = $query->getResults();
     try {
         FileSystem::put($file, json_encode($results));
     } catch (\Exception $e) {
         new Error($e->getMessage(), 0);
     }
     return $results;
 }
Exemple #7
0
 private function saveTempImage($thumbnail)
 {
     if (!FileSystem::exists($this->tempDirectory)) {
         FileSystem::makeDirectory($this->tempDirectory);
     }
     $fileName = $this->tempDirectory . $this->tempFileName();
     switch ($this->imageType) {
         case "image/jpeg":
             imagejpeg($thumbnail, $fileName);
             break;
         case "image/png":
             imagepng($thumbnail, $fileName);
             break;
         case "image/gif":
             imagegif($thumbnail, $fileName);
             break;
         default:
             die("Invalid Image Type");
             break;
     }
 }
Exemple #8
0
 public static function getContents($path)
 {
     $path = self::getRealPath($path);
     if (FileSystem::exists($path)) {
         return array_diff(scandir($path), array('..', '.'));
     }
     return [];
 }
Exemple #9
0
 private function controllerExists($controller, $method)
 {
     if (FileSystem::exists(BASE_DIR . "/Controllers/" . ucfirst($controller) . "Controller.php")) {
         $controllerPath = "Controllers\\" . ucfirst($controller) . "Controller";
         if (method_exists($controllerPath, $method)) {
             return true;
         }
         $method = $this->hyphenToCammelCase($method);
         if (method_exists($controllerPath, $method)) {
             return true;
         }
     }
     return false;
 }