diff --git a/classes/Search.php b/classes/Search.php index d13f854..f53a224 100644 --- a/classes/Search.php +++ b/classes/Search.php @@ -1,11 +1,10 @@ is_set_get('search') ? Url::html_output($request->get('search')) : ''); + $mode = ($request->is_set_get('search_mode') ? self::clean_mode($request->is_set_get('search_mode')) : 'f'); $modes = array('files' => 'f', 'folders' => 'd', 'both' => 'fd'); - $out = '
'; + return $out; } @@ -96,11 +104,11 @@ class Search extends DirectoryListDetailed */ private function merge(Search $obj) { - $this -> total_folders += $obj -> __get('total_folders'); - $this -> total_files += $obj -> __get('total_files'); - $this -> total_downloads += $obj -> __get('total_downloads'); - $this -> total_size -> add_size($obj -> __get('total_size')); - $this -> matches = array_merge($this -> matches, $obj -> __get('contents')); + $this->total_folders += $obj->__get('total_folders'); + $this->total_files += $obj->__get('total_files'); + $this->total_downloads += $obj->__get('total_downloads'); + $this->total_size->add_size($obj->__get('total_size')); + $this->matches = array_merge($this->matches, $obj->__get('contents')); } /** @@ -142,9 +150,9 @@ class Search extends DirectoryListDetailed $mode = self::clean_mode($mode); $dir = Item::make_sure_slash($dir); DirectoryList::__construct($dir); - $this -> matches = array(); - $this -> total_size = new Size(0); - $this -> total_downloads = $this -> total_folders = $this -> total_files = 0; + $this->matches = array(); + $this->total_size = new Size(0); + $this->total_downloads = $this->total_folders = $this->total_files = 0; foreach ($this as $item) { if ($item == '..') @@ -156,34 +164,34 @@ class Search extends DirectoryListDetailed if (stripos($mode, 'd') !== false && self::match($item, $query)) { $temp = new DirItem($dir, $item); - $this -> matches[] = $temp; - if ($temp -> __get('size') -> __get('bytes') !== false) + $this->matches[] = $temp; + if ($temp->__get('size')->__get('bytes') !== false) { - $this -> total_size -> add_size($temp -> __get('size')); + $this->total_size->add_size($temp->__get('size')); } - $this -> total_folders++; + $this->total_folders++; } $sub_search = new Search($query, $dir . $item, $mode); - $this -> merge($sub_search); + $this->merge($sub_search); } else if (stripos($mode, 'f') !== false && self::match($item, $query)) { $temp = new FileItem($dir, $item); - $this -> matches[] = $temp; - $this -> total_size -> add_size($temp -> __get('size')); - $this -> total_downloads += $temp -> __get('downloads'); - $this -> total_files++; + $this->matches[] = $temp; + $this->total_size->add_size($temp->__get('size')); + $this->total_downloads += $temp->__get('downloads'); + $this->total_files++; } } - global $words, $config, $subdir; - $link = ' ' . Url::html_output($dir) . ' '; - $this -> path_nav = $words -> __get('search results for') - . $link . $words -> __get('and its subdirectories'); - $this -> contents = $this -> matches; - unset($this -> matches); + $this->path_nav = $words->__get('search results for') + . $link . $words->__get('and its subdirectories'); + $this->contents = $this->matches; + unset($this->matches); } } -?> \ No newline at end of file +?>