Version Notes
v0.1.1
- Filter user data on general settings tab;
- Get actual system tabs instead of hardcoded values;
- Add "Save and Continue Edit" button to extension edit page;
-Update system source model to return existent configuration tabs, instead of hardcoded;
- Add system source model to return top admin menu items;
- Fix default configuration tab name selection on extension new/edit page;
- Hide extension grid if prometheus is disabled.
Download this release
Release Info
Developer | Ricardo Tonet |
Extension | Prometheus |
Version | 0.1.1 |
Comparing to | |
See all releases |
Code changes from version 0.1.0 to 0.1.1
- app/code/community/BlackChacal/Prometheus/Block/Adminhtml/Prometheus/Edit.php +23 -0
- app/code/community/BlackChacal/Prometheus/Block/Adminhtml/Prometheus/Edit/Tab/General.php +123 -39
- app/code/community/BlackChacal/Prometheus/Helper/Data.php +50 -3
- app/code/community/BlackChacal/Prometheus/Model/System/Config/Source/Systemmenu.php +49 -0
- app/code/community/BlackChacal/Prometheus/Model/System/Config/Source/Systemtabs.php +11 -25
- app/code/community/BlackChacal/Prometheus/controllers/Adminhtml/PrometheusController.php +145 -114
- app/code/community/BlackChacal/Prometheus/etc/system.xml +7 -7
- app/design/adminhtml/default/default/layout/blackchacal_prometheus.xml +3 -0
- package.xml +12 -5
- skin/adminhtml/default/default/blackchacal_prometheus/js/prometheus.js +86 -0
app/code/community/BlackChacal/Prometheus/Block/Adminhtml/Prometheus/Edit.php
CHANGED
@@ -33,6 +33,14 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit extends Mage_Adminh
|
|
33 |
// Define edit page button labels
|
34 |
$this->_updateButton('save', 'label', $this->__('Save Extension'));
|
35 |
$this->_updateButton('delete', 'label', $this->__('Delete Extension'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
/**
|
@@ -49,4 +57,19 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit extends Mage_Adminh
|
|
49 |
return $this->__('New Extension');
|
50 |
}
|
51 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
33 |
// Define edit page button labels
|
34 |
$this->_updateButton('save', 'label', $this->__('Save Extension'));
|
35 |
$this->_updateButton('delete', 'label', $this->__('Delete Extension'));
|
36 |
+
|
37 |
+
// Add "Save and Continue Edit" button to extension edit page.
|
38 |
+
$this->_addButton('saveandcontinue', array(
|
39 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
40 |
+
'onclick' => 'saveAndContinueEdit(\''.$this->getSaveAndContinueUrl().'\')',
|
41 |
+
'class' => 'save',
|
42 |
+
), 100);
|
43 |
+
$this->_formScripts[] = " function saveAndContinueEdit(url) { editForm.submit(url); }";
|
44 |
}
|
45 |
|
46 |
/**
|
57 |
return $this->__('New Extension');
|
58 |
}
|
59 |
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Returns the save and continue url for the button.
|
63 |
+
*
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function getSaveAndContinueUrl()
|
67 |
+
{
|
68 |
+
return $this->getUrl('*/*/save', array(
|
69 |
+
'_current' => true,
|
70 |
+
'back' => 'edit',
|
71 |
+
'tab' => 'blackchacal_prometheus_extension_info_tabs_general_section',
|
72 |
+
'active_tab' => null
|
73 |
+
));
|
74 |
+
}
|
75 |
}
|
app/code/community/BlackChacal/Prometheus/Block/Adminhtml/Prometheus/Edit/Tab/General.php
CHANGED
@@ -70,21 +70,35 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
70 |
'method' => 'post'
|
71 |
));
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
$infoFieldset = $form->addFieldset('base_fieldset', array(
|
74 |
'legend' => Mage::helper('blackchacal_prometheus')->__('Extension Information'),
|
75 |
'class' => 'fieldset-wide',
|
76 |
'expanded' => true,
|
77 |
));
|
78 |
-
$configFieldset = $form->addFieldset('config_fieldset', array(
|
79 |
-
'legend' => Mage::helper('blackchacal_prometheus')->__('Extension Configuration'),
|
80 |
-
'class' => 'fieldset-wide',
|
81 |
-
'expanded' => false,
|
82 |
-
));
|
83 |
-
$menuFieldset = $form->addFieldset('menu_fieldset', array(
|
84 |
-
'legend' => Mage::helper('blackchacal_prometheus')->__('Extension Admin Menu'),
|
85 |
-
'class' => 'fieldset-wide',
|
86 |
-
'expanded' => false,
|
87 |
-
));
|
88 |
|
89 |
if ($model->getId()) {
|
90 |
$infoFieldset->addField('extension_id', 'hidden', array(
|
@@ -92,13 +106,14 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
92 |
));
|
93 |
}
|
94 |
|
|
|
95 |
$infoFieldset->addField('namespace', 'text', array(
|
96 |
'name' => 'namespace',
|
97 |
'label' => Mage::helper('blackchacal_prometheus')->__('Namespace'),
|
98 |
'title' => Mage::helper('blackchacal_prometheus')->__('Namespace'),
|
99 |
'required' => true,
|
100 |
'value' => ($model->getNamespace()) ? $model->getNamespace() :
|
101 |
-
|
102 |
));
|
103 |
$infoFieldset->addField('name', 'text', array(
|
104 |
'name' => 'name',
|
@@ -113,7 +128,7 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
113 |
'title' => Mage::helper('blackchacal_prometheus')->__('Code Pool'),
|
114 |
'required' => true,
|
115 |
'value' => ($model->getCodepool()) ? $model->getCodepool() :
|
116 |
-
|
117 |
'values' => Mage::getModel('blackchacal_prometheus/system_config_source_codepool')->toOptionArray()
|
118 |
));
|
119 |
$infoFieldset->addField('version', 'text', array(
|
@@ -122,7 +137,7 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
122 |
'title' => Mage::helper('blackchacal_prometheus')->__('Version'),
|
123 |
'required' => true,
|
124 |
'value' => ($model->getVersion()) ? $model->getVersion() :
|
125 |
-
|
126 |
));
|
127 |
$infoFieldset->addField('license', 'textarea', array(
|
128 |
'name' => 'license',
|
@@ -130,7 +145,7 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
130 |
'title' => Mage::helper('blackchacal_prometheus')->__('License'),
|
131 |
'required' => false,
|
132 |
'value' => ($model->getLicense()) ? $model->getLicense() :
|
133 |
-
|
134 |
));
|
135 |
$infoFieldset->addField('author_name', 'text', array(
|
136 |
'name' => 'author_name',
|
@@ -152,7 +167,7 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
152 |
'title' => Mage::helper('blackchacal_prometheus')->__('Action'),
|
153 |
'required' => false,
|
154 |
'value' => ($model->getAction()) ? $model->getAction() :
|
155 |
-
|
156 |
'values' => Mage::getModel('blackchacal_prometheus/system_config_source_action')->toOptionArray()
|
157 |
));
|
158 |
$infoFieldset->addField('rewrite', 'select', array(
|
@@ -185,34 +200,78 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
185 |
->addFieldDependence('rewrite', 'action', 'install')
|
186 |
);
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
$configFieldset->addField('config_tab_type', 'select', array(
|
189 |
'name' => 'config_tab_type',
|
190 |
'label' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Type'),
|
191 |
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Type'),
|
192 |
'value' => ($model->getConfigTabType()) ? $model->getConfigTabType() :
|
193 |
-
Mage::helper('blackchacal_prometheus')->getConfig('
|
194 |
'values' => Mage::getModel('blackchacal_prometheus/system_config_source_tabtypes')->toOptionArray()
|
195 |
));
|
196 |
$configFieldset->addField('config_tab_name', 'text', array(
|
197 |
-
'name'
|
198 |
-
'label'
|
199 |
-
'title'
|
200 |
-
'value'
|
201 |
-
$this->
|
202 |
-
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
$configFieldset->addField('config_tab_label', 'text', array(
|
204 |
'name' => 'config_tab_label',
|
205 |
'label' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Label'),
|
206 |
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Label'),
|
207 |
'value' => ($model->getConfigTabLabel()) ? $model->getConfigTabLabel() :
|
208 |
-
$this->
|
209 |
));
|
210 |
$configFieldset->addField('config_tab_position', 'text', array(
|
211 |
'name' => 'config_tab_position',
|
212 |
'label' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Position'),
|
213 |
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Position'),
|
214 |
'value' => ($model->getConfigTabPosition()) ? $model->getConfigTabPosition() :
|
215 |
-
$this->
|
216 |
));
|
217 |
$configFieldset->addField('config_section_name', 'text', array(
|
218 |
'name' => 'config_section_name',
|
@@ -225,10 +284,44 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
225 |
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Section Label')
|
226 |
));
|
227 |
|
228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
'name' => 'admin_menu_parent',
|
230 |
'label' => Mage::helper('blackchacal_prometheus')->__('Admin Menu Parent'),
|
231 |
-
'title' => Mage::helper('blackchacal_prometheus')->__('Admin Menu Parent')
|
|
|
|
|
232 |
));
|
233 |
$menuFieldset->addField('admin_menu_name', 'text', array(
|
234 |
'name' => 'admin_menu_name',
|
@@ -251,16 +344,7 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
251 |
'title' => Mage::helper('blackchacal_prometheus')->__('Admin Menu Position')
|
252 |
));
|
253 |
|
254 |
-
$
|
255 |
-
/**
|
256 |
-
* If is "edit" page use model values. If is "new" page use default
|
257 |
-
* configuration data.
|
258 |
-
*/
|
259 |
-
if ($this->getRequest()->getParam('id')) {
|
260 |
-
$form->setValues($model->getData());
|
261 |
-
}
|
262 |
-
|
263 |
-
return parent::_prepareForm();
|
264 |
}
|
265 |
|
266 |
/**
|
@@ -269,7 +353,7 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
269 |
* @param $type string
|
270 |
* @return string
|
271 |
*/
|
272 |
-
private function
|
273 |
{
|
274 |
switch ($type) {
|
275 |
case 'namespace':
|
@@ -299,7 +383,7 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
299 |
* @param $type string
|
300 |
* @return string
|
301 |
*/
|
302 |
-
private function
|
303 |
{
|
304 |
switch ($type) {
|
305 |
case 'namespace':
|
@@ -329,7 +413,7 @@ class BlackChacal_Prometheus_Block_Adminhtml_Prometheus_Edit_Tab_General extends
|
|
329 |
* @param $type string
|
330 |
* @return string
|
331 |
*/
|
332 |
-
private function
|
333 |
{
|
334 |
switch ($type) {
|
335 |
case 'namespace':
|
70 |
'method' => 'post'
|
71 |
));
|
72 |
|
73 |
+
$form = $this->_prepareInfoFieldset($model, $form);
|
74 |
+
$form = $this->_prepareConfigFieldset($model, $form);
|
75 |
+
$form = $this->_prepareAdminMenuFieldset($model, $form);
|
76 |
+
|
77 |
+
$this->setForm($form);
|
78 |
+
/**
|
79 |
+
* If is "edit" page use model values. If is "new" page use default
|
80 |
+
* configuration data.
|
81 |
+
*/
|
82 |
+
if ($this->getRequest()->getParam('id')) {
|
83 |
+
$form->setValues($model->getData());
|
84 |
+
}
|
85 |
+
|
86 |
+
return parent::_prepareForm();
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Prepares the "Extension Information" fieldset.
|
91 |
+
*
|
92 |
+
* @param $model BlackChacal_Prometheus_Model_Extension
|
93 |
+
* @param $form Varien_Data_Form
|
94 |
+
*/
|
95 |
+
private function _prepareInfoFieldset($model, $form)
|
96 |
+
{
|
97 |
$infoFieldset = $form->addFieldset('base_fieldset', array(
|
98 |
'legend' => Mage::helper('blackchacal_prometheus')->__('Extension Information'),
|
99 |
'class' => 'fieldset-wide',
|
100 |
'expanded' => true,
|
101 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
if ($model->getId()) {
|
104 |
$infoFieldset->addField('extension_id', 'hidden', array(
|
106 |
));
|
107 |
}
|
108 |
|
109 |
+
// Fields on "Extension Information" fieldset
|
110 |
$infoFieldset->addField('namespace', 'text', array(
|
111 |
'name' => 'namespace',
|
112 |
'label' => Mage::helper('blackchacal_prometheus')->__('Namespace'),
|
113 |
'title' => Mage::helper('blackchacal_prometheus')->__('Namespace'),
|
114 |
'required' => true,
|
115 |
'value' => ($model->getNamespace()) ? $model->getNamespace() :
|
116 |
+
Mage::helper('blackchacal_prometheus')->escapeStrings(Mage::helper('blackchacal_prometheus')->getConfig('namespace'))
|
117 |
));
|
118 |
$infoFieldset->addField('name', 'text', array(
|
119 |
'name' => 'name',
|
128 |
'title' => Mage::helper('blackchacal_prometheus')->__('Code Pool'),
|
129 |
'required' => true,
|
130 |
'value' => ($model->getCodepool()) ? $model->getCodepool() :
|
131 |
+
Mage::helper('blackchacal_prometheus')->getConfig('codepool'),
|
132 |
'values' => Mage::getModel('blackchacal_prometheus/system_config_source_codepool')->toOptionArray()
|
133 |
));
|
134 |
$infoFieldset->addField('version', 'text', array(
|
137 |
'title' => Mage::helper('blackchacal_prometheus')->__('Version'),
|
138 |
'required' => true,
|
139 |
'value' => ($model->getVersion()) ? $model->getVersion() :
|
140 |
+
Mage::helper('blackchacal_prometheus')->getConfig('version')
|
141 |
));
|
142 |
$infoFieldset->addField('license', 'textarea', array(
|
143 |
'name' => 'license',
|
145 |
'title' => Mage::helper('blackchacal_prometheus')->__('License'),
|
146 |
'required' => false,
|
147 |
'value' => ($model->getLicense()) ? $model->getLicense() :
|
148 |
+
Mage::helper('blackchacal_prometheus')->getConfig('license')
|
149 |
));
|
150 |
$infoFieldset->addField('author_name', 'text', array(
|
151 |
'name' => 'author_name',
|
167 |
'title' => Mage::helper('blackchacal_prometheus')->__('Action'),
|
168 |
'required' => false,
|
169 |
'value' => ($model->getAction()) ? $model->getAction() :
|
170 |
+
Mage::helper('blackchacal_prometheus')->getConfig('action'),
|
171 |
'values' => Mage::getModel('blackchacal_prometheus/system_config_source_action')->toOptionArray()
|
172 |
));
|
173 |
$infoFieldset->addField('rewrite', 'select', array(
|
200 |
->addFieldDependence('rewrite', 'action', 'install')
|
201 |
);
|
202 |
|
203 |
+
return $form;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Prepares the "Extension Configuration" fieldset.
|
208 |
+
*
|
209 |
+
* @param $model BlackChacal_Prometheus_Model_Extension
|
210 |
+
* @param $form Varien_Data_Form
|
211 |
+
*/
|
212 |
+
private function _prepareConfigFieldset($model, $form)
|
213 |
+
{
|
214 |
+
$configFieldset = $form->addFieldset('config_fieldset', array(
|
215 |
+
'legend' => Mage::helper('blackchacal_prometheus')->__('Extension Configuration'),
|
216 |
+
'class' => 'fieldset-wide',
|
217 |
+
'expanded' => false,
|
218 |
+
));
|
219 |
+
|
220 |
+
// Fields on "Extension Configuration" fieldset
|
221 |
$configFieldset->addField('config_tab_type', 'select', array(
|
222 |
'name' => 'config_tab_type',
|
223 |
'label' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Type'),
|
224 |
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Type'),
|
225 |
'value' => ($model->getConfigTabType()) ? $model->getConfigTabType() :
|
226 |
+
Mage::helper('blackchacal_prometheus')->getConfig('config_tab_type'),
|
227 |
'values' => Mage::getModel('blackchacal_prometheus/system_config_source_tabtypes')->toOptionArray()
|
228 |
));
|
229 |
$configFieldset->addField('config_tab_name', 'text', array(
|
230 |
+
'name' => 'config_tab_name',
|
231 |
+
'label' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Name'),
|
232 |
+
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Name'),
|
233 |
+
'value' => ($model->getConfigTabName()) ? $model->getConfigTabName() :
|
234 |
+
$this->_getConfigTabName(Mage::helper('blackchacal_prometheus')->getConfig('config_tab_type'))
|
235 |
+
))->setAfterElementHtml("<script type='text/javascript'>
|
236 |
+
//<![CDATA[
|
237 |
+
(function() {
|
238 |
+
var onloadName = '".$model->getConfigTabName()."',
|
239 |
+
namespaceName = '".$this->_getConfigTabName('namespace')."',
|
240 |
+
namespaceLabel = '".$this->_getConfigTabLabel('namespace')."',
|
241 |
+
systemName = '".$this->_getConfigTabName('system')."',
|
242 |
+
systemLabel = '".$this->_getConfigTabLabel('system')."';
|
243 |
+
|
244 |
+
setDefaultConfigTabName(onloadName, namespaceName, namespaceLabel, systemName, systemLabel);
|
245 |
+
})();
|
246 |
+
//]]>
|
247 |
+
</script>");
|
248 |
+
$configFieldset->addField('config_system_tab_name', 'select', array(
|
249 |
+
'name' => 'config_tab_name',
|
250 |
+
'label' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Name'),
|
251 |
+
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Name'),
|
252 |
+
'value' => ($model->getConfigTabName()) ? $model->getConfigTabName() :
|
253 |
+
$this->_getConfigTabName(Mage::helper('blackchacal_prometheus')->getConfig('config_tab_type')),
|
254 |
+
'values' => Mage::getModel('blackchacal_prometheus/system_config_source_systemtabs')->toOptionArray()
|
255 |
+
))->setAfterElementHtml("<script type='text/javascript'>
|
256 |
+
//<![CDATA[
|
257 |
+
(function() {
|
258 |
+
setDefaultConfigSystemTabLabel();
|
259 |
+
})();
|
260 |
+
//]]>
|
261 |
+
</script>");
|
262 |
$configFieldset->addField('config_tab_label', 'text', array(
|
263 |
'name' => 'config_tab_label',
|
264 |
'label' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Label'),
|
265 |
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Label'),
|
266 |
'value' => ($model->getConfigTabLabel()) ? $model->getConfigTabLabel() :
|
267 |
+
$this->_getConfigTabLabel(Mage::helper('blackchacal_prometheus')->getConfig('config_tab_type'))
|
268 |
));
|
269 |
$configFieldset->addField('config_tab_position', 'text', array(
|
270 |
'name' => 'config_tab_position',
|
271 |
'label' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Position'),
|
272 |
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Tab Position'),
|
273 |
'value' => ($model->getConfigTabPosition()) ? $model->getConfigTabPosition() :
|
274 |
+
$this->_getConfigTabPositions(Mage::helper('blackchacal_prometheus')->getConfig('config_tab_type'))
|
275 |
));
|
276 |
$configFieldset->addField('config_section_name', 'text', array(
|
277 |
'name' => 'config_section_name',
|
284 |
'title' => Mage::helper('blackchacal_prometheus')->__('Configuration Section Label')
|
285 |
));
|
286 |
|
287 |
+
// Add fields dependencies
|
288 |
+
$this->setChild('form_after', $this->getLayout()
|
289 |
+
->createBlock('adminhtml/widget_form_element_dependence')
|
290 |
+
->addFieldMap('config_tab_type', 'config_tab_type')
|
291 |
+
->addFieldMap('config_system_tab_name', 'config_system_tab_name')
|
292 |
+
->addFieldMap('config_tab_name', 'config_tab_name')
|
293 |
+
->addFieldMap('config_tab_label', 'config_tab_label')
|
294 |
+
->addFieldMap('config_tab_position', 'config_tab_position')
|
295 |
+
->addFieldDependence('config_system_tab_name', 'config_tab_type', 'system')
|
296 |
+
->addFieldDependence('config_tab_name', 'config_tab_type', array('namespace', 'custom'))
|
297 |
+
->addFieldDependence('config_tab_label', 'config_tab_type', array('namespace', 'custom'))
|
298 |
+
->addFieldDependence('config_tab_position', 'config_tab_type', array('namespace', 'custom'))
|
299 |
+
);
|
300 |
+
|
301 |
+
return $form;
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Prepares the "Extension Admin Menu" fieldset.
|
306 |
+
*
|
307 |
+
* @param $model BlackChacal_Prometheus_Model_Extension
|
308 |
+
* @param $form Varien_Data_Form
|
309 |
+
*/
|
310 |
+
private function _prepareAdminMenuFieldset($model, $form)
|
311 |
+
{
|
312 |
+
$menuFieldset = $form->addFieldset('menu_fieldset', array(
|
313 |
+
'legend' => Mage::helper('blackchacal_prometheus')->__('Extension Admin Menu'),
|
314 |
+
'class' => 'fieldset-wide',
|
315 |
+
'expanded' => false,
|
316 |
+
));
|
317 |
+
|
318 |
+
// Fields on "Extension Admin Menu" fieldset
|
319 |
+
$menuFieldset->addField('admin_menu_parent', 'select', array(
|
320 |
'name' => 'admin_menu_parent',
|
321 |
'label' => Mage::helper('blackchacal_prometheus')->__('Admin Menu Parent'),
|
322 |
+
'title' => Mage::helper('blackchacal_prometheus')->__('Admin Menu Parent'),
|
323 |
+
'value' => $model->getAdminMenuParent(),
|
324 |
+
'values' => Mage::getModel('blackchacal_prometheus/system_config_source_systemmenu')->toOptionArray()
|
325 |
));
|
326 |
$menuFieldset->addField('admin_menu_name', 'text', array(
|
327 |
'name' => 'admin_menu_name',
|
344 |
'title' => Mage::helper('blackchacal_prometheus')->__('Admin Menu Position')
|
345 |
));
|
346 |
|
347 |
+
return $form;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
}
|
349 |
|
350 |
/**
|
353 |
* @param $type string
|
354 |
* @return string
|
355 |
*/
|
356 |
+
private function _getConfigTabLabel($type)
|
357 |
{
|
358 |
switch ($type) {
|
359 |
case 'namespace':
|
383 |
* @param $type string
|
384 |
* @return string
|
385 |
*/
|
386 |
+
private function _getConfigTabName($type)
|
387 |
{
|
388 |
switch ($type) {
|
389 |
case 'namespace':
|
413 |
* @param $type string
|
414 |
* @return string
|
415 |
*/
|
416 |
+
private function _getConfigTabPositions($type)
|
417 |
{
|
418 |
switch ($type) {
|
419 |
case 'namespace':
|
app/code/community/BlackChacal/Prometheus/Helper/Data.php
CHANGED
@@ -42,8 +42,8 @@ class BlackChacal_Prometheus_Helper_Data extends Mage_Core_Helper_Data
|
|
42 |
/**
|
43 |
* System configuration paths for "General" tab
|
44 |
*/
|
45 |
-
const XML_PATH_GENERAL_ACTIVE = '
|
46 |
-
const XML_PATH_GENERAL_HELP = '
|
47 |
|
48 |
/**
|
49 |
* General constants
|
@@ -73,7 +73,7 @@ class BlackChacal_Prometheus_Helper_Data extends Mage_Core_Helper_Data
|
|
73 |
*/
|
74 |
public function isPrometheusActive()
|
75 |
{
|
76 |
-
return Mage::getStoreConfig(self::XML_PATH_GENERAL_ACTIVE);
|
77 |
}
|
78 |
|
79 |
/**
|
@@ -145,4 +145,51 @@ class BlackChacal_Prometheus_Helper_Data extends Mage_Core_Helper_Data
|
|
145 |
{
|
146 |
return preg_replace('/[^ \w+]/', '', $str);
|
147 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
42 |
/**
|
43 |
* System configuration paths for "General" tab
|
44 |
*/
|
45 |
+
const XML_PATH_GENERAL_ACTIVE = 'blackchacal_prometheus/general/enabled';
|
46 |
+
const XML_PATH_GENERAL_HELP = 'blackchacal_prometheus/general/help';
|
47 |
|
48 |
/**
|
49 |
* General constants
|
73 |
*/
|
74 |
public function isPrometheusActive()
|
75 |
{
|
76 |
+
return (bool)Mage::getStoreConfig(self::XML_PATH_GENERAL_ACTIVE);
|
77 |
}
|
78 |
|
79 |
/**
|
145 |
{
|
146 |
return preg_replace('/[^ \w+]/', '', $str);
|
147 |
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Remove all characters that aren't numbers and ".".
|
151 |
+
*
|
152 |
+
* @param $str
|
153 |
+
*/
|
154 |
+
public function escapeVersionStrings($str)
|
155 |
+
{
|
156 |
+
return preg_replace('/[^0-9.+]/', '', $str);
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Remove all characters that aren't numbers.
|
161 |
+
*
|
162 |
+
* @param $str
|
163 |
+
*/
|
164 |
+
public function escapeNumberStrings($str)
|
165 |
+
{
|
166 |
+
return preg_replace('/[^0-9+]/', '', $str);
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Escapes the extension model strings for invalid characters before saving to db.
|
171 |
+
*
|
172 |
+
* @param $model BlackChacal_Prometheus_Model_Extension
|
173 |
+
* @return mixed
|
174 |
+
*/
|
175 |
+
public function escapeExtensionModel($model)
|
176 |
+
{
|
177 |
+
$validModel = $model;
|
178 |
+
$validModel->setNamespace($this->escapeStrings($model->getNamespace()));
|
179 |
+
$validModel->setName($this->escapeStrings($model->getName()));
|
180 |
+
$validModel->setVersion($this->escapeVersionStrings($model->getVersion()));
|
181 |
+
$validModel->setAuthorEmail(!Zend_Validate::is($model->getAuthorEmail(), 'EmailAddress') ? '' : $model->getAuthorEmail());
|
182 |
+
$validModel->setConfigNodeCode($this->escapeStrings($model->getConfigNodeCode()));
|
183 |
+
$validModel->setConfigTabName($this->escapeStrings($model->getConfigTabName()));
|
184 |
+
$validModel->setConfigTabLabel($this->escapeStrings($model->getConfigTabLabel()));
|
185 |
+
$validModel->setConfigTabPosition($this->escapeNumberStrings($model->getConfigTabPosition()));
|
186 |
+
$validModel->setConfigSectionName($this->escapeStrings($model->getConfigSectionName()));
|
187 |
+
$validModel->setConfigSectionLabel($this->escapeStrings($model->getConfigSectionLabel()));
|
188 |
+
$validModel->setAdminMenuName($this->escapeStrings($model->getAdminMenuName()));
|
189 |
+
$validModel->setAdminMenuTitle($this->escapeStrings($model->getAdminMenuTitle()));
|
190 |
+
$validModel->setAdminMenuAction($this->escapeStrings($model->getAdminMenuAction()));
|
191 |
+
$validModel->setAdminMenuPosition($this->escapeNumberStrings($model->getAdminMenuPosition()));
|
192 |
+
|
193 |
+
return $validModel;
|
194 |
+
}
|
195 |
}
|
app/code/community/BlackChacal/Prometheus/Model/System/Config/Source/Systemmenu.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BlackChacal_Prometheus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade Prometheus to newer
|
15 |
+
* versions in the future. If you wish to customize Prometheus for your
|
16 |
+
* needs please contact the author for more information.
|
17 |
+
*
|
18 |
+
* @category BlackChacal
|
19 |
+
* @package BlackChacal_Prometheus
|
20 |
+
* @copyright Copyright (c) 2015 BlackChacal <ribeiro.tonet@gmail.com>
|
21 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
22 |
+
*/
|
23 |
+
|
24 |
+
class BlackChacal_Prometheus_Model_System_Config_Source_Systemmenu
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Returns the top admin menu items.
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return array Admin Menu Items
|
31 |
+
*/
|
32 |
+
public function toOptionArray()
|
33 |
+
{
|
34 |
+
$helper = Mage::helper('blackchacal_prometheus');
|
35 |
+
$adminMenu = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu');
|
36 |
+
$options = array();
|
37 |
+
|
38 |
+
foreach($adminMenu as $adminMenuData) {
|
39 |
+
foreach($adminMenuData as $menuItemCode => $menuItemInfo) {
|
40 |
+
$options[] = array(
|
41 |
+
'value' => $menuItemCode,
|
42 |
+
'label' => $helper->__((string)$menuItemInfo->title)
|
43 |
+
);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
return $options;
|
48 |
+
}
|
49 |
+
}
|
app/code/community/BlackChacal/Prometheus/Model/System/Config/Source/Systemtabs.php
CHANGED
@@ -34,32 +34,18 @@ class BlackChacal_Prometheus_Model_System_Config_Source_Systemtabs
|
|
34 |
public function toOptionArray()
|
35 |
{
|
36 |
$helper = Mage::helper('blackchacal_prometheus');
|
37 |
-
|
38 |
$options = array();
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
'label' => $helper->__('Customers')
|
50 |
-
);
|
51 |
-
$options[] = array(
|
52 |
-
'value' => 'sales',
|
53 |
-
'label' => $helper->__('Sales')
|
54 |
-
);
|
55 |
-
$options[] = array(
|
56 |
-
'value' => 'service',
|
57 |
-
'label' => $helper->__('Services')
|
58 |
-
);
|
59 |
-
$options[] = array(
|
60 |
-
'value' => 'advanced',
|
61 |
-
'label' => $helper->__('Advanced')
|
62 |
-
);
|
63 |
|
64 |
return $options;
|
65 |
}
|
34 |
public function toOptionArray()
|
35 |
{
|
36 |
$helper = Mage::helper('blackchacal_prometheus');
|
37 |
+
$tabs = Mage::getSingleton('adminhtml/config')->getTabs();
|
38 |
$options = array();
|
39 |
+
|
40 |
+
foreach($tabs as $tabData) {
|
41 |
+
|
42 |
+
foreach($tabData as $tabCode => $tabInfo) {
|
43 |
+
$options[] = array(
|
44 |
+
'value' => $tabCode,
|
45 |
+
'label' => $helper->__((string)$tabInfo->label)
|
46 |
+
);
|
47 |
+
}
|
48 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
return $options;
|
51 |
}
|
app/code/community/BlackChacal/Prometheus/controllers/Adminhtml/PrometheusController.php
CHANGED
@@ -30,9 +30,13 @@ class BlackChacal_Prometheus_Adminhtml_PrometheusController extends Mage_Adminht
|
|
30 |
*/
|
31 |
public function indexAction()
|
32 |
{
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
/**
|
@@ -47,6 +51,25 @@ class BlackChacal_Prometheus_Adminhtml_PrometheusController extends Mage_Adminht
|
|
47 |
$this->_forward('edit');
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
/**
|
51 |
* Controller action for extension editing/creation.
|
52 |
*
|
@@ -54,38 +77,42 @@ class BlackChacal_Prometheus_Adminhtml_PrometheusController extends Mage_Adminht
|
|
54 |
*/
|
55 |
public function editAction()
|
56 |
{
|
57 |
-
|
|
|
|
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
-
|
|
|
73 |
}
|
74 |
-
}
|
75 |
|
76 |
-
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
|
83 |
-
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
89 |
}
|
90 |
|
91 |
/**
|
@@ -96,49 +123,64 @@ class BlackChacal_Prometheus_Adminhtml_PrometheusController extends Mage_Adminht
|
|
96 |
*/
|
97 |
public function saveAction()
|
98 |
{
|
99 |
-
if (
|
100 |
-
$
|
101 |
-
|
102 |
-
if (
|
103 |
-
$extensionModel
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
$extensionModel->save();
|
108 |
-
|
109 |
-
switch ($postData['action']) {
|
110 |
-
case 'package':
|
111 |
-
break;
|
112 |
-
case 'install':
|
113 |
-
$installed = $extensionModel->install();
|
114 |
-
if ($installed) {
|
115 |
-
$extensionModel->setInstalled(true);
|
116 |
-
$extensionModel->save();
|
117 |
-
}
|
118 |
-
break;
|
119 |
-
case 'uninstall':
|
120 |
-
$uninstalled = $extensionModel->uninstall();
|
121 |
-
if ($uninstalled) {
|
122 |
-
$extensionModel->setInstalled(false);
|
123 |
-
$extensionModel->save();
|
124 |
-
}
|
125 |
-
break;
|
126 |
-
default:
|
127 |
-
break;
|
128 |
}
|
|
|
129 |
|
130 |
-
|
131 |
-
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
-
|
141 |
-
|
|
|
142 |
}
|
143 |
}
|
144 |
|
@@ -150,23 +192,27 @@ class BlackChacal_Prometheus_Adminhtml_PrometheusController extends Mage_Adminht
|
|
150 |
*/
|
151 |
public function deleteAction()
|
152 |
{
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
|
|
|
|
|
|
166 |
}
|
167 |
-
}
|
168 |
|
169 |
-
|
|
|
170 |
}
|
171 |
|
172 |
/**
|
@@ -176,45 +222,30 @@ class BlackChacal_Prometheus_Adminhtml_PrometheusController extends Mage_Adminht
|
|
176 |
*/
|
177 |
public function massDeleteAction()
|
178 |
{
|
179 |
-
|
180 |
-
|
181 |
-
if (!is_array($extensionIds)) {
|
182 |
-
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select extension(s).'));
|
183 |
} else {
|
184 |
-
|
185 |
-
$extensionModel = Mage::getModel('blackchacal_prometheus/extension');
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Total of %d record(s) were deleted.', count($extensionIds)));
|
193 |
-
} catch (Exception $e) {
|
194 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
195 |
-
}
|
196 |
-
}
|
197 |
|
198 |
-
|
199 |
-
|
|
|
|
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
* @return Mage_Adminhtml_Controller_Action
|
207 |
-
*/
|
208 |
-
protected function _initAction()
|
209 |
-
{
|
210 |
-
$this->loadLayout()
|
211 |
-
// Make the active menu match the menu config nodes (without 'children' inbetween)
|
212 |
-
->_setActiveMenu('system/blackchacal_prometheus')
|
213 |
-
->_title($this->__('System'))->_title($this->__('Prometheus'))
|
214 |
-
->_addBreadcrumb($this->__('System'), $this->__('System'))
|
215 |
-
->_addBreadcrumb($this->__('Prometheus - Create Extensions'), $this->__('Prometheus - Create Extensions'));
|
216 |
|
217 |
-
|
|
|
218 |
}
|
219 |
|
220 |
/**
|
30 |
*/
|
31 |
public function indexAction()
|
32 |
{
|
33 |
+
if (!Mage::helper('blackchacal_prometheus')->isPrometheusActive()) {
|
34 |
+
$this->_redirect('adminhtml/dashboard/index');
|
35 |
+
} else {
|
36 |
+
// Let's call our initAction method which will set some basic params for each action
|
37 |
+
$this->_initAction();
|
38 |
+
$this->renderLayout();
|
39 |
+
}
|
40 |
}
|
41 |
|
42 |
/**
|
51 |
$this->_forward('edit');
|
52 |
}
|
53 |
|
54 |
+
/**
|
55 |
+
* Initialize action
|
56 |
+
*
|
57 |
+
* Here, we set the breadcrumbs and the active menu.
|
58 |
+
*
|
59 |
+
* @return Mage_Adminhtml_Controller_Action
|
60 |
+
*/
|
61 |
+
protected function _initAction()
|
62 |
+
{
|
63 |
+
$this->loadLayout()
|
64 |
+
// Make the active menu match the menu config nodes (without 'children' inbetween)
|
65 |
+
->_setActiveMenu('system/blackchacal_prometheus')
|
66 |
+
->_title($this->__('System'))->_title($this->__('Prometheus'))
|
67 |
+
->_addBreadcrumb($this->__('System'), $this->__('System'))
|
68 |
+
->_addBreadcrumb($this->__('Prometheus - Create Extensions'), $this->__('Prometheus - Create Extensions'));
|
69 |
+
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
/**
|
74 |
* Controller action for extension editing/creation.
|
75 |
*
|
77 |
*/
|
78 |
public function editAction()
|
79 |
{
|
80 |
+
if (!Mage::helper('blackchacal_prometheus')->isPrometheusActive()) {
|
81 |
+
$this->_redirect('adminhtml/dashboard/index');
|
82 |
+
} else {
|
83 |
+
$this->_initAction();
|
84 |
|
85 |
+
// Get id if available
|
86 |
+
$id = $this->getRequest()->getParam('id');
|
87 |
+
$extensionModel = Mage::getModel('blackchacal_prometheus/extension');
|
88 |
|
89 |
+
if ($id) {
|
90 |
+
// Load record
|
91 |
+
$extensionModel->load($id);
|
92 |
|
93 |
+
// Check if record is loaded
|
94 |
+
if (!$extensionModel->getExtensionId()) {
|
95 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('This extension no longer exists.'));
|
96 |
+
$this->_redirect('*/*/');
|
97 |
|
98 |
+
return;
|
99 |
+
}
|
100 |
}
|
|
|
101 |
|
102 |
+
$this->_title($extensionModel->getExtensionId() ? $extensionModel->getName() : $this->__('New Extension'));
|
103 |
|
104 |
+
$data = Mage::getSingleton('adminhtml/session')->getExtensionData(true);
|
105 |
+
if (!empty($data)) {
|
106 |
+
$extensionModel->setData($data);
|
107 |
+
}
|
108 |
|
109 |
+
Mage::register('blackchacal_prometheus', $extensionModel);
|
110 |
|
111 |
+
$this->_initAction()
|
112 |
+
->_addBreadcrumb($id ? $this->__('Edit Extension') : $this->__('New Extension'), $id ? $this->__('Edit Extension') : $this->__('New Extension'))
|
113 |
+
->_addContent($this->getLayout()->createBlock('blackchacal_prometheus/adminhtml_prometheus_edit')->setData('action', $this->getUrl('*/*/save')))
|
114 |
+
->renderLayout();
|
115 |
+
}
|
116 |
}
|
117 |
|
118 |
/**
|
123 |
*/
|
124 |
public function saveAction()
|
125 |
{
|
126 |
+
if (!Mage::helper('blackchacal_prometheus')->isPrometheusActive()) {
|
127 |
+
$this->_redirect('adminhtml/dashboard/index');
|
128 |
+
} else {
|
129 |
+
if ($postData = $this->getRequest()->getPost()) {
|
130 |
+
$extensionModel = Mage::getSingleton('blackchacal_prometheus/extension');
|
131 |
+
$extensionModel->setData($postData);
|
132 |
+
if (isset($postData['id'])) {
|
133 |
+
$extensionModel->setExtensionId($postData['id']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
+
$extensionModel = Mage::helper('blackchacal_prometheus')->escapeExtensionModel($extensionModel);
|
136 |
|
137 |
+
try {
|
138 |
+
$extensionModel->save();
|
139 |
|
140 |
+
switch ($postData['action']) {
|
141 |
+
case 'package':
|
142 |
+
break;
|
143 |
+
case 'install':
|
144 |
+
$installed = $extensionModel->install();
|
145 |
+
if ($installed) {
|
146 |
+
$extensionModel->setInstalled(true);
|
147 |
+
$extensionModel->save();
|
148 |
+
}
|
149 |
+
break;
|
150 |
+
case 'uninstall':
|
151 |
+
$uninstalled = $extensionModel->uninstall();
|
152 |
+
if ($uninstalled) {
|
153 |
+
$extensionModel->setInstalled(false);
|
154 |
+
$extensionModel->save();
|
155 |
+
}
|
156 |
+
break;
|
157 |
+
default:
|
158 |
+
break;
|
159 |
+
}
|
160 |
+
|
161 |
+
// Handle save and continue edit case.
|
162 |
+
if ($this->getRequest()->getParam('back')) {
|
163 |
+
$this->_redirect(
|
164 |
+
'*/*/edit',
|
165 |
+
array(
|
166 |
+
'id' => $extensionModel->getId(),
|
167 |
+
)
|
168 |
+
);
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
|
172 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The extension was saved.'));
|
173 |
+
$this->_redirect('*/*/');
|
174 |
+
return;
|
175 |
+
} catch (Mage_Core_Exception $e) {
|
176 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
177 |
+
} catch (Exception $e) {
|
178 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this extension.'));
|
179 |
+
}
|
180 |
|
181 |
+
Mage::getSingleton('adminhtml/session')->setExtensionData($postData);
|
182 |
+
$this->_redirectReferer();
|
183 |
+
}
|
184 |
}
|
185 |
}
|
186 |
|
192 |
*/
|
193 |
public function deleteAction()
|
194 |
{
|
195 |
+
if (!Mage::helper('blackchacal_prometheus')->isPrometheusActive()) {
|
196 |
+
$this->_redirect('adminhtml/dashboard/index');
|
197 |
+
} else {
|
198 |
+
// Get id if available
|
199 |
+
$id = $this->getRequest()->getParam('id');
|
200 |
+
|
201 |
+
if ($id) {
|
202 |
+
try {
|
203 |
+
// Delete record
|
204 |
+
$extensionModel = Mage::getModel('blackchacal_prometheus/extension');
|
205 |
+
$extensionModel->load($id)->delete();
|
206 |
+
$extensionModel->uninstall();
|
207 |
+
|
208 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The extension was deleted.'));
|
209 |
+
} catch (Exception $e) {
|
210 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
211 |
+
}
|
212 |
}
|
|
|
213 |
|
214 |
+
$this->_redirect('*/*/index');
|
215 |
+
}
|
216 |
}
|
217 |
|
218 |
/**
|
222 |
*/
|
223 |
public function massDeleteAction()
|
224 |
{
|
225 |
+
if (!Mage::helper('blackchacal_prometheus')->isPrometheusActive()) {
|
226 |
+
$this->_redirect('adminhtml/dashboard/index');
|
|
|
|
|
227 |
} else {
|
228 |
+
$extensionIds = $this->getRequest()->getParam('extensions');
|
|
|
229 |
|
230 |
+
if (!is_array($extensionIds)) {
|
231 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select extension(s).'));
|
232 |
+
} else {
|
233 |
+
try {
|
234 |
+
$extensionModel = Mage::getModel('blackchacal_prometheus/extension');
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
+
foreach ($extensionIds as $extensionId) {
|
237 |
+
$extensionModel->load($extensionId)->delete();
|
238 |
+
$extensionModel->uninstall();
|
239 |
+
}
|
240 |
|
241 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Total of %d record(s) were deleted.', count($extensionIds)));
|
242 |
+
} catch (Exception $e) {
|
243 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
244 |
+
}
|
245 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
|
247 |
+
$this->_redirect('*/*/index');
|
248 |
+
}
|
249 |
}
|
250 |
|
251 |
/**
|
app/code/community/BlackChacal/Prometheus/etc/system.xml
CHANGED
@@ -118,8 +118,8 @@
|
|
118 |
<show_in_website>0</show_in_website>
|
119 |
<show_in_store>0</show_in_store>
|
120 |
</license>
|
121 |
-
<
|
122 |
-
<label>Configuration Tab
|
123 |
<comment><![CDATA[Name for the extension tab on the menu System -> Configuration.]]></comment>
|
124 |
<frontend_type>select</frontend_type>
|
125 |
<source_model>blackchacal_prometheus/system_config_source_tabtypes</source_model>
|
@@ -127,7 +127,7 @@
|
|
127 |
<show_in_default>1</show_in_default>
|
128 |
<show_in_website>0</show_in_website>
|
129 |
<show_in_store>0</show_in_store>
|
130 |
-
</
|
131 |
<config_tab_custom translate="label,comment" module="blackchacal_prometheus">
|
132 |
<label>Configuration Tab Name - Custom Name</label>
|
133 |
<comment><![CDATA[]]></comment>
|
@@ -137,7 +137,7 @@
|
|
137 |
<show_in_website>0</show_in_website>
|
138 |
<show_in_store>0</show_in_store>
|
139 |
<depends>
|
140 |
-
<
|
141 |
</depends>
|
142 |
</config_tab_custom>
|
143 |
<config_tab_system translate="label,comment" module="blackchacal_prometheus">
|
@@ -150,7 +150,7 @@
|
|
150 |
<show_in_website>0</show_in_website>
|
151 |
<show_in_store>0</show_in_store>
|
152 |
<depends>
|
153 |
-
<
|
154 |
</depends>
|
155 |
</config_tab_system>
|
156 |
<config_tab_namespace_position translate="label,comment" module="blackchacal_prometheus">
|
@@ -162,7 +162,7 @@
|
|
162 |
<show_in_website>0</show_in_website>
|
163 |
<show_in_store>0</show_in_store>
|
164 |
<depends>
|
165 |
-
<
|
166 |
</depends>
|
167 |
</config_tab_namespace_position>
|
168 |
<config_tab_custom_position translate="label,comment" module="blackchacal_prometheus">
|
@@ -174,7 +174,7 @@
|
|
174 |
<show_in_website>0</show_in_website>
|
175 |
<show_in_store>0</show_in_store>
|
176 |
<depends>
|
177 |
-
<
|
178 |
</depends>
|
179 |
</config_tab_custom_position>
|
180 |
</fields>
|
118 |
<show_in_website>0</show_in_website>
|
119 |
<show_in_store>0</show_in_store>
|
120 |
</license>
|
121 |
+
<config_tab_type translate="label,comment" module="blackchacal_prometheus">
|
122 |
+
<label>Configuration Tab Type</label>
|
123 |
<comment><![CDATA[Name for the extension tab on the menu System -> Configuration.]]></comment>
|
124 |
<frontend_type>select</frontend_type>
|
125 |
<source_model>blackchacal_prometheus/system_config_source_tabtypes</source_model>
|
127 |
<show_in_default>1</show_in_default>
|
128 |
<show_in_website>0</show_in_website>
|
129 |
<show_in_store>0</show_in_store>
|
130 |
+
</config_tab_type>
|
131 |
<config_tab_custom translate="label,comment" module="blackchacal_prometheus">
|
132 |
<label>Configuration Tab Name - Custom Name</label>
|
133 |
<comment><![CDATA[]]></comment>
|
137 |
<show_in_website>0</show_in_website>
|
138 |
<show_in_store>0</show_in_store>
|
139 |
<depends>
|
140 |
+
<config_tab_type>custom</config_tab_type>
|
141 |
</depends>
|
142 |
</config_tab_custom>
|
143 |
<config_tab_system translate="label,comment" module="blackchacal_prometheus">
|
150 |
<show_in_website>0</show_in_website>
|
151 |
<show_in_store>0</show_in_store>
|
152 |
<depends>
|
153 |
+
<config_tab_type>system</config_tab_type>
|
154 |
</depends>
|
155 |
</config_tab_system>
|
156 |
<config_tab_namespace_position translate="label,comment" module="blackchacal_prometheus">
|
162 |
<show_in_website>0</show_in_website>
|
163 |
<show_in_store>0</show_in_store>
|
164 |
<depends>
|
165 |
+
<config_tab_type>namespace</config_tab_type>
|
166 |
</depends>
|
167 |
</config_tab_namespace_position>
|
168 |
<config_tab_custom_position translate="label,comment" module="blackchacal_prometheus">
|
174 |
<show_in_website>0</show_in_website>
|
175 |
<show_in_store>0</show_in_store>
|
176 |
<depends>
|
177 |
+
<config_tab_type>custom</config_tab_type>
|
178 |
</depends>
|
179 |
</config_tab_custom_position>
|
180 |
</fields>
|
app/design/adminhtml/default/default/layout/blackchacal_prometheus.xml
CHANGED
@@ -29,6 +29,9 @@
|
|
29 |
</reference>
|
30 |
</adminhtml_prometheus_index>
|
31 |
<adminhtml_prometheus_edit>
|
|
|
|
|
|
|
32 |
<reference name="left">
|
33 |
<block type="blackchacal_prometheus/adminhtml_prometheus_edit_tabs" name="prometheus_edit_tabs">
|
34 |
<block type="blackchacal_prometheus/adminhtml_prometheus_edit_tab_general" name="prometheus_edit_tab_general" />
|
29 |
</reference>
|
30 |
</adminhtml_prometheus_index>
|
31 |
<adminhtml_prometheus_edit>
|
32 |
+
<reference name="head">
|
33 |
+
<action method="addItem"><type>skin_js</type><name>blackchacal_prometheus/js/prometheus.js</name></action>
|
34 |
+
</reference>
|
35 |
<reference name="left">
|
36 |
<block type="blackchacal_prometheus/adminhtml_prometheus_edit_tabs" name="prometheus_edit_tabs">
|
37 |
<block type="blackchacal_prometheus/adminhtml_prometheus_edit_tab_general" name="prometheus_edit_tab_general" />
|
package.xml
CHANGED
@@ -1,18 +1,25 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Prometheus</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Prometheus allows the creation of Magento 1.7+ extensions.</summary>
|
10 |
<description>Prometheus allows the creation of Magento 1.7+ extensions.</description>
|
11 |
-
<notes>v0.1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
<authors><author><name>Ricardo Tonet</name><user>BlackChacal</user><email>ribeiro.tonet@gmail.com</email></author></authors>
|
13 |
-
<date>2015-
|
14 |
-
<time>22:
|
15 |
-
<contents><target name="magecommunity"><dir name="BlackChacal"><dir name="Prometheus"><dir name="Block"><dir name="Adminhtml"><dir name="Prometheus"><dir name="Edit"><file name="Form.php" hash="4d11e041c904626d17e6d3ac42fe8751"/><dir name="Tab"><file name="General.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Prometheus</name>
|
4 |
+
<version>0.1.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Prometheus allows the creation of Magento 1.7+ extensions.</summary>
|
10 |
<description>Prometheus allows the creation of Magento 1.7+ extensions.</description>
|
11 |
+
<notes>v0.1.1
|
12 |
+
- Filter user data on general settings tab;
|
13 |
+
- Get actual system tabs instead of hardcoded values;
|
14 |
+
- Add "Save and Continue Edit" button to extension edit page;
|
15 |
+
-Update system source model to return existent configuration tabs, instead of hardcoded;
|
16 |
+
- Add system source model to return top admin menu items;
|
17 |
+
- Fix default configuration tab name selection on extension new/edit page;
|
18 |
+
- Hide extension grid if prometheus is disabled.</notes>
|
19 |
<authors><author><name>Ricardo Tonet</name><user>BlackChacal</user><email>ribeiro.tonet@gmail.com</email></author></authors>
|
20 |
+
<date>2015-12-06</date>
|
21 |
+
<time>19:22:48</time>
|
22 |
+
<contents><target name="magecommunity"><dir name="BlackChacal"><dir name="Prometheus"><dir name="Block"><dir name="Adminhtml"><dir name="Prometheus"><dir name="Edit"><file name="Form.php" hash="4d11e041c904626d17e6d3ac42fe8751"/><dir name="Tab"><file name="General.php" hash="ce559e828a2dc25104101d6b89535546"/></dir><file name="Tabs.php" hash="702875cbf02284f8d814a144fd145e26"/></dir><file name="Edit.php" hash="e8eea35c7217b76d5cc239a3aa37feb8"/><file name="Grid.php" hash="d3000488bb6dadfd4c0d57005edb5c1b"/></dir><file name="Prometheus.php" hash="5b3e6f76247ceab03051320fa633294b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="c73f9831be34d8c18e909c5e2c38becc"/></dir><dir name="Model"><dir name="Config"><file name="Group.php" hash="6baeb301a5ab0e0492a1bdd579a3f0af"/><file name="Option.php" hash="c91c72e19bd6e8d642a56d688091a893"/></dir><dir name="Extension"><dir name="File"><dir name="Content"><dir name="Php"><file name="Classwriter.php" hash="8a9f344cb3f9adba8c23bff08d2ca2d5"/></dir><file name="Writer.php" hash="c949f0b3a652312326cdbdc38a4cd8e9"/><dir name="Xml"><file name="Configwriter.php" hash="ad846114d78652575a316a43bd1113ff"/><file name="Layoutwriter.php" hash="3dcadb828efd2e0c97b5c0a07b5a404e"/></dir></dir><file name="Writer.php" hash="e8f0eb3557f106b2bda753d576b60b0a"/></dir><file name="Writer.php" hash="9552c4663155d233a783f156d1530b41"/></dir><file name="Extension.php" hash="e42125754d11314e6d520b0ede4bad31"/><dir name="Resource"><dir name="Config"><dir name="Group"><file name="Collection.php" hash="ee5e7b5e6d090b196fa57a3a6683971b"/></dir><file name="Group.php" hash="a438c8ec8eb55064f2541d8fda8074fb"/><dir name="Option"><file name="Collection.php" hash="ec817a6630b1609f5a0154c125168baa"/></dir><file name="Option.php" hash="efcff0253a8ffba267d3791dde7c4a4d"/></dir><dir name="Extension"><file name="Collection.php" hash="ce629599b9bf4a7cc04ca308799a98ed"/></dir><file name="Extension.php" hash="b63ebbc48862e54f6e90b88bb87e98ea"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Action.php" hash="10ab280188e3b5586c90739cca331754"/><file name="Codepool.php" hash="c9d809872cacbefb3ea000a5d3ff3520"/><file name="Systemmenu.php" hash="852b66a1dd823d7d05e56f080417a0c6"/><file name="Systemtabs.php" hash="2ed23a64facd33e0718c0b1e24387308"/><file name="Tabtypes.php" hash="deb9c86eb9fcccc178171f04be460118"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="PrometheusController.php" hash="29b402cfeda16311d6490914cccce236"/></dir></dir><dir name="etc"><file name="LICENSE_AFL.txt" hash="45a399f2095030865fb962263ccd7506"/><file name="adminhtml.xml" hash="8da979de8efdd5d05f7e2830c51a15cc"/><file name="config.xml" hash="f7a42e6ae2ad09c9a56cf27de2d23620"/><dir name="source"><file name="extension_adminhtml_xml.txt" hash="e8c5ab77459217f71895d8f19f4dc2b3"/><file name="extension_config_xml.txt" hash="2dc1c45292ace28bfc6e4beda3c85365"/><file name="extension_system_xml.txt" hash="2f4c1d4b7d58956cac55b374bcff2622"/><file name="extension_system_xml_field.txt" hash="96d5122efded479cc4f8360463374e4b"/><file name="extension_system_xml_group.txt" hash="c998dbba9aa842cad17a1477e517fbd4"/><file name="modules_config_xml.txt" hash="e0e32c7bec4447e6911471ebb7cb9cb8"/></dir><file name="system.xml" hash="7227a13ad7e2aa4f70c22db12de99833"/></dir><dir name="sql"><dir name="prometheus_setup"><file name="install-0.1.0.php" hash="e460eb721e7faff97b1b5ea5799de363"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="BlackChacal_Prometheus.csv" hash="b7463ebfb30d1413701916b897a02039"/></dir></target><target name="mageetc"><dir name="modules"><file name="BlackChacal_Prometheus.xml" hash="817f978ce49863913d49625a9b7662e5"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="blackchacal_prometheus.xml" hash="518f3848dd8944adfe24de40f5846849"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="blackchacal_prometheus"><dir name="js"><file name="prometheus.js" hash="1a984ba1d7e66efd38e2796066fc6aa6"/></dir></dir></dir></dir></dir></target></contents>
|
23 |
<compatible/>
|
24 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
25 |
</package>
|
skin/adminhtml/default/default/blackchacal_prometheus/js/prometheus.js
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* BlackChacal_Prometheus
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
7 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
8 |
+
* It is also available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/afl-3.0.php
|
10 |
+
*
|
11 |
+
* DISCLAIMER
|
12 |
+
*
|
13 |
+
* Do not edit or add to this file if you wish to upgrade Prometheus to newer
|
14 |
+
* versions in the future. If you wish to customize Prometheus for your
|
15 |
+
* needs please contact the author for more information.
|
16 |
+
*
|
17 |
+
* @category BlackChacal
|
18 |
+
* @package BlackChacal_Prometheus
|
19 |
+
* @copyright Copyright (c) 2015 BlackChacal <ribeiro.tonet@gmail.com>
|
20 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
21 |
+
*/
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* This file contains several Js functions necessary for the proper working of the BlackChacal_Prometheus extension.
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Sets the default configuration tab name based on the configuration tab type value. It sets the value on page load and
|
30 |
+
* when the configuration tab type value changes.
|
31 |
+
*
|
32 |
+
* @public
|
33 |
+
*
|
34 |
+
* @param {string} onloadName
|
35 |
+
* @param {string} namespaceName
|
36 |
+
* @param {string} namespaceLabel
|
37 |
+
* @param {string} systemName
|
38 |
+
* @param {string} systemLabel
|
39 |
+
* @return {void}
|
40 |
+
*/
|
41 |
+
function setDefaultConfigTabName(onloadName, namespaceName, namespaceLabel, systemName, systemLabel)
|
42 |
+
{
|
43 |
+
document.observe('dom:loaded', function() {
|
44 |
+
$('config_system_tab_name').setValue(onloadName);
|
45 |
+
$('config_tab_type').on('change', function () {
|
46 |
+
var name,
|
47 |
+
label,
|
48 |
+
$tabType = $('config_tab_type').getValue();
|
49 |
+
|
50 |
+
switch ($tabType) {
|
51 |
+
case 'system':
|
52 |
+
name = systemName;
|
53 |
+
label = systemLabel;
|
54 |
+
break;
|
55 |
+
case 'namespace':
|
56 |
+
name = namespaceName;
|
57 |
+
label = namespaceLabel;
|
58 |
+
break;
|
59 |
+
default:
|
60 |
+
name = '';
|
61 |
+
label = '';
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
$('config_tab_name').setValue(name);
|
65 |
+
$('config_tab_label').setValue(label);
|
66 |
+
$('config_system_tab_name').setValue(name);
|
67 |
+
});
|
68 |
+
});
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Sets the default configuration system tab label when the configuration tab name select changes.
|
73 |
+
*
|
74 |
+
* @public
|
75 |
+
*
|
76 |
+
* @return {void}
|
77 |
+
*/
|
78 |
+
function setDefaultConfigSystemTabLabel()
|
79 |
+
{
|
80 |
+
document.observe('dom:loaded', function() {
|
81 |
+
$('config_system_tab_name').on('change', function () {
|
82 |
+
var label = this.options[this.selectedIndex].innerHTML;
|
83 |
+
$('config_tab_label').setValue(label);
|
84 |
+
});
|
85 |
+
});
|
86 |
+
}
|