/** * Adds some Javascript to the drop-down to place recommended defaults * * @param Varien_Data_Form_Element_Abstract $element * * @return string */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $defaultSizes = array('image' => array('width' => '265', 'height' => ''), 'small_image' => array('width' => '88', 'height' => '77'), 'thumbnail' => array('width' => '75', 'height' => '75')); $element->setData('onchange', "defaultImageSize();"); $element->setData('after_element_html', "\r\n\t\t\t<script>\r\n\t\t\t\tfunction defaultImageSize() {\r\n\t\t\t\t\tvar sizes = " . json_encode($defaultSizes) . ";\r\n\t\t\t\t\tvar size = sizes[\$('{$element->getId()}').value];\r\n\t\t\t\t\tif (size) {\r\n\t\t\t\t\t\tfor (var name in size) {\r\n\t\t\t\t\t\t\t\$('bronto_format_image_' + name).value = size[name];\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t</script>\r\n\t\t"); return parent::_getElementHtml($element); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $element->setData('onchange', "apiValidation(this.form, this);"); $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxvalidation'); $element->setData('after_element_html', "\n <script>\n document.observe('dom:loaded', function(){\n apiValidation();\n\n });\n function apiValidation(form, element) {\n var api_user = \$('connector_transactional_emails_credentials_api_username');\n var api_password = \$('connector_transactional_emails_credentials_api_password');\n var reloadurl = '{$url}';\n var encoded = btoa(api_password.value);\n new Ajax.Request(reloadurl, {\n method: 'post',\n parameters: {'api_username' : api_user.value, 'api_password' : encoded},\n onComplete: function(transport) {\n Element.hide('loadingmask');\n if(transport.responseText == '\"Credentials Valid.\"'){\n api_user.setStyle({\n fontWeight: 'bold',\n color: 'green' ,\n background: 'transparent url(\"" . $this->getSkinUrl('images/success_msg_icon.gif') . "\") no-repeat right center'\n })\n }else{\n api_user.setStyle({\n fontWeight: 'bold',\n color: 'red',\n background: 'transparent url(\"" . $this->getSkinUrl('images/error_msg_icon.gif') . "\") no-repeat right center'\n });\n\n }\n }\n });\n\n return false;\n }\n\n </script>\n "); return parent::_getElementHtml($element); }
/** * Override method to output our custom HTML with JavaScript * * @param Varien_Data_Form_Element_Abstract $element * * @return String */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { // Only do validation if module is installed and active if ($this->helper('bronto_common')->isModuleInstalled('Bronto_Verify')) { $_html = array(); // Create form object to grab scope details $form = new Mage_Adminhtml_Block_System_Config_Form(); $scope = $form->getScope(); $scopeId = $form->getScopeId(); $element->setData('onchange', "validateToken(this.form, this);"); $element->setData('after_element_html', "\n <span id=\"loadingMask\" style=\"display: none; width: 100px;\">\n <span class=\"loader\" id=\"loading-mask-loader\" style=\"background: url(" . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" . $this->__(' Verifying...') . "</span>\n <span id=\"loading-mask\"></span>\n </span>\n <script>\n /**\n * Function to Toggle Form Elements Disabled Status Based On Token Status\n */\n function toggleDisabled(form, element) {\n // Get Status Text Element\n var statusText = \$('bronto-validation-status-text');\n // If Status Text Element has Class of 'invalid' or empty, set boolean disabled value\n var disabled = (statusText.className == 'invalid' || statusText.className == '');\n\n // Cycle through form elements and disable/enable elements\n for (i = 0; i < form.length; i++) {\n if (form.elements[i].id != '{$element->getId()}' &&\n form.elements[i].id != 'bronto_settings_enabled' &&\n form.elements[i].id != 'verify-button' &&\n form.elements[i].type != 'hidden' &&\n form.elements[i].name.indexOf('groups') == 0) {\n form.elements[i].disabled = disabled;\n }\n }\n\n // Get Last Element of Form, and if the class name is 'note', empty the html value\n var last = element.parentNode.lastChild;\n if (last.className == 'note') {\n last.innerHTML = '';\n }\n }\n\n function trim1 (str) {\n return str.replace(/^\\s\\s*/, '').replace(/\\s\\s*\$/, '');\n }\n\n function validateToken(form, element) {\n var token = trim1(\$('{$element->getId()}').value);\n var statusText = \$('bronto-validation-status');\n var reloadUrl = '{$this->getUrl('*/apitoken/ajaxvalidation')}';\n\n statusText.innerHTML = \$('loadingMask').innerHTML;\n statusText.removeClassName('valid').removeClassName('invalid');\n\n new Ajax.Request(reloadUrl, {\n method: 'post',\n parameters: {token: token, scope: '{$scope}', scopeid: '{$scopeId}'},\n onComplete: function(transport) {\n Element.hide('loadingMask');\n statusText.innerHTML = transport.responseText;\n\n toggleDisabled(form, element);\n }\n });\n\n return false;\n }\n </script>\n "); if (!$this->helper('bronto_common')->getApiToken()) { $element->setComment('<span style="color:red;font-weight:bold">Please enter your Bronto API key here.</span>'); $buttonHtml = ""; } else { $button = $this->getLayout()->createBlock('bronto_verify/adminhtml_widget_button_runtoken')->toHtml(); $buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\">{$button}</p>"; } // Show Roundtrip Install Verification Status $_html[] = $buttonHtml . '<style>' . ' #bronto-validation-status { color:grey; font-weight:bold; }' . ' #bronto-validation-status .valid { color: green; }' . ' #bronto-validation-status .invalid { color: red; }' . '</style>' . '<strong style="float: left; width: 80px">Last Status:</strong> ' . '<span id="bronto-validation-status">' . $this->helper('bronto_verify/apitoken')->getAdminScopedApitokenStatusText() . '</span>'; // Show everything Else if (!empty($_html)) { $elementHtml = $element->getElementHtml(); if ($element->getComment()) { $elementHtml .= '<p class="note"><span>' . $element->getComment() . '</span></p>'; $element->setComment(null); } $elementHtml .= '<div style="margin-top:10px">'; $elementHtml .= implode('<br />', $_html); $elementHtml .= '</div>'; return $elementHtml; } } return parent::_getElementHtml($element); }
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $element->setData('onchange', "resetContacts();"); //url to reset the contacs $url = Mage::helper('adminhtml')->getUrl('*/connector/resetcontactsajax'); $element->setData('after_element_html', "\n <script>\n function resetContacts(){\n new Ajax.Request('{$url}', {\n method: 'get',\n onComplete: function(transport) {\n }\n });\n return false;\n }\n </script>\n "); return parent::_getElementHtml($element); }
/** label */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //base url $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); //config code $code = Mage::helper('ddg')->getPasscode(); if (!strlen($code)) { $code = '[PLEASE SET UP A PASSCODE]'; } //full url $text = $baseUrl . 'connector/email/coupon/id/[INSERT ID HERE]/code/' . $code . '/expire_days/[INSERT NUMBER OF DAYS HERE]/@EMAIL@'; $element->setData('value', $text); $element->setData('disabled', 'disabled'); return parent::_getElementHtml($element); }
/** label */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //base url $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); //config passcode $passcode = Mage::helper('ddg')->getPasscode(); if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } //full url $text = sprintf('%sconnector/report/bestsellers/code/%s', $baseUrl, $passcode); $element->setData('value', $text); $element->setData('disabled', 'disabled'); return parent::_getElementHtml($element); }
/** * Ajax Create the datafields. * * @param Varien_Data_Form_Element_Abstract $element * * @return string */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $url = Mage::helper('adminhtml')->getUrl('*/connector/createnewdatafield'); $website = Mage::app()->getRequest()->getParam('website', 0); $element->setData('after_element_html', "<script>\n function createDatafield(form, element) {\n var datafield_name \t= \$('connector_data_mapping_dynamic_datafield_datafield_name').value;\n var datafield_type \t= \$('connector_data_mapping_dynamic_datafield_datafield_type').value;\n var datafield_default \t= \$('connector_data_mapping_dynamic_datafield_datafield_default').value;\n var datafield_access = \$('connector_data_mapping_dynamic_datafield_datafield_access').value;\n\n var reloadurl = '{$url}';\n\n if(datafield_name && datafield_type && datafield_access){\n new Ajax.Request(reloadurl, {\n method: 'post',\n parameters: {'name' : datafield_name, 'type' : datafield_type, 'default' : datafield_default, 'access' : datafield_access, 'website': '{$website}'},\n onComplete: function(transport) {\n window.location.reload();\n }\n });\n }\n return false;}</script>"); return parent::_getElementHtml($element); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $after_element_html = $element->getAfterElementHtml(); $javaScript = "\r\n <script type=\"text/javascript\">\r\n \tif('{$element->getHtmlId()}' == 'gomage_navigation_category_show_shopby')\r\n \t{\r\n \t\tvar sel_cat = \$('gomage_navigation_category_filter_type');\r\n \t\t\r\n \t\tEvent.observe('{$element->getHtmlId()}', 'change', function(){\r\n\t var value = \$('{$element->getHtmlId()}').value; \r\n\t if (value == 1){\r\n\t \tfor(i=sel_cat.options.length-1;i>=0;i--)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (sel_cat.options[i].value == '8'\r\n\t\t\t\t\t\t\t\t\t\t||\r\n\t\t\t\t\t\t\t\t\tsel_cat.options[i].value == '6')\r\n\t\t \t{\r\n\t\t \t\tsel_cat.remove(i);\r\n\t\t \t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n \t\r\n\t \t\t\t\t}else{\r\n\t \t\t\t\t\tvar option_fly = false;\r\n\t \t\t\t\t\tvar option_plain = false;\r\n\t \t\t\t\t\tfor(i=sel_cat.options.length-1;i>=0;i--)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (sel_cat.options[i].value == '8')\r\n\t\t \t{\r\n\t\t \t\toption_fly = true;\r\n\t\t \t}\r\n\t\t \t\r\n\t\t \tif (sel_cat.options[i].value == '6')\r\n\t\t \t{\r\n\t\t \t\toption_plain = true;\r\n\t\t \t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t \t\t\t\t\tif ( !option_plain )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsel_cat.options[sel_cat.options.length] = new Option('Plain', '6');\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif ( !option_fly )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsel_cat.options[sel_cat.options.length] = new Option('Fly-Out', '8');\r\n\t\t\t\t\t\t\t}\r\n\t \t\t\t\t}\r\n\t });\r\n \t}\r\n \telse if('{$element->getHtmlId()}' == 'gomage_navigation_rightcolumnsettings_show_shopby')\r\n \t{\r\n \t\tvar sel_right = \$('gomage_navigation_rightcolumnsettings_filter_type');\r\n \t\t\r\n \t\tEvent.observe('{$element->getHtmlId()}', 'change', function(){\r\n\t var value = \$('{$element->getHtmlId()}').value; \r\n\t if (value == 1){\r\n\t \tfor(i=sel_right.options.length-1;i>=0;i--)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (sel_right.options[i].value == '8'\r\n\t\t\t\t\t\t\t\t\t\t||\r\n\t\t\t\t\t\t\t\t\tsel_right.options[i].value == '6'\r\n\t\t\t\t\t\t\t\t\t)\r\n\t\t \t{\r\n\t\t \t\tsel_right.remove(i);\r\n\t\t \t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n \t\r\n\t \t\t\t\t}else{\r\n\t \t\t\t\t\tvar option_fly = false;\r\n\t \t\t\t\t\tvar option_plain = false;\r\n\t \t\t\t\t\tfor(i=sel_right.options.length-1;i>=0;i--)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (sel_right.options[i].value == '8')\r\n\t\t \t{\r\n\t\t \t\toption_fly = true;\r\n\t\t \t}\r\n\t\t \t\r\n\t\t \tif (sel_right.options[i].value == '6')\r\n\t\t \t{\r\n\t\t \t\toption_plain = true;\r\n\t\t \t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t \t\t\t\t\tif ( !option_plain )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsel_right.options[sel_right.options.length] = new Option('Plain', '6');\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif ( !option_fly )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsel_right.options[sel_right.options.length] = new Option('Fly-Out', '8');\r\n\t\t\t\t\t\t\t}\r\n\t \t\t\t\t}\r\n\t });\r\n \t}\r\n \t\r\n \r\n document.observe('dom:loaded', function() { \t\r\n \tinit_{$element->getHtmlId()}(); \t\r\n });\r\n document.onreadystatechange = init_{$element->getHtmlId()};\r\n \r\n function init_{$element->getHtmlId()}() {\r\n \tGomage_Navigation_fireEvent(\$('{$element->getHtmlId()}'), 'change');\r\n }\r\n </script>"; $element->setData('after_element_html', $javaScript . $after_element_html); return $element->getElementHtml(); }
/** * Render element. * * @param Varien_Data_Form_Element_Abstract $element * @return string */ public function render(Varien_Data_Form_Element_Abstract $element) { $after_element_html = '<script> jQuery(function(){ jQuery("#' . $element->getHtmlId() . '").attr("style", "width: 200px !important").attr("data-hex", true).mColorPicker({ imageFolder: "' . $this->getJsUrl('olegnax/mColorPicker/') . '" }); });</script>'; $element->setData('after_element_html', $after_element_html); $this->_element = $element; return $this->toHtml(); }
/** * Override method to output our custom HTML with JavaScript * * @param Varien_Data_Form_Element_Abstract $element * * @return String */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $_html = array(); $element->setData('after_element_html', "\n <span id=\"classpath-loadingmask\" style=\"display: none; width: 100px;\">\n <span class=\"loader\" id=\"classpath-loading-mask-loader\" style=\"background: url(" . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" . $this->__(' Searching For Class Path...') . "</span>\n <span id=\"classpath-loading-mask\"></span>\n </span>\n\n <script>\n //<![CDATA[\n Event.observe(window, 'load', function() {\n var newTr = '<tr id=\"bronto_verify_advanced_classpath_results\"><td class=\"classpath_results\" colspan=\"4\"><div id=\"bronto-classpath-results\"></div></td></tr>';\n \$('" . $this->_getRowElementId($element) . "').insert({after: newTr});\n });\n function searchClasspath() {\n var reloadUrl = '{$this->getUrl('*/advanced/ajaxclasspath')}';\n var statusText = \$('bronto-classpath-results');\n\n var searchText = \$('bronto_verify_advanced_classpath_search').value;\n var classType = \$('classpath-type').value;\n\n statusText.innerHTML = \$('classpath-loadingmask').innerHTML;\n\n new Ajax.Request(reloadUrl, {\n method: 'post',\n parameters: {class: searchText, type: classType},\n onComplete: function(transport) {\n Element.hide('classpath-loadingmask');\n statusText.innerHTML = transport.responseText;\n }\n });\n\n return false;\n }\n //]]>\n </script>\n "); // Add Class Type Selector to Input $classTypeHtml = '<select id="classpath-type"><option value="model">Model (Default)</option><option value="helper">Helper</option><option value="block">Block</option><option value="controller">Controller</option></select>'; // Add Search Button $button = $this->getLayout()->createBlock('bronto_verify/adminhtml_widget_button_classpath')->toHtml(); $buttonHtml = "<p class=\"form-buttons\" id=\"events-button\" style=\"float:none;\">{$button}</p>"; // Add Button to Html $_html[] = $buttonHtml; // Show everything Else if (!empty($_html)) { $elementHtml = $element->getElementHtml(); $elementHtml .= $classTypeHtml; if ($element->getComment()) { $elementHtml .= '<p class="note"><span>' . $element->getComment() . '</span></p>'; $element->setComment(null); } $elementHtml .= '<div style="margin-top:10px">'; $elementHtml .= implode('<br />', $_html); $elementHtml .= '</div>'; return $elementHtml; } return parent::_getElementHtml($element); }
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element) { $html = '<script type="text/javascript">' . 'function showHideColumn(){ if(jQuery("select[name=\'parameters[widget_type]\']").val() == \'block\' && jQuery("select[name=\'parameters[scroll]\']").val() == 0) jQuery("input[name=\'parameters[column]\']").closest( "tr").hide(); else jQuery("input[name=\'parameters[column]\']").closest( "tr").show();}</script>'; $element->setOnchange('showHideColumn();'); $element->setData('after_element_html', $html); return $element; }
/** * Ajax Create the addressbooks. * * @param Varien_Data_Form_Element_Abstract $element * * @return string */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $url = Mage::helper('adminhtml')->getUrl('*/connector/createnewaddressbook'); $website = Mage::app()->getRequest()->getParam('website', 0); $element->setData('after_element_html', "<script>\n function createAddressbook(form, element) {\n var name = \$('connector_sync_settings_dynamic_addressbook_addressbook_name').value;\n var visibility = \$('connector_sync_settings_dynamic_addressbook_visibility').value;\n var reloadurl = '{$url}';\n if(name && visibility){\n new Ajax.Request(reloadurl, {\n method: 'post',\n parameters: {'name' : name, 'visibility' : visibility, 'website': '{$website}'},\n onComplete: function(transport) {\n window.location.reload();\n }\n });\n }\n return false;\n }\n </script>"); return parent::_getElementHtml($element); }
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element) { $targetId = $this->getFieldsetId() . '_' . $this->getConfig('target'); $block = $this->getLayout()->createBlock('mtwidget/adminhtml_widget_renderer_depend', '', array('target' => $targetId, 'url' => $this->getUrl('mtwidget/adminhtml_widget_attribute/option'), 'me' => $element->getHtmlId(), 'value' => implode(',', (array) $element->getValue()))); $element->setData('after_element_html', $block->toHtml()); return $element; }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $store = null; $disabled = false; if ($code = $this->getRequest()->getParam('store')) { $store = Mage::getModel('core/store')->load($code); } if ($store instanceof Mage_Core_Model_Store) { /* @var Nosto_Tagging_Helper_Account $accountHelper */ $accountHelper = Mage::helper('nosto_tagging/account'); /* @var NostoAccount $nostoAccount */ $nostoAccount = $accountHelper->find($store); if ($nostoAccount instanceof NostoAccountInterface) { foreach (NostoApiToken::getApiTokenNames() as $token) { if (!$nostoAccount->getApiToken($token)) { $disabled = true; break; } } } } if ($disabled === true) { /** @noinspection PhpUndefinedMethodInspection */ $element->setDisabled('disabled'); $metaOauth = new Nosto_Tagging_Model_Meta_Oauth(); /** @noinspection PhpUndefinedVariableInspection */ $metaOauth->loadData($store, $nostoAccount); $client = new NostoOAuthClient($metaOauth); $comment = sprintf('Your Nosto account is missing required tokens' . ' for updating settings to Nosto. Please click <a href="%s">' . ' here to re-connect</a> your account.', $client->getAuthorizationUrl()); $element->setData('comment', $comment); } return parent::_getElementHtml($element); }
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element) { $tree = Mage::getResourceModel('cms/page_tree')->load(); $element->setData('after_element_html', $tree->toSelectHtml($element->getName(), $element->getValue(), $element->getId())); $element->setValue(); // Not needed because page is already selected in select box return $element; }
/** * @return $this */ protected function _mergeAfterElementHtml() { $this->_afterElementHtml[90] = $this->_currentElement->getData('after_element_html'); $this->_addMarkDownConfig(); Mage::dispatchEvent('markdown_merge_after_element_html', array('instance' => $this)); ksort($this->_afterElementHtml); $this->_currentElement->setData('after_element_html', $this->_generateTabs()); $this->_afterElementHtml = array(); $this->_currentElement->addClass('initMarkdown ' . $this->_helper->getTextareaStyle()); return $this; }
/** * Prepare chooser element HTML * * @param Varien_Data_Form_Element_Abstract $element Form Element * @return Varien_Data_Form_Element_Abstract */ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element) { $this->_elementValueId = "{$element->getId()}"; $this->_selectedBanners = explode(',', $element->getValue()); //Create hidden field that store selected banner ids $hidden = new Varien_Data_Form_Element_Hidden($element->getData()); $hidden->setId($this->_elementValueId)->setForm($element->getForm()); $hiddenHtml = $hidden->getElementHtml(); $element->setValue('')->setValueClass('value2'); $element->setData('after_element_html', $hiddenHtml . $this->toHtml()); return $element; }
/** label */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //generate base url $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); $passcode = Mage::helper('ddg')->getPasscode(); if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } //full url for dynamic content $text = sprintf('%sconnector/products/push/code/%s', $baseUrl, $passcode); $element->setData('value', $text); return parent::_getElementHtml($element); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //passcode to append for url $passcode = Mage::helper('ddg')->getPasscode(); if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } //generate the base url and display for default store id $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); //display the full url $text = sprintf('%sconnector/feefo/score/code/%s', $baseUrl, $passcode); $element->setData('value', $text); return parent::_getElementHtml($element); }
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element) { $config = $this->getConfig(); $chooseButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setClass('scalable btn-chooser')->setLabel($config['button']['open'])->setOnclick('MediabrowserUtility.openDialog(\'' . $this->getUrl('*/cms_wysiwyg_images/index', array('target_element_id' => $element->getName())) . '\')')->setDisabled($element->getReadonly()); $text = new Varien_Data_Form_Element_Text(); $text->setForm($element->getForm())->setId($element->getName())->setName($element->getName())->setClass('widget-option input-text'); if ($element->getRequired()) { $text->addClass('required-entry'); } if ($element->getValue()) { $text->setValue($element->getValue()); } $element->setData('after_element_html', $text->getElementHtml() . $chooseButton->toHtml()); return $element; }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //base url $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); //config code $code = Mage::helper('ddg')->getPasscode(); $orderId = Mage::helper('ddg')->getMappedOrderId(); //message to set up the passcode if (!strlen($code)) { $code = '[PLEASE SET UP A PASSCODE]'; } //full url for dynamic content $text = sprintf('%s/connector/creditmemo/new/code/%s/id/@%s@', $baseUrl, $code, $orderId); $element->setData('value', $text); return parent::_getElementHtml($element); }
/** * Generate the urls. * * @param Varien_Data_Form_Element_Abstract $element * * @return string * @throws Mage_Core_Exception */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); $website = Mage::app()->getRequest()->getParam('website', false); if ($website) { $website = Mage::app()->getWebsite($website); $baseUrl = $website->getConfig('web/secure/base_url'); } $helper = Mage::helper('ddg'); $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website); $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website); if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } $text = sprintf('%sconnector/creditmemo/update/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId); $element->setData('value', $text); return parent::_getElementHtml($element); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //passcode to append for url $passcode = Mage::helper('ddg')->getPasscode(); //last order id witch information will be generated $lastOrderid = Mage::helper('ddg')->getLastOrderId(); if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } if (!$lastOrderid) { $lastOrderid = '[PLEASE MAP THE LAST ORDER ID]'; } //generate the base url and display for default store id $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); $text = sprintf('%sconnector/products/upsell/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderid); $element->setData('value', $text); return parent::_getElementHtml($element); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //generate base url for dynamic content $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); //config passcode $passcode = Mage::helper('ddg')->getPasscode(); $customerId = Mage::helper('ddg')->getMappedCustomerId(); if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } if (!$customerId) { $customerId = '[PLEASE MAP THE CUSTOMER ID]'; } //dynamic content url $text = sprintf('%sconnector/report/recentlyviewed/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId); $element->setData('value', $text); return parent::_getElementHtml($element); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //passcode to append for url $passcode = Mage::helper('ddg')->getPasscode(); //last quote id for dynamic page $lastQuoteId = Mage::helper('ddg')->getLastQuoteId(); if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } //alert message for last order id is not mapped if (!$lastQuoteId) { $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]'; } //generate the base url and display for default store id $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); $text = sprintf('%sconnector/quoteproducts/upsell/code/%s/quote_id/@%s@', $baseUrl, $passcode, $lastQuoteId); $element->setData('value', $text); return parent::_getElementHtml($element); }
/** * label * * @param Varien_Data_Form_Element_Abstract $element * @return string */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //passcode to append for url $passcode = Mage::helper('ddg')->getPasscode(); //last order id witch information will be generated $customerId = Mage::helper('ddg')->getMappedCustomerId(); if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } if (!$customerId) { $customerId = '[PLEASE MAP THE CUSTOMER ID]'; } //generate the base url and display for default store id $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); //display the full url $text = sprintf('%sconnector/email/wishlist/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId); $element->setData('value', $text); return parent::_getElementHtml($element); }
/** label */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //base url for dynamic content $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); $passcode = Mage::helper('ddg')->getPasscode(); //last quote id for dynamic page $lastQuoteId = Mage::helper('ddg')->getLastQuoteId(); //config passcode if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } //alert message for last order id is not mapped if (!$lastQuoteId) { $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]'; } // full url $text = sprintf("%sconnector/email/basket/code/%s/quote_id/@%s@", $baseUrl, $passcode, $lastQuoteId); $element->setData('value', $text); return parent::_getElementHtml($element); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { //base url $baseUrl = Mage::helper('ddg')->generateDynamicUrl(); //config passcode $passcode = Mage::helper('ddg')->getPasscode(); //last order id for dynamic page $lastOrderId = Mage::helper('ddg')->getLastOrderId(); if (!strlen($passcode)) { $passcode = '[PLEASE SET UP A PASSCODE]'; } //alert message for last order id is not mapped if (!$lastOrderId) { $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]'; } //full url for dynamic content $text = sprintf('%sconnector/products/crosssell/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderId); $element->setData('value', $text); return parent::_getElementHtml($element); }
/** * Render element. * * @param Varien_Data_Form_Element_Abstract $element * @return string */ public function render(Varien_Data_Form_Element_Abstract $element) { $previewHtml = ''; if ($element->getValue()) { // Add image preview. $url = $element->getValue(); if (!preg_match("/^http\\:\\/\\/|https\\:\\/\\//", $url)) { $url = Mage::getBaseUrl('media') . $url; } $previewHtml = '<a href="' . $url . '"' . ' onclick="imagePreview(\'' . $element->getHtmlId() . '_image\'); return false;">' . '<img src="' . $url . '" id="' . $element->getHtmlId() . '_image" title="' . $element->getValue() . '"' . ' alt="' . $element->getValue() . '" height="40" class="small-image-preview v-middle"' . ' style="margin-top:7px; border:1px solid grey" />' . '</a> '; } $prefix = $element->getForm()->getHtmlIdPrefix(); $elementId = $prefix . $element->getId(); $chooserUrl = $this->getUrl('*/cms_wysiwyg_images_chooser/index', array('target_element_id' => $elementId)); $label = $element->getValue() ? $this->__('Change Image') : $this->__('Insert Image'); $chooseButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setClass('btn-chooser')->setLabel($label)->setOnclick('MediabrowserUtility.openDialog(\'' . $chooserUrl . '\')')->setDisabled($element->getReadonly())->setStyle('display:inline;margin-top:7px'); // Add delete button. $removeButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setClass('delete')->setLabel($this->__('Remove Image'))->setOnclick('document.getElementById(\'' . $elementId . '\').value=\'\';if(document.getElementById(\'' . $elementId . '_image\'))document.getElementById(\'' . $elementId . '_image\').parentNode.remove()')->setDisabled($element->getReadonly())->setStyle('margin-left:10px;margin-top:7px'); $element->setData('after_element_html', $previewHtml . $chooseButton->toHtml() . $removeButton->toHtml()); $this->_element = $element; return $this->toHtml(); }
/** * SMS insert links. * * @param Varien_Data_Form_Element_Abstract $element * * @return string */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $element->setData('placeholder', self::DEFAULT_TEXT); $element->setData('after_element_html', "<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_one_message', '{{var order_number}}');return false;\">Insert Order Number</a>\n <a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_one_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>\n\n <script type='text/javascript'>\n function injectText(element,value){\n var element_dom=document.getElementById(element);\n if(document.selection){\n element_dom.focus();\n sel=document.selection.createRange();\n sel.text=value;\n return;\n }if(element_dom.selectionStart||element_dom.selectionStart=='0'){\n var t_start=element_dom.selectionStart;\n var t_end=element_dom.selectionEnd;\n var val_start=element_dom.value.substring(0,t_start);\n var val_end=element_dom.value.substring(t_end,element_dom.value.length);\n element_dom.value=val_start+value+val_end;\n }else{\n element_dom.value+=value;\n }\n }\n </script>\n "); return parent::_getElementHtml($element); }