本文整理汇总了PHP中Varien_Data_Form_Element_Abstract::getReadonly方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Abstract::getReadonly方法的具体用法?PHP Varien_Data_Form_Element_Abstract::getReadonly怎么用?PHP Varien_Data_Form_Element_Abstract::getReadonly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form_Element_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Element_Abstract::getReadonly方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render Media Chooser HTML (buttons and image preview) and set it after the form element HTML
*
* @param Varien_Data_Form_Element_Abstract $element
*
* @return Varien_Data_Form_Element_Abstract
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
if (Mage::getSingleton('admin/session')->isAllowed('cms/media_gallery')) {
$layout = Mage::app()->getLayout();
$id = $element->getHtmlId();
if ($url = $element->getValue()) {
$linkStyle = "display:inline;";
if (!preg_match("/^http\\:\\/\\/|https\\:\\/\\//", $url)) {
$url = Mage::getBaseUrl('media') . $url;
}
} else {
$linkStyle = "display:none;";
$url = "#";
}
$imagePreview = '<a id="' . $id . '_link" href="' . $url . '" style="text-decoration: none; ' . $linkStyle . '"' . ' onclick="imagePreview(\'' . $id . '_image\'); return false;">' . ' <img src="' . $url . '" id="' . $id . '_image" title="' . $element->getValue() . '"' . ' alt="' . $element->getValue() . '" height="30" class="small-image-preview v-middle"/>' . ' </a>';
$selectButtonId = 'add-image-' . mt_rand();
$chooserUrl = Mage::getUrl('adminhtml/cms_wysiwyg_images_chooser/index', array('target_element_id' => $id));
$label = $element->getValue() ? $this->__('Change Image') : $this->__('Select Image');
// Select/Change Image Button
$chooseButton = $layout->createBlock('adminhtml/widget_button')->setType('button')->setClass('add-image')->setId($selectButtonId)->setLabel($label)->setOnclick('MediabrowserUtility.openDialog(\'' . $chooserUrl . '\')')->setDisabled($element->getReadonly())->setStyle('display:inline;margin-top:7px');
// Remove Image Button
$onclickJs = '
document.getElementById(\'' . $id . '\').value=\'\';
if(document.getElementById(\'' . $id . '_image\')){
document.getElementById(\'' . $id . '_image\').parentNode.style.display = \'none\';
}
document.getElementById(\'' . $selectButtonId . '\').innerHTML=\'<span><span><span>' . addslashes($this->__('Select Image')) . '</span></span></span>\';
';
$removeButton = $layout->createBlock('adminhtml/widget_button')->setType('button')->setClass('delete')->setLabel($this->__('Remove Image'))->setOnclick($onclickJs)->setDisabled($element->getReadonly())->setStyle('margin-top:7px');
$wrapperStart = '<div id="buttons_' . $id . '" class="buttons-set" style=" width: 325px;">';
$wrapperEnd = '</div>';
$wrapperEnd .= '
<script type="text/javascript">
//<![CDATA[
varienGlobalEvents.clearEventHandlers(\'mediachooserChange' . $id . '\');
varienGlobalEvents.attachEventHandler(\'mediachooserChange' . $id . '\', function(url){
document.getElementById(\'' . $id . '_image\').src = \'' . Mage::getBaseUrl('media') . '\' + url;
document.getElementById(\'' . $id . '_image\').title = url;
document.getElementById(\'' . $id . '_image\').alt = url;
document.getElementById(\'' . $id . '_link\').href = \'' . Mage::getBaseUrl('media') . '\' + url;
document.getElementById(\'' . $id . '_link\').style.display = \'inline\';
document.getElementById(\'' . $selectButtonId . '\').innerHTML=\'<span><span><span>' . addslashes($this->__('Change Image')) . '</span></span></span>\';
});
//]]>
</script>
';
// Add our custom HTML after the form element
$element->setAfterElementHtml($wrapperStart . $imagePreview . $chooseButton->toHtml() . $removeButton->toHtml() . $wrapperEnd);
}
return $element;
}
示例2: _getExtraJs
/**
* Return js code for fieldset:
* - observe fieldset rows;
* - apply collapse;
*
* @param Varien_Data_Form_Element_Abstract $element
* @param bool $tooltipsExist Init tooltips observer or not
* @return string
*/
protected function _getExtraJs($element, $tooltipsExist = false)
{
$id = $element->getHtmlId();
$js = "Fieldset.applyCollapse('{$id}');";
/* To support Sales Rules Conditionnal */
$js .= "var {$element->getHtmlId()} = new VarienRulesForm('{$element->getHtmlId()}', '{$this->getUrl('*/promo_quote/newConditionHtml/form/rule_conditions_fieldset')}');";
if ($element->getReadonly()) {
$js .= "{$element->getHtmlId()}.setReadonly(true);";
}
return Mage::helper('adminhtml/js')->getScript($js);
}
示例3: render
/**
* 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();
}
示例4: renderMediaChooser
public function renderMediaChooser(Varien_Data_Form_Element_Abstract $element)
{
if (Mage::getSingleton('admin/session')->isAllowed('cms/media_gallery')) {
$layout = $element->getForm()->getParent()->getLayout();
$id = $element->getHtmlId();
if ($url = $element->getValue()) {
$linkStyle = "display:inline;";
if (!preg_match("/^http\\:\\/\\/|https\\:\\/\\//", $url)) {
$url = Mage::getBaseUrl('media') . $url;
}
} else {
$linkStyle = "display:none;";
$url = "#";
}
$hiddenField = '<input type="hidden" name="hidden_file" id="hidden_file_' . $id . '" class="hidden-file-path" value=""/>';
$imagePreview = '<a id="' . $id . '_link" class="image-preview-link" href="' . $url . '" style="text-decoration: none; ' . $linkStyle . '"' . ' onclick="imagePreview(\'' . $id . '_image\'); return false;">' . ' <img src="' . $url . '" id="' . $id . '_image" title="' . $element->getValue() . '"' . ' alt="' . $element->getValue() . '" height="30" class="small-image-preview v-middle"/>' . ' </a>';
$selectButtonId = 'add-image-' . mt_rand();
$chooserUrl = Mage::getUrl('adminhtml/cms_wysiwyg_images_chooser/index', array('target_element_id' => $id));
$label = $element->getValue() ? $this->__('Change Image') : $this->__('Select Image');
// Select/Change Image Button
$chooseButton = $layout->createBlock('adminhtml/widget_button')->setType('button')->setClass('add-image')->setId($selectButtonId)->setLabel($label)->setOnclick('openEfinder(this, \'hidden_file_' . $id . '\', \'#' . $id . '\', changeElFieldImage)')->setDisabled($element->getReadonly())->setStyle('display:inline;margin-top:7px');
// Remove Image Button
$onclickJs = '
document.getElementById(\'' . $id . '\').value=\'\';
document.getElementById(\'hidden_file_' . $id . '\').value=\'\';
if(document.getElementById(\'' . $id . '_image\')){
document.getElementById(\'' . $id . '_image\').parentNode.style.display = \'none\';
}
document.getElementById(\'' . $selectButtonId . '\').innerHTML=\'<span><span><span>' . addslashes($this->__('Select Image')) . '</span></span></span>\';
';
$removeButton = $layout->createBlock('adminhtml/widget_button')->setType('button')->setClass('delete')->setLabel($this->__('Remove Image'))->setOnclick($onclickJs)->setDisabled($element->getReadonly())->setStyle('margin-top:7px');
$wrapperStart = '<div id="buttons_' . $id . '" class="buttons-set" style=" width: 325px;">';
$wrapperEnd = '</div>';
// Add our custom HTML after the form element
$element->setAfterElementHtml($wrapperStart . $hiddenField . $imagePreview . $chooseButton->toHtml() . $removeButton->toHtml() . $wrapperEnd);
}
return $element;
}
示例5: prepareElementHtml
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;
}