本文整理汇总了PHP中Varien_Data_Form_Element_Abstract::getCanUseDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Abstract::getCanUseDefaultValue方法的具体用法?PHP Varien_Data_Form_Element_Abstract::getCanUseDefaultValue怎么用?PHP Varien_Data_Form_Element_Abstract::getCanUseDefaultValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form_Element_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Element_Abstract::getCanUseDefaultValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Enter description here...
*
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
$html = '<tr><td class="label">' . $element->getLabel() . '</td>';
$id = $element->getHtmlId();
//$isDefault = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
$isMultiple = $element->getExtType() === 'multiple';
// replace [value] with [inherit]
$namePrefix = preg_replace('#\\[value\\](\\[\\])?$#', '', $element->getName());
$options = $element->getValues();
$addInheritCheckbox = false;
if ($element->getCanUseWebsiteValue()) {
$addInheritCheckbox = true;
$checkboxLabel = Mage::helper('adminhtml')->__('Use website');
} elseif ($element->getCanUseDefaultValue()) {
$addInheritCheckbox = true;
$checkboxLabel = Mage::helper('adminhtml')->__('Use default');
}
if ($addInheritCheckbox) {
$inherit = $element->getInherit() == 1 ? 'checked' : '';
if ($inherit) {
$element->setDisabled(true);
}
}
$html .= '<td class="value">';
$html .= $this->_getElementHtml($element);
if ($element->getComment()) {
$html .= '<div><small>' . $element->getComment() . '</small></div>';
}
$html .= '</td>';
if ($addInheritCheckbox) {
$defText = $element->getDefaultValue();
if ($options) {
$defTextArr = array();
foreach ($options as $k => $v) {
if ($isMultiple) {
if (is_array($v['value']) && in_array($k, $v['value'])) {
$defTextArr[] = $v['label'];
}
} elseif ($v['value'] == $defText) {
$defTextArr[] = $v['label'];
break;
}
}
$defText = join(', ', $defTextArr);
}
// default value
$html .= '<td class="default">';
//$html.= '<input id="'.$id.'_inherit" name="'.$namePrefix.'[inherit]" type="checkbox" value="1" class="input-checkbox config-inherit" '.$inherit.' onclick="$(\''.$id.'\').disabled = this.checked">';
$html .= '<input id="' . $id . '_inherit" name="' . $namePrefix . '[inherit]" type="checkbox" value="1" class="input-checkbox config-inherit" ' . $inherit . ' onclick="toggleValueElements(this, Element.previous(this.parentNode))"/>';
$html .= '<label for="' . $id . '_inherit" class="inherit" title="' . htmlspecialchars($defText) . '">' . $checkboxLabel . '</label>';
$html .= '<input type="hidden" name="' . $namePrefix . '[default_value]" value="' . htmlspecialchars($element->getDefaultValue()) . '">';
$html .= '<input type="hidden" name="' . $namePrefix . '[old_value]" value="' . htmlspecialchars($element->getOldValue()) . '">';
$html .= '</td>';
}
$html .= '</tr>';
return $html;
}
示例2: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$elementId = $element->getHtmlId();
$optionShoppingCartId = str_replace('/', '_', Mage_Persistent_Helper_Data::XML_PATH_PERSIST_SHOPPING_CART);
$optionEnabled = str_replace('/', '_', Mage_Persistent_Helper_Data::XML_PATH_ENABLED);
$addInheritCheckbox = false;
if ($element->getCanUseWebsiteValue()) {
$addInheritCheckbox = true;
} elseif ($element->getCanUseDefaultValue()) {
$addInheritCheckbox = true;
}
$html = '<script type="text/javascript">
PersistentCustomerSegmentation = Class.create();
PersistentCustomerSegmentation.prototype = {
initialize : function () {
this._element = $("' . $elementId . '");
var funcTrackOnChangeShoppingCart = this.trackOnChangeShoppingCart.bind(this);
document.observe("dom:loaded", funcTrackOnChangeShoppingCart);
$("' . $optionShoppingCartId . '").observe("change", funcTrackOnChangeShoppingCart);
$("' . $optionEnabled . '").observe("change", function() {
setTimeout(funcTrackOnChangeShoppingCart, 1);
});' . ($addInheritCheckbox ? '$("' . $elementId . '_inherit").observe("change", funcTrackOnChangeShoppingCart);' : '') . '},
disable: function() {
this._element.disabled = true;
this._element.value = 1;
},
enable: function() {
this._element.disabled = false;
},
trackOnChangeShoppingCart: function() {
if ($("' . $optionEnabled . '").value == 1 && $("' . $optionShoppingCartId . '").value == 1 ) {
this.disable();
} else {
' . ($addInheritCheckbox ? 'if ($("' . $elementId . '_inherit").checked) {
this.disable();
} else {
this.enable();
}' : 'this.enable();') . '
}
}
};
var persistentCustomerSegmentation = new PersistentCustomerSegmentation();
</script>';
return parent::render($element) . $html;
}
示例3: render
/**
* Render country field considering request parameter
*
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
$country = $this->getRequest()->getParam(self::REQUEST_PARAM_COUNTRY);
if ($country) {
$element->setValue($country);
}
if ($element->getCanUseDefaultValue()) {
$defaultConfigNode = Mage::getConfig()->getNode(null, 'default');
if ($defaultConfigNode) {
$this->_defaultCountry = (string) $defaultConfigNode->descend('paypal/general/merchant_country');
}
if (!$this->_defaultCountry) {
$this->_defaultCountry = Mage::helper('core')->getDefaultCountry();
}
if ($country) {
$shouldInherit = $country == $this->_defaultCountry && $this->getRequest()->getParam(self::REQUEST_PARAM_DEFAULT);
$element->setInherit($shouldInherit);
}
if ($element->getInherit()) {
$this->_defaultCountry = null;
}
}
return parent::render($element);
}
示例4: hasInheritElement
/**
* Check whether checkbox has "Use default" option or not
*
* @param Varien_Data_Form_Element_Abstract $element
* @return bool
*/
public function hasInheritElement(Varien_Data_Form_Element_Abstract $element)
{
return (bool) $element->getCanUseDefaultValue();
}
示例5: render
/**
* Overloaded for forwards compatibility for Magento 1.6.
*
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
$id = $element->getHtmlId();
$html = '<td class="label"><label for="' . $id . '">' . $element->getLabel() . '</label></td>';
//$isDefault = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
$isMultiple = $element->getExtType() === 'multiple';
// replace [value] with [inherit]
$namePrefix = preg_replace('#\\[value\\](\\[\\])?$#', '', $element->getName());
$options = $element->getValues();
$addInheritCheckbox = false;
if ($element->getCanUseWebsiteValue()) {
$addInheritCheckbox = true;
$checkboxLabel = $this->__('Use Website');
} elseif ($element->getCanUseDefaultValue()) {
$addInheritCheckbox = true;
$checkboxLabel = $this->__('Use Default');
}
if ($addInheritCheckbox) {
$inherit = $element->getInherit() == 1 ? 'checked="checked"' : '';
if ($inherit) {
$element->setDisabled(true);
}
}
if ($element->getTooltip()) {
$html .= '<td class="value with-tooltip">';
$html .= $this->_getElementHtml($element);
$html .= '<div class="field-tooltip"><div>' . $element->getTooltip() . '</div></div>';
} else {
$html .= '<td class="value">';
$html .= $this->_getElementHtml($element);
}
if ($element->getComment()) {
$html .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
}
$html .= '</td>';
if ($addInheritCheckbox) {
$defText = $element->getDefaultValue();
if ($options) {
$defTextArr = array();
foreach ($options as $k => $v) {
if ($isMultiple) {
if (is_array($v['value']) && in_array($k, $v['value'])) {
$defTextArr[] = $v['label'];
}
} elseif (isset($v['value'])) {
if ($v['value'] == $defText) {
$defTextArr[] = $v['label'];
break;
}
} elseif (!is_array($v)) {
if ($k == $defText) {
$defTextArr[] = $v;
break;
}
}
}
$defText = join(', ', $defTextArr);
}
// default value
$html .= '<td class="use-default">';
$html .= '<input id="' . $id . '_inherit" name="' . $namePrefix . '[inherit]" type="checkbox" value="1" class="checkbox config-inherit" ' . $inherit . ' onclick="toggleValueElements(this, Element.previous(this.parentNode))" /> ';
$html .= '<label for="' . $id . '_inherit" class="inherit" title="' . htmlspecialchars($defText) . '">' . $checkboxLabel . '</label>';
$html .= '</td>';
}
$html .= '<td class="scope-label">';
if ($element->getScope()) {
$html .= $element->getScopeLabel();
}
$html .= '</td>';
$html .= '<td class="">';
if ($element->getHint()) {
$html .= '<div class="hint" >';
$html .= '<div style="display: none;">' . $element->getHint() . '</div>';
$html .= '</div>';
}
$html .= '</td>';
return $this->_decorateRowHtml($element, $html);
}
示例6: render
/**
* Enter description here...
*
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
if (version_compare(Mage::getVersion(), '1.7.0.1', '<')) {
if (Mage::app()->getRequest()->getParam('section') == "klevu_search") {
$id = $element->getHtmlId();
$features = Mage::helper('klevu_search/config')->getFeaturesUpdate($element->getHtmlId());
if (!empty($features)) {
$style = 'class="klevu-disabled"';
$upgrade_text = '';
if (!empty($features['upgrade_message']) || !empty($features['upgrade_label'])) {
$upgrade_text .= "<div class='klevu-upgrade-block'>";
if (!empty($features['upgrade_message'])) {
$upgrade_text .= $features['upgrade_message'];
}
if (!empty($features['upgrade_label'])) {
$upgrade_text .= "<br/><button type='button' onClick=upgradeLink('" . $features["upgrade_url"] . "')>" . $features['upgrade_label'] . "</button>";
}
$upgrade_text .= "</div>";
}
} else {
$style = '';
$upgrade_text = '';
}
$useContainerId = $element->getData('use_container_id');
$html = '<tr id="row_' . $id . '">' . '<td class="label"><label for="' . $id . '" ' . $style . '>' . $element->getLabel() . '</label>' . $upgrade_text . '</td>';
// $isDefault = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
$isMultiple = $element->getExtType() === 'multiple';
// replace [value] with [inherit]
$namePrefix = preg_replace('#\\[value\\](\\[\\])?$#', '', $element->getName());
$options = $element->getValues();
$addInheritCheckbox = false;
if ($element->getCanUseWebsiteValue()) {
$addInheritCheckbox = true;
$checkboxLabel = Mage::helper('adminhtml')->__('Use Website');
} elseif ($element->getCanUseDefaultValue()) {
$addInheritCheckbox = true;
$checkboxLabel = Mage::helper('adminhtml')->__('Use Default');
}
if ($addInheritCheckbox) {
$inherit = $element->getInherit() == 1 ? 'checked="checked"' : '';
if ($inherit) {
$element->setDisabled(true);
}
}
// Code added by klevu
if (!empty($features)) {
$element->setDisabled(true);
$element->setValue(0);
}
$html .= '<td class="value">';
$html .= $this->_getElementHtml($element);
if ($element->getComment()) {
$html .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
}
$html .= '</td>';
if ($addInheritCheckbox) {
$defText = $element->getDefaultValue();
if ($options) {
$defTextArr = array();
foreach ($options as $k => $v) {
if ($isMultiple) {
if (is_array($v['value']) && in_array($k, $v['value'])) {
$defTextArr[] = $v['label'];
}
} elseif ($v['value'] == $defText) {
$defTextArr[] = $v['label'];
break;
}
}
$defText = join(', ', $defTextArr);
}
// code added by klevu
if (!empty($features)) {
} else {
// default value
$html .= '<td class="use-default">';
// $html.= '<input id="'.$id.'_inherit" name="'.$namePrefix.'[inherit]" type="checkbox" value="1" class="input-checkbox config-inherit" '.$inherit.' onclick="$(\''.$id.'\').disabled = this.checked">';
$html .= '<input id="' . $id . '_inherit" name="' . $namePrefix . '[inherit]" type="checkbox" value="1" class="checkbox config-inherit" ' . $inherit . ' onclick="toggleValueElements(this, Element.previous(this.parentNode))" /> ';
$html .= '<label for="' . $id . '_inherit" class="inherit" title="' . htmlspecialchars($defText) . '">' . $checkboxLabel . '</label>';
$html .= '</td>';
}
}
$html .= '<td class="scope-label">';
if ($element->getScope()) {
$html .= $element->getScopeLabel();
}
$html .= '</td>';
// code added by klevu
if (!empty($features)) {
$element->setDisabled(true);
}
$html .= '<td class="">';
if ($element->getHint()) {
$html .= '<div class="hint" >';
//.........这里部分代码省略.........
示例7: _isInheritCheckboxRequired
/**
* Check if inheritance checkbox has to be rendered
*
* @param Varien_Data_Form_Element_Abstract $element
* @return bool
*/
protected function _isInheritCheckboxRequired(Varien_Data_Form_Element_Abstract $element)
{
return $element->getCanUseWebsiteValue() || $element->getCanUseDefaultValue();
}