Moves thumbTypes to config.js.

This commit is contained in:
Lars Jung 2012-02-16 00:34:55 +01:00
parent 9f10e92175
commit ba3e61c1d0
7 changed files with 25 additions and 22 deletions

View file

@ -34,6 +34,8 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h
* updates es translation * updates es translation
* custom headers/footers are now optional and disabled by default * custom headers/footers are now optional and disabled by default
* fixes problems with folder recognition in the JS version * fixes problems with folder recognition in the JS version
* fixes include problems in PHP version
* fixes path problems on servers running on Windows in PHP version
### v0.17 - *2011-11-28* ### v0.17 - *2011-11-28*

View file

@ -106,6 +106,7 @@ var H5AI_CONFIG = {
* Show thumbnails for image files. * Show thumbnails for image files.
*/ */
"showThumbs": true, "showThumbs": true,
"thumbTypes": ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"],
/* /*
* Requires PHP on the server. * Requires PHP on the server.

View file

@ -12,9 +12,8 @@ $H5AI_CONFIG = array();
/* /*
* This configuration assumes that h5ai is installed * This configuration assumes that h5ai is installed
* in the webroot directory of the Apache server. * in the webroot directory of the Apache server.
* Assumed to end with a slash.
*/ */
$H5AI_CONFIG["ROOT_ABS_PATH"] = dirname(dirname(str_replace('\\', '/', __FILE__))); $H5AI_CONFIG["ROOT_ABS_PATH"] = safe_dirname(safe_dirname(__FILE__));
/* /*
* Files/folders that should not be listed. Specified * Files/folders that should not be listed. Specified

View file

@ -11,7 +11,7 @@ class Crumb {
$this->parts = array(); $this->parts = array();
$href = $h5ai->getAbsHref(); $href = $h5ai->getAbsHref();
while ($href !== "/" && $href !== "//") { while ($href !== "/") {
$this->parts[] = $href; $this->parts[] = $href;
$href = safe_dirname($href, true); $href = safe_dirname($href, true);
} }

View file

@ -5,7 +5,7 @@ require_h5ai("/php/inc/Thumbnail.php");
class Entry { class Entry {
private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size, $thumbTypes; private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size;
public function __construct($h5ai, $absPath, $absHref, $type = null, $label = null) { public function __construct($h5ai, $absPath, $absHref, $type = null, $label = null) {
@ -25,8 +25,6 @@ class Entry {
$this->type = $type !== null ? $type : $this->h5ai->getType($this->absPath); $this->type = $type !== null ? $type : $this->h5ai->getType($this->absPath);
$this->size = filesize($this->absPath); $this->size = filesize($this->absPath);
} }
$this->thumbTypes = array("bmp", "gif", "ico", "image", "jpg", "png", "tiff");
} }
@ -59,7 +57,7 @@ class Entry {
} }
} }
} }
if ($this->h5ai->showThumbs() && in_array($this->type, $this->thumbTypes)) { if ($this->h5ai->showThumbs() && in_array($this->type, $this->h5ai->getThumbTypes())) {
$imgClass = " class='thumb' "; $imgClass = " class='thumb' ";
$thumbnail = new Thumbnail($this->h5ai, $this->absHref, "square", 16, 16); $thumbnail = new Thumbnail($this->h5ai, $this->absHref, "square", 16, 16);
$thumbnail->create(); $thumbnail->create();
@ -138,7 +136,7 @@ class Extended {
} }
public function generateHeaders() { private function generateHeaders() {
$html = "\t<li class='header'>\n"; $html = "\t<li class='header'>\n";
$html .= "\t\t<a class='icon'></a>\n"; $html .= "\t\t<a class='icon'></a>\n";

View file

@ -126,6 +126,12 @@ class H5ai {
} }
public function normalizePath($path, $endWithSlash) {
return preg_match("#^(\w:)?/$#", $path) ? $path : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : ""));
}
public function getAbsHref($absPath = null, $endWithSlash = true) { public function getAbsHref($absPath = null, $endWithSlash = true) {
if ($absPath === null) { if ($absPath === null) {
@ -139,11 +145,8 @@ class H5ai {
foreach ($parts as $part) { foreach ($parts as $part) {
$encodedParts[] = rawurlencode($part); $encodedParts[] = rawurlencode($part);
} }
$endodedAbsHref = implode("/", $encodedParts);
$endodedAbsHref = $this->rootAbsHref . $endodedAbsHref; return $this->normalizePath($this->rootAbsHref . implode("/", $encodedParts), $endWithSlash);
return $this->normalizePath($endodedAbsHref, $endWithSlash);
} }
@ -165,6 +168,12 @@ class H5ai {
} }
public function getThumbTypes() {
return $this->options["thumbTypes"];
}
public function getTitle() { public function getTitle() {
$title = $this->domain . rawurldecode($this->absHref); $title = $this->domain . rawurldecode($this->absHref);
@ -233,12 +242,6 @@ class H5ai {
} }
public function normalizePath($path, $endWithSlash) {
return $path === "/" ? "/" : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : ""));
}
public function startsWith($sequence, $start) { public function startsWith($sequence, $start) {
return strcasecmp(substr($sequence, 0, strlen($start)), $start) === 0; return strcasecmp(substr($sequence, 0, strlen($start)), $start) === 0;

View file

@ -78,7 +78,7 @@ class Image {
public function releaseDest() { public function releaseDest() {
if (!is_null($this->dest)) { if (!is_null($this->dest)) {
imagedestroy($this->dest); @imagedestroy($this->dest);
$this->dest = null; $this->dest = null;
} }
} }
@ -87,7 +87,7 @@ class Image {
public function releaseSource() { public function releaseSource() {
if (!is_null($this->source)) { if (!is_null($this->source)) {
imagedestroy($this->source); @imagedestroy($this->source);
$this->sourceFile = null; $this->sourceFile = null;
$this->source = null; $this->source = null;
$this->width = null; $this->width = null;