Merge branch '1.0' into 1.1

This commit is contained in:
Daniel Hensby 2017-01-25 13:24:17 +00:00
commit 616bcdb364
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
1 changed files with 24 additions and 24 deletions

View File

@ -1,13 +1,13 @@
<?php <?php
/** /**
* Widgets let CMS authors drag and drop small pieces of functionality into * Widgets let CMS authors drag and drop small pieces of functionality into
* defined areas of their websites. * defined areas of their websites.
* *
* You can use forms in widgets by implementing a {@link WidgetController}. * You can use forms in widgets by implementing a {@link WidgetController}.
* *
* See {@link Widget_Controller} for more information. * See {@link Widget_Controller} for more information.
* *
* @package widgets * @package widgets
*/ */
class Widget extends DataObject { class Widget extends DataObject {
@ -35,7 +35,7 @@ class Widget extends DataObject {
'CMSTitle' => 'Text', 'CMSTitle' => 'Text',
'Description' => 'Text', 'Description' => 'Text',
); );
private static $only_available_in = array(); private static $only_available_in = array();
/** /**
@ -81,10 +81,10 @@ class Widget extends DataObject {
parent::populateDefaults(); parent::populateDefaults();
$this->setField('Title', $this->getTitle()); $this->setField('Title', $this->getTitle());
} }
/** /**
* Note: Overloaded in {@link WidgetController}. * Note: Overloaded in {@link WidgetController}.
* *
* @return string HTML * @return string HTML
*/ */
public function WidgetHolder() { public function WidgetHolder() {
@ -101,16 +101,16 @@ class Widget extends DataObject {
} }
return $this->Content(); return $this->Content();
} }
/** /**
* Renders the widget content in a custom template with the same name as the * Renders the widget content in a custom template with the same name as the
* current class. This should be the main point of output customization. * current class. This should be the main point of output customization.
* *
* Invoked from within WidgetHolder.ss, which contains the "framing" around * Invoked from within WidgetHolder.ss, which contains the "framing" around
* the custom content, like a title. * the custom content, like a title.
* *
* Note: Overloaded in {@link WidgetController}. * Note: Overloaded in {@link WidgetController}.
* *
* @return string HTML * @return string HTML
*/ */
public function Content() { public function Content() {
@ -169,16 +169,16 @@ class Widget extends DataObject {
* @return string - HTML * @return string - HTML
*/ */
public function DescriptionSegment() { public function DescriptionSegment() {
return $this->renderWith('WidgetDescription'); return $this->renderWith('WidgetDescription');
} }
/** /**
* @see WidgetController::editablesegment() * @see WidgetController::editablesegment()
* *
* @return string - HTML * @return string - HTML
*/ */
public function EditableSegment() { public function EditableSegment() {
return $this->renderWith('WidgetEditor'); return $this->renderWith('WidgetEditor');
} }
/** /**
@ -192,7 +192,7 @@ class Widget extends DataObject {
$this->extend('updateCMSFields', $fields); $this->extend('updateCMSFields', $fields);
return $fields; return $fields;
} }
/** /**
* @return FieldList * @return FieldList
*/ */
@ -240,13 +240,13 @@ class Widget extends DataObject {
foreach(array_reverse(ClassInfo::ancestry($this->class)) as $widgetClass) { foreach(array_reverse(ClassInfo::ancestry($this->class)) as $widgetClass) {
$controllerClass = "{$widgetClass}_Controller"; $controllerClass = "{$widgetClass}_Controller";
if(class_exists($controllerClass)) { if(class_exists($controllerClass)) {
break; break;
} }
$controllerClass = "{$widgetClass}Controller"; $controllerClass = "{$widgetClass}Controller";
if(class_exists($controllerClass)) { if(class_exists($controllerClass)) {
break; break;
} }
@ -260,7 +260,7 @@ class Widget extends DataObject {
return $this->controller; return $this->controller;
} }
/** /**
* @param array $data * @param array $data
*/ */
@ -277,7 +277,7 @@ class Widget extends DataObject {
} }
} }
} }
//Look for checkbox fields not present in the data //Look for checkbox fields not present in the data
foreach($fields as $field) { foreach($fields as $field) {
if($field instanceof CheckboxField && !array_key_exists($field->getName(), $data)) { if($field instanceof CheckboxField && !array_key_exists($field->getName(), $data)) {
@ -285,12 +285,12 @@ class Widget extends DataObject {
$field->saveInto($this); $field->saveInto($this);
} }
} }
$this->write(); $this->write();
// The field must be written to ensure a unique ID. // The field must be written to ensure a unique ID.
$this->Name = $this->class.$this->ID; $this->Name = $this->class.$this->ID;
$this->write(); $this->write();
} }
} }