diff options
author | Joas Schilling <coding@schilljs.com> | 2016-08-01 17:56:33 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2016-08-01 17:56:33 +0200 |
commit | 6aa5d674d63db69367c97e7241e7d1575ef82690 (patch) | |
tree | 74600c656ba8034fd20847cf9853d748df30d189 /apps/workflowengine/lib | |
parent | ea4c6bd28568bce811c275d46478f44455cf237d (diff) | |
download | nextcloud-server-6aa5d674d63db69367c97e7241e7d1575ef82690.tar.gz nextcloud-server-6aa5d674d63db69367c97e7241e7d1575ef82690.zip |
Translate the errors
Diffstat (limited to 'apps/workflowengine/lib')
-rw-r--r-- | apps/workflowengine/lib/Check/AbstractStringCheck.php | 15 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileMimeType.php | 5 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileSize.php | 12 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileSystemTags.php | 14 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestRemoteAddress.php | 20 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestTime.php | 15 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestURL.php | 5 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestUserAgent.php | 5 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/UserGroupMembership.php | 4 |
9 files changed, 69 insertions, 26 deletions
diff --git a/apps/workflowengine/lib/Check/AbstractStringCheck.php b/apps/workflowengine/lib/Check/AbstractStringCheck.php index 77576266fcf..0fd728e3496 100644 --- a/apps/workflowengine/lib/Check/AbstractStringCheck.php +++ b/apps/workflowengine/lib/Check/AbstractStringCheck.php @@ -23,6 +23,7 @@ namespace OCA\WorkflowEngine\Check; use OCP\Files\Storage\IStorage; +use OCP\IL10N; use OCP\WorkflowEngine\ICheck; abstract class AbstractStringCheck implements ICheck { @@ -30,6 +31,16 @@ abstract class AbstractStringCheck implements ICheck { /** @var array[] Nested array: [Pattern => [ActualValue => Regex Result]] */ protected $matches; + /** @var IL10N */ + protected $l; + + /** + * @param IL10N $l + */ + public function __construct(IL10N $l) { + $this->l = $l; + } + /** * @param IStorage $storage * @param string $path @@ -81,12 +92,12 @@ abstract class AbstractStringCheck implements ICheck { */ public function validateCheck($operator, $value) { if (!in_array($operator, ['is', '!is', 'matches', '!matches'])) { - throw new \UnexpectedValueException('Invalid operator', 1); + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); } if (in_array($operator, ['matches', '!matches']) && @preg_match($value, null) === false) { - throw new \UnexpectedValueException('Invalid regex', 2); + throw new \UnexpectedValueException($this->l->t('The given regular expression is invalid'), 2); } } diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php index c774d30a233..1de9a70a17d 100644 --- a/apps/workflowengine/lib/Check/FileMimeType.php +++ b/apps/workflowengine/lib/Check/FileMimeType.php @@ -23,6 +23,7 @@ namespace OCA\WorkflowEngine\Check; use OCP\Files\IMimeTypeDetector; +use OCP\IL10N; use OCP\IRequest; class FileMimeType extends AbstractStringCheck { @@ -37,10 +38,12 @@ class FileMimeType extends AbstractStringCheck { protected $mimeTypeDetector; /** + * @param IL10N $l * @param IRequest $request * @param IMimeTypeDetector $mimeTypeDetector */ - public function __construct(IRequest $request, IMimeTypeDetector $mimeTypeDetector) { + public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) { + parent::__construct($l); $this->request = $request; $this->mimeTypeDetector = $mimeTypeDetector; } diff --git a/apps/workflowengine/lib/Check/FileSize.php b/apps/workflowengine/lib/Check/FileSize.php index 70071757c12..1744793dec7 100644 --- a/apps/workflowengine/lib/Check/FileSize.php +++ b/apps/workflowengine/lib/Check/FileSize.php @@ -23,6 +23,7 @@ namespace OCA\WorkflowEngine\Check; use OCP\Files\Storage\IStorage; +use OCP\IL10N; use OCP\IRequest; use OCP\Util; use OCP\WorkflowEngine\ICheck; @@ -32,13 +33,18 @@ class FileSize implements ICheck { /** @var int */ protected $size; + /** @var IL10N */ + protected $l; + /** @var IRequest */ protected $request; /** + * @param IL10N $l * @param IRequest $request */ - public function __construct(IRequest $request) { + public function __construct(IL10N $l, IRequest $request) { + $this->l = $l; $this->request = $request; } @@ -80,11 +86,11 @@ class FileSize implements ICheck { */ public function validateCheck($operator, $value) { if (!in_array($operator, ['less', '!less', 'greater', '!greater'])) { - throw new \UnexpectedValueException('Invalid operator', 1); + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); } if (!preg_match('/^[0-9]+[ ]?[kmgt]?b$/i', $value)) { - throw new \UnexpectedValueException('Invalid file size', 2); + throw new \UnexpectedValueException($this->l->t('The given file size is invalid'), 2); } } diff --git a/apps/workflowengine/lib/Check/FileSystemTags.php b/apps/workflowengine/lib/Check/FileSystemTags.php index 77179631fc1..e9b5a945967 100644 --- a/apps/workflowengine/lib/Check/FileSystemTags.php +++ b/apps/workflowengine/lib/Check/FileSystemTags.php @@ -24,6 +24,7 @@ namespace OCA\WorkflowEngine\Check; use OCP\Files\Cache\ICache; use OCP\Files\Storage\IStorage; +use OCP\IL10N; use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\ISystemTagObjectMapper; use OCP\SystemTag\TagNotFoundException; @@ -37,6 +38,9 @@ class FileSystemTags implements ICheck { /** @var array */ protected $fileSystemTags; + /** @var IL10N */ + protected $l; + /** @var ISystemTagManager */ protected $systemTagManager; @@ -50,10 +54,12 @@ class FileSystemTags implements ICheck { protected $path; /** + * @param IL10N $l * @param ISystemTagManager $systemTagManager * @param ISystemTagObjectMapper $systemTagObjectMapper */ - public function __construct(ISystemTagManager $systemTagManager, ISystemTagObjectMapper $systemTagObjectMapper) { + public function __construct(IL10N $l, ISystemTagManager $systemTagManager, ISystemTagObjectMapper $systemTagObjectMapper) { + $this->l = $l; $this->systemTagManager = $systemTagManager; $this->systemTagObjectMapper = $systemTagObjectMapper; } @@ -84,15 +90,15 @@ class FileSystemTags implements ICheck { */ public function validateCheck($operator, $value) { if (!in_array($operator, ['is', '!is'])) { - throw new \UnexpectedValueException('Invalid operator', 1); + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); } try { $this->systemTagManager->getTagsByIds($value); } catch (TagNotFoundException $e) { - throw new \UnexpectedValueException('Tag does not exist', 2); + throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 2); } catch (\InvalidArgumentException $e) { - throw new \UnexpectedValueException('Tag does not exist', 3); + throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 3); } } diff --git a/apps/workflowengine/lib/Check/RequestRemoteAddress.php b/apps/workflowengine/lib/Check/RequestRemoteAddress.php index 7897fcbd9d3..de9738fb631 100644 --- a/apps/workflowengine/lib/Check/RequestRemoteAddress.php +++ b/apps/workflowengine/lib/Check/RequestRemoteAddress.php @@ -23,18 +23,24 @@ namespace OCA\WorkflowEngine\Check; use OCP\Files\Storage\IStorage; +use OCP\IL10N; use OCP\IRequest; use OCP\WorkflowEngine\ICheck; class RequestRemoteAddress implements ICheck { + /** @var IL10N */ + protected $l; + /** @var IRequest */ protected $request; /** + * @param IL10N $l * @param IRequest $request */ - public function __construct(IRequest $request) { + public function __construct(IL10N $l, IRequest $request) { + $this->l = $l; $this->request = $request; } @@ -73,27 +79,27 @@ class RequestRemoteAddress implements ICheck { */ public function validateCheck($operator, $value) { if (!in_array($operator, ['matchesIPv4', '!matchesIPv4', 'matchesIPv6', '!matchesIPv6'])) { - throw new \UnexpectedValueException('Invalid operator', 1); + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); } $decodedValue = explode('/', $value); if (sizeof($decodedValue) !== 2) { - throw new \UnexpectedValueException('Invalid IP range', 2); + throw new \UnexpectedValueException($this->l->t('The given IP range is invalid'), 2); } if (in_array($operator, ['matchesIPv4', '!matchesIPv4'])) { if (!filter_var($decodedValue[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { - throw new \UnexpectedValueException('Invalid IPv4 range', 3); + throw new \UnexpectedValueException($this->l->t('The given IP range is not valid for IPv4'), 3); } if ($decodedValue[1] > 32 || $decodedValue[1] <= 0) { - throw new \UnexpectedValueException('Invalid IPv4 range', 4); + throw new \UnexpectedValueException($this->l->t('The given IP range is not valid for IPv4'), 4); } } else { if (!filter_var($decodedValue[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - throw new \UnexpectedValueException('Invalid IPv6 range', 3); + throw new \UnexpectedValueException($this->l->t('The given IP range is not valid for IPv6'), 3); } if ($decodedValue[1] > 128 || $decodedValue[1] <= 0) { - throw new \UnexpectedValueException('Invalid IPv6 range', 4); + throw new \UnexpectedValueException($this->l->t('The given IP range is not valid for IPv6'), 4); } } } diff --git a/apps/workflowengine/lib/Check/RequestTime.php b/apps/workflowengine/lib/Check/RequestTime.php index a114819d450..2aa79e77673 100644 --- a/apps/workflowengine/lib/Check/RequestTime.php +++ b/apps/workflowengine/lib/Check/RequestTime.php @@ -24,6 +24,7 @@ namespace OCA\WorkflowEngine\Check; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\Storage\IStorage; +use OCP\IL10N; use OCP\WorkflowEngine\ICheck; class RequestTime implements ICheck { @@ -34,13 +35,17 @@ class RequestTime implements ICheck { /** @var bool[] */ protected $cachedResults; + /** @var IL10N */ + protected $l; + /** @var ITimeFactory */ protected $timeFactory; /** * @param ITimeFactory $timeFactory */ - public function __construct(ITimeFactory $timeFactory) { + public function __construct(IL10N $l, ITimeFactory $timeFactory) { + $this->l = $l; $this->timeFactory = $timeFactory; } @@ -101,24 +106,24 @@ class RequestTime implements ICheck { */ public function validateCheck($operator, $value) { if (!in_array($operator, ['in', '!in'])) { - throw new \UnexpectedValueException('Invalid operator', 1); + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); } $regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"'; $result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches); if (!$result) { - throw new \UnexpectedValueException('Invalid time limits', 2); + throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2); } $values = json_decode($value, true); $time1 = \DateTime::createFromFormat('H:i e', $values[0]); if ($time1 === false) { - throw new \UnexpectedValueException('Invalid start time given', 3); + throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3); } $time2 = \DateTime::createFromFormat('H:i e', $values[1]); if ($time2 === false) { - throw new \UnexpectedValueException('Invalid end time given', 3); + throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4); } } } diff --git a/apps/workflowengine/lib/Check/RequestURL.php b/apps/workflowengine/lib/Check/RequestURL.php index 0cae3cf7e56..36d41c101f2 100644 --- a/apps/workflowengine/lib/Check/RequestURL.php +++ b/apps/workflowengine/lib/Check/RequestURL.php @@ -22,6 +22,7 @@ namespace OCA\WorkflowEngine\Check; +use OCP\IL10N; use OCP\IRequest; class RequestURL extends AbstractStringCheck { @@ -33,9 +34,11 @@ class RequestURL extends AbstractStringCheck { protected $request; /** + * @param IL10N $l * @param IRequest $request */ - public function __construct(IRequest $request) { + public function __construct(IL10N $l, IRequest $request) { + parent::__construct($l); $this->request = $request; } diff --git a/apps/workflowengine/lib/Check/RequestUserAgent.php b/apps/workflowengine/lib/Check/RequestUserAgent.php index 241b19136a7..7a8d4a71acf 100644 --- a/apps/workflowengine/lib/Check/RequestUserAgent.php +++ b/apps/workflowengine/lib/Check/RequestUserAgent.php @@ -22,6 +22,7 @@ namespace OCA\WorkflowEngine\Check; +use OCP\IL10N; use OCP\IRequest; class RequestUserAgent extends AbstractStringCheck { @@ -30,9 +31,11 @@ class RequestUserAgent extends AbstractStringCheck { protected $request; /** + * @param IL10N $l * @param IRequest $request */ - public function __construct(IRequest $request) { + public function __construct(IL10N $l, IRequest $request) { + parent::__construct($l); $this->request = $request; } diff --git a/apps/workflowengine/lib/Check/UserGroupMembership.php b/apps/workflowengine/lib/Check/UserGroupMembership.php index 6390c57fbea..fd6ba00d092 100644 --- a/apps/workflowengine/lib/Check/UserGroupMembership.php +++ b/apps/workflowengine/lib/Check/UserGroupMembership.php @@ -89,11 +89,11 @@ class UserGroupMembership implements ICheck { */ public function validateCheck($operator, $value) { if (!in_array($operator, ['is', '!is'])) { - throw new \UnexpectedValueException($this->l->t('Operator %s is invalid', $operator), 1); + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); } if (!$this->groupManager->groupExists($value)) { - throw new \UnexpectedValueException($this->l->t('Group %s does not exist', $value), 2); + throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2); } } |