/** * Set onClick data for button display. * * @param string $widget Id of the widget * @param string $controllerAction Controller action * @param array $urlParams URL params * @param string $confirmMessage Confirmation message * * @return string */ public function setOnClick($widget, $controllerAction, $urlParams = null, $confirmMessage = null) { $onClick = ''; // check if this is an ajax call with callback $cbMarker = Hackathon_MageMonitoring_Model_Widget_Abstract::CALLBACK; if (!strncmp($controllerAction, $cbMarker, strlen($cbMarker))) { $callback = substr($controllerAction, strlen($cbMarker)); $widgetId = $widget->getConfigId(); $tabId = $widget->getTabId(); $widgetName = $widget->getName(); $callbackUrl = Mage::helper('magemonitoring')->getWidgetUrl('*/mageMonitoring_widgetAjax/execCallback', $widget); $refreshUrl = 'null'; // check if refresh flag is set if (isset($urlParams['refreshAfter']) && $urlParams['refreshAfter']) { $refreshUrl = '\'' . Mage::helper('magemonitoring')->getWidgetUrl('*/widgetAjax/refreshWidget', $widget) . '\''; } // add callback js $onClick .= "execWidgetCallback('{$tabId}-{$widgetId}', '{$widgetName}', '{$callback}'," . "'{$callbackUrl}', {$refreshUrl});"; // add confirm dialog? if ($confirmMessage) { $onClick = "var r=confirm('{$confirmMessage}'); if (r==true) {" . $onClick . "}"; } return parent::setOnClick($onClick); } $url = Mage::getSingleton('adminhtml/url')->getUrl($controllerAction, $urlParams); if ($confirmMessage) { $onClick = "confirmSetLocation('{$confirmMessage}','{$url}')"; } else { $onClick = "setLocation('{$url}')"; } return parent::setOnClick($onClick); }
protected function _prepareLayout() { parent::_prepareLayout(); /* @var $layoutHelper Mana_Core_Helper_Layout */ $layoutHelper = Mage::helper('mana_core/layout'); $layoutHelper->delayPrepareLayout($this); return $this; }
/** * @return Mage_Adminhtml_Block_Widget_Button */ protected function _getRemoveButton() { /** @var Mage_Adminhtml_Block_Widget_Button $removeButton */ $removeButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setClass('delete')->setLabel($this->__('Remove Image'))->setOnclick('document.getElementById(\'' . $this->_fieldInput->getHtmlId() . '\').value=\'\';if(document.getElementById(\'' . $this->_fieldInput->getHtmlId() . self::IMAGE_PREVIEW_SUFFIX . '\'))$(\'' . $this->_fieldInput->getHtmlId() . self::IMAGE_PREVIEW_SUFFIX . '\').parentNode.addClassName(\'no-display\');$(\'' . $this->_imageChooserButton->getHtmlId() . '\').writeAttribute(\'disabled\', false);$(\'' . $this->_imageChooserButton->getHtmlId() . '\').removeClassName(\'disabled\');$(this).addClassName(\'disabled\');$(this).writeAttribute(\'disabled\', true)')->setDisabled($this->_fieldInput->getReadonly())->setStyle('margin-left:10px;margin-top:7px'); // Check if there is a value. If no value then we want the remove button to be disabled if (!$this->_fieldInput->getValue()) { $removeButton->setDisabled(true); } return $removeButton; }
protected function _toHtml() { $this->setCanShow(true); Mage::dispatchEvent('adminhtml_catalog_product_edit_tab_attributes_create_html_before', array('block' => $this)); if (!$this->getCanShow()) { return ''; } $html = parent::_toHtml(); $html .= Mage::helper('adminhtml/js')->getScript("var {$this->getJsObjectName()} = new Product.Attributes('{$this->getId()}');\n" . "{$this->getJsObjectName()}.setConfig(" . Mage::helper('core')->jsonEncode($this->getConfig()->getData()) . ");\n"); return $html; }
/** * Apply Additional Attributes to the Button * * @return string */ protected function _toHtml() { $cacheKey = $this->getCacheKey(); if ($html = $this->_commonHelper()->getCache()->getPreparedHtml($cacheKey)) { return $html; } else { $html = parent::_toHtml(); $injectAttributes = array(); if ($additionalAttributes = $this->getAdditionalAttributes()) { $attributesStr = explode(" ", $additionalAttributes); foreach ($attributesStr as $attributeStr) { if ($attributeStr) { try { $key = false; $value = false; list($key, $value) = explode("=", $attributeStr); if ($key && $value) { $value = trim($value, "\"'"); $injectAttributes[$key] = $value; } } catch (Exception $e) { $this->_commonHelper()->getException()->logException($e); } } } } foreach ($this->_getAngularKeys() as $key) { if ($this->hasData($key)) { $injectAttributes[$key] = $this->getData($key); } } if (count($injectAttributes)) { $dom = $this->_commonHelper()->getSimpleDOM()->str_get_dom($html); foreach ($dom->find("button") as $button) { foreach ($injectAttributes as $key => $value) { $button->setAttribute($key, $value); } } $html = $dom->__toString(); } $this->_commonHelper()->getCache()->savePreparedHtml($cacheKey, $html); return $html; } }
protected function _toHtml() { $html = parent::_toHtml(); $html .= Mage::helper('adminhtml/js')->getScript("var {$this->getJsObjectName()} = new Product.Attributes('{$this->getId()}');\n" . "{$this->getJsObjectName()}.setConfig(" . Zend_Json::encode($this->getConfig()->getData()) . ");\n"); return $html; }