mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
FIX getEditLink is now extensible and Lang route handling has a fallback
In some cases the Lang is not available in the route, this fixes that as well as making the getEditLink() method extensible
This commit is contained in:
parent
03ec3d287e
commit
e0c20ddf2b
@ -213,7 +213,6 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
ltrim($url, '/'),
|
ltrim($url, '/'),
|
||||||
strlen($base)
|
strlen($base)
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -276,6 +275,11 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
// return $redirect->redirect($cleaned, 302);
|
// return $redirect->redirect($cleaned, 302);
|
||||||
// }
|
// }
|
||||||
if ($record = $this->getManifest()->getPage($url)) {
|
if ($record = $this->getManifest()->getPage($url)) {
|
||||||
|
// In SS 3 offsetSet() isn't implemented for some reason... this is a workaround
|
||||||
|
$routeParams = $this->request->routeParams();
|
||||||
|
$routeParams['Lang'] = $lang;
|
||||||
|
$this->request->setRouteParams($routeParams);
|
||||||
|
|
||||||
$this->record = $record;
|
$this->record = $record;
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
@ -687,10 +691,13 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
/**
|
/**
|
||||||
* Returns an edit link to the current page (optional).
|
* Returns an edit link to the current page (optional).
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public function getEditLink()
|
public function getEditLink()
|
||||||
{
|
{
|
||||||
|
$editLink = false;
|
||||||
|
$entity = null;
|
||||||
|
|
||||||
$page = $this->getPage();
|
$page = $this->getPage();
|
||||||
|
|
||||||
if ($page) {
|
if ($page) {
|
||||||
@ -706,13 +713,13 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($version == 'trunk' && (isset($url['options']['rewritetrunktomaster']))) {
|
if ($version === 'trunk' && (isset($url['options']['rewritetrunktomaster']))) {
|
||||||
if ($url['options']['rewritetrunktomaster']) {
|
if ($url['options']['rewritetrunktomaster']) {
|
||||||
$version = "master";
|
$version = "master";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str_replace(
|
$editLink = str_replace(
|
||||||
array('%entity%', '%lang%', '%version%', '%path%'),
|
array('%entity%', '%lang%', '%version%', '%path%'),
|
||||||
array(
|
array(
|
||||||
$entity->title,
|
$entity->title,
|
||||||
@ -725,7 +732,9 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
$this->extend('updateDocumentationEditLink', $editLink, $entity);
|
||||||
|
|
||||||
|
return $editLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user