mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
ENHANCEMENT: hide index pages from menus. BUGFIX: fixed incorrect name strings coming through on nested pages
This commit is contained in:
parent
8a02cee714
commit
9335c789af
@ -331,11 +331,10 @@ class DocumentationParser {
|
||||
|
||||
// if the name has a . then take the substr
|
||||
$formatted = ($pos = strrpos($formatted, '.')) ? substr($formatted, 0, $pos) : $formatted;
|
||||
$name = ($dot = strrpos($formatted, '.')) ? substr($name, 0, $dot) : $name;
|
||||
$name = ($dot = strrpos($name, '.')) ? substr($name, 0, $dot) : $name;
|
||||
|
||||
// the folder is the one that we are looking for.
|
||||
if($name == $formatted) {
|
||||
|
||||
if(strtolower($name) == strtolower($formatted)) {
|
||||
if(is_dir($base . $file)) {
|
||||
// if this is a directory check that there is any more states to get
|
||||
// to in the goal. If none then what we want is the 'index.md' file
|
||||
|
@ -354,6 +354,7 @@ class DocumentationViewer extends Controller {
|
||||
if(!$module) return false;
|
||||
|
||||
$absFilepath = DocumentationParser::find_page($module->getPath(), $this->Remaining);
|
||||
|
||||
if($absFilepath) {
|
||||
$relativeFilePath = str_replace($module->getPath(), '', $absFilepath);
|
||||
|
||||
@ -382,6 +383,12 @@ class DocumentationViewer extends Controller {
|
||||
|
||||
if($pages) {
|
||||
foreach($pages as $page) {
|
||||
if(strtolower($page->Title) == "index") {
|
||||
$pages->remove($page);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$linkParts = array();
|
||||
|
||||
// don't include the 'index in the url
|
||||
@ -426,6 +433,12 @@ class DocumentationViewer extends Controller {
|
||||
}
|
||||
|
||||
foreach($children as $child) {
|
||||
if(strtolower($child->Title) == "index") {
|
||||
$children->remove($child);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$child->Link = $this->Link(array_merge($segments, array($child->Filename)));
|
||||
$child->LinkingMode = 'link';
|
||||
$child->Children = $this->_getModulePagesNested($child, $level + 1);
|
||||
|
@ -127,22 +127,23 @@ class DocumentationViewerTests extends FunctionalTest {
|
||||
$response = $v->handleRequest(new SS_HTTPRequest('GET', '2.4/en/DocumentationViewerTests/subfolder/'));
|
||||
$pages = $v->getModulePages();
|
||||
$this->assertEquals(
|
||||
array('index', 'sort', 'subfolder', 'test'),
|
||||
array('sort', 'subfolder', 'test'),
|
||||
$pages->column('Filename')
|
||||
);
|
||||
$this->assertEquals(
|
||||
array('link', 'link','current', 'link'),
|
||||
array('link','current', 'link'),
|
||||
$pages->column('LinkingMode')
|
||||
);
|
||||
$links = $pages->column('Link');
|
||||
$this->assertStringEndsWith('2.4/en/DocumentationViewerTests/', $links[0]);
|
||||
$this->assertStringEndsWith('2.4/en/DocumentationViewerTests/sort/', $links[1]);
|
||||
$this->assertStringEndsWith('2.4/en/DocumentationViewerTests/subfolder/', $links[2]);
|
||||
$this->assertStringEndsWith('2.4/en/DocumentationViewerTests/test/', $links[3]);
|
||||
|
||||
$this->assertStringEndsWith('2.4/en/DocumentationViewerTests/sort/', $links[0]);
|
||||
$this->assertStringEndsWith('2.4/en/DocumentationViewerTests/subfolder/', $links[1]);
|
||||
$this->assertStringEndsWith('2.4/en/DocumentationViewerTests/test/', $links[2]);
|
||||
|
||||
// Children
|
||||
$pagesArr = $pages->toArray();
|
||||
$child1 = $pagesArr[0];
|
||||
|
||||
$child1 = $pagesArr[1];
|
||||
|
||||
$this->assertFalse($child1->Children);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user