public function createImageSelector($sourcePath, $width, $height, $className, $caption, $crop = true) { if ($sourcePath) { $application = CoreFactory::getApplication(); $imageName = $width . "x" . $height . "-" . basename($sourcePath); $imageHash = 4294967296.0 + crc32($sourcePath); $imageDirectory = $application->registry->get("Cache/Path") . "/" . $imageHash; $imagePath = $imageDirectory . "/" . $imageName; if (!is_file($imagePath)) { @mkdir($imageDirectory, false, true); $imageControl = CoreFactory::getImageControl(); if ($width == null || $height == null) { $crop = false; } if (substr($sourcePath, 0, 4) == "http") { $tempName = tempnam("/tmp", $imageHash); copy($sourcePath, $tempName); $imageControl->resizeAndCrop($tempName, $imagePath, $width, $height, false, !$crop); unlink($tempName); } else { $sourcePath = $application->registry->get("Path") . "/" . $sourcePath; $imageControl->resizeAndCrop($sourcePath, $imagePath, $width, $height, false, !$crop); } } $sourcePath = "/resource/cache/" . $imageHash . "/" . $imageName; } if ($caption == "") { return "<span class=\"{$className}\"><img src=\"{$sourcePath}\" width=\"{$width}\" " . "height=\"{$height}\" alt=\"Linked Image('{$sourcePath}')\" " . "title=\"Linked Image('{$sourcePath}')\" /></span>"; } else { return "<span class=\"{$className}\"><img src=\"{$sourcePath}\" width=\"{$width}\" " . "height=\"{$height}\" alt=\"{$caption}\" title=\"{$caption}\" /><span>{$caption}</span></span>"; } }
/** * Checks and sets the template file location passed * * @param string $filename to be set at the Template File * @return sets template or returns error if file not found. */ public function setTemplateFile($filename) { $application =& CoreFactory::getApplication(); if (file_exists($application->registry->get("Path") . $filename)) { $this->setTemplate(file_get_contents($application->registry->get("Path") . $filename)); } else { if (file_exists($filename)) { $this->setTemplate(file_get_contents($filename)); } else { trigger_error("Unable to open template file '" . realpath($filename) . "', file not found"); } } }