Version Notes
Version 1.0.0 - Stable release.
Download this release
Release Info
Developer | Krisjanis Cers |
Extension | MaxTraffic_Exit_Offers |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Maxtraffic/WidgetTraffic/Helper/Data.php +6 -0
- app/code/community/Maxtraffic/WidgetTraffic/controllers/Adminhtml/TrafficController.php +88 -0
- app/code/community/Maxtraffic/WidgetTraffic/etc/adminhtml.xml +34 -0
- app/code/community/Maxtraffic/WidgetTraffic/etc/config.xml +65 -0
- app/code/community/Maxtraffic/WidgetTraffic/sql/widgettraffic_setup/install-1.0.0.php +18 -0
- app/etc/modules/Maxtraffic_WidgetTraffic.xml +9 -0
- package.xml +18 -0
app/code/community/Maxtraffic/WidgetTraffic/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Maxtraffic_WidgetTraffic_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/Maxtraffic/WidgetTraffic/controllers/Adminhtml/TrafficController.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Maxtraffic_WidgetTraffic_Adminhtml_TrafficController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
|
8 |
+
$storeId = Mage::app()->getStore()->getStoreId();
|
9 |
+
|
10 |
+
$domain = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
11 |
+
$websiteUrl = substr_compare($domain, '/index.php/', 0, 11) ? substr($domain, 0, -11) : $domain;
|
12 |
+
|
13 |
+
$connection = Mage::getSingleton('core/resource');
|
14 |
+
$readConnection = $connection->getConnection('core_read');
|
15 |
+
$maxtrafficSites = $readConnection->fetchAll("SELECT * FROM maxtraffic");
|
16 |
+
|
17 |
+
if(empty($maxtrafficSites))
|
18 |
+
{
|
19 |
+
$user = Mage::getSingleton('admin/session');
|
20 |
+
$userFirstName = $user->getUser()->getFirstname();
|
21 |
+
$email = $user->getUser()->getEmail();
|
22 |
+
|
23 |
+
$url = 'http://e.maxtraffic.com/magento/response?&store='.$websiteUrl.'&email='.$email.'&name='.$userFirstName;
|
24 |
+
$response = json_decode(file_get_contents($url));
|
25 |
+
|
26 |
+
if($response->ok)
|
27 |
+
{
|
28 |
+
$writeConnection = $connection->getConnection('core_write');
|
29 |
+
$writeConnection->insert('maxtraffic', array('maxtraffic_website_id' => $response->data->website_id, 'maxtraffic_token' => $response->data->user_token));
|
30 |
+
|
31 |
+
$template = "\n<!-- MaxTraffic script -->\n<script type='text/javascript'>\n(function() {\nvar k = document.createElement('script');\nk.type = 'text/javascript';\nk.async = true;\nk.src = '//e.maxtraffic.com/serve/public/index.php?id=".$response->data->website_id."&d=".$response->data->website_name."';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(k, s);\n})();\n</script>\n<!-- End of MaxTraffic script -->";
|
32 |
+
|
33 |
+
$headerScripts = $readConnection->fetchAll("SELECT * FROM core_config_data WHERE path = 'design/head/includes'");
|
34 |
+
|
35 |
+
if(empty($headerScripts))
|
36 |
+
{
|
37 |
+
$writeConnection->insert('core_config_data', array('scope' => 'default', 'value' => $template, 'path' => 'design/head/includes', 'scope_id' => '0'));
|
38 |
+
}
|
39 |
+
else
|
40 |
+
{
|
41 |
+
foreach ($headerScripts as $header)
|
42 |
+
{
|
43 |
+
$script = $header['value'] .' '. $template;
|
44 |
+
|
45 |
+
$updateQue = 'UPDATE core_config_data SET value = "'.$script.'" WHERE config_id = '.$header['config_id'];
|
46 |
+
$writeConnection->query($updateQue);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
$redirect = 'login';
|
51 |
+
}
|
52 |
+
else
|
53 |
+
{
|
54 |
+
$redirect = 'invalid';
|
55 |
+
}
|
56 |
+
}
|
57 |
+
else
|
58 |
+
{
|
59 |
+
$redirect = 'login';
|
60 |
+
}
|
61 |
+
|
62 |
+
Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl("adminhtml/traffic/".$redirect))->sendResponse();
|
63 |
+
}
|
64 |
+
|
65 |
+
public function loginAction()
|
66 |
+
{
|
67 |
+
$connection = Mage::getSingleton('core/resource');
|
68 |
+
$readConnection = $connection->getConnection('core_read');
|
69 |
+
$maxtrafficSites = $readConnection->fetchAll("SELECT * FROM maxtraffic");
|
70 |
+
|
71 |
+
$maxtrafficToken = empty($maxtrafficSites) ? null : $maxtrafficSites[0]['maxtraffic_token'];
|
72 |
+
$maxtrafficWebsiteId = empty($maxtrafficSites) ? null : $maxtrafficSites[0]['maxtraffic_website_id'];
|
73 |
+
|
74 |
+
$url = 'http://e.maxtraffic.com/magento/auth?token='.$maxtrafficToken.'&website='.$maxtrafficWebsiteId;
|
75 |
+
|
76 |
+
header("Location: ".$url);
|
77 |
+
}
|
78 |
+
|
79 |
+
public function invalidAction()
|
80 |
+
{
|
81 |
+
$this->loadLayout();
|
82 |
+
|
83 |
+
$block = $this->getLayout()->createBlock('core/text', 'invalid-message')->setText('<h1>Unable to connect with MaxTraffic</h1><p>Invalid e-mail</p>');
|
84 |
+
$this->_addContent($block);
|
85 |
+
|
86 |
+
$this->renderLayout();
|
87 |
+
}
|
88 |
+
}
|
app/code/community/Maxtraffic/WidgetTraffic/etc/adminhtml.xml
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<customtab module="maxtraffic_widgettraffic" translate="title">
|
5 |
+
<title>MaxTraffic</title>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
<action>adminhtml/traffic</action>
|
8 |
+
</customtab>
|
9 |
+
</menu>
|
10 |
+
<acl>
|
11 |
+
<resources>
|
12 |
+
<admin>
|
13 |
+
<traffic translate="title" module="maxtraffic_widgettraffic">
|
14 |
+
<title>MaxTraffic Controller</title>
|
15 |
+
<sort_order>-100</sort_order>
|
16 |
+
<index translate="title">
|
17 |
+
<title>MaxTraffic</title>
|
18 |
+
<sort_order>1</sort_order>
|
19 |
+
</index>
|
20 |
+
<children>
|
21 |
+
<login translate="title">
|
22 |
+
<title>login</title>
|
23 |
+
<sort_order>2</sort_order>
|
24 |
+
</login>
|
25 |
+
<invalid translate="title">
|
26 |
+
<title>invalid</title>
|
27 |
+
<sort_order>3</sort_order>
|
28 |
+
</invalid>
|
29 |
+
</children>
|
30 |
+
</traffic>
|
31 |
+
</admin>
|
32 |
+
</resources>
|
33 |
+
</acl>
|
34 |
+
</config>
|
app/code/community/Maxtraffic/WidgetTraffic/etc/config.xml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Maxtraffic_WidgetTraffic>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Maxtraffic_WidgetTraffic>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<helpers>
|
10 |
+
<widgettraffic>
|
11 |
+
<class>Maxtraffic_WidgetTraffic_Helper</class>
|
12 |
+
</widgettraffic>
|
13 |
+
<maxtraffic_widgettraffic>
|
14 |
+
<class>Mage_Core_Helper</class>
|
15 |
+
</maxtraffic_widgettraffic>
|
16 |
+
</helpers>
|
17 |
+
<models>
|
18 |
+
<widgettraffic>
|
19 |
+
<class>Maxtraffic_WidgetTraffic_Model</class>
|
20 |
+
<resourceModel>widgettraffic_mysql4</resourceModel>
|
21 |
+
</widgettraffic>
|
22 |
+
|
23 |
+
<widgettraffic_myslq4>
|
24 |
+
<class>Maxtraffic_WidgetTraffic_Model_Mysql4</class>
|
25 |
+
<entities>
|
26 |
+
<widgettraffic>
|
27 |
+
<table>maxtraffic</table>
|
28 |
+
</widgettraffic>
|
29 |
+
</entities>
|
30 |
+
</widgettraffic_myslq4>
|
31 |
+
</models>
|
32 |
+
|
33 |
+
<resources>
|
34 |
+
<widgettraffic_setup>
|
35 |
+
<setup>
|
36 |
+
<module>Maxtraffic_WidgetTraffic</module>
|
37 |
+
</setup>
|
38 |
+
<connection>
|
39 |
+
<use>core_setup</use>
|
40 |
+
</connection>
|
41 |
+
</widgettraffic_setup>
|
42 |
+
<WidgetTraffic_write>
|
43 |
+
<connection>
|
44 |
+
<use>core_write</use>
|
45 |
+
</connection>
|
46 |
+
</WidgetTraffic_write>
|
47 |
+
<WidgetTraffic_read>
|
48 |
+
<connection>
|
49 |
+
<use>core_read</use>
|
50 |
+
</connection>
|
51 |
+
</WidgetTraffic_read>
|
52 |
+
</resources>
|
53 |
+
</global>
|
54 |
+
<admin>
|
55 |
+
<routers>
|
56 |
+
<adminhtml>
|
57 |
+
<args>
|
58 |
+
<modules>
|
59 |
+
<foo_bar before="Mage_Adminhtml">Maxtraffic_WidgetTraffic_Adminhtml</foo_bar>
|
60 |
+
</modules>
|
61 |
+
</args>
|
62 |
+
</adminhtml>
|
63 |
+
</routers>
|
64 |
+
</admin>
|
65 |
+
</config>
|
app/code/community/Maxtraffic/WidgetTraffic/sql/widgettraffic_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
$installer->startSetup();
|
4 |
+
$table = $installer->getConnection()->newTable($installer->getTable('maxtraffic'))
|
5 |
+
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
|
6 |
+
'unsigned' => true,
|
7 |
+
'nullable' => false,
|
8 |
+
'primary' => true,
|
9 |
+
'identity' => true,
|
10 |
+
), 'ID')
|
11 |
+
->addColumn('maxtraffic_website_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
|
12 |
+
'nullable' => false,
|
13 |
+
), 'Maxtraffic Website ID')
|
14 |
+
->addColumn('maxtraffic_token', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
|
15 |
+
'nullable' => false,
|
16 |
+
), 'Maxtraffic token');
|
17 |
+
$installer->getConnection()->createTable($table);
|
18 |
+
$installer->endSetup();
|
app/etc/modules/Maxtraffic_WidgetTraffic.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Maxtraffic_WidgetTraffic>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Maxtraffic_WidgetTraffic>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>MaxTraffic_Exit_Offers</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Turn your abandoning visitors into customers.</summary>
|
10 |
+
<description>Turn your abandoning visitors into customers. Use this extension to implement our onsite marketing platform. After that see your sales increase by up to 15%.</description>
|
11 |
+
<notes>Version 1.0.0 - Stable release.</notes>
|
12 |
+
<authors><author><name>Krisjanis</name><user>MaxTraffic</user><email>krisjanis@maxtraffic.com</email></author></authors>
|
13 |
+
<date>2015-08-31</date>
|
14 |
+
<time>12:12:04</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Maxtraffic"><dir name="WidgetTraffic"><dir name="Helper"><file name="Data.php" hash="210b54a4ab109fb00f328f9c1ad20583"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="TrafficController.php" hash="05a5580660e85d5a3b37345d44ed009e"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="88fe9458526d5e199fece28775de7a9d"/><file name="config.xml" hash="40b15804219ba63655fc3ab8a5514e9f"/></dir><dir name="sql"><dir name="widgettraffic_setup"><file name="install-1.0.0.php" hash="04b5d02e861ae5ac8e6aaf68425ccca4"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Maxtraffic_WidgetTraffic.xml" hash="670e08b71fa3707e49eac1bae76ea728"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>5.6.0</max></php></required></dependencies>
|
18 |
+
</package>
|