public function render(Varien_Data_Form_Element_Abstract $element) { $html = '<tr>' . "\n"; $countryId = false; if ($country = $element->getForm()->getElement('country_id')) { $countryId = $country->getValue(); } $regionCollection = false; if ($countryId) { if (!isset(self::$_regionCollections[$countryId])) { self::$_regionCollections[$countryId] = Mage::getModel('directory/country')->setId($countryId)->getLoadedRegionCollection(); } $regionCollection = self::$_regionCollections[$countryId]; } $regionId = $element->getForm()->getElement('region_id')->getValue(); if ($regionCollection && $regionCollection->getSize()) { $elementClass = $element->getClass(); $element->setClass(str_replace('input-text', '', $elementClass)); $html .= '<td class="label">' . $element->getLabelHtml() . '</td>'; $html .= '<td class="value"><select id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" ' . $element->serialize($element->getHtmlAttributes()) . '>' . "\n"; foreach ($regionCollection as $region) { $selected = $regionId == $region->getId() ? ' selected' : ''; $html .= '<option value="' . $region->getId() . '"' . $selected . '>' . $region->getName() . '</option>'; } $html .= '</select></td>'; $element->setClass($elementClass); } else { $element->setClass('input-text'); $html .= '<td class="label"><label for="' . $element->getHtmlId() . '">' . $element->getLabel() . ' <span class="required" style="display:none">*</span></label></td>'; $element->setRequired(false); $html .= '<td class="value"><input id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" value="' . $element->getEscapedValue() . '"' . $element->serialize($element->getHtmlAttributes()) . '/></td>' . "\n"; } $html .= '</tr>' . "\n"; return $html; }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $html = ""; $html .= '<a id="' . $element->getHtmlId() . '" ' . $element->serialize($element->getHtmlAttributes()) . '>' . $element->getEscapedValue() . "</a>\n"; $html .= $element->getAfterElementHtml(); return $html; }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { if ($element->getScope() == "stores") { return $element->getEscapedValue(); } else { return Mage::helper("klevu_search")->__("Switch to store scope to set"); } }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $html = ""; $html .= "<input class=' input-text' type='hidden' id='" . $element->getHtmlId() . "' name='" . $element->getName() . "' value='" . $element->getEscapedValue() . "' '" . $element->serialize($element->getHtmlAttributes()) . "/>"; $html .= "\n<script>\n document.observe('dom:loaded', function(){\n \n if(!\$('" . $element->getHtmlId() . "').value.isJSON())\$('" . $element->getHtmlId() . "').value='{\"days\":[],\"hours\":[]}';\n cron=\$('" . $element->getHtmlId() . "').value.evalJSON();\n \n \n cron.days.each(function(d){\n if(\$('d-'+d)){\n \$('d-'+d).checked=true;\n \$('d-'+d).ancestors()[0].addClassName('checked');\n }\n \n })\n cron.hours.each(function(h){\n if( \$('h-'+h.replace(':',''))){\n \$('h-'+h.replace(':','')).checked=true;\n \$('h-'+h.replace(':','')).ancestors()[0].addClassName('checked');\n }\n })\n \n \$\$('.cron-box').each(function(e){\n e.observe('click',function(){\n \n if(e.checked)e.ancestors()[0].addClassName('checked');\n else e.ancestors()[0].removeClassName('checked');\n \n d=new Array\n \$\$('.cron-d-box INPUT').each(function(e){\n if(e.checked) d.push(e.value)\n })\n h=new Array;\n \$\$('.cron-h-box INPUT').each(function(e){\n if(e.checked) h.push(e.value)\n })\n \n \$('" . $element->getHtmlId() . "').value=Object.toJSON({days:d,hours:h})\n \n }) \n })\n })\n \n</script>\n"; $html .= "\n<style>\n .morning .cron-h-box{\n border: 1px solid #AFAFAF;\n border-radius: 3px 3px 3px 3px;\n margin: 2px;\n padding: 0 3px;\n background:#efefef;\n }\n .afternoon .cron-h-box{\n border: 1px solid #AFAFAF;\n border-radius: 3px 3px 3px 3px;\n margin: 2px;\n padding: 0 3px;\n background:#efefef;\n }\n .morning-half .cron-h-box{\n border: 1px solid #AFAFAF;\n border-radius: 3px 3px 3px 3px;\n margin: 2px;\n padding: 0 3px;\n background:#efefef;\n }\n .afternoon-half .cron-h-box{\n\n border: 1px solid #AFAFAF;\n border-radius: 3px 3px 3px 3px;\n margin: 2px;\n padding: 0 3px;\n background:#efefef;\n }\n\n .cron-d-box{\n\n background:#efefef;\n border: 1px solid #AFAFAF;\n border-radius: 3px 3px 3px 3px;\n margin: 2px;\n padding: 0 3px;\n }\n .checked{\n background-color: #EFFFF0!important;\n }\n</style>"; $html .= "<table style='width:600px !important'>\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'>\n <div class='cron-d-box'><input class='cron-box' value='Monday' id='d-Monday' type='checkbox'/> Monday</div>\n <div class='cron-d-box'><input class='cron-box' value='Tuesday' id='d-Tuesday' type='checkbox'/> Tuesday</div>\n <div class='cron-d-box'><input class='cron-box' value='Wednesday' id='d-Wednesday' type='checkbox'/> Wednesday</div>\n <div class='cron-d-box'><input class='cron-box' value='Thursday' id='d-Thursday' type='checkbox'/> Thursday</div>\n <div class='cron-d-box'><input class='cron-box' value='Friday' id='d-Friday' type='checkbox'/> Friday</div>\n <div class='cron-d-box'><input class='cron-box' value='Saturday' id='d-Saturday' type='checkbox'/> Saturday</div>\n <div class='cron-d-box'><input class='cron-box' value='Sunday' id='d-Sunday' type='checkbox'/> Sunday</div>\n </td>\n <td></td>\n <td width='150' class='morning-half'>\n <div class='cron-h-box'><input class='cron-box' value='00:00' id='h-0000' type='checkbox'/> 00:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='01:00' id='h-0100' type='checkbox'/> 01:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='02:00' id='h-0200' type='checkbox'/> 02:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='03:00' id='h-0300' type='checkbox'/> 03:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='04:00' id='h-0400' type='checkbox'/> 04:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='05:00' id='h-0500' type='checkbox'/> 05:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='06:00' id='h-0600' type='checkbox'/> 06:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='07:00' id='h-0700' type='checkbox'/> 07:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='08:00' id='h-0800' type='checkbox'/> 08:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='09:00' id='h-0900' type='checkbox'/> 09:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='10:00' id='h-1000' type='checkbox'/> 10:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='11:00' id='h-1100' type='checkbox'/> 11:00 AM</div>\n\n </td>\n <td width='150' class='morning'>\n <div class='cron-h-box'><input class='cron-box' value='00:30' id='h-0030' type='checkbox'/> 00:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='01:30' id='h-0130' type='checkbox'/> 01:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='02:30' id='h-0230' type='checkbox'/> 02:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='03:30' id='h-0330' type='checkbox'/> 03:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='04:30' id='h-0430' type='checkbox'/> 04:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='05:30' id='h-0530' type='checkbox'/> 05:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='06:30' id='h-0630' type='checkbox'/> 06:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='07:30' id='h-0730' type='checkbox'/> 07:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='08:30' id='h-0830' type='checkbox'/> 08:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='09:30' id='h-0930' type='checkbox'/> 09:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='10:30' id='h-1030' type='checkbox'/> 10:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='11:30' id='h-1130' type='checkbox'/> 11:30 AM</div>\n\n\n\n\n </td>\n <td width='150' class='afternoon-half'>\n <div class='cron-h-box'><input class='cron-box' value='12:00' id='h-1200' type='checkbox'/> 12:00 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='13:00' id='h-1300' type='checkbox'/> 01:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='14:00' id='h-1400' type='checkbox'/> 02:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='15:00' id='h-1500' type='checkbox'/> 03:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='16:00' id='h-1600' type='checkbox'/> 04:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='17:00' id='h-1700' type='checkbox'/> 05:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='18:00' id='h-1800' type='checkbox'/> 06:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='19:00' id='h-1900' type='checkbox'/> 07:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='20:00' id='h-2000' type='checkbox'/> 08:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='21:00' id='h-2100' type='checkbox'/> 09:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='22:00' id='h-2200' type='checkbox'/> 10:00 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='23:00' id='h-2300' type='checkbox'/> 11:00 PM</div>\n\n </td>\n <td width='150' class='afternoon'>\n <div class='cron-h-box'><input class='cron-box' value='12:30' id='h-1230' type='checkbox'/> 12:30 AM</div>\n <div class='cron-h-box'><input class='cron-box' value='13:30' id='h-1330' type='checkbox'/> 01:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='14:30' id='h-1430' type='checkbox'/> 02:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='15:30' id='h-1530' type='checkbox'/> 03:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='16:30' id='h-1630' type='checkbox'/> 04:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='17:30' id='h-1730' type='checkbox'/> 05:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='18:30' id='h-1830' type='checkbox'/> 06:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='19:30' id='h-1930' type='checkbox'/> 07:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='20:30' id='h-2030' type='checkbox'/> 08:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='21:30' id='h-2130' type='checkbox'/> 09:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='22:30' id='h-2230' type='checkbox'/> 10:30 PM</div>\n <div class='cron-h-box'><input class='cron-box' value='23:30' id='h-2330' type='checkbox'/> 11:30 PM</div>\n\n\n </td>\n </tr>\n </table>"; $html .= $element->getAfterElementHtml(); return $html; }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $element->addClass('link'); $id = $element->getHtmlId(); // If there's an inherited checkbox; hide it. This is a read-only property, and the checkbox is superfluous $inheritedCheckbox = $id . '_inherit'; $hideCheckboxJs = 'if ($("' . $inheritedCheckbox . '") != undefined ){$("' . $inheritedCheckbox . '").hide();}'; $html = sprintf('<a id="%s" name="%s" onClick="return false;" href="#">%s</a>', $id, $element->getName(), $element->getEscapedValue()); $html .= Mage::helper('core/js')->getScript('document.observe("dom:loaded", function() {' . $hideCheckboxJs . '});'); return $html; }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $elementId = $element->getHtmlId(); /* read configurations from system.xml */ $configarray = $element->getData('field_config')->asArray(); $min = $configarray['parameters']['min']; $max = $configarray['parameters']['max']; $step = $configarray['parameters']['step']; $label = $configarray['parameters']['label']; $skin = $configarray['parameters']['skin']; /* default values when theres no definition in system.xml */ if ($min == '') { $min = '0'; } if ($max == '') { $max = '10'; } if ($step == '') { $step = '1'; } if ($min >= $max) { $min = '0'; $max = '10'; $step = '1'; } if ($label == '') { $label = 'Unit / Maßeinheit'; } //wrong or no entering of a skin switch ($skin) { case 'blue': case 'plastic': case 'round': case 'round_plastic': break; default: $skin = 'plastic'; } //normal Inputfield, wolud hidden by the Slider JS $html = '<input id="' . $elementId . '" name="' . $element->getName() . '" value="' . $element->getEscapedValue() . '" ' . $element->serialize($element->getHtmlAttributes()) . '/>' . "\n"; //additional JS with configurations from system.xml $html .= '<script type="text/javascript" charset="utf-8"> if(typeof jQuery == "function") {//jQuery is a function when the jQuery library was loaded jQuery.noConflict();//get no conflicts with prototype in magento if(typeof jQuery("#' . $elementId . '").slider == "function") {//jQuery.slider is a function when the jQuerySlider library was loaded jQuery("#' . $elementId . '").slider({ from: ' . $min . ', to: ' . $max . ', step: ' . $step . ', dimension: \' ' . $label . '\', skin: "' . $skin . '" }); } } </script>'; $html .= $element->getAfterElementHtml(); return $html; }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { if ($element->getScope() == "stores") { return $element->getEscapedValue(); } else { $status = Mage::getModel("klevu_search/product_sync")->getKlevuCronStatus(); if (!empty($status)) { $html = Mage::getModel("klevu_search/product_sync")->getKlevuCronStatus(); } else { $html = Mage::helper("klevu_search")->__("Never Run"); } return $html; } }
public function render(Varien_Data_Form_Element_Abstract $element) { $html = '<tr>' . "\n"; $countryId = false; if ($country = $element->getForm()->getElement('country_id')) { $countryId = $country->getValue(); } $regionCollection = false; if ($countryId) { if (!isset(self::$_regionCollections[$countryId])) { self::$_regionCollections[$countryId] = Mage::getModel('directory/country')->setId($countryId)->getLoadedRegionCollection()->toOptionArray(); } $regionCollection = self::$_regionCollections[$countryId]; } $regionId = $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 ($regionCollection && count($regionCollection) > 0) { $elementClass = $element->getClass(); $html .= '<td class="label">' . $element->getLabelHtml() . '</td>'; $html .= '<td class="value">'; $html .= '<select id="' . $regionIdHtmlId . '" name="' . $regionIdHtmlName . '" ' . $element->serialize($htmlAttributes) . '>' . "\n"; foreach ($regionCollection as $region) { $selected = $regionId == $region['value'] ? ' selected="selected"' : ''; $html .= '<option value="' . $region['value'] . '"' . $selected . '>' . $region['label'] . '</option>'; } $html .= '</select>' . "\n"; $html .= '<input type="hidden" name="' . $regionHtmlName . '" id="' . $regionHtmlId . '" value=""/>'; $html .= '</td>'; $element->setClass($elementClass); } else { $element->setClass('input-text'); $html .= '<td class="label"><label for="' . $element->getHtmlId() . '">' . $element->getLabel() . ' <span class="required" style="display:none">*</span></label></td>'; $element->setRequired(false); $html .= '<td class="value">'; $html .= '<input id="' . $regionHtmlId . '" name="' . $regionHtmlName . '" value="' . $element->getEscapedValue() . '" ' . $element->serialize($htmlAttributes) . "/>" . "\n"; $html .= '<input type="hidden" name="' . $regionIdHtmlName . '" id="' . $regionIdHtmlId . '" value=""/>'; $html .= '</td>' . "\n"; } $html .= '</tr>' . "\n"; return $html; }
/** * Return escaped value * * @param int $index * @return string */ public function getEscapedValue($index = null) { if (is_array($this->getValue())) { return false; } $value = $this->getValue(); if (is_array($value) && is_null($index)) { $index = 'value'; } return parent::getEscapedValue($index); }
/** * Get the feed URL contents which include information about the last time a feed was generate, lock file information and scripts contents * @param Varien_Data_Form_Element_Abstract $element * @return string */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { $element->addClass('link'); $lock = Mage::getModel('eems_display/file_lock'); $this->addData(array('name' => $element->getName(), 'escaped_value' => $element->getEscapedValue(), 'is_lock_file_exist' => $lock->isLockFileExist(), 'lock_file_exist_text' => $this->_helper->__($lock->getLockFileExistText()), 'fail_to_remove_lock_file_text' => $this->_helper->__($lock->getFailRemoveLockFileText()), 'escaped_button_label' => $this->_helper->__($this->escapeHtml($lock->getRemoveLockButonText())), 'html_id' => $element->getHtmlId(), 'ajax_url' => $this->getUrl(static::REMOVE_LOCK_FILE_CONTROLLER, array('_current' => true)))); return $this->_toHtml(); }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { return sprintf('<div id="%s" class="box">%s</div>', $element->getHtmlId(), $element->getEscapedValue()); }