Refactor code.

This commit is contained in:
Lars Jung 2015-05-06 19:12:28 +02:00
parent d5a1a829e3
commit 6ee0ed3444
4 changed files with 15 additions and 15 deletions

View file

@ -24,7 +24,7 @@ class Api {
private function on_download() {
Util::json_fail(Util::ERR_DISABLED, "download disabled", !$this->app->get_option("download.enabled", false));
Util::json_fail(Util::ERR_DISABLED, "download disabled", !$this->app->query_option("download.enabled", false));
$as = Util::query_request_param("as");
$type = Util::query_request_param("type");
@ -66,7 +66,7 @@ class Api {
if (Util::query_request_param("custom", false)) {
Util::json_fail(Util::ERR_DISABLED, "custom disabled", !$this->app->get_option("custom.enabled", false));
Util::json_fail(Util::ERR_DISABLED, "custom disabled", !$this->app->query_option("custom.enabled", false));
$href = Util::query_request_param("custom");
$response["custom"] = $this->app->get_customizations($href);
@ -74,7 +74,7 @@ class Api {
if (Util::query_request_param("l10n", false)) {
Util::json_fail(Util::ERR_DISABLED, "l10n disabled", !$this->app->get_option("l10n.enabled", false));
Util::json_fail(Util::ERR_DISABLED, "l10n disabled", !$this->app->query_option("l10n.enabled", false));
$iso_codes = Util::query_array_request_param("l10n");
$iso_codes = array_filter($iso_codes);
@ -83,7 +83,7 @@ class Api {
if (Util::query_request_param("search", false)) {
Util::json_fail(Util::ERR_DISABLED, "search disabled", !$this->app->get_option("search.enabled", false));
Util::json_fail(Util::ERR_DISABLED, "search disabled", !$this->app->query_option("search.enabled", false));
$href = Util::query_request_param("search.href");
$pattern = Util::query_request_param("search.pattern");
@ -93,7 +93,7 @@ class Api {
if (Util::query_request_param("thumbs", false)) {
Util::json_fail(Util::ERR_DISABLED, "thumbnails disabled", !$this->app->get_option("thumbnails.enabled", false));
Util::json_fail(Util::ERR_DISABLED, "thumbnails disabled", !$this->app->query_option("thumbnails.enabled", false));
Util::json_fail(Util::ERR_UNSUPPORTED, "thumbnails not supported", !HAS_PHP_JPEG);
$thumbs = Util::query_array_request_param("thumbs");

View file

@ -15,13 +15,13 @@ class App {
}
public function get_options() {
public function query_options() {
return $this->options;
}
public function get_option($keypath = "", $default = null) {
public function query_option($keypath = "", $default = null) {
return Util::array_query($this->options, $keypath, $default);
}
@ -79,7 +79,7 @@ class App {
public function get_theme() {
$theme = $this->get_option("view.theme", "-NONE-");
$theme = $this->query_option("view.theme", "-NONE-");
$theme_path = APP_PATH . "/client/images/themes/${theme}";
$icons = [];
@ -129,7 +129,7 @@ class App {
return true;
}
foreach ($this->get_option("view.hidden", []) as $re) {
foreach ($this->query_option("view.hidden", []) as $re) {
$re = Util::wrap_pattern($re);
if (preg_match($re, $name)) {
return true;
@ -148,7 +148,7 @@ class App {
if (
$this->is_hidden($name)
|| $this->is_hidden($this->to_href($path) . $name)
|| (!is_readable($path .'/'. $name) && $this->get_option("view.hideIf403", false))
|| (!is_readable($path .'/'. $name) && $this->query_option("view.hideIf403", false))
) {
continue;
}
@ -175,7 +175,7 @@ class App {
return false;
}
foreach ($this->get_option("view.unmanaged", []) as $name) {
foreach ($this->query_option("view.unmanaged", []) as $name) {
if (file_exists($path . "/" . $name)) {
return false;
}
@ -337,7 +337,7 @@ class App {
public function get_customizations($href) {
if (!$this->get_option("custom.enabled", false)) {
if (!$this->query_option("custom.enabled", false)) {
return [
"header" => ["content" => null, "type" => null],
"footer" => ["content" => null, "type" => null]

View file

@ -62,7 +62,7 @@ class Thumb {
$image = new Image();
$et = false;
if (HAS_PHP_EXIF && $this->app->get_option("thumbnails.exif", false) === true && $height != 0) {
if (HAS_PHP_EXIF && $this->app->query_option("thumbnails.exif", false) === true && $height != 0) {
$et = @exif_thumbnail($source_path);
}
if($et !== false) {

View file

@ -209,8 +209,8 @@ class Util {
} else if (is_dir($path)) {
if ($app->get_option("foldersize.enabled", false)) {
if (HAS_CMD_DU && $app->get_option("foldersize.type", null) === "shell-du") {
if ($app->query_option("foldersize.enabled", false)) {
if (HAS_CMD_DU && $app->query_option("foldersize.type", null) === "shell-du") {
$cmdv = ["du", "-sk", $path];
$size = intval(preg_replace("#\s.*$#", "", Util::exec_cmdv($cmdv)), 10) * 1024;
} else {