From 6ee0ed3444382cf9318d694c5da2fa1af6a96683 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 6 May 2015 19:12:28 +0200 Subject: [PATCH] Refactor code. --- src/_h5ai/server/php/inc/class-api.php | 10 +++++----- src/_h5ai/server/php/inc/class-app.php | 14 +++++++------- src/_h5ai/server/php/inc/class-thumb.php | 2 +- src/_h5ai/server/php/inc/class-util.php | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/_h5ai/server/php/inc/class-api.php b/src/_h5ai/server/php/inc/class-api.php index ea3a907a..43cf6ee1 100644 --- a/src/_h5ai/server/php/inc/class-api.php +++ b/src/_h5ai/server/php/inc/class-api.php @@ -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"); diff --git a/src/_h5ai/server/php/inc/class-app.php b/src/_h5ai/server/php/inc/class-app.php index 8292f237..06e80b16 100644 --- a/src/_h5ai/server/php/inc/class-app.php +++ b/src/_h5ai/server/php/inc/class-app.php @@ -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] diff --git a/src/_h5ai/server/php/inc/class-thumb.php b/src/_h5ai/server/php/inc/class-thumb.php index c04e03bc..54876c68 100644 --- a/src/_h5ai/server/php/inc/class-thumb.php +++ b/src/_h5ai/server/php/inc/class-thumb.php @@ -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) { diff --git a/src/_h5ai/server/php/inc/class-util.php b/src/_h5ai/server/php/inc/class-util.php index 89b2705e..a4216e36 100644 --- a/src/_h5ai/server/php/inc/class-util.php +++ b/src/_h5ai/server/php/inc/class-util.php @@ -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 {