diff --git a/modules/backend/assets/css/october.css b/modules/backend/assets/css/october.css index 0e017d837..0efc517d9 100644 --- a/modules/backend/assets/css/october.css +++ b/modules/backend/assets/css/october.css @@ -7753,7 +7753,7 @@ nav#layout-mainmenu.navbar ul li.preview i { } nav#layout-mainmenu.navbar ul li.power-off a, nav#layout-mainmenu.navbar ul li.preview a { - padding: 20px; + padding: 22px 20px 20px 20px; } nav#layout-mainmenu.navbar ul li.account { margin-right: 0; diff --git a/modules/backend/assets/less/layout/mainmenu.less b/modules/backend/assets/less/layout/mainmenu.less index a09d2eb16..37ba22120 100644 --- a/modules/backend/assets/less/layout/mainmenu.less +++ b/modules/backend/assets/less/layout/mainmenu.less @@ -56,7 +56,7 @@ nav#layout-mainmenu.navbar { &.power-off, &.preview { i {font-size: 20px;} - a {padding: 20px;} + a {padding: 22px 20px 20px 20px;} } &.account { diff --git a/modules/cms/ServiceProvider.php b/modules/cms/ServiceProvider.php index e162910c0..35082ca9d 100644 --- a/modules/cms/ServiceProvider.php +++ b/modules/cms/ServiceProvider.php @@ -7,6 +7,7 @@ use BackendAuth; use Backend\Classes\WidgetManager; use October\Rain\Support\ModuleServiceProvider; use System\Classes\SettingsManager; +use Cms\Classes\ComponentManager; class ServiceProvider extends ModuleServiceProvider { @@ -116,6 +117,13 @@ class ServiceProvider extends ModuleServiceProvider ] ]); }); + + /* + * Register components + */ + ComponentManager::instance()->registerComponents(function($manager){ + $manager->registerComponent('Cms\Classes\ViewBag', 'viewBag'); + }); } /** diff --git a/modules/cms/assets/js/october.cmspage.js b/modules/cms/assets/js/october.cmspage.js index fc229401b..23431f044 100644 --- a/modules/cms/assets/js/october.cmspage.js +++ b/modules/cms/assets/js/october.cmspage.js @@ -367,7 +367,7 @@ var $componentList = $('.control-componentlist', pane), $primaryPanel = $('.control-tabs.primary', pane), $primaryTabContainer = $('.nav-tabs', $primaryPanel), - hasComponents = $('.layout', $componentList).children().length > 0 + hasComponents = $('.layout', $componentList).children(':not(.hidden)').length > 0 $primaryTabContainer.toggleClass('component-area', hasComponents) $componentList.toggleClass('has-components', hasComponents) diff --git a/modules/cms/classes/ComponentBase.php b/modules/cms/classes/ComponentBase.php index ec001ce6b..559ab3bb1 100644 --- a/modules/cms/classes/ComponentBase.php +++ b/modules/cms/classes/ComponentBase.php @@ -34,6 +34,11 @@ abstract class ComponentBase extends Extendable */ public $name; + /** + * @var boolean Determines whether the component is hidden in the back-end UI. + */ + public $isHidden = false; + /** * @var string Icon of the plugin that defines the component. * This field is used by the CMS internally. diff --git a/modules/cms/classes/ComponentManager.php b/modules/cms/classes/ComponentManager.php index ed0f3cfb8..e3792f4ce 100644 --- a/modules/cms/classes/ComponentManager.php +++ b/modules/cms/classes/ComponentManager.php @@ -100,6 +100,9 @@ class ComponentManager if (!$code) $code = Str::getClassId($className); + if ($code == 'viewBag' && $className != 'Cms\Classes\ViewBag') + throw new SystemException(sprintf('The component code viewBag is reserved. Please use another code for the component class %s.', $className)); + $className = Str::normalizeClassName($className); $this->codeMap[$code] = $className; $this->classMap[$className] = $code; diff --git a/modules/cms/classes/ViewBag.php b/modules/cms/classes/ViewBag.php new file mode 100644 index 000000000..02b42ec6e --- /dev/null +++ b/modules/cms/classes/ViewBag.php @@ -0,0 +1,50 @@ + 'viewBag', + 'description' => 'Stores custom template properties.' + ]; + } + + public function validateProperties(array $properties) + { + return $properties; + } + + public function __call($method, $parameters) + { + if (array_key_exists($method, $this->properties) && !method_exists($this, $method)) + return $this->properties[$method]; + + return parent::__call($method, $parameters); + } + + public function defineProperties() + { + $result = []; + + foreach ($this->properties as $name=>$value) { + $result[$name] = [ + 'title' => $name, + 'type' => 'string' + ]; + } + + return $result; + } +} \ No newline at end of file diff --git a/modules/cms/formwidgets/components/partials/_component.htm b/modules/cms/formwidgets/components/partials/_component.htm new file mode 100644 index 000000000..41f5834ec --- /dev/null +++ b/modules/cms/formwidgets/components/partials/_component.htm @@ -0,0 +1,17 @@ +
+
inspectorEnabled): ?>data-inspectable + data-inspector-title="getComponentName($component)) ?>" + data-inspector-description="getComponentDescription($component)) ?>" + data-inspector-config="getComponentsPropertyConfig($component)) ?>" + data-inspector-class=""> + + + alias) ?> + + + + × +
+
\ No newline at end of file diff --git a/modules/cms/formwidgets/components/partials/_formcomponents.htm b/modules/cms/formwidgets/components/partials/_formcomponents.htm index 0c769d9cd..51af8f844 100644 --- a/modules/cms/formwidgets/components/partials/_formcomponents.htm +++ b/modules/cms/formwidgets/components/partials/_formcomponents.htm @@ -1,25 +1,18 @@
+ isHidden) + echo $this->makePartial('component', ['component'=>$component]); + } + ?>
- -
-
inspectorEnabled): ?>data-inspectable - data-inspector-title="getComponentName($component)) ?>" - data-inspector-description="getComponentDescription($component)) ?>" - data-inspector-config="getComponentsPropertyConfig($component)) ?>" - data-inspector-class=""> - - - alias) ?> - - - - × -
-
- + isHidden) + echo $this->makePartial('component', ['component'=>$component]); + } + ?>