/**
  * Generates a thumbnail for the specified image path and size, then serves 
  * it to the browser. The next time the same thumbnail is rendered its URL 
  * will point to the generated image instead of this action.
  * @see Thumbnail
  * @param string $path the thumbnail path
  * @param int $size the thumbnail size
  * @throws PageNotFoundException if the image could not be generated
  */
 public function actionGenerate($path, $size)
 {
     $thumbnail = new Thumbnail($path, $size);
     $thumbnail->generate();
     $path = $thumbnail->getPath();
     if ($path === false) {
         throw new PageNotFoundException();
     }
     header('Content-Type: ' . CFileHelper::getMimeType($path));
     readfile($path);
     exit;
 }
Example #2
0
 public function toHtml()
 {
     $classes = "entry " . ($this->isFolder ? "folder " : "file ") . $this->type;
     $imgClass = "";
     $img = $this->type;
     $smallImg = $this->h5ai->icon($this->type);
     $bigImg = $this->h5ai->icon($this->type, true);
     $hint = "";
     if ($this->isFolder && $this->type !== "folder-parent") {
         $code = $this->h5ai->getHttpCode($this->absHref);
         $classes .= " checkedHttpCode";
         if ($code !== "h5ai") {
             if ($code === 200) {
                 $img = "folder-page";
                 $smallImg = $this->h5ai->icon("folder-page");
                 $bigImg = $this->h5ai->icon("folder-page", true);
             } else {
                 $classes .= " error";
                 $hint = "<span class='hint'> " . $code . " </span>";
             }
         }
     }
     if ($this->h5ai->showThumbs() && in_array($this->type, $this->h5ai->getThumbTypes())) {
         $imgClass = " class='thumb' ";
         $thumbnail = new Thumbnail($this->h5ai, $this->absHref, "square", 16, 16);
         $thumbnail->create();
         $smallImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref();
         $thumbnail = new Thumbnail($this->h5ai, $this->absHref, "rational", 96, 46);
         $thumbnail->create();
         $bigImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref();
     }
     $html = "\t<li class='" . $classes . "'>\n";
     $html .= "\t\t<a href='" . $this->absHref . "'>\n";
     $html .= "\t\t\t<span class='icon small'><img " . $imgClass . " src='" . $smallImg . "' alt='" . $img . "' /></span>\n";
     $html .= "\t\t\t<span class='icon big'><img " . $imgClass . " src='" . $bigImg . "' alt='" . $img . "' /></span>\n";
     $html .= "\t\t\t<span class='label'>" . $this->label . $hint . "</span>\n";
     $html .= "\t\t\t<span class='date' data-time='" . $this->date . "000'></span>\n";
     $html .= "\t\t\t<span class='size' data-bytes='" . $this->size . "'>" . $this->size . "</span>\n";
     $html .= "\t\t</a>\n";
     $html .= "\t</li>\n";
     return $html;
 }
Example #3
0
    $codes = getHttpCodes($h5ai, $hrefs);
    echo count($codes) === 0 ? "{}" : json_encode($codes);
} else {
    if ($action === "thumb") {
        fail(0, "thumbs are disabled", !$options["showThumbs"]);
        list($srcAbsHref, $width, $height, $mode) = checkKeys(array("href", "width", "height", "mode"));
        require_once "inc/Thumbnail.php";
        require_once "inc/Image.php";
        $srcAbsPath = $h5ai->getDocRoot() . rawurldecode($srcAbsHref);
        if (!Thumbnail::isUsable()) {
            Image::showImage($srcAbsPath);
            exit;
        }
        $thumbnail = new Thumbnail($h5ai, $srcAbsHref, $mode, $width, $height);
        $thumbnail->create(1);
        if (file_exists($thumbnail->getPath())) {
            Image::showImage($thumbnail->getPath());
        } else {
            $image = new Image();
            $image->setSource($srcAbsPath);
            $image->thumb($mode, $width, $height);
            $image->showDest();
        }
    } else {
        if ($action === "tree") {
            list($href) = checkKeys(array("href"));
            require_once "inc/Tree.php";
            $absHref = trim($href);
            $absPath = $h5ai->getAbsPath($absHref);
            $tree = new TreeEntry($h5ai, $absPath, $absHref);
            $tree->loadContent();