Webgriffe_TphPro - Version 1.1.0

Version Notes

the module is also available on github https://github.com/aleron75/Webgriffe_TphPro

Download this release

Release Info

Developer Alessandro Ronchi
Extension Webgriffe_TphPro
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

app/code/community/Webgriffe/TphPro/Block/Handles.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * TphPro Handles block
5
+ *
6
+ * @author Alessandro Ronchi <aronchi at webgriffe.com>
7
+ */
8
+ class Webgriffe_TphPro_Block_Handles extends Mage_Core_Block_Abstract {
9
+ protected function _toHtml()
10
+ {
11
+ $html = '';
12
+
13
+ switch(Mage::helper('webgriffe_tphpro')->getDisplayHandlesType()) {
14
+
15
+ case Webgriffe_TphPro_Model_System_Config_Source_Display::DISPLAY_HTML_ELEMENT:
16
+ $handles = '&lt;' . implode("&gt; &lt;", $this->getLayout()->getUpdate()->getHandles()) . '&gt;';
17
+ $html = '<div class="global-site-notice demo-notice" style="background:#1b83e6;">';
18
+ $html .= '<div class="notice-inner"><p>Handles: ' . $handles . '</p></div>';
19
+ $html .= '</div>';
20
+ break;
21
+
22
+ case Webgriffe_TphPro_Model_System_Config_Source_Display::DISPLAY_HTML_COMMENT:
23
+ $handles = '<' . implode("> <", $this->getLayout()->getUpdate()->getHandles()) . '>';
24
+ $html = "\r\n<!-- Handles: " . $handles . "-->\r\n";
25
+ break;
26
+
27
+ case Webgriffe_TphPro_Model_System_Config_Source_Display::DISPLAY_NONE:
28
+ #break intentionally omitted
29
+
30
+ default:
31
+ #nothing to do
32
+ }
33
+
34
+ return $html;
35
+ }
36
+ }
app/code/community/Webgriffe/TphPro/Helper/Data.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Webgriffe_TphPro_Helper_Data extends Mage_Core_Helper_Data
3
+ {
4
+ public function getDisplayHandlesType() {
5
+ return Mage::getStoreConfig('webgriffe_tphpro/webgriffe_tphpro_general/webgriffe_tphpro_handle');
6
+ }
7
+
8
+ public function getDisplayHintsType() {
9
+ return Mage::getStoreConfig('webgriffe_tphpro/webgriffe_tphpro_general/webgriffe_tphpro_hints');
10
+ }
11
+
12
+ public function getIsLogHttpParams() {
13
+ return Mage::getStoreConfig('webgriffe_tphpro/webgriffe_tphpro_general/webgriffe_tphpro_logparams');
14
+ }
15
+
16
+ }
app/code/community/Webgriffe/TphPro/Model/Observer.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * TphPro Observer model
5
+ *
6
+ * @author Alessandro Ronchi <aronchi at webgriffe.com>
7
+ */
8
+ class Webgriffe_TphPro_Model_Observer {
9
+
10
+ public function addHandlesBlock($observer) {
11
+ $event = $observer->getEvent();
12
+ /** @var Mage_Core_Model_Layout $layout */
13
+ if ($layout = $event->getLayout()) {
14
+ /** @var Mage_Core_Block_Abstract $layoutBlock */
15
+ $layoutBlock = $layout->createBlock('Webgriffe_TphPro_Block_Handles', 'webgriffe_tphpro_handles');
16
+ if (!empty($layoutBlock)) {
17
+ $layout->addOutputBlock('webgriffe_tphpro_handles');
18
+ }
19
+ }
20
+ }
21
+
22
+ public function addTemplateHints($observer) {
23
+ $event = $observer->getEvent();
24
+ /** @var Mage_Core_Block_Abstract $block */
25
+ $block = $event->getBlock();
26
+
27
+ $transport = $event->getTransport();
28
+
29
+ $html = '';
30
+ switch(Mage::helper('webgriffe_tphpro')->getDisplayHintsType()) {
31
+ case Webgriffe_TphPro_Model_System_Config_Source_Display::DISPLAY_HTML_ELEMENT:
32
+ $html = '<magento '
33
+ #. ($isRootBlock ? 'handles="' . implode(",", $block->getLayout()->getUpdate()->getHandles()) . '"' : '')
34
+ . ' block="' . get_class($block) . '"'
35
+ #. ' template="' . $block->getTemplate() . '"'
36
+ . (!strcmp($block->getTemplate(), '') ? '' : ' template_file="' . $block->getTemplateFile() . '"' )
37
+ . ' name="' . $block->getNameInLayout() . '"'
38
+ . ' alias="' . $block->getBlockAlias() . '"'
39
+ . '>' . $transport->getHtml() . '</magento>';
40
+ break;
41
+
42
+ case Webgriffe_TphPro_Model_System_Config_Source_Display::DISPLAY_HTML_COMMENT:
43
+ $data = 'block="' . get_class($block) . '"'
44
+ . (!strcmp($block->getTemplate(), '') ? '' : ' template_file="' . $block->getTemplateFile() . '"' )
45
+ . ' name="' . $block->getNameInLayout() . '"'
46
+ . ' alias="' . $block->getBlockAlias() . '"';
47
+ $html = "\r\n<!-- [HINTS BEGIN " . $data . "] -->\r\n"
48
+ . $transport->getHtml()
49
+ . "<!-- [HINTS END " . $data . "] -->\r\n";
50
+ break;
51
+
52
+ case Webgriffe_TphPro_Model_System_Config_Source_Display::DISPLAY_NONE:
53
+ #break intentionally omitted
54
+
55
+ default:
56
+ $html = $transport->getHtml();
57
+ }
58
+ $transport->setHtml($html);
59
+ }
60
+
61
+ public function logRequestParameters($observer) {
62
+ if (Mage::helper('webgriffe_tphpro')->getIsLogHttpParams()) {
63
+ $request = Mage::app()->getRequest();
64
+
65
+ $txt = "Request Parameters:\r\n";
66
+ $txt .= sprintf("Module name: %s\r\n", $request->getModuleName());
67
+ $txt .= sprintf("Controller name: %s\r\n", $request->getControllerName());
68
+ $txt .= sprintf("Action name: %s\r\n", $request->getActionName());
69
+ $txt .= sprintf("Request Parameters: %s\r\n", var_export($request->getParams(), true));
70
+
71
+ Mage::log($txt, null, 'Webgriffe_TphPro.log', true);
72
+ }
73
+ }
74
+
75
+ }
app/code/community/Webgriffe/TphPro/Model/System/Config/Source/Display.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Webgriffe_TphPro_Model_System_Config_Source_Display
3
+ {
4
+ const DISPLAY_NONE = 'none';
5
+ const DISPLAY_HTML_ELEMENT = 'html_element';
6
+ const DISPLAY_HTML_COMMENT = 'html_comment';
7
+
8
+ /**
9
+ * Options getter
10
+ *
11
+ * @return array
12
+ */
13
+ public function toOptionArray()
14
+ {
15
+ return array(
16
+ array('value' => self::DISPLAY_NONE, 'label'=>Mage::helper('webgriffe_tphpro')->__('No')),
17
+ array('value' => self::DISPLAY_HTML_ELEMENT, 'label'=>Mage::helper('webgriffe_tphpro')->__('Yes, as HTML element')),
18
+ array('value' => self::DISPLAY_HTML_COMMENT, 'label'=>Mage::helper('webgriffe_tphpro')->__('Yes, as HTML comment')),
19
+ );
20
+ }
21
+
22
+ /**
23
+ * Get options in "key-value" format
24
+ *
25
+ * @return array
26
+ */
27
+ public function toArray()
28
+ {
29
+ return array(
30
+ self::DISPLAY_NONE => Mage::helper('webgriffe_tphpro')->__('No'),
31
+ self::DISPLAY_HTML_ELEMENT => Mage::helper('webgriffe_tphpro')->__('Yes, as HTML element'),
32
+ self::DISPLAY_HTML_COMMENT => Mage::helper('webgriffe_tphpro')->__('Yes, as HTML comment'),
33
+ );
34
+ }
35
+
36
+ }
app/code/community/Webgriffe/TphPro/etc/config.xml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Webgriffe_TphPro>
5
+ <version>1.1.0</version>
6
+ </Webgriffe_TphPro>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <webgriffe_tphpro>
11
+ <class>Webgriffe_TphPro_Block</class>
12
+ </webgriffe_tphpro>
13
+ </blocks>
14
+ <helpers>
15
+ <webgriffe_tphpro>
16
+ <class>Webgriffe_TphPro_Helper</class>
17
+ </webgriffe_tphpro>
18
+ </helpers>
19
+ <models>
20
+ <webgriffe_tphpro>
21
+ <class>Webgriffe_TphPro_Model</class>
22
+ </webgriffe_tphpro>
23
+ </models>
24
+
25
+ <events>
26
+ <http_response_send_before>
27
+ <observers>
28
+ <webgriffe_http_response_send_before>
29
+ <type>enabled</type>
30
+ <class>webgriffe_tphpro/observer</class>
31
+ <method>logRequestParameters</method>
32
+ </webgriffe_http_response_send_before>
33
+ </observers>
34
+ </http_response_send_before>
35
+ </events>
36
+ </global>
37
+
38
+ <frontend>
39
+ <events>
40
+ <controller_action_layout_generate_blocks_before>
41
+ <observers>
42
+ <webgriffe_tphpro_generate_blocks_before>
43
+ <type>singleton</type>
44
+ <class>webgriffe_tphpro/observer</class>
45
+ <method>addHandlesBlock</method>
46
+ </webgriffe_tphpro_generate_blocks_before>
47
+ </observers>
48
+ </controller_action_layout_generate_blocks_before>
49
+
50
+ <core_block_abstract_to_html_after>
51
+ <observers>
52
+ <webgriffe_tphpro_block_to_html_after>
53
+ <type>singleton</type>
54
+ <class>webgriffe_tphpro/observer</class>
55
+ <method>addTemplateHints</method>
56
+ </webgriffe_tphpro_block_to_html_after>
57
+ </observers>
58
+ </core_block_abstract_to_html_after>
59
+ </events>
60
+ </frontend>
61
+
62
+ <adminhtml>
63
+ <acl>
64
+ <resources>
65
+ <all>
66
+ <title>Allow Everything</title>
67
+ </all>
68
+ <admin>
69
+ <children>
70
+ <system>
71
+ <children>
72
+ <config>
73
+ <children>
74
+ <webgriffe_tphpro>
75
+ <title>Webgriffe - Template Path Hints Pro</title>
76
+ </webgriffe_tphpro>
77
+ </children>
78
+ </config>
79
+ </children>
80
+ </system>
81
+ </children>
82
+ </admin>
83
+ </resources>
84
+ </acl>
85
+ </adminhtml>
86
+ </config>
app/code/community/Webgriffe/TphPro/etc/system.xml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <webgriffe translate="label">
5
+ <label>Webgriffe Extensions</label>
6
+ <sort_order>999000</sort_order>
7
+ </webgriffe>
8
+ </tabs>
9
+ <sections>
10
+ <webgriffe_tphpro translate="label">
11
+ <label>Template Path Hints Pro</label>
12
+ <tab>webgriffe</tab>
13
+ <sort_order>10</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <webgriffe_tphpro_general translate="label">
19
+ <label>General</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>10</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <webgriffe_tphpro_handle translate="label,comment">
27
+ <label>Display Layout Handles</label>
28
+ <comment>Choose whether and how to display Frontend Layout Handles; consider that displaying them as HTML element can invalidate CSS rules and break the HTML layout.</comment>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>webgriffe_tphpro/system_config_source_display</source_model>
31
+ <sort_order>10</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </webgriffe_tphpro_handle>
36
+ <webgriffe_tphpro_hints translate="label,comment">
37
+ <label>Display Template Hints</label>
38
+ <comment>Choose whether and how to display Frontend Template Hints; consider that displaying them as HTML element can invalidate CSS rules and break the HTML layout.</comment>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>webgriffe_tphpro/system_config_source_display</source_model>
41
+ <sort_order>20</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </webgriffe_tphpro_hints>
46
+ <webgriffe_tphpro_logparams translate="label,comment">
47
+ <label>Log Request Parameters</label>
48
+ <comment>Choose whether to log (both Frontend and Admin) HTTP Request's parameters. Note: if you set this value to 'Yes', it will produce a log whether or not you have Magento logging enabled.</comment>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_yesno</source_model>
51
+ <sort_order>30</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </webgriffe_tphpro_logparams>
56
+ </fields>
57
+ </webgriffe_tphpro_general>
58
+ </groups>
59
+ </webgriffe_tphpro>
60
+ </sections>
61
+ </config>
app/etc/modules/Webgriffe_TphPro.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Webgriffe_TphPro>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends></depends>
8
+ </Webgriffe_TphPro>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Webgriffe_TphPro</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>An enhanced Template Path Hints extension for Magento that inserts references to used Magento Blocks inside HTML code, avoiding the usage of the more invasive built in Template Path Hints.</summary>
10
+ <description>This extension allows you to print some useful information about Frontend Blocks in the HTML of your page.&#xD;
11
+ &#xD;
12
+ You can choose whether to print them as HTML Elements or Comments.&#xD;
13
+ &#xD;
14
+ Furthermore you can choose to log both Frontend and Backend HTTP Request's parameters.&#xD;
15
+ &#xD;
16
+ Once installed, you can configure this extension in the System &gt; Configuration &gt; WEBGRIFFE EXTENSIONS &gt; Template Path Hints Pro section.</description>
17
+ <notes>the module is also available on github https://github.com/aleron75/Webgriffe_TphPro</notes>
18
+ <authors><author><name>Webgriffe</name><user>webgriffe</user><email>mail@webgriffe.com</email></author></authors>
19
+ <date>2013-11-27</date>
20
+ <time>11:46:22</time>
21
+ <contents><target name="magecommunity"><dir name="Webgriffe"><dir name="TphPro"><dir name="Block"><file name="Handles.php" hash="7ee9d6173d0fa0c239b3a309c74ef701"/></dir><dir name="Helper"><file name="Data.php" hash="d677fdd630a6bfc23768b702a5a07bf9"/></dir><dir name="Model"><file name="Observer.php" hash="2dcc887f26c60bd0ff457780167332a5"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Display.php" hash="56e50ea3e82e749d80530231863f834c"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="7dc7bde9da8728f4bf6b4186935cc14d"/><file name="system.xml" hash="db5b1984b67aa26578afa6c87d6c8021"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Webgriffe_TphPro.xml" hash="c19ce79f7ac273f912e1b8cbcd371b14"/></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.0</min><max>1.8</max></package></required></dependencies>
24
+ </package>