Completed
Pull Request — master (#6328)
by Blizzz
28:13 queued 13:30
created
lib/private/Security/IdentityProof/Key.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,25 +22,25 @@
 block discarded – undo
22 22
 namespace OC\Security\IdentityProof;
23 23
 
24 24
 class Key {
25
-	/** @var string */
26
-	private $publicKey;
27
-	/** @var string */
28
-	private $privateKey;
25
+    /** @var string */
26
+    private $publicKey;
27
+    /** @var string */
28
+    private $privateKey;
29 29
 
30
-	/**
31
-	 * @param string $publicKey
32
-	 * @param string $privateKey
33
-	 */
34
-	public function __construct($publicKey, $privateKey) {
35
-		$this->publicKey = $publicKey;
36
-		$this->privateKey = $privateKey;
37
-	}
30
+    /**
31
+     * @param string $publicKey
32
+     * @param string $privateKey
33
+     */
34
+    public function __construct($publicKey, $privateKey) {
35
+        $this->publicKey = $publicKey;
36
+        $this->privateKey = $privateKey;
37
+    }
38 38
 
39
-	public function getPrivate() {
40
-		return $this->privateKey;
41
-	}
39
+    public function getPrivate() {
40
+        return $this->privateKey;
41
+    }
42 42
 
43
-	public function getPublic() {
44
-		return $this->publicKey;
45
-	}
43
+    public function getPublic() {
44
+        return $this->publicKey;
45
+    }
46 46
 }
Please login to merge, or discard this patch.
lib/private/Federation/CloudIdManager.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -24,87 +24,87 @@
 block discarded – undo
24 24
 use OCP\Federation\ICloudIdManager;
25 25
 
26 26
 class CloudIdManager implements ICloudIdManager {
27
-	/**
28
-	 * @param string $cloudId
29
-	 * @return ICloudId
30
-	 * @throws \InvalidArgumentException
31
-	 */
32
-	public function resolveCloudId($cloudId) {
33
-		// TODO magic here to get the url and user instead of just splitting on @
27
+    /**
28
+     * @param string $cloudId
29
+     * @return ICloudId
30
+     * @throws \InvalidArgumentException
31
+     */
32
+    public function resolveCloudId($cloudId) {
33
+        // TODO magic here to get the url and user instead of just splitting on @
34 34
 
35
-		if (!$this->isValidCloudId($cloudId)) {
36
-			throw new \InvalidArgumentException('Invalid cloud id');
37
-		}
35
+        if (!$this->isValidCloudId($cloudId)) {
36
+            throw new \InvalidArgumentException('Invalid cloud id');
37
+        }
38 38
 
39
-		// Find the first character that is not allowed in user names
40
-		$id = $this->fixRemoteURL($cloudId);
41
-		$posSlash = strpos($id, '/');
42
-		$posColon = strpos($id, ':');
39
+        // Find the first character that is not allowed in user names
40
+        $id = $this->fixRemoteURL($cloudId);
41
+        $posSlash = strpos($id, '/');
42
+        $posColon = strpos($id, ':');
43 43
 
44
-		if ($posSlash === false && $posColon === false) {
45
-			$invalidPos = strlen($id);
46
-		} else if ($posSlash === false) {
47
-			$invalidPos = $posColon;
48
-		} else if ($posColon === false) {
49
-			$invalidPos = $posSlash;
50
-		} else {
51
-			$invalidPos = min($posSlash, $posColon);
52
-		}
44
+        if ($posSlash === false && $posColon === false) {
45
+            $invalidPos = strlen($id);
46
+        } else if ($posSlash === false) {
47
+            $invalidPos = $posColon;
48
+        } else if ($posColon === false) {
49
+            $invalidPos = $posSlash;
50
+        } else {
51
+            $invalidPos = min($posSlash, $posColon);
52
+        }
53 53
 
54
-		// Find the last @ before $invalidPos
55
-		$pos = $lastAtPos = 0;
56
-		while ($lastAtPos !== false && $lastAtPos <= $invalidPos) {
57
-			$pos = $lastAtPos;
58
-			$lastAtPos = strpos($id, '@', $pos + 1);
59
-		}
54
+        // Find the last @ before $invalidPos
55
+        $pos = $lastAtPos = 0;
56
+        while ($lastAtPos !== false && $lastAtPos <= $invalidPos) {
57
+            $pos = $lastAtPos;
58
+            $lastAtPos = strpos($id, '@', $pos + 1);
59
+        }
60 60
 
61
-		if ($pos !== false) {
62
-			$user = substr($id, 0, $pos);
63
-			$remote = substr($id, $pos + 1);
64
-			if (!empty($user) && !empty($remote)) {
65
-				return new CloudId($id, $user, $remote);
66
-			}
67
-		}
68
-		throw new \InvalidArgumentException('Invalid cloud id');
69
-	}
61
+        if ($pos !== false) {
62
+            $user = substr($id, 0, $pos);
63
+            $remote = substr($id, $pos + 1);
64
+            if (!empty($user) && !empty($remote)) {
65
+                return new CloudId($id, $user, $remote);
66
+            }
67
+        }
68
+        throw new \InvalidArgumentException('Invalid cloud id');
69
+    }
70 70
 
71
-	/**
72
-	 * @param string $user
73
-	 * @param string $remote
74
-	 * @return CloudId
75
-	 */
76
-	public function getCloudId($user, $remote) {
77
-		// TODO check what the correct url is for remote (asking the remote)
78
-		return new CloudId($user. '@' . $remote, $user, $remote);
79
-	}
71
+    /**
72
+     * @param string $user
73
+     * @param string $remote
74
+     * @return CloudId
75
+     */
76
+    public function getCloudId($user, $remote) {
77
+        // TODO check what the correct url is for remote (asking the remote)
78
+        return new CloudId($user. '@' . $remote, $user, $remote);
79
+    }
80 80
 
81
-	/**
82
-	 * Strips away a potential file names and trailing slashes:
83
-	 * - http://localhost
84
-	 * - http://localhost/
85
-	 * - http://localhost/index.php
86
-	 * - http://localhost/index.php/s/{shareToken}
87
-	 *
88
-	 * all return: http://localhost
89
-	 *
90
-	 * @param string $remote
91
-	 * @return string
92
-	 */
93
-	protected function fixRemoteURL($remote) {
94
-		$remote = str_replace('\\', '/', $remote);
95
-		if ($fileNamePosition = strpos($remote, '/index.php')) {
96
-			$remote = substr($remote, 0, $fileNamePosition);
97
-		}
98
-		$remote = rtrim($remote, '/');
81
+    /**
82
+     * Strips away a potential file names and trailing slashes:
83
+     * - http://localhost
84
+     * - http://localhost/
85
+     * - http://localhost/index.php
86
+     * - http://localhost/index.php/s/{shareToken}
87
+     *
88
+     * all return: http://localhost
89
+     *
90
+     * @param string $remote
91
+     * @return string
92
+     */
93
+    protected function fixRemoteURL($remote) {
94
+        $remote = str_replace('\\', '/', $remote);
95
+        if ($fileNamePosition = strpos($remote, '/index.php')) {
96
+            $remote = substr($remote, 0, $fileNamePosition);
97
+        }
98
+        $remote = rtrim($remote, '/');
99 99
 
100
-		return $remote;
101
-	}
100
+        return $remote;
101
+    }
102 102
 
103
-	/**
104
-	 * @param string $cloudId
105
-	 * @return bool
106
-	 */
107
-	public function isValidCloudId($cloudId) {
108
-		return strpos($cloudId, '@') !== false;
109
-	}
103
+    /**
104
+     * @param string $cloudId
105
+     * @return bool
106
+     */
107
+    public function isValidCloudId($cloudId) {
108
+        return strpos($cloudId, '@') !== false;
109
+    }
110 110
 }
Please login to merge, or discard this patch.
lib/private/Federation/CloudId.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -23,54 +23,54 @@
 block discarded – undo
23 23
 use OCP\Federation\ICloudId;
24 24
 
25 25
 class CloudId implements ICloudId {
26
-	/** @var string */
27
-	private $id;
28
-	/** @var string */
29
-	private $user;
30
-	/** @var string */
31
-	private $remote;
26
+    /** @var string */
27
+    private $id;
28
+    /** @var string */
29
+    private $user;
30
+    /** @var string */
31
+    private $remote;
32 32
 
33
-	/**
34
-	 * CloudId constructor.
35
-	 *
36
-	 * @param string $id
37
-	 * @param string $user
38
-	 * @param string $remote
39
-	 */
40
-	public function __construct($id, $user, $remote) {
41
-		$this->id = $id;
42
-		$this->user = $user;
43
-		$this->remote = $remote;
44
-	}
33
+    /**
34
+     * CloudId constructor.
35
+     *
36
+     * @param string $id
37
+     * @param string $user
38
+     * @param string $remote
39
+     */
40
+    public function __construct($id, $user, $remote) {
41
+        $this->id = $id;
42
+        $this->user = $user;
43
+        $this->remote = $remote;
44
+    }
45 45
 
46
-	/**
47
-	 * The full remote cloud id
48
-	 *
49
-	 * @return string
50
-	 */
51
-	public function getId() {
52
-		return $this->id;
53
-	}
46
+    /**
47
+     * The full remote cloud id
48
+     *
49
+     * @return string
50
+     */
51
+    public function getId() {
52
+        return $this->id;
53
+    }
54 54
 
55
-	public function getDisplayId() {
56
-		return str_replace('https://', '', str_replace('http://', '', $this->getId()));
57
-	}
55
+    public function getDisplayId() {
56
+        return str_replace('https://', '', str_replace('http://', '', $this->getId()));
57
+    }
58 58
 
59
-	/**
60
-	 * The username on the remote server
61
-	 *
62
-	 * @return string
63
-	 */
64
-	public function getUser() {
65
-		return $this->user;
66
-	}
59
+    /**
60
+     * The username on the remote server
61
+     *
62
+     * @return string
63
+     */
64
+    public function getUser() {
65
+        return $this->user;
66
+    }
67 67
 
68
-	/**
69
-	 * The base address of the remote server
70
-	 *
71
-	 * @return string
72
-	 */
73
-	public function getRemote() {
74
-		return $this->remote;
75
-	}
68
+    /**
69
+     * The base address of the remote server
70
+     *
71
+     * @return string
72
+     */
73
+    public function getRemote() {
74
+        return $this->remote;
75
+    }
76 76
 }
Please login to merge, or discard this patch.
lib/private/Log/Errorlog.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,20 +28,20 @@
 block discarded – undo
28 28
 class Errorlog {
29 29
 
30 30
 
31
-	/**
32
-	 * Init class data
33
-	 */
34
-	public static function init() {
35
-	}
31
+    /**
32
+     * Init class data
33
+     */
34
+    public static function init() {
35
+    }
36 36
 
37
-	/**
38
-	 * write a message in the log
39
-	 * @param string $app
40
-	 * @param string $message
41
-	 * @param int $level
42
-	 */
43
-	public static function write($app, $message, $level) {
44
-		error_log('[owncloud]['.$app.']['.$level.'] '.$message);
45
-	}
37
+    /**
38
+     * write a message in the log
39
+     * @param string $app
40
+     * @param string $message
41
+     * @param int $level
42
+     */
43
+    public static function write($app, $message, $level) {
44
+        error_log('[owncloud]['.$app.']['.$level.'] '.$message);
45
+    }
46 46
 }
47 47
 
Please login to merge, or discard this patch.
lib/private/Log/Syslog.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -26,31 +26,31 @@
 block discarded – undo
26 26
 namespace OC\Log;
27 27
 
28 28
 class Syslog {
29
-	static protected $levels = array(
30
-		\OCP\Util::DEBUG => LOG_DEBUG,
31
-		\OCP\Util::INFO => LOG_INFO,
32
-		\OCP\Util::WARN => LOG_WARNING,
33
-		\OCP\Util::ERROR => LOG_ERR,
34
-		\OCP\Util::FATAL => LOG_CRIT,
35
-	);
29
+    static protected $levels = array(
30
+        \OCP\Util::DEBUG => LOG_DEBUG,
31
+        \OCP\Util::INFO => LOG_INFO,
32
+        \OCP\Util::WARN => LOG_WARNING,
33
+        \OCP\Util::ERROR => LOG_ERR,
34
+        \OCP\Util::FATAL => LOG_CRIT,
35
+    );
36 36
 
37
-	/**
38
-	 * Init class data
39
-	 */
40
-	public static function init() {
41
-		openlog(\OC::$server->getSystemConfig()->getValue("syslog_tag", "ownCloud"), LOG_PID | LOG_CONS, LOG_USER);
42
-		// Close at shutdown
43
-		register_shutdown_function('closelog');
44
-	}
37
+    /**
38
+     * Init class data
39
+     */
40
+    public static function init() {
41
+        openlog(\OC::$server->getSystemConfig()->getValue("syslog_tag", "ownCloud"), LOG_PID | LOG_CONS, LOG_USER);
42
+        // Close at shutdown
43
+        register_shutdown_function('closelog');
44
+    }
45 45
 
46
-	/**
47
-	 * write a message in the log
48
-	 * @param string $app
49
-	 * @param string $message
50
-	 * @param int $level
51
-	 */
52
-	public static function write($app, $message, $level) {
53
-		$syslog_level = self::$levels[$level];
54
-		syslog($syslog_level, '{'.$app.'} '.$message);
55
-	}
46
+    /**
47
+     * write a message in the log
48
+     * @param string $app
49
+     * @param string $message
50
+     * @param int $level
51
+     */
52
+    public static function write($app, $message, $level) {
53
+        $syslog_level = self::$levels[$level];
54
+        syslog($syslog_level, '{'.$app.'} '.$message);
55
+    }
56 56
 }
Please login to merge, or discard this patch.
lib/private/Log/ErrorHandler.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -28,74 +28,74 @@
 block discarded – undo
28 28
 use OCP\ILogger;
29 29
 
30 30
 class ErrorHandler {
31
-	/** @var ILogger */
32
-	private static $logger;
31
+    /** @var ILogger */
32
+    private static $logger;
33 33
 
34
-	/**
35
-	 * remove password in URLs
36
-	 * @param string $msg
37
-	 * @return string
38
-	 */
39
-	protected static function removePassword($msg) {
40
-		return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg);
41
-	}
34
+    /**
35
+     * remove password in URLs
36
+     * @param string $msg
37
+     * @return string
38
+     */
39
+    protected static function removePassword($msg) {
40
+        return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg);
41
+    }
42 42
 
43
-	public static function register($debug=false) {
44
-		$handler = new ErrorHandler();
43
+    public static function register($debug=false) {
44
+        $handler = new ErrorHandler();
45 45
 
46
-		if ($debug) {
47
-			set_error_handler(array($handler, 'onAll'), E_ALL);
48
-			if (\OC::$CLI) {
49
-				set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
50
-			}
51
-		} else {
52
-			set_error_handler(array($handler, 'onError'));
53
-		}
54
-		register_shutdown_function(array($handler, 'onShutdown'));
55
-		set_exception_handler(array($handler, 'onException'));
56
-	}
46
+        if ($debug) {
47
+            set_error_handler(array($handler, 'onAll'), E_ALL);
48
+            if (\OC::$CLI) {
49
+                set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
50
+            }
51
+        } else {
52
+            set_error_handler(array($handler, 'onError'));
53
+        }
54
+        register_shutdown_function(array($handler, 'onShutdown'));
55
+        set_exception_handler(array($handler, 'onException'));
56
+    }
57 57
 
58
-	public static function setLogger(ILogger $logger) {
59
-		self::$logger = $logger;
60
-	}
58
+    public static function setLogger(ILogger $logger) {
59
+        self::$logger = $logger;
60
+    }
61 61
 
62
-	//Fatal errors handler
63
-	public static function onShutdown() {
64
-		$error = error_get_last();
65
-		if($error && self::$logger) {
66
-			//ob_end_clean();
67
-			$msg = $error['message'] . ' at ' . $error['file'] . '#' . $error['line'];
68
-			self::$logger->critical(self::removePassword($msg), array('app' => 'PHP'));
69
-		}
70
-	}
62
+    //Fatal errors handler
63
+    public static function onShutdown() {
64
+        $error = error_get_last();
65
+        if($error && self::$logger) {
66
+            //ob_end_clean();
67
+            $msg = $error['message'] . ' at ' . $error['file'] . '#' . $error['line'];
68
+            self::$logger->critical(self::removePassword($msg), array('app' => 'PHP'));
69
+        }
70
+    }
71 71
 
72
-	/**
73
-	 * 	Uncaught exception handler
74
-	 *
75
-	 * @param \Exception $exception
76
-	 */
77
-	public static function onException($exception) {
78
-		$class = get_class($exception);
79
-		$msg = $exception->getMessage();
80
-		$msg = "$class: $msg at " . $exception->getFile() . '#' . $exception->getLine();
81
-		self::$logger->critical(self::removePassword($msg), ['app' => 'PHP']);
82
-	}
72
+    /**
73
+     * 	Uncaught exception handler
74
+     *
75
+     * @param \Exception $exception
76
+     */
77
+    public static function onException($exception) {
78
+        $class = get_class($exception);
79
+        $msg = $exception->getMessage();
80
+        $msg = "$class: $msg at " . $exception->getFile() . '#' . $exception->getLine();
81
+        self::$logger->critical(self::removePassword($msg), ['app' => 'PHP']);
82
+    }
83 83
 
84
-	//Recoverable errors handler
85
-	public static function onError($number, $message, $file, $line) {
86
-		if (error_reporting() === 0) {
87
-			return;
88
-		}
89
-		$msg = $message . ' at ' . $file . '#' . $line;
90
-		self::$logger->error(self::removePassword($msg), array('app' => 'PHP'));
84
+    //Recoverable errors handler
85
+    public static function onError($number, $message, $file, $line) {
86
+        if (error_reporting() === 0) {
87
+            return;
88
+        }
89
+        $msg = $message . ' at ' . $file . '#' . $line;
90
+        self::$logger->error(self::removePassword($msg), array('app' => 'PHP'));
91 91
 
92
-	}
92
+    }
93 93
 
94
-	//Recoverable handler which catch all errors, warnings and notices
95
-	public static function onAll($number, $message, $file, $line) {
96
-		$msg = $message . ' at ' . $file . '#' . $line;
97
-		self::$logger->debug(self::removePassword($msg), array('app' => 'PHP'));
94
+    //Recoverable handler which catch all errors, warnings and notices
95
+    public static function onAll($number, $message, $file, $line) {
96
+        $msg = $message . ' at ' . $file . '#' . $line;
97
+        self::$logger->debug(self::removePassword($msg), array('app' => 'PHP'));
98 98
 
99
-	}
99
+    }
100 100
 
101 101
 }
Please login to merge, or discard this patch.
lib/private/Log/Rotate.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,23 +31,23 @@
 block discarded – undo
31 31
  * location and manage that with your own tools.
32 32
  */
33 33
 class Rotate extends \OC\BackgroundJob\Job {
34
-	private $max_log_size;
35
-	public function run($dummy) {
36
-		$systemConfig = \OC::$server->getSystemConfig();
37
-		$logFile = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
38
-		$this->max_log_size = \OC::$server->getConfig()->getSystemValue('log_rotate_size', false);
39
-		if ($this->max_log_size) {
40
-			$filesize = @filesize($logFile);
41
-			if ($filesize >= $this->max_log_size) {
42
-				$this->rotate($logFile);
43
-			}
44
-		}
45
-	}
34
+    private $max_log_size;
35
+    public function run($dummy) {
36
+        $systemConfig = \OC::$server->getSystemConfig();
37
+        $logFile = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
38
+        $this->max_log_size = \OC::$server->getConfig()->getSystemValue('log_rotate_size', false);
39
+        if ($this->max_log_size) {
40
+            $filesize = @filesize($logFile);
41
+            if ($filesize >= $this->max_log_size) {
42
+                $this->rotate($logFile);
43
+            }
44
+        }
45
+    }
46 46
 
47
-	protected function rotate($logfile) {
48
-		$rotatedLogfile = $logfile.'.1';
49
-		rename($logfile, $rotatedLogfile);
50
-		$msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"';
51
-		\OCP\Util::writeLog('OC\Log\Rotate', $msg, \OCP\Util::WARN);
52
-	}
47
+    protected function rotate($logfile) {
48
+        $rotatedLogfile = $logfile.'.1';
49
+        rename($logfile, $rotatedLogfile);
50
+        $msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"';
51
+        \OCP\Util::writeLog('OC\Log\Rotate', $msg, \OCP\Util::WARN);
52
+    }
53 53
 }
Please login to merge, or discard this patch.
lib/private/Search.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -34,97 +34,97 @@
 block discarded – undo
34 34
  */
35 35
 class Search implements ISearch {
36 36
 
37
-	private $providers = array();
38
-	private $registeredProviders = array();
37
+    private $providers = array();
38
+    private $registeredProviders = array();
39 39
 
40
-	/**
41
-	 * Search all providers for $query
42
-	 * @param string $query
43
-	 * @param string[] $inApps optionally limit results to the given apps
44
-	 * @return array An array of OC\Search\Result's
45
-	 */
46
-	public function search($query, array $inApps = array()) {
47
-		// old apps might assume they get all results, so we set size 0
48
-		return $this->searchPaged($query, $inApps, 1, 0);
49
-	}
40
+    /**
41
+     * Search all providers for $query
42
+     * @param string $query
43
+     * @param string[] $inApps optionally limit results to the given apps
44
+     * @return array An array of OC\Search\Result's
45
+     */
46
+    public function search($query, array $inApps = array()) {
47
+        // old apps might assume they get all results, so we set size 0
48
+        return $this->searchPaged($query, $inApps, 1, 0);
49
+    }
50 50
 
51
-	/**
52
-	 * Search all providers for $query
53
-	 * @param string $query
54
-	 * @param string[] $inApps optionally limit results to the given apps
55
-	 * @param int $page pages start at page 1
56
-	 * @param int $size, 0 = all
57
-	 * @return array An array of OC\Search\Result's
58
-	 */
59
-	public function searchPaged($query, array $inApps = array(), $page = 1, $size = 30) {
60
-		$this->initProviders();
61
-		$results = array();
62
-		foreach($this->providers as $provider) {
63
-			/** @var $provider Provider */
64
-			if ( ! $provider->providesResultsFor($inApps) ) {
65
-				continue;
66
-			}
67
-			if ($provider instanceof PagedProvider) {
68
-				$results = array_merge($results, $provider->searchPaged($query, $page, $size));
69
-			} else if ($provider instanceof Provider) {
70
-				$providerResults = $provider->search($query);
71
-				if ($size > 0) {
72
-					$slicedResults = array_slice($providerResults, ($page - 1) * $size, $size);
73
-					$results = array_merge($results, $slicedResults);
74
-				} else {
75
-					$results = array_merge($results, $providerResults);
76
-				}
77
-			} else {
78
-				\OC::$server->getLogger()->warning('Ignoring Unknown search provider', array('provider' => $provider));
79
-			}
80
-		}
81
-		return $results;
82
-	}
51
+    /**
52
+     * Search all providers for $query
53
+     * @param string $query
54
+     * @param string[] $inApps optionally limit results to the given apps
55
+     * @param int $page pages start at page 1
56
+     * @param int $size, 0 = all
57
+     * @return array An array of OC\Search\Result's
58
+     */
59
+    public function searchPaged($query, array $inApps = array(), $page = 1, $size = 30) {
60
+        $this->initProviders();
61
+        $results = array();
62
+        foreach($this->providers as $provider) {
63
+            /** @var $provider Provider */
64
+            if ( ! $provider->providesResultsFor($inApps) ) {
65
+                continue;
66
+            }
67
+            if ($provider instanceof PagedProvider) {
68
+                $results = array_merge($results, $provider->searchPaged($query, $page, $size));
69
+            } else if ($provider instanceof Provider) {
70
+                $providerResults = $provider->search($query);
71
+                if ($size > 0) {
72
+                    $slicedResults = array_slice($providerResults, ($page - 1) * $size, $size);
73
+                    $results = array_merge($results, $slicedResults);
74
+                } else {
75
+                    $results = array_merge($results, $providerResults);
76
+                }
77
+            } else {
78
+                \OC::$server->getLogger()->warning('Ignoring Unknown search provider', array('provider' => $provider));
79
+            }
80
+        }
81
+        return $results;
82
+    }
83 83
 
84
-	/**
85
-	 * Remove all registered search providers
86
-	 */
87
-	public function clearProviders() {
88
-		$this->providers = array();
89
-		$this->registeredProviders = array();
90
-	}
84
+    /**
85
+     * Remove all registered search providers
86
+     */
87
+    public function clearProviders() {
88
+        $this->providers = array();
89
+        $this->registeredProviders = array();
90
+    }
91 91
 
92
-	/**
93
-	 * Remove one existing search provider
94
-	 * @param string $provider class name of a OC\Search\Provider
95
-	 */
96
-	public function removeProvider($provider) {
97
-		$this->registeredProviders = array_filter(
98
-			$this->registeredProviders,
99
-			function ($element) use ($provider) {
100
-				return ($element['class'] != $provider);
101
-			}
102
-		);
103
-		// force regeneration of providers on next search
104
-		$this->providers = array();
105
-	}
92
+    /**
93
+     * Remove one existing search provider
94
+     * @param string $provider class name of a OC\Search\Provider
95
+     */
96
+    public function removeProvider($provider) {
97
+        $this->registeredProviders = array_filter(
98
+            $this->registeredProviders,
99
+            function ($element) use ($provider) {
100
+                return ($element['class'] != $provider);
101
+            }
102
+        );
103
+        // force regeneration of providers on next search
104
+        $this->providers = array();
105
+    }
106 106
 
107
-	/**
108
-	 * Register a new search provider to search with
109
-	 * @param string $class class name of a OC\Search\Provider
110
-	 * @param array $options optional
111
-	 */
112
-	public function registerProvider($class, array $options = array()) {
113
-		$this->registeredProviders[] = array('class' => $class, 'options' => $options);
114
-	}
107
+    /**
108
+     * Register a new search provider to search with
109
+     * @param string $class class name of a OC\Search\Provider
110
+     * @param array $options optional
111
+     */
112
+    public function registerProvider($class, array $options = array()) {
113
+        $this->registeredProviders[] = array('class' => $class, 'options' => $options);
114
+    }
115 115
 
116
-	/**
117
-	 * Create instances of all the registered search providers
118
-	 */
119
-	private function initProviders() {
120
-		if( ! empty($this->providers) ) {
121
-			return;
122
-		}
123
-		foreach($this->registeredProviders as $provider) {
124
-			$class = $provider['class'];
125
-			$options = $provider['options'];
126
-			$this->providers[] = new $class($options);
127
-		}
128
-	}
116
+    /**
117
+     * Create instances of all the registered search providers
118
+     */
119
+    private function initProviders() {
120
+        if( ! empty($this->providers) ) {
121
+            return;
122
+        }
123
+        foreach($this->registeredProviders as $provider) {
124
+            $class = $provider['class'];
125
+            $options = $provider['options'];
126
+            $this->providers[] = new $class($options);
127
+        }
128
+    }
129 129
 
130 130
 }
Please login to merge, or discard this patch.
lib/private/Http/Client/Response.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -32,51 +32,51 @@
 block discarded – undo
32 32
  * @package OC\Http
33 33
  */
34 34
 class Response implements IResponse {
35
-	/** @var GuzzleResponse */
36
-	private $response;
35
+    /** @var GuzzleResponse */
36
+    private $response;
37 37
 
38
-	/**
39
-	 * @var bool
40
-	 */
41
-	private $stream;
38
+    /**
39
+     * @var bool
40
+     */
41
+    private $stream;
42 42
 
43
-	/**
44
-	 * @param GuzzleResponse $response
45
-	 * @param bool $stream
46
-	 */
47
-	public function __construct(GuzzleResponse $response, $stream = false) {
48
-		$this->response = $response;
49
-		$this->stream = $stream;
50
-	}
43
+    /**
44
+     * @param GuzzleResponse $response
45
+     * @param bool $stream
46
+     */
47
+    public function __construct(GuzzleResponse $response, $stream = false) {
48
+        $this->response = $response;
49
+        $this->stream = $stream;
50
+    }
51 51
 
52
-	/**
53
-	 * @return string|resource
54
-	 */
55
-	public function getBody() {
56
-		return $this->stream ?
57
-			$this->response->getBody()->detach():
58
-			$this->response->getBody()->getContents();
59
-	}
52
+    /**
53
+     * @return string|resource
54
+     */
55
+    public function getBody() {
56
+        return $this->stream ?
57
+            $this->response->getBody()->detach():
58
+            $this->response->getBody()->getContents();
59
+    }
60 60
 
61
-	/**
62
-	 * @return int
63
-	 */
64
-	public function getStatusCode() {
65
-		return $this->response->getStatusCode();
66
-	}
61
+    /**
62
+     * @return int
63
+     */
64
+    public function getStatusCode() {
65
+        return $this->response->getStatusCode();
66
+    }
67 67
 
68
-	/**
69
-	 * @param $key
70
-	 * @return string
71
-	 */
72
-	public function getHeader($key) {
73
-		return $this->response->getHeader($key);
74
-	}
68
+    /**
69
+     * @param $key
70
+     * @return string
71
+     */
72
+    public function getHeader($key) {
73
+        return $this->response->getHeader($key);
74
+    }
75 75
 
76
-	/**
77
-	 * @return array
78
-	 */
79
-	public function getHeaders() {
80
-		return $this->response->getHeaders();
81
-	}
76
+    /**
77
+     * @return array
78
+     */
79
+    public function getHeaders() {
80
+        return $this->response->getHeaders();
81
+    }
82 82
 }
Please login to merge, or discard this patch.