summaryrefslogtreecommitdiffstats
path: root/lib/search.php
diff options
context:
space:
mode:
authorJakob Sack <kde@jakobsack.de>2011-07-29 21:03:53 +0200
committerJakob Sack <kde@jakobsack.de>2011-07-29 21:03:53 +0200
commit2ff8d7a8bc067901ecbc64599b86d1b325f5fe98 (patch)
tree7523d0e4bde9a9c691112a71e2b0fe4c6904c078 /lib/search.php
parent2bfad189e7e9c8ea78e4b5f78c9e779074dd991c (diff)
downloadnextcloud-server-2ff8d7a8bc067901ecbc64599b86d1b325f5fe98.tar.gz
nextcloud-server-2ff8d7a8bc067901ecbc64599b86d1b325f5fe98.zip
One class per file!
Diffstat (limited to 'lib/search.php')
-rw-r--r--lib/search.php75
1 files changed, 2 insertions, 73 deletions
diff --git a/lib/search.php b/lib/search.php
index ef82e225f3d..cb5e5eee78b 100644
--- a/lib/search.php
+++ b/lib/search.php
@@ -29,7 +29,7 @@ class OC_SEARCH{
/**
* register a new search provider to be used
- * @param OC_SearchProvider $provider
+ * @param OC_Search_Provider $provider
*/
public static function registerProvider($provider){
self::$providers[]=$provider;
@@ -38,7 +38,7 @@ class OC_SEARCH{
/**
* search all provider for $query
* @param string query
- * @return array An array of OC_SearchResult's
+ * @return array An array of OC_Search_Result's
*/
public static function search($query){
$results=array();
@@ -48,74 +48,3 @@ class OC_SEARCH{
return $results;
}
}
-
-/**
- * provides search functionalty
- */
-abstract class OC_SearchProvider{
- public function __construct(){
- OC_SEARCH::registerProvider($this);
- }
-
- /**
- * search for $query
- * @param string $query
- * @return array An array of OC_SearchResult's
- */
- abstract function search($query);
-}
-
-/**
- * a result of a search
- */
-class OC_SearchResult{
- private $name;
- private $text;
- private $link;
- private $type;
-
- /**
- * create a new search result
- * @param string $name short name for the result
- * @param string $text some more information about the result
- * @param string $link link for the result
- * @param string $type the type of result as human readable string ('File', 'Music', etc)
- */
- public function __construct($name,$text,$link,$type){
- $this->name=$name;
- $this->text=$text;
- $this->link=$link;
- $this->type=$type;
- }
-
- public function __get($name){
- switch($name){
- case 'name':
- return $this->name;
- case 'text':
- return $this->text;
- case 'link':
- return $this->link;
- case 'type':
- return $this->type;
- }
- }
-}
-
-class OC_FileSearchProvider extends OC_SearchProvider{
- function search($query){
- $files=OC_FILESYSTEM::search($query);
- $results=array();
- foreach($files as $file){
- if(OC_FILESYSTEM::is_dir($file)){
- $results[]=new OC_SearchResult(basename($file),$file,OC_HELPER::linkTo( 'files', 'index.php?dir='.$file ),'Files');
- }else{
- $results[]=new OC_SearchResult(basename($file),$file,OC_HELPER::linkTo( 'files', 'download.php?file='.$file ),'Files');
- }
- }
- return $results;
- }
-}
-
-new OC_FileSearchProvider();
-?> \ No newline at end of file