aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/search.php
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-12-02 17:31:04 +0100
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-12-10 15:51:59 +0100
commit1d490b559ce279f5c9f44b727fe9d71d3718a24b (patch)
tree5520065370f6874c80eb8a5be38e2b284d4e292f /lib/private/search.php
parente9029f94cb6eb9b37623ea1a2faf8aac11675900 (diff)
downloadnextcloud-server-1d490b559ce279f5c9f44b727fe9d71d3718a24b.tar.gz
nextcloud-server-1d490b559ce279f5c9f44b727fe9d71d3718a24b.zip
introduce inApps[] filter for search via ajax query, make file results show up in files app only
use more flexible return type check array with !empty instead of count
Diffstat (limited to 'lib/private/search.php')
-rw-r--r--lib/private/search.php21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/private/search.php b/lib/private/search.php
index bcaebdddd9c..8f04aa8360b 100644
--- a/lib/private/search.php
+++ b/lib/private/search.php
@@ -35,14 +35,17 @@ class Search implements ISearch {
/**
* Search all providers for $query
* @param string $query
+ * @param string[] $inApps optionally limit results to the given apps
* @return array An array of OC\Search\Result's
*/
- public function search($query) {
+ public function search($query, array $inApps = array()) {
$this->initProviders();
$results = array();
foreach($this->providers as $provider) {
/** @var $provider Provider */
- $results = array_merge($results, $provider->search($query));
+ if ($provider->providesResultsFor($inApps)) {
+ $results = array_merge($results, $provider->search($query));
+ }
}
return $results;
}
@@ -51,8 +54,8 @@ class Search implements ISearch {
* Remove all registered search providers
*/
public function clearProviders() {
- $this->providers=array();
- $this->registeredProviders=array();
+ $this->providers = array();
+ $this->registeredProviders = array();
}
/**
@@ -67,7 +70,7 @@ class Search implements ISearch {
}
);
// force regeneration of providers on next search
- $this->providers=array();
+ $this->providers = array();
}
/**
@@ -75,21 +78,21 @@ class Search implements ISearch {
* @param string $class class name of a OC\Search\Provider
* @param array $options optional
*/
- public function registerProvider($class, $options=array()) {
- $this->registeredProviders[]=array('class'=>$class, 'options'=>$options);
+ public function registerProvider($class, array $options = array()) {
+ $this->registeredProviders[] = array('class' => $class, 'options' => $options);
}
/**
* Create instances of all the registered search providers
*/
private function initProviders() {
- if(count($this->providers)>0) {
+ if( ! empty($this->providers) ) {
return;
}
foreach($this->registeredProviders as $provider) {
$class = $provider['class'];
$options = $provider['options'];
- $this->providers[]=new $class($options);
+ $this->providers[] = new $class($options);
}
}