1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Base widget class
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Block_Widget extends Mage_Adminhtml_Block_Template
35: {
36: public function getId()
37: {
38: if ($this->getData('id')===null) {
39: $this->setData('id', Mage::helper('core')->uniqHash('id_'));
40: }
41: return $this->getData('id');
42: }
43:
44: public function getHtmlId()
45: {
46: return $this->getId();
47: }
48:
49: /**
50: * Get current url
51: *
52: * @param array $params url parameters
53: * @return string current url
54: */
55: public function getCurrentUrl($params = array())
56: {
57: if (!isset($params['_current'])) {
58: $params['_current'] = true;
59: }
60: return $this->getUrl('*/*/*', $params);
61: }
62:
63: protected function _addBreadcrumb($label, $title=null, $link=null)
64: {
65: $this->getLayout()->getBlock('breadcrumbs')->addLink($label, $title, $link);
66: }
67:
68: /**
69: * Create buttonn and return its html
70: *
71: * @param string $label
72: * @param string $onclick
73: * @param string $class
74: * @param string $id
75: * @return string
76: */
77: public function getButtonHtml($label, $onclick, $class='', $id=null) {
78: return $this->getLayout()->createBlock('adminhtml/widget_button')
79: ->setData(array(
80: 'label' => $label,
81: 'onclick' => $onclick,
82: 'class' => $class,
83: 'type' => 'button',
84: 'id' => $id,
85: ))
86: ->toHtml();
87: }
88:
89: public function getGlobalIcon()
90: {
91: return '<img src="'.$this->getSkinUrl('images/fam_link.gif').'" alt="'.$this->__('Global Attribute').'" title="'.$this->__('This attribute shares the same value in all the stores').'" class="attribute-global"/>';
92: }
93: }
94:
95: