Ejemplo n.º 1
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     $model = $this->_coreRegistry->registry('cms_block');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
     $form->setHtmlIdPrefix('block_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General Information'), 'class' => 'fieldset-wide']);
     if ($model->getBlockId()) {
         $fieldset->addField('block_id', 'hidden', ['name' => 'block_id']);
     }
     $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Block Title'), 'title' => __('Block Title'), 'required' => true]);
     $fieldset->addField('identifier', 'text', ['name' => 'identifier', 'label' => __('Identifier'), 'title' => __('Identifier'), 'required' => true, 'class' => 'validate-xml-identifier']);
     /* Check is single store mode */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, true)]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
         $model->setStoreId($this->_storeManager->getStore(true)->getId());
     }
     $fieldset->addField('is_active', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => ['1' => __('Enabled'), '0' => __('Disabled')]]);
     if (!$model->getId()) {
         $model->setData('is_active', '1');
     }
     $fieldset->addField('content', 'editor', ['name' => 'content', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:36em', 'required' => true, 'config' => $this->_wysiwygConfig->getConfig()]);
     $form->setValues($model->getData());
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 2
0
 /**
  * @return array
  */
 public function getAllOptions()
 {
     if (!$this->_options) {
         $this->_options = $this->_store->getWebsiteValuesForForm(false, true);
     }
     return $this->_options;
 }
Ejemplo n.º 3
0
 /**
  * Initialise form fields
  *
  * @return void
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $fieldset = $form->addFieldset('general', array('legend' => __('General Settings')));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'select', array('label' => __('Store'), 'title' => __('Store'), 'values' => $this->_systemStore->getStoreValuesForForm(), 'name' => 'store_id', 'required' => true));
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', array('name' => 'store_id', 'value' => $this->_storeManager->getStore(true)->getId()));
     }
     /** @var $label \Magento\Framework\View\Design\Theme\Label */
     $label = $this->_labelFactory->create();
     $options = $label->getLabelsCollection(__('-- Please Select --'));
     $fieldset->addField('design', 'select', array('label' => __('Custom Design'), 'title' => __('Custom Design'), 'values' => $options, 'name' => 'design', 'required' => true));
     $dateFormat = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT);
     $fieldset->addField('date_from', 'date', array('label' => __('Date From'), 'title' => __('Date From'), 'name' => 'date_from', 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'date_format' => $dateFormat));
     $fieldset->addField('date_to', 'date', array('label' => __('Date To'), 'title' => __('Date To'), 'name' => 'date_to', 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'date_format' => $dateFormat));
     $formData = $this->_backendSession->getDesignData(true);
     if (!$formData) {
         $formData = $this->_coreRegistry->registry('design')->getData();
     } else {
         $formData = $formData['design'];
     }
     $form->addValues($formData);
     $form->setFieldNameSuffix('design');
     $this->setForm($form);
 }
Ejemplo n.º 4
0
 /**
  * Prepare add review form
  *
  * @return void
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $fieldset = $form->addFieldset('add_review_form', array('legend' => __('Review Details')));
     $fieldset->addField('product_name', 'note', array('label' => __('Product'), 'text' => 'product_name'));
     $fieldset->addField('detailed_rating', 'note', array('label' => __('Product Rating'), 'required' => true, 'text' => '<div id="rating_detail">' . $this->getLayout()->createBlock('Magento\\Review\\Block\\Adminhtml\\Rating\\Detailed')->toHtml() . '</div>'));
     $fieldset->addField('status_id', 'select', array('label' => __('Status'), 'required' => true, 'name' => 'status_id', 'values' => $this->_reviewData->getReviewStatusesOptionArray()));
     /**
      * Check is single store mode
      */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('select_stores', 'multiselect', array('label' => __('Visible In'), 'required' => true, 'name' => 'select_stores[]', 'values' => $this->_systemStore->getStoreValuesForForm()));
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     }
     $fieldset->addField('nickname', 'text', array('name' => 'nickname', 'title' => __('Nickname'), 'label' => __('Nickname'), 'maxlength' => '50', 'required' => true));
     $fieldset->addField('title', 'text', array('name' => 'title', 'title' => __('Summary of Review'), 'label' => __('Summary of Review'), 'maxlength' => '255', 'required' => true));
     $fieldset->addField('detail', 'textarea', array('name' => 'detail', 'title' => __('Review'), 'label' => __('Review'), 'style' => 'height: 600px;', 'required' => true));
     $fieldset->addField('product_id', 'hidden', array('name' => 'product_id'));
     /*$gridFieldset = $form->addFieldset('add_review_grid', array('legend' => __('Please select a product')));
       $gridFieldset->addField('products_grid', 'note', array(
       'text' => $this->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Product\Grid')->toHtml(),
       ));*/
     $form->setMethod('post');
     $form->setUseContainer(true);
     $form->setId('edit_form');
     $form->setAction($this->getUrl('review/product/post'));
     $this->setForm($form);
 }
Ejemplo n.º 5
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var $model \Magento\Cms\Model\Page */
     $model = $this->_coreRegistry->registry('team');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('page_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Team Content')]);
     $fieldset->addField('slogan', 'text', ['name' => 'slogan', 'label' => __('Team Slogan'), 'title' => __('Team Slogan'), 'required' => true]);
     $fieldset->addField('team_color', 'text', ['name' => 'team_color', 'label' => __('Team Color'), 'title' => __('Team Color'), 'class' => 'jscolor {refine:false}']);
     /**
      * Check is single store mode
      */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, true)]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
         $model->setStoreId($this->_storeManager->getStore(true)->getId());
     }
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 6
0
 /**
  * @return $this
  */
 protected function _prepareForm()
 {
     $model = $this->_coreRegistry->registry('checkout_agreement');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(array('data' => array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')));
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => __('Terms and Conditions Information'), 'class' => 'fieldset-wide'));
     if ($model->getId()) {
         $fieldset->addField('agreement_id', 'hidden', array('name' => 'agreement_id'));
     }
     $fieldset->addField('name', 'text', array('name' => 'name', 'label' => __('Condition Name'), 'title' => __('Condition Name'), 'required' => true));
     $fieldset->addField('is_active', 'select', array('label' => __('Status'), 'title' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => array('1' => __('Enabled'), '0' => __('Disabled'))));
     $fieldset->addField('is_html', 'select', array('label' => __('Show Content as'), 'title' => __('Show Content as'), 'name' => 'is_html', 'required' => true, 'options' => array(0 => __('Text'), 1 => __('HTML'))));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'multiselect', array('name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, true)));
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', array('name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()));
         $model->setStoreId($this->_storeManager->getStore(true)->getId());
     }
     $fieldset->addField('checkbox_text', 'editor', array('name' => 'checkbox_text', 'label' => __('Checkbox Text'), 'title' => __('Checkbox Text'), 'rows' => '5', 'cols' => '30', 'wysiwyg' => false, 'required' => true));
     $fieldset->addField('content', 'editor', array('name' => 'content', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:24em;', 'wysiwyg' => false, 'required' => true));
     $fieldset->addField('content_height', 'text', array('name' => 'content_height', 'label' => __('Content Height (css)'), 'title' => __('Content Height'), 'maxlength' => 25, 'class' => 'validate-css-length'));
     $form->setValues($model->getData());
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 7
0
 /**
  * Generate current options
  *
  * @return void
  */
 protected function generateCurrentOptions()
 {
     $websiteCollection = $this->systemStore->getWebsiteCollection();
     $groupCollection = $this->systemStore->getGroupCollection();
     $storeCollection = $this->systemStore->getStoreCollection();
     /** @var \Magento\Store\Model\Website $website */
     foreach ($websiteCollection as $website) {
         $groups = [];
         /** @var \Magento\Store\Model\Group $group */
         foreach ($groupCollection as $group) {
             if ($group->getWebsiteId() == $website->getId()) {
                 $stores = [];
                 /** @var  \Magento\Store\Model\Store $store */
                 foreach ($storeCollection as $store) {
                     if ($store->getGroupId() == $group->getId()) {
                         $name = $this->escaper->escapeHtml($store->getName());
                         $stores[$name]['label'] = str_repeat(' ', 8) . $name;
                         $stores[$name]['value'] = $store->getId();
                     }
                 }
                 if (!empty($stores)) {
                     $name = $this->escaper->escapeHtml($group->getName());
                     $groups[$name]['label'] = str_repeat(' ', 4) . $name;
                     $groups[$name]['value'] = array_values($stores);
                 }
             }
         }
         if (!empty($groups)) {
             $name = $this->escaper->escapeHtml($website->getName());
             $this->currentOptions[$name]['label'] = $name;
             $this->currentOptions[$name]['value'] = array_values($groups);
         }
     }
 }
 /**
  * @return $this
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function _prepareForm()
 {
     $model = $this->_coreRegistry->registry('current_ddg_rule');
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('rule_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Rule Information')]);
     if ($model->getId()) {
         $fieldset->addField('id', 'hidden', ['name' => 'id']);
     }
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Rule Name'), 'title' => __('Rule Name'), 'required' => true]);
     $fieldset->addField('type', 'select', ['label' => __('Rule Type'), 'title' => __('Rule Type'), 'name' => 'type', 'required' => true, 'options' => [\Dotdigitalgroup\Email\Model\Rules::ABANDONED => 'Abandoned Cart Exclusion Rule', \Dotdigitalgroup\Email\Model\Rules::REVIEW => 'Review Email Exclusion Rule']]);
     $fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => ['1' => __('Active'), '0' => __('Inactive')]]);
     if (!$model->getId()) {
         $model->setData('status', '0');
     }
     if ($this->_storeManager->isSingleStoreMode()) {
         $websiteId = $this->_storeManager->getStore(true)->getWebsiteId();
         $fieldset->addField('website_ids', 'hidden', ['name' => 'website_ids[]', 'value' => $websiteId]);
         $model->setWebsiteIds($websiteId);
     } else {
         $field = $fieldset->addField('website_ids', 'multiselect', ['name' => 'website_ids[]', 'label' => __('Websites'), 'title' => __('Websites'), 'required' => true, 'values' => $this->systemStore->getWebsiteValuesForForm()]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     }
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 9
0
 /**
  * Process website info
  *
  * @param \Magento\Store\Model\System\Store $storeModel
  * @param \Magento\Store\Model\Website $website
  * @param string $section
  * @param string $curStore
  * @param string $curWebsite
  * @param array $options
  * @return array
  */
 protected function _processWebsite(\Magento\Store\Model\System\Store $storeModel, \Magento\Store\Model\Website $website, $section, $curStore, $curWebsite, array $options)
 {
     $websiteShow = false;
     foreach ($storeModel->getGroupCollection() as $group) {
         if ($group->getWebsiteId() != $website->getId()) {
             continue;
         }
         $groupShow = false;
         foreach ($storeModel->getStoreCollection() as $store) {
             if ($store->getGroupId() != $group->getId()) {
                 continue;
             }
             if (!$websiteShow) {
                 $websiteShow = true;
                 $options['website_' . $website->getCode()] = array('label' => $website->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode())), 'selected' => !$curStore && $curWebsite == $website->getCode(), 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;');
             }
             if (!$groupShow) {
                 $groupShow = true;
                 $options['group_' . $group->getId() . '_open'] = array('is_group' => true, 'is_close' => false, 'label' => $group->getName(), 'style' => 'padding-left:32px;');
             }
             $options['store_' . $store->getCode()] = array('label' => $store->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode(), 'store' => $store->getCode())), 'selected' => $curStore == $store->getCode(), 'style' => '');
         }
         if ($groupShow) {
             $options['group_' . $group->getId() . '_close'] = array('is_group' => true, 'is_close' => true);
         }
     }
     return $options;
 }
Ejemplo n.º 10
0
 /**
  * Prepare form fields
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     $model = $this->_coreRegistry->registry('current_catalog_search');
     /* @var $model \Magento\CatalogSearch\Model\Query */
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(array('data' => array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')));
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => __('General Information')));
     $yesno = array(array('value' => 0, 'label' => __('No')), array('value' => 1, 'label' => __('Yes')));
     if ($model->getId()) {
         $fieldset->addField('query_id', 'hidden', array('name' => 'query_id'));
     }
     $fieldset->addField('query_text', 'text', array('name' => 'query_text', 'label' => __('Search Query'), 'title' => __('Search Query'), 'required' => true));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'select', array('name' => 'store_id', 'label' => __('Store'), 'title' => __('Store'), 'values' => $this->_systemStore->getStoreValuesForForm(true, false), 'required' => true));
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', array('name' => 'store_id'));
         $model->setStoreId($this->_storeManager->getStore(true)->getId());
     }
     if ($model->getId()) {
         $fieldset->addField('num_results', 'text', array('name' => 'num_results', 'label' => __('Number of results'), 'title' => __('Number of results (For the last time placed)'), 'note' => __('For the last time placed.'), 'required' => true));
         $fieldset->addField('popularity', 'text', array('name' => 'popularity', 'label' => __('Number of Uses'), 'title' => __('Number of Uses'), 'required' => true));
     }
     $fieldset->addField('synonym_for', 'text', array('name' => 'synonym_for', 'label' => __('Synonym For'), 'title' => __('Synonym For'), 'note' => __('Will make search for the query above return results for this search')));
     $fieldset->addField('redirect', 'text', array('name' => 'redirect', 'label' => __('Redirect URL'), 'title' => __('Redirect URL'), 'class' => 'validate-url', 'note' => __('ex. http://domain.com')));
     $fieldset->addField('display_in_terms', 'select', array('name' => 'display_in_terms', 'label' => __('Display in Suggested Terms'), 'title' => __('Display in Suggested Terms'), 'values' => $yesno));
     $form->setValues($model->getData());
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 11
0
 /**
  * Get data
  *
  * @param array $item
  * @return string
  */
 protected function prepareItem(array $item)
 {
     $content = '';
     $origStores = $item['store_id'];
     if (empty($origStores)) {
         return '';
     }
     if (!is_array($origStores)) {
         $origStores = [$origStores];
     }
     if (in_array(0, $origStores) && count($origStores) == 1) {
         return __('All Store Views');
     }
     $data = $this->systemStore->getStoresStructure(false, $origStores);
     foreach ($data as $website) {
         $content .= $website['label'] . "<br/>";
         foreach ($website['children'] as $group) {
             $content .= str_repeat('&nbsp;', 3) . $this->escaper->escapeHtml($group['label']) . "<br/>";
             foreach ($group['children'] as $store) {
                 $content .= str_repeat('&nbsp;', 6) . $this->escaper->escapeHtml($store['label']) . "<br/>";
             }
         }
     }
     return $content;
 }
Ejemplo n.º 12
0
 public function testPrepareDataSource()
 {
     $dataSource = ['data' => ['items' => [['stores' => [1]]]]];
     $expectedVisibility = "Test Website<br/>&nbsp;&nbsp;&nbsp;Test group<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Test store<br/>";
     $expectedDataSource = ['data' => ['items' => [['stores' => [1], 'visibility' => $expectedVisibility]]]];
     $this->storeMock->expects($this->once())->method('getStoresStructure')->willReturn([['label' => 'Test Website', 'children' => [['label' => 'Test group', 'children' => [['label' => 'Test store']]]]]]);
     $this->assertEquals($expectedDataSource, $this->getModel()->prepareDataSource($dataSource));
 }
Ejemplo n.º 13
0
 /**
  * @param FrontTab $subject
  * @param callable $proceed
  * @param Form $form
  * @return Front
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundSetForm(FrontTab $subject, \Closure $proceed, Form $form)
 {
     $block = $proceed($form);
     /** @var Fieldset $fieldset */
     $fieldset = $form->getElement('front_fieldset');
     $fieldset->addField('advanced_search_store_ids', 'multiselect', ['name' => 'advanced_search_store_ids[]', 'label' => __('Advanced Search Store(s)'), 'title' => __('Advanced Search Store(s)'), 'value' => 0, 'values' => $this->_systemStore->getStoreValuesForForm(false, true)], 'is_visible_in_advanced_search');
     $subject->getChildBlock('form_after')->addFieldMap('advanced_search_store_ids', 'advanced_search_store_ids')->addFieldDependence('advanced_search_store_ids', 'advanced_search', '1')->addFieldDependence('advanced_search_store_ids', 'searchable', '1');
     return $block;
 }
Ejemplo n.º 14
0
 /**
  * @dataProvider prepareDataSourceDataProvider
  */
 public function testPrepareDataSource($dataSource, $expectedResult)
 {
     $website = 'website';
     $group = 'group';
     $store = 'store';
     $storeStructure = [1 => ['value' => 1, 'label' => $website, 'children' => [1 => ['value' => 1, 'label' => $group, 'children' => [1 => ['value' => 1, 'label' => $store]]]]]];
     $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnMap([[$group, null, $group], [$store, null, $store]]);
     $this->systemStoreMock->expects($this->any())->method('getStoresStructure')->willReturn($storeStructure);
     $this->assertEquals($this->model->prepareDataSource($dataSource), $expectedResult);
 }
Ejemplo n.º 15
0
 /**
  * Get metadata for sales rule form. It will be merged with form UI component declaration.
  *
  * @param Rule $rule
  * @return array
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function getMetadataValues(\Magento\SalesRule\Model\Rule $rule)
 {
     $customerGroups = $this->groupRepository->getList($this->searchCriteriaBuilder->create())->getItems();
     $applyOptions = [['label' => __('Percent of product price discount'), 'value' => Rule::BY_PERCENT_ACTION], ['label' => __('Fixed amount discount'), 'value' => Rule::BY_FIXED_ACTION], ['label' => __('Fixed amount discount for whole cart'), 'value' => Rule::CART_FIXED_ACTION], ['label' => __('Buy X get Y free (discount amount is Y)'), 'value' => Rule::BUY_X_GET_Y_ACTION]];
     $couponTypesOptions = [];
     $couponTypes = $this->salesRuleFactory->create()->getCouponTypes();
     foreach ($couponTypes as $key => $couponType) {
         $couponTypesOptions[] = ['label' => $couponType, 'value' => $key];
     }
     $labels = $rule->getStoreLabels();
     return ['rule_information' => ['children' => ['website_ids' => ['arguments' => ['data' => ['config' => ['options' => $this->store->getWebsiteValuesForForm()]]]], 'is_active' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Active'), 'value' => '1'], ['label' => __('Inactive'), 'value' => '0']]]]]], 'customer_group_ids' => ['arguments' => ['data' => ['config' => ['options' => $this->objectConverter->toOptionArray($customerGroups, 'id', 'code')]]]], 'coupon_type' => ['arguments' => ['data' => ['config' => ['options' => $couponTypesOptions]]]], 'is_rss' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]]]], 'actions' => ['children' => ['simple_action' => ['arguments' => ['data' => ['config' => ['options' => $applyOptions]]]], 'discount_amount' => ['arguments' => ['data' => ['config' => ['value' => '0']]]], 'discount_qty' => ['arguments' => ['data' => ['config' => ['value' => '0']]]], 'apply_to_shipping' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]], 'stop_rules_processing' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]]]], 'labels' => ['children' => ['store_labels[0]' => ['arguments' => ['data' => ['config' => ['value' => isset($labels[0]) ? $labels[0] : '']]]]]]];
 }
Ejemplo n.º 16
0
 /**
  * Prepare rating edit form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $this->setForm($form);
     $fieldset = $form->addFieldset('rating_form', array('legend' => __('Rating Title')));
     $fieldset->addField('rating_code', 'text', array('name' => 'rating_code', 'label' => __('Default Value'), 'class' => 'required-entry', 'required' => true));
     foreach ($this->_systemStore->getStoreCollection() as $store) {
         $fieldset->addField('rating_code_' . $store->getId(), 'text', array('label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']'));
     }
     if ($this->_session->getRatingData()) {
         $form->setValues($this->_session->getRatingData());
         $data = $this->_session->getRatingData();
         if (isset($data['rating_codes'])) {
             $this->_setRatingCodes($data['rating_codes']);
         }
         $this->_session->setRatingData(null);
     } elseif ($this->_coreRegistry->registry('rating_data')) {
         $form->setValues($this->_coreRegistry->registry('rating_data')->getData());
         if ($this->_coreRegistry->registry('rating_data')->getRatingCodes()) {
             $this->_setRatingCodes($this->_coreRegistry->registry('rating_data')->getRatingCodes());
         }
     }
     if ($this->_coreRegistry->registry('rating_data')) {
         $collection = $this->_optionFactory->create()->getResourceCollection()->addRatingFilter($this->_coreRegistry->registry('rating_data')->getId())->load();
         $i = 1;
         foreach ($collection->getItems() as $item) {
             $fieldset->addField('option_code_' . $item->getId(), 'hidden', array('required' => true, 'name' => 'option_title[' . $item->getId() . ']', 'value' => $item->getCode() ? $item->getCode() : $i));
             $i++;
         }
     } else {
         for ($i = 1; $i <= 5; $i++) {
             $fieldset->addField('option_code_' . $i, 'hidden', array('required' => true, 'name' => 'option_title[add_' . $i . ']', 'value' => $i));
         }
     }
     $fieldset = $form->addFieldset('visibility_form', array('legend' => __('Rating Visibility')));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('stores', 'multiselect', array('label' => __('Visible In'), 'name' => 'stores[]', 'values' => $this->_systemStore->getStoreValuesForForm()));
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
         if ($this->_coreRegistry->registry('rating_data')) {
             $form->getElement('stores')->setValue($this->_coreRegistry->registry('rating_data')->getStores());
         }
     }
     $fieldset->addField('is_active', 'checkbox', array('label' => __('Is Active'), 'name' => 'is_active', 'value' => 1));
     $fieldset->addField('position', 'text', array('label' => __('Sort Order'), 'name' => 'position'));
     if ($this->_coreRegistry->registry('rating_data')) {
         $form->getElement('position')->setValue($this->_coreRegistry->registry('rating_data')->getPosition());
         $form->getElement('is_active')->setIsChecked($this->_coreRegistry->registry('rating_data')->getIsActive());
     }
     return parent::_prepareForm();
 }
Ejemplo n.º 17
0
 /**
  * Prepare form for newsletter queue editing.
  * Form can be run from newsletter template grid by option "Queue newsletter"
  * or from  newsletter queue grid by edit option.
  *
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     /* @var $queue \Magento\Newsletter\Model\Queue */
     $queue = $this->getQueue();
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Queue Information'), 'class' => 'fieldset-wide']);
     $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::MEDIUM);
     $timeFormat = $this->_localeDate->getTimeFormat(\IntlDateFormatter::MEDIUM);
     if ($queue->getQueueStatus() == \Magento\Newsletter\Model\Queue::STATUS_NEVER) {
         $fieldset->addField('date', 'date', ['name' => 'start_at', 'date_format' => $dateFormat, 'time_format' => $timeFormat, 'label' => __('Queue Date Start')]);
         if (!$this->_storeManager->hasSingleStore()) {
             $fieldset->addField('stores', 'multiselect', ['name' => 'stores[]', 'label' => __('Subscribers From'), 'values' => $this->_systemStore->getStoreValuesForForm(), 'value' => $queue->getStores()]);
         } else {
             $fieldset->addField('stores', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
         }
     } else {
         $fieldset->addField('date', 'date', ['name' => 'start_at', 'disabled' => 'true', 'style' => 'width:38%;', 'date_format' => $dateFormat, 'time_format' => $timeFormat, 'label' => __('Queue Date Start')]);
         if (!$this->_storeManager->hasSingleStore()) {
             $fieldset->addField('stores', 'multiselect', ['name' => 'stores[]', 'label' => __('Subscribers From'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(), 'value' => $queue->getStores()]);
         } else {
             $fieldset->addField('stores', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
         }
     }
     if ($queue->getQueueStartAt()) {
         $form->getElement('date')->setValue($this->_localeDate->date(new \DateTime($queue->getQueueStartAt())));
     }
     $fieldset->addField('subject', 'text', ['name' => 'subject', 'label' => __('Subject'), 'required' => true, 'value' => $queue->isNew() ? $queue->getTemplate()->getTemplateSubject() : $queue->getNewsletterSubject()]);
     $fieldset->addField('sender_name', 'text', ['name' => 'sender_name', 'label' => __('Sender Name'), 'title' => __('Sender Name'), 'required' => true, 'value' => $queue->isNew() ? $queue->getTemplate()->getTemplateSenderName() : $queue->getNewsletterSenderName()]);
     $fieldset->addField('sender_email', 'text', ['name' => 'sender_email', 'label' => __('Sender Email'), 'title' => __('Sender Email'), 'class' => 'validate-email', 'required' => true, 'value' => $queue->isNew() ? $queue->getTemplate()->getTemplateSenderEmail() : $queue->getNewsletterSenderEmail()]);
     $widgetFilters = ['is_email_compatible' => 1];
     $wysiwygConfig = $this->_wysiwygConfig->getConfig(['widget_filters' => $widgetFilters]);
     if ($queue->isNew()) {
         $fieldset->addField('text', 'editor', ['name' => 'text', 'label' => __('Message'), 'state' => 'html', 'required' => true, 'value' => $queue->getTemplate()->getTemplateText(), 'style' => 'height: 600px;', 'config' => $wysiwygConfig]);
         $fieldset->addField('styles', 'textarea', ['name' => 'styles', 'label' => __('Newsletter Styles'), 'container_id' => 'field_newsletter_styles', 'value' => $queue->getTemplate()->getTemplateStyles()]);
     } elseif (\Magento\Newsletter\Model\Queue::STATUS_NEVER != $queue->getQueueStatus()) {
         $fieldset->addField('text', 'textarea', ['name' => 'text', 'label' => __('Message'), 'value' => $queue->getNewsletterText()]);
         $fieldset->addField('styles', 'textarea', ['name' => 'styles', 'label' => __('Newsletter Styles'), 'value' => $queue->getNewsletterStyles()]);
         $form->getElement('text')->setDisabled('true')->setRequired(false);
         $form->getElement('styles')->setDisabled('true')->setRequired(false);
         $form->getElement('subject')->setDisabled('true')->setRequired(false);
         $form->getElement('sender_name')->setDisabled('true')->setRequired(false);
         $form->getElement('sender_email')->setDisabled('true')->setRequired(false);
         $form->getElement('stores')->setDisabled('true');
     } else {
         $fieldset->addField('text', 'editor', ['name' => 'text', 'label' => __('Message'), 'state' => 'html', 'required' => true, 'value' => $queue->getNewsletterText(), 'style' => 'height: 600px;', 'config' => $wysiwygConfig]);
         $fieldset->addField('styles', 'textarea', ['name' => 'styles', 'label' => __('Newsletter Styles'), 'value' => $queue->getNewsletterStyles(), 'style' => 'height: 300px;']);
     }
     $this->setForm($form);
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * @return array
  */
 public function getAllOptions()
 {
     if (!$this->_options) {
         $collection = $this->_createStoresCollection();
         if ('store_id' == $this->getAttribute()->getAttributeCode()) {
             $collection->setWithoutDefaultFilter();
         }
         $this->_options = $this->_store->getStoreValuesForForm();
         if ('created_in' == $this->getAttribute()->getAttributeCode()) {
             array_unshift($this->_options, ['value' => '0', 'label' => __('Admin')]);
         }
     }
     return $this->_options;
 }
Ejemplo n.º 19
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     //Magento\Backend\Model\Session
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
     $form->setUseContainer(true);
     $data = $this->_coreRegistry->registry('import_config')->getData();
     /*
      * Checking if user have permissions to save information
      */
     if ($this->_authorization->isAllowed('Magefan_Blog::import')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     $isElementDisabled = false;
     $form->setHtmlIdPrefix('import_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => '']);
     $fieldset->addField('type', 'hidden', ['name' => 'type', 'required' => true, 'disabled' => $isElementDisabled]);
     $fieldset->addField('notice', 'label', ['label' => __('NOTICE'), 'name' => 'prefix', 'after_element_html' => 'When the import is completed successfully, please copy image files from WordPress <strong style="color:#bd1616;">wp-content/uploads</strong> directory to Magento <strong style="color:#105610;">pub/media/magefan_blog</strong> directory.']);
     $fieldset->addField('dbname', 'text', ['name' => 'dbname', 'label' => __('Database Name'), 'title' => __('Database Name'), 'required' => true, 'disabled' => $isElementDisabled, 'after_element_html' => '<small>The name of the database you run in WP.</small>']);
     $fieldset->addField('uname', 'text', ['label' => __('User Name'), 'title' => __('User Name'), 'name' => 'uname', 'required' => true, 'disabled' => $isElementDisabled, 'after_element_html' => '<small>Your WP MySQL username.</small>']);
     $fieldset->addField('pwd', 'text', ['label' => __('Password'), 'title' => __('Password'), 'name' => 'pwd', 'required' => true, 'disabled' => $isElementDisabled, 'after_element_html' => '<small>…and your WP MySQL password.</small>']);
     $fieldset->addField('dbhost', 'text', ['label' => __('Database Host'), 'title' => __('Database Host'), 'name' => 'dbhost', 'required' => true, 'disabled' => $isElementDisabled, 'after_element_html' => '<small>…and your WP MySQL host.</small>']);
     $fieldset->addField('prefix', 'text', ['label' => __('Table Prefix'), 'title' => __('Table Prefix'), 'name' => 'prefix', 'required' => true, 'disabled' => $isElementDisabled, 'after_element_html' => '<small>…and your WP MySQL table prefix.</small>']);
     /**
      * Check is single store mode
      */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'select', ['name' => 'store_id', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, false), 'disabled' => $isElementDisabled]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', ['name' => 'store_id', 'value' => $this->_storeManager->getStore(true)->getId()]);
         $data['store_id'] = $this->_storeManager->getStore(true)->getId();
     }
     $this->_eventManager->dispatch('magefan_blog_import_wordpress_prepare_form', ['form' => $form]);
     /*if (empty($data['homepageurl'])) {
           $data['homepageurl'] = $this->getUrl('blog', ['_store' => 1]);
       }*/
     if (empty($data['prefix'])) {
         $data['prefix'] = 'wp_';
     }
     if (empty($data['dbhost'])) {
         $data['dbhost'] = 'localhost';
     }
     $data['type'] = 'wordpress';
     $form->setValues($data);
     $this->setForm($form);
     return parent::_prepareForm();
 }
 /**
  * Rendering store visibility structure
  *
  * @param array $storeIds
  * @return string
  */
 protected function renderVisibilityStructure(array $storeIds)
 {
     $visibility = '';
     foreach ($this->store->getStoresStructure(false, $storeIds) as $website) {
         $visibility .= $website['label'] . '<br/>';
         foreach ($website['children'] as $group) {
             $visibility .= str_repeat('&nbsp;', 3) . $group['label'] . '<br/>';
             foreach ($group['children'] as $store) {
                 $visibility .= str_repeat('&nbsp;', 6) . $store['label'] . '<br/>';
             }
         }
     }
     return $visibility;
 }
Ejemplo n.º 21
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Swissup\Easytabs\Model\Data $model */
     $model = $this->_coreRegistry->registry('easytab');
     /*
      * Checking if user have permissions to save information
      */
     if ($this->_isAllowedAction('Swissup_Easytabs::save')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
     $form->setHtmlIdPrefix('easytab_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Tab Information')]);
     if ($model->getTabId()) {
         $fieldset->addField('tab_id', 'hidden', ['name' => 'tab_id']);
     }
     $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Title'), 'title' => __('title'), 'required' => true, 'disabled' => $isElementDisabled]);
     $fieldset->addField('alias', 'text', ['name' => 'alias', 'label' => __('Alias'), 'title' => __('Alias'), 'required' => true, 'disabled' => $isElementDisabled]);
     $block = $model->getBlock();
     $blockTypes = $this->_getBlockTypes();
     if (!isset($blockTypes[$block])) {
         $model->setBlock('Swissup\\Easytabs\\Block\\Tab\\Html');
     }
     $model->setBlockType($model->getBlock());
     $fieldset->addField('block_type', 'select', ['name' => 'block_type', 'label' => __('Block Type'), 'title' => __('Block Type'), 'required' => true, 'options' => $this->_getBlockTypes(), 'disabled' => $isElementDisabled, 'after_element_html' => $this->_getWidgetSelectAfterHtml()]);
     $fieldset->addField('block', 'text', ['name' => 'block', 'label' => __('Block'), 'title' => __('Block'), 'required' => true, 'disabled' => true]);
     $sortOrder = $model->getSortOrder();
     if (empty($sortOrder)) {
         $model->setSortOrder(0);
     }
     $fieldset->addField('sort_order', 'text', ['name' => 'sort_order', 'label' => __('Sort Order'), 'title' => __('Sort Order'), 'required' => true, 'disabled' => $isElementDisabled]);
     $fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => $model->getAvailableStatuses(), 'disabled' => $isElementDisabled]);
     /* Check is single store mode */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->systemStore->getStoreValuesForForm(false, true), 'disabled' => $isElementDisabled]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
         $model->setStoreId($this->_storeManager->getStore(true)->getId());
     }
     $form->setValues($model->getData());
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 22
0
 /**
  * Get options
  *
  * @return array
  */
 public function toOptionArray()
 {
     $currentOptions['']['label'] = '--';
     $currentOptions['']['value'] = '--';
     $currentOptions['All Store Views']['label'] = __('All Websites');
     $currentOptions['All Store Views']['value'] = self::ALL_WEBSITES;
     $websiteCollection = $this->systemStore->getWebsiteCollection();
     foreach ($websiteCollection as $website) {
         $name = $this->escaper->escapeHtml($website->getName());
         $currentOptions[$name]['label'] = $name;
         $currentOptions[$name]['value'] = $website->getId();
     }
     $this->options = array_values($currentOptions);
     return $currentOptions;
 }
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /* @var $model \Magefan\Blog\Model\Category */
     $model = $this->_coreRegistry->registry('current_model');
     /*
      * Checking if user have permissions to save information
      */
     $isElementDisabled = !$this->_isAllowedAction('Magefan_Blog::category');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('category_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Category Information')]);
     if ($model->getId()) {
         $fieldset->addField('category_id', 'hidden', ['name' => 'id']);
     }
     $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Category Title'), 'title' => __('Category Title'), 'required' => true, 'disabled' => $isElementDisabled]);
     $fieldset->addField('is_active', 'select', ['label' => __('Status'), 'title' => __('Category Status'), 'name' => 'is_active', 'required' => true, 'options' => $model->getAvailableStatuses(), 'disabled' => $isElementDisabled]);
     if (!$model->getId()) {
         $model->setData('is_active', $isElementDisabled ? '0' : '1');
     }
     $fieldset->addField('identifier', 'text', ['name' => 'identifier', 'label' => __('URL Key'), 'title' => __('URL Key'), 'class' => 'validate-identifier', 'note' => __('Relative to Web Site Base URL'), 'disabled' => $isElementDisabled]);
     /**
      * Check is single store mode
      */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, true), 'disabled' => $isElementDisabled]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
         $model->setStoreId($this->_storeManager->getStore(true)->getId());
     }
     $categories[] = ['label' => __('Please select'), 'value' => 0];
     $collection = $this->_categoryCollection->addFieldToFilter('category_id', array('neq' => $model->getId()))->setOrder('position')->getTreeOrderedArray();
     foreach ($collection as $item) {
         if (!$model->isChild($item)) {
             $categories[] = array('label' => $this->_getSpaces($item->getLevel()) . ' ' . $item->getTitle() . ($item->getIsActive() ? '' : ' (' . __('Disabled') . ')'), 'value' => ($item->getPath() ? $item->getPath() . '/' : '') . $item->getId());
         }
     }
     if (count($categories)) {
         $field = $fieldset->addField('path', 'select', ['name' => 'path', 'label' => __('Parent Category'), 'title' => __('Parent Category'), 'values' => $categories, 'disabled' => $isElementDisabled, 'style' => 'width:100%']);
     }
     $fieldset->addField('position', 'text', ['name' => 'position', 'label' => __('Position'), 'title' => __('Position'), 'disabled' => $isElementDisabled]);
     $this->_eventManager->dispatch('magefan_blog_category_edit_tab_main_prepare_form', ['form' => $form]);
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 24
0
 /**
  * Render HTML of the element
  *
  * @return string
  */
 public function getHtml()
 {
     $websiteCollection = $this->_systemStore->getWebsiteCollection();
     $groupCollection = $this->_systemStore->getGroupCollection();
     $storeCollection = $this->_systemStore->getStoreCollection();
     $allShow = $this->getColumn()->getStoreAll();
     $html = '<select name="' . $this->escapeHtml($this->_getHtmlName()) . '" ' . $this->getColumn()->getValidateClass() . $this->getUiId('filter', $this->_getHtmlName()) . '>';
     $value = $this->getColumn()->getValue();
     if ($allShow) {
         $html .= '<option value="0"' . ($value == 0 ? ' selected="selected"' : '') . '>' . __('All Store Views') . '</option>';
     } else {
         $html .= '<option value=""' . (!$value ? ' selected="selected"' : '') . '></option>';
     }
     foreach ($websiteCollection as $website) {
         $websiteShow = false;
         foreach ($groupCollection as $group) {
             if ($group->getWebsiteId() != $website->getId()) {
                 continue;
             }
             $groupShow = false;
             foreach ($storeCollection as $store) {
                 if ($store->getGroupId() != $group->getId()) {
                     continue;
                 }
                 if (!$websiteShow) {
                     $websiteShow = true;
                     $html .= '<optgroup label="' . $this->escapeHtml($website->getName()) . '"></optgroup>';
                 }
                 if (!$groupShow) {
                     $groupShow = true;
                     $html .= '<optgroup label="&nbsp;&nbsp;&nbsp;&nbsp;' . $this->escapeHtml($group->getName()) . '">';
                 }
                 $value = $this->getValue();
                 $selected = $value == $store->getId() ? ' selected="selected"' : '';
                 $html .= '<option value="' . $store->getId() . '"' . $selected . '>&nbsp;&nbsp;&nbsp;&nbsp;' . $this->escapeHtml($store->getName()) . '</option>';
             }
             if ($groupShow) {
                 $html .= '</optgroup>';
             }
         }
     }
     if ($this->getColumn()->getDisplayDeleted()) {
         $selected = $this->getValue() == '_deleted_' ? ' selected' : '';
         $html .= '<option value="_deleted_"' . $selected . '>' . __('[ deleted ]') . '</option>';
     }
     $html .= '</select>';
     return $html;
 }
Ejemplo n.º 25
0
 /**
  * Get request stores
  *
  * @return array
  */
 protected function _getAllStores()
 {
     if ($this->_allStores === null) {
         $this->_allStores = $this->_systemStore->getStoreValuesForForm();
     }
     return $this->_allStores;
 }
 /**
  * Prepare mocks for getCurrencySymbolsData
  *
  * @param int $websiteId
  * @param int $groupId
  * @param string $currencies
  */
 protected function prepareMocksForGetCurrencySymbolsData($websiteId, $groupId, $currencies)
 {
     /**
      * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
      */
     $websiteMock = $this->getMock('Magento\\Store\\Model\\Website', ['getId', 'getConfig'], [], '', false);
     /**
      * @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject
      */
     $groupMock = $this->getMock('Magento\\Store\\Model\\Group', ['getId', 'getWebsiteId'], [], '', false);
     /**
      * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
      */
     $storeMock = $this->getMock('Magento\\Store\\Model\\Store', ['getGroupId'], [], '', false);
     $this->systemStoreMock->expects($this->once())->method('getWebsiteCollection')->willReturn([$websiteMock]);
     $this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn([$groupMock]);
     $this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn([$storeMock]);
     $websiteMock->expects($this->any())->method('getId')->willReturn($websiteId);
     $groupMock->expects($this->any())->method('getWebsiteId')->willReturn($websiteId);
     $groupMock->expects($this->any())->method('getId')->willReturn($groupId);
     $storeMock->expects($this->any())->method('getGroupId')->willReturn($groupId);
     $this->scopeConfigMock->expects($this->any())->method('getValue')->willReturnMap([[CurrencySymbol::XML_PATH_CUSTOM_CURRENCY_SYMBOL, ScopeInterface::SCOPE_STORE, null, ''], [CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, $storeMock, $currencies], [CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, null, $currencies], [CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, $storeMock, $currencies]]);
     $websiteMock->expects($this->any())->method('getConfig')->with(CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES)->willReturn($currencies);
     $this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn('en');
 }
Ejemplo n.º 27
0
 /**
  * Prepare the form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Sample\News\Model\Author $author */
     $author = $this->_coreRegistry->registry('sample_news_author');
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('author_');
     $form->setFieldNameSuffix('author');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Stores'), 'class' => 'fieldset-wide']);
     $field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->systemStore->getStoreValuesForForm(false, true)]);
     /** @var \Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element $renderer */
     $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
     $field->setRenderer($renderer);
     $form->addValues($author->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 28
0
 /**
  * Prepare form before rendering HTML
  *
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     $widgetInstance = $this->getWidgetInstance();
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Storefront Properties')]);
     if ($widgetInstance->getId()) {
         $fieldset->addField('instance_id', 'hidden', ['name' => 'instance_id']);
     }
     $this->_addElementTypes($fieldset);
     $fieldset->addField('instance_code', 'select', ['name' => 'instance_code', 'label' => __('Type'), 'title' => __('Type'), 'class' => '', 'values' => $this->getTypesOptionsArray(), 'disabled' => true]);
     /** @var $label \Magento\Framework\View\Design\Theme\Label */
     $label = $this->_themeLabelFactory->create();
     $options = $label->getLabelsCollection(__('-- Please Select --'));
     $fieldset->addField('theme_id', 'select', ['name' => 'theme_id', 'label' => __('Design Package/Theme'), 'title' => __('Design Package/Theme'), 'required' => false, 'values' => $options, 'disabled' => true]);
     $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Widget Instance Title'), 'title' => __('Widget Instance Title'), 'class' => '', 'required' => true]);
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_ids', 'multiselect', ['name' => 'store_ids[]', 'label' => __('Assign to Store Views'), 'title' => __('Assign to Store Views'), 'required' => true, 'values' => $this->_store->getStoreValuesForForm(false, true)]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     }
     $fieldset->addField('sort_order', 'text', ['name' => 'sort_order', 'label' => __('Sort Order'), 'title' => __('Sort Order'), 'class' => '', 'required' => false, 'note' => __('Sort Order of widget instances in the same container')]);
     /* @var $layoutBlock \Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Tab\Main\Layout */
     $layoutBlock = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Instance\\Edit\\Tab\\Main\\Layout')->setWidgetInstance($widgetInstance);
     $fieldset = $form->addFieldset('layout_updates_fieldset', ['legend' => __('Layout Updates')]);
     $fieldset->addField('layout_updates', 'note', []);
     $form->getElement('layout_updates_fieldset')->setRenderer($layoutBlock);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 29
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Swissup\Testimonial\Model\Data $model */
     $model = $this->_coreRegistry->registry('testimonial');
     /*
      * Checking if user have permissions to save information
      */
     if ($this->_isAllowedAction('Swissup_Testimonials::save')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
     $form->setHtmlIdPrefix('testimonial_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Testimonial Information')]);
     $fieldset->addType('image', 'Swissup\\Testimonials\\Block\\Adminhtml\\Index\\Helper\\Image');
     if ($model->getTestimonialId()) {
         $fieldset->addField('testimonial_id', 'hidden', ['name' => 'testimonial_id']);
     }
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Name'), 'title' => __('Name'), 'required' => true, 'disabled' => $isElementDisabled]);
     $fieldset->addField('email', 'text', ['name' => 'email', 'label' => __('Email'), 'title' => __('Email'), 'required' => true, 'disabled' => $isElementDisabled]);
     /* Check is single store mode */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, true), 'disabled' => $isElementDisabled]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
         $model->setStoreId($this->_storeManager->getStore(true)->getId());
     }
     $fieldset->addField('message', 'textarea', ['name' => 'message', 'label' => __('Message'), 'title' => __('Message'), 'required' => true, 'disabled' => $isElementDisabled]);
     $fieldset->addField('company', 'text', ['name' => 'company', 'label' => __('Company'), 'title' => __('Company'), 'required' => false, 'disabled' => $isElementDisabled]);
     $fieldset->addField('website', 'text', ['name' => 'website', 'label' => __('Website'), 'title' => __('Website'), 'required' => false, 'disabled' => $isElementDisabled]);
     $fieldset->addField('facebook', 'text', ['name' => 'facebook', 'label' => __('Facebook'), 'title' => __('Facebook'), 'required' => false, 'disabled' => $isElementDisabled]);
     $fieldset->addField('twitter', 'text', ['name' => 'twitter', 'label' => __('Twitter'), 'title' => __('Twitter'), 'required' => false, 'disabled' => $isElementDisabled]);
     $field = $fieldset->addField('rating', 'select', ['name' => 'rating', 'label' => __('Rating'), 'title' => __('Rating'), 'required' => false, 'options' => ['-1' => __('No rating'), '1' => '1 ' . __('star'), '2' => '2 ' . __('stars'), '3' => '3 ' . __('stars'), '4' => '4 ' . __('stars'), '5' => '5 ' . __('stars')], 'disabled' => $isElementDisabled]);
     $fieldset->addField('image', 'image', ['name' => 'image', 'label' => __('Profile Image'), 'title' => __('Profile Image'), 'required' => false, 'disabled' => $isElementDisabled]);
     $fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => $model->getAvailableStatuses(), 'disabled' => $isElementDisabled]);
     $fieldset->addField('widget', 'select', ['label' => __('Display in side list widget'), 'title' => __('Display in side list widget'), 'name' => 'widget', 'required' => false, 'options' => ['1' => __('Yes'), '0' => __('No')], 'disabled' => $isElementDisabled]);
     $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
     $fieldset->addField('date', 'date', ['label' => __('Created date'), 'title' => __('Created date'), 'name' => 'date', 'date_format' => $dateFormat, 'required' => false, 'disabled' => $isElementDisabled]);
     $form->setValues($model->getData());
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Ejemplo n.º 30
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /**
      * Checking if user have permission to save information
      */
     if ($this->_isAllowedAction('Ves_Setup::import')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Ves Setup Import')]);
     $folders = $this->_exportFolders->toArray();
     $fds = [];
     foreach ($folders as $k => $v) {
         $k = strtolower(str_replace("/", "-", $k));
         $fds[$k] = $v;
     }
     $fieldset->addField('folder', 'select', ['label' => __('Folder'), 'title' => __('Folder'), 'name' => 'folder', 'options' => $fds, 'disabled' => $isElementDisabled, 'class' => 'ves-import']);
     foreach ($this->_exportFolders->toArray() as $key => $val) {
         $orginKey = $key;
         $key = strtolower(str_replace("/", "-", $key));
         $fieldPreset = $fieldset->addField($key, 'select', ['name' => $key, 'label' => __('Select Configuration to Import'), 'title' => __('Select Configuration to Import'), 'values' => $this->_importFiles->toOptionArray($orginKey), 'note' => '
                 Folder: <strong>app/design/frontend/' . $orginKey . '/backup</strong>
                 <script type="text/javascript">
                 require(["jquery"], function(){
                     jQuery("#' . $key . '").parents(".admin__field").hide();
                     jQuery(".ves-import").change(function(){
                         var folder_name = jQuery(this).val();
                         if(folder_name!="' . $key . '"){
                             jQuery("#' . $key . '").parents(".admin__field").hide();    
                         }else{
                             jQuery("#' . $key . '").parents(".admin__field").show();    
                         }
                     }).change();
                     jQuery("#' . $key . '").change(function(){
                         var data_import_file = jQuery(this).val();
                         if(data_import_file == "data_import_file"){
                             jQuery("#data_import_file").parents(".admin__field").show();
                         }else{
                             jQuery("#data_import_file").parents(".admin__field").hide();
                         }
                     }).change();
                 });</script>']);
     }
     $fieldset->addField('data_import_file', 'file', ['name' => 'data_import_file', 'label' => __('Upload Custom File'), 'title' => __('Upload Custom File'), 'after_element_html' => '
             <script type="text/javascript">
                 require(["jquery"], function(){
                     jQuery("#data_import_file").parents(".admin__field").hide();
                 });
             </script>
             ']);
     $fieldset->addField('overwrite_blocks', 'select', ['name' => 'overwrite_blocks', 'label' => __('Overwrite Existing Blocks'), 'title' => __('Overwrite Existing Blocks'), 'values' => $this->_yesno->toArray(), 'note' => __('If set to <b>Yes</b>, the import data will override exist data. Check exits data according to the field <b>URL Key</b> of <b>Cms Pages</b> and the field <b>Identifier</b> of <b>Static Block</b>.<br><br>If set to <b>No</b>, the function import will empty data of all table of <b>CMS Page</b> and <b>Static Block</b>, then insert import data.')]);
     $field = $fieldset->addField('store_id', 'select', ['name' => 'store_id', 'label' => __('Configuration Scope'), 'title' => __('Configuration Scope'), 'values' => $this->_systemStore->getStoreValuesForForm(false, true), 'disabled' => $isElementDisabled, 'note' => __('Imported configuration settings will be applied to selected scope (selected store view or website). If you\'re not sure what is \'scope\' in Magento system configuration.<br/><br/>It is highly recommended to leave the default scope <strong>\'Default Config\'</strong>. In this case imported configuration will be applied to all existing store views.')]);
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }