summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-10-02 12:13:53 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-10-02 12:13:53 +0200
commitccbdcf0ab33e943e6bac45a2ae3b602ed0593103 (patch)
tree8f92688ab8a211e5770dac40bd50fbda6d954fe3 /apps
parentdaf9a63d43c9a7975b17ebee11e3fb92c431d3d7 (diff)
parente478d925c37d908046327f6f76c5ed2c5bdac313 (diff)
downloadnextcloud-server-ccbdcf0ab33e943e6bac45a2ae3b602ed0593103.tar.gz
nextcloud-server-ccbdcf0ab33e943e6bac45a2ae3b602ed0593103.zip
Merge pull request #19522 from owncloud/activity-395-less-sidebar-text
Activity 395 less sidebar text
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/activity.php38
-rw-r--r--apps/files_sharing/appinfo/app.php3
-rw-r--r--apps/files_sharing/lib/activity.php130
-rw-r--r--apps/files_sharing/tests/activity.php5
4 files changed, 139 insertions, 37 deletions
diff --git a/apps/files/lib/activity.php b/apps/files/lib/activity.php
index bf80d0cfd7c..f3bbff48640 100644
--- a/apps/files/lib/activity.php
+++ b/apps/files/lib/activity.php
@@ -145,6 +145,24 @@ class Activity implements IExtension {
}
$l = $this->getL10N($languageCode);
+
+ if ($this->activityManager->isFormattingFilteredObject()) {
+ $translation = $this->translateShort($text, $l, $params);
+ if ($translation !== false) {
+ return $translation;
+ }
+ }
+
+ return $this->translateLong($text, $l, $params);
+ }
+
+ /**
+ * @param string $text
+ * @param IL10N $l
+ * @param array $params
+ * @return bool|string
+ */
+ protected function translateLong($text, IL10N $l, array $params) {
switch ($text) {
case 'created_self':
return (string) $l->t('You created %1$s', $params);
@@ -171,6 +189,26 @@ class Activity implements IExtension {
}
/**
+ * @param string $text
+ * @param IL10N $l
+ * @param array $params
+ * @return bool|string
+ */
+ protected function translateShort($text, IL10N $l, array $params) {
+ switch ($text) {
+ case 'changed_by':
+ return (string) $l->t('Changed by %2$s', $params);
+ case 'deleted_by':
+ return (string) $l->t('Deleted by %2$s', $params);
+ case 'restored_by':
+ return (string) $l->t('Restored by %2$s', $params);
+
+ default:
+ return false;
+ }
+ }
+
+ /**
* The extension can define the type of parameters for translation
*
* Currently known types are:
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 15c0b864b08..1417dd6214b 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -70,7 +70,8 @@ $eventDispatcher->addListener(
\OC::$server->getActivityManager()->registerExtension(function() {
return new \OCA\Files_Sharing\Activity(
\OC::$server->query('L10NFactory'),
- \OC::$server->getURLGenerator()
+ \OC::$server->getURLGenerator(),
+ \OC::$server->getActivityManager()
);
});
diff --git a/apps/files_sharing/lib/activity.php b/apps/files_sharing/lib/activity.php
index 63ac2e90b2a..c5eb7d09ede 100644
--- a/apps/files_sharing/lib/activity.php
+++ b/apps/files_sharing/lib/activity.php
@@ -24,6 +24,8 @@
namespace OCA\Files_Sharing;
use OCP\Activity\IExtension;
+use OCP\Activity\IManager;
+use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
@@ -67,13 +69,18 @@ class Activity implements IExtension {
/** @var IURLGenerator */
protected $URLGenerator;
+ /** @var IManager */
+ protected $activityManager;
+
/**
* @param IFactory $languageFactory
* @param IURLGenerator $URLGenerator
+ * @param IManager $activityManager
*/
- public function __construct(IFactory $languageFactory, IURLGenerator $URLGenerator) {
+ public function __construct(IFactory $languageFactory, IURLGenerator $URLGenerator, IManager $activityManager) {
$this->languageFactory = $languageFactory;
$this->URLGenerator = $URLGenerator;
+ $this->activityManager = $activityManager;
}
protected function getL10N($languageCode = null) {
@@ -149,49 +156,102 @@ class Activity implements IExtension {
* @return string|false
*/
public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
+ if ($app !== self::FILES_SHARING_APP) {
+ return false;
+ }
+
$l = $this->getL10N($languageCode);
- if ($app === self::FILES_SHARING_APP) {
- switch ($text) {
- case self::SUBJECT_REMOTE_SHARE_RECEIVED:
- if (sizeof($params) === 2) {
- // New activity ownCloud 8.2+
- return (string) $l->t('You received a new remote share %2$s from %1$s', $params);
- }
- return (string) $l->t('You received a new remote share from %s', $params);
- case self::SUBJECT_REMOTE_SHARE_ACCEPTED:
- return (string) $l->t('%1$s accepted remote share %2$s', $params);
- case self::SUBJECT_REMOTE_SHARE_DECLINED:
- return (string) $l->t('%1$s declined remote share %2$s', $params);
- case self::SUBJECT_REMOTE_SHARE_UNSHARED:
- return (string) $l->t('%1$s unshared %2$s from you', $params);
- case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED:
- return (string) $l->t('Public shared folder %1$s was downloaded', $params);
- case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED:
- return (string) $l->t('Public shared file %1$s was downloaded', $params);
- case self::SUBJECT_SHARED_USER_SELF:
- return (string) $l->t('You shared %1$s with %2$s', $params);
- case self::SUBJECT_SHARED_GROUP_SELF:
- return (string) $l->t('You shared %1$s with group %2$s', $params);
- case self::SUBJECT_RESHARED_USER_BY:
- return (string) $l->t('%2$s shared %1$s with %3$s', $params);
- case self::SUBJECT_RESHARED_GROUP_BY:
- return (string) $l->t('%2$s shared %1$s with group %3$s', $params);
- case self::SUBJECT_RESHARED_LINK_BY:
- return (string) $l->t('%2$s shared %1$s via link', $params);
- case self::SUBJECT_SHARED_WITH_BY:
- return (string) $l->t('%2$s shared %1$s with you', $params);
- case self::SUBJECT_SHARED_LINK_SELF:
- return (string) $l->t('You shared %1$s via link', $params);
- case self::SUBJECT_SHARED_EMAIL:
- return (string) $l->t('You shared %1$s with %2$s', $params);
+ if ($this->activityManager->isFormattingFilteredObject()) {
+ $translation = $this->translateShort($text, $l, $params);
+ if ($translation !== false) {
+ return $translation;
}
}
+ return $this->translateLong($text, $l, $params);
+ }
+
+ /**
+ * @param string $text
+ * @param IL10N $l
+ * @param array $params
+ * @return bool|string
+ */
+ protected function translateLong($text, IL10N $l, array $params) {
+
+ switch ($text) {
+ case self::SUBJECT_REMOTE_SHARE_RECEIVED:
+ if (sizeof($params) === 2) {
+ // New activity ownCloud 8.2+
+ return (string) $l->t('You received a new remote share %2$s from %1$s', $params);
+ }
+ return (string) $l->t('You received a new remote share from %s', $params);
+ case self::SUBJECT_REMOTE_SHARE_ACCEPTED:
+ return (string) $l->t('%1$s accepted remote share %2$s', $params);
+ case self::SUBJECT_REMOTE_SHARE_DECLINED:
+ return (string) $l->t('%1$s declined remote share %2$s', $params);
+ case self::SUBJECT_REMOTE_SHARE_UNSHARED:
+ return (string) $l->t('%1$s unshared %2$s from you', $params);
+ case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED:
+ return (string) $l->t('Public shared folder %1$s was downloaded', $params);
+ case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED:
+ return (string) $l->t('Public shared file %1$s was downloaded', $params);
+ case self::SUBJECT_SHARED_USER_SELF:
+ return (string) $l->t('You shared %1$s with %2$s', $params);
+ case self::SUBJECT_SHARED_GROUP_SELF:
+ return (string) $l->t('You shared %1$s with group %2$s', $params);
+ case self::SUBJECT_RESHARED_USER_BY:
+ return (string) $l->t('%2$s shared %1$s with %3$s', $params);
+ case self::SUBJECT_RESHARED_GROUP_BY:
+ return (string) $l->t('%2$s shared %1$s with group %3$s', $params);
+ case self::SUBJECT_RESHARED_LINK_BY:
+ return (string) $l->t('%2$s shared %1$s via link', $params);
+ case self::SUBJECT_SHARED_WITH_BY:
+ return (string) $l->t('%2$s shared %1$s with you', $params);
+ case self::SUBJECT_SHARED_LINK_SELF:
+ return (string) $l->t('You shared %1$s via link', $params);
+ case self::SUBJECT_SHARED_EMAIL:
+ return (string) $l->t('You shared %1$s with %2$s', $params);
+ }
+
return false;
}
/**
+ * @param string $text
+ * @param IL10N $l
+ * @param array $params
+ * @return bool|string
+ */
+ protected function translateShort($text, IL10N $l, array $params) {
+ switch ($text) {
+ case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED:
+ case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED:
+ return (string) $l->t('Downloaded via public link');
+ case self::SUBJECT_SHARED_USER_SELF:
+ return (string) $l->t('Shared with %2$s', $params);
+ case self::SUBJECT_SHARED_GROUP_SELF:
+ return (string) $l->t('Shared with group %2$s', $params);
+ case self::SUBJECT_RESHARED_USER_BY:
+ return (string) $l->t('Shared with %3$s by %2$s', $params);
+ case self::SUBJECT_RESHARED_GROUP_BY:
+ return (string) $l->t('Shared with group %3$s by %2$s', $params);
+ case self::SUBJECT_RESHARED_LINK_BY:
+ return (string) $l->t('Shared via link by %2$s', $params);
+ case self::SUBJECT_SHARED_WITH_BY:
+ return (string) $l->t('Shared by %2$s', $params);
+ case self::SUBJECT_SHARED_LINK_SELF:
+ return (string) $l->t('Shared via public link');
+ case self::SUBJECT_SHARED_EMAIL:
+ return (string) $l->t('Shared with %2$s', $params);
+
+ default:
+ return false;
+ }
+ }
+
+ /**
* The extension can define the type of parameters for translation
*
* Currently known types are:
diff --git a/apps/files_sharing/tests/activity.php b/apps/files_sharing/tests/activity.php
index 53a306b70f7..f7f324cdfc3 100644
--- a/apps/files_sharing/tests/activity.php
+++ b/apps/files_sharing/tests/activity.php
@@ -36,7 +36,10 @@ class Activity extends \OCA\Files_Sharing\Tests\TestCase{
parent::setUp();
$this->activity = new \OCA\Files_Sharing\Activity(
$this->getMock('\OC\L10N\Factory'),
- $this->getMockBuilder('\OC\URLGenerator')
+ $this->getMockBuilder('\OCP\IURLGenerator')
+ ->disableOriginalConstructor()
+ ->getMock(),
+ $this->getMockBuilder('\OCP\Activity\IManager')
->disableOriginalConstructor()
->getMock()
);