@@ -26,54 +26,54 @@ |
||
| 26 | 26 | namespace OC\Template; |
| 27 | 27 | |
| 28 | 28 | class JSResourceLocator extends ResourceLocator { |
| 29 | - /** |
|
| 30 | - * @param string $script |
|
| 31 | - */ |
|
| 32 | - public function doFind($script) { |
|
| 33 | - $theme_dir = 'themes/'.$this->theme.'/'; |
|
| 34 | - if (strpos($script, '3rdparty') === 0 |
|
| 35 | - && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
| 36 | - return; |
|
| 37 | - } |
|
| 29 | + /** |
|
| 30 | + * @param string $script |
|
| 31 | + */ |
|
| 32 | + public function doFind($script) { |
|
| 33 | + $theme_dir = 'themes/'.$this->theme.'/'; |
|
| 34 | + if (strpos($script, '3rdparty') === 0 |
|
| 35 | + && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
| 36 | + return; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - if (strpos($script, '/l10n/') !== false) { |
|
| 40 | - // For language files we try to load them all, so themes can overwrite |
|
| 41 | - // single l10n strings without having to translate all of them. |
|
| 42 | - $found = 0; |
|
| 43 | - $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
| 44 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
| 45 | - $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
| 46 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
| 47 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
| 39 | + if (strpos($script, '/l10n/') !== false) { |
|
| 40 | + // For language files we try to load them all, so themes can overwrite |
|
| 41 | + // single l10n strings without having to translate all of them. |
|
| 42 | + $found = 0; |
|
| 43 | + $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
| 44 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
| 45 | + $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
| 46 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
| 47 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
| 48 | 48 | |
| 49 | - if ($found) { |
|
| 50 | - return; |
|
| 51 | - } |
|
| 52 | - } else if ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
| 53 | - || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
| 54 | - || $this->appendIfExist($this->serverroot, $script.'.js') |
|
| 55 | - || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
| 56 | - || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
| 57 | - ) { |
|
| 58 | - return; |
|
| 59 | - } |
|
| 49 | + if ($found) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 52 | + } else if ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
| 53 | + || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
| 54 | + || $this->appendIfExist($this->serverroot, $script.'.js') |
|
| 55 | + || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
| 56 | + || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
| 57 | + ) { |
|
| 58 | + return; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $app = substr($script, 0, strpos($script, '/')); |
|
| 62 | - $script = substr($script, strpos($script, '/')+1); |
|
| 63 | - $app_path = \OC_App::getAppPath($app); |
|
| 64 | - $app_url = \OC_App::getAppWebPath($app); |
|
| 61 | + $app = substr($script, 0, strpos($script, '/')); |
|
| 62 | + $script = substr($script, strpos($script, '/')+1); |
|
| 63 | + $app_path = \OC_App::getAppPath($app); |
|
| 64 | + $app_url = \OC_App::getAppWebPath($app); |
|
| 65 | 65 | |
| 66 | - // missing translations files fill be ignored |
|
| 67 | - if (strpos($script, 'l10n/') === 0) { |
|
| 68 | - $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
| 69 | - return; |
|
| 70 | - } |
|
| 71 | - $this->append($app_path, $script . '.js', $app_url); |
|
| 72 | - } |
|
| 66 | + // missing translations files fill be ignored |
|
| 67 | + if (strpos($script, 'l10n/') === 0) { |
|
| 68 | + $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
| 69 | + return; |
|
| 70 | + } |
|
| 71 | + $this->append($app_path, $script . '.js', $app_url); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @param string $script |
|
| 76 | - */ |
|
| 77 | - public function doFindTheme($script) { |
|
| 78 | - } |
|
| 74 | + /** |
|
| 75 | + * @param string $script |
|
| 76 | + */ |
|
| 77 | + public function doFindTheme($script) { |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -59,16 +59,16 @@ |
||
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $app = substr($script, 0, strpos($script, '/')); |
| 62 | - $script = substr($script, strpos($script, '/')+1); |
|
| 62 | + $script = substr($script, strpos($script, '/') + 1); |
|
| 63 | 63 | $app_path = \OC_App::getAppPath($app); |
| 64 | 64 | $app_url = \OC_App::getAppWebPath($app); |
| 65 | 65 | |
| 66 | 66 | // missing translations files fill be ignored |
| 67 | 67 | if (strpos($script, 'l10n/') === 0) { |
| 68 | - $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
| 68 | + $this->appendIfExist($app_path, $script.'.js', $app_url); |
|
| 69 | 69 | return; |
| 70 | 70 | } |
| 71 | - $this->append($app_path, $script . '.js', $app_url); |
|
| 71 | + $this->append($app_path, $script.'.js', $app_url); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -24,5 +24,5 @@ |
||
| 24 | 24 | namespace OC\Hooks; |
| 25 | 25 | |
| 26 | 26 | abstract class BasicEmitter implements Emitter { |
| 27 | - use EmitterTrait; |
|
| 27 | + use EmitterTrait; |
|
| 28 | 28 | } |
@@ -32,19 +32,19 @@ |
||
| 32 | 32 | * @package OC\Hooks |
| 33 | 33 | */ |
| 34 | 34 | interface Emitter { |
| 35 | - /** |
|
| 36 | - * @param string $scope |
|
| 37 | - * @param string $method |
|
| 38 | - * @param callable $callback |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - public function listen($scope, $method, callable $callback); |
|
| 35 | + /** |
|
| 36 | + * @param string $scope |
|
| 37 | + * @param string $method |
|
| 38 | + * @param callable $callback |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + public function listen($scope, $method, callable $callback); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param string $scope optional |
|
| 45 | - * @param string $method optional |
|
| 46 | - * @param callable $callback optional |
|
| 47 | - * @return void |
|
| 48 | - */ |
|
| 49 | - public function removeListener($scope = null, $method = null, callable $callback = null); |
|
| 43 | + /** |
|
| 44 | + * @param string $scope optional |
|
| 45 | + * @param string $method optional |
|
| 46 | + * @param callable $callback optional |
|
| 47 | + * @return void |
|
| 48 | + */ |
|
| 49 | + public function removeListener($scope = null, $method = null, callable $callback = null); |
|
| 50 | 50 | } |
@@ -24,12 +24,12 @@ |
||
| 24 | 24 | namespace OC\Hooks; |
| 25 | 25 | |
| 26 | 26 | class PublicEmitter extends BasicEmitter { |
| 27 | - /** |
|
| 28 | - * @param string $scope |
|
| 29 | - * @param string $method |
|
| 30 | - * @param array $arguments optional |
|
| 31 | - */ |
|
| 32 | - public function emit($scope, $method, array $arguments = array()) { |
|
| 33 | - parent::emit($scope, $method, $arguments); |
|
| 34 | - } |
|
| 27 | + /** |
|
| 28 | + * @param string $scope |
|
| 29 | + * @param string $method |
|
| 30 | + * @param array $arguments optional |
|
| 31 | + */ |
|
| 32 | + public function emit($scope, $method, array $arguments = array()) { |
|
| 33 | + parent::emit($scope, $method, $arguments); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -31,35 +31,35 @@ |
||
| 31 | 31 | * @package OC\Hooks |
| 32 | 32 | */ |
| 33 | 33 | abstract class ForwardingEmitter extends BasicEmitter { |
| 34 | - /** |
|
| 35 | - * @var \OC\Hooks\Emitter[] array |
|
| 36 | - */ |
|
| 37 | - private $forwardEmitters = array(); |
|
| 34 | + /** |
|
| 35 | + * @var \OC\Hooks\Emitter[] array |
|
| 36 | + */ |
|
| 37 | + private $forwardEmitters = array(); |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $scope |
|
| 41 | - * @param string $method |
|
| 42 | - * @param callable $callback |
|
| 43 | - */ |
|
| 44 | - public function listen($scope, $method, callable $callback) { |
|
| 45 | - parent::listen($scope, $method, $callback); |
|
| 46 | - foreach ($this->forwardEmitters as $emitter) { |
|
| 47 | - $emitter->listen($scope, $method, $callback); |
|
| 48 | - } |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * @param string $scope |
|
| 41 | + * @param string $method |
|
| 42 | + * @param callable $callback |
|
| 43 | + */ |
|
| 44 | + public function listen($scope, $method, callable $callback) { |
|
| 45 | + parent::listen($scope, $method, $callback); |
|
| 46 | + foreach ($this->forwardEmitters as $emitter) { |
|
| 47 | + $emitter->listen($scope, $method, $callback); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param \OC\Hooks\Emitter $emitter |
|
| 53 | - */ |
|
| 54 | - protected function forward(Emitter $emitter) { |
|
| 55 | - $this->forwardEmitters[] = $emitter; |
|
| 51 | + /** |
|
| 52 | + * @param \OC\Hooks\Emitter $emitter |
|
| 53 | + */ |
|
| 54 | + protected function forward(Emitter $emitter) { |
|
| 55 | + $this->forwardEmitters[] = $emitter; |
|
| 56 | 56 | |
| 57 | - //forward all previously connected hooks |
|
| 58 | - foreach ($this->listeners as $key => $listeners) { |
|
| 59 | - list($scope, $method) = explode('::', $key, 2); |
|
| 60 | - foreach ($listeners as $listener) { |
|
| 61 | - $emitter->listen($scope, $method, $listener); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 57 | + //forward all previously connected hooks |
|
| 58 | + foreach ($this->listeners as $key => $listeners) { |
|
| 59 | + list($scope, $method) = explode('::', $key, 2); |
|
| 60 | + foreach ($listeners as $listener) { |
|
| 61 | + $emitter->listen($scope, $method, $listener); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -24,8 +24,8 @@ |
||
| 24 | 24 | namespace OC\Hooks; |
| 25 | 25 | |
| 26 | 26 | abstract class LegacyEmitter extends BasicEmitter { |
| 27 | - protected function emit($scope, $method, array $arguments = array()) { |
|
| 28 | - \OC_Hook::emit($scope, $method, $arguments); |
|
| 29 | - parent::emit($scope, $method, $arguments); |
|
| 30 | - } |
|
| 27 | + protected function emit($scope, $method, array $arguments = array()) { |
|
| 28 | + \OC_Hook::emit($scope, $method, $arguments); |
|
| 29 | + parent::emit($scope, $method, $arguments); |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -24,80 +24,80 @@ |
||
| 24 | 24 | |
| 25 | 25 | trait EmitterTrait { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var (callable[])[] $listeners |
|
| 29 | - */ |
|
| 30 | - protected $listeners = array(); |
|
| 27 | + /** |
|
| 28 | + * @var (callable[])[] $listeners |
|
| 29 | + */ |
|
| 30 | + protected $listeners = array(); |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param string $scope |
|
| 34 | - * @param string $method |
|
| 35 | - * @param callable $callback |
|
| 36 | - */ |
|
| 37 | - public function listen($scope, $method, callable $callback) { |
|
| 38 | - $eventName = $scope . '::' . $method; |
|
| 39 | - if (!isset($this->listeners[$eventName])) { |
|
| 40 | - $this->listeners[$eventName] = array(); |
|
| 41 | - } |
|
| 42 | - if (array_search($callback, $this->listeners[$eventName], true) === false) { |
|
| 43 | - $this->listeners[$eventName][] = $callback; |
|
| 44 | - } |
|
| 45 | - } |
|
| 32 | + /** |
|
| 33 | + * @param string $scope |
|
| 34 | + * @param string $method |
|
| 35 | + * @param callable $callback |
|
| 36 | + */ |
|
| 37 | + public function listen($scope, $method, callable $callback) { |
|
| 38 | + $eventName = $scope . '::' . $method; |
|
| 39 | + if (!isset($this->listeners[$eventName])) { |
|
| 40 | + $this->listeners[$eventName] = array(); |
|
| 41 | + } |
|
| 42 | + if (array_search($callback, $this->listeners[$eventName], true) === false) { |
|
| 43 | + $this->listeners[$eventName][] = $callback; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @param string $scope optional |
|
| 49 | - * @param string $method optional |
|
| 50 | - * @param callable $callback optional |
|
| 51 | - */ |
|
| 52 | - public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
| 53 | - $names = array(); |
|
| 54 | - $allNames = array_keys($this->listeners); |
|
| 55 | - if ($scope and $method) { |
|
| 56 | - $name = $scope . '::' . $method; |
|
| 57 | - if (isset($this->listeners[$name])) { |
|
| 58 | - $names[] = $name; |
|
| 59 | - } |
|
| 60 | - } elseif ($scope) { |
|
| 61 | - foreach ($allNames as $name) { |
|
| 62 | - $parts = explode('::', $name, 2); |
|
| 63 | - if ($parts[0] == $scope) { |
|
| 64 | - $names[] = $name; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - } elseif ($method) { |
|
| 68 | - foreach ($allNames as $name) { |
|
| 69 | - $parts = explode('::', $name, 2); |
|
| 70 | - if ($parts[1] == $method) { |
|
| 71 | - $names[] = $name; |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } else { |
|
| 75 | - $names = $allNames; |
|
| 76 | - } |
|
| 47 | + /** |
|
| 48 | + * @param string $scope optional |
|
| 49 | + * @param string $method optional |
|
| 50 | + * @param callable $callback optional |
|
| 51 | + */ |
|
| 52 | + public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
| 53 | + $names = array(); |
|
| 54 | + $allNames = array_keys($this->listeners); |
|
| 55 | + if ($scope and $method) { |
|
| 56 | + $name = $scope . '::' . $method; |
|
| 57 | + if (isset($this->listeners[$name])) { |
|
| 58 | + $names[] = $name; |
|
| 59 | + } |
|
| 60 | + } elseif ($scope) { |
|
| 61 | + foreach ($allNames as $name) { |
|
| 62 | + $parts = explode('::', $name, 2); |
|
| 63 | + if ($parts[0] == $scope) { |
|
| 64 | + $names[] = $name; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + } elseif ($method) { |
|
| 68 | + foreach ($allNames as $name) { |
|
| 69 | + $parts = explode('::', $name, 2); |
|
| 70 | + if ($parts[1] == $method) { |
|
| 71 | + $names[] = $name; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } else { |
|
| 75 | + $names = $allNames; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - foreach ($names as $name) { |
|
| 79 | - if ($callback) { |
|
| 80 | - $index = array_search($callback, $this->listeners[$name], true); |
|
| 81 | - if ($index !== false) { |
|
| 82 | - unset($this->listeners[$name][$index]); |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - $this->listeners[$name] = array(); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - } |
|
| 78 | + foreach ($names as $name) { |
|
| 79 | + if ($callback) { |
|
| 80 | + $index = array_search($callback, $this->listeners[$name], true); |
|
| 81 | + if ($index !== false) { |
|
| 82 | + unset($this->listeners[$name][$index]); |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + $this->listeners[$name] = array(); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * @param string $scope |
|
| 92 | - * @param string $method |
|
| 93 | - * @param array $arguments optional |
|
| 94 | - */ |
|
| 95 | - protected function emit($scope, $method, array $arguments = array()) { |
|
| 96 | - $eventName = $scope . '::' . $method; |
|
| 97 | - if (isset($this->listeners[$eventName])) { |
|
| 98 | - foreach ($this->listeners[$eventName] as $callback) { |
|
| 99 | - call_user_func_array($callback, $arguments); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 90 | + /** |
|
| 91 | + * @param string $scope |
|
| 92 | + * @param string $method |
|
| 93 | + * @param array $arguments optional |
|
| 94 | + */ |
|
| 95 | + protected function emit($scope, $method, array $arguments = array()) { |
|
| 96 | + $eventName = $scope . '::' . $method; |
|
| 97 | + if (isset($this->listeners[$eventName])) { |
|
| 98 | + foreach ($this->listeners[$eventName] as $callback) { |
|
| 99 | + call_user_func_array($callback, $arguments); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | 103 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param callable $callback |
| 36 | 36 | */ |
| 37 | 37 | public function listen($scope, $method, callable $callback) { |
| 38 | - $eventName = $scope . '::' . $method; |
|
| 38 | + $eventName = $scope.'::'.$method; |
|
| 39 | 39 | if (!isset($this->listeners[$eventName])) { |
| 40 | 40 | $this->listeners[$eventName] = array(); |
| 41 | 41 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $names = array(); |
| 54 | 54 | $allNames = array_keys($this->listeners); |
| 55 | 55 | if ($scope and $method) { |
| 56 | - $name = $scope . '::' . $method; |
|
| 56 | + $name = $scope.'::'.$method; |
|
| 57 | 57 | if (isset($this->listeners[$name])) { |
| 58 | 58 | $names[] = $name; |
| 59 | 59 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param array $arguments optional |
| 94 | 94 | */ |
| 95 | 95 | protected function emit($scope, $method, array $arguments = array()) { |
| 96 | - $eventName = $scope . '::' . $method; |
|
| 96 | + $eventName = $scope.'::'.$method; |
|
| 97 | 97 | if (isset($this->listeners[$eventName])) { |
| 98 | 98 | foreach ($this->listeners[$eventName] as $callback) { |
| 99 | 99 | call_user_func_array($callback, $arguments); |
@@ -34,87 +34,87 @@ |
||
| 34 | 34 | * @deprecated Use \OCP\Http\Client\IClientService |
| 35 | 35 | */ |
| 36 | 36 | class HTTPHelper { |
| 37 | - const USER_AGENT = 'ownCloud Server Crawler'; |
|
| 37 | + const USER_AGENT = 'ownCloud Server Crawler'; |
|
| 38 | 38 | |
| 39 | - /** @var \OCP\IConfig */ |
|
| 40 | - private $config; |
|
| 41 | - /** @var IClientService */ |
|
| 42 | - private $clientService; |
|
| 39 | + /** @var \OCP\IConfig */ |
|
| 40 | + private $config; |
|
| 41 | + /** @var IClientService */ |
|
| 42 | + private $clientService; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param IConfig $config |
|
| 46 | - * @param IClientService $clientService |
|
| 47 | - */ |
|
| 48 | - public function __construct(IConfig $config, |
|
| 49 | - IClientService $clientService) { |
|
| 50 | - $this->config = $config; |
|
| 51 | - $this->clientService = $clientService; |
|
| 52 | - } |
|
| 44 | + /** |
|
| 45 | + * @param IConfig $config |
|
| 46 | + * @param IClientService $clientService |
|
| 47 | + */ |
|
| 48 | + public function __construct(IConfig $config, |
|
| 49 | + IClientService $clientService) { |
|
| 50 | + $this->config = $config; |
|
| 51 | + $this->clientService = $clientService; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Get URL content |
|
| 56 | - * @param string $url Url to get content |
|
| 57 | - * @throws \Exception If the URL does not start with http:// or https:// |
|
| 58 | - * @return string of the response or false on error |
|
| 59 | - * This function get the content of a page via curl, if curl is enabled. |
|
| 60 | - * If not, file_get_contents is used. |
|
| 61 | - * @deprecated Use \OCP\Http\Client\IClientService |
|
| 62 | - */ |
|
| 63 | - public function getUrlContent($url) { |
|
| 64 | - try { |
|
| 65 | - $client = $this->clientService->newClient(); |
|
| 66 | - $response = $client->get($url); |
|
| 67 | - return $response->getBody(); |
|
| 68 | - } catch (\Exception $e) { |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 71 | - } |
|
| 54 | + /** |
|
| 55 | + * Get URL content |
|
| 56 | + * @param string $url Url to get content |
|
| 57 | + * @throws \Exception If the URL does not start with http:// or https:// |
|
| 58 | + * @return string of the response or false on error |
|
| 59 | + * This function get the content of a page via curl, if curl is enabled. |
|
| 60 | + * If not, file_get_contents is used. |
|
| 61 | + * @deprecated Use \OCP\Http\Client\IClientService |
|
| 62 | + */ |
|
| 63 | + public function getUrlContent($url) { |
|
| 64 | + try { |
|
| 65 | + $client = $this->clientService->newClient(); |
|
| 66 | + $response = $client->get($url); |
|
| 67 | + return $response->getBody(); |
|
| 68 | + } catch (\Exception $e) { |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Returns the response headers of a HTTP URL without following redirects |
|
| 75 | - * @param string $location Needs to be a HTTPS or HTTP URL |
|
| 76 | - * @return array |
|
| 77 | - * @deprecated Use \OCP\Http\Client\IClientService |
|
| 78 | - */ |
|
| 79 | - public function getHeaders($location) { |
|
| 80 | - $client = $this->clientService->newClient(); |
|
| 81 | - $response = $client->get($location); |
|
| 82 | - return $response->getHeaders(); |
|
| 83 | - } |
|
| 73 | + /** |
|
| 74 | + * Returns the response headers of a HTTP URL without following redirects |
|
| 75 | + * @param string $location Needs to be a HTTPS or HTTP URL |
|
| 76 | + * @return array |
|
| 77 | + * @deprecated Use \OCP\Http\Client\IClientService |
|
| 78 | + */ |
|
| 79 | + public function getHeaders($location) { |
|
| 80 | + $client = $this->clientService->newClient(); |
|
| 81 | + $response = $client->get($location); |
|
| 82 | + return $response->getHeaders(); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Checks whether the supplied URL begins with HTTPS:// or HTTP:// (case insensitive) |
|
| 87 | - * @param string $url |
|
| 88 | - * @return bool |
|
| 89 | - */ |
|
| 90 | - public function isHTTPURL($url) { |
|
| 91 | - return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0; |
|
| 92 | - } |
|
| 85 | + /** |
|
| 86 | + * Checks whether the supplied URL begins with HTTPS:// or HTTP:// (case insensitive) |
|
| 87 | + * @param string $url |
|
| 88 | + * @return bool |
|
| 89 | + */ |
|
| 90 | + public function isHTTPURL($url) { |
|
| 91 | + return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * send http post request |
|
| 96 | - * |
|
| 97 | - * @param string $url |
|
| 98 | - * @param array $fields data send by the request |
|
| 99 | - * @return array |
|
| 100 | - * @deprecated Use \OCP\Http\Client\IClientService |
|
| 101 | - */ |
|
| 102 | - public function post($url, array $fields) { |
|
| 103 | - $client = $this->clientService->newClient(); |
|
| 94 | + /** |
|
| 95 | + * send http post request |
|
| 96 | + * |
|
| 97 | + * @param string $url |
|
| 98 | + * @param array $fields data send by the request |
|
| 99 | + * @return array |
|
| 100 | + * @deprecated Use \OCP\Http\Client\IClientService |
|
| 101 | + */ |
|
| 102 | + public function post($url, array $fields) { |
|
| 103 | + $client = $this->clientService->newClient(); |
|
| 104 | 104 | |
| 105 | - try { |
|
| 106 | - $response = $client->post( |
|
| 107 | - $url, |
|
| 108 | - [ |
|
| 109 | - 'body' => $fields, |
|
| 110 | - 'connect_timeout' => 10, |
|
| 111 | - ] |
|
| 112 | - ); |
|
| 113 | - } catch (\Exception $e) { |
|
| 114 | - return ['success' => false, 'result' => $e->getMessage()]; |
|
| 115 | - } |
|
| 105 | + try { |
|
| 106 | + $response = $client->post( |
|
| 107 | + $url, |
|
| 108 | + [ |
|
| 109 | + 'body' => $fields, |
|
| 110 | + 'connect_timeout' => 10, |
|
| 111 | + ] |
|
| 112 | + ); |
|
| 113 | + } catch (\Exception $e) { |
|
| 114 | + return ['success' => false, 'result' => $e->getMessage()]; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - return ['success' => true, 'result' => $response->getBody()]; |
|
| 118 | - } |
|
| 117 | + return ['success' => true, 'result' => $response->getBody()]; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | 120 | } |
@@ -31,88 +31,88 @@ |
||
| 31 | 31 | * this class should only be used as a reference for method signatures and their descriptions |
| 32 | 32 | */ |
| 33 | 33 | abstract class OC_Group_Example { |
| 34 | - /** |
|
| 35 | - * Try to create a new group |
|
| 36 | - * @param string $gid The name of the group to create |
|
| 37 | - * @return bool |
|
| 38 | - * |
|
| 39 | - * Tries to create a new group. If the group name already exists, false will |
|
| 40 | - * be returned. |
|
| 41 | - */ |
|
| 42 | - abstract public static function createGroup($gid); |
|
| 34 | + /** |
|
| 35 | + * Try to create a new group |
|
| 36 | + * @param string $gid The name of the group to create |
|
| 37 | + * @return bool |
|
| 38 | + * |
|
| 39 | + * Tries to create a new group. If the group name already exists, false will |
|
| 40 | + * be returned. |
|
| 41 | + */ |
|
| 42 | + abstract public static function createGroup($gid); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * delete a group |
|
| 46 | - * @param string $gid gid of the group to delete |
|
| 47 | - * @return bool |
|
| 48 | - * |
|
| 49 | - * Deletes a group and removes it from the group_user-table |
|
| 50 | - */ |
|
| 51 | - abstract public static function deleteGroup($gid); |
|
| 44 | + /** |
|
| 45 | + * delete a group |
|
| 46 | + * @param string $gid gid of the group to delete |
|
| 47 | + * @return bool |
|
| 48 | + * |
|
| 49 | + * Deletes a group and removes it from the group_user-table |
|
| 50 | + */ |
|
| 51 | + abstract public static function deleteGroup($gid); |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * is user in group? |
|
| 55 | - * @param string $uid uid of the user |
|
| 56 | - * @param string $gid gid of the group |
|
| 57 | - * @return bool |
|
| 58 | - * |
|
| 59 | - * Checks whether the user is member of a group or not. |
|
| 60 | - */ |
|
| 61 | - abstract public static function inGroup($uid, $gid); |
|
| 53 | + /** |
|
| 54 | + * is user in group? |
|
| 55 | + * @param string $uid uid of the user |
|
| 56 | + * @param string $gid gid of the group |
|
| 57 | + * @return bool |
|
| 58 | + * |
|
| 59 | + * Checks whether the user is member of a group or not. |
|
| 60 | + */ |
|
| 61 | + abstract public static function inGroup($uid, $gid); |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Add a user to a group |
|
| 65 | - * @param string $uid Name of the user to add to group |
|
| 66 | - * @param string $gid Name of the group in which add the user |
|
| 67 | - * @return bool |
|
| 68 | - * |
|
| 69 | - * Adds a user to a group. |
|
| 70 | - */ |
|
| 71 | - abstract public static function addToGroup($uid, $gid); |
|
| 63 | + /** |
|
| 64 | + * Add a user to a group |
|
| 65 | + * @param string $uid Name of the user to add to group |
|
| 66 | + * @param string $gid Name of the group in which add the user |
|
| 67 | + * @return bool |
|
| 68 | + * |
|
| 69 | + * Adds a user to a group. |
|
| 70 | + */ |
|
| 71 | + abstract public static function addToGroup($uid, $gid); |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Removes a user from a group |
|
| 75 | - * @param string $uid Name of the user to remove from group |
|
| 76 | - * @param string $gid Name of the group from which remove the user |
|
| 77 | - * @return bool |
|
| 78 | - * |
|
| 79 | - * removes the user from a group. |
|
| 80 | - */ |
|
| 81 | - abstract public static function removeFromGroup($uid, $gid); |
|
| 73 | + /** |
|
| 74 | + * Removes a user from a group |
|
| 75 | + * @param string $uid Name of the user to remove from group |
|
| 76 | + * @param string $gid Name of the group from which remove the user |
|
| 77 | + * @return bool |
|
| 78 | + * |
|
| 79 | + * removes the user from a group. |
|
| 80 | + */ |
|
| 81 | + abstract public static function removeFromGroup($uid, $gid); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Get all groups a user belongs to |
|
| 85 | - * @param string $uid Name of the user |
|
| 86 | - * @return array an array of group names |
|
| 87 | - * |
|
| 88 | - * This function fetches all groups a user belongs to. It does not check |
|
| 89 | - * if the user exists at all. |
|
| 90 | - */ |
|
| 91 | - abstract public static function getUserGroups($uid); |
|
| 83 | + /** |
|
| 84 | + * Get all groups a user belongs to |
|
| 85 | + * @param string $uid Name of the user |
|
| 86 | + * @return array an array of group names |
|
| 87 | + * |
|
| 88 | + * This function fetches all groups a user belongs to. It does not check |
|
| 89 | + * if the user exists at all. |
|
| 90 | + */ |
|
| 91 | + abstract public static function getUserGroups($uid); |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * get a list of all groups |
|
| 95 | - * @param string $search |
|
| 96 | - * @param int $limit |
|
| 97 | - * @param int $offset |
|
| 98 | - * @return array an array of group names |
|
| 99 | - */ |
|
| 100 | - abstract public static function getGroups($search = '', $limit = -1, $offset = 0); |
|
| 93 | + /** |
|
| 94 | + * get a list of all groups |
|
| 95 | + * @param string $search |
|
| 96 | + * @param int $limit |
|
| 97 | + * @param int $offset |
|
| 98 | + * @return array an array of group names |
|
| 99 | + */ |
|
| 100 | + abstract public static function getGroups($search = '', $limit = -1, $offset = 0); |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Check if a group exists |
|
| 104 | - * @param string $gid |
|
| 105 | - * @return bool |
|
| 106 | - */ |
|
| 107 | - abstract public function groupExists($gid); |
|
| 102 | + /** |
|
| 103 | + * Check if a group exists |
|
| 104 | + * @param string $gid |
|
| 105 | + * @return bool |
|
| 106 | + */ |
|
| 107 | + abstract public function groupExists($gid); |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * get a list of all users in a group |
|
| 111 | - * @param string $gid |
|
| 112 | - * @param string $search |
|
| 113 | - * @param int $limit |
|
| 114 | - * @param int $offset |
|
| 115 | - * @return array an array of user ids |
|
| 116 | - */ |
|
| 117 | - abstract public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0); |
|
| 109 | + /** |
|
| 110 | + * get a list of all users in a group |
|
| 111 | + * @param string $gid |
|
| 112 | + * @param string $search |
|
| 113 | + * @param int $limit |
|
| 114 | + * @param int $offset |
|
| 115 | + * @return array an array of user ids |
|
| 116 | + */ |
|
| 117 | + abstract public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0); |
|
| 118 | 118 | } |