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: * Custom Variable Edit Container
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34:
35: class Mage_Adminhtml_Block_System_Variable_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
36: {
37: /**
38: * Internal constructor
39: *
40: */
41: protected function _construct()
42: {
43: parent::_construct();
44: $this->_objectId = 'variable_id';
45: $this->_controller = 'system_variable';
46: }
47:
48: /**
49: * Getter
50: *
51: * @return Mage_Core_Model_Variable
52: */
53: public function getVariable()
54: {
55: return Mage::registry('current_variable');
56: }
57:
58: /**
59: * Prepare layout.
60: * Adding save_and_continue button
61: *
62: * @return Mage_Adminhtml_Block_System_Variable_Edit
63: */
64: protected function _preparelayout()
65: {
66: $this->_addButton('save_and_edit', array(
67: 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
68: 'class' => 'save',
69: 'onclick' => 'editForm.submit(\'' . $this->getSaveAndContinueUrl() . '\');'
70: ), 100);
71: if (!$this->getVariable()->getId()) {
72: $this->removeButton('delete');
73: }
74: return parent::_prepareLayout();
75: }
76:
77: /**
78: * Return form HTML
79: *
80: * @return string
81: */
82: public function getFormHtml()
83: {
84: $formHtml = parent::getFormHtml();
85: if (!Mage::app()->isSingleStoreMode() && $this->getVariable()->getId()) {
86: $storeSwitcher = $this->getLayout()
87: ->createBlock('adminhtml/store_switcher')->toHtml();
88: $formHtml = $storeSwitcher.$formHtml;
89: }
90: return $formHtml;
91: }
92:
93: /**
94: * Return translated header text depending on creating/editing action
95: *
96: * @return string
97: */
98: public function getHeaderText()
99: {
100: if ($this->getVariable()->getId()) {
101: return Mage::helper('adminhtml')->__('Custom Variable "%s"', $this->htmlEscape($this->getVariable()->getName()));
102: }
103: else {
104: return Mage::helper('adminhtml')->__('New Custom Variable');
105: }
106: }
107:
108: /**
109: * Return validation url for edit form
110: *
111: * @return string
112: */
113: public function getValidationUrl()
114: {
115: return $this->getUrl('*/*/validate', array('_current'=>true));
116: }
117:
118: /**
119: * Return save url for edit form
120: *
121: * @return string
122: */
123: public function getSaveUrl()
124: {
125: return $this->getUrl('*/*/save', array('_current' => true, 'back' => null));
126: }
127:
128: /**
129: * Return save and continue url for edit form
130: *
131: * @return string
132: */
133: public function getSaveAndContinueUrl()
134: {
135: return $this->getUrl('*/*/save', array('_current' => true, 'back' => 'edit'));
136: }
137: }
138: