From e0b693203f9c24dc68e99a11ce3267102588e403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szab=C3=B3=20Gerg=C5=91?= Date: Wed, 17 Dec 2014 10:38:40 +0100 Subject: [PATCH 01/15] Add charset meta tag --- themes/demo/layouts/default.htm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/demo/layouts/default.htm b/themes/demo/layouts/default.htm index 68260361c..3a22acd52 100644 --- a/themes/demo/layouts/default.htm +++ b/themes/demo/layouts/default.htm @@ -3,6 +3,7 @@ description = "Default layout" + October CMS - {{ this.page.title }} @@ -60,4 +61,4 @@ description = "Default layout" {% scripts %} - \ No newline at end of file + From f0005d196bcba58ab5d83a43344d12b55d385051 Mon Sep 17 00:00:00 2001 From: gergo85 Date: Sat, 3 Jan 2015 12:41:23 +0100 Subject: [PATCH 02/15] Cleanup Remove whitespaces. --- modules/backend/behaviors/ListController.php | 1 - modules/backend/classes/BackendHelper.php | 1 - modules/backend/classes/FormTabs.php | 4 +--- modules/backend/classes/FormWidgetBase.php | 1 - modules/backend/classes/ListColumn.php | 1 - modules/backend/classes/WidgetBase.php | 1 - modules/backend/controllers/AccessLogs.php | 1 - modules/backend/controllers/EditorPreferences.php | 1 - modules/backend/routes.php | 4 +--- modules/cms/classes/CmsException.php | 1 - modules/cms/classes/CmsObjectQuery.php | 1 - modules/cms/routes.php | 6 ++---- modules/system/classes/Controller.php | 1 - modules/system/classes/ErrorHandler.php | 1 - modules/system/classes/ExceptionBase.php | 1 - modules/system/classes/ModelBehavior.php | 4 ++-- modules/system/controllers/EventLogs.php | 2 -- modules/system/controllers/MailLayouts.php | 2 -- modules/system/controllers/MailTemplates.php | 2 -- modules/system/controllers/RequestLogs.php | 2 -- modules/system/models/EventLog.php | 1 - modules/system/models/RequestLog.php | 1 - modules/system/routes.php | 4 +--- 23 files changed, 7 insertions(+), 37 deletions(-) diff --git a/modules/backend/behaviors/ListController.php b/modules/backend/behaviors/ListController.php index dadf95bab..8d3826433 100644 --- a/modules/backend/behaviors/ListController.php +++ b/modules/backend/behaviors/ListController.php @@ -15,7 +15,6 @@ use Backend\Classes\ControllerBehavior; */ class ListController extends ControllerBehavior { - /** * @var array List definitions, keys for alias and value for configuration. */ diff --git a/modules/backend/classes/BackendHelper.php b/modules/backend/classes/BackendHelper.php index e48701bfe..f07637c81 100644 --- a/modules/backend/classes/BackendHelper.php +++ b/modules/backend/classes/BackendHelper.php @@ -13,7 +13,6 @@ use October\Rain\Router\Helper as RouterHelper; */ class BackendHelper { - /** * Returns a URL in context of the Backend */ diff --git a/modules/backend/classes/FormTabs.php b/modules/backend/classes/FormTabs.php index 3a2e22804..0dab4e06a 100644 --- a/modules/backend/classes/FormTabs.php +++ b/modules/backend/classes/FormTabs.php @@ -16,7 +16,6 @@ use ArrayAccess; */ class FormTabs implements IteratorAggregate, ArrayAccess { - const SECTION_OUTSIDE = 'outside'; const SECTION_PRIMARY = 'primary'; const SECTION_SECONDARY = 'secondary'; @@ -176,5 +175,4 @@ class FormTabs implements IteratorAggregate, ArrayAccess { return isset($this->fields[$offset]) ? $this->fields[$offset] : null; } - -} \ No newline at end of file +} diff --git a/modules/backend/classes/FormWidgetBase.php b/modules/backend/classes/FormWidgetBase.php index 5a5748e1b..e59458c50 100644 --- a/modules/backend/classes/FormWidgetBase.php +++ b/modules/backend/classes/FormWidgetBase.php @@ -11,7 +11,6 @@ use Str; */ abstract class FormWidgetBase extends WidgetBase { - /** * @var FormField Object containing general form field information. */ diff --git a/modules/backend/classes/ListColumn.php b/modules/backend/classes/ListColumn.php index 6cf0a32bb..afc44cec5 100644 --- a/modules/backend/classes/ListColumn.php +++ b/modules/backend/classes/ListColumn.php @@ -9,7 +9,6 @@ */ class ListColumn { - /** * @var string List column name. */ diff --git a/modules/backend/classes/WidgetBase.php b/modules/backend/classes/WidgetBase.php index 763f6ed72..40016f78a 100644 --- a/modules/backend/classes/WidgetBase.php +++ b/modules/backend/classes/WidgetBase.php @@ -13,7 +13,6 @@ use Session; */ abstract class WidgetBase { - use \System\Traits\AssetMaker; use \System\Traits\ConfigMaker; use \System\Traits\ViewMaker; diff --git a/modules/backend/controllers/AccessLogs.php b/modules/backend/controllers/AccessLogs.php index 6dd8dc476..1c1bd7617 100644 --- a/modules/backend/controllers/AccessLogs.php +++ b/modules/backend/controllers/AccessLogs.php @@ -21,7 +21,6 @@ use Exception; */ class AccessLogs extends Controller { - public $implement = [ 'Backend.Behaviors.ListController' ]; diff --git a/modules/backend/controllers/EditorPreferences.php b/modules/backend/controllers/EditorPreferences.php index 459aa91fc..b1e0f52ab 100644 --- a/modules/backend/controllers/EditorPreferences.php +++ b/modules/backend/controllers/EditorPreferences.php @@ -14,7 +14,6 @@ use Backend\Models\EditorPreferences as EditorPreferencesModel; */ class EditorPreferences extends Controller { - public $implement = [ 'Backend.Behaviors.FormController', ]; diff --git a/modules/backend/routes.php b/modules/backend/routes.php index 56ef8a3e1..63b93c388 100644 --- a/modules/backend/routes.php +++ b/modules/backend/routes.php @@ -1,10 +1,9 @@ where('slug', '(.*)?'); - }); diff --git a/modules/system/classes/Controller.php b/modules/system/classes/Controller.php index ae68562b3..d1ed59eb5 100644 --- a/modules/system/classes/Controller.php +++ b/modules/system/classes/Controller.php @@ -13,7 +13,6 @@ use Exception; */ class Controller extends BaseController { - /** * Combines JavaScript and StyleSheet assets. * @param string $name Combined file code diff --git a/modules/system/classes/ErrorHandler.php b/modules/system/classes/ErrorHandler.php index 2e572dda7..40912e107 100644 --- a/modules/system/classes/ErrorHandler.php +++ b/modules/system/classes/ErrorHandler.php @@ -19,7 +19,6 @@ use System\Classes\ApplicationException; */ class ErrorHandler { - /** * @var System\Classes\ExceptionBase A prepared mask exception used to mask any exception fired. */ diff --git a/modules/system/classes/ExceptionBase.php b/modules/system/classes/ExceptionBase.php index 09818c6e0..b25a3f834 100644 --- a/modules/system/classes/ExceptionBase.php +++ b/modules/system/classes/ExceptionBase.php @@ -16,7 +16,6 @@ use System\Classes\ApplicationException; */ class ExceptionBase extends Exception { - /** * @var Exception If this exception is acting as a mask, this property stores the face exception. */ diff --git a/modules/system/classes/ModelBehavior.php b/modules/system/classes/ModelBehavior.php index 2959a0b13..60301b5bb 100644 --- a/modules/system/classes/ModelBehavior.php +++ b/modules/system/classes/ModelBehavior.php @@ -12,7 +12,6 @@ use October\Rain\Database\ModelBehavior as ModelBehaviorBase; */ class ModelBehavior extends ModelBehaviorBase { - /** * @var array Properties that must exist in the model using this behavior. */ @@ -29,7 +28,8 @@ class ModelBehavior extends ModelBehaviorBase /* * Validate model properties */ - foreach ($this->requiredProperties as $property) { + foreach ($this->requiredProperties as $property) + { if (!isset($model->{$property})) { throw new ApplicationException(Lang::get('system::lang.behavior.missing_property', [ 'class' => get_class($model), diff --git a/modules/system/controllers/EventLogs.php b/modules/system/controllers/EventLogs.php index bc50755cd..37b37e803 100644 --- a/modules/system/controllers/EventLogs.php +++ b/modules/system/controllers/EventLogs.php @@ -18,11 +18,9 @@ use Exception; * * @package october\system * @author Alexey Bobkov, Samuel Georges - * */ class EventLogs extends Controller { - public $implement = [ 'Backend.Behaviors.FormController', 'Backend.Behaviors.ListController' diff --git a/modules/system/controllers/MailLayouts.php b/modules/system/controllers/MailLayouts.php index 17885ce76..cfff5c42f 100644 --- a/modules/system/controllers/MailLayouts.php +++ b/modules/system/controllers/MailLayouts.php @@ -17,11 +17,9 @@ use Exception; * * @package october\system * @author Alexey Bobkov, Samuel Georges - * */ class MailLayouts extends Controller { - public $implement = [ 'Backend.Behaviors.FormController', ]; diff --git a/modules/system/controllers/MailTemplates.php b/modules/system/controllers/MailTemplates.php index e4702c471..9ecc6808e 100644 --- a/modules/system/controllers/MailTemplates.php +++ b/modules/system/controllers/MailTemplates.php @@ -20,11 +20,9 @@ use Exception; * * @package october\system * @author Alexey Bobkov, Samuel Georges - * */ class MailTemplates extends Controller { - public $implement = [ 'Backend.Behaviors.FormController', 'Backend.Behaviors.ListController' diff --git a/modules/system/controllers/RequestLogs.php b/modules/system/controllers/RequestLogs.php index 23b4f4f18..f5348bdb9 100644 --- a/modules/system/controllers/RequestLogs.php +++ b/modules/system/controllers/RequestLogs.php @@ -18,11 +18,9 @@ use Exception; * * @package october\system * @author Alexey Bobkov, Samuel Georges - * */ class RequestLogs extends Controller { - public $implement = [ 'Backend.Behaviors.FormController', 'Backend.Behaviors.ListController' diff --git a/modules/system/models/EventLog.php b/modules/system/models/EventLog.php index f23cb81a9..d70f9fc32 100644 --- a/modules/system/models/EventLog.php +++ b/modules/system/models/EventLog.php @@ -11,7 +11,6 @@ use Model; */ class EventLog extends Model { - /** * @var string The database table used by the model. */ diff --git a/modules/system/models/RequestLog.php b/modules/system/models/RequestLog.php index c6a9cc3a1..00a95971e 100644 --- a/modules/system/models/RequestLog.php +++ b/modules/system/models/RequestLog.php @@ -11,7 +11,6 @@ use Request; */ class RequestLog extends Model { - /** * @var string The database table used by the model. */ diff --git a/modules/system/routes.php b/modules/system/routes.php index 4cf0d0b53..f1090b831 100644 --- a/modules/system/routes.php +++ b/modules/system/routes.php @@ -1,13 +1,11 @@ Date: Mon, 5 Jan 2015 09:16:32 +1100 Subject: [PATCH 03/15] * Build 174 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3a4630a2..9549659d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -* **Build 17x** (2014-12-xx) +* **Build 174** (2015-01-05) - Improved asset caching (`cms.enableAssetCache`), when enabled the server will send a *304 Not Modified* header. - Introduced new *Table* widget and *DataTable* form widget. - There is now a simpler way for sending mail via `Mail::sendTo()`. From 0be582c42da8dc4779f063347e516b8d7600d235 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 09:43:39 +1100 Subject: [PATCH 04/15] getSaveData -> getSaveValue --- modules/backend/classes/FormWidgetBase.php | 5 +++-- modules/backend/formwidgets/ColorPicker.php | 2 +- modules/backend/formwidgets/DataGrid.php | 2 +- modules/backend/formwidgets/DataTable.php | 2 +- modules/backend/formwidgets/DatePicker.php | 2 +- modules/backend/formwidgets/FileUpload.php | 2 +- modules/backend/formwidgets/RecordFinder.php | 2 +- modules/backend/formwidgets/Relation.php | 2 +- modules/backend/widgets/Form.php | 15 +++++++++++++-- 9 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/backend/classes/FormWidgetBase.php b/modules/backend/classes/FormWidgetBase.php index e59458c50..212bfeb5e 100644 --- a/modules/backend/classes/FormWidgetBase.php +++ b/modules/backend/classes/FormWidgetBase.php @@ -87,11 +87,11 @@ abstract class FormWidgetBase extends WidgetBase } /** - * Process the postback data for this widget. + * Process the postback value for this widget. * @param $value The existing value for this widget. * @return string The new value for this widget. */ - public function getSaveData($value) + public function getSaveValue($value) { return $value; } @@ -131,4 +131,5 @@ abstract class FormWidgetBase extends WidgetBase return [$model, $last]; } + } diff --git a/modules/backend/formwidgets/ColorPicker.php b/modules/backend/formwidgets/ColorPicker.php index 463109843..14dd951f8 100644 --- a/modules/backend/formwidgets/ColorPicker.php +++ b/modules/backend/formwidgets/ColorPicker.php @@ -74,7 +74,7 @@ class ColorPicker extends FormWidgetBase /** * {@inheritDoc} */ - public function getSaveData($value) + public function getSaveValue($value) { return strlen($value) ? $value : null; } diff --git a/modules/backend/formwidgets/DataGrid.php b/modules/backend/formwidgets/DataGrid.php index 8a14211ba..705eae131 100644 --- a/modules/backend/formwidgets/DataGrid.php +++ b/modules/backend/formwidgets/DataGrid.php @@ -69,7 +69,7 @@ class DataGrid extends FormWidgetBase /** * {@inheritDoc} */ - public function getSaveData($value) + public function getSaveValue($value) { return json_decode($value); } diff --git a/modules/backend/formwidgets/DataTable.php b/modules/backend/formwidgets/DataTable.php index c41b0f03a..dd62a2c3e 100644 --- a/modules/backend/formwidgets/DataTable.php +++ b/modules/backend/formwidgets/DataTable.php @@ -69,7 +69,7 @@ class DataTable extends FormWidgetBase /** * {@inheritDoc} */ - public function getSaveData($value) + public function getSaveValue($value) { $dataSource = $this->table->getDataSource(); diff --git a/modules/backend/formwidgets/DatePicker.php b/modules/backend/formwidgets/DatePicker.php index 1e283aaff..5a1a9dfce 100644 --- a/modules/backend/formwidgets/DatePicker.php +++ b/modules/backend/formwidgets/DatePicker.php @@ -120,7 +120,7 @@ class DatePicker extends FormWidgetBase /** * {@inheritDoc} */ - public function getSaveData($value) + public function getSaveValue($value) { if (!strlen($value)) { return null; diff --git a/modules/backend/formwidgets/FileUpload.php b/modules/backend/formwidgets/FileUpload.php index 5212de4cf..0358dbc73 100644 --- a/modules/backend/formwidgets/FileUpload.php +++ b/modules/backend/formwidgets/FileUpload.php @@ -195,7 +195,7 @@ class FileUpload extends FormWidgetBase /** * {@inheritDoc} */ - public function getSaveData($value) + public function getSaveValue($value) { return FormField::NO_SAVE_DATA; } diff --git a/modules/backend/formwidgets/RecordFinder.php b/modules/backend/formwidgets/RecordFinder.php index 45db4ff90..83e0fb06c 100644 --- a/modules/backend/formwidgets/RecordFinder.php +++ b/modules/backend/formwidgets/RecordFinder.php @@ -165,7 +165,7 @@ class RecordFinder extends FormWidgetBase /** * {@inheritDoc} */ - public function getSaveData($value) + public function getSaveValue($value) { return strlen($value) ? $value : null; } diff --git a/modules/backend/formwidgets/Relation.php b/modules/backend/formwidgets/Relation.php index 16c576ff1..f976f177c 100644 --- a/modules/backend/formwidgets/Relation.php +++ b/modules/backend/formwidgets/Relation.php @@ -141,7 +141,7 @@ class Relation extends FormWidgetBase /** * {@inheritDoc} */ - public function getSaveData($value) + public function getSaveValue($value) { if (is_string($value) && !strlen($value)) { return null; diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index 3081793bc..445bf6eae 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -710,7 +710,9 @@ class Form extends WidgetBase } $fieldName = $field->fieldName; - $defaultValue = (!$this->model->exists && $field->defaults !== '') ? $field->defaults : null; + $defaultValue = (!$this->model->exists && $field->defaults !== '') + ? $field->defaults + : null; /* * Array field name, eg: field[key][key2][key3] @@ -806,7 +808,16 @@ class Form extends WidgetBase $parts = Str::evalHtmlArray($field); $dotted = implode('.', $parts); - $widgetValue = $widget->getSaveData(array_get($data, $dotted)); + $widgetValue = $widget->getSaveValue(array_get($data, $dotted)); + + /* + * @deprecated Remove if year >= 2016 + */ + if (method_exists($widget, 'getSaveData')) { + traceLog('Method getSaveData() is deprecated, use getSaveValue() instead. Found in: ' . get_class($widget), 'warning'); + $widgetValue = $widget->getSaveData(array_get($data, $dotted)); + } + array_set($data, $dotted, $widgetValue); } From d91d4112a575c8615e4f8c9c7fac59bd7a344806 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 09:45:04 +1100 Subject: [PATCH 05/15] getLoadData -> getLoadValue --- modules/backend/classes/FormWidgetBase.php | 2 +- modules/backend/formwidgets/CodeEditor.php | 2 +- modules/backend/formwidgets/ColorPicker.php | 2 +- modules/backend/formwidgets/DataTable.php | 2 +- modules/backend/formwidgets/DatePicker.php | 2 +- modules/backend/formwidgets/RecordFinder.php | 2 +- modules/backend/formwidgets/RichEditor.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/backend/classes/FormWidgetBase.php b/modules/backend/classes/FormWidgetBase.php index 212bfeb5e..ca9d2e541 100644 --- a/modules/backend/classes/FormWidgetBase.php +++ b/modules/backend/classes/FormWidgetBase.php @@ -101,7 +101,7 @@ abstract class FormWidgetBase extends WidgetBase * supports nesting via HTML array. * @return string */ - public function getLoadData() + public function getLoadValue() { list($model, $attribute) = $this->getModelArrayAttribute($this->valueFrom); diff --git a/modules/backend/formwidgets/CodeEditor.php b/modules/backend/formwidgets/CodeEditor.php index 605f3d2b5..701f837c3 100644 --- a/modules/backend/formwidgets/CodeEditor.php +++ b/modules/backend/formwidgets/CodeEditor.php @@ -106,7 +106,7 @@ class CodeEditor extends FormWidgetBase $this->vars['stretch'] = $this->formField->stretch; $this->vars['size'] = $this->formField->size; $this->vars['name'] = $this->formField->getName(); - $this->vars['value'] = $this->getLoadData(); + $this->vars['value'] = $this->getLoadValue(); } /** diff --git a/modules/backend/formwidgets/ColorPicker.php b/modules/backend/formwidgets/ColorPicker.php index 14dd951f8..6aeef0682 100644 --- a/modules/backend/formwidgets/ColorPicker.php +++ b/modules/backend/formwidgets/ColorPicker.php @@ -55,7 +55,7 @@ class ColorPicker extends FormWidgetBase public function prepareVars() { $this->vars['name'] = $this->formField->getName(); - $this->vars['value'] = $value = $this->getLoadData(); + $this->vars['value'] = $value = $this->getLoadValue(); $this->vars['availableColors'] = $this->availableColors; $this->vars['isCustomColor'] = !in_array($value, $this->availableColors); } diff --git a/modules/backend/formwidgets/DataTable.php b/modules/backend/formwidgets/DataTable.php index dd62a2c3e..7c9eb3d1f 100644 --- a/modules/backend/formwidgets/DataTable.php +++ b/modules/backend/formwidgets/DataTable.php @@ -87,7 +87,7 @@ class DataTable extends FormWidgetBase protected function populateTableWidget() { $dataSource = $this->table->getDataSource(); - $records = $this->getLoadData() ?: []; + $records = $this->getLoadValue() ?: []; $dataSource->initRecords((array) $records); } diff --git a/modules/backend/formwidgets/DatePicker.php b/modules/backend/formwidgets/DatePicker.php index 5a1a9dfce..0c1fabf42 100644 --- a/modules/backend/formwidgets/DatePicker.php +++ b/modules/backend/formwidgets/DatePicker.php @@ -62,7 +62,7 @@ class DatePicker extends FormWidgetBase $this->vars['timeName'] = self::TIME_PREFIX.$this->formField->getName(false); $this->vars['timeValue'] = null; - if ($value = $this->getLoadData()) { + if ($value = $this->getLoadValue()) { /* * Date / Time diff --git a/modules/backend/formwidgets/RecordFinder.php b/modules/backend/formwidgets/RecordFinder.php index 83e0fb06c..f4e68f80b 100644 --- a/modules/backend/formwidgets/RecordFinder.php +++ b/modules/backend/formwidgets/RecordFinder.php @@ -143,7 +143,7 @@ class RecordFinder extends FormWidgetBase public function prepareVars() { // This should be a relation and return a Model - $this->relationModel = $this->getLoadData(); + $this->relationModel = $this->getLoadValue(); $this->vars['value'] = $this->getKeyValue(); $this->vars['field'] = $this->formField; diff --git a/modules/backend/formwidgets/RichEditor.php b/modules/backend/formwidgets/RichEditor.php index 5e626f7a6..945834214 100644 --- a/modules/backend/formwidgets/RichEditor.php +++ b/modules/backend/formwidgets/RichEditor.php @@ -41,7 +41,7 @@ class RichEditor extends FormWidgetBase $this->vars['stretch'] = $this->formField->stretch; $this->vars['size'] = $this->formField->size; $this->vars['name'] = $this->formField->getName(); - $this->vars['value'] = $this->getLoadData(); + $this->vars['value'] = $this->getLoadValue(); } /** From 5d2a177646d04d77e2135d9ce6fca3b85c0c14c8 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 11:18:43 +1100 Subject: [PATCH 06/15] getModelArrayAttribute -> resolveModelAttribute --- modules/backend/classes/FormWidgetBase.php | 6 +++--- modules/backend/formwidgets/FileUpload.php | 4 ++-- modules/backend/formwidgets/RecordFinder.php | 2 +- modules/backend/formwidgets/Relation.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/backend/classes/FormWidgetBase.php b/modules/backend/classes/FormWidgetBase.php index ca9d2e541..1fb2be4b9 100644 --- a/modules/backend/classes/FormWidgetBase.php +++ b/modules/backend/classes/FormWidgetBase.php @@ -103,7 +103,7 @@ abstract class FormWidgetBase extends WidgetBase */ public function getLoadValue() { - list($model, $attribute) = $this->getModelArrayAttribute($this->valueFrom); + list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom); if (!is_null($model)) { return $model->{$attribute}; @@ -115,11 +115,11 @@ abstract class FormWidgetBase extends WidgetBase /** * Returns the final model and attribute name of * a nested HTML array attribute. - * Eg: list($model, $attribute) = $this->getModelArrayAttribute($this->valueFrom); + * Eg: list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom); * @param string $attribute. * @return array */ - public function getModelArrayAttribute($attribute) + public function resolveModelAttribute($attribute) { $model = $this->model; $parts = Str::evalHtmlArray($attribute); diff --git a/modules/backend/formwidgets/FileUpload.php b/modules/backend/formwidgets/FileUpload.php index 0358dbc73..929d5a757 100644 --- a/modules/backend/formwidgets/FileUpload.php +++ b/modules/backend/formwidgets/FileUpload.php @@ -109,7 +109,7 @@ class FileUpload extends FormWidgetBase */ protected function getRelationObject() { - list($model, $attribute) = $this->getModelArrayAttribute($this->valueFrom); + list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom); return $model->{$attribute}(); } @@ -120,7 +120,7 @@ class FileUpload extends FormWidgetBase */ protected function getRelationType() { - list($model, $attribute) = $this->getModelArrayAttribute($this->valueFrom); + list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom); return $model->getRelationType($attribute); } diff --git a/modules/backend/formwidgets/RecordFinder.php b/modules/backend/formwidgets/RecordFinder.php index f4e68f80b..a2b57e5e8 100644 --- a/modules/backend/formwidgets/RecordFinder.php +++ b/modules/backend/formwidgets/RecordFinder.php @@ -130,7 +130,7 @@ class RecordFinder extends FormWidgetBase public function onRefresh() { - list($model, $attribute) = $this->getModelArrayAttribute($this->valueFrom); + list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom); $model->{$attribute} = post($this->formField->getName()); $this->prepareVars(); diff --git a/modules/backend/formwidgets/Relation.php b/modules/backend/formwidgets/Relation.php index f976f177c..bfd8d97b7 100644 --- a/modules/backend/formwidgets/Relation.php +++ b/modules/backend/formwidgets/Relation.php @@ -104,7 +104,7 @@ class Relation extends FormWidgetBase $field = clone $this->formField; - list($model, $attribute) = $this->getModelArrayAttribute($this->relationName); + list($model, $attribute) = $this->resolveModelAttribute($this->relationName); $relatedObj = $model->makeRelation($attribute); $query = $model->{$attribute}()->newQuery(); From 8b45ed4178768077609e0aefb7dcabf2b66f0e7a Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 11:30:03 +1100 Subject: [PATCH 07/15] Remove functional tests from the standard phpunit process --- phpunit.xml | 2 +- tests/{ => functional}/phpunit.xml | 2 +- tests/unit/phpunit.xml | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) rename tests/{ => functional}/phpunit.xml (89%) create mode 100644 tests/unit/phpunit.xml diff --git a/phpunit.xml b/phpunit.xml index 417aa24b2..f2b4406ab 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -12,7 +12,7 @@ > - ./tests + ./tests/unit ./vendor/october/rain/tests diff --git a/tests/phpunit.xml b/tests/functional/phpunit.xml similarity index 89% rename from tests/phpunit.xml rename to tests/functional/phpunit.xml index e29aad30f..a5415e7e5 100644 --- a/tests/phpunit.xml +++ b/tests/functional/phpunit.xml @@ -1,7 +1,7 @@ + + + + ./ + + + \ No newline at end of file From 2160ddf3e543e1fd4e00d5cb86d6644189a3a961 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 11:46:33 +1100 Subject: [PATCH 08/15] Fixes unit test - normalize plugin paths for Win systems --- modules/system/classes/PluginManager.php | 3 +-- tests/unit/system/classes/PluginManagerTest.php | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index 507d75c3e..491822060 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -211,7 +211,6 @@ class PluginManager /** * Returns the directory path to a plugin - * */ public function getPluginPath($id) { @@ -220,7 +219,7 @@ class PluginManager return null; } - return $this->pathMap[$classId]; + return File::normalizePath($this->pathMap[$classId]); } /** diff --git a/tests/unit/system/classes/PluginManagerTest.php b/tests/unit/system/classes/PluginManagerTest.php index ff0a92f5a..dbfcff19a 100644 --- a/tests/unit/system/classes/PluginManagerTest.php +++ b/tests/unit/system/classes/PluginManagerTest.php @@ -72,7 +72,8 @@ class PluginManagerTest extends TestCase { $manager = PluginManager::instance(); $result = $manager->getPluginPath('October\Tester'); - $this->assertEquals(base_path() . '/tests/fixtures/system/plugins/october/tester', $result); + $basePath = str_replace('\\', '/', base_path()); + $this->assertEquals($basePath . '/tests/fixtures/system/plugins/october/tester', $result); } public function testGetPlugins() From 415f07eb1d98d03f1fbe733b24ba0846ef3a0fe7 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 12:37:04 +1100 Subject: [PATCH 09/15] Fixes various unit tests so they pass (Tested in Windows) --- app/config/testing/cms.php | 12 +++++++++ modules/cms/classes/SectionParser.php | 3 +++ modules/system/behaviors/SettingsModel.php | 3 ++- modules/system/classes/SystemException.php | 9 ++++++- .../cms/classes/CmsCompoundObjectTest.php | 25 ++++++++++++++++--- tests/unit/cms/classes/CmsObjectTest.php | 2 +- tests/unit/cms/classes/CodeParserTest.php | 16 ++++++++++-- tests/unit/cms/classes/FileHelperTest.php | 21 +++++++++++++--- tests/unit/cms/classes/RouterTest.php | 7 +++--- tests/unit/cms/classes/ThemeTest.php | 2 +- 10 files changed, 83 insertions(+), 17 deletions(-) diff --git a/app/config/testing/cms.php b/app/config/testing/cms.php index 7343d99a2..181bada7d 100644 --- a/app/config/testing/cms.php +++ b/app/config/testing/cms.php @@ -96,4 +96,16 @@ return array( */ 'twigNoCache' => true, + + /* + |-------------------------------------------------------------------------- + | Convert Line Endings + |-------------------------------------------------------------------------- + | + | Determines if October should convert line endings from the windows style + | \r\n to the unix style \n. + | + */ + + 'convertLineEndings' => true, ); diff --git a/modules/cms/classes/SectionParser.php b/modules/cms/classes/SectionParser.php index 74027e3e0..a9e913684 100644 --- a/modules/cms/classes/SectionParser.php +++ b/modules/cms/classes/SectionParser.php @@ -1,5 +1,7 @@ getSettingsRecord() !== null; + return DbDongle::hasDatabase() && $this->getSettingsRecord() !== null; } /** diff --git a/modules/system/classes/SystemException.php b/modules/system/classes/SystemException.php index cad2361cd..b7d40c0f5 100644 --- a/modules/system/classes/SystemException.php +++ b/modules/system/classes/SystemException.php @@ -1,5 +1,6 @@ assertFileExists($referenceFilePath); $this->assertFileExists($destFilePath); - $this->assertFileEquals($referenceFilePath, $destFilePath); + $this->assertFileEqualsNormalized($referenceFilePath, $destFilePath); } public function testSaveMarkupAndSettings() @@ -187,7 +187,7 @@ class CmsCompoundObjectTest extends TestCase $this->assertFileExists($referenceFilePath); $this->assertFileExists($destFilePath); - $this->assertFileEquals($referenceFilePath, $destFilePath); + $this->assertFileEqualsNormalized($referenceFilePath, $destFilePath); } public function testSaveFull() @@ -195,8 +195,9 @@ class CmsCompoundObjectTest extends TestCase $theme = Theme::load('apitest'); $destFilePath = $theme->getPath().'/testobjects/compound.htm'; - if (file_exists($destFilePath)) + if (file_exists($destFilePath)) { unlink($destFilePath); + } $this->assertFileNotExists($destFilePath); @@ -213,6 +214,22 @@ class CmsCompoundObjectTest extends TestCase $this->assertFileExists($referenceFilePath); $this->assertFileExists($destFilePath); - $this->assertFileEquals($referenceFilePath, $destFilePath); + $this->assertFileEqualsNormalized($referenceFilePath, $destFilePath); } + + // + // Helpers + // + + protected function assertFileEqualsNormalized($expected, $actual) + { + $expected = file_get_contents($expected); + $expected = preg_replace('~\R~u', PHP_EOL, $expected); // Normalize EOL + + $actual = file_get_contents($actual); + $actual = preg_replace('~\R~u', PHP_EOL, $actual); // Normalize EOL + + $this->assertEquals($expected, $actual); + } + } \ No newline at end of file diff --git a/tests/unit/cms/classes/CmsObjectTest.php b/tests/unit/cms/classes/CmsObjectTest.php index f74193b16..481fc4a33 100644 --- a/tests/unit/cms/classes/CmsObjectTest.php +++ b/tests/unit/cms/classes/CmsObjectTest.php @@ -141,7 +141,7 @@ class CmsObjectTest extends TestCase /** * @expectedException \System\Classes\ApplicationException - * @expectedExceptionMessage The property "something" cannot be set + * @expectedExceptionMessage The property 'something' cannot be set */ public function testFillNotFillable() { diff --git a/tests/unit/cms/classes/CodeParserTest.php b/tests/unit/cms/classes/CodeParserTest.php index e87d79e1d..00799b932 100644 --- a/tests/unit/cms/classes/CodeParserTest.php +++ b/tests/unit/cms/classes/CodeParserTest.php @@ -253,10 +253,22 @@ class CodeParserTest extends TestCase $referenceFilePath = base_path().'/tests/fixtures/cms/reference/namespaces.php'; $this->assertFileExists($referenceFilePath); - $referenceContents = file_get_contents($referenceFilePath); + $referenceContents = $this->getContents($referenceFilePath); $referenceContents = str_replace('{className}', $info['className'], $referenceContents); - $this->assertEquals($referenceContents, file_get_contents($info['filePath'])); + $this->assertEquals($referenceContents, $this->getContents($info['filePath'])); } + + // + // Helpers + // + + protected function getContents($path) + { + $content = file_get_contents($path); + $content = preg_replace('~\R~u', PHP_EOL, $content); // Normalize EOL + return $content; + } + } \ No newline at end of file diff --git a/tests/unit/cms/classes/FileHelperTest.php b/tests/unit/cms/classes/FileHelperTest.php index 2b9075ea1..f8f66d324 100644 --- a/tests/unit/cms/classes/FileHelperTest.php +++ b/tests/unit/cms/classes/FileHelperTest.php @@ -28,7 +28,7 @@ class FileHelperTest extends TestCase $str = FileHelper::formatIniString($data); $this->assertNotEmpty($str); - $this->assertEquals(file_get_contents($path), $str); + $this->assertEquals($this->getContents($path), $str); $data = [ 'section' => [ @@ -47,7 +47,7 @@ class FileHelperTest extends TestCase $this->assertFileExists($path); $str = FileHelper::formatIniString($data); - $this->assertEquals(file_get_contents($path), $str); + $this->assertEquals($this->getContents($path), $str); $data = [ 'section' => [ @@ -75,6 +75,21 @@ class FileHelperTest extends TestCase $this->assertFileExists($path); $str = FileHelper::formatIniString($data); - $this->assertEquals(file_get_contents($path), $str); + $this->assertEquals($this->getContents($path), $str); } + + // + // Helpers + // + + protected function getContents($path) + { + $content = file_get_contents($path); + + // Normalize EOL + $content = preg_replace('~\R~u', PHP_EOL, $content); + + return $content; + } + } diff --git a/tests/unit/cms/classes/RouterTest.php b/tests/unit/cms/classes/RouterTest.php index b1d75936c..12c3c402f 100644 --- a/tests/unit/cms/classes/RouterTest.php +++ b/tests/unit/cms/classes/RouterTest.php @@ -6,11 +6,10 @@ use Cms\Classes\Theme; class RouterTest extends TestCase { protected static $theme = null; - + public static function setUpBeforeClass() { - self::$theme = new Theme(); - self::$theme->load('test'); + self::$theme = Theme::load('test'); } protected static function getMethod($name) @@ -28,7 +27,7 @@ class RouterTest extends TestCase $property->setAccessible(true); return $property; } - + public function testLoadUrlMap() { $method = self::getMethod('loadUrlMap'); diff --git a/tests/unit/cms/classes/ThemeTest.php b/tests/unit/cms/classes/ThemeTest.php index 3c5b65c20..f3192aa56 100644 --- a/tests/unit/cms/classes/ThemeTest.php +++ b/tests/unit/cms/classes/ThemeTest.php @@ -2,7 +2,7 @@ use Cms\Classes\Theme; -class ThemeTest extends TestCase +class ThemeTest extends TestCase { public function setUp() { From 54ecf8d33a662842a9afaa00961b2ff76ecdf99d Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 12:37:59 +1100 Subject: [PATCH 10/15] Minor --- tests/unit/cms/classes/FileHelperTest.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/unit/cms/classes/FileHelperTest.php b/tests/unit/cms/classes/FileHelperTest.php index f8f66d324..43f7f6ae4 100644 --- a/tests/unit/cms/classes/FileHelperTest.php +++ b/tests/unit/cms/classes/FileHelperTest.php @@ -85,10 +85,7 @@ class FileHelperTest extends TestCase protected function getContents($path) { $content = file_get_contents($path); - - // Normalize EOL - $content = preg_replace('~\R~u', PHP_EOL, $content); - + $content = preg_replace('~\R~u', PHP_EOL, $content); // Normalize EOL return $content; } From b74b19741b6181b740fdb19b8ba0b748be44ccea Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 12:54:14 +1100 Subject: [PATCH 11/15] Unify the logic for getting field values from a dataset Amongst Form Widgets and "the" Form widget ping @alekseybobkov --- modules/backend/classes/FormField.php | 50 ++++++++++++++++++++ modules/backend/classes/FormWidgetBase.php | 8 +--- modules/backend/formwidgets/RecordFinder.php | 15 +++++- modules/backend/widgets/Form.php | 40 +--------------- 4 files changed, 66 insertions(+), 47 deletions(-) diff --git a/modules/backend/classes/FormField.php b/modules/backend/classes/FormField.php index 67b2fdacc..c67b6c5c6 100644 --- a/modules/backend/classes/FormField.php +++ b/modules/backend/classes/FormField.php @@ -395,4 +395,54 @@ class FormField return Str::evalHtmlId($id); } + + /** + * Returns this fields value from a supplied data set, which can be + * an array or a model or another generic collection. + * @param mixed $data + * @return mixed + */ + public function getValueFromData($data, $default = null) + { + $fieldName = $this->fieldName; + + /* + * Array field name, eg: field[key][key2][key3] + */ + $keyParts = Str::evalHtmlArray($fieldName); + $lastField = end($keyParts); + $result = $data; + + /* + * Loop the field key parts and build a value. + * To support relations only the last field should return the + * relation value, all others will look up the relation object as normal. + */ + foreach ($keyParts as $key) { + + if ($result instanceof Model && $result->hasRelation($key)) { + if ($key == $lastField) { + $result = $result->getRelationValue($key) ?: $default; + } + else { + $result = $result->{$key}; + } + } + elseif (is_array($result)) { + if (!array_key_exists($key, $result)) { + return $default; + } + $result = $result[$key]; + } + else { + if (!isset($result->{$key})) { + return $default; + } + $result = $result->{$key}; + } + + } + + return $result; + } } diff --git a/modules/backend/classes/FormWidgetBase.php b/modules/backend/classes/FormWidgetBase.php index 1fb2be4b9..da539c723 100644 --- a/modules/backend/classes/FormWidgetBase.php +++ b/modules/backend/classes/FormWidgetBase.php @@ -103,13 +103,7 @@ abstract class FormWidgetBase extends WidgetBase */ public function getLoadValue() { - list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom); - - if (!is_null($model)) { - return $model->{$attribute}; - } - - return null; + return $this->formField->getValueFromData($this->model); } /** diff --git a/modules/backend/formwidgets/RecordFinder.php b/modules/backend/formwidgets/RecordFinder.php index a2b57e5e8..3e94b77fb 100644 --- a/modules/backend/formwidgets/RecordFinder.php +++ b/modules/backend/formwidgets/RecordFinder.php @@ -142,7 +142,6 @@ class RecordFinder extends FormWidgetBase */ public function prepareVars() { - // This should be a relation and return a Model $this->relationModel = $this->getLoadValue(); $this->vars['value'] = $this->getKeyValue(); @@ -170,6 +169,20 @@ class RecordFinder extends FormWidgetBase return strlen($value) ? $value : null; } + /** + * {@inheritDoc} + */ + public function getLoadValue() + { + list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom); + + if (!is_null($model)) { + return $model->{$attribute}; + } + + return null; + } + public function getKeyValue() { if (!$this->relationModel) { diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index 445bf6eae..b9b388155 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -709,49 +709,11 @@ class Form extends WidgetBase $field = $this->fields[$field]; } - $fieldName = $field->fieldName; $defaultValue = (!$this->model->exists && $field->defaults !== '') ? $field->defaults : null; - /* - * Array field name, eg: field[key][key2][key3] - */ - $keyParts = Str::evalHtmlArray($fieldName); - $lastField = end($keyParts); - $result = $this->data; - - /* - * Loop the field key parts and build a value. - * To support relations only the last field should return the - * relation value, all others will look up the relation object as normal. - */ - foreach ($keyParts as $key) { - - if ($result instanceof Model && $result->hasRelation($key)) { - if ($key == $lastField) { - $result = $result->getRelationValue($key) ?: $defaultValue; - } - else { - $result = $result->{$key}; - } - } - elseif (is_array($result)) { - if (!array_key_exists($key, $result)) { - return $defaultValue; - } - $result = $result[$key]; - } - else { - if (!isset($result->{$key})) { - return $defaultValue; - } - $result = $result->{$key}; - } - - } - - return $result; + return $field->getValueFromData($this->data, $defaultValue); } /** From f4487076b7bfea1281b285def07d2c246bb0fcb4 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 13:12:48 +1100 Subject: [PATCH 12/15] Remove some legacy code, no need to pipe WidgetMaker thru WidgetManager --- modules/backend/classes/WidgetManager.php | 30 ----------------------- modules/backend/traits/WidgetMaker.php | 15 ++++++++---- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/modules/backend/classes/WidgetManager.php b/modules/backend/classes/WidgetManager.php index b46cc3623..399c6df7e 100644 --- a/modules/backend/classes/WidgetManager.php +++ b/modules/backend/classes/WidgetManager.php @@ -2,12 +2,10 @@ use Str; use File; -use Lang; use Closure; use October\Rain\Support\Yaml; use Illuminate\Container\Container; use System\Classes\PluginManager; -use System\Classes\SystemException; /** * Widget manager @@ -57,34 +55,6 @@ class WidgetManager $this->pluginManager = PluginManager::instance(); } - /** - * Makes a widget object with configuration set. - * @param string $className A widget class name. - * @param Controller $controller The Backend controller that spawned this widget. - * @param array $configuration Configuration values. - * @return WidgetBase The widget object. - */ - public function makeWidget($className, $controller = null, $configuration = null) - { - /* - * Build configuration - */ - if ($configuration === null) { - $configuration = []; - } - - /* - * Create widget object - */ - if (!class_exists($className)) { - throw new SystemException(Lang::get('backend::lang.widget.not_registered', [ - 'name' => $className - ])); - } - - return new $className($controller, $configuration); - } - // // Form Widgets // diff --git a/modules/backend/traits/WidgetMaker.php b/modules/backend/traits/WidgetMaker.php index d67540746..d27fb745a 100644 --- a/modules/backend/traits/WidgetMaker.php +++ b/modules/backend/traits/WidgetMaker.php @@ -1,5 +1,6 @@ controller) ?: $this; - $manager = WidgetManager::instance(); - $widget = $manager->makeWidget($class, $controller, $configuration); - return $widget; + if (!class_exists($class)) { + throw new SystemException(Lang::get('backend::lang.widget.not_registered', [ + 'name' => $class + ])); + } + + return new $class($controller, $configuration); } } From dc6098c08979ec095eaded04f2c090d53d2d0fba Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 13:22:40 +1100 Subject: [PATCH 13/15] Create unit tests for WidgetMaker trait --- modules/backend/traits/WidgetMaker.php | 4 +- .../backend/classes/WidgetManagerTest.php | 17 ------ tests/unit/backend/traits/WidgetMakerTest.php | 60 +++++++++++++++++++ 3 files changed, 63 insertions(+), 18 deletions(-) create mode 100644 tests/unit/backend/traits/WidgetMakerTest.php diff --git a/modules/backend/traits/WidgetMaker.php b/modules/backend/traits/WidgetMaker.php index d27fb745a..5ad8c50c3 100644 --- a/modules/backend/traits/WidgetMaker.php +++ b/modules/backend/traits/WidgetMaker.php @@ -24,7 +24,9 @@ trait WidgetMaker */ public function makeWidget($class, $configuration = []) { - $controller = ($this->controller) ?: $this; + $controller = property_exists($this, 'controller') && $this->controller + ? $this->controller + : $this; if (!class_exists($class)) { throw new SystemException(Lang::get('backend::lang.widget.not_registered', [ diff --git a/tests/unit/backend/classes/WidgetManagerTest.php b/tests/unit/backend/classes/WidgetManagerTest.php index 45d2b6aec..936c65779 100644 --- a/tests/unit/backend/classes/WidgetManagerTest.php +++ b/tests/unit/backend/classes/WidgetManagerTest.php @@ -5,23 +5,6 @@ use Backend\Classes\WidgetManager; class WidgetManagerTest extends TestCase { - public function testMakeWidget() - { - $manager = WidgetManager::instance(); - $widget = $manager->makeWidget('Backend\Widgets\Search'); - $this->assertTrue($widget instanceof \Backend\Widgets\Search); - - $controller = new Controller; - $widget = $manager->makeWidget('Backend\Widgets\Search', $controller); - $this->assertInstanceOf('Backend\Widgets\Search', $widget); - $this->assertInstanceOf('Backend\Classes\Controller', $widget->getController()); - - $config = ['test' => 'config']; - $widget = $manager->makeWidget('Backend\Widgets\Search', null, $config); - $this->assertInstanceOf('Backend\Widgets\Search', $widget); - $this->assertEquals('config', $widget->getConfig('test')); - } - public function testListFormWidgets() { $manager = WidgetManager::instance(); diff --git a/tests/unit/backend/traits/WidgetMakerTest.php b/tests/unit/backend/traits/WidgetMakerTest.php new file mode 100644 index 000000000..3401fe6df --- /dev/null +++ b/tests/unit/backend/traits/WidgetMakerTest.php @@ -0,0 +1,60 @@ +controller = new Controller; + } +} + +class WidgetMakerTest extends TestCase +{ + /** + * The object under test. + * + * @var object + */ + private $traitObject; + + /** + * Sets up the fixture. + * + * This method is called before a test is executed. + * + * @return void + */ + public function setUp() + { + $traitName = 'Backend\Traits\WidgetMaker'; + $this->traitObject = $this->getObjectForTrait($traitName); + } + + public function testTraitObject() + { + $maker = $this->traitObject; + + $widget = $maker->makeWidget('Backend\Widgets\Search'); + $this->assertTrue($widget instanceof \Backend\Widgets\Search); + } + + public function testMakeWidget() + { + $manager = new ExampleTraitClass; + + $controller = new Controller; + $widget = $manager->makeWidget('Backend\Widgets\Search'); + $this->assertInstanceOf('Backend\Widgets\Search', $widget); + $this->assertInstanceOf('Backend\Classes\Controller', $widget->getController()); + + $config = ['test' => 'config']; + $widget = $manager->makeWidget('Backend\Widgets\Search', $config); + $this->assertInstanceOf('Backend\Widgets\Search', $widget); + $this->assertEquals('config', $widget->getConfig('test')); + } + +} \ No newline at end of file From 55a68be13b9e5b9d8e13739954c1901f19b6600b Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 14:57:17 +1100 Subject: [PATCH 14/15] Check for the presence of validation errors in the session, and add it to the view --- modules/cms/classes/Controller.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/cms/classes/Controller.php b/modules/cms/classes/Controller.php index d29d813dc..0a72a6590 100644 --- a/modules/cms/classes/Controller.php +++ b/modules/cms/classes/Controller.php @@ -235,6 +235,13 @@ class Controller extends BaseController 'environment' => App::environment(), ]; + /* + * Check for the presence of validation errors in the session. + */ + $this->vars['errors'] = (Config::get('session.driver') && \Session::has('errors')) + ? \Session::get('errors') + : new \Illuminate\Support\ViewErrorBag; + /* * Handle AJAX requests and execute the life cycle functions */ From b08020fd4c6816640f33e6419f08fef62b1df5d6 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 5 Jan 2015 15:02:22 +1100 Subject: [PATCH 15/15] Update CHANGELOG --- CHANGELOG.md | 3 +++ modules/cms/classes/Controller.php | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9549659d1..74c8716a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* **Build 17x** (2015-01-xx) + - The variable `errors` will be included in a CMS page when redirecting via `Redirect::withErrors($validator)`. + * **Build 174** (2015-01-05) - Improved asset caching (`cms.enableAssetCache`), when enabled the server will send a *304 Not Modified* header. - Introduced new *Table* widget and *DataTable* form widget. diff --git a/modules/cms/classes/Controller.php b/modules/cms/classes/Controller.php index 0a72a6590..dcb14b242 100644 --- a/modules/cms/classes/Controller.php +++ b/modules/cms/classes/Controller.php @@ -8,6 +8,7 @@ use View; use Lang; use Event; use Config; +use Session; use Request; use Response; use Exception; @@ -238,8 +239,8 @@ class Controller extends BaseController /* * Check for the presence of validation errors in the session. */ - $this->vars['errors'] = (Config::get('session.driver') && \Session::has('errors')) - ? \Session::get('errors') + $this->vars['errors'] = (Config::get('session.driver') && Session::has('errors')) + ? Session::get('errors') : new \Illuminate\Support\ViewErrorBag; /*