From 55b3a5384a5e2ed89a974eadc6b454ac14ea5ab8 Mon Sep 17 00:00:00 2001
From: Eric Lippmann <eric.lippmann@netways.de>
Date: Tue, 19 Aug 2014 13:38:18 +0200
Subject: [PATCH] doc: set page title

refs #4820
---
 modules/doc/application/views/scripts/toc.phtml |  2 +-
 modules/doc/library/Doc/DocController.php       |  3 +++
 modules/doc/library/Doc/SectionRenderer.php     | 15 ++++++++-------
 modules/doc/public/css/module.less              | 10 ++++++++++
 4 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/modules/doc/application/views/scripts/toc.phtml b/modules/doc/application/views/scripts/toc.phtml
index 3f6c6b37c..ca6283d67 100644
--- a/modules/doc/application/views/scripts/toc.phtml
+++ b/modules/doc/application/views/scripts/toc.phtml
@@ -1,5 +1,5 @@
 <div class="controls">
-    <h1><?= $this->translate(sprintf('%s Documentation', ucfirst($docName))); ?></h1>
+    <h1><?= $title ?></h1>
 </div>
 <div class="content toc">
     <?= $tocRenderer->render($this, $this->getHelper('Url')); ?>
diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php
index 88beeee96..66895bfb4 100644
--- a/modules/doc/library/Doc/DocController.php
+++ b/modules/doc/library/Doc/DocController.php
@@ -27,6 +27,7 @@ class DocController extends ModuleActionController
             $url,
             $urlParams
         );
+        $this->view->title = $chapterId;
         $this->_helper->viewRenderer('chapter', null, true);
     }
 
@@ -42,7 +43,9 @@ class DocController extends ModuleActionController
     {
         $parser = new DocParser($path);
         $this->view->tocRenderer = new TocRenderer($parser->getDocTree(), $url, $urlParams);
+        $name = ucfirst($name);
         $this->view->docName = $name;
+        $this->view->title = $this->translate(sprintf('%s Documentation', $name));
         $this->_helper->viewRenderer('toc', null, true);
     }
 
diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php
index fab6d66c4..6281b6d76 100644
--- a/modules/doc/library/Doc/SectionRenderer.php
+++ b/modules/doc/library/Doc/SectionRenderer.php
@@ -222,7 +222,7 @@ class SectionRenderer extends Renderer
         if ($renderNavigation) {
             foreach ($this->docTree as $chapter) {
                 if ($chapter->getValue()->getId() === $section->getChapterId()) {
-                    $content[] = '<ul class="navigation">';
+                    $navigation = array('<ul class="navigation">');
                     $this->docTree->prev();
                     $prev = $this->docTree->current();
                     if ($prev !== null) {
@@ -240,8 +240,8 @@ class SectionRenderer extends Renderer
                         );
                         $url = $view->url($path);
                         $url->setAnchor($this->encodeAnchor($prev->getId()));
-                        $content[] = sprintf(
-                            '<li><a %shref="%s">%s</a></li>',
+                        $navigation[] = sprintf(
+                            '<li class="prev"><a %shref="%s">%s</a></li>',
                             $prev->isNoFollow() ? 'rel="nofollow" ' : '',
                             $url->getAbsoluteUrl(),
                             $view->escape($prev->getTitle())
@@ -253,7 +253,7 @@ class SectionRenderer extends Renderer
                         $this->docTree->next();
                     }
                     $url = $view->url($this->tocUrl);
-                    $content[] = sprintf(
+                    $navigation[] = sprintf(
                         '<li><a href="%s">%s</a></li>',
                         $url->getAbsoluteUrl(),
                         mt('doc', 'Index')
@@ -274,14 +274,15 @@ class SectionRenderer extends Renderer
                         );
                         $url = $view->url($path);
                         $url->setAnchor($this->encodeAnchor($next->getId()));
-                        $content[] = sprintf(
-                            '<li><a %shref="%s">%s</a></li>',
+                        $navigation[] = sprintf(
+                            '<li class="next"><a %shref="%s">%s</a></li>',
                             $next->isNoFollow() ? 'rel="nofollow" ' : '',
                             $url->getAbsoluteUrl(),
                             $view->escape($next->getTitle())
                         );
                     }
-                    $content[] = '</ul>';
+                    $navigation[] = '</ul>';
+                    $content = array_merge($navigation, $content, $navigation);
                     break;
                 }
             }
diff --git a/modules/doc/public/css/module.less b/modules/doc/public/css/module.less
index 2676d0f24..d6d0d2a94 100644
--- a/modules/doc/public/css/module.less
+++ b/modules/doc/public/css/module.less
@@ -48,5 +48,15 @@ div.chapter > ul.navigation {
       color: #fff;
       text-decoration: none;
     }
+
+    &.prev {
+      padding-right: 0.6em;
+      border-right: 2px solid #fff;
+    }
+
+    &.next {
+      padding-left: 0.6em;
+      border-left: 2px solid #fff;
+    }
   }
 }