예제 #1
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);
 }
예제 #2
0
 /**
  * Output the region element and javasctipt that makes it dependent from country element
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  *
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     if ($country = $element->getForm()->getElement('country_id')) {
         $countryId = $country->getValue();
     } else {
         return $element->getDefaultHtml();
     }
     $regionId = $element->getForm()->getElement('region_id')->getValue();
     $html = '<div class="field field-state required">';
     $element->setClass('input-text');
     $element->setRequired(true);
     $html .= $element->getLabelHtml() . '<div class="control">';
     $html .= $element->getElementHtml();
     $selectName = str_replace('region', 'region_id', $element->getName());
     $selectId = $element->getHtmlId() . '_id';
     $html .= '<select id="' . $selectId . '" name="' . $selectName . '" class="select required-entry" style="display:none">';
     $html .= '<option value="">' . __('Please select') . '</option>';
     $html .= '</select>';
     $html .= '<script>' . "\n";
     $html .= 'require(["prototype", "mage/adminhtml/form"], function(){';
     $html .= '$("' . $selectId . '").setAttribute("defaultValue", "' . $regionId . '");' . "\n";
     $html .= 'new regionUpdater("' . $country->getHtmlId() . '", "' . $element->getHtmlId() . '", "' . $selectId . '", ' . $this->_directoryHelper->getRegionJson() . ');' . "\n";
     $html .= '});';
     $html .= '</script>' . "\n";
     $html .= '</div></div>' . "\n";
     return $html;
 }
예제 #3
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;
 }
예제 #4
0
파일: Checkbox.php 프로젝트: aiesh/magento2
 /**
  * Checkbox render function
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     /** @var \Magento\Framework\Data\Form\Element\Checkbox $checkbox */
     $checkbox = $this->_elementFactory->create('checkbox', array('data' => $element->getData()));
     $checkbox->setForm($element->getForm());
     $elementHtml = sprintf('<div class="field no-label field-%s with-note">' . '<div class="control">' . '<div class="nested">' . '<div class="field choice"> %s' . '<label class="label" for="%s">%s</label>' . '<p class="note">%s</p>' . '</div>' . '</div>' . '</div>' . '</div>', $element->getHtmlId(), $checkbox->getElementHtml(), $element->getHtmlId(), $element->getLabel(), $element->getNote());
     return $elementHtml;
 }
예제 #5
0
 /**
  * @covers \Magento\Framework\Data\Form\Element\AbstractElement::getHtmlId()
  */
 public function testGetHtmlId()
 {
     $htmlIdPrefix = '--';
     $htmlIdSuffix = ']]';
     $htmlId = 'some_id';
     $formMock = $this->getMock('Magento\\Framework\\Data\\Form\\AbstractForm', ['getHtmlIdPrefix', 'getHtmlIdSuffix'], [], '', false);
     $formMock->expects($this->any())->method('getHtmlIdPrefix')->will($this->returnValue($htmlIdPrefix));
     $formMock->expects($this->any())->method('getHtmlIdSuffix')->will($this->returnValue($htmlIdSuffix));
     $this->_model->setId($htmlId);
     $this->_model->setForm($formMock);
     $this->assertEquals($htmlIdPrefix . $htmlId . $htmlIdSuffix, $this->_model->getHtmlId());
 }
예제 #6
0
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $html = '';
     if ($element->getBeforeElementHtml() && $element->getBeforeElementHtml() != '') {
         $html .= '<label class="addbefore" for="' . $element->getHtmlId() . '">' . $element->getBeforeElementHtml() . '</label>';
     }
     $html .= '<input id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" ' . ' value="0" type="hidden"/>';
     if ($element->getAfterElementJs() && $element->getAfterElementJs() != '') {
         $html .= $element->getAfterElementJs();
     }
     if ($element->getAfterElementHtml() && $element->getAfterElementHtml() != '') {
         $html .= '<label class="addafter" for="' . $element->getHtmlId() . '">' . $element->getAfterElementHtml() . '</label>';
     }
     return $html;
 }
예제 #7
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();
 }
예제 #8
0
파일: Newpass.php 프로젝트: aiesh/magento2
 /**
  * @param AbstractElement $element
  * @return string
  */
 public function render(AbstractElement $element)
 {
     $html = '<div class="field field-' . $element->getHtmlId() . '">';
     $html .= $element->getLabelHtml();
     $html .= '<div class="control">' . $element->getElementHtml();
     $html .= '<div class="nested">';
     $html .= '<div class="field choice">';
     $html .= '<label for="account-send-pass" class="addbefore"><span>' . __('or ') . '</span></label>';
     $html .= '<input type="checkbox" id="account-send-pass" name="' . $element->getName() . '" value="auto" onclick="setElementDisable(\'' . $element->getHtmlId() . '\', this.checked)" />';
     $html .= '<label class="label" for="account-send-pass"><span>' . __(' Send auto-generated password') . '</span></label>';
     $html .= '</div>' . "\n";
     $html .= '</div>' . "\n";
     $html .= '</div>' . "\n";
     $html .= '</div>' . "\n";
     return $html;
 }
예제 #9
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();
 }
예제 #10
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();
 }
예제 #11
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();
 }
 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();
 }
예제 #13
0
 /**
  * @param AbstractElement $element
  * @return string
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 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();
 }
예제 #15
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;
 }
예제 #16
0
 /**
  * Return header title part of html for payment solution
  *
  * @param AbstractElement $element
  * @return string
  */
 protected function _getHeaderTitleHtml($element)
 {
     $isPaymentEnabled = '';
     $disabledLegend = '';
     if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_STANDARD_ACTIVE)) {
         $isPaymentEnabled = 'disabled';
         $disabledLegend = __("Checkout Classic Method must be enabled");
     } else {
         if (!$this->_helper->isCountryEnabled()) {
             $isPaymentEnabled = 'disabled';
             $disabledLegend = __("MercadoEnvios is not enabled in the country where Mercado Pago is configured");
         }
     }
     $html = '<div class="config-heading" ><div class="heading"><strong id="meen-logo"><div class="meli-legend">' . $element->getLegend();
     $html .= '</div></strong>';
     $html .= '<div class="button-container"><button ' . $isPaymentEnabled . ' type="button"' . ' class="button meli-payment-btn action-configure ' . $isPaymentEnabled . ' ' . '" 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 class="disabled-legend"> ' . $disabledLegend . '</div></div></div>';
     $html .= '</div>';
     return $html;
 }
예제 #17
0
 /**
  * @param null|string $requestCountry
  * @param null|string $requestDefaultCountry
  * @param bool $canUseDefault
  * @param bool $inherit
  * @dataProvider renderDataProvider
  */
 public function testRender($requestCountry, $requestDefaultCountry, $canUseDefault, $inherit)
 {
     $this->_request->expects($this->any())->method('getParam')->will($this->returnCallback(function ($param) use($requestCountry, $requestDefaultCountry) {
         if ($param == \Magento\Paypal\Model\Config\StructurePlugin::REQUEST_PARAM_COUNTRY) {
             return $requestCountry;
         }
         if ($param == Country::REQUEST_PARAM_DEFAULT_COUNTRY) {
             return $requestDefaultCountry;
         }
         return $param;
     }));
     $this->_element->setInherit($inherit);
     $this->_element->setCanUseDefaultValue($canUseDefault);
     $constraints = [new \PHPUnit_Framework_Constraint_StringContains('document.observe("dom:loaded", function() {'), new \PHPUnit_Framework_Constraint_StringContains('$("' . $this->_element->getHtmlId() . '").observe("change", function () {')];
     if ($canUseDefault && $requestCountry == 'US' && $requestDefaultCountry) {
         $constraints[] = new \PHPUnit_Framework_Constraint_StringContains('$("' . $this->_element->getHtmlId() . '_inherit").observe("click", function () {');
     }
     $this->_jsHelper->expects($this->once())->method('getScript')->with(new \PHPUnit_Framework_Constraint_And($constraints));
     $this->_url->expects($this->once())->method('getUrl')->with('*/*/*', ['section' => 'section', 'website' => 'website', 'store' => 'store', \Magento\Paypal\Model\Config\StructurePlugin::REQUEST_PARAM_COUNTRY => '__country__']);
     $this->_model->render($this->_element);
 }
 /**
  * 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 EMerchantPayCheckout" ><div class="headingEMerchantPay"><strong>' . $element->getLegend();
     $html .= '</strong>';
     if ($element->getComment()) {
         $html .= '<span class="heading-intro">' . $element->getComment() . '</span>';
     }
     $html .= '</div>';
     $htmlId = $element->getHtmlId();
     $html .= '<div class="button-container"><button type="button"' . ' class="button action-configure' . '" id="' . $htmlId . '-head" onclick="showHideEMPPaymentSolution.call(this, \'' . $htmlId . '\'); return false;"><span class="state-closed">' . __('Configure') . '</span><span class="state-opened">' . __('Collapse') . '</span></button>';
     $html .= '</div></div>';
     return $html;
 }
예제 #19
0
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $html = "<input class=' input-text'  type='hidden' id='" . $element->getHtmlId() . "' name='" . $element->getName() . "' value='" . $element->getEscapedValue() . "' '" . $element->serialize($element->getHtmlAttributes()) . "/>";
     $html .= "<table cellpadding='2' style='width:600px !important;width:auto;' class='wl-cron'>\n            <thead> \n                <tr><th>Days of the week</th><th width='20'></th><th colspan='4'>Hours of the day</th></tr>\n            </thead>\n            <tr>\n                <td width='300' align='left'>\n                    <div>" . $this->checkbox("Monday", "d-Monday", "Monday", 'd') . "</div>\n                    <div>" . $this->checkbox("Tuesday", "d-Tuesday", "Tuesday", 'd') . "</div>\n                    <div>" . $this->checkbox("Wednesday", "d-Wednesday", "Wednesday", 'd') . "</div>\n                    <div>" . $this->checkbox("Thursday", "d-Thursday", "Thurday", 'd') . "</div>\n                    <div>" . $this->checkbox("Friday", "d-Friday", "Friday", 'd') . "</div>\n                    <div>" . $this->checkbox("Saturday", "d-Saturday", "Saturday", 'd') . "</div>\n                    <div>" . $this->checkbox("Sunday", "d-Sunday", "Sunday", 'd') . "</div>\n                </td>\n                <td width='175' class='morning-half'>\n                    <div>" . $this->checkbox("00:00", "h-0000", "00:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("01:00", "h-0100", "01:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("02:00", "h-0200", "02:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("03:00", "h-0300", "03:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("04:00", "h-0400", "04:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("05:00", "h-0500", "05:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("06:00", "h-0600", "06:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("07:00", "h-0700", "07:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("08:00", "h-0800", "08:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("09:00", "h-0900", "09:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("10:00", "h-1000", "10:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("11:00", "h-1100", "11:00 AM", 'h') . "</div>\n                </td>\n                <td width='175' class='morning'>\n                    <div>" . $this->checkbox("00:30", "h-0030", "00:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("01:30", "h-0130", "01:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("02:30", "h-0230", "02:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("03:30", "h-0330", "03:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("04:30", "h-0430", "04:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("05:30", "h-0530", "05:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("06:30", "h-0630", "06:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("07:30", "h-0730", "07:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("08:30", "h-0830", "08:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("09:30", "h-0930", "09:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("10:30", "h-1030", "10:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("11:30", "h-1130", "11:30 AM", 'h') . "</div>\n                </td>\n                <td width='175' class='afternoon-half'>\n                    <div>" . $this->checkbox("12:00", "h-1200", "12:00 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("13:00", "h-1300", "01:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("14:00", "h-1400", "02:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("15:00", "h-1500", "03:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("16:00", "h-1600", "04:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("17:00", "h-1700", "05:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("18:00", "h-1800", "06:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("19:00", "h-1900", "07:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("20:00", "h-2000", "08:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("21:00", "h-2100", "09:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("22:00", "h-2200", "10:00 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("23:00", "h-2300", "11:00 PM", 'h') . "</div>\n                </td>\n                <td width='175' class='afternoon'>\n                    <div>" . $this->checkbox("12:30", "h-1230", "12:30 AM", 'h') . "</div>\n                    <div>" . $this->checkbox("13:30", "h-1330", "01:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("14:30", "h-1430", "02:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("15:30", "h-1530", "03:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("16:30", "h-1630", "04:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("17:30", "h-1730", "05:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("18:30", "h-1830", "06:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("19:30", "h-1930", "07:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("20:30", "h-2030", "08:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("21:30", "h-2130", "09:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("22:30", "h-2230", "10:30 PM", 'h') . "</div>\n                    <div>" . $this->checkbox("23:30", "h-2330", "11:30 PM", 'h') . "</div>\n                </td>\n            </tr>\n        </table>";
     $html .= "<script>\nrequire([\n    'jquery',\n    'mage/mage'\n], function (\$) {\n    \$(function () {\n        jQuery(document).ready(function () {\n\n            if (jQuery('#" . $element->getHtmlId() . "').length > 0) {\n\n                if (jQuery('#" . $element->getHtmlId() . "').val() === '') {\n                    jQuery('#" . $element->getHtmlId() . "').val('{\"days\":[],\"hours\":[]}');\n                }\n                var cron = jQuery.parseJSON(jQuery('#" . $element->getHtmlId() . "').val());\n\n                for (var i = 0; i < cron.days.length; i++) {\n                    if (jQuery('#d-' + cron.days[i])) {\n                        jQuery('#d-' + cron.days[i]).prop('checked', true);\n                    }\n                }\n\n                for (var i = 0; i < cron.hours.length; i++) {\n                    if (jQuery('#h-' + cron.hours[i].replace(':', ''))) {\n                        jQuery('#h-' + cron.hours[i].replace(':', '')).prop('checked', true);\n                    }\n                }\n\n                jQuery('.cron-box').on('click', function () {\n                    var d = new Array();\n                    jQuery('.cron-d-box').each(function () {\n                        if (jQuery(this).prop('checked')) {\n                            d.push(jQuery(this).val());\n                        }\n                    });\n                    var h = new Array();\n                    jQuery('.cron-h-box').each(function () {\n                        if (jQuery(this).prop('checked')) {\n                            h.push(jQuery(this).val());\n                        }\n                    });\n                    jQuery('#" . $element->getHtmlId() . "').val(Object.toJSON({days: d, hours: h}));\n                });\n            }\n        });\n    });\n});\n</script>";
     $html .= $element->getAfterElementHtml();
     return $html;
 }
예제 #20
0
파일: Heading.php 프로젝트: vasuscoin/brand
 /**
  * render separator config row
  * 
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $fieldConfig = $element->getFieldConfig();
     $htmlId = $element->getHtmlId();
     $html = '<tr id="row_' . $htmlId . '">' . '<td class="label" colspan="3">';
     $html .= '<div style="border-bottom: 1px solid #dfdfdf;
     font-size: 15px;
     color: #666;
     border-left: #CCC solid 5px;
     padding: 2px 12px;
     text-align: left !important;
     margin-left: 10%;
     margin-top: 20px;">';
     $html .= $element->getLabel();
     $html .= '</div></td></tr>';
     return $html;
 }
예제 #21
0
파일: Color.php 프로젝트: clkweb/popup
 /**
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $html = $element->getElementHtml();
     $value = $element->getData('value');
     $html .= '<script type="text/javascript">
         require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) {
             $(document).ready(function () {
                 var $el = $("#' . $element->getHtmlId() . '");
                 $el.css("backgroundColor", "' . $value . '");
                 // Attach the color picker
                 $el.ColorPicker({
                     color: "' . $value . '",
                     onChange: function (hsb, hex, rgb) {
                         $el.css("backgroundColor", "#" + hex).val("#" + hex);
                     }
                 });
             });
         });
         </script>';
     return $html;
 }
예제 #22
0
파일: Form.php 프로젝트: aiesh/magento2
 /**
  * Instantiate form and fields
  *
  * @return \Magento\Framework\Data\Form
  */
 protected function _prepareForm()
 {
     $form = $this->_formFactory->create();
     $form->setFieldsetRenderer($this->getLayout()->createBlock('Magento\\Backend\\Block\\Widget\\Form\\Renderer\\Fieldset'));
     $form->setFieldsetElementRenderer($this->getLayout()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Form\\Renderer\\Fieldset\\Element'));
     /**
      * if there is a parent element defined, it will be replaced by a hidden element with the same name
      * and overridden by the form elements
      * It is needed to maintain HTML consistency of the parent element's form
      */
     if ($this->_parentElement) {
         $form->setHtmlIdPrefix($this->_parentElement->getHtmlId())->setFieldNameSuffix($this->_parentElement->getName());
         $form->addField('', 'hidden', array('name' => ''));
     }
     $noYes = array(__('No'), __('Yes'));
     // schedule
     $schedule = $form->addFieldset('schedule_fieldset', array('legend' => __('Schedule'), 'disabled' => $this->_isReadOnly));
     $schedule->addField('start_date_is_editable', 'select', array('name' => 'start_date_is_editable', 'label' => __('Customer Can Define Start Date'), 'comment' => __('Select whether buyer can define the date when billing for the payment begins.'), 'options' => $noYes, 'disabled' => $this->_isReadOnly));
     $this->_addField($schedule, 'schedule_description');
     $this->_addField($schedule, 'suspension_threshold');
     $this->_addField($schedule, 'bill_failed_later', array('options' => $noYes), 'select');
     // billing
     $billing = $form->addFieldset('billing_fieldset', array('legend' => __('Billing'), 'disabled' => $this->_isReadOnly));
     $this->_addField($billing, 'period_unit', array('options' => $this->_getPeriodUnitOptions(__('-- Please Select --'))), 'select');
     $this->_addField($billing, 'period_frequency');
     $this->_addField($billing, 'period_max_cycles');
     // trial
     $trial = $form->addFieldset('trial_fieldset', array('legend' => __('Trial Period'), 'disabled' => $this->_isReadOnly));
     $this->_addField($trial, 'trial_period_unit', array('options' => $this->_getPeriodUnitOptions(__('-- Not Selected --'))), 'select');
     $this->_addField($trial, 'trial_period_frequency');
     $this->_addField($trial, 'trial_period_max_cycles');
     $this->_addField($trial, 'trial_billing_amount');
     // initial fees
     $initial = $form->addFieldset('initial_fieldset', array('legend' => __('Initial Fees'), 'disabled' => $this->_isReadOnly));
     $this->_addField($initial, 'init_amount');
     $this->_addField($initial, 'init_may_fail', array('options' => $noYes), 'select');
     return $form;
 }
예제 #23
0
 /**
  * Render element
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  *
  * @see RendererInterface::render()
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $element->addClass('element-value-changer');
     $valueName = $element->getValueName();
     if ($valueName === '') {
         $valueName = '...';
     }
     if ($element->getShowAsText()) {
         $html = ' <input type="hidden" class="hidden" id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" value="' . $element->getValue() . '"/> ' . htmlspecialchars($valueName) . '&nbsp;';
     } else {
         $html = ' <span class="rule-param"' . ($element->getParamId() ? ' id="' . $element->getParamId() . '"' : '') . '>' . '<a href="javascript:void(0)" class="label">';
         if ($this->inlineTranslate->isAllowed()) {
             $html .= $this->escapeHtml($valueName);
         } else {
             $html .= $this->escapeHtml($this->filterManager->truncate($valueName, ['length' => 33, 'etc' => '...']));
         }
         $html .= '</a><span class="element"> ' . $element->getElementHtml();
         if ($element->getExplicitApply()) {
             $html .= ' <a href="javascript:void(0)" class="rule-param-apply"><img src="' . $this->getViewFileUrl('images/rule_component_apply.gif') . '" class="v-middle" alt="' . __('Apply') . '" title="' . __('Apply') . '" /></a> ';
         }
         $html .= '</span></span>&nbsp;';
     }
     return $html;
 }
예제 #24
0
 /**
  * Render element html
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     return sprintf('<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h4 id="%s">%s</h4></td></tr>', $element->getHtmlId(), $element->getHtmlId(), $element->getLabel());
 }
예제 #25
0
파일: form.php 프로젝트: mage2pro/core
/**
 * 2016-01-08
 * @param AE $e
 * @param string $uidSuffix [optional]
 * @return array(string => string)
 */
function df_fe_attrs(AE $e, $uidSuffix = null)
{
    return ['id' => $e->getHtmlId(), 'name' => $e->getName()] + df_fe_uid($e, $uidSuffix) + dfa_select($e->getData(), $e->getHtmlAttributes());
}
예제 #26
0
 /**
  * Get country selector html
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $urlParams = ['section' => $this->getRequest()->getParam('section'), 'website' => $this->getRequest()->getParam('website'), 'store' => $this->getRequest()->getParam('store'), StructurePlugin::REQUEST_PARAM_COUNTRY => '__country__'];
     $urlString = $this->_escaper->escapeJsQuote($this->_url->getUrl('*/*/*', $urlParams));
     $jsString = '
         $("' . $element->getHtmlId() . '").observe("change", function () {
             location.href = \'' . $urlString . '\'.replace("__country__", this.value);
         });
     ';
     if ($this->_defaultCountry) {
         $urlParams[self::REQUEST_PARAM_DEFAULT_COUNTRY] = '__default__';
         $urlString = $this->_escaper->escapeJsQuote($this->_url->getUrl('*/*/*', $urlParams));
         $jsParentCountry = $this->_escaper->escapeJsQuote($this->_defaultCountry);
         $jsString .= '
             $("' . $element->getHtmlId() . '_inherit").observe("click", function () {
                 if (this.checked) {
                     location.href = \'' . $urlString . '\'.replace("__country__", \'' . $jsParentCountry . '\')
                         .replace("__default__", "1");
                 }
             });
         ';
     }
     return parent::_getElementHtml($element) . $this->_jsHelper->getScript('require([\'prototype\'], function(){document.observe("dom:loaded", function() {' . $jsString . '});});');
 }
예제 #27
0
 /**
  * Decorate field row html
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @param string $html
  * @return string
  */
 protected function _decorateRowHtml($element, $html)
 {
     return '<tr id="row_' . $element->getHtmlId() . '">' . $html . '</tr>';
 }
예제 #28
0
 /**
  * Decorate field row html
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @param string $html
  * @return string
  */
 protected function _decorateRowHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element, $html)
 {
     return '<tr id="row_' . $element->getHtmlId() . '">' . $html . '</tr>';
 }
예제 #29
0
 /**
  * @param AbstractElement $element
  * @return string
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 protected function _getHeaderHtml($element)
 {
     $id = $element->getHtmlId();
     $default = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
     $html = '<h4 class="icon-head head-edit-form">' . $element->getLegend() . '</h4>';
     $html .= '<fieldset class="config" id="' . $element->getHtmlId() . '">';
     $html .= '<legend>' . $element->getLegend() . '</legend>';
     // field label column
     $html .= '<table cellspacing="0"><colgroup class="label" /><colgroup class="value" />';
     if (!$default) {
         $html .= '<colgroup class="use-default" />';
     }
     $html .= '<tbody>';
     return $html;
 }
예제 #30
0
 /**
  * 2015-12-13
  * Отличия от модифицируемого метода
  * @see \Magento\Framework\Data\Form\Element\AbstractElement::getLabelHtml():
  * 1) Добавляем свои классы для Font Awesome.
  * 2) При использовании Font Awesome не добавляем исходную подпись
  * (значением которой является класс Font Awesome)
  * и выводим, по сути, пустые теги <label><span></span></label>.
  * 3) Добавляем атрибут title.
  * 2015-12-28
  * 4) Добавляем класс, соответствующий типу элемента.
  *
  * Пример использования Font Awesome: https://github.com/mage2pro/core/tree/7cb37ab2c4d728bc20d29ca3c7c643e551f6eb0a/Framework/Data/Form/Element/Font.php#L40
  *
  * @see \Df\Framework\Form\Element\Font::onFormInitialized()
  * @see \Magento\Framework\Data\Form\Element\AbstractElement::getLabelHtml()
  * @param Sb|E $sb
  * @param \Closure $proceed
  * @param string|null $idSuffix
  * @return string
  */
 public function aroundGetLabelHtml(Sb $sb, \Closure $proceed, $idSuffix = '')
 {
     /** @var string|null|Phrase $label */
     $label = $sb->getLabel();
     /** @var string $result */
     if (is_null($label)) {
         $result = '';
     } else {
         $label = (string) $label;
         /**
          * 2015-12-25
          * @see \Magento\Framework\Data\Form\Element\Multiline::getLabelHtml()
          * имеет другое значение по-умолчанию параметра $idSuffix:
          * public function getLabelHtml($suffix = 0)
          * https://github.com/magento/magento2/blob/2.0.0/lib/internal/Magento/Framework/Data/Form/Element/Multiline.php#L59
          */
         if ('' === $idSuffix && $sb instanceof Multiline) {
             $idSuffix = 0;
         }
         /** @var bool $isFontAwesome */
         $isFontAwesome = df_starts_with($label, 'fa-');
         /** @var string[] $classA */
         $classA = ['label', 'admin__field-label', 'df-element-' . $sb->getType()];
         if ($isFontAwesome) {
             $classA[] = 'fa';
             $classA[] = $label;
             $label = '';
         }
         /** @var array(string => string) $params */
         $params = ['class' => df_cc_s($classA), 'for' => $sb->getHtmlId() . $idSuffix, 'data-ui-id' => E::uidSt($sb, 'label')];
         /** @var string $title */
         $title = (string) $sb->getTitle();
         if ($title !== $label) {
             $params['title'] = $title;
         }
         $result = df_tag('label', $params, df_tag('span', [], $label)) . "\n";
     }
     return $result;
 }