Exemplo n.º 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(array('data' => array('html_id_prefix' => 'page_')));
     $model = $this->_coreRegistry->registry('cms_page');
     $layoutFieldset = $form->addFieldset('layout_fieldset', array('legend' => __('Page Layout'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled));
     $layoutFieldset->addField('page_layout', 'select', array('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', array('name' => 'layout_update_xml', 'label' => __('Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled));
     $designFieldset = $form->addFieldset('design_fieldset', array('legend' => __('Custom Design'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled));
     $dateFormat = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT);
     $designFieldset->addField('custom_theme_from', 'date', array('name' => 'custom_theme_from', 'label' => __('Custom Design From'), 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'date_format' => $dateFormat, 'disabled' => $isElementDisabled, 'class' => 'validate-date validate-date-range date-range-custom_theme-from'));
     $designFieldset->addField('custom_theme_to', 'date', array('name' => 'custom_theme_to', 'label' => __('Custom Design To'), 'image' => $this->getViewFileUrl('images/grid-cal.gif'), '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', array('name' => 'custom_theme', 'label' => __('Custom Theme'), 'values' => $options, 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_page_layout', 'select', array('name' => 'custom_page_layout', 'label' => __('Custom Layout'), 'values' => $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(true), 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_layout_update_xml', 'textarea', array('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', array('form' => $form));
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function getAllOptions()
 {
     if (!$this->_options) {
         $this->_options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray();
         array_unshift($this->_options, array('value' => '', 'label' => __('No layout updates')));
     }
     return $this->_options;
 }
Exemplo n.º 4
0
 public function testGetAllOptions()
 {
     $expectedOptions = array('0' => array('value' => '', 'label' => 'No layout updates'), '1' => array('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);
 }
Exemplo n.º 5
0
 /**
  * Prepare columns for pages grid
  *
  * @return $this
  */
 protected function _prepareColumns()
 {
     $this->addColumn('chooser_id', array('header' => __('ID'), 'index' => 'page_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id'));
     $this->addColumn('chooser_title', array('header' => __('Title'), 'index' => 'title', 'header_css_class' => 'col-title', 'column_css_class' => 'col-title'));
     $this->addColumn('chooser_identifier', array('header' => __('URL Key'), 'index' => 'identifier', 'header_css_class' => 'col-url', 'column_css_class' => 'col-url'));
     $this->addColumn('chooser_page_layout', array('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', array('header' => __('Status'), 'index' => 'is_active', 'type' => 'options', 'options' => $this->_cmsPage->getAvailableStatuses(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status'));
     return parent::_prepareColumns();
 }
Exemplo n.º 6
0
 /**
  * Prepare columns
  *
  * @return \Magento\Backend\Block\Widget\Grid\Extended
  */
 protected function _prepareColumns()
 {
     $this->addColumn('title', array('header' => __('Title'), 'index' => 'title'));
     $this->addColumn('identifier', array('header' => __('URL Key'), 'index' => 'identifier'));
     $this->addColumn('page_layout', array('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', array('header' => __('Store View'), 'index' => 'store_id', 'type' => 'store', 'store_all' => true, 'store_view' => true, 'sortable' => false, 'filter_condition_callback' => array($this, '_filterStoreCondition')));
     }
     $this->addColumn('is_active', array('header' => __('Status'), 'index' => 'is_active', 'type' => 'options', 'options' => $this->_cmsPage->getAvailableStatuses()));
     $this->addColumn('creation_time', array('header' => __('Created'), 'index' => 'creation_time', 'type' => 'datetime', 'header_css_class' => 'col-date', 'column_css_class' => 'col-date'));
     $this->addColumn('update_time', array('header' => __('Modified'), 'index' => 'update_time', 'type' => 'datetime', 'header_css_class' => 'col-date', 'column_css_class' => 'col-date'));
     $this->addColumn('page_actions', array('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();
 }