[icinga-checkins] icinga.org: icingaweb2/feature/doc-search-6630: doc/lib: Remove DocSearchRenderer::highlight()

git at icinga.org git at icinga.org
Wed Feb 11 13:27:43 CET 2015


Module: icingaweb2
Branch: feature/doc-search-6630
Commit: 512eb3fe8365a46d05625cd83d75c2e737119fc1
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=512eb3fe8365a46d05625cd83d75c2e737119fc1

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Wed Feb 11 13:16:14 2015 +0100

doc/lib: Remove DocSearchRenderer::highlight()

refs #6630

---

 .../doc/library/Doc/Search/DocSearchRenderer.php   |   35 ++++----------------
 1 file changed, 6 insertions(+), 29 deletions(-)

diff --git a/modules/doc/library/Doc/Search/DocSearchRenderer.php b/modules/doc/library/Doc/Search/DocSearchRenderer.php
index 97f830a..8d04cd9 100644
--- a/modules/doc/library/Doc/Search/DocSearchRenderer.php
+++ b/modules/doc/library/Doc/Search/DocSearchRenderer.php
@@ -16,13 +16,6 @@ use Icinga\Module\Doc\Renderer;
 class DocSearchRenderer extends Renderer
 {
     /**
-     * CSS class
-     *
-     * @type string
-     */
-    const HIGHLIGHT_CSS_CLASS = 'search-highlight';
-
-    /**
      * The content to render
      *
      * @type array
@@ -44,7 +37,7 @@ class DocSearchRenderer extends Renderer
      */
     public function beginIteration()
     {
-        $this->content[] = '<nav><ul>';
+        $this->content[] = '<nav role="navigation"><ul class="toc">';
     }
 
     /**
@@ -61,7 +54,7 @@ class DocSearchRenderer extends Renderer
     public function beginChildren()
     {
         if ($this->getInnerIterator()->getMatches()) {
-            $this->content[] = '<ul>';
+            $this->content[] = '<ul class="toc">';
         }
     }
 
@@ -75,22 +68,6 @@ class DocSearchRenderer extends Renderer
         }
     }
 
-    public function highlight($line, array $matches)
-    {
-        $highlighted = '';
-        $offset = 0;
-        ksort($matches);
-        foreach ($matches as $position => $match) {
-            $highlighted .= $this->getView()->escape(substr($line, $offset, $position - $offset))
-                . '<span class="' . static::HIGHLIGHT_CSS_CLASS .'">'
-                . $this->getView()->escape($match)
-                . '</span>';
-            $offset = $position + strlen($match);
-        }
-        $highlighted .= $this->getView()->escape(substr($line, $offset));
-        return $highlighted;
-    }
-
     /**
      * {@inheritdoc}
      */
@@ -104,17 +81,17 @@ class DocSearchRenderer extends Renderer
             $contentMatches = array();
             foreach ($matches as $match) {
                 if ($match->getMatchType() === DocSearchMatch::MATCH_HEADER) {
-                    $title = $this->highlight($match->getLine(), $match->getMatches());
+                    $title = $match->highlight();
                 } else {
                     $contentMatches[] = sprintf(
                         '<p>%s</p>',
-                        $this->highlight($match->getLine(), $match->getMatches())
+                        $match->highlight()
                     );
                 }
             }
             $path = $this->getView()->getHelper('Url')->url(
                 array_merge(
-                    $this->urlParams,
+                    $this->getUrlParams(),
                     array(
                         'chapter' => $this->encodeUrlParam($section->getChapter()->getId())
                     )
@@ -125,7 +102,7 @@ class DocSearchRenderer extends Renderer
             );
             $url = $this->getView()->url(
                 $path,
-                array('highlight' => $this->getInnerIterator()->getSearch()->getInput())
+                array('highlight-search' => $this->getInnerIterator()->getSearch()->getInput())
             );
             /** @type \Icinga\Web\Url $url */
             $url->setAnchor($this->encodeAnchor($section->getId()));



More information about the icinga-checkins mailing list