diff --git a/code/DocumentationManifest.php b/code/DocumentationManifest.php index e54b815..9e044b9 100644 --- a/code/DocumentationManifest.php +++ b/code/DocumentationManifest.php @@ -432,12 +432,13 @@ class DocumentationManifest $link = $this->stripLinkBase($page->Link()); $this->pages[$link] = array( - 'title' => $page->getTitle(), - 'basename' => $basename, - 'filepath' => DocumentationHelper::normalizePath($path), - 'type' => get_class($page), + 'title' => $page->getTitle(), + 'version' => $page->getVersion(), + 'basename' => $basename, + 'filepath' => DocumentationHelper::normalizePath($path), + 'type' => get_class($page), 'entitypath' => $this->entity->getPath(), - 'summary' => $page->getSummary() + 'summary' => $page->getSummary() ); } diff --git a/code/controllers/DocumentationViewer.php b/code/controllers/DocumentationViewer.php index c7dde2e..d438fa7 100755 --- a/code/controllers/DocumentationViewer.php +++ b/code/controllers/DocumentationViewer.php @@ -251,7 +251,7 @@ class DocumentationViewer extends Controller implements PermissionProvider if (in_array($action, $allowed)) { // // if it's one of the allowed actions such as search or all then the - // URL must be prefixed with one of the allowed languages. + // URL must be prefixed with one of the allowed languages and versions // return parent::handleAction($request, $action); } else { @@ -275,8 +275,8 @@ class DocumentationViewer extends Controller implements PermissionProvider $type = get_class($this->record); $body = $this->renderWith( array( - "DocumentationViewer_{$type}", - "DocumentationViewer" + "DocumentationViewer_{$type}", + 'DocumentationViewer' ) ); @@ -288,8 +288,8 @@ class DocumentationViewer extends Controller implements PermissionProvider } elseif (!$url || $url == $lang) { $body = $this->renderWith( array( - "DocumentationViewer_DocumentationFolder", - "DocumentationViewer" + 'DocumentationViewer_DocumentationFolder', + 'DocumentationViewer' ) ); @@ -572,15 +572,21 @@ class DocumentationViewer extends Controller implements PermissionProvider * Generate a list of all the pages in the documentation grouped by the * first letter of the page. * + * @param string|int|null $version * @return GroupedList */ - public function AllPages() + public function AllPages($version = null) { $pages = $this->getManifest()->getPages(); $output = new ArrayList(); $baseLink = $this->getDocumentationBaseHref(); foreach ($pages as $url => $page) { + // Option to skip Pages that do not belong to the current version + if (!is_null($version) && (string) $page['version'] !== (string) $version) { + continue; + } + $first = strtoupper(trim(substr($page['title'], 0, 1))); if ($first) { @@ -599,6 +605,16 @@ class DocumentationViewer extends Controller implements PermissionProvider return GroupedList::create($output->sort('Title', 'ASC')); } + /** + * Return all Pages that apply to the current version (from the route) + * + * @return GroupedList + */ + public function getAllVersionPages() + { + return $this->AllPages($this->getRequestedVersion()); + } + /** * Documentation Search Form. Allows filtering of the results by many entities * and multiple versions. @@ -761,4 +777,24 @@ class DocumentationViewer extends Controller implements PermissionProvider { return $this->getManifest()->getHasDefaultEntity(); } + + /** + * Gets the requested version from the URL + * + * @return string + */ + public function getRequestedVersion() + { + return (string) $this->request->param('Version'); + } + + /** + * Gets the link to the "documentation index" containing the currently requested version + * + * @return string + */ + public function getDocumentationIndexLink() + { + return $this->Link($this->getRequestedVersion() . '/all'); + } } diff --git a/code/models/DocumentationPage.php b/code/models/DocumentationPage.php index 04c1a97..6da3b29 100755 --- a/code/models/DocumentationPage.php +++ b/code/models/DocumentationPage.php @@ -15,7 +15,9 @@ class DocumentationPage extends ViewableData /** * @var string */ - protected $title, $summary, $introduction; + protected $title; + protected $summary; + protected $introduction; /** * @var DocumentationEntity diff --git a/templates/Includes/DocumentationSidebar.ss b/templates/Includes/DocumentationSidebar.ss index 687afec..1d85644 100644 --- a/templates/Includes/DocumentationSidebar.ss +++ b/templates/Includes/DocumentationSidebar.ss @@ -63,7 +63,7 @@
diff --git a/templates/Layout/DocumentationViewer_all.ss b/templates/Layout/DocumentationViewer_all.ss index 6a9b7ce..2585c08 100644 --- a/templates/Layout/DocumentationViewer_all.ss +++ b/templates/Layout/DocumentationViewer_all.ss @@ -1,13 +1,13 @@