@@ -21,62 +21,62 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | return [ |
| 24 | - 'routes' => [ |
|
| 25 | - [ |
|
| 26 | - 'name' => 'RateLimitTest#userAndAnonProtected', |
|
| 27 | - 'url' => '/userAndAnonProtected', |
|
| 28 | - 'verb' => 'GET', |
|
| 29 | - ], |
|
| 30 | - [ |
|
| 31 | - 'name' => 'RateLimitTest#onlyAnonProtected', |
|
| 32 | - 'url' => '/anonProtected', |
|
| 33 | - 'verb' => 'GET', |
|
| 34 | - ], |
|
| 35 | - ], |
|
| 24 | + 'routes' => [ |
|
| 25 | + [ |
|
| 26 | + 'name' => 'RateLimitTest#userAndAnonProtected', |
|
| 27 | + 'url' => '/userAndAnonProtected', |
|
| 28 | + 'verb' => 'GET', |
|
| 29 | + ], |
|
| 30 | + [ |
|
| 31 | + 'name' => 'RateLimitTest#onlyAnonProtected', |
|
| 32 | + 'url' => '/anonProtected', |
|
| 33 | + 'verb' => 'GET', |
|
| 34 | + ], |
|
| 35 | + ], |
|
| 36 | 36 | |
| 37 | - 'ocs' => [ |
|
| 38 | - [ |
|
| 39 | - 'name' => 'Config#setAppValue', |
|
| 40 | - 'url' => '/api/v1/app/{appid}/{configkey}', |
|
| 41 | - 'verb' => 'POST', |
|
| 42 | - ], |
|
| 43 | - [ |
|
| 44 | - 'name' => 'Config#deleteAppValue', |
|
| 45 | - 'url' => '/api/v1/app/{appid}/{configkey}', |
|
| 46 | - 'verb' => 'DELETE', |
|
| 47 | - ], |
|
| 48 | - [ |
|
| 49 | - 'name' => 'Locking#isLockingEnabled', |
|
| 50 | - 'url' => '/api/v1/lockprovisioning', |
|
| 51 | - 'verb' => 'GET', |
|
| 52 | - ], |
|
| 53 | - [ |
|
| 54 | - 'name' => 'Locking#isLocked', |
|
| 55 | - 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
| 56 | - 'verb' => 'GET', |
|
| 57 | - ], |
|
| 58 | - [ |
|
| 59 | - 'name' => 'Locking#acquireLock', |
|
| 60 | - 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
| 61 | - 'verb' => 'POST', |
|
| 62 | - ], |
|
| 63 | - [ |
|
| 64 | - 'name' => 'Locking#changeLock', |
|
| 65 | - 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
| 66 | - 'verb' => 'PUT', |
|
| 67 | - ], |
|
| 68 | - [ |
|
| 69 | - 'name' => 'Locking#releaseLock', |
|
| 70 | - 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
| 71 | - 'verb' => 'DELETE', |
|
| 72 | - ], |
|
| 73 | - [ |
|
| 74 | - 'name' => 'Locking#releaseAll', |
|
| 75 | - 'url' => '/api/v1/lockprovisioning/{type}', |
|
| 76 | - 'verb' => 'DELETE', |
|
| 77 | - 'defaults' => [ |
|
| 78 | - 'type' => null |
|
| 79 | - ] |
|
| 80 | - ], |
|
| 81 | - ], |
|
| 37 | + 'ocs' => [ |
|
| 38 | + [ |
|
| 39 | + 'name' => 'Config#setAppValue', |
|
| 40 | + 'url' => '/api/v1/app/{appid}/{configkey}', |
|
| 41 | + 'verb' => 'POST', |
|
| 42 | + ], |
|
| 43 | + [ |
|
| 44 | + 'name' => 'Config#deleteAppValue', |
|
| 45 | + 'url' => '/api/v1/app/{appid}/{configkey}', |
|
| 46 | + 'verb' => 'DELETE', |
|
| 47 | + ], |
|
| 48 | + [ |
|
| 49 | + 'name' => 'Locking#isLockingEnabled', |
|
| 50 | + 'url' => '/api/v1/lockprovisioning', |
|
| 51 | + 'verb' => 'GET', |
|
| 52 | + ], |
|
| 53 | + [ |
|
| 54 | + 'name' => 'Locking#isLocked', |
|
| 55 | + 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
| 56 | + 'verb' => 'GET', |
|
| 57 | + ], |
|
| 58 | + [ |
|
| 59 | + 'name' => 'Locking#acquireLock', |
|
| 60 | + 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
| 61 | + 'verb' => 'POST', |
|
| 62 | + ], |
|
| 63 | + [ |
|
| 64 | + 'name' => 'Locking#changeLock', |
|
| 65 | + 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
| 66 | + 'verb' => 'PUT', |
|
| 67 | + ], |
|
| 68 | + [ |
|
| 69 | + 'name' => 'Locking#releaseLock', |
|
| 70 | + 'url' => '/api/v1/lockprovisioning/{type}/{user}', |
|
| 71 | + 'verb' => 'DELETE', |
|
| 72 | + ], |
|
| 73 | + [ |
|
| 74 | + 'name' => 'Locking#releaseAll', |
|
| 75 | + 'url' => '/api/v1/lockprovisioning/{type}', |
|
| 76 | + 'verb' => 'DELETE', |
|
| 77 | + 'defaults' => [ |
|
| 78 | + 'type' => null |
|
| 79 | + ] |
|
| 80 | + ], |
|
| 81 | + ], |
|
| 82 | 82 | ]; |
@@ -32,14 +32,14 @@ |
||
| 32 | 32 | * @since 9.1.0 |
| 33 | 33 | */ |
| 34 | 34 | class OCSNotFoundException extends OCSException { |
| 35 | - /** |
|
| 36 | - * OCSNotFoundException constructor. |
|
| 37 | - * |
|
| 38 | - * @param string $message |
|
| 39 | - * @param Exception|null $previous |
|
| 40 | - * @since 9.1.0 |
|
| 41 | - */ |
|
| 42 | - public function __construct($message = '', Exception $previous = null) { |
|
| 43 | - parent::__construct($message, Http::STATUS_NOT_FOUND, $previous); |
|
| 44 | - } |
|
| 35 | + /** |
|
| 36 | + * OCSNotFoundException constructor. |
|
| 37 | + * |
|
| 38 | + * @param string $message |
|
| 39 | + * @param Exception|null $previous |
|
| 40 | + * @since 9.1.0 |
|
| 41 | + */ |
|
| 42 | + public function __construct($message = '', Exception $previous = null) { |
|
| 43 | + parent::__construct($message, Http::STATUS_NOT_FOUND, $previous); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -32,14 +32,14 @@ |
||
| 32 | 32 | * @since 9.1.0 |
| 33 | 33 | */ |
| 34 | 34 | class OCSForbiddenException extends OCSException { |
| 35 | - /** |
|
| 36 | - * OCSForbiddenException constructor. |
|
| 37 | - * |
|
| 38 | - * @param string $message |
|
| 39 | - * @param Exception|null $previous |
|
| 40 | - * @since 9.1.0 |
|
| 41 | - */ |
|
| 42 | - public function __construct($message = '', Exception $previous = null) { |
|
| 43 | - parent::__construct($message, Http::STATUS_FORBIDDEN, $previous); |
|
| 44 | - } |
|
| 35 | + /** |
|
| 36 | + * OCSForbiddenException constructor. |
|
| 37 | + * |
|
| 38 | + * @param string $message |
|
| 39 | + * @param Exception|null $previous |
|
| 40 | + * @since 9.1.0 |
|
| 41 | + */ |
|
| 42 | + public function __construct($message = '', Exception $previous = null) { |
|
| 43 | + parent::__construct($message, Http::STATUS_FORBIDDEN, $previous); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -32,14 +32,14 @@ |
||
| 32 | 32 | * @since 9.1.0 |
| 33 | 33 | */ |
| 34 | 34 | class OCSBadRequestException extends OCSException { |
| 35 | - /** |
|
| 36 | - * OCSBadRequestException constructor. |
|
| 37 | - * |
|
| 38 | - * @param string $message |
|
| 39 | - * @param Exception|null $previous |
|
| 40 | - * @since 9.1.0 |
|
| 41 | - */ |
|
| 42 | - public function __construct($message = '', Exception $previous = null) { |
|
| 43 | - parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous); |
|
| 44 | - } |
|
| 35 | + /** |
|
| 36 | + * OCSBadRequestException constructor. |
|
| 37 | + * |
|
| 38 | + * @param string $message |
|
| 39 | + * @param Exception|null $previous |
|
| 40 | + * @since 9.1.0 |
|
| 41 | + */ |
|
| 42 | + public function __construct($message = '', Exception $previous = null) { |
|
| 43 | + parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | public function __construct($arguments) { |
| 51 | 51 | $this->user = $arguments['user']; |
| 52 | 52 | $datadir = $this->user->getHome(); |
| 53 | - $this->id = 'home::' . $this->user->getUID(); |
|
| 53 | + $this->id = 'home::'.$this->user->getUID(); |
|
| 54 | 54 | |
| 55 | 55 | parent::__construct(['datadir' => $datadir]); |
| 56 | 56 | } |
@@ -33,80 +33,80 @@ |
||
| 33 | 33 | * Specialized version of Local storage for home directory usage |
| 34 | 34 | */ |
| 35 | 35 | class Home extends Local implements \OCP\Files\IHomeStorage { |
| 36 | - /** |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 39 | - protected $id; |
|
| 36 | + /** |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | + protected $id; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var \OC\User\User $user |
|
| 43 | - */ |
|
| 44 | - protected $user; |
|
| 41 | + /** |
|
| 42 | + * @var \OC\User\User $user |
|
| 43 | + */ |
|
| 44 | + protected $user; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Construct a Home storage instance |
|
| 48 | - * |
|
| 49 | - * @param array $arguments array with "user" containing the |
|
| 50 | - * storage owner |
|
| 51 | - */ |
|
| 52 | - public function __construct($arguments) { |
|
| 53 | - $this->user = $arguments['user']; |
|
| 54 | - $datadir = $this->user->getHome(); |
|
| 55 | - $this->id = 'home::' . $this->user->getUID(); |
|
| 46 | + /** |
|
| 47 | + * Construct a Home storage instance |
|
| 48 | + * |
|
| 49 | + * @param array $arguments array with "user" containing the |
|
| 50 | + * storage owner |
|
| 51 | + */ |
|
| 52 | + public function __construct($arguments) { |
|
| 53 | + $this->user = $arguments['user']; |
|
| 54 | + $datadir = $this->user->getHome(); |
|
| 55 | + $this->id = 'home::' . $this->user->getUID(); |
|
| 56 | 56 | |
| 57 | - parent::__construct(['datadir' => $datadir]); |
|
| 58 | - } |
|
| 57 | + parent::__construct(['datadir' => $datadir]); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - public function getId() { |
|
| 61 | - return $this->id; |
|
| 62 | - } |
|
| 60 | + public function getId() { |
|
| 61 | + return $this->id; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @return \OC\Files\Cache\HomeCache |
|
| 66 | - */ |
|
| 67 | - public function getCache($path = '', $storage = null) { |
|
| 68 | - if (!$storage) { |
|
| 69 | - $storage = $this; |
|
| 70 | - } |
|
| 71 | - if (!isset($this->cache)) { |
|
| 72 | - $this->cache = new \OC\Files\Cache\HomeCache($storage); |
|
| 73 | - } |
|
| 74 | - return $this->cache; |
|
| 75 | - } |
|
| 64 | + /** |
|
| 65 | + * @return \OC\Files\Cache\HomeCache |
|
| 66 | + */ |
|
| 67 | + public function getCache($path = '', $storage = null) { |
|
| 68 | + if (!$storage) { |
|
| 69 | + $storage = $this; |
|
| 70 | + } |
|
| 71 | + if (!isset($this->cache)) { |
|
| 72 | + $this->cache = new \OC\Files\Cache\HomeCache($storage); |
|
| 73 | + } |
|
| 74 | + return $this->cache; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * get a propagator instance for the cache |
|
| 79 | - * |
|
| 80 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
| 81 | - * @return \OC\Files\Cache\Propagator |
|
| 82 | - */ |
|
| 83 | - public function getPropagator($storage = null) { |
|
| 84 | - if (!$storage) { |
|
| 85 | - $storage = $this; |
|
| 86 | - } |
|
| 87 | - if (!isset($this->propagator)) { |
|
| 88 | - $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection()); |
|
| 89 | - } |
|
| 90 | - return $this->propagator; |
|
| 91 | - } |
|
| 77 | + /** |
|
| 78 | + * get a propagator instance for the cache |
|
| 79 | + * |
|
| 80 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
| 81 | + * @return \OC\Files\Cache\Propagator |
|
| 82 | + */ |
|
| 83 | + public function getPropagator($storage = null) { |
|
| 84 | + if (!$storage) { |
|
| 85 | + $storage = $this; |
|
| 86 | + } |
|
| 87 | + if (!isset($this->propagator)) { |
|
| 88 | + $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection()); |
|
| 89 | + } |
|
| 90 | + return $this->propagator; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Returns the owner of this home storage |
|
| 96 | - * |
|
| 97 | - * @return \OC\User\User owner of this home storage |
|
| 98 | - */ |
|
| 99 | - public function getUser() { |
|
| 100 | - return $this->user; |
|
| 101 | - } |
|
| 94 | + /** |
|
| 95 | + * Returns the owner of this home storage |
|
| 96 | + * |
|
| 97 | + * @return \OC\User\User owner of this home storage |
|
| 98 | + */ |
|
| 99 | + public function getUser() { |
|
| 100 | + return $this->user; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * get the owner of a path |
|
| 105 | - * |
|
| 106 | - * @param string $path The path to get the owner |
|
| 107 | - * @return string uid or false |
|
| 108 | - */ |
|
| 109 | - public function getOwner($path) { |
|
| 110 | - return $this->user->getUID(); |
|
| 111 | - } |
|
| 103 | + /** |
|
| 104 | + * get the owner of a path |
|
| 105 | + * |
|
| 106 | + * @param string $path The path to get the owner |
|
| 107 | + * @return string uid or false |
|
| 108 | + */ |
|
| 109 | + public function getOwner($path) { |
|
| 110 | + return $this->user->getUID(); |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -31,33 +31,33 @@ |
||
| 31 | 31 | |
| 32 | 32 | class EMailProvider implements IProvider { |
| 33 | 33 | |
| 34 | - /** @var IActionFactory */ |
|
| 35 | - private $actionFactory; |
|
| 36 | - |
|
| 37 | - /** @var IURLGenerator */ |
|
| 38 | - private $urlGenerator; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @param IActionFactory $actionFactory |
|
| 42 | - * @param IURLGenerator $urlGenerator |
|
| 43 | - */ |
|
| 44 | - public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) { |
|
| 45 | - $this->actionFactory = $actionFactory; |
|
| 46 | - $this->urlGenerator = $urlGenerator; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param IEntry $entry |
|
| 51 | - */ |
|
| 52 | - public function process(IEntry $entry) { |
|
| 53 | - $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
| 54 | - foreach ($entry->getEMailAddresses() as $address) { |
|
| 55 | - if (empty($address)) { |
|
| 56 | - // Skip |
|
| 57 | - continue; |
|
| 58 | - } |
|
| 59 | - $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address); |
|
| 60 | - $entry->addAction($action); |
|
| 61 | - } |
|
| 62 | - } |
|
| 34 | + /** @var IActionFactory */ |
|
| 35 | + private $actionFactory; |
|
| 36 | + |
|
| 37 | + /** @var IURLGenerator */ |
|
| 38 | + private $urlGenerator; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param IActionFactory $actionFactory |
|
| 42 | + * @param IURLGenerator $urlGenerator |
|
| 43 | + */ |
|
| 44 | + public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) { |
|
| 45 | + $this->actionFactory = $actionFactory; |
|
| 46 | + $this->urlGenerator = $urlGenerator; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param IEntry $entry |
|
| 51 | + */ |
|
| 52 | + public function process(IEntry $entry) { |
|
| 53 | + $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
| 54 | + foreach ($entry->getEMailAddresses() as $address) { |
|
| 55 | + if (empty($address)) { |
|
| 56 | + // Skip |
|
| 57 | + continue; |
|
| 58 | + } |
|
| 59 | + $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address); |
|
| 60 | + $entry->addAction($action); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | * @package OC\AppFramework\Middleware\Security\Exceptions |
| 33 | 33 | */ |
| 34 | 34 | class StrictCookieMissingException extends SecurityException { |
| 35 | - public function __construct() { |
|
| 36 | - parent::__construct('Strict Cookie has not been found in request.', Http::STATUS_PRECONDITION_FAILED); |
|
| 37 | - } |
|
| 35 | + public function __construct() { |
|
| 36 | + parent::__construct('Strict Cookie has not been found in request.', Http::STATUS_PRECONDITION_FAILED); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -29,40 +29,40 @@ |
||
| 29 | 29 | |
| 30 | 30 | class FedAuth extends AbstractBasic { |
| 31 | 31 | |
| 32 | - /** @var DbHandler */ |
|
| 33 | - private $db; |
|
| 32 | + /** @var DbHandler */ |
|
| 33 | + private $db; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * FedAuth constructor. |
|
| 37 | - * |
|
| 38 | - * @param DbHandler $db |
|
| 39 | - */ |
|
| 40 | - public function __construct(DbHandler $db) { |
|
| 41 | - $this->db = $db; |
|
| 42 | - $this->principalPrefix = 'principals/system/'; |
|
| 35 | + /** |
|
| 36 | + * FedAuth constructor. |
|
| 37 | + * |
|
| 38 | + * @param DbHandler $db |
|
| 39 | + */ |
|
| 40 | + public function __construct(DbHandler $db) { |
|
| 41 | + $this->db = $db; |
|
| 42 | + $this->principalPrefix = 'principals/system/'; |
|
| 43 | 43 | |
| 44 | - // setup realm |
|
| 45 | - $defaults = new \OCP\Defaults(); |
|
| 46 | - $this->realm = $defaults->getName(); |
|
| 47 | - } |
|
| 44 | + // setup realm |
|
| 45 | + $defaults = new \OCP\Defaults(); |
|
| 46 | + $this->realm = $defaults->getName(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Validates a username and password |
|
| 51 | - * |
|
| 52 | - * This method should return true or false depending on if login |
|
| 53 | - * succeeded. |
|
| 54 | - * |
|
| 55 | - * @param string $username |
|
| 56 | - * @param string $password |
|
| 57 | - * @return bool |
|
| 58 | - */ |
|
| 59 | - protected function validateUserPass($username, $password) { |
|
| 60 | - return $this->db->auth($username, $password); |
|
| 61 | - } |
|
| 49 | + /** |
|
| 50 | + * Validates a username and password |
|
| 51 | + * |
|
| 52 | + * This method should return true or false depending on if login |
|
| 53 | + * succeeded. |
|
| 54 | + * |
|
| 55 | + * @param string $username |
|
| 56 | + * @param string $password |
|
| 57 | + * @return bool |
|
| 58 | + */ |
|
| 59 | + protected function validateUserPass($username, $password) { |
|
| 60 | + return $this->db->auth($username, $password); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @inheritdoc |
|
| 65 | - */ |
|
| 66 | - public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
| 67 | - } |
|
| 63 | + /** |
|
| 64 | + * @inheritdoc |
|
| 65 | + */ |
|
| 66 | + public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -61,8 +61,7 @@ |
||
| 61 | 61 | $fn = $this->l10n->getPluralFormFunction(); |
| 62 | 62 | $id = $fn($this->count); |
| 63 | 63 | $text = $translations[$this->text][$id]; |
| 64 | - } |
|
| 65 | - else{ |
|
| 64 | + } else{ |
|
| 66 | 65 | $text = $translations[$this->text]; |
| 67 | 66 | } |
| 68 | 67 | } |
@@ -29,59 +29,59 @@ |
||
| 29 | 29 | namespace OC\L10N; |
| 30 | 30 | |
| 31 | 31 | class L10NString implements \JsonSerializable { |
| 32 | - /** @var \OC\L10N\L10N */ |
|
| 33 | - protected $l10n; |
|
| 32 | + /** @var \OC\L10N\L10N */ |
|
| 33 | + protected $l10n; |
|
| 34 | 34 | |
| 35 | - /** @var string */ |
|
| 36 | - protected $text; |
|
| 35 | + /** @var string */ |
|
| 36 | + protected $text; |
|
| 37 | 37 | |
| 38 | - /** @var array */ |
|
| 39 | - protected $parameters; |
|
| 38 | + /** @var array */ |
|
| 39 | + protected $parameters; |
|
| 40 | 40 | |
| 41 | - /** @var integer */ |
|
| 42 | - protected $count; |
|
| 41 | + /** @var integer */ |
|
| 42 | + protected $count; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param \OC\L10N\L10N $l10n |
|
| 46 | - * @param string|string[] $text |
|
| 47 | - * @param array $parameters |
|
| 48 | - * @param int $count |
|
| 49 | - */ |
|
| 50 | - public function __construct(\OC\L10N\L10N $l10n, $text, $parameters, $count = 1) { |
|
| 51 | - $this->l10n = $l10n; |
|
| 52 | - $this->text = $text; |
|
| 53 | - $this->parameters = $parameters; |
|
| 54 | - $this->count = $count; |
|
| 55 | - } |
|
| 44 | + /** |
|
| 45 | + * @param \OC\L10N\L10N $l10n |
|
| 46 | + * @param string|string[] $text |
|
| 47 | + * @param array $parameters |
|
| 48 | + * @param int $count |
|
| 49 | + */ |
|
| 50 | + public function __construct(\OC\L10N\L10N $l10n, $text, $parameters, $count = 1) { |
|
| 51 | + $this->l10n = $l10n; |
|
| 52 | + $this->text = $text; |
|
| 53 | + $this->parameters = $parameters; |
|
| 54 | + $this->count = $count; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public function __toString() { |
|
| 61 | - $translations = $this->l10n->getTranslations(); |
|
| 57 | + /** |
|
| 58 | + * @return string |
|
| 59 | + */ |
|
| 60 | + public function __toString() { |
|
| 61 | + $translations = $this->l10n->getTranslations(); |
|
| 62 | 62 | |
| 63 | - $text = $this->text; |
|
| 64 | - if(array_key_exists($this->text, $translations)) { |
|
| 65 | - if(is_array($translations[$this->text])) { |
|
| 66 | - $fn = $this->l10n->getPluralFormFunction(); |
|
| 67 | - $id = $fn($this->count); |
|
| 68 | - $text = $translations[$this->text][$id]; |
|
| 69 | - } |
|
| 70 | - else{ |
|
| 71 | - $text = $translations[$this->text]; |
|
| 72 | - } |
|
| 73 | - } |
|
| 63 | + $text = $this->text; |
|
| 64 | + if(array_key_exists($this->text, $translations)) { |
|
| 65 | + if(is_array($translations[$this->text])) { |
|
| 66 | + $fn = $this->l10n->getPluralFormFunction(); |
|
| 67 | + $id = $fn($this->count); |
|
| 68 | + $text = $translations[$this->text][$id]; |
|
| 69 | + } |
|
| 70 | + else{ |
|
| 71 | + $text = $translations[$this->text]; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - // Replace %n first (won't interfere with vsprintf) |
|
| 76 | - $text = str_replace('%n', (string)$this->count, $text); |
|
| 77 | - return vsprintf($text, $this->parameters); |
|
| 78 | - } |
|
| 75 | + // Replace %n first (won't interfere with vsprintf) |
|
| 76 | + $text = str_replace('%n', (string)$this->count, $text); |
|
| 77 | + return vsprintf($text, $this->parameters); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @return string |
|
| 83 | - */ |
|
| 84 | - public function jsonSerialize() { |
|
| 85 | - return $this->__toString(); |
|
| 86 | - } |
|
| 81 | + /** |
|
| 82 | + * @return string |
|
| 83 | + */ |
|
| 84 | + public function jsonSerialize() { |
|
| 85 | + return $this->__toString(); |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -56,19 +56,19 @@ |
||
| 56 | 56 | $translations = $this->l10n->getTranslations(); |
| 57 | 57 | |
| 58 | 58 | $text = $this->text; |
| 59 | - if(array_key_exists($this->text, $translations)) { |
|
| 60 | - if(is_array($translations[$this->text])) { |
|
| 59 | + if (array_key_exists($this->text, $translations)) { |
|
| 60 | + if (is_array($translations[$this->text])) { |
|
| 61 | 61 | $fn = $this->l10n->getPluralFormFunction(); |
| 62 | 62 | $id = $fn($this->count); |
| 63 | 63 | $text = $translations[$this->text][$id]; |
| 64 | 64 | } |
| 65 | - else{ |
|
| 65 | + else { |
|
| 66 | 66 | $text = $translations[$this->text]; |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // Replace %n first (won't interfere with vsprintf) |
| 71 | - $text = str_replace('%n', (string)$this->count, $text); |
|
| 71 | + $text = str_replace('%n', (string) $this->count, $text); |
|
| 72 | 72 | return vsprintf($text, $this->parameters); |
| 73 | 73 | } |
| 74 | 74 | |