mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
Fix issue with Language parameter not being set
When the user accesses a page more than three levels deep.
This commit is contained in:
parent
48afabff7b
commit
aed63c9df5
@ -4,5 +4,5 @@ After: framework/routes#coreroutes
|
|||||||
---
|
---
|
||||||
Director:
|
Director:
|
||||||
rules:
|
rules:
|
||||||
'dev/docs': 'DocumentationViewer'
|
'dev/docs//$Lang/$Action': 'DocumentationViewer'
|
||||||
'DocumentationOpenSearchController//$Action': 'DocumentationOpenSearchController'
|
'DocumentationOpenSearchController//$Action': 'DocumentationOpenSearchController'
|
||||||
|
@ -355,10 +355,6 @@ class DocumentationManifest {
|
|||||||
|
|
||||||
$parts = explode('/', trim($record->getRelativeLink(), '/'));
|
$parts = explode('/', trim($record->getRelativeLink(), '/'));
|
||||||
|
|
||||||
// the first part of the URL should be the language, so shift that off
|
|
||||||
// so we just have the core pages.
|
|
||||||
array_shift($parts);
|
|
||||||
|
|
||||||
// Add the base link.
|
// Add the base link.
|
||||||
$output->push(new ArrayData(array(
|
$output->push(new ArrayData(array(
|
||||||
'Link' => $base->Link(),
|
'Link' => $base->Link(),
|
||||||
@ -446,7 +442,14 @@ class DocumentationManifest {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function normalizeUrl($url) {
|
public function normalizeUrl($url) {
|
||||||
return trim($url, '/') .'/';
|
$url = trim($url, '/') .'/';
|
||||||
|
|
||||||
|
// if the page is the index page then hide it from the menu
|
||||||
|
if(strpos(strtolower($url), '/index.md/')) {
|
||||||
|
$url = substr($url, 0, strpos($url, "index.md/"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -458,33 +461,33 @@ class DocumentationManifest {
|
|||||||
*
|
*
|
||||||
* @return ArrayList
|
* @return ArrayList
|
||||||
*/
|
*/
|
||||||
public function getChildrenFor($path, $recursive = true) {
|
public function getChildrenFor($entityPath, $recordPath = null) {
|
||||||
|
if(!$recordPath) {
|
||||||
|
$recordPath = $entityPath;
|
||||||
|
}
|
||||||
|
|
||||||
$output = new ArrayList();
|
$output = new ArrayList();
|
||||||
$base = Config::inst()->get('DocumentationViewer', 'link_base');
|
$base = Config::inst()->get('DocumentationViewer', 'link_base');
|
||||||
$path = $this->normalizeUrl($path);
|
$entityPath = $this->normalizeUrl($entityPath);
|
||||||
$depth = substr_count($path, '/');
|
$recordPath = $this->normalizeUrl($recordPath);
|
||||||
|
|
||||||
|
$depth = substr_count($entityPath, '/');
|
||||||
|
|
||||||
foreach($this->getPages() as $url => $page) {
|
foreach($this->getPages() as $url => $page) {
|
||||||
$pagePath = $this->normalizeUrl($page['filepath']);
|
$pagePath = $this->normalizeUrl($page['filepath']);
|
||||||
|
|
||||||
// check to see if this page is under the given path
|
// check to see if this page is under the given path
|
||||||
if(strpos($pagePath, $path) === false) {
|
if(strpos($pagePath, $entityPath) === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the page is the index page then hide it from the menu
|
|
||||||
if(strpos(strtolower($pagePath), '/index.md/')) {
|
|
||||||
$pagePath = substr($pagePath, 0, strpos($pagePath, "index.md/"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// only pull it up if it's one more level depth
|
// only pull it up if it's one more level depth
|
||||||
if(substr_count($pagePath, DIRECTORY_SEPARATOR) == ($depth + 1)) {
|
if(substr_count($pagePath, DIRECTORY_SEPARATOR) == ($depth + 1)) {
|
||||||
// found a child
|
$mode = (strpos($recordPath, $pagePath) !== false) ? 'current' : 'link';
|
||||||
$mode = ($pagePath == $path) ? 'current' : 'link';
|
|
||||||
$children = new ArrayList();
|
$children = new ArrayList();
|
||||||
|
|
||||||
if($mode == 'current' && $recursive) {
|
if($mode == 'current') {
|
||||||
// $children = $this->getChildrenFor($url, false);
|
$children = $this->getChildrenFor($pagePath, $recordPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->push(new ArrayData(array(
|
$output->push(new ArrayData(array(
|
||||||
|
@ -32,13 +32,6 @@ class DocumentationViewer extends Controller {
|
|||||||
*/
|
*/
|
||||||
private static $documentation_title = 'SilverStripe Documentation';
|
private static $documentation_title = 'SilverStripe Documentation';
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $url_handlers = array(
|
|
||||||
'$Lang/$Action' => 'handleAction'
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@ -323,12 +316,13 @@ class DocumentationViewer extends Controller {
|
|||||||
|
|
||||||
$mode = 'link';
|
$mode = 'link';
|
||||||
$children = new ArrayList();
|
$children = new ArrayList();
|
||||||
|
|
||||||
if($entity->hasRecord($record) || $entity->getIsDefaultEntity()) {
|
if($entity->hasRecord($record) || $entity->getIsDefaultEntity()) {
|
||||||
$mode = 'current';
|
$mode = 'current';
|
||||||
|
|
||||||
// add children
|
// add children
|
||||||
$children = $this->getManifest()->getChildrenFor(
|
$children = $this->getManifest()->getChildrenFor(
|
||||||
$entity->getPath()
|
$entity->getPath(), ($record) ? $record->getPath() : $entity->getPath()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if($current && $current->getKey() == $entity->getKey()) {
|
if($current && $current->getKey() == $entity->getKey()) {
|
||||||
@ -372,6 +366,9 @@ class DocumentationViewer extends Controller {
|
|||||||
return $codes->parse($html);
|
return $codes->parse($html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Short code parser
|
||||||
|
*/
|
||||||
public function includeChildren($args) {
|
public function includeChildren($args) {
|
||||||
if(isset($args['Folder'])) {
|
if(isset($args['Folder'])) {
|
||||||
$children = $this->getManifest()->getChildrenFor(
|
$children = $this->getManifest()->getChildrenFor(
|
||||||
@ -388,6 +385,21 @@ class DocumentationViewer extends Controller {
|
|||||||
)))->renderWith('Includes/DocumentationPages');
|
)))->renderWith('Includes/DocumentationPages');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ArrayList
|
||||||
|
*/
|
||||||
|
public function getChildren() {
|
||||||
|
if($this->record instanceof DocumentationFolder) {
|
||||||
|
return $this->getManifest()->getChildrenFor(
|
||||||
|
$this->record->getPath()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return $this->getManifest()->getChildrenFor(
|
||||||
|
dirname($this->record->getPath())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a list of breadcrumbs for the user.
|
* Generate a list of breadcrumbs for the user.
|
||||||
*
|
*
|
||||||
@ -416,6 +428,9 @@ class DocumentationViewer extends Controller {
|
|||||||
return ($this->record) ? $this->record->getEntity() : null;
|
return ($this->record) ? $this->record->getEntity() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ArrayList
|
||||||
|
*/
|
||||||
public function getVersions() {
|
public function getVersions() {
|
||||||
return $this->manifest->getVersions($this->getEntity);
|
return $this->manifest->getVersions($this->getEntity);
|
||||||
}
|
}
|
||||||
|
@ -185,16 +185,6 @@ html {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Breadcrumbs */
|
|
||||||
#breadcrumbs {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
#breadcrumbs p {
|
|
||||||
font-size: 11px;
|
|
||||||
margin: 0 0 5px 0;
|
|
||||||
color: #798D85;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Search Results */
|
/* Search Results */
|
||||||
#search-results {
|
#search-results {
|
||||||
@ -446,7 +436,7 @@ html {
|
|||||||
}
|
}
|
||||||
.doc-breadcrumbs p {
|
.doc-breadcrumbs p {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
margin: 0;
|
margin: 0 0 5px 0;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
.doc-breadcrumbs p a {
|
.doc-breadcrumbs p a {
|
||||||
@ -504,3 +494,25 @@ html {
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.next-prev {
|
||||||
|
border-top: 1px solid #eee;
|
||||||
|
margin-top: 20px;
|
||||||
|
padding-top: 19px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.next-prev a {
|
||||||
|
color: #798D85;
|
||||||
|
}
|
||||||
|
|
||||||
|
.next-prev p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.next-prev .prev-link {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.next-prev .next-link {
|
||||||
|
float: right;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user