mirror of
https://github.com/silverstripe/silverstripe-widgets
synced 2024-10-22 17:05:54 +02:00
Merge branch '1.1' into 1.2
This commit is contained in:
commit
1bbaba52e0
@ -26,15 +26,18 @@ class WidgetContentControllerExtension extends Extension
|
|||||||
* @return RequestHandler
|
* @return RequestHandler
|
||||||
*/
|
*/
|
||||||
public function handleWidget()
|
public function handleWidget()
|
||||||
{
|
{$SQL_id = $this->owner->getRequest()->param('ID');
|
||||||
$SQL_id = $this->owner->getRequest()->param('ID');
|
if(!$SQL_id) {return false;
|
||||||
if (!$SQL_id) {
|
}
|
||||||
return false;
|
/** @var SiteTree $widgetOwner */
|
||||||
|
$widgetOwner = $this->owner->data();
|
||||||
|
while($widgetOwner->InheritSideBar && $widgetOwner->Parent()->exists()){
|
||||||
|
$widgetOwner = $widgetOwner->Parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// find WidgetArea relations
|
// find WidgetArea relations
|
||||||
$widgetAreaRelations = array();
|
$widgetAreaRelations = array();
|
||||||
$hasOnes = $this->owner->data()->hasOne();
|
$hasOnes = $widgetOwner->hasOne();
|
||||||
|
|
||||||
if(!$hasOnes) {
|
if(!$hasOnes) {
|
||||||
return false;
|
return false;
|
||||||
@ -54,7 +57,7 @@ class WidgetContentControllerExtension extends Extension
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$widget = $this->owner->data()->$widgetAreaRelation()->Widgets()
|
$widget = $widgetOwner->$widgetAreaRelation()->Widgets()
|
||||||
->filter('ID', $SQL_id)
|
->filter('ID', $SQL_id)
|
||||||
->First();
|
->First();
|
||||||
}
|
}
|
||||||
|
@ -54,19 +54,38 @@ class WidgetController extends Controller
|
|||||||
$id = ($this->widget) ? $this->widget->ID : null;
|
$id = ($this->widget) ? $this->widget->ID : null;
|
||||||
$segment = Controller::join_links('widget', $id, $action);
|
$segment = Controller::join_links('widget', $id, $action);
|
||||||
|
|
||||||
if ($page = Director::get_current_page()) {
|
$page = Director::get_current_page();
|
||||||
return $page->Link($segment);
|
if($page && !($page instanceof WidgetController)) {return $page->Link($segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Controller::curr()->Link($segment);
|
if ($controller = $this->getParentController()) {return $controller->Link($segment);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $segment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cycles up the controller stack until it finds a non-widget controller
|
||||||
|
* This is needed becauseController::currreturns the widget controller,
|
||||||
|
* which means anyLinkfunction turns into endless loop.
|
||||||
|
*
|
||||||
|
* @return Controller
|
||||||
|
*/
|
||||||
|
public function getParentController()
|
||||||
|
{
|
||||||
|
foreach(Controller::$controller_stack as $controller) {
|
||||||
|
if (!($controller instanceof WidgetController)) {
|
||||||
|
return $controller;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Widget
|
* @return Widget
|
||||||
*/
|
*/
|
||||||
public function getWidget()
|
public function getWidget()
|
||||||
{
|
{return $this->widget;
|
||||||
return $this->widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,8 +95,7 @@ class WidgetController extends Controller
|
|||||||
* @return string HTML
|
* @return string HTML
|
||||||
*/
|
*/
|
||||||
public function Content()
|
public function Content()
|
||||||
{
|
{return $this->renderWith(array_reverse(ClassInfo::ancestry($this->widget->class)));
|
||||||
return $this->renderWith(array_reverse(ClassInfo::ancestry($this->widget->class)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,8 +105,7 @@ class WidgetController extends Controller
|
|||||||
* @return string HTML
|
* @return string HTML
|
||||||
*/
|
*/
|
||||||
public function WidgetHolder()
|
public function WidgetHolder()
|
||||||
{
|
{return $this->renderWith("WidgetHolder");
|
||||||
return $this->renderWith("WidgetHolder");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,12 +116,10 @@ class WidgetController extends Controller
|
|||||||
*
|
*
|
||||||
* @return string HTML
|
* @return string HTML
|
||||||
*/
|
*/
|
||||||
public function editablesegment()
|
public function editablesegment() {
|
||||||
{
|
|
||||||
// use left and main to set the html config
|
// use left and main to set the html config
|
||||||
$leftandmain = LeftAndMain::create();
|
$leftandmain = LeftAndMain::create();
|
||||||
$leftandmain->init();
|
$leftandmain->init();
|
||||||
|
|
||||||
$className = $this->urlParams['ID'];
|
$className = $this->urlParams['ID'];
|
||||||
if (class_exists('Translatable') && Member::currentUserID()) {
|
if (class_exists('Translatable') && Member::currentUserID()) {
|
||||||
// set current locale based on logged in user's locale
|
// set current locale based on logged in user's locale
|
||||||
|
Loading…
Reference in New Issue
Block a user