RazvanMocanu_Devtools - Version 0.0.3

Version Notes

This extension was made for my personal use.
If you find it useful or think it should contain other features, feel free to contact me.

Download this release

Release Info

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


Code changes from version 0.0.2 to 0.0.3

app/code/community/RazvanMocanu/Devtools/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class RazvanMocanu_Devtools_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ }
app/code/community/RazvanMocanu/Devtools/Model/Booleanselect.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class RazvanMocanu_Devtools_Model_Booleanselect
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => true, 'label' => Mage::helper('devtools')->__('Enabled')),
9
+ array('value' => false, 'label' => Mage::helper('devtools')->__('Disabled')),
10
+ );
11
+ }
12
+
13
+ }
app/code/community/RazvanMocanu/Devtools/Model/Observer.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class RazvanMocanu_Devtools_Model_Observer extends Varien_Event_Observer
3
+ {
4
+ public function __construct()
5
+ {
6
+ }
7
+ public function highlightBlocks($observer)
8
+ {
9
+
10
+ if((Mage::getDesign()->getArea() == 'frontend') && (Mage::getStoreConfig('devtools_options/block_info_settings/block_info_enabled'))) {
11
+
12
+ $argBefore = $observer->getBlock()->getYourCustomParam();
13
+
14
+ $_currentBlock = $observer->getBlock();
15
+ $_blockName = $_currentBlock->getNameInLayout();
16
+ $_blockTemplate = $_currentBlock->getTemplateFile();
17
+
18
+ if($_blockName == 'header') {
19
+ //var_dump($_currentBlock);
20
+ }
21
+
22
+ // get config for encapsulating tag
23
+ $_wrapperTag = Mage::getStoreConfig('devtools_options/block_info_settings/tag_select');
24
+ if($_wrapperTag == null) {
25
+ $_wrapperTag = 'comment';
26
+ }
27
+
28
+ if(($_blockName == 'root') || ($_blockName == 'head') || (($_currentBlock->getParentBlock() != null) && ($_currentBlock->getParentBlock()->getNameInLayout() == 'head'))) {
29
+ $_wrapperTag = 'comment';
30
+ }
31
+
32
+ // get config for show_block_name
33
+ $_showBlockName = Mage::getStoreConfig('devtools_options/block_info_settings/show_block_name');
34
+ // prepare content for block name
35
+ $_blockNameContent = '';
36
+ if($_showBlockName) {
37
+ $_blockNameContent = ' BlockName="'.$_blockName.'"';
38
+ }
39
+
40
+ // get config for show_block_template
41
+ $_showTemplate = Mage::getStoreConfig('devtools_options/block_info_settings/show_block_template');
42
+ // prepare content for block name
43
+ $_blockTemplateContent = '';
44
+ if($_showTemplate) {
45
+ $_blockTemplateContent = ' BlockTemplate="'.$_blockTemplate.'"';
46
+ }
47
+
48
+ // get config for show_block_data
49
+ $_showData = Mage::getStoreConfig('devtools_options/block_info_settings/show_block_data');
50
+ // prepare content for block data
51
+ $_blockDataContent = '';
52
+ if($_showData) {
53
+
54
+ $_currentData = '';
55
+
56
+ //get first level of data in array
57
+ //if the value is array it will not be parsed
58
+ foreach($_currentBlock->debug() as $key=>$value){
59
+ if($key != "text") {
60
+ if(!is_array($value)){
61
+ $_currentData .= $key . ':' . $value .'; ';
62
+ }
63
+ else {
64
+ $_currentData .= $key . ':' . 'ARRAY' .'; ';
65
+ }
66
+ }
67
+ }
68
+
69
+ $_blockDataContent = ' Data="'.$_currentData.'"';
70
+ }
71
+
72
+ //get config for show_on_hover
73
+ $_showOnHover = Mage::getStoreConfig('devtools_options/block_info_settings/show_on_hover');
74
+ $_blockHoverContent = '';
75
+ if($_showOnHover) {
76
+ $_blockHoverContent = ' title="'.$_blockTemplate.'" ';
77
+ }
78
+
79
+ $normalOutput = $observer->getTransport()->getHtml();
80
+
81
+
82
+ $_showEmptyBlocks = Mage::getStoreConfig('devtools_options/block_info_settings/show_empty_blocks');
83
+
84
+
85
+ if(!$_showEmptyBlocks && !$normalOutput) {
86
+
87
+ }
88
+ else {
89
+ if($_wrapperTag == 'comment') {
90
+ $normalOutput = '<!-- Begin'.$_blockNameContent.$_blockTemplateContent.$_blockDataContent.' -->'."\n".$normalOutput."\n".'<!-- End'.$_blockNameContent.' -->';
91
+ }
92
+
93
+ if($_wrapperTag == 'section') {
94
+ $normalOutput = '<section'.$_blockNameContent.$_blockTemplateContent.$_blockDataContent.'>'."\n".$normalOutput."\n".'</section>';
95
+ }
96
+
97
+ if($_wrapperTag == 'div') {
98
+ $normalOutput = '<div'.$_blockHoverContent.$_blockNameContent.$_blockTemplateContent.$_blockDataContent.'>'."\n".$normalOutput."\n".'</div>';
99
+ }
100
+ }
101
+
102
+ $observer->getTransport()->setHtml( $argBefore . $normalOutput );
103
+
104
+ }
105
+ }
106
+
107
+ }
app/code/community/RazvanMocanu/Devtools/Model/Tagselect.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class RazvanMocanu_Devtools_Model_Tagselect
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 'comment', 'label' => Mage::helper('devtools')->__('Comment block')),
9
+ array('value' => 'section', 'label' => Mage::helper('devtools')->__('Section')),
10
+ array('value' => 'div', 'label' => Mage::helper('devtools')->__('Div')),
11
+ );
12
+ }
13
+
14
+ }
app/code/community/RazvanMocanu/Devtools/changes.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
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
app/code/community/RazvanMocanu/Devtools/etc/config.xml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <RazvanMocanu_Devtools>
5
+ <version>0.0.3</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 ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>razvanMocanu_devtools/booleanselect</source_model>
31
+ <comment>If enabled this will add information about each block in the HTML source. Below you can configure which information is added.</comment>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </block_info_enabled>
37
+ <tag_select>
38
+ <label>Tag to use</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>razvanMocanu_devtools/tagselect</source_model>
41
+ <comment>This tag will encapsulate the block. The root block, head block and children of head block will be encapsulated in comments regardless of this selection.</comment>
42
+ <sort_order>2</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </tag_select>
47
+ <show_block_name>
48
+ <label>Show Block Name</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>razvanMocanu_devtools/booleanselect</source_model>
51
+ <comment>If enabled the block name will be included as attribute in the encapsulating tag.</comment>
52
+ <sort_order>3</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </show_block_name>
57
+ <show_block_template>
58
+ <label>Show Block Template</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>razvanMocanu_devtools/booleanselect</source_model>
61
+ <comment>If enabled the block template will be included as attribute in the encapsulating tag.</comment>
62
+ <sort_order>4</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ </show_block_template>
67
+ <show_block_data>
68
+ <label>Show Block Data</label>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>razvanMocanu_devtools/booleanselect</source_model>
71
+ <comment>If enabled the block data will be included as attribute in the encapsulating tag.</comment>
72
+ <sort_order>5</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </show_block_data>
77
+ <show_on_hover>
78
+ <label>Use title</label>
79
+ <frontend_type>select</frontend_type>
80
+ <source_model>razvanMocanu_devtools/booleanselect</source_model>
81
+ <comment>If enabled and div used as encapsulating tag, this will ad the title attribute to the encapsulating div so it will display the template file on hover.</comment>
82
+ <sort_order>6</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </show_on_hover>
87
+ <show_empty_blocks>
88
+ <label>Encapsulate Empty Blocks</label>
89
+ <frontend_type>select</frontend_type>
90
+ <source_model>razvanMocanu_devtools/booleanselect</source_model>
91
+ <comment>If enabled the block will be encapsulated even if it is empty.</comment>
92
+ <sort_order>7</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_empty_blocks>
97
+ </fields>
98
+ </block_info_settings>
99
+ </groups>
100
+ </devtools_options>
101
+ </sections>
102
+ </config>
app/etc/modules/RazvanMocanu_Devtools.xml ADDED
@@ -0,0 +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>
package.xml CHANGED
@@ -1,27 +1,23 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>RazvanMocanu_Devtools</name>
4
- <version>0.0.2</version>
5
  <stability>stable</stability>
6
- <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>See extended block information inside the HTML source.</summary>
10
  <description>This module wraps each block in comment tags and ads information about the block like name, template and data.&#xD;
11
  &#xD;
12
  This allows the developer to quickly identify blocks and find the associated templates.&#xD;
13
  &#xD;
14
  It doesn't work as the template hints. All the information is contained inside the HTLM which you can inspect with the browser.</description>
15
- <notes>Display block data:&#xD;
16
- - block name&#xD;
17
- - block template&#xD;
18
- - block data&#xD;
19
- &#xD;
20
- Easy inspect block parte/children.</notes>
21
  <authors><author><name>Razvan Mocanu</name><user>razvan_mocanu</user><email>razvan_mocanu@yahoo.com</email></author></authors>
22
- <date>2014-06-20</date>
23
- <time>20:39:30</time>
24
- <contents><target name="mageetc"><dir name="."><dir name="app"><dir name="etc"><dir name="modules"><file name="RazvanMocanu_Devtools.xml" hash=""/></dir></dir></dir></dir></target></contents>
25
  <compatible/>
26
- <dependencies><required><php><min>1.5.2</min><max>1.5.5</max></php></required></dependencies>
27
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>RazvanMocanu_Devtools</name>
4
+ <version>0.0.3</version>
5
  <stability>stable</stability>
6
+ <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Inserts block information inside the HTML source.</summary>
10
  <description>This module wraps each block in comment tags and ads information about the block like name, template and data.&#xD;
11
  &#xD;
12
  This allows the developer to quickly identify blocks and find the associated templates.&#xD;
13
  &#xD;
14
  It doesn't work as the template hints. All the information is contained inside the HTLM which you can inspect with the browser.</description>
15
+ <notes>This extension was made for my personal use.&#xD;
16
+ If you find it useful or think it should contain other features, feel free to contact me.</notes>
 
 
 
 
17
  <authors><author><name>Razvan Mocanu</name><user>razvan_mocanu</user><email>razvan_mocanu@yahoo.com</email></author></authors>
18
+ <date>2014-06-30</date>
19
+ <time>07:57:02</time>
20
+ <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="Booleanselect.php" hash="8e8c9f59d97b9fe67291b93c4e59da7c"/><file name="Observer.php" hash="6f2e2384b379e259d236fd137a3a98bc"/><file name="Tagselect.php" hash="29c03ea79a9567aedd52652c7cd499ae"/></dir><file name="changes.txt" hash="5c04bfae5f1d19eb2c71b6e66818ae9a"/><dir name="etc"><file name="config.xml" hash="1feb0feb485089d57a7d915aa4919978"/><file name="system.xml" hash="bb328fb1a9c271b64593fc2ccb8e89a9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RazvanMocanu_Devtools.xml" hash="ddb82da5aa2c298e79a7cfff58985999"/></dir></target></contents>
21
  <compatible/>
22
+ <dependencies><required><php><min>5.2.0</min><max>5.5.0</max></php></required></dependencies>
23
  </package>