Zota_Zotabox - Version 1.0.0

Version Notes

Release Zotabox magento extension

Download this release

Release Info

Developer zotabox
Extension Zota_Zotabox
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Zota/Zotabox/Block/Adminhtml/Source/System/Config/Connectbutton.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zota_Zotabox_Block_Adminhtml_Source_System_Config_Connectbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ private $_tokenKey;
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $this->setElement($element);
8
+
9
+ $this->_tokenKey = $this->_createTokenKey();
10
+ $accessKey = $this->_getAccessKey();
11
+
12
+ $buttonUrl = Mage::helper('zotabox')->getDomainUrl()
13
+ . "/customer/access?redirect=" . $this->_getRedirectUrl()
14
+ . "&token=" . $this->_tokenKey
15
+ . "&customer=" . $this->_getCustomerId()
16
+ . "&access=" . $accessKey
17
+ ;
18
+ $buttonBlock = $this->getLayout()->createBlock('zotabox/adminhtml_widget_button')
19
+ ->setId('connect-to-zotabox')
20
+ ->setClass('btn btn-fancy')
21
+ ->setTarget('_zotabox')
22
+ ->setHref($buttonUrl)
23
+ ;
24
+ if (empty($accessKey)) {
25
+ $buttonBlock->setLabel('Sign into Zotabox');
26
+ $buttonBlock->setOnClick($this->_onClickScript());
27
+ }else{
28
+ $buttonBlock->setLabel('Configure your widgets');
29
+ }
30
+
31
+ $html = $buttonBlock->toHtml();
32
+ $html .= $this->getLayout()->createBlock('zotabox/adminhtml_widget_asset')->toHtml();
33
+ return $html;
34
+ }
35
+
36
+ protected function _getTokenKey() {
37
+ return $this->_tokenKey;
38
+ }
39
+
40
+ protected function _getRedirectUrl() {
41
+ return Mage::helper("adminhtml")->getUrl("adminhtml/zotabox/connect");
42
+ }
43
+
44
+ protected function _getAccessKey() {
45
+ return Mage::getStoreConfig('zotabox/basic/access', 0);
46
+ }
47
+
48
+ protected function _getCustomerId() {
49
+ return Mage::getStoreConfig('zotabox/basic/customer', 0);
50
+ }
51
+
52
+ protected function _onClickScript() {
53
+ $tokenValidUrl = Mage::helper("adminhtml")->getUrl("adminhtml/zotabox/validToken");
54
+ $tokenKey = $this->_getTokenKey();
55
+
56
+ return <<<EOT
57
+ var _checkValidToken = function(callback) {
58
+ new Ajax.Request('{$tokenValidUrl}', {
59
+ method: 'POST',
60
+ parameters: { 'token': '{$tokenKey}' },
61
+ onCreate: function(request) {
62
+ return Ajax.Responders.unregister(varienLoaderHandler.handler);
63
+ },
64
+ onSuccess: function(transport) {
65
+ return callback.call(this, (/^(true|1)$/i).test(transport.responseText));
66
+ }
67
+ });
68
+ }
69
+ var _retried = 0;
70
+ var _retryChecking = function() {
71
+ _checkValidToken(function(valid) {
72
+ if (false !== valid || _retried >= 30) {
73
+ return window.location.reload();
74
+ }
75
+ var _t = setTimeout(function() {
76
+ return _retryChecking();
77
+ }, 100);
78
+ _retried++;
79
+ });
80
+ }
81
+ _retryChecking();
82
+ EOT;
83
+ }
84
+
85
+ protected function _createTokenKey() {
86
+ // $tokenKey = Mage::getStoreConfig('zotabox/basic/token', 0);
87
+ // if (!isset($tokenKey) || empty($tokenKey)) {
88
+ $tokenKey = $this->_generateTokenKey();
89
+ $config = new Mage_Core_Model_Config();
90
+ $config->saveConfig('zotabox/basic/token', $tokenKey, 'default', 0);
91
+ Mage::app()->getCacheInstance()->cleanType('config');
92
+ // }
93
+ return $tokenKey;
94
+ }
95
+
96
+ protected function _generateTokenKey() {
97
+ return Mage::helper('core')->getRandomString(32);
98
+ }
99
+ }
100
+ ?>
app/code/community/Zota/Zotabox/Block/Adminhtml/Source/System/Config/Disconnectbutton.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zota_Zotabox_Block_Adminhtml_Source_System_Config_Disconnectbutton extends Zota_Zotabox_Block_Adminhtml_Source_System_Config_Connectbutton
3
+ {
4
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
+ {
6
+ $this->setElement($element);
7
+ if (!Mage::helper('zotabox')->getConnectState()) {
8
+ return '';
9
+ }
10
+ $tokenKey = $this->_getTokenKey();
11
+ $accessKey = $this->_getAccessKey();
12
+
13
+ $buttonBlock = $this->getLayout()->createBlock('zotabox/adminhtml_widget_button')
14
+ // ->setId('connect-to-zotabox')
15
+ // ->setClass('btn btn-fancy')
16
+ // ->setHref($buttonUrl)
17
+ ->setLabel('Disconnect')
18
+ ->setTarget('_self')
19
+ ->setOnClick($this->_onClickScript() . ';return false;')
20
+ ;
21
+
22
+ $html = $buttonBlock->toHtml();
23
+ return $html;
24
+ }
25
+
26
+ protected function _getRedirectUrl() {
27
+ return Mage::helper("adminhtml")->getUrl("adminhtml/zotabox/disconnect");
28
+ }
29
+
30
+ protected function _onClickScript() {
31
+ $redirectUrl = $this->_getRedirectUrl();
32
+
33
+ return <<<EOT
34
+ (function() {
35
+ var result = confirm('Do you want to disconnect from Zotabox?');
36
+ if (result !== true) return;
37
+ new Ajax.Request('{$redirectUrl}', {
38
+ method: 'POST',
39
+ parameters: {},
40
+ // onCreate: function(request) {
41
+ // return Ajax.Responders.unregister(varienLoaderHandler.handler);
42
+ // },
43
+ onSuccess: function(transport) {
44
+ return window.location.reload();
45
+ }
46
+ });
47
+ })();
48
+ return false;
49
+ EOT;
50
+ }
51
+ }
52
+ ?>
app/code/community/Zota/Zotabox/Block/Adminhtml/Source/System/Config/SaveEmbedCodeButton.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zota_Zotabox_Block_Adminhtml_Source_System_Config_SaveEmbedCodeButton extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
+ {
6
+ $this->setElement($element);
7
+ $buttonBlock = $this->getLayout()->createBlock('zotabox/adminhtml_widget_button')
8
+ // // ->setId('connect-to-zotabox')
9
+ ->setClass('btn btn-fancy')
10
+ ->setTarget("_self")
11
+ ->setOnClick($this->_onClickScript())
12
+ ;
13
+ $buttonBlock->setLabel('Save');
14
+ $html = $buttonBlock->toHtml();
15
+ return $html;
16
+ }
17
+
18
+ protected function _onClickScript() {
19
+ $removeAccessKeyUrl = Mage::helper("adminhtml")->getUrl("adminhtml/zotabox/removeAccessKey");
20
+
21
+ return <<<EOT
22
+ new Ajax.Request('{$removeAccessKeyUrl}', {
23
+ method: 'POST',
24
+ parameters: {},
25
+ onSuccess: function(transport) {
26
+ return configForm.submit();
27
+ }
28
+ });
29
+ return false;
30
+ EOT;
31
+ }
32
+ }
33
+ ?>
app/code/community/Zota/Zotabox/Block/Adminhtml/Source/System/Config/ShowEmbedCodeButton.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zota_Zotabox_Block_Adminhtml_Source_System_Config_ShowEmbedCodeButton extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
+ {
6
+ $this->setElement($element);
7
+ $currentUrl = Mage::helper('core/url')->getCurrentUrl();
8
+ $buttonBlock = $this->getLayout()->createBlock('zotabox/adminhtml_widget_button')
9
+ // ->setId('connect-to-zotabox')
10
+ // ->setClass('btn btn-fancy')
11
+ ->setTarget("_self")
12
+ ->setOnClick("Fieldset.toggleCollapse('zotabox_advanced', '{$currentUrl}'); return false;")
13
+ ;
14
+ $buttonBlock->setLabel('Save your embed code manually');
15
+ $html = $buttonBlock->toHtml();
16
+ if (Mage::helper('zotabox')->getEmbedState()) {
17
+ $html .= $this->_getEmbedStateHtml();
18
+ }
19
+ return $html;
20
+ }
21
+
22
+ private function _getEmbedStateHtml() {
23
+ return <<<EOT
24
+ <span>(</span>
25
+ <span class="check-actived">&nbsp;</span>
26
+ <span>activated</span>
27
+ <span>)</span>
28
+ EOT;
29
+ }
30
+ }
31
+ ?>
app/code/community/Zota/Zotabox/Block/Adminhtml/Widget/Asset.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Zota_Zotabox_Block_Adminhtml_Widget_Asset extends Mage_Core_Block_Template
4
+ {
5
+ protected $_template = 'zotabox/asset.phtml';
6
+ }
app/code/community/Zota/Zotabox/Block/Adminhtml/Widget/Button.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Zota_Zotabox_Block_Adminhtml_Widget_Button extends Mage_Adminhtml_Block_Widget
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ }
9
+
10
+ public function getHref() {
11
+ return ($href=$this->getData('href')) ? $href : 'javascript:void(0);';
12
+ }
13
+
14
+ public function getTarget() {
15
+ return ($target=$this->getData('target')) ? $target : '_blank';
16
+ }
17
+
18
+ public function getOnClick()
19
+ {
20
+ if (!$this->getData('on_click')) {
21
+ return $this->getData('onclick');
22
+ }
23
+ return $this->getData('on_click');
24
+ }
25
+
26
+ protected function _toHtml()
27
+ {
28
+ $html = $this->getBeforeHtml().'<a '
29
+ . ($this->getId()?' id="'.$this->getId() . '"':'')
30
+ . ($this->getElementName()?' name="'.$this->getElementName() . '"':'')
31
+ . ' href="'.$this->getHref() .'"'
32
+ . ' title="'
33
+ . $this->quoteEscape($this->getTitle() ? $this->getTitle() : $this->getLabel())
34
+ . '"'
35
+ . ' class="scalable ' . $this->getClass() . ($this->getDisabled() ? ' disabled' : '') . '"'
36
+ . ' onclick="'.$this->getOnClick().'"'
37
+ . ' style="'.$this->getStyle() .'"'
38
+ . ' target="'.$this->getTarget() .'"'
39
+ . ($this->getValue()?' value="'.$this->getValue() . '"':'')
40
+ . ($this->getDisabled() ? ' disabled="disabled"' : '')
41
+ . '><span><span><span>' .$this->getLabel().'</span></span></span></a>'.$this->getAfterHtml();
42
+
43
+ return $html;
44
+ }
45
+
46
+ /**
47
+ * Escape quotes inside html attributes
48
+ * Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc)
49
+ *
50
+ * @param string $data
51
+ * @param bool $addSlashes
52
+ * @return string
53
+ */
54
+ public function quoteEscape($data, $addSlashes = false)
55
+ {
56
+ if ($addSlashes === true) {
57
+ $data = addslashes($data);
58
+ }
59
+ return htmlspecialchars($data, ENT_QUOTES, null, false);
60
+ }
61
+ }
app/code/community/Zota/Zotabox/Block/Script.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zota_Zotabox_Block_Script extends Mage_Core_Block_Template
3
+ {
4
+ const XML_PATH_ZOTABOX_ENABLED = 'zotabox/basic/enabled';
5
+ const XML_PATH_ZOTABOX_EMBED_SCRIPT = 'zotabox/advanced/embed_script';
6
+
7
+ public function isEnable() {
8
+ return Mage::helper('zotabox')->getEmbedState() ? true : false;
9
+ }
10
+
11
+ public function printScript() {
12
+ $script = Mage::getStoreConfig(self::XML_PATH_ZOTABOX_EMBED_SCRIPT);
13
+ if (isset($script) && !empty($script)) {
14
+ echo $script;
15
+ }
16
+ return false;
17
+ }
18
+ }
app/code/community/Zota/Zotabox/Helper/Data.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zota_Zotabox_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ const ZOTABOX_DOMAIN_URL = 'zotabox.com';
5
+
6
+ public function getDomainUrl($subDomain = 'widgets', $protocol = 'http') {
7
+ return "{$protocol}://{$subDomain}." . self::ZOTABOX_DOMAIN_URL;
8
+ }
9
+
10
+ public function getEmbedState() {
11
+ $embedScript = Mage::getStoreConfig('zotabox/advanced/embed_script', 0);
12
+ if (!isset($embedScript) || empty($embedScript)) return false;
13
+ $matches = array();
14
+ preg_match("/src\=\"(.+)\/([a-zA-Z0-9]{32})\/(.+)\"/", $embedScript, $matches);
15
+ $domain = $matches[2];
16
+ return (!isset($domain) || empty($domain)) ? false : true;
17
+ }
18
+
19
+ public function getConnectState() {
20
+ $domain = Mage::getStoreConfig('zotabox/basic/domain', 0);
21
+ return (!isset($domain) || empty($domain)) ? false : true;
22
+ }
23
+
24
+ public function getEmbedCode($domainSecureId) {
25
+ $domainUrl = Mage::helper('zotabox')->getDomainUrl('static');
26
+ $ds1 = substr($domainSecureId, 0, 1);
27
+ $ds2 = substr($domainSecureId, 1, 1);
28
+ return <<<EOT
29
+ <script type="text/javascript">
30
+ (function(d,s,id){var z=d.createElement(s);z.type="text/javascript";z.id=id;z.async=true;z.src="{$domainUrl}/{$ds1}/{$ds2}/{$domainSecureId}/widgets.js";var sz=d.getElementsByTagName(s)[0];sz.parentNode.insertBefore(z,sz)}(document,"script","zb-embed-code"));
31
+ </script>
32
+ EOT;
33
+ }
34
+ }
35
+ ?>
app/code/community/Zota/Zotabox/controllers/Adminhtml/ZotaboxController.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Zota_Zotabox_Adminhtml_ZotaboxController extends Mage_Core_Controller_Varien_Action//Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function connectAction() {
6
+ $redirectUrl = Mage::app()->getRequest()->getPost('redirect');
7
+ if (!isset($redirectUrl) || empty($redirectUrl)) {
8
+ $redirectUrl = Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit/section/zotabox");
9
+ }
10
+
11
+ $accessKey = Mage::app()->getRequest()->getPost('access');
12
+ $customerId = Mage::app()->getRequest()->getPost('customer');
13
+ $domainSecureId = Mage::app()->getRequest()->getPost('domain');
14
+
15
+ if (isset($accessKey) && !empty($accessKey)
16
+ && isset($customerId) && !empty($customerId)
17
+ && isset($domainSecureId) && !empty($domainSecureId)
18
+ ) {
19
+ $config = new Mage_Core_Model_Config();
20
+ $config->saveConfig('zotabox/basic/customer', $customerId, 'default', 0);
21
+ $config->saveConfig('zotabox/basic/domain', $domainSecureId, 'default', 0);
22
+ $config->saveConfig('zotabox/basic/access', $accessKey, 'default', 0);
23
+
24
+ $embedCode = Mage::helper('zotabox')->getEmbedCode($domainSecureId);
25
+ $config->saveConfig('zotabox/advanced/embed_script', $embedCode, 'default', 0);
26
+ Mage::app()->getCacheInstance()->cleanType('config');
27
+ }
28
+ $this->_destroyToken();
29
+ }
30
+
31
+ public function disconnectAction() {
32
+ $this->removeAccessKeyAction();
33
+
34
+ $ch = curl_init();
35
+ curl_setopt($ch, CURLOPT_URL, Mage::helper('zotabox')->getDomainUrl()."/customer/access/disconnect");
36
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
37
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
38
+ curl_setopt($ch, CURLOPT_POST, true);
39
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array(
40
+ 'customer' => Mage::getStoreConfig('zotabox/basic/customer')
41
+ ));
42
+ $response = curl_exec($ch);
43
+ curl_close($ch);
44
+
45
+ Mage::getSingleton('core/cookie')
46
+ ->set('zotabox_flash_message', __('Disconnected from Zotabox successfully.'))
47
+ ;
48
+ $this->_destroyToken();
49
+
50
+ return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(true));
51
+ }
52
+
53
+ public function removeAccessKeyAction() {
54
+ $storeId = Mage::app()->getStore()->getStoreId();
55
+
56
+ $config = new Mage_Core_Model_Config();
57
+ $config->deleteConfig('zotabox/basic/customer', 'default', $storeId);
58
+ $config->deleteConfig('zotabox/basic/domain', 'default', $storeId);
59
+ $config->deleteConfig('zotabox/basic/access', 'default', $storeId);
60
+ $config->deleteConfig('zotabox/advanced/embed_script', 'default', $storeId);
61
+
62
+ $config->deleteConfig('zotabox/basic/customer', 'default', 0);
63
+ $config->deleteConfig('zotabox/basic/domain', 'default', 0);
64
+ $config->deleteConfig('zotabox/basic/access', 'default', 0);
65
+ $config->deleteConfig('zotabox/advanced/embed_script', 'default', 0);
66
+
67
+ $config->deleteConfig('zotabox/basic/customer', 'default', 1);
68
+ $config->deleteConfig('zotabox/basic/domain', 'default', 1);
69
+ $config->deleteConfig('zotabox/basic/access', 'default', 1);
70
+ $config->deleteConfig('zotabox/advanced/embed_script', 'default', 1);
71
+
72
+ Mage::app()->getCacheInstance()->cleanType('config');
73
+ }
74
+
75
+ public function validTokenAction() {
76
+ $token = Mage::app()->getRequest()->getPost('token');
77
+ $isExpired = $this->_isValidToken($token) ? false : true;
78
+ $this->getResponse()
79
+ ->clearHeaders()
80
+ ->setHeader('Content-type', 'application/json', true)
81
+ ;
82
+ if ($isExpired) {
83
+ Mage::getSingleton('core/cookie')
84
+ ->set('zotabox_flash_message', __('Connect to Zotabox successfully.'))
85
+ ;
86
+ }
87
+ return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($isExpired));
88
+ }
89
+
90
+ private function _destroyToken() {
91
+ $config = new Mage_Core_Model_Config();
92
+ $config->deleteConfig('zotabox/basic/token', 'default', 0);
93
+ return Mage::app()->getCacheInstance()->cleanType('config');
94
+ }
95
+
96
+ private function _isValidToken($token) {
97
+ $storeToken = Mage::getStoreConfig('zotabox/basic/token', 0);
98
+ if (!isset($storeToken) || !isset($token)) return false;
99
+ return $storeToken === $token;
100
+ }
101
+ }
app/code/community/Zota/Zotabox/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <zotabox translate="title">
12
+ <title>Zotabox</title>
13
+ <sort_order>20</sort_order>
14
+ </zotabox>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/community/Zota/Zotabox/etc/config.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Zota_Zotabox>
5
+ <version>1.0.0</version>
6
+ </Zota_Zotabox>
7
+ </modules>
8
+
9
+ <global>
10
+ <blocks>
11
+ <zotabox>
12
+ <class>Zota_Zotabox_Block</class>
13
+ </zotabox>
14
+ </blocks>
15
+ <helpers>
16
+ <zotabox>
17
+ <class>Zota_Zotabox_Helper</class>
18
+ </zotabox>
19
+ </helpers>
20
+ </global>
21
+
22
+ <adminhtml>
23
+ <translate>
24
+ <modules>
25
+ <zotabox>
26
+ <files>
27
+ <default>Zota_Zotabox.csv</default>
28
+ </files>
29
+ </zotabox>
30
+ </modules>
31
+ </translate>
32
+ </adminhtml>
33
+
34
+ <admin>
35
+ <routers>
36
+ <adminhtml>
37
+ <args>
38
+ <modules>
39
+ <Zota_Zotabox before="Mage_Adminhtml">Zota_Zotabox_Adminhtml</Zota_Zotabox>
40
+ </modules>
41
+ </args>
42
+ </adminhtml>
43
+ </routers>
44
+ </admin>
45
+
46
+ <frontend>
47
+ <translate>
48
+ <modules>
49
+ <Zota_Zotabox>
50
+ <files>
51
+ <default>Zota_Zotabox.csv</default>
52
+ </files>
53
+ </Zota_Zotabox>
54
+ </modules>
55
+ </translate>
56
+ <layout>
57
+ <updates>
58
+ <zotabox>
59
+ <file>zotabox.xml</file>
60
+ </zotabox>
61
+ </updates>
62
+ </layout>
63
+ </frontend>
64
+
65
+ <!-- <acl>
66
+ <resources>
67
+ <admin>
68
+ <children>
69
+ <zotabox translate="title" module="zotabox">
70
+ <title>My Controller</title>
71
+ <sort_order>1</sort_order>
72
+ <children>
73
+ <index translate="title">
74
+ <title>Index Action</title>
75
+ <sort_order>1</sort_order>
76
+ </index>
77
+ </children>
78
+ </zotabox>
79
+ </children>
80
+ </admin>
81
+ </resources>
82
+ </acl> -->
83
+ </config>
app/code/community/Zota/Zotabox/etc/system.xml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <zotabox translate="label" module="zotabox">
5
+ <label><![CDATA[
6
+ <img id="zotabox_favicon" style="vertical-align: text-bottom;" src="" alt="" border="0" width="16" height="16" />&nbsp;&nbsp;Zotabox
7
+ <script>$('zotabox_favicon').src = BLANK_IMG.replace('js/spacer.gif', 'skin/zotabox/icon.png');</script>
8
+ ]]></label>
9
+ <tab>service</tab>
10
+ <frontend_type>text</frontend_type>
11
+ <sort_order>400</sort_order>
12
+ <show_in_default>1</show_in_default>
13
+ <show_in_website>1</show_in_website>
14
+ <show_in_store>1</show_in_store>
15
+ <groups>
16
+ <zotabox_logo translate="label">
17
+ <comment><![CDATA[
18
+ <h3 class="config-title">Configure your Zotabox widgets</h3>
19
+ ]]></comment>
20
+ <expanded>1</expanded>
21
+ <sort_order>1</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
+ </zotabox_logo>
26
+
27
+ <basic translate="label">
28
+ <expanded>1</expanded>
29
+ <sort_order>2</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ <fields>
34
+ <connect_zotabox translate="comment">
35
+ <comment><![CDATA[]]></comment>
36
+ <frontend_model>zotabox/adminhtml_source_system_config_connectbutton</frontend_model>
37
+ <sort_order>2</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>1</show_in_store>
41
+ </connect_zotabox>
42
+ <disconnect_zotabox translate="comment">
43
+ <comment><![CDATA[]]></comment>
44
+ <frontend_model>zotabox/adminhtml_source_system_config_disconnectbutton</frontend_model>
45
+ <sort_order>3</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ </disconnect_zotabox>
50
+
51
+ <show_embed_code_button translate="comment">
52
+ <comment><![CDATA[]]></comment>
53
+ <frontend_model>zotabox/adminhtml_source_system_config_showEmbedCodeButton</frontend_model>
54
+ <sort_order>4</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </show_embed_code_button>
59
+ </fields>
60
+ </basic>
61
+
62
+ <advanced translate="label">
63
+ <expanded>1</expanded>
64
+ <sort_order>3</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ <fields>
69
+ <embed_script translate="label comment">
70
+ <comment><![CDATA[]]></comment>
71
+ <frontend_type>textarea</frontend_type>
72
+ <sort_order>1</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
+ </embed_script>
77
+
78
+ <save_code translate="comment">
79
+ <label>Save</label>
80
+ <frontend_model>zotabox/adminhtml_source_system_config_saveEmbedCodeButton</frontend_model>
81
+ <sort_order>2</sort_order>
82
+ <show_in_default>1</show_in_default>
83
+ <show_in_website>1</show_in_website>
84
+ <show_in_store>1</show_in_store>
85
+ </save_code>
86
+ </fields>
87
+ </advanced>
88
+ </groups>
89
+ </zotabox>
90
+ </sections>
91
+ </config>
app/design/adminhtml/default/default/template/zotabox/asset.phtml ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ $('config_edit_form').insert({
3
+ before: '<a href="http://zotabox.com" target="_zotabox"><img id="zotabox_brand" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>zotabox/logo-zotabox.png" alt="zotabox" title="Zotabox"></a>'
4
+ });
5
+
6
+ document.observe("dom:loaded", function() {
7
+ Fieldset.toggleCollapse('zotabox_advanced');
8
+ });
9
+
10
+ <?php
11
+ $flashMessage = Mage::getSingleton("core/cookie")->get("zotabox_flash_message");
12
+ if (isset($flashMessage) && !empty($flashMessage)) : ?>
13
+ $("messages").update('<ul class="messages"><li class="success-msg"><ul><li><span><?php echo Mage::getSingleton("core/cookie")->get("zotabox_flash_message") ?></span></li></ul></li></ul>');
14
+ <?php endif; ?>
15
+ </script>
16
+ <?php Mage::getSingleton("core/cookie")->delete("zotabox_flash_message"); ?>
17
+
18
+ <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600' rel='stylesheet' type='text/css'>
19
+ <style type="text/css">
20
+ .config-title {
21
+ font-size: 24px;
22
+ font-weight: normal;
23
+ margin-bottom: 0;
24
+ text-align: center;
25
+ color: #414141;
26
+ }
27
+ #content {
28
+ background-attachment: scroll;
29
+ background-clip: border-box;
30
+ background-color: rgba(0, 0, 0, 0);
31
+ background: url("<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>zotabox/bg_body.png") repeat scroll 30% 70% rgba(0, 0, 0, 0);
32
+ background-origin: padding-box;
33
+ background-repeat: repeat;
34
+ background-size: auto auto;
35
+ margin-left: 255px;
36
+ padding-left: 0;
37
+ }
38
+ .content-header {
39
+ display: none;
40
+ }
41
+ .entry-edit-head,
42
+ .scope-label {
43
+ display: none;
44
+ }
45
+ .columns .form-list,
46
+ .columns .form-list td.value {
47
+ vertical-align: middle;
48
+ width: 100%;
49
+ }
50
+ .form-list td.label {
51
+ display: none;
52
+ }
53
+ .check-actived {
54
+ background: url("<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) ?>zotabox/check.png") no-repeat scroll left 0 top -2px / 20px 20px rgba(0, 0, 0, 0);
55
+ height: 20px;
56
+ width: 20px;
57
+ margin-left: 0;
58
+ margin-right: 3px;
59
+ display: inline-block;
60
+ }
61
+ .btn:hover,
62
+ .btn:focus {
63
+ outline:medium none;
64
+ }
65
+
66
+ .btn:focus,
67
+ .btn:active:focus,
68
+ .btn.active:focus {
69
+ outline:medium none;
70
+ outline-offset:medium none;
71
+ }
72
+
73
+ .btn-fancy {
74
+ background-color: #e03a3a;
75
+ border: medium none;
76
+ border-radius: 5px;
77
+ box-shadow: 0 0 0 #bc2425 inset, 0 3px 0 0 #bc2425, 0 0 2px #999999;
78
+ color: white;
79
+ cursor: pointer;
80
+ text-decoration: none;
81
+ font-family: 'Open Sans', sans-serif;
82
+ font-size: 14px;
83
+ font-weight: bold;
84
+ padding: 10px 20px;
85
+ position: relative;
86
+ text-decoration: none;
87
+ text-shadow: 0 1px 0 #bc2425;
88
+ }
89
+ .btn-fancy:hover, .btn-fancy:focus, .btn-fancy:active {
90
+ text-decoration: none;
91
+ color: white;
92
+ }
93
+ .btn-fancy:active {
94
+ text-decoration: none;
95
+ background-image: -moz-linear-gradient(center bottom , #e63e3e 0%, #c92c2c 100%);
96
+ box-shadow: 0 1px 0 #ed2b2b inset, 0 2px 0 0 #851515, 0 2px 1px #999999;
97
+ top: 1px;
98
+ }
99
+ .btn-fancy:active::before {
100
+ box-shadow: 0 1px 0 #f06060 inset, 0 3px 0 #702d0d, 0 6px 3px #a61b1b;
101
+ margin-top: -12px;
102
+ top: 50%;
103
+ }
104
+
105
+ #config_edit_form {
106
+ font-family: 'Open Sans', sans-serif;
107
+ font-size: 13px;
108
+ font-weight: 400;
109
+ display: block;
110
+ background: white;
111
+ width: 600px;
112
+ margin: 10px auto;
113
+ box-shadow: 2px 2px 1px 0 #d6dadd;
114
+ border-radius: 5px;
115
+ }
116
+ #zotabox_brand {
117
+ display: block;
118
+ margin: 10px auto;
119
+ padding: 12px;
120
+ }
121
+ #zotabox_zotabox_logo,
122
+ #zotabox_basic,
123
+ #zotabox_advanced {
124
+ border: medium none;
125
+ background: none;
126
+ }
127
+ #zotabox_zotabox_logo {
128
+ margin-bottom: 0;
129
+ padding-bottom: 5px;
130
+ }
131
+ #zotabox_zotabox_logo img {
132
+ top: 25px;
133
+ left: 50%;
134
+ margin-left: -80px;
135
+ position: relative;
136
+ }
137
+ #zotabox_zotabox_logo .comment {
138
+ padding-top: 42px;
139
+ }
140
+ #row_zotabox_basic_connect_zotabox,
141
+ #row_zotabox_basic_disconnect_zotabox {
142
+ text-align: center;
143
+ }
144
+ #row_zotabox_basic_connect_zotabox {
145
+ height: 45px;
146
+ }
147
+ #row_zotabox_basic_show_embed_code_button {
148
+ display: block;
149
+ margin-top: 12px;
150
+ }
151
+ #zotabox_advanced_embed_script {
152
+ background-color: #fef9cf;
153
+ display: block;
154
+ font-family: "Lucida Console","Lucida Sans Typewriter",Monaco,"Bitstream Vera Sans Mono",monospace;
155
+ font-size: 12px;
156
+ margin: -24px auto 5px;
157
+ height: auto;
158
+ min-height: 105px;
159
+ padding: 12px;
160
+ width: 95%;
161
+ border: 1px solid #ccc;
162
+ border-radius: 5px;
163
+ }
164
+ #row_zotabox_advanced_save_code {
165
+ text-align: center;
166
+ height: 54px;
167
+ }
168
+
169
+ #connect-to-zotabox {
170
+ background-color: #196cca;/*#e03a3a;*/
171
+ -webkit-border-radius:30px;
172
+ -moz-border-radius:30px;
173
+ -o-border-radius:30px;
174
+ border-radius:30px;
175
+ -webkit-box-shadow:0 2px 0 0 #0C3563;/*#bc2425;*/
176
+ -moz-box-shadow:0 2px 0 0 #0C3563;/*#bc2425;*/
177
+ -o-box-shadow:0 2px 0 0 #0C3563;/*#bc2425;*/
178
+ box-shadow:0 2px 0 0 #0C3563;/*#bc2425;*/
179
+ text-shadow:0 1px 0 #0C3563;/*#bc2425;*/
180
+ }
181
+ #connect-to-zotabox:hover,
182
+ #connect-to-zotabox:focus,
183
+ #connect-to-zotabox:active {
184
+ color:#FFF;
185
+ background-color:#2A77CE;
186
+ text-decoration:none;
187
+ }
188
+ #connect-to-zotabox:active {
189
+ background-image:linear-gradient(bottom,#3A81D2 0%,#155CAD 100%);
190
+ background-image:-o-linear-gradient(bottom,#3A81D2 0%,#155CAD 100%);
191
+ background-image:-moz-linear-gradient(bottom,#3A81D2 0%,#155CAD 100%);
192
+ background-image:-webkit-linear-gradient(bottom,#3A81D2 0%,#155CAD 100%);
193
+ background-image:-ms-linear-gradient(bottom,#3A81D2 0%,#155CAD 100%);
194
+ background-image:-webkit-gradient(linear,left bottom,left top,color-stop(0,#3A81D2),color-stop(1,#155CAD));
195
+ -webkit-box-shadow:inset 0 1px 0 #6099DA,0px 2px 0 0 #114B8C,0px 2px 1px #999;
196
+ -moz-box-shadow:inset 0 1px 0 #6099DA,0px 2px 0 0 #114B8C,0px 2px 1px #999;
197
+ -o-box-shadow:inset 0 1px 0 #6099DA,0px 2px 0 0 #114B8C,0px 2px 1px #999;
198
+ box-shadow:inset 0 1px 0 #6099DA,0px 2px 0 0 #114B8C,0px 2px 1px #999;
199
+ }
200
+ #connect-to-zotabox:active::before {
201
+ -webkit-box-shadow:inset 0 1px 0 #3A81D2,0px 3px 0 #155CAD,0px 6px 3px #a61b1b;
202
+ -moz-box-shadow:inset 0 1px 0 #3A81D2,0px 3px 0 #155CAD,0px 6px 3px #a61b1b;
203
+ -o-box-shadow:inset 0 1px 0 #3A81D2,0px 3px 0 #155CAD,0px 6px 3px #a61b1b;
204
+ box-shadow:inset 0 1px 0 #3A81D2,0px 3px 0 #155CAD,0px 6px 3px #a61b1b;
205
+ }
206
+ </style>
app/design/frontend/base/default/layout/zotabox.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="before_body_end">
5
+ <block type="zotabox/script" name="zotabox_script" as="zotabox_script" translate="label">
6
+ <label>Zotabox Embed Script</label>
7
+ <action method="setTemplate">
8
+ <template>zotabox/script.phtml</template>
9
+ </action>
10
+ </block>
11
+ </reference>
12
+ </default>
13
+ </layout>
app/design/frontend/base/default/template/zotabox/script.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ if ($this->isEnable()) {
3
+ $this->printScript();
4
+ }
5
+ ?>
app/etc/modules/Zota_Zotabox.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Zota_Zotabox>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Zota_Zotabox>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Zota_Zotabox</name>
4
+ <version>1.0.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>Dramatically Boost Your Sales/Subscribers&#xD;
10
+ with These FREE Customizable Tools for Your Website</summary>
11
+ <description>Dramatically Boost Your Sales/Subscribers&#xD;
12
+ with These FREE Customizable Tools for Your Website</description>
13
+ <notes>Release Zotabox magento extension</notes>
14
+ <authors><author><name>zotabox</name><user>zotabox</user><email>support@zotabox.com</email></author></authors>
15
+ <date>2015-06-01</date>
16
+ <time>10:14:12</time>
17
+ <contents><target name="mageskin"><dir name="zotabox"><file name="bg_body.png" hash="9c80e8c1efae9f432416ebc9a3731b50"/><file name="check.png" hash="8923586db9a3ee5d3239e3ede52d3d33"/><file name="icon.png" hash="091df18a2b6722b22ad88ec3ea19999d"/><file name="logo-zotabox.png" hash="7b1aa437adce08c6debe088b2859141b"/></dir></target><target name="magecommunity"><dir name="Zota"><dir name="Zotabox"><dir name="Block"><dir name="Adminhtml"><dir name="Source"><dir name="System"><dir name="Config"><file name="Connectbutton.php" hash="5c1a292f98a0478eec66a235b36e1aed"/><file name="Disconnectbutton.php" hash="a9dea7b8c5e350dbc47949a60fbeec94"/><file name="SaveEmbedCodeButton.php" hash="38e598c6c81553af83c68c5564ac0ac5"/><file name="ShowEmbedCodeButton.php" hash="a89b7d3e7dbbe070571c0ede3ab709a6"/></dir></dir></dir><dir name="Widget"><file name="Asset.php" hash="78ce9a5edcded3e553c846d79ce74108"/><file name="Button.php" hash="3c54d3ee3ae3a40a496a1168f4be10d8"/></dir></dir><file name="Script.php" hash="65c38311cd379ed186836478322d2fae"/></dir><dir name="Helper"><file name="Data.php" hash="2e6c4643a982023089a30f1fe2be777c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ZotaboxController.php" hash="42ef274439d6540fc0b559413e4645de"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="fae757ddf69c715a3f46d72bf583b6d2"/><file name="config.xml" hash="1de51c8659324c564ca4834e46f8de28"/><file name="system.xml" hash="235e6ee3df67a6ce07f1894e4067cd23"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="zotabox"><file name="asset.phtml" hash="bd9db9e96097ddf997ba7a91f8834f7e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="zotabox"><file name="script.phtml" hash="90e5b756ddf5433a317c21aacc2bc855"/></dir></dir><dir name="layout"><file name="zotabox.xml" hash="512208f8d451ecb29215196dfa9f14ab"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Zota_Zotabox.xml" hash="830f655a238f4c63c9f05d7dad099324"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>4.0.0</min><max>7.0.0</max></php></required></dependencies>
20
+ </package>
skin/zotabox/bg_body.png ADDED
Binary file
skin/zotabox/check.png ADDED
Binary file
skin/zotabox/icon.png ADDED
Binary file
skin/zotabox/logo-zotabox.png ADDED
Binary file