mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00: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());
|
$link = $this->stripLinkBase($page->Link());
|
||||||
|
|
||||||
$this->pages[$link] = array(
|
$this->pages[$link] = array(
|
||||||
'title' => $page->getTitle(),
|
'title' => $page->getTitle(),
|
||||||
'basename' => $basename,
|
'version' => $page->getVersion(),
|
||||||
'filepath' => DocumentationHelper::normalizePath($path),
|
'basename' => $basename,
|
||||||
'type' => get_class($page),
|
'filepath' => DocumentationHelper::normalizePath($path),
|
||||||
|
'type' => get_class($page),
|
||||||
'entitypath' => $this->entity->getPath(),
|
'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 (in_array($action, $allowed)) {
|
||||||
//
|
//
|
||||||
// if it's one of the allowed actions such as search or all then the
|
// 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);
|
return parent::handleAction($request, $action);
|
||||||
} else {
|
} else {
|
||||||
@ -275,8 +275,8 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
$type = get_class($this->record);
|
$type = get_class($this->record);
|
||||||
$body = $this->renderWith(
|
$body = $this->renderWith(
|
||||||
array(
|
array(
|
||||||
"DocumentationViewer_{$type}",
|
"DocumentationViewer_{$type}",
|
||||||
"DocumentationViewer"
|
'DocumentationViewer'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -288,8 +288,8 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
} elseif (!$url || $url == $lang) {
|
} elseif (!$url || $url == $lang) {
|
||||||
$body = $this->renderWith(
|
$body = $this->renderWith(
|
||||||
array(
|
array(
|
||||||
"DocumentationViewer_DocumentationFolder",
|
'DocumentationViewer_DocumentationFolder',
|
||||||
"DocumentationViewer"
|
'DocumentationViewer'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -572,15 +572,21 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
* Generate a list of all the pages in the documentation grouped by the
|
* Generate a list of all the pages in the documentation grouped by the
|
||||||
* first letter of the page.
|
* first letter of the page.
|
||||||
*
|
*
|
||||||
|
* @param string|int|null $version
|
||||||
* @return GroupedList
|
* @return GroupedList
|
||||||
*/
|
*/
|
||||||
public function AllPages()
|
public function AllPages($version = null)
|
||||||
{
|
{
|
||||||
$pages = $this->getManifest()->getPages();
|
$pages = $this->getManifest()->getPages();
|
||||||
$output = new ArrayList();
|
$output = new ArrayList();
|
||||||
$baseLink = $this->getDocumentationBaseHref();
|
$baseLink = $this->getDocumentationBaseHref();
|
||||||
|
|
||||||
foreach ($pages as $url => $page) {
|
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)));
|
$first = strtoupper(trim(substr($page['title'], 0, 1)));
|
||||||
|
|
||||||
if ($first) {
|
if ($first) {
|
||||||
@ -599,6 +605,16 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
return GroupedList::create($output->sort('Title', 'ASC'));
|
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
|
* Documentation Search Form. Allows filtering of the results by many entities
|
||||||
* and multiple versions.
|
* and multiple versions.
|
||||||
@ -761,4 +777,24 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
{
|
{
|
||||||
return $this->getManifest()->getHasDefaultEntity();
|
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
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $title, $summary, $introduction;
|
protected $title;
|
||||||
|
protected $summary;
|
||||||
|
protected $introduction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DocumentationEntity
|
* @var DocumentationEntity
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
<div class="no-box">
|
<div class="no-box">
|
||||||
<ul class="minor-nav">
|
<ul class="minor-nav">
|
||||||
<li><a href="{$Link(all)}">Documentation Index</a></li>
|
<li><a href="$DocumentationIndexLink">Documentation Index</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<div id="documentation_index" class="box">
|
<div id="documentation_index" class="box">
|
||||||
<div id="page-numbers">
|
<div id="page-numbers">
|
||||||
<span>
|
<span>
|
||||||
<% loop $AllPages.GroupedBy(FirstLetter) %>
|
<% loop $AllVersionPages.GroupedBy(FirstLetter) %>
|
||||||
<a href="#$FirstLetter">$FirstLetter</a>
|
<a href="#$FirstLetter">$FirstLetter</a>
|
||||||
<% end_loop %>
|
<% end_loop %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% loop $AllPages.GroupedBy(FirstLetter) %>
|
<% loop $AllVersionPages.GroupedBy(FirstLetter) %>
|
||||||
<h2 id="$FirstLetter">$FirstLetter</h2>
|
<h2 id="$FirstLetter">$FirstLetter</h2>
|
||||||
|
|
||||||
<ul class="third semantic">
|
<ul class="third semantic">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user