[icinga-checkins] icinga.org: icingaweb2/master: Dashboard: Refactor search/ replace implementation

git at icinga.org git at icinga.org
Wed Nov 19 12:15:36 CET 2014


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Nov 11 16:04:51 2014 +0100

Dashboard: Refactor search/replace implementation

refs #4537

---

 library/Icinga/Web/Widget/Dashboard/Component.php |   26 +++++++++++++++------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php
index 1773447..46b49eb 100644
--- a/library/Icinga/Web/Widget/Dashboard/Component.php
+++ b/library/Icinga/Web/Widget/Dashboard/Component.php
@@ -175,13 +175,25 @@ EOD;
         $iframeUrl = clone($url);
         $iframeUrl->setParam('isIframe');
 
-        $html = str_replace('{URL}', $url, $this->template);
-        $html = str_replace('{IFRAME_URL}', $iframeUrl, $html);
-        $html = str_replace('{FULL_URL}', $url->getUrlWithout(array('view', 'limit')), $html);
-        $html = str_replace('{REMOVE_BTN}', $this->getRemoveForm($view), $html);
-        $html = str_replace('{TITLE}', $view->escape($this->getTitle()), $html);
-        $html = str_replace('{REMOVE}', $this->getRemoveForm(), $html);
-        return $html;
+        $searchTokens = array(
+            '{URL}',
+            '{IFRAME_URL}',
+            '{FULL_URL}',
+            '{REMOVE_BTN}',
+            '{TITLE}',
+            '{REMOVE}'
+        );
+
+        $replaceTokens = array(
+            $url,
+            $iframeUrl,
+            $url->getUrlWithout(array('view', 'limit')),
+            $this->getRemoveForm($view),
+            $view->escape($this->getTitle()),
+            $this->getRemoveForm()
+        );
+
+        return str_replace($searchTokens, $replaceTokens, $this->template);
     }
 
     /**



More information about the icinga-checkins mailing list