mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge pull request #701 from tractorcow/3.1-api-updaterelativelink
API Added SiteTreeExtension::updateRelativeLink
This commit is contained in:
commit
b2e9353755
@ -468,22 +468,19 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function RelativeLink($action = null) {
|
public function RelativeLink($action = null) {
|
||||||
if($this->ParentID && self::config()->nested_urls) {
|
if($this->ParentID && self::config()->nested_urls) {
|
||||||
$base = $this->Parent()->RelativeLink($this->URLSegment);
|
$base = $this->Parent()->RelativeLink($this->URLSegment);
|
||||||
|
} elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) {
|
||||||
|
// Unset base for root-level homepages.
|
||||||
|
// Note: Homepages with action parameters (or $action === true)
|
||||||
|
// need to retain their URLSegment.
|
||||||
|
$base = null;
|
||||||
} else {
|
} else {
|
||||||
$base = $this->URLSegment;
|
$base = $this->URLSegment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unset base for homepage URLSegments in their default language.
|
$this->extend('updateRelativeLink', $base, $action);
|
||||||
// Homepages with action parameters or in different languages
|
|
||||||
// need to retain their URLSegment. We can only do this if the homepage
|
|
||||||
// is on the root level.
|
|
||||||
if(!$action && $base == RootURLController::get_homepage_link() && !$this->ParentID) {
|
|
||||||
$base = null;
|
|
||||||
if(class_exists('Translatable') && $this->hasExtension('Translatable') && $this->Locale != Translatable::default_locale()){
|
|
||||||
$base = $this->URLSegment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Legacy support
|
// Legacy support: If $action === true, retain URLSegment for homepages,
|
||||||
|
// but don't append any action
|
||||||
if($action === true) $action = null;
|
if($action === true) $action = null;
|
||||||
|
|
||||||
return Controller::join_links($base, '/', $action);
|
return Controller::join_links($base, '/', $action);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plug-ins for additional functionality in your SiteTree classes.
|
* Plug-ins for additional functionality in your SiteTree classes.
|
||||||
*
|
*
|
||||||
@ -7,23 +8,71 @@
|
|||||||
*/
|
*/
|
||||||
abstract class SiteTreeExtension extends DataExtension {
|
abstract class SiteTreeExtension extends DataExtension {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called before the page's {@link SiteTree::doPublish()} action is completed
|
||||||
|
*
|
||||||
|
* @param SiteTree &$original The current Live SiteTree record prior to publish
|
||||||
|
*/
|
||||||
public function onBeforePublish(&$original) {
|
public function onBeforePublish(&$original) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called after the page's {@link SiteTree::doPublish()} action is completed
|
||||||
|
*
|
||||||
|
* @param SiteTree &$original The current Live SiteTree record prior to publish
|
||||||
|
*/
|
||||||
public function onAfterPublish(&$original) {
|
public function onAfterPublish(&$original) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called before the page's {@link SiteTree::doUnpublish()} action is completed
|
||||||
|
*/
|
||||||
public function onBeforeUnpublish() {
|
public function onBeforeUnpublish() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called after the page's {@link SiteTree::doUnpublish()} action is completed
|
||||||
|
*/
|
||||||
public function onAfterUnpublish() {
|
public function onAfterUnpublish() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called to determine if a user may add children to this SiteTree object
|
||||||
|
*
|
||||||
|
* @see SiteTree::canAddChildren()
|
||||||
|
*
|
||||||
|
* @param Member $member The member to check permission against, or the currently
|
||||||
|
* logged in user
|
||||||
|
* @return boolean|null Return false to deny rights, or null to yield to default
|
||||||
|
*/
|
||||||
public function canAddChildren($member) {
|
public function canAddChildren($member) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called to determine if a user may publish this SiteTree object
|
||||||
|
*
|
||||||
|
* @see SiteTree::canPublish()
|
||||||
|
*
|
||||||
|
* @param Member $member The member to check permission against, or the currently
|
||||||
|
* logged in user
|
||||||
|
* @return boolean|null Return false to deny rights, or null to yield to default
|
||||||
|
*/
|
||||||
public function canPublish($member) {
|
public function canPublish($member) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called to modify the $base url of this page, with a given $action,
|
||||||
|
* before {@link SiteTree::RelativeLink()} calls {@link Controller::join_links()}
|
||||||
|
* on the $base and $action
|
||||||
|
*
|
||||||
|
* @param string &$base The URL of this page relative to siteroot, not including
|
||||||
|
* the action
|
||||||
|
* @param string|boolean &$action The action or subpage called on this page.
|
||||||
|
* (Legacy support) If this is true, then do not reduce the 'home' urlsegment
|
||||||
|
* to an empty link
|
||||||
|
*/
|
||||||
|
public function updateRelativeLink(&$base, &$action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user