[icinga-checkins] icinga.org: icingaweb2/master: Add Help decorator for icon help description

git at icinga.org git at icinga.org
Tue Nov 18 15:00:11 CET 2014


Module: icingaweb2
Branch: master
Commit: 4a4fbaee8e239ccdfd79a23dde13b4202a90d5f5
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=4a4fbaee8e239ccdfd79a23dde13b4202a90d5f5

Author: Alexander Fuhr <alexander.fuhr at netways.de>
Date:   Tue Nov 18 14:58:05 2014 +0100

Add Help decorator for icon help description

refs #7696

---

 library/Icinga/Web/Form/Decorator/Help.php |   33 ++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/library/Icinga/Web/Form/Decorator/Help.php b/library/Icinga/Web/Form/Decorator/Help.php
new file mode 100644
index 0000000..1f8df2c
--- /dev/null
+++ b/library/Icinga/Web/Form/Decorator/Help.php
@@ -0,0 +1,33 @@
+<?php
+// {{{ICINGA_LICENSE_HEADER}}}
+// {{{ICINGA_LICENSE_HEADER}}}
+
+namespace Icinga\Web\Form\Decorator;
+
+use Icinga\Application\Icinga;
+use Zend_Form_Decorator_Abstract;
+
+/**
+ * A decorator that will display the description as a help icon
+ */
+class Help extends Zend_Form_Decorator_Abstract
+{
+    /**
+     * Render a description and show it as a help icon
+     *
+     * @param  string $content
+     * @return string
+     */
+    public function render($content = '')
+    {
+        $element = $this->getElement();
+        $description = $element->getView()->escape($element->getDescription());
+
+        if (! empty($description)) {
+            $helpIcon = Icinga::app()->getViewRenderer()->view->icon('help', $description);
+            return $helpIcon . $content;
+        }
+
+        return  $content;
+    }
+}



More information about the icinga-checkins mailing list