diff --git a/src/_h5ai/client/js/inc/ext/filter.js b/src/_h5ai/client/js/inc/ext/filter.js index c714e02d..5014233b 100644 --- a/src/_h5ai/client/js/inc/ext/filter.js +++ b/src/_h5ai/client/js/inc/ext/filter.js @@ -67,6 +67,11 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core return new RegExp(sequence, 'i'); }, + reset = function () { + + $input.val('').blur(); + }, + update = function (focus) { var val = $input.val(); @@ -103,12 +108,12 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core .on('keydown', function (event) { if (event.which === 27) { - $input.val('').blur(); + reset(); } }) .on('keypress', updt); - event.sub('location.changed', updf); + event.sub('location.changed', reset); }; init(); diff --git a/src/_h5ai/server/php/inc/class-api.php b/src/_h5ai/server/php/inc/class-api.php index 3e6a41e2..445ccbd3 100644 --- a/src/_h5ai/server/php/inc/class-api.php +++ b/src/_h5ai/server/php/inc/class-api.php @@ -82,6 +82,12 @@ class Api { $response["items"] = $this->app->get_items($url, $what); } + if (has_request_param("all_items")) { + + use_request_param("all_items"); + $response["all_items"] = $this->app->get_all_items(); + } + if (count($_REQUEST)) { $response["unused"] = $_REQUEST; } diff --git a/src/_h5ai/server/php/inc/class-app.php b/src/_h5ai/server/php/inc/class-app.php index 3b5ee777..2af5744b 100644 --- a/src/_h5ai/server/php/inc/class-app.php +++ b/src/_h5ai/server/php/inc/class-app.php @@ -187,6 +187,34 @@ class App { } + private function get_all_item_content($item, &$cache) { + + foreach ($item->get_content($cache) as $child) { + if ($child->is_folder) { + $this->get_all_item_content($child, $cache); + } + } + } + + + public function get_all_items() { + + $cache = array(); + $root = Item::get($this, ROOT_PATH, $cache); + + $this->get_all_item_content($root, $cache); + + uasort($cache, array("Item", "cmp")); + $result = array(); + foreach ($cache as $p => $item) { + $result[] = $item->to_json_object(); + } + + @file_put_contents(CACHE_PATH . "/item.json", json_encode($result)); + return $result; + } + + public function get_fallback() { $cache = array();