diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-12-12 13:03:26 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-12-12 13:03:26 +0100 |
commit | 4f92e4a233a4235cddf7260818fbdf09f67aec49 (patch) | |
tree | 7753d5b48df089cb4effeaebd01ee130dc713009 | |
parent | ffd5e93f70c5e866d0b1207896c98cef44da9ce6 (diff) | |
parent | 46def69574e15b4ec3230c7e6131b882397e210c (diff) | |
download | nextcloud-server-4f92e4a233a4235cddf7260818fbdf09f67aec49.tar.gz nextcloud-server-4f92e4a233a4235cddf7260818fbdf09f67aec49.zip |
Merge pull request #12808 from owncloud/add-special-parameterlist-to-manager
Add special parameterlist to manager
-rw-r--r-- | apps/files_sharing/lib/activity.php | 37 | ||||
-rw-r--r-- | lib/private/activitymanager.php | 19 | ||||
-rw-r--r-- | lib/public/activity/iextension.php | 13 | ||||
-rw-r--r-- | lib/public/activity/imanager.php | 7 | ||||
-rw-r--r-- | tests/lib/activitymanager.php | 20 |
5 files changed, 93 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/activity.php b/apps/files_sharing/lib/activity.php index 0f7e8ab9b63..979df1c1da6 100644 --- a/apps/files_sharing/lib/activity.php +++ b/apps/files_sharing/lib/activity.php @@ -94,16 +94,47 @@ class Activity implements \OCP\Activity\IExtension { case self::SUBJECT_REMOTE_SHARE_RECEIVED: return $l->t('You received a new remote share from %s', $params)->__toString(); case self::SUBJECT_REMOTE_SHARE_ACCEPTED: - return $l->t('%1$s accepted remote share <strong>%2$s</strong>', $params)->__toString(); + return $l->t('%1$s accepted remote share %2$s', $params)->__toString(); case self::SUBJECT_REMOTE_SHARE_DECLINED: - return $l->t('%1$s declined remote share <strong>%2$s</strong>', $params)->__toString(); + return $l->t('%1$s declined remote share %2$s', $params)->__toString(); case self::SUBJECT_REMOTE_SHARE_UNSHARED: - return $l->t('%1$s unshared <strong>%2$s</strong>', $params)->__toString(); + return $l->t('%1$s unshared %2$s', $params)->__toString(); } } } /** + * The extension can define the type of parameters for translation + * + * Currently known types are: + * * file => will strip away the path of the file and add a tooltip with it + * * username => will add the avatar of the user + * + * @param string $app + * @param string $text + * @return array|false + */ + public function getSpecialParameterList($app, $text) { + if ($app === 'files_sharing') { + switch ($text) { + case self::SUBJECT_REMOTE_SHARE_RECEIVED: + return array( + 0 => '',// We can not use 'username' since the user is in a different ownCloud + ); + case self::SUBJECT_REMOTE_SHARE_ACCEPTED: + case self::SUBJECT_REMOTE_SHARE_DECLINED: + case self::SUBJECT_REMOTE_SHARE_UNSHARED: + return array( + 0 => '',// We can not use 'username' since the user is in a different ownCloud + 1 => 'file', + ); + } + } + + return false; + } + + /** * A string naming the css class for the icon to be used can be returned. * If no icon is known for the given type false is to be returned. * diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php index e0ee7c1b055..70bd227b417 100644 --- a/lib/private/activitymanager.php +++ b/lib/private/activitymanager.php @@ -168,6 +168,25 @@ class ActivityManager implements IManager { } /** + * @param string $app + * @param string $text + * @return array|false + */ + function getSpecialParameterList($app, $text) { + foreach($this->extensions as $extension) { + $c = $extension(); + if ($c instanceof IExtension) { + $specialParameter = $c->getSpecialParameterList($app, $text); + if (is_array($specialParameter)) { + return $specialParameter; + } + } + } + + return false; + } + + /** * @param string $type * @return string */ diff --git a/lib/public/activity/iextension.php b/lib/public/activity/iextension.php index e78ae0043a6..1b405ad8d3d 100644 --- a/lib/public/activity/iextension.php +++ b/lib/public/activity/iextension.php @@ -80,6 +80,19 @@ interface IExtension { public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode); /** + * The extension can define the type of parameters for translation + * + * Currently known types are: + * * file => will strip away the path of the file and add a tooltip with it + * * username => will add the avatar of the user + * + * @param string $app + * @param string $text + * @return array|false + */ + function getSpecialParameterList($app, $text); + + /** * A string naming the css class for the icon to be used can be returned. * If no icon is known for the given type false is to be returned. * diff --git a/lib/public/activity/imanager.php b/lib/public/activity/imanager.php index 0a49fdf4999..a08670be4b0 100644 --- a/lib/public/activity/imanager.php +++ b/lib/public/activity/imanager.php @@ -100,6 +100,13 @@ interface IManager { function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode); /** + * @param string $app + * @param string $text + * @return array|false + */ + function getSpecialParameterList($app, $text); + + /** * @param string $type * @return string */ diff --git a/tests/lib/activitymanager.php b/tests/lib/activitymanager.php index 0683eb68193..6a5af7b259b 100644 --- a/tests/lib/activitymanager.php +++ b/tests/lib/activitymanager.php @@ -59,6 +59,14 @@ class Test_ActivityManager extends \Test\TestCase { $this->assertFalse($result); } + public function testGetSpecialParameterList() { + $result = $this->activityManager->getSpecialParameterList('APP0', ''); + $this->assertEquals(array(0 => 'file', 1 => 'username'), $result); + + $result = $this->activityManager->getSpecialParameterList('APP1', ''); + $this->assertFalse($result); + } + public function testTypeIcon() { $result = $this->activityManager->getTypeIcon('NT1'); $this->assertEquals('icon-nt-one', $result); @@ -132,6 +140,14 @@ class SimpleExtension implements \OCP\Activity\IExtension { return false; } + public function getSpecialParameterList($app, $text) { + if ($app === 'APP0') { + return array(0 => 'file', 1 => 'username'); + } + + return false; + } + public function getTypeIcon($type) { if ($type === 'NT1') { return 'icon-nt-one'; @@ -185,6 +201,10 @@ class NoOpExtension implements \OCP\Activity\IExtension { return false; } + public function getSpecialParameterList($app, $text) { + return false; + } + public function getTypeIcon($type) { return false; } |