From 802f96f10ecfbc6b9c58de227774da15c5696ed1 Mon Sep 17 00:00:00 2001 From: alekseybobkov Date: Mon, 3 Nov 2014 20:50:18 -0800 Subject: [PATCH] Refactoring of the view bag support code --- modules/cms/classes/CmsCompoundObject.php | 18 ++++++++++++++++++ modules/cms/controllers/Index.php | 3 +++ 2 files changed, 21 insertions(+) diff --git a/modules/cms/classes/CmsCompoundObject.php b/modules/cms/classes/CmsCompoundObject.php index deb9f8673..33a286331 100644 --- a/modules/cms/classes/CmsCompoundObject.php +++ b/modules/cms/classes/CmsCompoundObject.php @@ -43,6 +43,12 @@ class CmsCompoundObject extends CmsObject */ public $markup; + /** + * @var array Contains the view bag properties. + * This property is used by the page editor internally. + */ + public $viewBag = []; + protected static $fillable = [ 'markup', 'settings', @@ -417,6 +423,18 @@ class CmsCompoundObject extends CmsObject */ protected function parseSettings() { + $this->fillViewBagArray(); + } + + /* + * Copies view bag properties to the view bag array. + * This is required for the back-end editors. + */ + protected function fillViewBagArray() + { + $viewBag = $this->getViewBag(); + foreach ($viewBag->getProperties() as $name=>$value) + $this->viewBag[$name] = $value; } /** diff --git a/modules/cms/controllers/Index.php b/modules/cms/controllers/Index.php index 3c4f23d93..ae5498df6 100644 --- a/modules/cms/controllers/Index.php +++ b/modules/cms/controllers/Index.php @@ -440,6 +440,9 @@ class Index extends Controller $settings[$section] = $properties; } + if (array_key_exists('viewBag', $_POST)) + $settings['viewBag'] = $_POST['viewBag']; + return $settings; }