diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2022-05-11 08:42:11 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2022-05-11 08:42:11 +0000 |
| commit | f8529970a4018ee95b52a9c3bede75f3098186b4 (patch) | |
| tree | 936a46eff8ddbdb9dfc7e1463d3f82b8cb53c3ec /lib/classes/ActionMenu.php | |
| parent | 6b3ca21b124871ca44af1584214a6eb5e907a06f (diff) | |
TIC #608
Merge request studip/studip!421
Diffstat (limited to 'lib/classes/ActionMenu.php')
| -rw-r--r-- | lib/classes/ActionMenu.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/classes/ActionMenu.php b/lib/classes/ActionMenu.php index ed6b36a..92eac8d 100644 --- a/lib/classes/ActionMenu.php +++ b/lib/classes/ActionMenu.php @@ -27,6 +27,11 @@ class ActionMenu private $condition_all = null; private $condition = true; + /** + * @var string $context The context for the action menu. + */ + protected $context = ''; + /** * Private constructur. @@ -254,6 +259,7 @@ class ActionMenu } return $action; }, $this->actions); + $template->action_menu_title = $this->generateTitle(); $template->attributes = $this->attributes; return $template->render(); } @@ -278,4 +284,37 @@ class ActionMenu } return null; } + + + /** + * Sets the context for the menu. + * + * @param string $context The context to be set. + * + * @return ActionMenu The action menu instance (to allow chaining). + */ + public function setContext(string $context) + { + $this->context = $context; + + return $this; + } + + + /** + * Generates the title of the action menu, including its context, if the context has been set. + * + * @return string The title of the action menu. + */ + public function generateTitle() : string + { + if ($this->context) { + return sprintf( + _('Aktionsmenü für %s'), + $this->context + ); + } else { + return _('Aktionsmenü'); + } + } } |
