Lexity_Live - Version 1.0.0

Version Notes

Initial release.

Download this release

Release Info

Developer Lexity
Extension Lexity_Live
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Lexity/LexCore/Block/Live.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lexity_LexCore_Block_Live extends Mage_Adminhtml_Block_Template
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('lexity/lexcore/live.phtml');
8
+ }
9
+ }
app/code/local/Lexity/LexCore/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Lexity_LexCore_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+ ?>
app/code/local/Lexity/LexCore/Model/Core.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lexity_LexCore_Model_Core extends Mage_Core_Model_Config
3
+ {
4
+ public $app_name = 'marketing';
5
+ public $platform = 'magento';
6
+
7
+ public function has_lexity_user()
8
+ {
9
+ $resource = Mage::getSingleton('core/resource');
10
+ $readConnection = $resource->getConnection('core_read');
11
+ $tableName = $resource->getTableName('api/user');
12
+ $results = $readConnection->fetchALL("SELECT * FROM api_user where username = 'lexity' LIMIT 1");
13
+
14
+ return (isset($results[0]) && $results[0]["email"] == 'support@lexity.com');
15
+ }
16
+
17
+ public function add_lexity_user($api_key)
18
+ {
19
+ $role = Mage::getModel('api/roles')
20
+ ->setName('lexity')
21
+ ->setPid(false)
22
+ ->setRoleType('G')
23
+ ->save();
24
+
25
+ Mage::getModel("api/rules")
26
+ ->setRoleId($role->getId())
27
+ ->setResources(array('all'))
28
+ ->saveRel();
29
+
30
+ $user = Mage::getModel('api/user');
31
+ $user->setData(array(
32
+ 'username' => 'lexity',
33
+ 'firstname' => 'lexity',
34
+ 'lastname' => 'lexity',
35
+ 'email' => 'support@lexity.com',
36
+ 'api_key' => $api_key,
37
+ 'api_key_confirmation' => $api_key,
38
+ 'is_active' => 1,
39
+ 'user_roles' => '',
40
+ 'assigned_user_role' => '',
41
+ 'role_name' => '',
42
+ 'roles' => array($role->getId())
43
+ ));
44
+
45
+ $user->save()->load($user->getId());
46
+
47
+ $user->setRoleIds(array($role->getId()))
48
+ ->setRoleUserId($user->getUserId())
49
+ ->saveRelations();
50
+ }
51
+
52
+ public function create_account($new_token = null, $signup_type = null)
53
+ {
54
+ $user = Mage::getModel('api/user');
55
+ $user->loadByUsername('lexity');
56
+
57
+ $hash = $user->getApiKey();
58
+ $hashArr = explode(':', $hash);
59
+ switch (count($hashArr)) {
60
+ case 1:
61
+ $token = $hash;
62
+ case 2:
63
+ $token = $hashArr[0];
64
+ $skey = $hashArr[1];
65
+ }
66
+
67
+ if (isset($new_token)) {
68
+ $token = $new_token;
69
+ }
70
+
71
+ $uri = "https://lexity.com/xcomapi/createaccount?app="
72
+ . $this->app_name
73
+ . "&platform=" . $this->platform . "&token=" . $token
74
+ . "&url=" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
75
+
76
+ if (isset($skey)) {
77
+ $uri .= "&skey=${skey}";
78
+ }
79
+
80
+ $admin_user = Mage::getSingleton('admin/session')->getUser();
81
+ if (isset($admin_user)) {
82
+ $uri .= "&email=" . urlencode($admin_user->getEmail());
83
+ }
84
+
85
+ if ($signup_type != null) {
86
+ $uri .= "&signup_type=" . $signup_type;
87
+ }
88
+
89
+ # initiate handshake
90
+ $client = new Varien_Http_Client($uri);
91
+ $response = $client->request('GET');
92
+ $body = $response->getBody();
93
+
94
+ $decode = json_decode($body);
95
+ if (!isset($decode->error) && isset($decode->public_id)) {
96
+ $this->saveConfig('lexcore/core/public_id', $decode->public_id);
97
+ }
98
+
99
+ return $decode->redirect_url;
100
+ }
101
+
102
+ public function get_lexity_login_url($target = null)
103
+ {
104
+ $user = Mage::getModel('api/user');
105
+ $user->loadByUsername('lexity');
106
+
107
+ $hash = $user->getApiKey();
108
+ $hashArr = explode(':', $hash);
109
+ switch (count($hashArr)) {
110
+ case 1:
111
+ $token = $hash;
112
+ case 2:
113
+ $token = $hashArr[0];
114
+ $skey = $hashArr[1];
115
+ }
116
+
117
+ $public_id = Mage::getStoreConfig('lexcore/core/public_id');
118
+
119
+ $redirect_url = "https://lexity.com/xcomapi/login?app="
120
+ . $this->app_name
121
+ . "&platform=" . $this->platform . "&token=" . $token
122
+ . "&public_id=" . Mage::getStoreConfig('lexcore/core/public_id');
123
+
124
+ if (isset($skey)) {
125
+ $redirect_url .= "&skey=${skey}";
126
+ }
127
+ if (!empty($target)) {
128
+ $redirect_url .= "&target=${target}";
129
+ }
130
+
131
+ return $redirect_url;
132
+ }
133
+
134
+ public function loginAndRedirect($target = null, $signup_type = null)
135
+ {
136
+ $public_id = Mage::getStoreConfig('lexcore/core/public_id');
137
+ if (empty($public_id)) {
138
+ $token = null;
139
+ if (!$this->has_lexity_user()) {
140
+ $token = md5(uniqid());
141
+ $this->add_lexity_user($token);
142
+ }
143
+
144
+ return $this->create_account($token, $signup_type);
145
+ }
146
+ else {
147
+ return $this->get_lexity_login_url($target);
148
+ }
149
+ }
150
+ }
151
+ ?>
app/code/local/Lexity/LexCore/Model/Core/Api.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lexity_LexCore_Model_Core_Api extends Mage_Api_Model_Resource_Abstract
4
+ {
5
+ public function getMisc()
6
+ {
7
+ Mage::app()->getCacheInstance()->cleanType('config');
8
+ $js = Mage::getStoreConfig('design/head/includes');
9
+ return $js;
10
+ }
11
+
12
+ public function setMisc($js)
13
+ {
14
+ Mage::app()->getCacheInstance()->cleanType('config');
15
+ Mage::getModel('core/config')->saveConfig('design/head/includes', $js );
16
+ return array('status' => 'updated');
17
+ }
18
+ }
app/code/local/Lexity/LexCore/controllers/Adminhtml/LexCore/IndexController.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lexity_LexCore_Adminhtml_LexCore_IndexController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function liveAction()
5
+ {
6
+ $this->_title('Lexity Live');
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('Lexity');
9
+ $this->_addContent($this->getLayout()->createBlock('lexcore/live'));
10
+ $this->renderLayout();
11
+ }
12
+
13
+ public function marketingAction()
14
+ {
15
+
16
+ }
17
+ }
app/code/local/Lexity/LexCore/controllers/Adminhtml/LexCore/LexityController.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lexity_LexCore_Adminhtml_LexCore_LexityController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function liveAction()
5
+ {
6
+ Mage::Log('In the liveAction for adminhtml lexity controller');
7
+ $this->_title('Lexity Live');
8
+ $this->loadLayout()
9
+ ->_setActiveMenu('Lexity');
10
+ $this->_addContent($this->getLayout()->createBlock('lexcore/live'));
11
+ $this->renderLayout();
12
+ }
13
+
14
+ public function marketingAction()
15
+ {
16
+
17
+ }
18
+ }
app/code/local/Lexity/LexCore/controllers/Adminhtml/LexCore/LiveController.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lexity_LexCore_Adminhtml_LexCore_LiveController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->_title('Lexity Live');
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('Lexity');
9
+ $this->_addContent($this->getLayout()->createBlock('lexcore/live'));
10
+ $this->renderLayout();
11
+ }
12
+ }
app/code/local/Lexity/LexCore/controllers/Adminhtml/LexityController.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Lexity_LexCore_Adminhtml_LexityController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->setUsedModuleName('Lexity_LexCore');
7
+ }
8
+
9
+ public function liveAction()
10
+ {
11
+ $this->_title('Lexity Live');
12
+ $this->loadLayout()
13
+ ->_setActiveMenu('lexity/live');
14
+ $this->_addContent($this->getLayout()->createBlock('lexcore/live'));
15
+ $this->renderLayout();
16
+ }
17
+
18
+ public function marketingAction()
19
+ {
20
+ $this->_title('Lexity Dashboard');
21
+ $this->loadLayout()
22
+ ->_setActiveMenu('lexity/marketing');
23
+
24
+ $uri = Mage::getModel('lexcore/core')->loginAndRedirect();
25
+ $this->getResponse()->setRedirect($uri);
26
+ }
27
+ }
app/code/local/Lexity/LexCore/etc/api.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <api>
5
+ <resources>
6
+ <lexcore_core translate="title" module="lexcore">
7
+ <model>lexcore/core_api</model>
8
+ <title>Lexity Core API</title>
9
+ <acl>lexcore/core</acl>
10
+ <methods>
11
+ <getMisc translate="title" module="lexcore">
12
+ <title>Get header scripts</title>
13
+ <method>getMisc</method>
14
+ </getMisc>
15
+ <setMisc translate="title" module="lexcore">
16
+ <title>Set header scripts</title>
17
+ <method>setMisc</method>
18
+ </setMisc>
19
+ </methods>
20
+ </lexcore_core>
21
+ </resources>
22
+ </api>
23
+ </config>
app/code/local/Lexity/LexCore/etc/config.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Lexity_LexCore>
5
+ <version>0.1.0</version>
6
+ </Lexity_LexCore>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <lexcore>
11
+ <class>Lexity_LexCore_Helper</class>
12
+ </lexcore>
13
+ </helpers>
14
+ <models>
15
+ <lexcore>
16
+ <class>Lexity_LexCore_Model</class>
17
+ </lexcore>
18
+ </models>
19
+ <blocks>
20
+ <lexcore>
21
+ <class>Lexity_LexCore_Block</class>
22
+ </lexcore>
23
+ </blocks>
24
+ </global>
25
+ <admin>
26
+ <routers>
27
+ <adminhtml>
28
+ <args>
29
+ <modules>
30
+ <Lexity_LexCore before="Mage_Adminhtml">Lexity_LexCore_Adminhtml</Lexity_LexCore>
31
+ </modules>
32
+ </args>
33
+ </adminhtml>
34
+ </routers>
35
+ </admin>
36
+ <adminhtml>
37
+ <menu>
38
+ <lexity translate="title">
39
+ <title>Lexity</title>
40
+ <sort_order>99</sort_order>
41
+ <children>
42
+ <lexlive translate="title">
43
+ <title>Live</title>
44
+ <action>adminhtml/lexity/live</action>
45
+ <sort_order>10</sort_order>
46
+ </lexlive>
47
+ <lexdash translate="title">
48
+ <title>Apps</title>
49
+ <action>adminhtml/lexity/marketing</action>
50
+ <sort_order>20</sort_order>
51
+ </lexdash>
52
+ </children>
53
+ </lexity>
54
+ </menu>
55
+ </adminhtml>
56
+ </config>
app/design/adminhtml/default/default/template/lexity/lexcore/live.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ $liveUri = Mage::getModel('lexcore/core')->loginAndRedirect(urlencode('live?embed=true'), 'live');
3
+ ?>
4
+
5
+ <iframe src="<?php echo $liveUri ?>" width="100%" style="min-height: 800px;" scrolling="auto" frameborder="0"></iframe>
app/etc/modules/Lexity_LexCore.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Lexity_LexCore>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ </Lexity_LexCore>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Lexity_Live</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>BSD License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Your Customers. In Real Time. For Free. </summary>
10
+ <description>With Lexity Live You Can:&#xD;
11
+ &#xD;
12
+ Monitor Your Customer Activity In Real Time&#xD;
13
+ &#xD;
14
+ Lexity Live is a free website traffic analysis tool designed for ecommerce, with real-time visitor tracking. Other tools like Google Analytics can take hours to process data, too late for you to react. With Lexity Live, real-time information about current site visitors lets you watch your customers browse your web site and category pages, learn about your products from product pages, and go from checkout to purchase, all as it happens. &#xD;
15
+ &#xD;
16
+ Track Your Store's Traffic&#xD;
17
+ &#xD;
18
+ See how your traffic improves over time and when your peak hours of business are, while tracking where your customers are coming from and what they are looking for. View reports on unique visitors, page views, keyword trends, top referring sites, search engines, and geolocation.&#xD;
19
+ &#xD;
20
+ See Where Your Customers Spend Their Time&#xD;
21
+ &#xD;
22
+ What pages do your customers look at and for how long? Where are they dropping off? Find out by tracking each individual customer and seeing their realtime behavior in your ecommerce store. Detailed path and page analysis reports for unique visitors include time on site, down to the second.</description>
23
+ <notes>Initial release.</notes>
24
+ <authors><author><name>Lexity</name><user>lexity</user><email>support@lexity.com</email></author></authors>
25
+ <date>2012-05-21</date>
26
+ <time>22:19:52</time>
27
+ <contents><target name="magelocal"><dir name="Lexity"><dir name="LexCore"><dir name="Block"><file name="Live.php" hash="d73b67a7eb31016c2ee3e6f674cfcf11"/></dir><dir name="Helper"><file name="Data.php" hash="e727c8f95fe6b6a049e6fc6352cdc77f"/></dir><dir name="Model"><dir name="Core"><file name="Api.php" hash="d40a9a0a8798eb92ea3d4c1f686dc7ab"/></dir><file name="Core.php" hash="d2236aa839d5b6c2aa4d69044619bdcf"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="LexCore"><file name="IndexController.php" hash="b1c3a31ae524d50f1bcfb0774f062430"/><file name="LexityController.php" hash="aa384afcd33df4bac04e248108456599"/><file name="LiveController.php" hash="8cabfac1641087f53f5ab922eabe0603"/></dir><file name="LexityController.php" hash="074b7a58f03f49671f37d3b864a61b82"/></dir></dir><dir name="etc"><file name="api.xml" hash="242f90416f3df2c6656e2f94b6d5c8dd"/><file name="config.xml" hash="f57969b8d4aae894514711f975d4d38c"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Lexity_LexCore.xml" hash="b45eb5c776e018a3ddee602195a444d0"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="lexity"><dir name="lexcore"><file name="live.phtml" hash="5bdd09bece977c7626989d6f28292b0c"/></dir></dir></dir></dir></dir></dir></target></contents>
28
+ <compatible/>
29
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
30
+ </package>