/** * Resolves the file type (css, js) regarding to it's * source file extension. * * @uses File::get_extension() * @param string $item * @param bool $reset Reset (empty) the array of the item type before adding * @return int Number of elements of given type after adding */ protected function resolve_unknown_type($item, $reset = FALSE) { $ext = File::get_extension($item); switch (strtolower($ext)) { case 'css': return $this->add(new HTML_Header_Stylesheet($item), $reset); break; case 'js': return $this->add(new HTML_Header_Javascript($item), $reset); break; case 'ico': return $this->add(new HTML_Header_Favicon($item), $reset); break; } }
/** * 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; }