RazvanMocanu_Devtools - Version 1.0.1

Version Notes

New functionality.
Code refactored.

Download this release

Release Info

Developer Razvan Mocanu
Extension RazvanMocanu_Devtools
Version 1.0.1
Comparing to
See all releases


Code changes from version 0.0.5 to 1.0.1

app/code/community/RazvanMocanu/Devtools/Helper/Data.php CHANGED
@@ -1,5 +1,49 @@
1
- <?php
2
-
3
- class RazvanMocanu_Devtools_Helper_Data extends Mage_Core_Helper_Abstract {
4
-
5
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Development Tools
4
+ *
5
+ * PHP version 5.5
6
+ *
7
+ * @category RazvanMocanu
8
+ * @package RazvanMocanu_Devtools
9
+ * @author Razvan Mocanu <razvan@mocanu.biz>
10
+ * @copyright 2015 Razvan Mocanu (http://mocanu.biz)
11
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12
+ * @link http://mocanu.biz
13
+ */
14
+
15
+ /**
16
+ * Devtools helper class
17
+ *
18
+ * PHP version 5.5
19
+ *
20
+ * @category RazvanMocanu_Devtools
21
+ * @package RazvanMocanu_Devtools
22
+ * @author Razvan Mocanu <razvan@mocanu.biz>
23
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
24
+ * @link http://mocanu.biz
25
+ */
26
+
27
+ class RazvanMocanu_Devtools_Helper_Data extends Mage_Core_Helper_Abstract
28
+ {
29
+
30
+ /**
31
+ * Makes the string representation of the tag attribute
32
+ *
33
+ * @param boolean $isUsed (If false returns empty string)
34
+ * @param string $attributeName (The attribute name)
35
+ * @param string $attributeValue (The attribute value)
36
+ * @param bool $onNewLine (If true, a new line char is added before)
37
+ *
38
+ * @return string
39
+ */
40
+ public function makeAttribute($isUsed, $attributeName, $attributeValue, $onNewLine = true)
41
+ {
42
+ if ($isUsed) {
43
+ return ($onNewLine? "\n" : "")
44
+ . ' ' . $attributeName . '="' . $attributeValue . '"';
45
+ } else {
46
+ return "";
47
+ }
48
+ }
49
+ }
app/code/community/RazvanMocanu/Devtools/Model/Observer.php CHANGED
@@ -1,133 +1,359 @@
1
- <?php
2
-
3
- class RazvanMocanu_Devtools_Model_Observer extends Varien_Event_Observer {
4
- public function __construct() {
5
- }
6
-
7
- public function highlightBlocks($observer) {
8
- if ((Mage::getDesign()->getArea() == 'frontend') && (Mage::getStoreConfig('devtools_options/block_info_settings/block_info_enabled'))) {
9
- $observer->getTransport()->setHtml($this->updateContent($observer));
10
- }
11
- }
12
-
13
- private function updateContent($observer) {
14
-
15
- $blockDetails = $this->prepareContent($observer);
16
-
17
- $_showEmptyBlocks = Mage::getStoreConfig('devtools_options/block_info_settings/show_empty_blocks');
18
-
19
- if ((!$_showEmptyBlocks && !$blockDetails['blockInitialContent'])) {
20
- $blockDetails['wrapperTag'] = "empty";
21
- }
22
-
23
- switch($blockDetails['wrapperTag']):
24
- case 'section':
25
- $newContent = $this->prepareSection($blockDetails);
26
- break;
27
- case 'div':
28
- $newContent = $this->prepareDiv($blockDetails);
29
- break;
30
- case 'comment':
31
- $newContent = $this->prepareComment($blockDetails);
32
- break;
33
- default:
34
- $newContent = '';
35
- endswitch;
36
-
37
- return $newContent;
38
- }
39
-
40
- private function prepareContent($observer) {
41
- $_currentBlock = $observer->getBlock();
42
-
43
- $_blockDetails = array();
44
- $_blockDetails['wrapperTag'] = $this->getWrapperTag($_currentBlock);
45
- $_blockDetails['blockName'] = $this->getBlockNameContent($_currentBlock);
46
- $_blockDetails['blockTemplate'] = $this->getBlockTemplateContent($_currentBlock);
47
- $_blockDetails['blockData'] = $this->getBlockDataContent($_currentBlock);
48
- $_blockDetails['blockHover'] = $this->getBlockHoverContent($_currentBlock);
49
- $_blockDetails['blockInitialContent'] = $observer->getTransport()->getHtml();
50
-
51
- return $_blockDetails;
52
- }
53
-
54
- private function getWrapperTag($theBlock) {
55
- $_wrapperTag = Mage::getStoreConfig('devtools_options/block_info_settings/tag_select');
56
- // Set wrapper tag to comment if the block is root, head or contained in head.
57
- // In this cases no other tag can be used.
58
- if (($theBlock == 'root') ||
59
- ($theBlock == 'head') ||
60
- (($theBlock->getParentBlock() != null) &&
61
- ($theBlock->getParentBlock()->getNameInLayout() == 'head')
62
- )
63
- ) {
64
- $_wrapperTag = 'comment';
65
- }
66
- return $_wrapperTag;
67
- }
68
-
69
- private function getBlockNameContent($theBlock) {
70
- if (Mage::getStoreConfig('devtools_options/block_info_settings/show_block_name')) {
71
- return ' BlockName="' . $theBlock->getNameInLayout() . '"';
72
- } else {
73
- return "";
74
- }
75
- }
76
-
77
- private function getBlockTemplateContent($theBlock) {
78
- if (Mage::getStoreConfig('devtools_options/block_info_settings/show_block_template')) {
79
- return ' BlockTemplate="' . $theBlock->getTemplateFile() . '"';
80
- } else {
81
- return "";
82
- }
83
- }
84
-
85
- private function getBlockDataContent($theBlock) {
86
-
87
- if (Mage::getStoreConfig('devtools_options/block_info_settings/show_block_data')) {
88
- return $this->prepareDataContent($theBlock);
89
- } else {
90
- return "";
91
- }
92
- }
93
-
94
- private function prepareDataContent($theBlock) {
95
-
96
- $_currentData = '';
97
-
98
- //get first level of data in array
99
- //if the value is array it will not be parsed
100
- foreach ($theBlock->debug() as $key => $value) {
101
- if ($key != "text") {
102
- if (!is_array($value)) {
103
- $_currentData .= $key . ':' . $value . '; ';
104
- } else {
105
- $_currentData .= $key . ':' . 'ARRAY' . '; ';
106
- }
107
- }
108
- }
109
-
110
- return ' Data="' . $_currentData . '"';
111
- }
112
-
113
- private function getBlockHoverContent($theBlock) {
114
-
115
- if (Mage::getStoreConfig('devtools_options/block_info_settings/show_on_hover')) {
116
- return ' title="' . $theBlock->getTemplateFile() . '" ';
117
- } else {
118
- return "";
119
- }
120
- }
121
-
122
- private function prepareSection($blockDetails) {
123
- return '<section' . $blockDetails['blockName'] . $blockDetails['blockTemplate'] . $blockDetails['blockData'] . '>' . "\n" . $blockDetails['blockInitialContent'] . "\n" . '</section>';
124
- }
125
-
126
- private function prepareDiv($blockDetails) {
127
- return '<div' . $blockDetails['blockHover'] . $blockDetails['blockName'] . $blockDetails['blockTemplate'] . $blockDetails['blockData'] . '>' . "\n" . $blockDetails['blockInitialContent'] . "\n" . '</div>';
128
- }
129
-
130
- private function prepareComment($blockDetails) {
131
- return '<!-- Begin' . $blockDetails['blockName'] . $blockDetails['blockTemplate'] . $blockDetails['blockData'] . ' -->' . "\n" . $blockDetails['blockInitialContent'] . "\n" . '<!-- End' . $blockDetails['blockName'] . ' -->';
132
- }
133
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Development Tools
4
+ *
5
+ * PHP version 5.5
6
+ *
7
+ * @category RazvanMocanu
8
+ * @package RazvanMocanu_Devtools
9
+ * @author Razvan Mocanu <razvan@mocanu.biz>
10
+ * @copyright 2015 Razvan Mocanu (http://mocanu.biz)
11
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12
+ * @link http://mocanu.biz
13
+ */
14
+
15
+ /**
16
+ * Class RazvanMocanu_Devtools_Model_Observer
17
+ *
18
+ * @category RazvanMocanu/Devtools
19
+ * @package RazvanMocanu
20
+ * @author Razvan Mocanu <razvan@mocanu.biz>
21
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
22
+ * @link http://mocanu.biz
23
+ */
24
+ class RazvanMocanu_Devtools_Model_Observer extends Varien_Event_Observer
25
+ {
26
+
27
+ private $_helper;
28
+
29
+ /**
30
+ * Constructor
31
+ */
32
+ public function __construct()
33
+ {
34
+ $this->_helper = Mage::helper('devtools');
35
+ }
36
+
37
+ /**
38
+ * Replaces the current content with the new content including information data.
39
+ *
40
+ * @param Varien_Event_Observer $observer (The current observer.)
41
+ *
42
+ * @return void
43
+ */
44
+ public function highlightBlocks($observer)
45
+ {
46
+ if ((Mage::getDesign()->getArea() == 'frontend')
47
+ && (Mage::getStoreConfig('devtools_options/block_info_settings/block_info_enabled'))) {
48
+ $observer->getTransport()->setHtml($this->_updateContent($observer));
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Updates the content with the block information.
54
+ *
55
+ * @param Varien_Event_Observer $observer (The current observer.)
56
+ *
57
+ * @return string
58
+ */
59
+ private function _updateContent($observer)
60
+ {
61
+
62
+ $blockDetails = $this->_prepareContentData($observer);
63
+
64
+ $_showEmptyBlocks = Mage::getStoreConfig('devtools_options/block_info_settings/show_empty_blocks');
65
+
66
+ if ((!$_showEmptyBlocks && !$blockDetails['blockInitialContent'])) {
67
+ $blockDetails['wrapperTag'] = "empty";
68
+ }
69
+
70
+ return $this->_prepareContent($blockDetails, $blockDetails['wrapperTag']);
71
+ }
72
+
73
+ /**
74
+ * Prepares an array containing the block information
75
+ *
76
+ * @param Varien_Event_Observer $observer (The current observer.)
77
+ *
78
+ * @return array
79
+ */
80
+ private function _prepareContentData($observer)
81
+ {
82
+
83
+ $_currentBlock = $observer->getBlock();
84
+
85
+ $_blockDetails = array();
86
+ $_blockDetails['wrapperTag'] = $this->_getWrapperTag($_currentBlock)? $this->_getWrapperTag($_currentBlock) : 'empty';
87
+ $_blockDetails['isRoot'] = $this->_getBlockIsRoot($_currentBlock);
88
+ $_blockDetails['blockName'] = $this->_getBlockNameContent($_currentBlock);
89
+ $_blockDetails['blockTemplate'] = $this->_getBlockTemplateContent($_currentBlock);
90
+ $_blockDetails['CMSData'] = $this->_getBlockCMSInfoContent($_currentBlock);
91
+ $_blockDetails['blockData'] = $this->_getBlockDataContent($_currentBlock);
92
+ $_blockDetails['blockHover'] = $this->_getBlockHoverContent($_currentBlock);
93
+ $_blockDetails['blockInitialContent'] = $observer->getTransport()->getHtml();
94
+
95
+ return $_blockDetails;
96
+ }
97
+
98
+ /**
99
+ * Get the wrapper tag from config
100
+ *
101
+ * @param Mage_Core_Block_Abstract $theBlock (The actual block extends the core block)
102
+ *
103
+ * @return string
104
+ */
105
+ private function _getWrapperTag($theBlock)
106
+ {
107
+ $_wrapperTag = Mage::getStoreConfig('devtools_options/block_info_settings/tag_select');
108
+ // Set wrapper tag to comment if the block is root, head or contained in head.
109
+ // In this cases no other tag can be used.
110
+
111
+ $specialBlocks = array('root','head');
112
+
113
+ if (in_array($theBlock, $specialBlocks) ||
114
+ ($theBlock->getParentBlock() === null ? false : ($theBlock->getParentBlock()->getNameInLayout() == 'head'))
115
+ ) {
116
+ $_wrapperTag = 'comment';
117
+ }
118
+ return $_wrapperTag;
119
+ }
120
+
121
+ /**
122
+ * Checks if the block is the root block
123
+ *
124
+ * @param Mage_Core_Block_Abstract $theBlock (The actual block extends the core block)
125
+ *
126
+ * @return bool
127
+ */
128
+ private function _getBlockIsRoot($theBlock)
129
+ {
130
+ return ($theBlock->getNameInLayout() == 'root');
131
+ }
132
+
133
+ /**
134
+ * Gets the list of update handles for the current page
135
+ *
136
+ * @return string
137
+ */
138
+ private function _getLayoutHandles()
139
+ {
140
+ if (Mage::getStoreConfig('devtools_options/block_info_settings/show_layout_handles')) {
141
+ return "<!-- \n"
142
+ . "Layout update handles: \n - "
143
+ . implode("\n - ", Mage::app()->getLayout()->getUpdate()->getHandles())
144
+ . "\n -->";
145
+ } else {
146
+ return "";
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Get the block name
152
+ *
153
+ * @param Mage_Core_Block_Abstract $theBlock (The actual block extends the core block)
154
+ *
155
+ * @return string
156
+ */
157
+ private function _getBlockNameContent($theBlock)
158
+ {
159
+ return $this->_helper->makeAttribute(
160
+ Mage::getStoreConfig('devtools_options/block_info_settings/show_block_name'),
161
+ 'BlockName',
162
+ $theBlock->getNameInLayout()
163
+ );
164
+ }
165
+
166
+ /**
167
+ * Get the block template
168
+ *
169
+ * @param Mage_Core_Block_Abstract $theBlock (The actual block extends the core block)
170
+ *
171
+ * @return string
172
+ */
173
+ private function _getBlockTemplateContent($theBlock)
174
+ {
175
+ return $this->_helper->makeAttribute(
176
+ Mage::getStoreConfig('devtools_options/block_info_settings/show_block_template'),
177
+ 'BlockTemplate',
178
+ $theBlock->getTemplateFile()
179
+ );
180
+ }
181
+
182
+ /**
183
+ * Get the block data (only partial)
184
+ *
185
+ * @param Mage_Core_Block_Abstract $theBlock (The actual block extends the core block)
186
+ *
187
+ * @return string
188
+ */
189
+ private function _getBlockDataContent($theBlock)
190
+ {
191
+ return $this->_helper->makeAttribute(
192
+ Mage::getStoreConfig('devtools_options/block_info_settings/show_block_data'),
193
+ 'Data',
194
+ $this->_prepareDataContent($theBlock)
195
+ );
196
+ }
197
+
198
+ /**
199
+ * Prepares the block data content
200
+ *
201
+ * @param Mage_Core_Block_Abstract $theBlock (The actual block extends the core block)
202
+ *
203
+ * @return string
204
+ */
205
+ private function _prepareDataContent($theBlock)
206
+ {
207
+
208
+ $_currentData = '';
209
+
210
+ //get first level of data in array
211
+ //if the value is array it will not be parsed
212
+ foreach ($theBlock->debug() as $key => $value) {
213
+ if ($key != "text") {
214
+ if (!is_array($value)) {
215
+ $_currentData .= $key . ':' . $value . '; ';
216
+ } else {
217
+ $_currentData .= $key . ':' . 'ARRAY' . '; ';
218
+ }
219
+ }
220
+ }
221
+
222
+ return $_currentData;
223
+ }
224
+
225
+ /**
226
+ * Get block hover content
227
+ *
228
+ * @param Mage_Core_Block_Abstract $theBlock (The actual block extends the core block)
229
+ *
230
+ * @return string
231
+ */
232
+ private function _getBlockHoverContent($theBlock)
233
+ {
234
+
235
+ if (Mage::getStoreConfig('devtools_options/block_info_settings/show_on_hover')) {
236
+ return ' title="' . $theBlock->getTemplateFile() . '" ';
237
+ } else {
238
+ return "";
239
+ }
240
+ }
241
+
242
+ /**
243
+ * Get information about CMS blocks
244
+ *
245
+ * @param Mage_Core_Block_Abstract $theBlock (The actual block extends the core block)
246
+ *
247
+ * @return string
248
+ */
249
+ private function _getBlockCMSInfoContent($theBlock)
250
+ {
251
+
252
+ if (Mage::getStoreConfig('devtools_options/block_info_settings/show_cms_data')
253
+ && in_array($theBlock->getType(), ["cms/block","cms/page"])
254
+ ) {
255
+
256
+ switch($theBlock->getType()){
257
+ case 'cms/block':
258
+ $CMSInfo = $this->_getBlockCMSBlockInfo($theBlock);
259
+ break;
260
+ case 'cms/page':
261
+ $CMSInfo = $this->_getBlockCMSPageInfo($theBlock);
262
+ break;
263
+ default:
264
+ $CMSInfo = '';
265
+ }
266
+
267
+ return "\n" . 'CMSData="' . $CMSInfo . '"';
268
+ } else {
269
+ return "";
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Get CMS block ID
275
+ *
276
+ * @param Mage_Cms_Block_Block $theBlock (The actual CMS block block.)
277
+ *
278
+ * @return string
279
+ */
280
+ private function _getBlockCMSBlockInfo($theBlock)
281
+ {
282
+
283
+ return 'CMSBlockId: ' . $theBlock->getBlockId();
284
+ }
285
+
286
+ /**
287
+ * Get CMS page Identifier
288
+ *
289
+ * @param Mage_Cms_Block_Page $theBlock (The actual CMS page block.)
290
+ *
291
+ * @return string
292
+ */
293
+ private function _getBlockCMSPageInfo($theBlock)
294
+ {
295
+
296
+ $currentPage = $theBlock->getPage();
297
+ return 'CMSPageIdentifier: ' . $currentPage->getIdentifier();
298
+ }
299
+
300
+ /**
301
+ * Prepares the actual content
302
+ *
303
+ * @param array $blockDetails (Array containing the block details)
304
+ * @param string $contentType (String containing the content type)
305
+ *
306
+ * @return string
307
+ */
308
+ private function _prepareContent($blockDetails, $contentType)
309
+ {
310
+ $content = $blockDetails['blockName']
311
+ . $blockDetails['blockTemplate']
312
+ . $blockDetails['CMSData']
313
+ . $blockDetails['blockData'];
314
+
315
+ $contentTypes = array(
316
+
317
+ 'section' => '<section' . $content . '>'
318
+ . "\n" . $blockDetails['blockInitialContent'] . "\n"
319
+ . '</section>',
320
+
321
+ 'div' => '<div' . $blockDetails['blockHover'] . $content . '>'
322
+ . "\n" . $blockDetails['blockInitialContent'] . "\n"
323
+ . '</div>',
324
+
325
+ 'comment' => "\n" . '<!-- Begin' . $content . ' -->'
326
+ . "\n" . $blockDetails['blockInitialContent'] . "\n"
327
+ . '<!-- End' . $blockDetails['blockName'] . ' -->',
328
+
329
+ 'empty' => ''
330
+ );
331
+
332
+
333
+ $begin = "\n" . '<!-- Begin' . $content . ' -->';
334
+ $end = "\n" . '<!-- End' . $blockDetails['blockName'] . ' -->';
335
+
336
+ if ($blockDetails['isRoot']) {
337
+ $pos = strpos($blockDetails['blockInitialContent'], '<html');
338
+ if ($pos !== false) {
339
+ return substr_replace(
340
+ $blockDetails['blockInitialContent'],
341
+ $this->_getLayoutHandles() . $begin . "\n" . '<html',
342
+ $pos,
343
+ 5
344
+ ) . $end;
345
+ } else {
346
+ $contentTypes['comment'] = $begin
347
+ . $blockDetails['blockInitialContent']
348
+ . $end;
349
+ }
350
+
351
+ } else {
352
+ $contentTypes['comment'] = $begin
353
+ . $blockDetails['blockInitialContent']
354
+ . $end;
355
+ }
356
+
357
+ return $contentTypes[$contentType];
358
+ }
359
+ }
app/code/community/RazvanMocanu/Devtools/Model/Tagselect.php CHANGED
@@ -1,11 +1,49 @@
1
- <?php
2
-
3
- class RazvanMocanu_Devtools_Model_Tagselect {
4
- public function toOptionArray() {
5
- return array(
6
- array('value' => 'comment', 'label' => Mage::helper('devtools')->__('Comment block')),
7
- array('value' => 'section', 'label' => Mage::helper('devtools')->__('Section')),
8
- array('value' => 'div', 'label' => Mage::helper('devtools')->__('Div')),
9
- );
10
- }
11
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Development Tools
4
+ *
5
+ * PHP version 5.5
6
+ *
7
+ * @category RazvanMocanu
8
+ * @package RazvanMocanu_Devtools
9
+ * @author Razvan Mocanu <razvan@mocanu.biz>
10
+ * @copyright 2015 Razvan Mocanu (http://mocanu.biz)
11
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12
+ * @link http://mocanu.biz
13
+ */
14
+
15
+ /**
16
+ * Devtools tag selector model
17
+ *
18
+ * PHP version 5.5
19
+ *
20
+ * @category RazvanMocanu_Devtools
21
+ * @package RazvanMocanu_Devtools
22
+ * @author Razvan Mocanu <razvan@mocanu.biz>
23
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
24
+ * @link http://mocanu.biz
25
+ */
26
+ class RazvanMocanu_Devtools_Model_Tagselect
27
+ {
28
+ /**
29
+ * Defines the tag array.
30
+ *
31
+ * @return array
32
+ */
33
+ public function toOptionArray()
34
+ {
35
+ return array(
36
+ array('value' => 'comment',
37
+ 'label' => Mage::helper('devtools')->__('Comment block')
38
+ ),
39
+
40
+ array('value' => 'section',
41
+ 'label' => Mage::helper('devtools')->__('Section')
42
+ ),
43
+
44
+ array('value' => 'div',
45
+ 'label' => Mage::helper('devtools')->__('Div')
46
+ ),
47
+ );
48
+ }
49
+ }
app/code/community/RazvanMocanu/Devtools/changes.txt CHANGED
@@ -1,16 +1,27 @@
1
- 0.0.2
2
-
3
- - template includes package and theme
4
- - option to add the template file name as div title so it will be displayed on hover
5
-
6
- 0.0.3
7
-
8
- - option to not encapsulate empty blocks
9
-
10
- 0.0.4
11
-
12
- - support PHP 5.6
13
-
14
- 0.0.5
15
-
16
- - code reformat
 
 
 
 
 
 
 
 
 
 
 
1
+ 0.0.2
2
+
3
+ - template includes package and theme
4
+ - option to add the template file name as div title so it will be displayed on hover
5
+
6
+ 0.0.3
7
+
8
+ - option to not encapsulate empty blocks
9
+
10
+ 0.0.4
11
+
12
+ - support PHP 5.6
13
+
14
+ 0.0.5
15
+
16
+ - code reformat
17
+
18
+ 0.0.6
19
+
20
+ - CMS block/page info
21
+ - repositioning root block info after the <!DOCTYPE HTML>
22
+ - layout update handles list
23
+ - some php doc added
24
+
25
+ 1.0.1
26
+
27
+ - refactoring some methods
app/code/community/RazvanMocanu/Devtools/etc/config.xml CHANGED
@@ -1,52 +1,52 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <RazvanMocanu_Devtools>
5
- <version>0.0.5</version>
6
- </RazvanMocanu_Devtools>
7
- </modules>
8
- <global>
9
- <models>
10
- <razvanMocanu_devtools>
11
- <class>RazvanMocanu_Devtools_Model</class>
12
- </razvanMocanu_devtools>
13
- </models>
14
- <helpers>
15
- <devtools>
16
- <class>RazvanMocanu_Devtools_Helper</class>
17
- </devtools>
18
- </helpers>
19
- <events>
20
- <core_block_abstract_to_html_after>
21
- <observers>
22
- <RazvanMocanu_Devtools_Model_Observer>
23
- <type>singleton</type>
24
- <class>razvanMocanu_devtools/observer</class>
25
- <method>highlightBlocks</method>
26
- </RazvanMocanu_Devtools_Model_Observer>
27
- </observers>
28
- </core_block_abstract_to_html_after>
29
- </events>
30
- </global>
31
- <adminhtml>
32
- <acl>
33
- <resources>
34
- <admin>
35
- <children>
36
- <system>
37
- <children>
38
- <config>
39
- <children>
40
- <devtools_options>
41
- <title>Razvan Mocanu Devtools</title>
42
- </devtools_options>
43
- </children>
44
- </config>
45
- </children>
46
- </system>
47
- </children>
48
- </admin>
49
- </resources>
50
- </acl>
51
- </adminhtml>
52
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <RazvanMocanu_Devtools>
5
+ <version>1.0.1</version>
6
+ </RazvanMocanu_Devtools>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <razvanMocanu_devtools>
11
+ <class>RazvanMocanu_Devtools_Model</class>
12
+ </razvanMocanu_devtools>
13
+ </models>
14
+ <helpers>
15
+ <devtools>
16
+ <class>RazvanMocanu_Devtools_Helper</class>
17
+ </devtools>
18
+ </helpers>
19
+ <events>
20
+ <core_block_abstract_to_html_after>
21
+ <observers>
22
+ <RazvanMocanu_Devtools_Model_Observer>
23
+ <type>singleton</type>
24
+ <class>razvanMocanu_devtools/observer</class>
25
+ <method>highlightBlocks</method>
26
+ </RazvanMocanu_Devtools_Model_Observer>
27
+ </observers>
28
+ </core_block_abstract_to_html_after>
29
+ </events>
30
+ </global>
31
+ <adminhtml>
32
+ <acl>
33
+ <resources>
34
+ <admin>
35
+ <children>
36
+ <system>
37
+ <children>
38
+ <config>
39
+ <children>
40
+ <devtools_options>
41
+ <title>Razvan Mocanu Devtools</title>
42
+ </devtools_options>
43
+ </children>
44
+ </config>
45
+ </children>
46
+ </system>
47
+ </children>
48
+ </admin>
49
+ </resources>
50
+ </acl>
51
+ </adminhtml>
52
+ </config>
app/code/community/RazvanMocanu/Devtools/etc/system.xml CHANGED
@@ -1,112 +1,133 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <tabs>
4
- <razvanmocanu translate="label" module="devtools">
5
- <label>Razvan Mocanu Devtools</label>
6
- <sort_order>150</sort_order>
7
- </razvanmocanu>
8
- </tabs>
9
- <sections>
10
- <devtools_options translate="label" module="devtools">
11
- <label>Devtools Config Options</label>
12
- <tab>razvanmocanu</tab>
13
- <frontend_type>text</frontend_type>
14
- <sort_order>1000</sort_order>
15
- <show_in_default>1</show_in_default>
16
- <show_in_website>1</show_in_website>
17
- <show_in_store>1</show_in_store>
18
- <groups>
19
- <block_info_settings translate="label">
20
- <label>Devtools Block Info</label>
21
- <frontend_type>text</frontend_type>
22
- <sort_order>1</sort_order>
23
- <show_in_default>1</show_in_default>
24
- <show_in_website>1</show_in_website>
25
- <show_in_store>1</show_in_store>
26
- <fields>
27
- <block_info_enabled>
28
- <label>Enable Block Info</label>
29
- <frontend_type>select</frontend_type>
30
- <source_model>adminhtml/system_config_source_yesno</source_model>
31
- <comment>If enabled this will add information about each block in the HTML source. Below you
32
- can configure which information is added.
33
- </comment>
34
- <sort_order>1</sort_order>
35
- <show_in_default>1</show_in_default>
36
- <show_in_website>1</show_in_website>
37
- <show_in_store>1</show_in_store>
38
- </block_info_enabled>
39
- <tag_select>
40
- <label>Tag to use</label>
41
- <frontend_type>select</frontend_type>
42
- <source_model>razvanMocanu_devtools/tagselect</source_model>
43
- <comment>This tag will encapsulate the block. The root block, head block and children of
44
- head block will be encapsulated in comments regardless of this selection.
45
- </comment>
46
- <sort_order>2</sort_order>
47
- <show_in_default>1</show_in_default>
48
- <show_in_website>1</show_in_website>
49
- <show_in_store>1</show_in_store>
50
- </tag_select>
51
- <show_block_name>
52
- <label>Show Block Name</label>
53
- <frontend_type>select</frontend_type>
54
- <source_model>adminhtml/system_config_source_yesno</source_model>
55
- <comment>If enabled the block name will be included as attribute in the encapsulating tag.
56
- </comment>
57
- <sort_order>3</sort_order>
58
- <show_in_default>1</show_in_default>
59
- <show_in_website>1</show_in_website>
60
- <show_in_store>1</show_in_store>
61
- </show_block_name>
62
- <show_block_template>
63
- <label>Show Block Template</label>
64
- <frontend_type>select</frontend_type>
65
- <source_model>adminhtml/system_config_source_yesno</source_model>
66
- <comment>If enabled the block template will be included as attribute in the encapsulating
67
- tag.
68
- </comment>
69
- <sort_order>4</sort_order>
70
- <show_in_default>1</show_in_default>
71
- <show_in_website>1</show_in_website>
72
- <show_in_store>1</show_in_store>
73
- </show_block_template>
74
- <show_block_data>
75
- <label>Show Block Data</label>
76
- <frontend_type>select</frontend_type>
77
- <source_model>adminhtml/system_config_source_yesno</source_model>
78
- <comment>If enabled the block data will be included as attribute in the encapsulating tag.
79
- </comment>
80
- <sort_order>5</sort_order>
81
- <show_in_default>1</show_in_default>
82
- <show_in_website>1</show_in_website>
83
- <show_in_store>1</show_in_store>
84
- </show_block_data>
85
- <show_on_hover>
86
- <label>Use title</label>
87
- <frontend_type>select</frontend_type>
88
- <source_model>adminhtml/system_config_source_yesno</source_model>
89
- <comment>If enabled and div used as encapsulating tag, this will ad the title attribute to
90
- the encapsulating div so it will display the template file on hover.
91
- </comment>
92
- <sort_order>6</sort_order>
93
- <show_in_default>1</show_in_default>
94
- <show_in_website>1</show_in_website>
95
- <show_in_store>1</show_in_store>
96
- </show_on_hover>
97
- <show_empty_blocks>
98
- <label>Encapsulate Empty Blocks</label>
99
- <frontend_type>select</frontend_type>
100
- <source_model>adminhtml/system_config_source_yesno</source_model>
101
- <comment>If enabled the block will be encapsulated even if it is empty.</comment>
102
- <sort_order>7</sort_order>
103
- <show_in_default>1</show_in_default>
104
- <show_in_website>1</show_in_website>
105
- <show_in_store>1</show_in_store>
106
- </show_empty_blocks>
107
- </fields>
108
- </block_info_settings>
109
- </groups>
110
- </devtools_options>
111
- </sections>
112
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <razvanmocanu translate="label" module="devtools">
5
+ <label>Razvan Mocanu Devtools</label>
6
+ <sort_order>150</sort_order>
7
+ </razvanmocanu>
8
+ </tabs>
9
+ <sections>
10
+ <devtools_options translate="label" module="devtools">
11
+ <label>Devtools Config Options</label>
12
+ <tab>razvanmocanu</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <block_info_settings translate="label">
20
+ <label>Devtools Block Info</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <block_info_enabled>
28
+ <label>Enable Block Info</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <comment>If enabled this will add information about each block in the HTML source. Below you
32
+ can configure which information is added.
33
+ </comment>
34
+ <sort_order>1</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </block_info_enabled>
39
+ <tag_select>
40
+ <label>Tag to use</label>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>razvanMocanu_devtools/tagselect</source_model>
43
+ <comment>This tag will encapsulate the block. The root block, head block and children of
44
+ head block will be encapsulated in comments regardless of this selection.
45
+ </comment>
46
+ <sort_order>2</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ </tag_select>
51
+ <show_block_name>
52
+ <label>Show Block Name</label>
53
+ <frontend_type>select</frontend_type>
54
+ <source_model>adminhtml/system_config_source_yesno</source_model>
55
+ <comment>If enabled the block name will be included as attribute in the encapsulating tag.
56
+ </comment>
57
+ <sort_order>3</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ </show_block_name>
62
+ <show_block_template>
63
+ <label>Show Block Template</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_yesno</source_model>
66
+ <comment>If enabled the block template will be included as attribute in the encapsulating
67
+ tag.
68
+ </comment>
69
+ <sort_order>4</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </show_block_template>
74
+ <show_block_data>
75
+ <label>Show Block Data</label>
76
+ <frontend_type>select</frontend_type>
77
+ <source_model>adminhtml/system_config_source_yesno</source_model>
78
+ <comment>If enabled the block data will be included as attribute in the encapsulating tag.
79
+ </comment>
80
+ <sort_order>5</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ </show_block_data>
85
+ <show_cms_data>
86
+ <label>Show CMS Data</label>
87
+ <frontend_type>select</frontend_type>
88
+ <source_model>adminhtml/system_config_source_yesno</source_model>
89
+ <comment>If enabled and the block is of CMS type, the ID will be included as attribute in the encapsulating tag.
90
+ </comment>
91
+ <sort_order>6</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ </show_cms_data>
96
+ <show_on_hover>
97
+ <label>Use title</label>
98
+ <frontend_type>select</frontend_type>
99
+ <source_model>adminhtml/system_config_source_yesno</source_model>
100
+ <comment>If enabled and div used as encapsulating tag, this will ad the title attribute to
101
+ the encapsulating div so it will display the template file on hover.
102
+ </comment>
103
+ <sort_order>7</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ </show_on_hover>
108
+ <show_empty_blocks>
109
+ <label>Encapsulate Empty Blocks</label>
110
+ <frontend_type>select</frontend_type>
111
+ <source_model>adminhtml/system_config_source_yesno</source_model>
112
+ <comment>If enabled the block will be encapsulated even if it is empty.</comment>
113
+ <sort_order>8</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </show_empty_blocks>
118
+ <show_layout_handles>
119
+ <label>Layout Update Handles List</label>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>adminhtml/system_config_source_yesno</source_model>
122
+ <comment>If enabled, a comment with the list of handles will be added at the beginning of the page.</comment>
123
+ <sort_order>9</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ </show_layout_handles>
128
+ </fields>
129
+ </block_info_settings>
130
+ </groups>
131
+ </devtools_options>
132
+ </sections>
133
+ </config>
app/etc/modules/RazvanMocanu_Devtools.xml CHANGED
@@ -1,9 +1,9 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <RazvanMocanu_Devtools>
5
- <active>active</active>
6
- <codePool>community</codePool>
7
- </RazvanMocanu_Devtools>
8
- </modules>
9
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <RazvanMocanu_Devtools>
5
+ <active>active</active>
6
+ <codePool>community</codePool>
7
+ </RazvanMocanu_Devtools>
8
+ </modules>
9
+ </config>
package.xml CHANGED
@@ -1,18 +1,27 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>RazvanMocanu_Devtools</name>
4
- <version>0.0.5</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>This module wraps each block in comment tags and ads information about the block. The available information is: name, template and data. This allows the developer to quickly identify blocks and find the associated templates and data. It doesn't work as the template hints. All the information is contained inside the HTLM which you can inspect with the browser. If you are using Firebug, don't forget to set it to show comments. See screenshots.</summary>
10
- <description>This module wraps each block in comment tags and ads information about the block. The available information is: name, template and data. This allows the developer to quickly identify blocks and find the associated templates and data. It doesn't work as the template hints. All the information is contained inside the HTLM which you can inspect with the browser. If you are using Firebug, don't forget to set it to show comments. See screenshots.</description>
11
- <notes>Code refactoring.</notes>
 
 
 
 
 
 
 
 
 
12
  <authors><author><name>Razvan Mocanu</name><user>razvan_mocanu</user><email>razvan_mocanu@yahoo.com</email></author></authors>
13
- <date>2014-10-11</date>
14
- <time>15:23:58</time>
15
- <contents><target name="magecommunity"><dir name="RazvanMocanu"><dir name="Devtools"><dir name="Helper"><file name="Data.php" hash="d845c14710df9b1b2f511fcaa58872ea"/></dir><dir name="Model"><file name="Observer.php" hash="8b45c5b1f962545f4a94fd6f2e613a0e"/><file name="Tagselect.php" hash="ec541a5fcf7c158446a36331ae0f40f2"/></dir><file name="changes.txt" hash="c19a5aac95003791e4ceefaf30a009a6"/><dir name="etc"><file name="config.xml" hash="c7497202fc56f965e389b81ecb22c6d8"/><file name="system.xml" hash="cd479a31494679ded976b751d8091702"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RazvanMocanu_Devtools.xml" hash="949c28e6d2e0a4416716145bb28483d1"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.6.9</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>RazvanMocanu_Devtools</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>- This module wraps each block in comment tags containing information about the block. &#xD;
10
+ - Shows block info in page source: block name, block template, specific CMS block data, other data&#xD;
11
+ - Shows the list of layout update handles for the current page&#xD;
12
+ &#xD;
13
+ This allows the developer to quickly identify blocks and find the associated templates and data. It doesn't work as the template hints. All the information is contained inside the HTML which you can inspect with the browser. If you are using Firebug, don't forget to set it to show comments. See screenshots.</summary>
14
+ <description>- This module wraps each block in comment tags containing information about the block. &#xD;
15
+ - Shows block info in page source: block name, block template, specific CMS block data, other data&#xD;
16
+ - Shows the list of layout update handles for the current page&#xD;
17
+ &#xD;
18
+ This allows the developer to quickly identify blocks and find the associated templates and data. It doesn't work as the template hints. All the information is contained inside the HTML which you can inspect with the browser. If you are using Firebug, don't forget to set it to show comments. See screenshots.</description>
19
+ <notes>New functionality.&#xD;
20
+ Code refactored.</notes>
21
  <authors><author><name>Razvan Mocanu</name><user>razvan_mocanu</user><email>razvan_mocanu@yahoo.com</email></author></authors>
22
+ <date>2015-03-14</date>
23
+ <time>07:06:52</time>
24
+ <contents><target name="magecommunity"><dir name="RazvanMocanu"><dir name="Devtools"><dir name="Helper"><file name="Data.php" hash="d60488db48d25d934463700665be4b12"/></dir><dir name="Model"><file name="Observer.php" hash="763d9a76d69c588759dffbd444b114b2"/><file name="Tagselect.php" hash="79c2d2ce23f05044304a9862848ab4c7"/></dir><file name="changes.txt" hash="53d80db03385c76187e6a018bce7a18e"/><dir name="etc"><file name="config.xml" hash="fbed2f82a4a5c668fd0c7a5154cd7f3b"/><file name="system.xml" hash="b74a7c9e428982171dedee2469017168"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RazvanMocanu_Devtools.xml" hash="945aafcccd52bc69ee057c55b43fe1b6"/></dir></target></contents>
25
  <compatible/>
26
  <dependencies><required><php><min>5.3.0</min><max>5.6.9</max></php></required></dependencies>
27
  </package>