Pubble_io - Version 1.0.0

Version Notes

First release

- Supports enabling/disabling the extension.
- Supports adding the messenger widget to your site via either Copy & Pasting the code directly from Pubble or just adding in the App ID and Identifier fields.

Download this release

Release Info

Developer StudioForty9
Extension Pubble_io
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Pubble/Messenger/Block/Script.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Pubble_Messenger
4
+ *
5
+ * @category Pubble
6
+ * @package Pubble_Messenger
7
+ * @author Pubble <ross@pubble.io>
8
+ * @copyright 2015 Pubble (http://www.pubble.io)
9
+ * @version 1.0.0
10
+ */
11
+
12
+ /**
13
+ * Pubble_Messenger_Block_Script
14
+ *
15
+ * @category Pubble
16
+ * @package Pubble_Messenger
17
+ * @subpackage Block
18
+ */
19
+ class Pubble_Messenger_Block_Script extends Mage_Core_Block_Template
20
+ {
21
+ /**
22
+ * The pubble javascript library code URL.
23
+ * @var string
24
+ */
25
+ protected $_url = '//www.pubble.io/resources/javascript/QAInit.js';
26
+
27
+ /**
28
+ * Render the javascript to initialize the pubble messenger.
29
+ *
30
+ * @return string
31
+ */
32
+ public function render()
33
+ {
34
+ return ($this->isCopyPaste()) ? $this->renderCode() : $this->renderCredentials();
35
+ }
36
+
37
+ /**
38
+ * Is the configuration method set to 'Copy & Paste'?
39
+ *
40
+ * @return bool
41
+ */
42
+ protected function isCopyPaste()
43
+ {
44
+ return $this->_getHelper()->isMethodCopyPaste();
45
+ }
46
+
47
+ /**
48
+ * Render the copy and pasted code.
49
+ *
50
+ * @return string
51
+ */
52
+ protected function renderCode()
53
+ {
54
+ return $this->_getHelper()->getCode();
55
+ }
56
+
57
+ /**
58
+ * Render the tag to fetch the pubble javascript library code.
59
+ *
60
+ * @return string
61
+ */
62
+ protected function renderJsUrl()
63
+ {
64
+ return sprintf('<script type="text/javascript" src="%s"></script>', $this->_url);
65
+ }
66
+
67
+ /**
68
+ * Render the javascript to initialize the pubble messenger.
69
+ *
70
+ * @return string
71
+ */
72
+ protected function renderJsScript()
73
+ {
74
+ $appId = $this->_getHelper()->getAppId();
75
+ $identifier = $this->_getHelper()->getIdentifier();
76
+
77
+ $html = sprintf(
78
+ '<script type="text/javascript">var lpQA = lpQA({appID: "%s", identifier: "%s"});</script>',
79
+ $appId,
80
+ $identifier
81
+ );
82
+
83
+ return $html;
84
+ }
85
+
86
+ /**
87
+ * Render the javascript using credential variables.
88
+ *
89
+ * @return string
90
+ */
91
+ protected function renderCredentials()
92
+ {
93
+ return sprintf("%s\n%s", $this->renderJsUrl(), $this->renderJsScript());
94
+ }
95
+
96
+ /**
97
+ * Get an instance of the Pubble Data helper.
98
+ *
99
+ * @return Pubble_Messenger_Helper_Data
100
+ */
101
+ protected function _getHelper()
102
+ {
103
+ return Mage::helper('pubble_messenger');
104
+ }
105
+ }
app/code/community/Pubble/Messenger/Helper/Data.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Pubble_Messenger
4
+ *
5
+ * @category Pubble
6
+ * @package Pubble_Messenger
7
+ * @author Pubble <ross@pubble.io>
8
+ * @copyright 2015 Pubble (http://www.pubble.io)
9
+ * @version 1.0.0
10
+ */
11
+
12
+ /**
13
+ * Pubble_Messenger_Helper_Data
14
+ *
15
+ * @category Pubble
16
+ * @package Pubble_Messenger
17
+ * @subpackage Helper
18
+ */
19
+ class Pubble_Messenger_Helper_Data extends Mage_Core_Helper_Abstract
20
+ {
21
+ /**#@+
22
+ * Configuration Method Types
23
+ * @var int
24
+ */
25
+ const METHOD_CREDENTIALS = 1;
26
+ const METHOD_COPYPASTE = 2;
27
+ /**#@-*/
28
+
29
+ /**
30
+ * Determine whether the module is enabled via admin configuration.
31
+ *
32
+ * @return bool
33
+ */
34
+ public function isEnabled()
35
+ {
36
+ return Mage::getStoreConfigFlag('pubble/messenger/enabled');
37
+ }
38
+
39
+ /**
40
+ * Get the method configuration type.
41
+ *
42
+ * @return int
43
+ */
44
+ public function getMethod()
45
+ {
46
+ return (int) Mage::getStoreConfig('pubble/messenger/method');
47
+ }
48
+
49
+ /**
50
+ * Determine if the method type is 'credentials'.
51
+ *
52
+ * @return bool
53
+ */
54
+ public function isMethodCredentials()
55
+ {
56
+ return ($this->getMethod() === static::METHOD_CREDENTIALS);
57
+ }
58
+
59
+ /**
60
+ * Determine if the method type is 'copy and paste'.
61
+ *
62
+ * @return bool
63
+ */
64
+ public function isMethodCopyPaste()
65
+ {
66
+ return ($this->getMethod() === static::METHOD_COPYPASTE);
67
+ }
68
+
69
+ /**
70
+ * Get the configuration setting for App Id.
71
+ *
72
+ * @return int
73
+ */
74
+ public function getAppId()
75
+ {
76
+ return Mage::getStoreConfig('pubble/messenger/app_id');
77
+ }
78
+
79
+ /**
80
+ * Get the configuration setting for Identifier.
81
+ *
82
+ * @return int
83
+ */
84
+ public function getIdentifier()
85
+ {
86
+ return Mage::getStoreConfig('pubble/messenger/identifier');
87
+ }
88
+
89
+ /**
90
+ * Get the copy and pasted code from Pubble saved in the configuration.
91
+ *
92
+ * @return int
93
+ */
94
+ public function getCode()
95
+ {
96
+ return Mage::getStoreConfig('pubble/messenger/code');
97
+ }
98
+ }
app/code/community/Pubble/Messenger/Model/Observer.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Pubble_Messenger
4
+ *
5
+ * @category Pubble
6
+ * @package Pubble_Messenger
7
+ * @author Pubble <ross@pubble.io>
8
+ * @copyright 2015 Pubble (http://www.pubble.io)
9
+ * @version 1.0.0
10
+ */
11
+
12
+ /**
13
+ * Pubble_Messenger_Model_Observer
14
+ *
15
+ * @category Pubble
16
+ * @package Pubble_Messenger
17
+ * @subpackage Model
18
+ */
19
+ class Pubble_Messenger_Model_Observer
20
+ {
21
+ /**#@+
22
+ * Block parameters
23
+ * @var string
24
+ */
25
+ const BLOCK_NAME = 'pubble_messenger/script';
26
+ const BLOCK_ALIAS = 'pubble.messenger.script';
27
+ const BLOCK_TEMPLATE = 'pubble/messenger/script.phtml';
28
+ const BLOCK_TARGET = 'before_body_end';
29
+ /**#@-*/
30
+
31
+ /**
32
+ * Add Pubble script to the footer.
33
+ *
34
+ * The observer will return the Pubble_Messenger_Block_Script class if
35
+ * everything goes as expected. It will return itself if the extension
36
+ * is disabled via configuration. And it will return false in the case
37
+ * of an exception being thrown.
38
+ *
39
+ * @return mixed
40
+ */
41
+ public function addPubbleBeforeBodyEnd()
42
+ {
43
+ if (! $this->_getHelper()->isEnabled()) {
44
+ return $this;
45
+ }
46
+
47
+ try {
48
+ /** @var Mage_Core_Model_Layout $layout */
49
+ /** @var Pubble_Messenger_Block_Script $pubble */
50
+ $layout = Mage::app()->getLayout();
51
+ $pubble = $layout->createBlock(self::BLOCK_NAME, self::BLOCK_ALIAS);
52
+ $pubble->setTemplate(self::BLOCK_TEMPLATE);
53
+ $layout->getBlock(self::BLOCK_TARGET)->append($pubble);
54
+
55
+ return $pubble;
56
+ } catch (Exception $e) {
57
+ Mage::logException($e);
58
+ return false;
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Get an instance of the Pubble Data helper.
64
+ *
65
+ * @return Pubble_Messenger_Helper_Data
66
+ */
67
+ private function _getHelper()
68
+ {
69
+ return Mage::helper('pubble_messenger');
70
+ }
71
+ }
app/code/community/Pubble/Messenger/Model/Source/Method.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Pubble_Messenger
4
+ *
5
+ * @category Pubble
6
+ * @package Pubble_Messenger
7
+ * @author Pubble <ross@pubble.io>
8
+ * @copyright 2015 Pubble (http://www.pubble.io)
9
+ * @version 1.0.0
10
+ */
11
+
12
+ /**
13
+ * Pubble_Messenger_Model_Source_Method
14
+ *
15
+ * @category Pubble
16
+ * @package Pubble_Messenger
17
+ * @subpackage Model
18
+ */
19
+ class Pubble_Messenger_Model_Source_Method
20
+ {
21
+ /**
22
+ * Provide the methods as options to the select box.
23
+ *
24
+ * @return array
25
+ */
26
+ public function toOptionArray()
27
+ {
28
+ return array(
29
+ Pubble_Messenger_Helper_Data::METHOD_COPYPASTE => $this->_getHelper()->__('Copy & Paste'),
30
+ Pubble_Messenger_Helper_Data::METHOD_CREDENTIALS => $this->_getHelper()->__('Credentials'),
31
+ );
32
+ }
33
+
34
+ /**
35
+ * Get an instance of the Pubble Data helper.
36
+ *
37
+ * @return Pubble_Messenger_Helper_Data
38
+ */
39
+ private function _getHelper()
40
+ {
41
+ return Mage::helper('pubble_messenger');
42
+ }
43
+ }
app/code/community/Pubble/Messenger/etc/config.xml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!--
3
+ /**
4
+ * Pubble_Messenger
5
+ *
6
+ * @category Pubble
7
+ * @package Pubble_Messenger
8
+ * @author Pubble <ross@pubble.io>
9
+ * @copyright 2015 Pubble (http://www.pubble.io)
10
+ * @version 1.0.0
11
+ */
12
+ -->
13
+ <config>
14
+ <modules>
15
+ <Pubble_Messenger>
16
+ <version>1.0.0</version>
17
+ </Pubble_Messenger>
18
+ </modules>
19
+ <global>
20
+ <blocks>
21
+ <pubble_messenger>
22
+ <class>Pubble_Messenger_Block</class>
23
+ </pubble_messenger>
24
+ </blocks>
25
+ <helpers>
26
+ <pubble_messenger>
27
+ <class>Pubble_Messenger_Helper</class>
28
+ </pubble_messenger>
29
+ </helpers>
30
+ <models>
31
+ <pubble_messenger>
32
+ <class>Pubble_Messenger_Model</class>
33
+ </pubble_messenger>
34
+ </models>
35
+ </global>
36
+ <frontend>
37
+ <events>
38
+ <controller_action_layout_generate_blocks_after>
39
+ <observers>
40
+ <pubble_messenger>
41
+ <type>singleton</type>
42
+ <class>Pubble_Messenger_Model_Observer</class>
43
+ <method>addPubbleBeforeBodyEnd</method>
44
+ </pubble_messenger>
45
+ </observers>
46
+ </controller_action_layout_generate_blocks_after>
47
+ </events>
48
+ </frontend>
49
+ <adminhtml>
50
+ <acl>
51
+ <resources>
52
+ <admin>
53
+ <children>
54
+ <system>
55
+ <children>
56
+ <config>
57
+ <children>
58
+ <pubble translate="title" module="pubble_messenger">
59
+ <title>Pubble Messenger Settings</title>
60
+ </pubble>
61
+ </children>
62
+ </config>
63
+ </children>
64
+ </system>
65
+ </children>
66
+ </admin>
67
+ </resources>
68
+ </acl>
69
+ </adminhtml>
70
+ <phpunit>
71
+ <suite>
72
+ <modules>
73
+ <Pubble_Messenger/>
74
+ </modules>
75
+ </suite>
76
+ </phpunit>
77
+ </config>
app/code/community/Pubble/Messenger/etc/system.xml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Pubble_Messenger
5
+ *
6
+ * @category Pubble
7
+ * @package Pubble_Messenger
8
+ * @author Pubble <ross@pubble.io>
9
+ * @copyright 2015 Pubble (http://www.pubble.io)
10
+ * @version 1.0.0
11
+ */
12
+ -->
13
+ <config>
14
+ <tabs>
15
+ <pubble translate="label" module="pubble_messenger">
16
+ <label>Pubble</label>
17
+ <sort_order>10</sort_order>
18
+ </pubble>
19
+ </tabs>
20
+ <sections>
21
+ <pubble translate="label" module="pubble_messenger">
22
+ <label>Messenger</label>
23
+ <tab>pubble</tab>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>110</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <groups>
30
+ <messenger translate="label title" module="pubble_messenger">
31
+ <label>Settings</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>100</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <fields>
38
+ <enabled translate="label">
39
+ <label>Enabled</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_yesno</source_model>
42
+ <sort_order>10</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
+ </enabled>
47
+ <method translate="label">
48
+ <label>Method</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>pubble_messenger/source_method</source_model>
51
+ <sort_order>20</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
+ </method>
56
+ <app_id translate="label" module="pubble_messenger">
57
+ <label>App ID</label>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>40</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ <depends><method>1</method></depends>
64
+ </app_id>
65
+ <identifier translate="label" module="pubble_messenger">
66
+ <label>Identifier</label>
67
+ <frontend_type>text</frontend_type>
68
+ <sort_order>50</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ <depends><method>1</method></depends>
73
+ </identifier>
74
+ <code translate="label" module="pubble_messenger">
75
+ <label>Copy &amp; Paste Your Tracking Code</label>
76
+ <frontend_type>textarea</frontend_type>
77
+ <sort_order>30</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ <depends><method>2</method></depends>
82
+ </code>
83
+ </fields>
84
+ </messenger>
85
+ </groups>
86
+ </pubble>
87
+ </sections>
88
+ </config>
app/etc/modules/Pubble_Messenger.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!--
3
+ /**
4
+ * Pubble_Messenger
5
+ *
6
+ * @category Pubble
7
+ * @package Pubble_Messenger
8
+ * @author Pubble <ross@pubble.io>
9
+ * @copyright 2015 Pubble (http://www.pubble.io)
10
+ * @version 1.0.0
11
+ */
12
+ -->
13
+ <config>
14
+ <modules>
15
+ <Pubble_Messenger>
16
+ <active>true</active>
17
+ <codePool>community</codePool>
18
+ </Pubble_Messenger>
19
+ </modules>
20
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Pubble_io</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/BSD-3-Clause">BSDL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Easily install your Pubble messenger code on Magento via the admin configuration panel.</summary>
10
+ <description>&lt;p&gt;Supports enabling/disabling the extension.&lt;/p&gt;&#xD;
11
+ &lt;p&gt;Supports adding the messenger widget to your site via either Copy &amp; Pasting the code directly from Pubble or just adding in the App ID and Identifier fields.&lt;/p&gt;</description>
12
+ <notes>First release&#xD;
13
+ &#xD;
14
+ - Supports enabling/disabling the extension.&#xD;
15
+ - Supports adding the messenger widget to your site via either Copy &amp; Pasting the code directly from Pubble or just adding in the App ID and Identifier fields.</notes>
16
+ <authors><author><name>StudioForty9</name><user>SF9</user><email>info@studioforty9.com</email></author><author><name>Eoghan O'Brien</name><user>eoghanobrien</user><email>eoghan@eoghanobrien.com</email></author><author><name>Pubble</name><user>soleary</user><email>shane@pubble.co</email></author></authors>
17
+ <date>2015-11-09</date>
18
+ <time>15:15:15</time>
19
+ <contents><target name="magecommunity"><dir name="Pubble"><dir name="Messenger"><dir name="Block"><file name="Script.php" hash="a96a1d8ad303585ab6acdc5deebd6c93"/></dir><dir name="Helper"><file name="Data.php" hash="7aad922f7fcc70ded4b0325ffd6c2915"/></dir><dir name="Model"><file name="Observer.php" hash="dfd1caca574a6aaf23464a9e1ecd796f"/><dir name="Source"><file name="Method.php" hash="3fd1cb931b9de16434f24b8fa59afe90"/></dir></dir><dir name="etc"><file name="config.xml" hash="5265b17a5e29a7065d2017959e8d1efa"/><file name="system.xml" hash="3ad88728ac8523ba6947afb91ccd20d2"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="pubble"><file name="messenger" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Pubble_Messenger.xml" hash="299e7218c4c3f9de5a9f26cd68e92f53"/></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.00.00</min><max>7.99.99</max></php></required></dependencies>
22
+ </package>