mirror of
https://github.com/silverstripe/silverstripe-widgets
synced 2024-10-22 17:05:54 +02:00
Merge pull request #161 from creative-commoners/pulls/2.0/fix-namespace-handling
FIX Ensure namespaced widget classes are handled and Widget is not included
This commit is contained in:
commit
f8f10e96ff
@ -135,15 +135,11 @@ class WidgetController extends Controller
|
|||||||
{
|
{
|
||||||
// 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->setRequest($this->getRequest());
|
||||||
$leftandmain->doInit();
|
$leftandmain->doInit();
|
||||||
|
|
||||||
// Decode if fully qualified - @see Widget::ClassName
|
// Decode if fully qualified - @see Widget::ClassName
|
||||||
$className = str_replace('_', '\\', $this->urlParams['ID']);
|
$className = str_replace('_', '\\', $this->urlParams['ID']);
|
||||||
if (class_exists('Translatable') && Member::currentUserID()) {
|
|
||||||
// set current locale based on logged in user's locale
|
|
||||||
$locale = Member::currentUser()->Locale;
|
|
||||||
i18n::set_locale($locale);
|
|
||||||
}
|
|
||||||
if (class_exists($className) && is_subclass_of($className, Widget::class)) {
|
if (class_exists($className) && is_subclass_of($className, Widget::class)) {
|
||||||
$obj = new $className();
|
$obj = new $className();
|
||||||
return $obj->EditableSegment();
|
return $obj->EditableSegment();
|
||||||
|
@ -75,13 +75,4 @@ class WidgetPageExtension extends DataExtension
|
|||||||
|
|
||||||
return $duplicatePage;
|
return $duplicatePage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Support Translatable so that we don't link WidgetAreas across translations
|
|
||||||
*/
|
|
||||||
public function onTranslatableCreate()
|
|
||||||
{
|
|
||||||
//reset the sidebar ID
|
|
||||||
$this->owner->SideBarID = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ use SilverStripe\Forms\FormField;
|
|||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\DataObjectInterface;
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
use SilverStripe\View\Requirements;
|
use SilverStripe\View\Requirements;
|
||||||
use SilverStripe\Widgets\Forms\WidgetAreaEditor;
|
|
||||||
use SilverStripe\Widgets\Model\Widget;
|
use SilverStripe\Widgets\Model\Widget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,8 +56,8 @@ class WidgetAreaEditor extends FormField
|
|||||||
foreach ($this->widgetClasses as $widgetClass) {
|
foreach ($this->widgetClasses as $widgetClass) {
|
||||||
$classes = ClassInfo::subclassesFor($widgetClass);
|
$classes = ClassInfo::subclassesFor($widgetClass);
|
||||||
|
|
||||||
if (isset($classes[Widget::class])) {
|
if (isset($classes[strtolower(Widget::class)])) {
|
||||||
unset($classes[Widget::class]);
|
unset($classes[strtolower(Widget::class)]);
|
||||||
} elseif (isset($classes[0]) && $classes[0] == Widget::class) {
|
} elseif (isset($classes[0]) && $classes[0] == Widget::class) {
|
||||||
unset($classes[0]);
|
unset($classes[0]);
|
||||||
}
|
}
|
||||||
@ -165,6 +164,12 @@ class WidgetAreaEditor extends FormField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unsantise the class name
|
||||||
|
if (empty($newWidgetData['Type'])) {
|
||||||
|
$newWidgetData['Type'] = '';
|
||||||
|
}
|
||||||
|
$newWidgetData['Type'] = str_replace('_', '\\', $newWidgetData['Type']);
|
||||||
|
|
||||||
// create a new object
|
// create a new object
|
||||||
if (!$widget
|
if (!$widget
|
||||||
&& !empty($newWidgetData['Type'])
|
&& !empty($newWidgetData['Type'])
|
||||||
|
Loading…
Reference in New Issue
Block a user