Example #1
0
 /**
  * show function - this is now moved from the contoller level so can differ for each model
  * NOTE: this function exits
  * @param string $size 
  */
 public function show($size = 110, $compress = false)
 {
     $source = PUBLIC_DIR . $this->rpath . "/" . $this->filename;
     $extension = File::get_extension($this->filename);
     $file = CACHE_DIR . $this->id . "_" . $size . "." . $extension;
     //slash any spaces
     $source = preg_replace("/[\\s]/", "\\ ", $source);
     if (!is_readable($source)) {
         error_log("FATAL IMAGE ERROR");
     }
     if (!File::is_image($source)) {
         if (!is_file($file) || !is_readable($file)) {
             $icon_type = $extension;
             $icon = PLUGIN_DIR . "cms/resources/public/images/cms/" . "cms-generic-icon-" . strtolower($icon_type) . ".gif";
             if (!is_readable($icon) || $icon_file != file_get_contents($icon)) {
                 $icon_file = PLUGIN_DIR . "cms/resources/public/images/cms/" . "cms-generic-icon.png";
                 $source = CACHE_DIR . "cms-generic-icon.gif";
             } else {
                 $source = CACHE_DIR . "cms-generic-icon-{$icon_type}.gif";
             }
             file_put_contents($source, $icon_file);
         }
     }
     if (!is_file($file) || !is_readable($file)) {
         File::resize_image($source, $file, $size, $compression);
     }
     if ($this->image = File::display_image($file)) {
         return true;
     }
     return false;
 }
Example #2
0
 public static function detect_assets()
 {
     self::register("framework", "File", FRAMEWORK_DIR . "/utilities/File.php");
     if (!isset($_GET["route"])) {
         return false;
     }
     $temp_route = $_GET["route"];
     $_temp_route = preg_replace("/[^a-zA-Z0-9_\\-\\.]/", "", $temp_route);
     while (strpos($temp_route, "..")) {
         $temp_route = str_replace("..", ".", $temp_route);
     }
     $asset_paths = explode("/", $_GET["route"]);
     if ($asset_paths[0] == "images" || $asset_paths[0] == "javascripts" || $asset_paths[0] == "stylesheets") {
         $plugins = scandir(PLUGIN_DIR);
         $type = array_shift($asset_paths);
         rsort($plugins);
         foreach ($plugins as $plugin) {
             $path = PLUGIN_DIR . $plugin . "/resources/public/" . $type . "/" . implode("/", $asset_paths);
             if ($type == "images") {
                 File::display_image($path);
             }
             if ($type == "javascripts") {
                 File::display_asset($path, "text/javascript");
             }
             if ($type == "stylesheets") {
                 File::display_asset($path, "text/css");
             }
         }
     }
 }