Add filter reset on location change.

This commit is contained in:
Lars Jung 2014-06-10 00:30:32 +02:00
parent af29d651b5
commit a1ebf1f4fb
3 changed files with 41 additions and 2 deletions

View file

@ -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;
}

View file

@ -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();