mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
Merge pull request #128 from robbieaverill/bugfix/127-use-stable-version-in-all-page
Use the current version to filter pages in the "documentation index"
This commit is contained in:
commit
ded5432ec0
@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,9 @@ class DocumentationPage extends ViewableData
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $title, $summary, $introduction;
|
||||
protected $title;
|
||||
protected $summary;
|
||||
protected $introduction;
|
||||
|
||||
/**
|
||||
* @var DocumentationEntity
|
||||
|
@ -63,7 +63,7 @@
|
||||
|
||||
<div class="no-box">
|
||||
<ul class="minor-nav">
|
||||
<li><a href="{$Link(all)}">Documentation Index</a></li>
|
||||
<li><a href="$DocumentationIndexLink">Documentation Index</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,13 +1,13 @@
|
||||
<div id="documentation_index" class="box">
|
||||
<div id="page-numbers">
|
||||
<span>
|
||||
<% loop $AllPages.GroupedBy(FirstLetter) %>
|
||||
<% loop $AllVersionPages.GroupedBy(FirstLetter) %>
|
||||
<a href="#$FirstLetter">$FirstLetter</a>
|
||||
<% end_loop %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<% loop $AllPages.GroupedBy(FirstLetter) %>
|
||||
<% loop $AllVersionPages.GroupedBy(FirstLetter) %>
|
||||
<h2 id="$FirstLetter">$FirstLetter</h2>
|
||||
|
||||
<ul class="third semantic">
|
||||
@ -18,4 +18,4 @@
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
<% end_loop %>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user