h5ai = $h5ai; $this->label = $label !== null ? $label : $this->h5ai->getLabel( $absHref ); $this->absPath = $this->h5ai->normalizePath( $absPath, false ); $this->isFolder = is_dir( $this->absPath ); $this->absHref = $this->h5ai->normalizePath( $absHref, $this->isFolder ); $this->date = filemtime( $this->absPath ); if ( $this->isFolder ) { $this->type = $type !== null ? $type : "folder"; $this->size = ""; } else { $this->type = $type !== null ? $type : $this->h5ai->getType( $this->absPath ); $this->size = filesize( $this->absPath ); } $this->thumbTypes = array( "bmp", "gif", "ico", "image", "jpg", "png", "tiff" ); } public function isFolder() { return $this->isFolder; } function compare( $that, $sortOrder ) { if ( $this->isFolder && !$that->isFolder ) { return -1; } if ( !$this->isFolder && $that->isFolder ) { return 1; } $res = 0; if ( $sortOrder[ "column" ] === "name" ) { $res = strcasecmp( $this->absPath, $that->absPath ); } else if ( $sortOrder[ "column" ] === "date" ) { $res = $this->date - $that->date; } else if ( $sortOrder[ "column" ] === "size" ) { $res = $this->size - $that->size; } if ( ! $sortOrder[ "ascending" ] ) { $res = -$res; } return $res; } public function toHtml( $dateFormat ) { $classes = "entry " . $this->type; $img = $this->type; $smallImg = "/h5ai/icons/16x16/" . $this->type . ".png"; $bigImg = "/h5ai/icons/48x48/" . $this->type . ".png"; $hint = ""; $dateLabel = date( $dateFormat, $this->date ); 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 = "/h5ai/icons/16x16/folder-page.png"; $bigImg = "/h5ai/icons/48x48/folder-page.png"; } else { $classes .= " error"; $hint = " " . $code . " "; } } } if ( $this->h5ai->showThumbs() && in_array( $this->type, $this->thumbTypes ) ) { $classes .= " thumb"; $thumbnail = new Thumbnail( $this->absPath, "square", 16, 16 ); $thumbnail->create(); $smallImg = file_exists( $thumbnail->getPath() ) ? $thumbnail->getHref() : $thumbnail->getLiveHref(); $thumbnail = new Thumbnail( $this->absPath, "rational", 96, 46 ); $thumbnail->create(); $bigImg = file_exists( $thumbnail->getPath() ) ? $thumbnail->getHref() : $thumbnail->getLiveHref(); } $html = "\t
";
$desc = "
";
$so = $this->h5ai->getSortOrder();
$order = $so["ascending"] ? $asc : $desc;
$nameHref = "?col=name" . ( $so["column"] === "name" && $so["ascending"] ? "&asc=false" : "&asc=true" );
$dateHref = "?col=date" . ( $so["column"] === "date" && $so["ascending"] ? "&asc=false" : "&asc=true" );
$sizeHref = "?col=size" . ( $so["column"] === "size" && $so["ascending"] ? "&asc=false" : "&asc=true" );
$nameSort = $so["column"] === "name" ? $order : "";
$dateSort = $so["column"] === "date" ? $order : "";
$sizeSort = $so["column"] === "size" ? $order : "";
$html = "\t