示例#1
0
 /**
  * Initialise form fields
  *
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     /*
      * Checking if user have permissions to save information
      */
     $isElementDisabled = !$this->_isAllowedAction('Magento_Cms::save');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['html_id_prefix' => 'page_']]);
     $model = $this->_coreRegistry->registry('cms_page');
     $layoutFieldset = $form->addFieldset('layout_fieldset', ['legend' => __('Page Layout'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled]);
     $layoutFieldset->addField('page_layout', 'select', ['name' => 'page_layout', 'label' => __('Layout'), 'required' => true, 'values' => $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(), 'disabled' => $isElementDisabled]);
     if (!$model->getId()) {
         $model->setRootTemplate($this->_pageLayout->getDefaultValue());
     }
     $layoutFieldset->addField('layout_update_xml', 'textarea', ['name' => 'layout_update_xml', 'label' => __('Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled]);
     $designFieldset = $form->addFieldset('design_fieldset', ['legend' => __('Custom Design'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled]);
     $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
     $designFieldset->addField('custom_theme_from', 'date', ['name' => 'custom_theme_from', 'label' => __('Custom Design From'), 'date_format' => $dateFormat, 'disabled' => $isElementDisabled, 'class' => 'validate-date validate-date-range date-range-custom_theme-from']);
     $designFieldset->addField('custom_theme_to', 'date', ['name' => 'custom_theme_to', 'label' => __('Custom Design To'), 'date_format' => $dateFormat, 'disabled' => $isElementDisabled, 'class' => 'validate-date validate-date-range date-range-custom_theme-to']);
     $options = $this->_labelFactory->create()->getLabelsCollection(__('-- Please Select --'));
     $designFieldset->addField('custom_theme', 'select', ['name' => 'custom_theme', 'label' => __('Custom Theme'), 'values' => $options, 'disabled' => $isElementDisabled]);
     $designFieldset->addField('custom_page_layout', 'select', ['name' => 'custom_page_layout', 'label' => __('Custom Layout'), 'values' => $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(true), 'disabled' => $isElementDisabled]);
     $designFieldset->addField('custom_layout_update_xml', 'textarea', ['name' => 'custom_layout_update_xml', 'label' => __('Custom Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled]);
     $this->_eventManager->dispatch('adminhtml_cms_page_edit_tab_design_prepare_form', ['form' => $form]);
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function getAllOptions()
 {
     if (!$this->_options) {
         $this->_options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray();
         array_unshift($this->_options, ['value' => '', 'label' => __('No layout updates')]);
     }
     return $this->_options;
 }
示例#3
0
 /**
  * Get options
  *
  * @param array $options
  * @return array
  */
 public function getOptions(array $options = [])
 {
     $newOptions = $this->pageLayoutBuilder->getPageLayoutsConfig()->getOptions();
     foreach ($newOptions as $key => $value) {
         $newOptions[$key] = ['label' => $value, 'value' => $key];
     }
     return array_merge_recursive($newOptions, $options);
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManager($this);
     $this->builderMock = $this->getMockBuilder('Magento\\Framework\\View\\Model\\PageLayout\\Config\\BuilderInterface')->disableOriginalConstructor()->setMethods(['getPageLayoutsConfig'])->getMock();
     $this->pageLayoutConfigMock = $this->getMockBuilder('Magento\\Framework\\View\\PageLayout\\Config')->disableOriginalConstructor()->setMethods(['getOptions'])->getMock();
     $this->builderMock->expects($this->any())->method('getPageLayoutsConfig')->willReturn($this->pageLayoutConfigMock);
     $this->object = $this->objectManagerHelper->getObject($this->getSourceClassName(), ['pageLayoutBuilder' => $this->builderMock]);
 }
 public function testGetAllOptions()
 {
     $expectedOptions = ['0' => ['value' => '', 'label' => 'No layout updates'], '1' => ['value' => 'option_value', 'label' => 'option_label']];
     $mockPageLayoutConfig = $this->getMockBuilder('Magento\\Framework\\View\\PageLayout\\Config')->disableOriginalConstructor()->getMock();
     $mockPageLayoutConfig->expects($this->any())->method('toOptionArray')->will($this->returnValue(['0' => $expectedOptions['1']]));
     $this->pageLayoutBuilder->expects($this->once())->method('getPageLayoutsConfig')->will($this->returnValue($mockPageLayoutConfig));
     $layoutOptions = $this->layoutModel->getAllOptions();
     $this->assertEquals($expectedOptions, $layoutOptions);
 }
示例#6
0
 /**
  * To option array
  *
  * @return array
  */
 public function toOptionArray()
 {
     if (is_null($this->options)) {
         $_options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(true);
         foreach ($_options as $option) {
             $this->options[$option['value']] = $option['label'];
         }
     }
     $options = $this->options;
     return $options;
 }
示例#7
0
 /**
  * Get options
  *
  * @return array
  */
 public function toOptionArray()
 {
     if ($this->options !== null) {
         return $this->options;
     }
     $configOptions = $this->pageLayoutBuilder->getPageLayoutsConfig()->getOptions();
     $options = [];
     foreach ($configOptions as $key => $value) {
         $options[] = ['label' => $value, 'value' => $key];
     }
     $this->options = $options;
     return $this->options;
 }
示例#8
0
 /**
  * Prepare columns
  *
  * @return \Magento\Backend\Block\Widget\Grid\Extended
  */
 protected function _prepareColumns()
 {
     $this->addColumn('title', ['header' => __('Title'), 'index' => 'title']);
     $this->addColumn('identifier', ['header' => __('URL Key'), 'index' => 'identifier']);
     $this->addColumn('page_layout', ['header' => __('Layout'), 'index' => 'page_layout', 'type' => 'options', 'options' => $this->pageLayoutBuilder->getPageLayoutsConfig()->getOptions()]);
     /**
      * Check is single store mode
      */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $this->addColumn('store_id', ['header' => __('Store View'), 'index' => 'store_id', 'type' => 'store', 'store_all' => true, 'store_view' => true, 'sortable' => false, 'filter_condition_callback' => [$this, '_filterStoreCondition']]);
     }
     $this->addColumn('is_active', ['header' => __('Status'), 'index' => 'is_active', 'type' => 'options', 'options' => $this->_cmsPage->getAvailableStatuses()]);
     $this->addColumn('creation_time', ['header' => __('Created'), 'index' => 'creation_time', 'type' => 'datetime', 'header_css_class' => 'col-date', 'column_css_class' => 'col-date']);
     $this->addColumn('update_time', ['header' => __('Modified'), 'index' => 'update_time', 'type' => 'datetime', 'header_css_class' => 'col-date', 'column_css_class' => 'col-date']);
     $this->addColumn('page_actions', ['header' => __('Action'), 'sortable' => false, 'filter' => false, 'renderer' => 'Magento\\Cms\\Block\\Adminhtml\\Page\\Grid\\Renderer\\Action', 'header_css_class' => 'col-action', 'column_css_class' => 'col-action']);
     return parent::_prepareColumns();
 }
示例#9
0
 /**
  * Prepare columns for pages grid
  *
  * @return $this
  */
 protected function _prepareColumns()
 {
     $this->addColumn('chooser_id', ['header' => __('ID'), 'index' => 'page_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']);
     $this->addColumn('chooser_title', ['header' => __('Title'), 'index' => 'title', 'header_css_class' => 'col-title', 'column_css_class' => 'col-title']);
     $this->addColumn('chooser_identifier', ['header' => __('URL Key'), 'index' => 'identifier', 'header_css_class' => 'col-url', 'column_css_class' => 'col-url']);
     $this->addColumn('chooser_page_layout', ['header' => __('Layout'), 'index' => 'page_layout', 'type' => 'options', 'options' => $this->pageLayoutBuilder->getPageLayoutsConfig()->getOptions(), 'header_css_class' => 'col-layout', 'column_css_class' => 'col-layout']);
     $this->addColumn('chooser_is_active', ['header' => __('Status'), 'index' => 'is_active', 'type' => 'options', 'options' => $this->_cmsPage->getAvailableStatuses(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status']);
     return parent::_prepareColumns();
 }
示例#10
0
 /**
  * Initialise form fields
  *
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     /*
      * Checking if user have permissions to save information
      */
     $isElementDisabled = !$this->_isAllowedAction('Ves_Brand::brand_edit');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['html_id_prefix' => 'brand_']]);
     $model = $this->_coreRegistry->registry('ves_brand');
     $layoutFieldset = $form->addFieldset('layout_fieldset', ['legend' => __('Page Layout'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled]);
     $layoutFieldset->addField('page_layout', 'select', ['name' => 'page_layout', 'label' => __('Layout'), 'required' => true, 'values' => $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(), 'disabled' => $isElementDisabled]);
     if (!$model->getId()) {
         $model->setRootTemplate($this->_pageLayout->getDefaultValue());
     }
     $layoutFieldset->addField('layout_update_xml', 'textarea', ['name' => 'layout_update_xml', 'label' => __('Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled]);
     $this->_eventManager->dispatch('adminhtml_cms_page_edit_tab_design_prepare_form', ['form' => $form]);
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }