diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-02-09 09:20:11 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-27 12:25:52 +0100 |
commit | 4f83462f6788b863bdeaa1e29c344dfc7550698c (patch) | |
tree | f4605abaacd08a176d4ed37383ec7240d2ffa766 /lib | |
parent | faeb277ece50f5c2d9016ad881b6eed74efd4f48 (diff) | |
download | nextcloud-server-4f83462f6788b863bdeaa1e29c344dfc7550698c.tar.gz nextcloud-server-4f83462f6788b863bdeaa1e29c344dfc7550698c.zip |
Add phpdoc, typehints and sanitize HTML
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/AppFramework/Http/Template/SimpleMenuAction.php | 74 |
1 files changed, 69 insertions, 5 deletions
diff --git a/lib/public/AppFramework/Http/Template/SimpleMenuAction.php b/lib/public/AppFramework/Http/Template/SimpleMenuAction.php index c5cbd9a032c..087887eed51 100644 --- a/lib/public/AppFramework/Http/Template/SimpleMenuAction.php +++ b/lib/public/AppFramework/Http/Template/SimpleMenuAction.php @@ -23,18 +23,43 @@ namespace OCP\AppFramework\Http\Template; -use OCP\AppFramework\Http\Template\IMenuAction; -use Twig_Environment; +use OCP\Util; +/** + * Class SimpleMenuAction + * + * @package OCP\AppFramework\Http\Template + */ class SimpleMenuAction implements IMenuAction { + /** @var string */ private $id; + + /** @var string */ private $label; + + /** @var string */ private $icon; + + /** @var string */ private $link; - private $priority = 100; + + /** @var int */ + private $priority; + + /** @var string */ private $detail; + /** + * SimpleMenuAction constructor. + * + * @param string $id + * @param string $label + * @param string $icon + * @param string $link + * @param int $priority + * @param string $detail + */ public function __construct(string $id, string $label, string $icon, string $link = '', int $priority = 100, string $detail = '') { $this->id = $id; $this->label = $label; @@ -44,53 +69,92 @@ class SimpleMenuAction implements IMenuAction { $this->detail = $detail; } + /** + * @param string $id + */ public function setId(string $id) { $this->id = $id; } + /** + * @param string $label + */ public function setLabel(string $label) { $this->label = $label; } + /** + * @param string $detail + */ public function setDetail(string $detail) { $this->detail = $detail; } + /** + * @param string $icon + */ public function setIcon(string $icon) { $this->icon = $icon; } + /** + * @param string $link + */ public function setLink(string $link) { $this->link = $link; } + /** + * @param int $priority + */ public function setPriority(int $priority) { $this->priority = $priority; } + /** + * @return string + */ public function getId(): string { return $this->id; } + /** + * @return string + */ public function getLabel(): string { return $this->label; } + /** + * @return string + */ public function getIcon(): string { return $this->icon; } + /** + * @return string + */ public function getLink(): string { return $this->link; } + /** + * @return int + */ public function getPriority(): int { return $this->priority; } + /** + * @return string + */ public function render(): string { - $detailContent = ($this->detail !== '') ? ' <span class="download-size">(' . $this->detail . ')</span>' : ''; - return sprintf('<li><a href="%s"><span class="icon %s"></span>%s %s</a></li>', $this->link, $this->icon, $this->label, $detailContent); + $detailContent = ($this->detail !== '') ? ' <span class="download-size">(' . Util::sanitizeHTML($this->detail) . ')</span>' : ''; + return sprintf( + '<li><a href="%s"><span class="icon %s"></span>%s %s</a></li>', + Util::sanitizeHTML($this->link), Util::sanitizeHTML($this->icon), Util::sanitizeHTML($this->label), Util::sanitizeHTML($detailContent) + ); } }
\ No newline at end of file |