[icinga-checkins] icinga.org: icingaweb2/master: doc: Don't use $this->_helper->viewRenderer

git at icinga.org git at icinga.org
Thu Nov 20 15:30:43 CET 2014


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

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Thu Nov 20 15:29:46 2014 +0100

doc: Don't use $this->_helper->viewRenderer

This somehow breaks our postDispatch logic. But $this->render does not.

---

 .../application/controllers/IcingawebController.php  |    6 +++---
 .../doc/application/controllers/IndexController.php  |    4 +++-
 .../doc/application/controllers/ModuleController.php |   10 +++++-----
 modules/doc/library/Doc/DocController.php            |    6 +++---
 modules/doc/library/Doc/SectionRenderer.php          |   18 ++++++++++++++++++
 5 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php
index 967a2b7..5740f50 100644
--- a/modules/doc/application/controllers/IcingawebController.php
+++ b/modules/doc/application/controllers/IcingawebController.php
@@ -13,7 +13,7 @@ class Doc_IcingawebController extends DocController
      */
     public function tocAction()
     {
-        $this->renderToc(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter');
+        return $this->renderToc(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter');
     }
 
     /**
@@ -30,7 +30,7 @@ class Doc_IcingawebController extends DocController
                 404
             );
         }
-        $this->renderChapter(
+        return $this->renderChapter(
             Icinga::app()->getApplicationDir('/../doc'),
             $chapterId,
             'doc/icingaweb/toc',
@@ -43,6 +43,6 @@ class Doc_IcingawebController extends DocController
      */
     public function pdfAction()
     {
-        $this->renderPdf(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter');
+        return $this->renderPdf(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter');
     }
 }
diff --git a/modules/doc/application/controllers/IndexController.php b/modules/doc/application/controllers/IndexController.php
index c83cfab..63b5e8c 100644
--- a/modules/doc/application/controllers/IndexController.php
+++ b/modules/doc/application/controllers/IndexController.php
@@ -6,5 +6,7 @@ use Icinga\Module\Doc\DocController;
 
 class Doc_IndexController extends DocController
 {
-    public function indexAction() {}
+    public function indexAction()
+    {
+    }
 }
diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php
index 4091336..1e9cf43 100644
--- a/modules/doc/application/controllers/ModuleController.php
+++ b/modules/doc/application/controllers/ModuleController.php
@@ -65,9 +65,10 @@ class Doc_ModuleController extends DocController
     {
         $moduleName = $this->getParam('moduleName');
         $this->assertModuleEnabled($moduleName);
+        $this->view->moduleName = $moduleName;
         $moduleManager = Icinga::app()->getModuleManager();
         try {
-            $this->renderToc(
+            return $this->renderToc(
                 $moduleManager->getModuleDir($moduleName, '/doc'),
                 $moduleName,
                 'doc/module/chapter',
@@ -76,7 +77,6 @@ class Doc_ModuleController extends DocController
         } catch (DocException $e) {
             throw new Zend_Controller_Action_Exception($e->getMessage(), 404);
         }
-        $this->view->moduleName = $moduleName;
     }
 
     /**
@@ -97,9 +97,10 @@ class Doc_ModuleController extends DocController
                 404
             );
         }
+        $this->view->moduleName = $moduleName;
         $moduleManager = Icinga::app()->getModuleManager();
         try {
-            $this->renderChapter(
+            return $this->renderChapter(
                 $moduleManager->getModuleDir($moduleName, '/doc'),
                 $chapterId,
                 $this->_helper->url->url(array('moduleName' => $moduleName), 'doc/module/toc'),
@@ -109,7 +110,6 @@ class Doc_ModuleController extends DocController
         } catch (DocException $e) {
             throw new Zend_Controller_Action_Exception($e->getMessage(), 404);
         }
-        $this->view->moduleName = $moduleName;
     }
 
     /**
@@ -122,7 +122,7 @@ class Doc_ModuleController extends DocController
         $moduleName = $this->getParam('moduleName');
         $this->assertModuleEnabled($moduleName);
         $moduleManager = Icinga::app()->getModuleManager();
-        $this->renderPdf(
+        return $this->renderPdf(
             $moduleManager->getModuleDir($moduleName, '/doc'),
             $moduleName,
             'doc/module/chapter',
diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php
index 42f8dce..bc78295 100644
--- a/modules/doc/library/Doc/DocController.php
+++ b/modules/doc/library/Doc/DocController.php
@@ -28,7 +28,7 @@ class DocController extends ModuleActionController
             $urlParams
         );
         $this->view->title = $chapterId;
-        $this->_helper->viewRenderer('chapter', null, true);
+        return $this->render('chapter', null, true);
     }
 
     /**
@@ -46,7 +46,7 @@ class DocController extends ModuleActionController
         $name = ucfirst($name);
         $this->view->docName = $name;
         $this->view->title = sprintf($this->translate('%s Documentation'), $name);
-        $this->_helper->viewRenderer('toc', null, true);
+        return $this->render('toc', null, true);
     }
 
     /**
@@ -70,7 +70,7 @@ class DocController extends ModuleActionController
             $urlParams
         );
         $this->view->docName = $name;
-        $this->_helper->viewRenderer('pdf', null, true);
         $this->_request->setParam('format', 'pdf');
+        return $this->render('pdf', null, true);
     }
 }
diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php
index 12f0f2a..2fdaf8e 100644
--- a/modules/doc/library/Doc/SectionRenderer.php
+++ b/modules/doc/library/Doc/SectionRenderer.php
@@ -181,6 +181,19 @@ class SectionRenderer extends Renderer
         return substr_replace($doc->saveXML($img), '', -2, 1);  // Replace '/>' with '>'
     }
 
+    protected function blubb($match)
+    {
+        $doc = new DOMDocument();
+        $doc->loadHTML($match[0]);
+        $xpath = new DOMXPath($doc);
+        $blockquote = $xpath->query('//blockquote[1]')->item(0);
+        /* @var $blockquote \DOMElement */
+        if (strtolower(substr(trim($blockquote->nodeValue), 0, 5)) === 'note:') {
+            $blockquote->setAttribute('class', 'note');
+        }
+        return $doc->saveXML($blockquote);
+    }
+
     /**
      * Render the section
      *
@@ -213,6 +226,11 @@ class SectionRenderer extends Renderer
                 array($this, 'replaceImg'),
                 $html
             );
+            $html = preg_replace_callback(
+                '#<blockquote>.+</blockquote>#ms',
+                array($this, 'blubb'),
+                $html
+            );
             $content[] = preg_replace_callback(
                 '/<a\s+(?P<attribs>[^>]*?\s+)?href="#(?P<fragment>[^"]+)"/',
                 array($callback, 'render'),



More information about the icinga-checkins mailing list