summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2013-08-26 14:12:06 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-06-05 19:22:22 +0200
commitafd24385a8b8a9ba75e6e0e7f3c56dfe1628991b (patch)
treeea66491be651b6b04ef50449038e2a3ac96d6e07 /lib
parenta6583d39769e48253835b28e0c2e717b9575bf5d (diff)
downloadnextcloud-server-afd24385a8b8a9ba75e6e0e7f3c56dfe1628991b.tar.gz
nextcloud-server-afd24385a8b8a9ba75e6e0e7f3c56dfe1628991b.zip
fix formatting
Diffstat (limited to 'lib')
-rw-r--r--lib/legacy/search.php11
-rw-r--r--lib/legacy/search/provider.php6
-rw-r--r--lib/legacy/search/provider/file.php6
-rw-r--r--lib/legacy/search/result.php6
-rw-r--r--lib/private/search.php11
-rw-r--r--lib/private/search/provider.php38
-rw-r--r--lib/private/search/provider/file.php69
-rw-r--r--lib/private/search/result.php70
-rw-r--r--lib/search/result/file.php159
-rw-r--r--lib/search/result/folder.php15
10 files changed, 200 insertions, 191 deletions
diff --git a/lib/legacy/search.php b/lib/legacy/search.php
index 084f9dcd6ab..61c7f167208 100644
--- a/lib/legacy/search.php
+++ b/lib/legacy/search.php
@@ -25,13 +25,13 @@
* provides an interface to all search providers
* @deprecated see lib/search.php
*/
-class OC_Search{
+class OC_Search {
static private $providers=array();
static private $registeredProviders=array();
/**
* remove all registered search providers
- * @deprecated see lib/search.php
+ * @deprecated see lib/search.php
*/
public static function clearProviders() {
return \OC\Search::clearProviders();
@@ -40,7 +40,7 @@ class OC_Search{
/**
* register a new search provider to be used
* @param string $provider class name of a OC_Search_Provider
- * @deprecated see lib/search.php
+ * @deprecated see lib/search.php
*/
public static function registerProvider($class, $options=array()) {
return \OC\Search::registerProvider($class, $options);
@@ -50,7 +50,7 @@ class OC_Search{
* search all provider for $query
* @param string query
* @return array An array of OC_Search_Result's
- * @deprecated see lib/search.php
+ * @deprecated see lib/search.php
*/
public static function search($query) {
return \OC\Search::search($query);
@@ -59,9 +59,10 @@ class OC_Search{
/**
* remove an existing search provider
* @param string $provider class name of a OC_Search_Provider
- * @deprecated see lib/search.php
+ * @deprecated see lib/search.php
*/
public static function removeProvider($provider) {
return \OC\Search::removeProvider($provider);
}
+
}
diff --git a/lib/legacy/search/provider.php b/lib/legacy/search/provider.php
index 6a5ee2dec6f..a14ae53c5d3 100644
--- a/lib/legacy/search/provider.php
+++ b/lib/legacy/search/provider.php
@@ -17,6 +17,6 @@
*
*/
-abstract class OC_Search_Provider extends \OC\Search\Provider{
-
-} \ No newline at end of file
+abstract class OC_Search_Provider extends \OC\Search\Provider {
+
+}
diff --git a/lib/legacy/search/provider/file.php b/lib/legacy/search/provider/file.php
index c113cd79d27..e610281131d 100644
--- a/lib/legacy/search/provider/file.php
+++ b/lib/legacy/search/provider/file.php
@@ -17,6 +17,6 @@
*
*/
-class OC_Search_Provider_File extends \OC\Search\Provider\File{
-
-} \ No newline at end of file
+class OC_Search_Provider_File extends \OC\Search\Provider\File {
+
+}
diff --git a/lib/legacy/search/result.php b/lib/legacy/search/result.php
index 0c7326f209a..dc8d36dbe4a 100644
--- a/lib/legacy/search/result.php
+++ b/lib/legacy/search/result.php
@@ -17,6 +17,6 @@
*
*/
-class OC_Search_Result extends \OC\Search\Result{
-
-} \ No newline at end of file
+class OC_Search_Result extends \OC\Search\Result {
+
+}
diff --git a/lib/private/search.php b/lib/private/search.php
index f3ade2683ce..966b0570135 100644
--- a/lib/private/search.php
+++ b/lib/private/search.php
@@ -25,7 +25,7 @@ namespace OC;
/**
* Provide an interface to all search providers
*/
-class Search{
+class Search {
static private $providers=array();
static private $registeredProviders=array();
@@ -58,10 +58,10 @@ class Search{
*/
public static function removeProvider($provider) {
self::$registeredProviders = array_filter(
- self::$registeredProviders,
- function ($element) use ($provider) {
- return ($element['class'] != $provider);
- }
+ self::$registeredProviders,
+ function ($element) use ($provider) {
+ return ($element['class'] != $provider);
+ }
);
// force regeneration of providers on next search
self::$providers=array();
@@ -88,4 +88,5 @@ class Search{
self::$providers[]=new $class($options);
}
}
+
}
diff --git a/lib/private/search/provider.php b/lib/private/search/provider.php
index e45d3790c3f..45d9f823c55 100644
--- a/lib/private/search/provider.php
+++ b/lib/private/search/provider.php
@@ -24,24 +24,24 @@ namespace OC\Search;
*/
abstract class Provider {
- /**
- * List of options (currently unused)
- * @var array
- */
- private $options;
+ /**
+ * List of options (currently unused)
+ * @var array
+ */
+ private $options;
- /**
- * Constructor
- * @param array $options
- */
- public function __construct($options) {
- $this->options = $options;
- }
+ /**
+ * Constructor
+ * @param array $options
+ */
+ public function __construct($options) {
+ $this->options = $options;
+ }
- /**
- * Search for $query
- * @param string $query
- * @return array An array of OC\Search\Result's
- */
- abstract public function search($query);
-} \ No newline at end of file
+ /**
+ * Search for $query
+ * @param string $query
+ * @return array An array of OC\Search\Result's
+ */
+ abstract public function search($query);
+}
diff --git a/lib/private/search/provider/file.php b/lib/private/search/provider/file.php
index 5e3fb83721e..a9082763002 100644
--- a/lib/private/search/provider/file.php
+++ b/lib/private/search/provider/file.php
@@ -22,38 +22,39 @@ namespace OC\Search\Provider;
/**
* Provide search results from the 'files' app
*/
-class File extends \OC\Search\Provider{
-
- /**
- * Search for files and folders matching the given query
- * @param string $query
- * @return \OC\Search\Result
- */
- function search($query) {
- $files = \OC\Files\Filesystem::search($query);
- $results = array();
- // edit results
- foreach ($files as $fileData) {
- // skip versions
- if (strpos($fileData['path'], '_versions') === 0) {
- continue;
- }
- // skip top-level folder
- if ($fileData['name'] == 'files' && $fileData['parent'] == -1) {
- continue;
- }
- // create folder result
- if($fileData['mimetype'] == 'httpd/unix-directory'){
- $result = new \OC\Search\Result\Folder($fileData);
- }
- // or create file result
- else{
- $result = new \OC\Search\Result\File($fileData);
- }
- // add to results
- $results[] = $result;
- }
- // return
- return $results;
- }
+class File extends \OC\Search\Provider {
+
+ /**
+ * Search for files and folders matching the given query
+ * @param string $query
+ * @return \OC\Search\Result
+ */
+ function search($query) {
+ $files = \OC\Files\Filesystem::search($query);
+ $results = array();
+ // edit results
+ foreach ($files as $fileData) {
+ // skip versions
+ if (strpos($fileData['path'], '_versions') === 0) {
+ continue;
+ }
+ // skip top-level folder
+ if ($fileData['name'] === 'files' && $fileData['parent'] === -1) {
+ continue;
+ }
+ // create folder result
+ if($fileData['mimetype'] === 'httpd/unix-directory'){
+ $result = new \OC\Search\Result\Folder($fileData);
+ }
+ // or create file result
+ else{
+ $result = new \OC\Search\Result\File($fileData);
+ }
+ // add to results
+ $results[] = $result;
+ }
+ // return
+ return $results;
+ }
+
}
diff --git a/lib/private/search/result.php b/lib/private/search/result.php
index e671aa1b609..90e7081e753 100644
--- a/lib/private/search/result.php
+++ b/lib/private/search/result.php
@@ -24,42 +24,42 @@ namespace OC\Search;
*/
abstract class Result {
- /**
- * A unique identifier for the result, usually given as the item ID in its
- * corresponding application.
- * @var string
- */
- public $id;
+ /**
+ * A unique identifier for the result, usually given as the item ID in its
+ * corresponding application.
+ * @var string
+ */
+ public $id;
- /**
- * The name of the item returned; this will be displayed in the search
- * results.
- * @var string
- */
- public $name;
+ /**
+ * The name of the item returned; this will be displayed in the search
+ * results.
+ * @var string
+ */
+ public $name;
- /**
- * URL to the application item.
- * @var string
- */
- public $link;
-
- /**
- * The type of search result returned; for consistency, name this the same
- * as the class name (e.g. \OC\Search\File -> 'file') in lowercase.
- * @var string
- */
- public $type = 'generic';
+ /**
+ * URL to the application item.
+ * @var string
+ */
+ public $link;
- /**
- * Create a new search result
- * @param string $id unique identifier from application: '[app_name]/[item_identifier_in_app]'
- * @param string $name displayed text of result
- * @param string $link URL to the result within its app
- */
- public function __construct($id = null, $name = null, $link = null) {
- $this->id = $id;
- $this->name = $name;
- $this->link = $link;
- }
+ /**
+ * The type of search result returned; for consistency, name this the same
+ * as the class name (e.g. \OC\Search\File -> 'file') in lowercase.
+ * @var string
+ */
+ public $type = 'generic';
+
+ /**
+ * Create a new search result
+ * @param string $id unique identifier from application: '[app_name]/[item_identifier_in_app]'
+ * @param string $name displayed text of result
+ * @param string $link URL to the result within its app
+ */
+ public function __construct($id = null, $name = null, $link = null) {
+ $this->id = $id;
+ $this->name = $name;
+ $this->link = $link;
+ }
}
diff --git a/lib/search/result/file.php b/lib/search/result/file.php
index b97327e00f7..0ecbc0ba1fa 100644
--- a/lib/search/result/file.php
+++ b/lib/search/result/file.php
@@ -23,87 +23,92 @@ namespace OC\Search\Result;
* A found file
*/
class File extends \OC\Search\Result {
-
- /**
- * Type name; translated in templates
- * @var string
- */
- public $type = 'file';
- /**
- * Path to file
- * @var string
- */
- public $path;
+ /**
+ * Type name; translated in templates
+ * @var string
+ */
+ public $type = 'file';
- /**
- * Size, in bytes
- * @var int
- */
- public $size;
+ /**
+ * Path to file
+ * @var string
+ */
+ public $path;
- /**
- * Date modified, in human readable form
- * @var string
- */
- public $modified;
+ /**
+ * Size, in bytes
+ * @var int
+ */
+ public $size;
- /**
- * File mime type
- * @var string
- */
- public $mime_type;
+ /**
+ * Date modified, in human readable form
+ * @var string
+ */
+ public $modified;
- /**
- * File permissions:
- *
- * @var string
- */
- public $permissions;
+ /**
+ * File mime type
+ * @var string
+ */
+ public $mime_type;
- /**
- * Create a new file search result
- * @param string $id unique identifier from application: '[app_name]/[item_identifier_in_app]'
- * @param string $name displayed text of result
- * @param string $link URL to the result within its app
- * @param array $data file data given by provider
- */
- public function __construct(array $data = null) {
- $info = pathinfo($data['path']);
- $this->id = $data['fileid'];
- $this->name = $info['basename'];
- $this->link = \OCP\Util::linkTo('files', 'index.php', array('dir' => $info['dirname'], 'file' => $info['basename']));
- $this->permissions = self::get_permissions($data['path']);
- $this->path = (strpos($data['path'], 'files') === 0) ? substr($data['path'], 5) : $data['path'];
- $this->size = $data['size'];
- $this->modified = $data['mtime'];
- $this->mime_type = $data['mimetype'];
- }
+ /**
+ * File permissions:
+ *
+ * @var string
+ */
+ public $permissions;
- /**
- * Determine permissions for a given file path
- * @param string $path
- * @return int
- */
- function get_permissions($path) {
- // add read permissions
- $permissions = \OCP\PERMISSION_READ;
- // get directory
- $fileinfo = pathinfo($path);
- $dir = $fileinfo['dirname'] . '/';
- // add update permissions
- if (\OC_Filesystem::isUpdatable($dir)) {
- $permissions |= \OCP\PERMISSION_UPDATE;
- }
- // add delete permissions
- if (\OC_Filesystem::isDeletable($dir)) {
- $permissions |= \OCP\PERMISSION_DELETE;
- }
- // add share permissions
- if (\OC_Filesystem::isSharable($dir)) {
- $permissions |= \OCP\PERMISSION_SHARE;
- }
- // return
- return $permissions;
- }
-} \ No newline at end of file
+ /**
+ * Create a new file search result
+ * @param string $id unique identifier from application: '[app_name]/[item_identifier_in_app]'
+ * @param string $name displayed text of result
+ * @param string $link URL to the result within its app
+ * @param array $data file data given by provider
+ */
+ public function __construct(array $data = null) {
+ $info = pathinfo($data['path']);
+ $this->id = $data['fileid'];
+ $this->name = $info['basename'];
+ $this->link = \OCP\Util::linkTo(
+ 'files',
+ 'index.php',
+ array('dir' => $info['dirname'], 'file' => $info['basename'])
+ );
+ $this->permissions = self::get_permissions($data['path']);
+ $this->path = (strpos($data['path'], 'files') === 0) ? substr($data['path'], 5) : $data['path'];
+ $this->size = $data['size'];
+ $this->modified = $data['mtime'];
+ $this->mime_type = $data['mimetype'];
+ }
+
+ /**
+ * Determine permissions for a given file path
+ * @param string $path
+ * @return int
+ */
+ function get_permissions($path) {
+ // add read permissions
+ $permissions = \OCP\PERMISSION_READ;
+ // get directory
+ $fileinfo = pathinfo($path);
+ $dir = $fileinfo['dirname'] . '/';
+ // add update permissions
+ if (\OC_Filesystem::isUpdatable($dir)) {
+ $permissions |= \OCP\PERMISSION_UPDATE;
+ }
+ // add delete permissions
+ if (\OC_Filesystem::isDeletable($dir)) {
+ $permissions |= \OCP\PERMISSION_DELETE;
+ }
+ // add share permissions
+ if (\OC_Filesystem::isSharable($dir)) {
+ $permissions |= \OCP\PERMISSION_SHARE;
+ }
+ // return
+ return $permissions;
+ }
+
+}
diff --git a/lib/search/result/folder.php b/lib/search/result/folder.php
index ba46b10bcc1..8346f933b4d 100644
--- a/lib/search/result/folder.php
+++ b/lib/search/result/folder.php
@@ -23,10 +23,11 @@ namespace OC\Search\Result;
* A found folder
*/
class Folder extends \OC\Search\Result\File {
-
- /**
- * Type name; translated in templates
- * @var string
- */
- public $type = 'folder';
-} \ No newline at end of file
+
+ /**
+ * Type name; translated in templates
+ * @var string
+ */
+ public $type = 'folder';
+
+}