From 1b18554aa7e0af7e13ba8c088375750ea2f53d6c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Dec 2014 14:54:50 +0100 Subject: [PATCH] Allow extensions to specify the list of special parameters --- lib/private/activitymanager.php | 19 +++++++++++++++++++ lib/public/activity/iextension.php | 13 +++++++++++++ lib/public/activity/imanager.php | 7 +++++++ 3 files changed, 39 insertions(+) diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php index e0ee7c1b05..70bd227b41 100644 --- a/lib/private/activitymanager.php +++ b/lib/private/activitymanager.php @@ -167,6 +167,25 @@ class ActivityManager implements IManager { return false; } + /** + * @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 e78ae0043a..1b405ad8d3 100644 --- a/lib/public/activity/iextension.php +++ b/lib/public/activity/iextension.php @@ -79,6 +79,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 0a49fdf499..a08670be4b 100644 --- a/lib/public/activity/imanager.php +++ b/lib/public/activity/imanager.php @@ -99,6 +99,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