예제 #1
0
 /**
  * @codeCoverageIgnore
  */
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $originalData = $element->getOriginalData();
     $label = $originalData['button_label'];
     $this->addData(['button_label' => __($label), 'button_url' => $this->getUrl('magewondersmtp/email/test'), 'html_id' => $element->getHtmlId()]);
     return $this->_toHtml();
 }
예제 #2
0
 /**
  * Return header title part of html for payment solution
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  *
  * @return string
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _getHeaderTitleHtml($element)
 {
     $html = '<div class="config-heading meli" ><div class="heading"><strong id="meli-logo">' . $element->getLegend();
     $html .= '</strong></div>';
     $html .= '<div class="button-container meli-cards"><button type="button"' . ' class="meli-payment-btn action-configure button' . '" id="' . $element->getHtmlId() . '-head" onclick="Fieldset.toggleCollapse(\'' . $element->getHtmlId() . '\', \'' . $this->getUrl('*/*/state') . '\'); return false;"><span class="state-closed">' . __('Configure') . '</span><span class="state-opened">' . __('Close') . '</span></button></div></div>';
     return $html;
 }
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $originalData = $element->getOriginalData();
     $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->_saveButtonLabel;
     $this->addData(['button_label' => __($buttonLabel), 'html_id' => $element->getHtmlId(), 'ajax_url' => $this->_urlBuilder->getUrl('seo/system_config_robot/save')]);
     return $this->_toHtml();
 }
예제 #4
0
 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $element->unsScope();
     $element->unsCanUseWebsiteValue();
     $element->unsCanUseDefaultValue();
     return $this->getDbStatus();
 }
예제 #5
0
 /**
  * @param mixed $expanded
  * @param int $expected
  * @dataProvider isCollapseStateDataProvider
  */
 public function testIsCollapseState($expanded, $expected)
 {
     $this->_user->setExtra(['configState' => []]);
     $this->_element->setGroup(isset($expanded) ? ['expanded' => $expanded] : []);
     $html = $this->_model->render($this->_element);
     $this->assertContains('<input id="' . $this->_element->getHtmlId() . '-state" name="config_state[' . $this->_element->getId() . ']" type="hidden" value="' . $expected . '" />', $html);
 }
예제 #6
0
 /**
  * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::prepareElementHtml
  * @param string $elementValue
  * @param integer|null $modelBlockId
  *
  * @dataProvider prepareElementHtmlDataProvider
  */
 public function testPrepareElementHtml($elementValue, $modelBlockId)
 {
     $elementId = 1;
     $uniqId = '126hj4h3j73hk7b347jhkl37gb34';
     $sourceUrl = 'cms/block_widget/chooser/126hj4h3j73hk7b347jhkl37gb34';
     $config = ['key1' => 'value1'];
     $fieldsetId = 2;
     $html = 'some html';
     $title = 'some title';
     $this->this->setConfig($config);
     $this->this->setFieldsetId($fieldsetId);
     $this->elementMock->expects($this->atLeastOnce())->method('getId')->willReturn($elementId);
     $this->mathRandomMock->expects($this->atLeastOnce())->method('getUniqueHash')->with($elementId)->willReturn($uniqId);
     $this->urlBuilderMock->expects($this->atLeastOnce())->method('getUrl')->with('cms/block_widget/chooser', ['uniq_id' => $uniqId])->willReturn($sourceUrl);
     $this->layoutMock->expects($this->atLeastOnce())->method('createBlock')->with('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->willReturn($this->chooserMock);
     $this->chooserMock->expects($this->atLeastOnce())->method('setElement')->with($this->elementMock)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setConfig')->with($config)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setFieldsetId')->with($fieldsetId)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setSourceUrl')->with($sourceUrl)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setUniqId')->with($uniqId)->willReturnSelf();
     $this->elementMock->expects($this->atLeastOnce())->method('getValue')->willReturn($elementValue);
     $this->blockFactoryMock->expects($this->any())->method('create')->willReturn($this->modelBlockMock);
     $this->modelBlockMock->expects($this->any())->method('load')->with($elementValue)->willReturnSelf();
     $this->modelBlockMock->expects($this->any())->method('getId')->willReturn($modelBlockId);
     $this->modelBlockMock->expects($this->any())->method('getTitle')->willReturn($title);
     $this->chooserMock->expects($this->any())->method('setLabel')->with($title)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('toHtml')->willReturn($html);
     $this->elementMock->expects($this->atLeastOnce())->method('setData')->with('after_element_html', $html)->willReturnSelf();
     $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock));
 }
예제 #7
0
 /**
  * @param AbstractElement $element
  * @return string
  */
 public function render(AbstractElement $element)
 {
     if ($element->getRule() && $element->getRule()->getActions()) {
         return $element->getRule()->getActions()->asHtmlRecursive();
     }
     return '';
 }
예제 #8
0
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $element->setValue(0);
     $element->setDisabled('disabled');
     $element->setValues([['label' => __('Disabled - Coming Soon...'), 'value' => '0']]);
     return $element->getElementHtml();
 }
예제 #9
0
 protected function _renderScopeLabel(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $html = '<td class="scope-label" style="display:none;">';
     $html .= $element->getTooltip();
     $html .= '</td>';
     return $html;
 }
예제 #10
0
 /**
  * {@inheritdoc}
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $originalData = $element->getOriginalData();
     $buttonLabel = $originalData['button_label'];
     $this->addData(['button_label' => __($buttonLabel), 'html_id' => $element->getHtmlId(), 'ajax_url' => $this->_urlBuilder->getUrl('searchsphinx/command/' . $this->getAction())]);
     return $this->_toHtml();
 }
예제 #11
0
 /**
  * @dataProvider isPaymentEnabledDataProvider
  */
 public function testIsPaymentEnabled($groupConfig, $expected)
 {
     $this->_element->setGroup($groupConfig);
     $this->_backendConfig->expects($this->any())->method('getConfigDataValue')->will($this->returnValueMap([[self::CONFIG_PATH_ACTIVE, null, null, '1'], [self::CONFIG_PATH_NOT_ACTIVE, null, null, '0']]));
     $html = $this->_model->render($this->_element);
     $this->assertContains($expected, $html);
 }
예제 #12
0
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $originalData = $element->getOriginalData();
     $label = $originalData['button_label'];
     $this->addData(array('button_label' => __($label), 'button_url' => $this->authorizeRequestUrl(), 'html_id' => $element->getHtmlId()));
     return $this->_toHtml();
 }
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $element->setData('after_element_html', "<script src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script><script type=\\'text/javascript\\'>");
     // Set up additional JavaScript for our validation using jQuery.
     $element->setData('after_element_html', "\n\t        jQuery.noConflict();\n            jQuery(document).ready(function() {\n\t\t\t\tjQuery('#connector_data_mapping_enterprise_data-head').parent().hide();\n            });\n            </script>");
     return parent::_getElementHtml($element);
 }
예제 #14
0
 /**
  * Get the button and scripts contents
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $originalData = $element->getOriginalData();
     $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->_vatButtonLabel;
     $this->addData(['button_label' => __($buttonLabel), 'html_id' => $element->getHtmlId()]);
     return $this->_toHtml();
 }
예제 #15
0
 /**
  * @param AbstractElement $element
  * @return string
  */
 public function render(AbstractElement $element)
 {
     if (!$element instanceof Select || empty($element->getData('values'))) {
         return '';
     }
     return parent::render($element);
 }
예제 #16
0
 /**
  * Return header comment part of html for fieldset
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 protected function _getHeaderCommentHtml($element)
 {
     $beforeDiv = '<div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">';
     $afterDiv = '</div>';
     $synch = __('Click here to <a href="%1">Synchronize</a> with ShipperHQ.', $this->getUrl('shipperhq/synchronize/index'));
     $element->getComment() ? $comment = $element->getComment() : ($comment = '');
     $html = $beforeDiv . '<table>
         <tr>
             <td style="vertical-align:bottom">
             <b>ShipperHQ installed version ' . $this->getModuleVersion() . '</b>
              </td>
         </tr>
         <tr>
          <td colspan="3">
             <p>' . $comment . '</p>
           </td>
         </tr>
         <tr>
             <td colspan="3">
             <p>' . $synch . '</p>
             </td>
         </tr>
         </table>' . $afterDiv;
     return $html;
 }
 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $extensionVersion = $this->_helper->getExtensionVersion();
     $versionLabel = sprintf('<a href="%s" title="Easy Template Path Hints for Magento 2" target="_blank">%s</a>', self::EXTENSION_URL, $extensionVersion);
     $element->setValue($versionLabel);
     return $element->getValue();
 }
예제 #18
0
파일: Region.php 프로젝트: aiesh/magento2
 /**
  * @param AbstractElement $element
  * @return string
  */
 public function render(AbstractElement $element)
 {
     $countryId = false;
     $isRegionRequired = false;
     if ($country = $element->getForm()->getElement('country_id')) {
         $countryId = $country->getValue();
         $isRegionRequired = $this->_directoryHelper->isRegionRequired($countryId);
     }
     $html = '<div class="field field-region ' . ($isRegionRequired ? 'required' : '') . '">' . "\n";
     $regionCollection = false;
     if ($countryId) {
         if (!isset(self::$_regionCollections[$countryId])) {
             self::$_regionCollections[$countryId] = $this->_countryFactory->create()->setId($countryId)->getLoadedRegionCollection()->toOptionArray();
         }
         $regionCollection = self::$_regionCollections[$countryId];
     }
     $regionId = intval($element->getForm()->getElement('region_id')->getValue());
     $htmlAttributes = $element->getHtmlAttributes();
     foreach ($htmlAttributes as $key => $attribute) {
         if ('type' === $attribute) {
             unset($htmlAttributes[$key]);
             break;
         }
     }
     // Output two elements - for 'region' and for 'region_id'.
     // Two elements are needed later upon form post - to properly set data to address model,
     // otherwise old value can be left in region_id attribute and saved to DB.
     // Depending on country selected either 'region' (input text) or 'region_id' (selectbox) is visible to user
     $regionHtmlName = $element->getName();
     $regionIdHtmlName = str_replace('region', 'region_id', $regionHtmlName);
     $regionHtmlId = $element->getHtmlId();
     $regionIdHtmlId = str_replace('region', 'region_id', $regionHtmlId);
     if ($isRegionRequired) {
         $element->addClass('required-entry');
     }
     if ($regionCollection && count($regionCollection) > 0) {
         $elementClass = $element->getClass();
         $html .= '<label class="label" for="' . $regionIdHtmlId . '"><span>' . $element->getLabel() . '</span>' . '</label>';
         $html .= '<div class="control">';
         $html .= '<select id="' . $regionIdHtmlId . '" name="' . $regionIdHtmlName . '" ' . $element->serialize($htmlAttributes) . '>' . "\n";
         foreach ($regionCollection as $region) {
             $selected = $regionId == $region['value'] ? ' selected="selected"' : '';
             $regionVal = 0 == $region['value'] ? '' : (int) $region['value'];
             $html .= '<option value="' . $regionVal . '"' . $selected . '>' . $this->_escaper->escapeHtml(__($region['label'])) . '</option>';
         }
         $html .= '</select>' . "\n";
         $html .= '<input type="hidden" name="' . $regionHtmlName . '" id="' . $regionHtmlId . '" value=""/>';
         $html .= '</div>';
         $element->setClass($elementClass);
     } else {
         $html .= '<label class="label" for="' . $regionHtmlId . '"><span>' . $element->getLabel() . '</span></label>';
         $html .= '<div class="control">';
         $html .= '<input id="' . $regionHtmlId . '" name="' . $regionHtmlName . '" value="' . $element->getEscapedValue() . '" ' . $element->serialize($htmlAttributes) . "/>" . "\n";
         $html .= '<input type="hidden" name="' . $regionIdHtmlName . '" id="' . $regionIdHtmlId . '" value=""/>';
         $html .= '</div>' . "\n";
     }
     $html .= '</div>' . "\n";
     return $html;
 }
 /**
  * Get the button and scripts contents.
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  *
  * @return string
  */
 public function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $originalData = $element->getOriginalData();
     $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->buttonLabel;
     $url = $this->_urlBuilder->getUrl('dotdigitalgroup_email/addressbook/save');
     $this->addData(['button_label' => __($buttonLabel), 'html_id' => $element->getHtmlId(), 'ajax_url' => $url]);
     return $this->_toHtml();
 }
예제 #20
0
 /**
  * Retrieve label for the inheritance checkbox
  *
  * @SuppressWarnings(PHPMD.CamelCaseMethodName)
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element The form element
  *
  * @return string
  */
 protected function _getInheritCheckboxLabel(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $checkboxLabel = __('Use Default');
     if ($element->getCanUseContainerValue()) {
         $checkboxLabel = __('Use Container');
     }
     return $checkboxLabel;
 }
예제 #21
0
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $id = $element->getHtmlId();
     $html = '<tr id="row_' . $id . '">';
     $html .= '<td class="label">' . __('Module Version') . '</td><td class="value">' . $this->getModuleVersion() . '</td><td class="scope-label"></td>';
     $html .= '</tr>';
     return $html;
 }
 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $extensionVersion = $this->_helper->getExtensionVersion();
     $extensionTitle = 'Custom Shipping';
     $versionLabel = sprintf('<a href="%s" title="%s" target="_blank">%s</a>', self::EXTENSION_URL, $extensionTitle, $extensionVersion);
     $element->setValue($versionLabel);
     return $element->getValue();
 }
예제 #23
0
 /**
  * Render fieldset html
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $elementOriginalData = $element->getOriginalData();
     if (isset($elementOriginalData['help_link'])) {
         $this->setHelpLink($elementOriginalData['help_link']);
     }
     return $this->toHtml();
 }
예제 #24
0
파일: Expanded.php 프로젝트: aiesh/magento2
 /**
  * Return collapse state
  *
  * @param AbstractElement $element
  * @return string|true
  */
 protected function _isCollapseState($element)
 {
     $extra = $this->_authSession->getUser()->getExtra();
     if (isset($extra['configState'][$element->getId()])) {
         return $extra['configState'][$element->getId()];
     }
     return true;
 }
예제 #25
0
파일: Editor.php 프로젝트: swissup/easytabs
 /**
  * Prepare wysiwyg element HTML
  *
  * @param AbstractElement $element Form Element
  * @return AbstractElement
  */
 public function prepareElementHtml(AbstractElement $element)
 {
     /* @var $fieldset \Magento\Framework\Data\Form\Element\Fieldset */
     $fieldset = $element->getForm()->getElement($this->getFieldsetId());
     $widgetValues = $this->getLayout()->getBlock('easytabs.tab.options')->getWidgetValues();
     $fieldset->addField('widget_content', 'editor', ['name' => 'parameters[widget_content]', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:36em', 'required' => true, 'config' => $this->wysiwygConfig->getConfig(), 'value' => $widgetValues['widget_content']]);
     return $element;
 }
예제 #26
0
 /**
  * Render given element (return html of element)
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element The element
  *
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     if ($this->getValues()) {
         $element->setValue($this->getValues());
     }
     $this->setElement($element);
     return $this->toHtml();
 }
예제 #27
0
 public function testRender()
 {
     $rule = $this->getMockBuilder('Magento\\Rule\\Model\\AbstractModel')->setMethods(['getConditions', '__sleep', '__wakeup'])->disableOriginalConstructor()->getMockForAbstractClass();
     $conditions = $this->getMock('\\Magento\\Rule\\Model\\Condition\\Combine', ['asHtmlRecursive'], [], '', false);
     $this->_element->expects($this->any())->method('getRule')->will($this->returnValue($rule));
     $rule->expects($this->any())->method('getConditions')->will($this->returnValue($conditions));
     $conditions->expects($this->once())->method('asHtmlRecursive')->will($this->returnValue('conditions html'));
     $this->assertEquals('conditions html', $this->conditions->render($this->_element));
 }
 /**
  * Run test for render method
  *
  * @return void
  */
 public function testRender()
 {
     $formMock = $this->getMockBuilder('Magento\\Framework\\Data\\Form')->setMethods(['getFieldNameSuffix'])->disableOriginalConstructor()->getMock();
     $this->elementMock->expects($this->any())->method('getHtmlId')->willReturn('test-html-id');
     $this->elementMock->expects($this->once())->method('getTooltip')->willReturn('');
     $this->elementMock->expects($this->any())->method('getForm')->willReturn($formMock);
     $formMock->expects($this->any())->method('getFieldNameSuffix')->willReturn('');
     $this->assertContains(self::EXPECTED_ATTRIBUTE, $this->abstractEnable->render($this->elementMock));
 }
예제 #29
0
 /**
  * Add form element
  *
  * @param AbstractElement $element
  * @param bool $after
  * @return Form
  */
 public function addElement(AbstractElement $element, $after = false)
 {
     if ($this->getForm()) {
         $this->getForm()->checkElementId($element->getId());
         $this->getForm()->addElementToCollection($element);
     }
     parent::addElement($element, $after);
     return $this;
 }
예제 #30
0
 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $_days = [];
     for ($i = 1; $i <= 31; $i++) {
         $_days[$i] = $i < 10 ? '0' . $i : $i;
     }
     $_daysHtml = $element->setStyle('width:50px;')->setValues($_days)->getElementHtml();
     return $_daysHtml;
 }