Inside_Analytics - Version 2.2.0

Version Notes

Dynamic route configuration with support for all existing Magento extensions.

Download this release

Release Info

Developer Hadar Paz
Extension Inside_Analytics
Version 2.2.0
Comparing to
See all releases


Version 2.2.0

Files changed (29) hide show
  1. app/code/community/Inside/Analytics/Block/Adminhtml/Route.php +23 -0
  2. app/code/community/Inside/Analytics/Block/Adminhtml/Route/Edit.php +61 -0
  3. app/code/community/Inside/Analytics/Block/Adminhtml/Route/Edit/Form.php +33 -0
  4. app/code/community/Inside/Analytics/Block/Adminhtml/Route/Edit/Tab/General.php +176 -0
  5. app/code/community/Inside/Analytics/Block/Adminhtml/Route/Edit/Tabs.php +21 -0
  6. app/code/community/Inside/Analytics/Block/Adminhtml/Route/Grid.php +147 -0
  7. app/code/community/Inside/Analytics/Block/Analytics.php +158 -0
  8. app/code/community/Inside/Analytics/Helper/Data.php +156 -0
  9. app/code/community/Inside/Analytics/Model/Mysql4/Route.php +17 -0
  10. app/code/community/Inside/Analytics/Model/Mysql4/Route/Collection.php +17 -0
  11. app/code/community/Inside/Analytics/Model/Observer.php +49 -0
  12. app/code/community/Inside/Analytics/Model/PageView.php +297 -0
  13. app/code/community/Inside/Analytics/Model/PageView/Type.php +159 -0
  14. app/code/community/Inside/Analytics/Model/Route.php +79 -0
  15. app/code/community/Inside/Analytics/Model/System/Config/Source/Abstract.php +88 -0
  16. app/code/community/Inside/Analytics/Model/System/Config/Source/Page/Type.php +43 -0
  17. app/code/community/Inside/Analytics/controllers/Adminhtml/RouteController.php +187 -0
  18. app/code/community/Inside/Analytics/etc/adminhtml.xml +64 -0
  19. app/code/community/Inside/Analytics/etc/config.xml +117 -0
  20. app/code/community/Inside/Analytics/etc/system.xml +92 -0
  21. app/code/community/Inside/Analytics/sql/inside_setup/mysql4-upgrade-1.1.2-2.0.0.php +48 -0
  22. app/code/community/Inside/Analytics/sql/inside_setup/mysql4-upgrade-2.0.0-2.1.0.php +18 -0
  23. app/code/community/Inside/Analytics/sql/inside_setup/mysql4-upgrade-2.1.0-2.2.0.php +18 -0
  24. app/design/adminhtml/default/default/layout/inside/analytics.xml +25 -0
  25. app/design/frontend/base/default/layout/inside/analytics.xml +18 -0
  26. app/design/frontend/base/default/template/inside/analytics.phtml +20 -0
  27. app/etc/modules/Inside_Analytics.xml +9 -0
  28. package.xml +40 -0
  29. skin/adminhtml/default/default/inside/route.js +21 -0
app/code/community/Inside/Analytics/Block/Adminhtml/Route.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Block_Adminhtml_Route
11
+ extends Mage_Adminhtml_Block_Widget_Grid_Container {
12
+
13
+ public function __construct()
14
+ {
15
+ $this->_blockGroup = 'inside';
16
+ $this->_controller = 'adminhtml_route';
17
+ $this->_headerText = $this->__('Track Routes');
18
+ $this->_addButtonLabel = 'Add New Route';
19
+ parent::__construct();
20
+
21
+ }
22
+ }
23
+
app/code/community/Inside/Analytics/Block/Adminhtml/Route/Edit.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of class...
4
+ *
5
+ * @category Inside
6
+ * @package Inside_Analytics
7
+ * @author Inside <martin.novak@inside.tm>
8
+ */
9
+ class Inside_Analytics_Block_Adminhtml_Route_Edit
10
+ extends Mage_Adminhtml_Block_Widget_Form_Container
11
+ {
12
+ /**
13
+ * The route being edited
14
+ * @var Inside_Analytics_Model_Route
15
+ */
16
+ protected $_route = null;
17
+
18
+ public function __construct()
19
+ {
20
+ parent::__construct();
21
+
22
+ $this->_objectId = 'id';
23
+ $this->_blockGroup = 'inside';
24
+ $this->_controller = 'adminhtml_route';
25
+
26
+ if ($this->getRoute() && $this->getRoute()->getId() &&
27
+ !$this->getRoute()->getUserDefined())
28
+ {
29
+ //system entry - read only
30
+ $this->_removeButton('delete');
31
+ }
32
+
33
+ }
34
+
35
+ /**
36
+ * Gets the route being edited.
37
+ *
38
+ * @return Inside_Analytics_Model_Route
39
+ */
40
+ public function getRoute()
41
+ {
42
+ if (!$this->_route) {
43
+ $this->_route = Mage::registry('current_inside_route');
44
+ }
45
+ return $this->_route;
46
+ }
47
+
48
+
49
+ public function getHeaderText()
50
+ {
51
+ if ($this->getRoute() && $this->getRoute()->getId()) {
52
+ return $foo = $this->__(
53
+ 'Route # %s | %s',
54
+ $this->htmlEscape($this->getRoute()->getId()),
55
+ $this->htmlEscape($this->getRoute()->getFullQualifier())
56
+ );
57
+ } else {
58
+ return $foo = $this->__('New Track Route');
59
+ }
60
+ }
61
+ }
app/code/community/Inside/Analytics/Block/Adminhtml/Route/Edit/Form.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of class...
4
+ *
5
+ * @category Inside
6
+ * @package Inside_Analytics
7
+ * @author Inside <martin.novak@inside.tm>
8
+ */
9
+ class Inside_Analytics_Block_Adminhtml_Route_Edit_Form
10
+ extends Mage_Adminhtml_Block_Widget_Form
11
+ {
12
+
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ $this->setId('route_form');
17
+ }
18
+
19
+ protected function _prepareForm()
20
+ {
21
+ $form = new Varien_Data_Form(
22
+ array(
23
+ 'id' => 'edit_form',
24
+ 'action' => $this->getData('action'),
25
+ 'method' => 'post')
26
+ );
27
+
28
+ $form->setUseContainer(true);
29
+ $this->setForm($form);
30
+ return parent::_prepareForm();
31
+ }
32
+
33
+ }
app/code/community/Inside/Analytics/Block/Adminhtml/Route/Edit/Tab/General.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of class...
4
+ *
5
+ * @category Inside
6
+ * @package Inside_Analytics
7
+ * @author Inside <martin.novak@inside.tm>
8
+ */
9
+ class Inside_Analytics_Block_Adminhtml_Route_Edit_Tab_General
10
+ extends Mage_Adminhtml_Block_Widget_Form
11
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
12
+ {
13
+ /**
14
+ * The route being edited
15
+ * @var Inside_Analytics_Model_Route
16
+ */
17
+ protected $_route = null;
18
+
19
+ /**
20
+ * Prepare content for tab
21
+ *
22
+ * @return string
23
+ */
24
+ public function getTabLabel()
25
+ {
26
+ return $this->__('Track Route Information');
27
+ }
28
+
29
+ /**
30
+ * Prepare title for tab
31
+ *
32
+ * @return string
33
+ */
34
+ public function getTabTitle()
35
+ {
36
+ return $this->__('Track Route Information');
37
+ }
38
+
39
+ /**
40
+ * Returns status flag about this tab can be showed or not
41
+ *
42
+ * @return true
43
+ */
44
+ public function canShowTab()
45
+ {
46
+ return true;
47
+ }
48
+
49
+ /**
50
+ * Returns status flag about this tab hidden or not
51
+ *
52
+ * @return true
53
+ */
54
+ public function isHidden()
55
+ {
56
+ return false;
57
+ }
58
+
59
+ protected function _prepareForm()
60
+ {
61
+ $model = Mage::registry('current_inside_route');
62
+
63
+ $form = new Varien_Data_Form();
64
+ $form->setHtmlIdPrefix('route_');
65
+
66
+ $fieldset = $form->addFieldset('base_fieldset',
67
+ array('legend' => $this->__('General Information'))
68
+ );
69
+
70
+ if ($model->getId()) {
71
+ $fieldset->addField('id', 'hidden', array(
72
+ 'name' => 'id',
73
+ ));
74
+ }
75
+
76
+ $fieldset->addField('is_active', 'select', array(
77
+ 'name' => 'is_active',
78
+ 'label' => $this->__('Status'),
79
+ 'title' => $this->__('Status'),
80
+ 'required' => true,
81
+ 'options' => array(
82
+ '1' => $this->__('Enabled'),
83
+ '0' => $this->__('Disabled'),
84
+ ),
85
+ ));
86
+
87
+ $fieldset->addField('module', 'text', array(
88
+ 'name' => 'module',
89
+ 'label' => $this->__('Module Name'),
90
+ 'title' => $this->__('Module Name'),
91
+ 'required' => true,
92
+ 'disabled' => $this->isReadOnly(),
93
+ 'note' => $this->__('The modules route name (\'frontName\' as specified in modules configuration file).'),
94
+ ));
95
+
96
+ $fieldset->addField('controller', 'text', array(
97
+ 'name' => 'controller',
98
+ 'label' => $this->__('Controller Name'),
99
+ 'title' => $this->__('Controller Name'),
100
+ 'required' => false,
101
+ 'disabled' => $this->isReadOnly(),
102
+ 'note' => $this->__('Leave blank for any.'),
103
+ ));
104
+
105
+ $fieldset->addField('action', 'text', array(
106
+ 'label' => $this->__('Action Name'),
107
+ 'title' => $this->__('Action Name'),
108
+ 'name' => 'action',
109
+ 'required' => false,
110
+ 'disabled' => $this->isReadOnly(),
111
+ 'note' => $this->__('Leave blank for any. Only applicable if controller name exists.'),
112
+ ));
113
+
114
+ $fieldset->addField('type', 'select', array(
115
+ 'name' => 'type',
116
+ 'label' => $this->__('Page Type'),
117
+ 'title' => $this->__('Page Type'),
118
+ 'required' => true,
119
+ 'disabled' => $this->isReadOnly(),
120
+ 'options' => Mage::getSingleton('inside/system_config_source_page_type')->getOptions(),
121
+ ));
122
+
123
+ $fieldset->addField('is_ajax', 'select', array(
124
+ 'name' => 'is_ajax',
125
+ 'label' => $this->__('Is Ajax'),
126
+ 'title' => $this->__('Is Ajax'),
127
+ 'required' => true,
128
+ 'disabled' => $this->isReadOnly(),
129
+ 'options' => array(
130
+ '1' => $this->__('Yes'),
131
+ '0' => $this->__('No'),
132
+ ),
133
+ ));
134
+
135
+ $fieldset->addField('search_param', 'text', array(
136
+ 'label' => $this->__('Search Param'),
137
+ 'title' => $this->__('Search Param'),
138
+ 'name' => 'search_param',
139
+ 'required' => true,
140
+ 'disabled' => $this->isReadOnly(),
141
+ 'note' => $this->__('The search parameter name.'),
142
+ ));
143
+
144
+ $form->setValues($model->getData());
145
+ $this->setForm($form);
146
+
147
+ return parent::_prepareForm();
148
+ }
149
+
150
+ /**
151
+ * Gets the route being edited.
152
+ *
153
+ * @return Inside_Analytics_Model_Route
154
+ */
155
+ public function getRoute()
156
+ {
157
+ if (!$this->_route) {
158
+ $this->_route = Mage::registry('current_inside_route');
159
+ }
160
+ return $this->_route;
161
+ }
162
+
163
+ /**
164
+ * Is the current route read only (system) route?
165
+ * @return boolean
166
+ */
167
+ public function isReadOnly()
168
+ {
169
+ if ($this->getRoute() && $this->getRoute()->getId() &&
170
+ !$this->getRoute()->getUserDefined())
171
+ {
172
+ return true;
173
+ }
174
+ return false;
175
+ }
176
+ }
app/code/community/Inside/Analytics/Block/Adminhtml/Route/Edit/Tabs.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Block_Adminhtml_Route_Edit_Tabs
11
+ extends Mage_Adminhtml_Block_Widget_Tabs
12
+ {
13
+
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->setId('inside_route_edit_tabs');
18
+ $this->setDestElementId('edit_form');
19
+ }
20
+
21
+ }
app/code/community/Inside/Analytics/Block/Adminhtml/Route/Grid.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Block_Adminhtml_Route_Grid
11
+ extends Mage_Adminhtml_Block_Widget_Grid
12
+ {
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ $this->setSaveParametersInSession(true);
17
+ }
18
+
19
+ protected function _prepareCollection()
20
+ {
21
+ $collection = Mage::getResourceModel('inside/route_collection');
22
+ /* @var $collection Inside_Analytics_Model_Mysql4_Route_Collection */
23
+
24
+ $this->setCollection($collection);
25
+ return parent::_prepareCollection();
26
+ }
27
+
28
+ protected function _prepareColumns()
29
+ {
30
+ $this->addColumn('is_active', array(
31
+ 'header' => $this->__('Status'),
32
+ 'width' => '80px',
33
+ 'type' => 'options',
34
+ 'options'=> array(
35
+ 0 => 'Disabled',
36
+ 1 => 'Enabled',
37
+ ),
38
+ 'index' => 'is_active',
39
+ ));
40
+
41
+ $this->addColumn('module', array(
42
+ 'header' => $this->__('Module Name'),
43
+ 'width' => '100px',
44
+ 'index' => 'module',
45
+ ));
46
+
47
+ $this->addColumn('controller', array(
48
+ 'header' => $this->__('Controller Name'),
49
+ 'width' => '160px',
50
+ 'index' => 'controller',
51
+ ));
52
+
53
+ $this->addColumn('action_name', array(
54
+ 'header' => $this->__('Action Name'),
55
+ 'width' => '160px',
56
+ 'index' => 'action',
57
+ ));
58
+
59
+ $this->addColumn('full_qualifier', array(
60
+ 'header' => $this->__('Full Route'),
61
+ 'width' => '160px',
62
+ 'index' => 'full_qualifier',
63
+ ));
64
+
65
+ $this->addColumn('type', array(
66
+ 'header' => $this->__('Page Type'),
67
+ 'index' => 'type',
68
+ 'type' => 'options',
69
+ 'options'=> Mage::getSingleton('inside/system_config_source_page_type')->getOptions(),
70
+ ));
71
+
72
+ $this->addColumn('is_ajax', array(
73
+ 'header' => $this->__('Is Ajax'),
74
+ 'width' => '80px',
75
+ 'type' => 'options',
76
+ 'options'=> array(
77
+ 0 => 'No',
78
+ 1 => 'Yes',
79
+ ),
80
+ 'index' => 'is_ajax',
81
+ ));
82
+
83
+ $this->addColumn('user_defined', array(
84
+ 'header' => $this->__('User Defined'),
85
+ 'width' => '80px',
86
+ 'type' => 'options',
87
+ 'options'=> array(
88
+ 0 => 'No',
89
+ 1 => 'Yes',
90
+ ),
91
+ 'index' => 'user_defined',
92
+ ));
93
+
94
+ $this->addColumn('action', array(
95
+ 'header' => $this->__('Action'),
96
+ 'width' => '100',
97
+ 'type' => 'action',
98
+ 'getter' => 'getId',
99
+ 'actions' => array(
100
+ 'view' => array(
101
+ 'caption' => $this->__('View'),
102
+ 'url' => array('base' => '*/*/edit'),
103
+ 'field' => 'id'
104
+ )
105
+ ),
106
+ 'filter' => false,
107
+ 'sortable' => false,
108
+ 'index' => 'stores',
109
+ 'is_system' => true,
110
+ ));
111
+
112
+ return parent::_prepareColumns();
113
+ }
114
+
115
+ protected function _prepareMassaction() {
116
+ parent::_prepareMassaction();
117
+
118
+ $this->getMassactionBlock()->addItem('enable_all', array(
119
+ 'label'=> Mage::helper('inside')->__('Enable Routes'),
120
+ 'url' => $this->getUrl('*/*/massEnable'),
121
+ ));
122
+
123
+ $this->getMassactionBlock()->addItem('disable_all', array(
124
+ 'label'=> Mage::helper('inside')->__('Disable Routes'),
125
+ 'url' => $this->getUrl('*/*/massDisable'),
126
+ ));
127
+
128
+ $this->getMassactionBlock()->addItem('delete_all', array(
129
+ 'label'=> Mage::helper('inside')->__('Delete Routes'),
130
+ 'url' => $this->getUrl('*/*/massDelete'),
131
+ 'confirm' => Mage::helper('inside')->__('Only user defined routes can be deleted. Delete selected routes?'),
132
+ ));
133
+
134
+ $this->setMassactionIdField('id');
135
+ $this->getMassactionBlock()->setUseSelectAll(false);
136
+
137
+ return $this;
138
+ }
139
+
140
+
141
+ public function getRowUrl($row)
142
+ {
143
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
144
+ }
145
+
146
+ }
147
+
app/code/community/Inside/Analytics/Block/Analytics.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Block_Analytics extends Mage_Core_Block_Template
11
+ {
12
+ /**
13
+ * The current request module, controller and action name
14
+ * @var array
15
+ */
16
+ protected $_requestArray = null;
17
+
18
+ /**
19
+ * Get a specific page name (may be customized via layout)
20
+ *
21
+ * @return string|null
22
+ */
23
+ public function getPageName()
24
+ {
25
+ return $this->_getData('page_name');
26
+ }
27
+
28
+ /**
29
+ * Get main getTracker code. This will initialise the _insideGraph tracker
30
+ * object with your account key.
31
+ *
32
+ * @return string
33
+ */
34
+ protected function _getAccountCode()
35
+ {
36
+ $accountId = Mage::getStoreConfig(Inside_Analytics_Helper_Data::XML_PATH_ACCOUNT);
37
+ $visitorId = Mage::helper('inside')->getVisitorId();
38
+ $visitorName = Mage::helper('inside')->getVisitorName();
39
+ return "_inside.push({
40
+ 'action': 'getTracker', 'account': '{$this->jsQuoteEscape($accountId)}'{$visitorId}{$visitorName}
41
+ });
42
+ ";
43
+ }
44
+
45
+ /**
46
+ * Render regular page tracking javascript code
47
+ *
48
+ * @return string
49
+ */
50
+ protected function _getPageTrackingCode()
51
+ {
52
+ $script = "_inside.push({";
53
+ $data = Mage::getModel('inside/pageView')->getPageTrackCodeData($this->_requestArray);
54
+ foreach ($data as $key => $val) {
55
+ if (is_null($val)) {
56
+ continue;
57
+ }
58
+ $script .= '\''.$key.'\':\''. addslashes($val).'\',';
59
+ }
60
+
61
+ return substr($script, 0, strlen($script)-1) . "});";
62
+ }
63
+
64
+ /**
65
+ * Render order items tracking code
66
+ *
67
+ * @return string
68
+ */
69
+ protected function _getOrdersTrackingCode()
70
+ {
71
+ $script = '';
72
+ $data = Mage::getModel('inside/pageView')->getOrderTrackCodeData($this->_requestArray);
73
+ if (!empty($data)) {
74
+ foreach ($data as $index => $itemData) {
75
+ $script .= "_inside.push({";
76
+ foreach ($itemData as $key => $val) {
77
+ if (is_null($val)) {
78
+ continue;
79
+ }
80
+ $script .= '\''.$key.'\':\''. addslashes($val).'\',';
81
+ }
82
+ $script = substr($script, 0, strlen($script)-1) . "});";
83
+ }
84
+ }
85
+ return $script;
86
+ }
87
+
88
+ /**
89
+ * Render order complete tracking code
90
+ *
91
+ * @return string
92
+ */
93
+ protected function _getSaleTrackingCode()
94
+ {
95
+ $orderIds = $this->getOrderIds();
96
+ if (empty($orderIds) || !is_array($orderIds)) {
97
+ return;
98
+ }
99
+ $collection = Mage::getResourceModel('sales/order_collection')
100
+ ->addFieldToFilter('entity_id', array('in' => $orderIds))
101
+ ;
102
+ $script = '';
103
+ foreach ($collection as $order) {
104
+ /* @var $order Mage_Sales_Model_Order */
105
+ $script .= "_inside.push({
106
+ 'action':'trackOrder',
107
+ 'orderId':'{$order->getQuoteId()}',
108
+ 'orderTotal':'{$order->getGrandTotal()}',
109
+ 'complete':'true'});";
110
+ }
111
+ return $script;
112
+ }
113
+
114
+ /**
115
+ * Render debug code - request parts
116
+ *
117
+ * @return string
118
+ */
119
+ protected function _getDebugCode()
120
+ {
121
+ if (Mage::helper('inside')->canShowRequest()) {
122
+ return '<h3>'.implode('::', array_values($this->_requestArray)).'</h3>';
123
+ }
124
+ return '';
125
+ }
126
+
127
+ /**
128
+ * Render Inside Analytics tracking scripts
129
+ *
130
+ * @return string
131
+ */
132
+ protected function _toHtml()
133
+ {
134
+ if (!Mage::helper('inside')->isInsideAnalyticsAvailable() || !is_array($this->_requestArray)) {
135
+ return $this->_getDebugCode();
136
+ }
137
+
138
+ return parent::_toHtml();
139
+ }
140
+
141
+ /**
142
+ * Load current request route params
143
+ */
144
+ protected function _prepareLayout() {
145
+ parent::_prepareLayout();
146
+ $action = Mage::app()->getFrontController()->getAction();
147
+ if ($action) {
148
+ $this->_requestArray = array(
149
+ 'module' => $action->getRequest()->getRequestedRouteName(),
150
+ 'controller' => $action->getRequest()->getRequestedControllerName(),
151
+ 'action' => $action->getRequest()->getRequestedActionName()
152
+ );
153
+ if(Mage::helper('inside')->isLoggingEnabled()) {
154
+ Mage::log($this->_requestArray, null, 'inside-analytics.log', true);
155
+ }
156
+ }
157
+ }
158
+ }
app/code/community/Inside/Analytics/Helper/Data.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Helper_Data extends Mage_Core_Helper_Abstract {
11
+
12
+ /**
13
+ * Config paths for using throughout the code
14
+ */
15
+ const XML_PATH_ACTIVE = 'inside/analytics/active';
16
+ const XML_PATH_ACCOUNT = 'inside/analytics/account';
17
+ const XML_LOG_ACTIVE = 'inside/debug/log';
18
+ const XML_SHOW_REQUEST = 'inside/debug/show';
19
+
20
+ const REQUEST_PART_MODULE = 'module';
21
+ const REQUEST_PART_CONTROLLER = 'controller';
22
+ const REQUEST_PART_ACTION = 'action';
23
+
24
+ /**
25
+ * Whether IA is ready to use
26
+ *
27
+ * @param mixed $store
28
+ * @return bool
29
+ */
30
+ public function isInsideAnalyticsAvailable($store = null)
31
+ {
32
+ $accountId = Mage::getStoreConfig(self::XML_PATH_ACCOUNT, $store);
33
+ return $accountId && Mage::getStoreConfigFlag(self::XML_PATH_ACTIVE, $store);
34
+ }
35
+
36
+ /**
37
+ * Get customerId string for the main getTracker script
38
+ * customer email is a md5 string (logged in customers only)
39
+ */
40
+ public function getVisitorId()
41
+ {
42
+ if (Mage::helper('customer')->isLoggedIn()) {
43
+ $customer = Mage::helper('customer')->getCustomer();
44
+ /* @var $customer Mage_Customer_Model_Customer */
45
+ $emailAddress = $customer->getEmail();
46
+ if (strlen($emailAddress)) {
47
+ return ', \'visitorId\': \''.md5($emailAddress).'\'';
48
+ }
49
+ }
50
+ return '';
51
+ }
52
+
53
+ /**
54
+ * Get customer full name for the main getTracker script
55
+ * @return string
56
+ */
57
+ public function getVisitorName()
58
+ {
59
+ if (Mage::helper('customer')->isLoggedIn()) {
60
+ $customer = Mage::helper('customer')->getCustomer();
61
+ /* @var $customer Mage_Customer_Model_Customer */
62
+ $fullName = $customer->getName();
63
+ if (strlen($fullName)) {
64
+ return ', \'visitorName\': \''.$fullName.'\'';
65
+ }
66
+ }
67
+ return '';
68
+ }
69
+
70
+ /**
71
+ * Gets product image Url (thumbnail)
72
+ *
73
+ * @param Mage_Catalog_Model_Product $product
74
+ * @return string|null
75
+ */
76
+ public function getProductImageUrl(Mage_Catalog_Model_Product $product)
77
+ {
78
+ return sprintf('%s', Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(256));
79
+ }
80
+
81
+ /**
82
+ * Gets combined parent category names this product/category belongs to.
83
+ *
84
+ * @param Varien_Object $object
85
+ * @return string
86
+ */
87
+ public function getFullCategoryName(Varien_Object $object)
88
+ {
89
+ $categoryName = array();
90
+ if ($object instanceof Mage_Catalog_Model_Product) {
91
+ $category = $object->getCategory();
92
+ } else {
93
+ $category = $object;
94
+ }
95
+ if ($category instanceof Mage_Catalog_Model_Category) {
96
+ $categoryName[] = $category->getName();
97
+ $parentCategory = $category->getParentCategory();
98
+ while ($parentCategory instanceof Mage_Catalog_Model_Category
99
+ && $parentCategory->getParentId() > 1)
100
+ {
101
+ $categoryName[] = $parentCategory->getName();
102
+ $parentCategory = $parentCategory->getParentCategory();
103
+ }
104
+ }
105
+ return array_reverse($categoryName);
106
+ }
107
+
108
+ /**
109
+ * Gets category array from page title (Amasty improved navigation)
110
+ *
111
+ * @return array
112
+ */
113
+ public function getAmastyCategory()
114
+ {
115
+ $title = explode(' - ', Mage::app()->getLayout()->getBlock('head')->getTitle());
116
+ return $title;
117
+ }
118
+
119
+ /**
120
+ * Is extension logging enabled?
121
+ *
122
+ * @param int $store
123
+ * @return boolean
124
+ */
125
+ public function isLoggingEnabled($store = null)
126
+ {
127
+ return Mage::getStoreConfigFlag(self::XML_LOG_ACTIVE, $store);
128
+ }
129
+
130
+ /**
131
+ * Can request array be shown?
132
+ *
133
+ * @param int $store
134
+ * @return boolean
135
+ */
136
+ public function canShowRequest($store = null)
137
+ {
138
+ return Mage::getStoreConfigFlag(self::XML_SHOW_REQUEST, $store);
139
+ }
140
+
141
+ /**
142
+ * Returns all search parameter names available
143
+ *
144
+ * @return array
145
+ */
146
+ public function getAllSearchParams()
147
+ {
148
+ $searchParams = array();
149
+ $collection = Mage::getResourceModel('inside/route_collection')
150
+ ->addFieldToFilter('search_param', array('notnull' => true));
151
+ foreach ($collection as $route) {
152
+ $searchParams[] = $route->getSearchParam();
153
+ }
154
+ return $searchParams;
155
+ }
156
+ }
app/code/community/Inside/Analytics/Model/Mysql4/Route.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Model_Mysql4_Route
11
+ extends Mage_Core_Model_Mysql4_Abstract {
12
+
13
+ public function _construct() {
14
+ $this->_init('inside/route', 'id');
15
+ }
16
+
17
+ }
app/code/community/Inside/Analytics/Model/Mysql4/Route/Collection.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Model_Mysql4_Route_Collection extends
11
+ Mage_Core_Model_Mysql4_Collection_Abstract
12
+ {
13
+ public function _construct()
14
+ {
15
+ $this->_init('inside/route');
16
+ }
17
+ }
app/code/community/Inside/Analytics/Model/Observer.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Model_Observer {
11
+
12
+ public function setOrderSuccessPageView(Varien_Event_Observer $observer)
13
+ {
14
+ $orderIds = $observer->getEvent()->getOrderIds();
15
+ if (empty($orderIds) || !is_array($orderIds)) {
16
+ return;
17
+ }
18
+ $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('inside_analytics');
19
+ if ($block) {
20
+ $block->setOrderIds($orderIds);
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Saves update on next flag into session (Ajax calls only)
26
+ *
27
+ * @param Varien_Event_Observer $observer
28
+ */
29
+ public function setAjax(Varien_Event_Observer $observer)
30
+ {
31
+ $frontController = $observer->getEvent()->getFront();
32
+ /* @var $frontController Mage_Core_Controller_Varien_Front */
33
+ $routes = Mage::getResourceModel('inside/route_collection')
34
+ ->addFieldToFilter('is_active', 1)
35
+ ->addFieldToFilter('is_ajax', 1);
36
+
37
+ foreach ($routes as $route) {
38
+ /* @var $route Inside_Analytics_Model_Route */
39
+ if ($route->matches(
40
+ $frontController->getRequest()->getModuleName(),
41
+ $frontController->getRequest()->getControllerName(),
42
+ $frontController->getRequest()->getActionName()
43
+ )) {
44
+ Mage::getSingleton('core/session')->setInsideUpdateOnNext(true);
45
+ }
46
+ }
47
+ }
48
+ }
49
+
app/code/community/Inside/Analytics/Model/PageView.php ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Model_PageView extends Mage_Core_Model_Abstract {
11
+
12
+ /**
13
+ * @var Inside_Analytics_Model_PageView_Type
14
+ */
15
+ protected $_pageViewType = null;
16
+
17
+ /**
18
+ * @var Mage_Catalog_Model_Product
19
+ */
20
+ protected $_product = null;
21
+
22
+ /**
23
+ * @var Mage_Catalog_Model_Category
24
+ */
25
+ protected $_category = null;
26
+
27
+ /**
28
+ * Is Amasty Improved Navigation extension active?
29
+ *
30
+ * @var boolean
31
+ */
32
+ protected $_isAmasty = false;
33
+
34
+
35
+ public function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->_pageViewType = Mage::getModel('inside/pageView_type');
39
+ $this->_loadProduct()->_loadCategory();
40
+ }
41
+
42
+ /**
43
+ * Gets array of pageTrack required data
44
+ *
45
+ * @param string $fullActionName
46
+ * @return array
47
+ */
48
+ public function getPageTrackCodeData($requestArray)
49
+ {
50
+ $this->_setAmasty($requestArray);
51
+ $type = $this->_pageViewType->getPageType($requestArray);
52
+ $common = array(
53
+ 'action' => 'trackView',
54
+ 'type' => $type,
55
+ 'name' => $this->_pageViewType->getPageName($type),
56
+ 'orderId' => $this->_getOrderId(),
57
+ 'orderTotal' => $this->_getOrderTotal(),
58
+ 'shippingTotal' => $this->_getShippingTotal()
59
+ );
60
+ $pageSpecificData = $this->_getPageSpecificByType($type);
61
+ return array_merge($common, $pageSpecificData);
62
+ }
63
+
64
+ /**
65
+ * Gets array of order track data
66
+ *
67
+ * @param string $fullActionName
68
+ * @return array
69
+ */
70
+ public function getOrderTrackCodeData($requestArray)
71
+ {
72
+ $items = array();
73
+ $type = $this->_pageViewType->getPageType($requestArray);
74
+ if (($type == Inside_Analytics_Model_System_Config_Source_Page_Type::CHECKOUT || $this->_isForcedOrderUpdate())
75
+ && $this->_getQuote()->getItemsCount() > 0)
76
+ {
77
+ foreach ($this->_getQuote()->getAllVisibleItems() as $item)
78
+ {
79
+ /* @var $item Mage_Sales_Model_Quote_Item */
80
+ $items[] = array(
81
+ 'action' => 'addItem',
82
+ 'orderId' => $this->_getOrderId(),
83
+ 'sku' => $item->getSku(),
84
+ 'name' => $item->getName(),
85
+ 'img' => Mage::helper('inside')->getProductImageUrl($item->getProduct()),
86
+ 'price' => $item->getPriceInclTax() ? $item->getPriceInclTax() : $item->getPrice(),
87
+ 'qty' => $item->getQty()
88
+ );
89
+ }
90
+ //Add track order array
91
+ $items[] = array(
92
+ 'action' => 'trackOrder',
93
+ 'orderId' => $this->_getOrderId(),
94
+ 'orderTotal'=> $this->_getOrderTotal(),
95
+ 'shippingTotal' => $this->_getShippingTotal(),
96
+ 'update' => 'false'
97
+ );
98
+ }
99
+ if ($this->_isForcedOrderUpdate()) {
100
+ $this->_resetSession();
101
+ }
102
+ return $items;
103
+ }
104
+
105
+ /**
106
+ * Gets specific data based on current page type
107
+ * (ie product image on product pages)
108
+ *
109
+ * @param string $type
110
+ * @return string
111
+ */
112
+ protected function _getPageSpecificByType($type)
113
+ {
114
+ $extra = array();
115
+ switch ($type) {
116
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::CATEGORY:
117
+ if ($this->_isAmasty) {
118
+ $categoryArr = array_reverse(Mage::helper('inside')->getAmastyCategory());
119
+ $extra['name'] = array_pop($categoryArr);
120
+ $extra['category'] = implode(' / ', $categoryArr);
121
+ if (empty($extra['name']) && $this->_category instanceof Mage_Catalog_Model_Category) {
122
+ //defaults to real category name
123
+ $this->_category->getName();
124
+ }
125
+ } else {
126
+ //standard Magento
127
+ if ($this->_category instanceof Mage_Catalog_Model_Category) {
128
+ $catArr = Mage::helper('inside')->getFullCategoryName($this->_category);
129
+ $extra['name'] = array_pop($catArr);
130
+ $extra['category'] = implode(' / ', $catArr);
131
+ }
132
+ }
133
+ break;
134
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::PRODUCT:
135
+ if ($this->_product instanceof Mage_Catalog_Model_Product) {
136
+ if($categoryName = Mage::helper('inside')->getFullCategoryName($this->_product)) {
137
+ $extra['category'] = implode(' / ', $categoryName);
138
+ }
139
+ if($imageUrl = Mage::helper('inside')->getProductImageUrl($this->_product)) {
140
+ $extra['img'] = $imageUrl;
141
+ }
142
+ //rewrite page name to include product name
143
+ $extra['name'] = $this->_product->getName();
144
+ }
145
+ break;
146
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::SEARCH:
147
+ $params = Mage::helper('inside')->getAllSearchParams();
148
+ foreach ($params as $param) {
149
+ if ($value = Mage::app()->getRequest()->getParam($param)) {
150
+ $extra['name'] = $value;
151
+ break;
152
+ }
153
+ }
154
+ break;
155
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::ARTICLE:
156
+ $extra['name'] = Mage::app()->getLayout()->getBlock('head')->getTitle();
157
+ break;
158
+
159
+ }
160
+ return $extra;
161
+ }
162
+
163
+ /**
164
+ * Get unique identifier of a page
165
+ * (used by Inside to distinguish different pages of the same type)
166
+ *
167
+ * @deprecated Since v1.1.2 (Oct 7th 2013)
168
+ * @param string $type
169
+ * @return string
170
+ */
171
+ protected function _getPageUniqueId($type)
172
+ {
173
+ $id = null;
174
+ switch ($type) {
175
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::CATEGORY:
176
+ if ($this->_category instanceof Mage_Catalog_Model_Category) {
177
+ $id = $this->_category->getId();
178
+ }
179
+ break;
180
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::PRODUCT:
181
+ if ($this->_product instanceof Mage_Catalog_Model_Product) {
182
+ $id = $this->_product->getId();
183
+ }
184
+ break;
185
+ }
186
+ return $id;
187
+ }
188
+
189
+ /**
190
+ * Get checkout quote instance by current session
191
+ *
192
+ * @return Mage_Sales_Model_Quote
193
+ */
194
+ protected function _getQuote()
195
+ {
196
+ return Mage::getSingleton('checkout/session')->getQuote();
197
+ }
198
+
199
+ /**
200
+ * Return Quote ID (only if items in cart)
201
+ *
202
+ * @return int|null
203
+ */
204
+ protected function _getOrderId()
205
+ {
206
+ if ($this->_getQuote()->getItemsCount() > 0) {
207
+ return $this->_getQuote()->getId();
208
+ }
209
+ return null;
210
+ }
211
+
212
+ /**
213
+ * Return formatted grand total of the current quote if active
214
+ *
215
+ * @return string
216
+ */
217
+ protected function _getOrderTotal()
218
+ {
219
+ if ($this->_getOrderId()) {
220
+ return sprintf('%.2f', $this->_getQuote()->getGrandTotal());
221
+ }
222
+ return null;
223
+ }
224
+
225
+ /**
226
+ * Return formatted grand total of the current quote if active
227
+ *
228
+ * @return string
229
+ */
230
+ protected function _getShippingTotal()
231
+ {
232
+ if ($this->_getOrderId()) {
233
+ return sprintf('%.2f', $this->_getQuote()->getShippingAddress()->getBaseShippingInclTax());
234
+ }
235
+ return null;
236
+ }
237
+
238
+ /**
239
+ * Load current product from registry
240
+ * @return \Inside_Analytics_Model_PageView
241
+ */
242
+ protected function _loadProduct()
243
+ {
244
+ $product = Mage::registry('current_product');
245
+ if ($product && $product->getId()) {
246
+ $this->_product = $product;
247
+ }
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * Load current category from registry
253
+ * @return \Inside_Analytics_Model_PageView
254
+ */
255
+ protected function _loadCategory()
256
+ {
257
+ $category = Mage::registry('current_category');
258
+ if ($category && $category->getId()) {
259
+ $this->_category = $category;
260
+ }
261
+ return $this;
262
+ }
263
+
264
+ /**
265
+ * Checks for Amasty improved navigation extension
266
+ *
267
+ * @param array $requestArr
268
+ * @return \Inside_Analytics_Model_PageView
269
+ */
270
+ protected function _setAmasty($requestArr)
271
+ {
272
+ if ($requestArr[Inside_Analytics_Helper_Data::REQUEST_PART_MODULE] == 'amshopby') {
273
+ $this->_isAmasty = true;
274
+ }
275
+ return $this;
276
+ }
277
+
278
+ /**
279
+ * Check if we have outstanding Ajax add-to-cart call
280
+ *
281
+ * @return boolean
282
+ */
283
+ protected function _isForcedOrderUpdate()
284
+ {
285
+ return Mage::getSingleton('core/session')->getInsideUpdateOnNext() === true;
286
+ }
287
+
288
+ /**
289
+ * Resets Ajax call related session variables
290
+ */
291
+ protected function _resetSession()
292
+ {
293
+ Mage::getSingleton('core/session')->unsetData('inside_update_on_next');
294
+ }
295
+
296
+ }
297
+
app/code/community/Inside/Analytics/Model/PageView/Type.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Model_PageView_Type extends Mage_Core_Model_Abstract {
11
+
12
+ /**
13
+ * List of page view types and associated route names
14
+ * @var array
15
+ */
16
+ protected $_typeActions = array();
17
+
18
+ public function _construct()
19
+ {
20
+ $this->_loadTrackRoutes();
21
+ }
22
+
23
+ /**
24
+ * Loads array of page types and configured routes
25
+ *
26
+ * @return \Inside_Analytics_Model_PageView_Type
27
+ */
28
+ protected function _loadTrackRoutes()
29
+ {
30
+ $routes = Mage::getResourceModel('inside/route_collection')
31
+ ->addFieldToFilter('is_active', true);
32
+ foreach($routes as $route) {
33
+ /* @var $route Inside_Analytics_Model_Route */
34
+ if (array_key_exists($route->getType(), $this->_typeActions)) {
35
+ $this->_typeActions[$route->getType()][] = $route->getFullQualifier();
36
+ } else {
37
+ $this->_typeActions[$route->getType()] = array($route->getFullQualifier());
38
+ }
39
+ }
40
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * Get list of allowed page view types
45
+ *
46
+ * @return array
47
+ */
48
+ public function getAllowedPageViewTypes()
49
+ {
50
+ return array_keys($this->_typeActions);
51
+ }
52
+
53
+ /**
54
+ * Get associative array of all allowed page view types
55
+ * and their action names
56
+ *
57
+ * @return array
58
+ */
59
+ public function getTypeActions()
60
+ {
61
+ return $this->_typeActions;
62
+ }
63
+
64
+ /**
65
+ * Get page type based on the full action name
66
+ *
67
+ * @param string $fullActionName
68
+ * @return string
69
+ */
70
+ public function getPageType($requestArray)
71
+ {
72
+ $fullActionName = implode('_', array_values($requestArray));
73
+ $match = $this->_getPageTypeExact($fullActionName);
74
+ if (!$match) {
75
+ $found = false;
76
+ foreach ($this->getTypeActions() as $type => $actions)
77
+ {
78
+ foreach ($actions as $action) {
79
+ $_t = explode('_', $action);
80
+ switch (count($_t))
81
+ {
82
+ case 1: //match only module name
83
+ if ($_t[0] === $requestArray[Inside_Analytics_Helper_Data::REQUEST_PART_MODULE]) {
84
+ $match = $type; $found = true;
85
+ }
86
+ break;
87
+ case 2: //match module and controller name
88
+ if ($_t[0] === $requestArray[Inside_Analytics_Helper_Data::REQUEST_PART_MODULE] &&
89
+ $_t[1] === $requestArray[Inside_Analytics_Helper_Data::REQUEST_PART_CONTROLLER])
90
+ {
91
+ $match = $type; $found = true;
92
+ }
93
+ break;
94
+ }
95
+ if ($found) break;
96
+ }
97
+ if ($found) break;
98
+ }
99
+ }
100
+ return $match ? $match : Inside_Analytics_Model_System_Config_Source_Page_Type::OTHER;
101
+ }
102
+
103
+ /**
104
+ * Search for exact full action name match in page type actions
105
+ *
106
+ * @param string $key
107
+ * @return string Page type or false if not found
108
+ */
109
+ protected function _getPageTypeExact($key)
110
+ {
111
+ foreach ($this->getTypeActions() as $type => $actions)
112
+ {
113
+ if (in_array($key, $actions)) {
114
+ return $type;
115
+ }
116
+ }
117
+ return false;
118
+ }
119
+
120
+ /**
121
+ * Get page name based on it's type
122
+ *
123
+ * @param string $type
124
+ * @return string
125
+ */
126
+ public function getPageName($type)
127
+ {
128
+ $name = 'Unknown/Untracked Page Type';
129
+ switch ($type) {
130
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::HOMEPAGE:
131
+ $name = 'Home Page'; break;
132
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::ARTICLE:
133
+ $name = 'Information Page'; break;
134
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::SEARCH:
135
+ $name = 'Search Result Page'; break;
136
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::CATEGORY:
137
+ $name = 'Product Category Page'; break;
138
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::PRODUCT:
139
+ $name = 'Product Page'; break;
140
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::LOGIN:
141
+ $name = 'Login Page'; break;
142
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::CHECKOUT:
143
+ $name = 'Checkout/Cart Page'; break;
144
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::ORDERCONFIRMED:
145
+ $name = 'Order Confirmation Page'; break;
146
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::LEAD:
147
+ $name = 'Lead Page'; break;
148
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::LEADCONFIRMED:
149
+ $name = 'Lead Confirmation Page'; break;
150
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::NOTFOUND:
151
+ $name = 'Page Not Found (404)'; break;
152
+ case Inside_Analytics_Model_System_Config_Source_Page_Type::OTHER:
153
+ default:
154
+ $name = 'Page Type Not Available'; break;
155
+ }
156
+
157
+ return $name;
158
+ }
159
+ }
app/code/community/Inside/Analytics/Model/Route.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @method string getModule()
5
+ * @method string getController()
6
+ * @method string getAction()
7
+ * @method string getFullQualifier()
8
+ * @method string getType()
9
+ * @method boolean getUserDefined()
10
+ *
11
+ * @method Inside_Analytics_Model_Route setModule()
12
+ * @method Inside_Analytics_Model_Route setController()
13
+ * @method Inside_Analytics_Model_Route setAction()
14
+ * @method Inside_Analytics_Model_Route setFullQualifier()
15
+ * @method Inside_Analytics_Model_Route setType()
16
+ * @method Inside_Analytics_Model_Route setUserDefined()
17
+ *
18
+ *
19
+ * Description of class...
20
+ *
21
+ * @category Inside
22
+ * @package Inside_Analytics
23
+ * @author Inside <martin.novak@inside.tm>
24
+ */
25
+ class Inside_Analytics_Model_Route extends Mage_Core_Model_Abstract {
26
+
27
+ public function _construct()
28
+ {
29
+ parent::_construct();
30
+ $this->_init('inside/route');
31
+ }
32
+
33
+ /**
34
+ * Checks if request matches this tracking route
35
+ *
36
+ * @param string $module
37
+ * @param string $controller
38
+ * @param string $action
39
+ * @return boolean
40
+ */
41
+ public function matches($module, $controller, $action)
42
+ {
43
+ if ($this->getModule() !== $module) {
44
+ return false;
45
+ }
46
+ if ($this->getController() && $this->getController() !== $controller) {
47
+ return false;
48
+ }
49
+ if ($this->getAction() && $this->getAction() !== $action) {
50
+ return false;
51
+ }
52
+ return true;
53
+ }
54
+
55
+ /**
56
+ * Fixes full route qualifier
57
+ * @return \Inside_Analytics_Model_Route
58
+ */
59
+ protected function _fixRouteName()
60
+ {
61
+ $fullName = $this->getModule();
62
+ if ($this->getController()) {
63
+ $fullName = $fullName . '_' . $this->getController();
64
+
65
+ if ($this->getAction()) {
66
+ $fullName = $fullName . '_' . $this->getAction();
67
+ }
68
+ }
69
+ $this->setFullQualifier($fullName);
70
+ return $this;
71
+ }
72
+
73
+ protected function _beforeSave()
74
+ {
75
+ parent::_beforeSave();
76
+ $this->_fixRouteName();
77
+ return $this;
78
+ }
79
+ }
app/code/community/Inside/Analytics/Model/System/Config/Source/Abstract.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of class...
4
+ *
5
+ * @category Inside
6
+ * @package Inside_Analytics
7
+ * @author Inside <martin.novak@inside.tm>
8
+ */
9
+ abstract class Inside_Analytics_Model_System_Config_Source_Abstract
10
+ {
11
+
12
+ /**
13
+ * The array of options in the configuration item.
14
+ *
15
+ * This array's keys are the values used in the database etc. and the
16
+ * values of this array are used as labels on the frontend.
17
+ *
18
+ * @var array
19
+ */
20
+ protected $_options;
21
+
22
+ public function __construct()
23
+ {
24
+ $this->_setupOptions();
25
+ }
26
+
27
+ /**
28
+ * Sets up the $_options array with the correct values.
29
+ *
30
+ * This function is called in the constructor.
31
+ *
32
+ * @return Inside_Analytics_Model_System_Config_Source_Abstract
33
+ */
34
+ protected abstract function _setupOptions();
35
+
36
+ /**
37
+ * Gets all the options in the key => value type array.
38
+ *
39
+ * @return array
40
+ */
41
+ public function getOptions($please_select = false)
42
+ {
43
+ $options = $this->_options;
44
+ if ($please_select) {
45
+ $options = array(null => '--Please Select--') + $options;
46
+ }
47
+ return $options;
48
+ }
49
+
50
+ /**
51
+ * Converts the options into a format suitable for use in the admin area.
52
+ *
53
+ * @return array
54
+ */
55
+ public function toOptionArray()
56
+ {
57
+ return $this->_toOptionArray($this->_options);
58
+ }
59
+
60
+ protected function _toOptionArray($input)
61
+ {
62
+ $array = array();
63
+
64
+ foreach ($input as $key => $value) {
65
+ $array[] = array(
66
+ 'value' => $key,
67
+ 'label' => $value,
68
+ );
69
+ }
70
+
71
+ return $array;
72
+ }
73
+
74
+ /**
75
+ * Looks up an option by key and gets the label.
76
+ *
77
+ * @param mixed $value
78
+ * @return mixed
79
+ */
80
+ public function getOptionLabel($value)
81
+ {
82
+ if (array_key_exists($value, $this->_options)) {
83
+ return $this->_options[$value];
84
+ }
85
+ return null;
86
+ }
87
+
88
+ }
app/code/community/Inside/Analytics/Model/System/Config/Source/Page/Type.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of class...
4
+ *
5
+ * @category Inside
6
+ * @package Inside_Analytics
7
+ * @author Inside <martin.novak@inside.tm>
8
+ */
9
+ class Inside_Analytics_Model_System_Config_Source_Page_Type
10
+ extends Inside_Analytics_Model_System_Config_Source_Abstract
11
+ {
12
+
13
+ const HOMEPAGE = 'homepage';
14
+ const ARTICLE = 'article';
15
+ const SEARCH = 'search';
16
+ const CATEGORY = 'productcategory';
17
+ const PRODUCT = 'product';
18
+ const LOGIN = 'login';
19
+ const CHECKOUT = 'checkout';
20
+ const ORDERCONFIRMED = 'orderconfirmed';
21
+ const LEAD = 'lead';
22
+ const LEADCONFIRMED = 'leadconfirmed';
23
+ const NOTFOUND = 'pagenotfound';
24
+ const OTHER = 'other';
25
+
26
+ protected function _setupOptions()
27
+ {
28
+ $this->_options = array(
29
+ self::HOMEPAGE => Mage::helper('inside')->__('Home Page'),
30
+ self::ARTICLE => Mage::helper('inside')->__('Article Page'),
31
+ self::SEARCH => Mage::helper('inside')->__('Search Result Page'),
32
+ self::CATEGORY => Mage::helper('inside')->__('Product Category Page'),
33
+ self::PRODUCT => Mage::helper('inside')->__('Product View Page'),
34
+ self::LOGIN => Mage::helper('inside')->__('Login Page'),
35
+ self::CHECKOUT => Mage::helper('inside')->__('Shopping Cart or Checkout Page'),
36
+ self::ORDERCONFIRMED => Mage::helper('inside')->__('Order Confirmation Page'),
37
+ // self::LEAD => Mage::helper('inside')->__('Lead/Form Page'),
38
+ // self::LEADCONFIRMED => Mage::helper('inside')->__('Lead/Form Confirmation Page'),
39
+ self::NOTFOUND => Mage::helper('inside')->__('Page not Found (404)'),
40
+ );
41
+ }
42
+
43
+ }
app/code/community/Inside/Analytics/controllers/Adminhtml/RouteController.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ class Inside_Analytics_Adminhtml_RouteController extends Mage_Adminhtml_Controller_Action {
11
+
12
+ const ERR_UNIQUE_CONSTRAINT = 'Track route with the same name already exists.';
13
+ const ERR_SAVE_GENERIC = 'Error saving track route name.';
14
+
15
+ const MODE_DISABLE = 0;
16
+ const MODE_ENABLE = 1;
17
+ const MODE_DELETE = 2;
18
+
19
+
20
+ protected $_allowedModes = array(
21
+ self::MODE_DISABLE => 'disabled',
22
+ self::MODE_ENABLE => 'enabled',
23
+ self::MODE_DELETE => 'deleted',
24
+ );
25
+
26
+ public function indexAction()
27
+ {
28
+ $this->loadLayout()->_setActiveMenu('inside/route')->renderLayout();
29
+ }
30
+
31
+ public function newAction() {
32
+ $this->_forward('edit');
33
+ }
34
+
35
+ public function editAction()
36
+ {
37
+ $id = $this->getRequest()->getParam('id', null);
38
+ $model = Mage::getModel('inside/route');
39
+ /* @var $model Inside_Analytics_Model_Route */
40
+ if ($id) {
41
+ $model->load((int) $id);
42
+ if ($model->getId()) {
43
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
44
+ if ($data) {
45
+ $model->setData($data)->setId($id);
46
+ }
47
+ } else {
48
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Route does not exist'));
49
+ $this->_redirect('*/*/');
50
+ }
51
+ }
52
+ Mage::register('current_inside_route', $model);
53
+
54
+ $this->loadLayout();
55
+ $this->renderLayout();
56
+ }
57
+
58
+ public function saveAction()
59
+ {
60
+ if ($data = $this->getRequest()->getPost()) {
61
+ $model = Mage::getModel('inside/route');
62
+ /* @var $model Inside_Analytics_Model_Route */
63
+ $id = $this->getRequest()->getParam('id');
64
+ foreach ($data as $key => $val) {
65
+ $data[$key] = trim($val);
66
+ }
67
+ $model->setData($data);
68
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
69
+ try {
70
+ if ($id) {
71
+ $model->setId($id);
72
+ }
73
+
74
+ $model->save();
75
+ if (!$model->getId()) {
76
+ Mage::throwException($this->__('Error saving route'));
77
+ }
78
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Route was successfully saved.'));
79
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
80
+
81
+ $this->_redirect('*/*/');
82
+ } catch (Exception $e) {
83
+ Mage::logException($e);
84
+ if(stristr($e->getMessage(), 'UNIQUE_ROUTE_NAME')) {
85
+ Mage::getSingleton('adminhtml/session')->addError(self::ERR_UNIQUE_CONSTRAINT);
86
+ } else {
87
+ Mage::getSingleton('adminhtml/session')->addError(self::ERR_SAVE_GENERIC);
88
+ }
89
+ if ($model && $model->getId()) {
90
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
91
+ } else {
92
+ $this->_redirect('*/*/');
93
+ }
94
+ }
95
+
96
+ return;
97
+ }
98
+ Mage::getSingleton('adminhtml/session')->addError($this->__('No data found to save'));
99
+ $this->_redirect('*/*/');
100
+ }
101
+
102
+ public function deleteAction() {
103
+ $id = $this->getRequest()->getParam('id');
104
+ $model = Mage::getModel('inside/route')->load($id);
105
+
106
+ if ($model->getId() == $id) {
107
+ try {
108
+ $model->delete();
109
+ $this->_getSession()->addSuccess($this->__('The route has been deleted.'));
110
+ $this->_redirect('*/*/');
111
+ return;
112
+ } catch (Exception $e) {
113
+ $this->_getSession()->addError($this->__('Error deleting route.'));
114
+ $this->_redirect('*/*/edit', array('id' => $id));
115
+ return;
116
+ }
117
+ } else {
118
+ $this->_getSession()->addError($this->__('Invalid route id supplied. Route does not exist.'));
119
+ $this->_redirect('*/*/');
120
+ return;
121
+ }
122
+ }
123
+
124
+ public function massDeleteAction() {
125
+ return $this->massStatusAction(self::MODE_DELETE);
126
+ }
127
+
128
+ public function massEnableAction() {
129
+ return $this->massStatusAction(self::MODE_ENABLE);
130
+ }
131
+
132
+ public function massDisableAction() {
133
+ return $this->massStatusAction(self::MODE_DISABLE);
134
+ }
135
+
136
+ protected function massStatusAction($mode = 0)
137
+ {
138
+ if(!array_key_exists($mode, $this->_allowedModes)) {
139
+ $this->_getSession()->addError('Invalid mode specified for mass status action.');
140
+ $this->_redirect('*/*');
141
+ return;
142
+ }
143
+ $params = $this->getRequest()->getParams();
144
+ if (!isset($params['massaction']) || !is_array($params['massaction']) || empty($params['massaction'])) {
145
+ $this->_getSession()->addError(Mage::helper('inside')->__('No routes selected.'));
146
+ $this->_redirect('*/*/');
147
+ }
148
+ $route_ids = $params['massaction'];
149
+ $notices = array(); $count = 0;
150
+ foreach ($route_ids as $id) {
151
+ $route = Mage::getModel('inside/route')->load($id);
152
+ /* @var $route Inside_Analytics_Model_Route */
153
+ if (!$route || !$route->getId()) {
154
+ $notices[] = "Route ID $id not found.";
155
+ continue;
156
+ }
157
+ switch($mode) {
158
+ case self::MODE_DELETE:
159
+ if ($route->getUserDefined()) {
160
+ $route->delete();
161
+ } else {
162
+ $count--;
163
+ }
164
+ break;
165
+ case self::MODE_ENABLE:
166
+ case self::MODE_DISABLE:
167
+ $route->setIsActive($mode);
168
+ $route->save();
169
+ break;
170
+ }
171
+
172
+ $count++;
173
+ }
174
+ if (!empty($notices)) {
175
+ foreach ($notices as $notice) {
176
+ $this->_getSession()->addError($notice);
177
+ }
178
+ }
179
+ $successMsg = $this->_allowedModes[$mode];
180
+ $this->_getSession()->addSuccess("Total of $count routes $successMsg.");
181
+ //back to index route grid
182
+ $this->_redirect('*/*/');
183
+
184
+ return;
185
+ }
186
+
187
+ }
app/code/community/Inside/Analytics/etc/adminhtml.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ -->
11
+ <config>
12
+ <menu>
13
+ <inside translate="title" module="inside">
14
+ <title>Inside</title>
15
+ <sort_order>75</sort_order>
16
+ <children>
17
+ <routes translate="title" module="inside">
18
+ <title>Manage Tracking Routes</title>
19
+ <sort_order>10</sort_order>
20
+ <action>inside/adminhtml_route</action>
21
+ </routes>
22
+ <configuration translate="title" module="inside">
23
+ <title>Settings</title>
24
+ <sort_order>20</sort_order>
25
+ <action>adminhtml/system_config/edit/section/inside</action>
26
+ </configuration>
27
+ </children>
28
+ </inside>
29
+ </menu>
30
+ <acl>
31
+ <resources>
32
+ <all>
33
+ <title>Allow Everything</title>
34
+ </all>
35
+ <admin>
36
+ <children>
37
+ <inside>
38
+ <title>Inside</title>
39
+ <sort_order>10</sort_order>
40
+ <children>
41
+ <routes>
42
+ <title>Tracking Route Manager</title>
43
+ </routes>
44
+ <configuration>
45
+ <title>Inside Settings</title>
46
+ </configuration>
47
+ </children>
48
+ </inside>
49
+ <system>
50
+ <children>
51
+ <config>
52
+ <children>
53
+ <inside translate="title" module="inside">
54
+ <title>Inside Analytics</title>
55
+ </inside>
56
+ </children>
57
+ </config>
58
+ </children>
59
+ </system>
60
+ </children>
61
+ </admin>
62
+ </resources>
63
+ </acl>
64
+ </config>
app/code/community/Inside/Analytics/etc/config.xml ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Inside_Analytics>
14
+ <version>2.2.0</version>
15
+ </Inside_Analytics>
16
+ </modules>
17
+ <global>
18
+ <models>
19
+ <inside>
20
+ <class>Inside_Analytics_Model</class>
21
+ <resourceModel>inside_mysql4</resourceModel>
22
+ </inside>
23
+ <inside_mysql4>
24
+ <class>Inside_Analytics_Model_Mysql4</class>
25
+ <entities>
26
+ <route><table>insideanalytics_route</table></route>
27
+ </entities>
28
+ </inside_mysql4>
29
+ </models>
30
+ <blocks>
31
+ <inside>
32
+ <class>Inside_Analytics_Block</class>
33
+ </inside>
34
+ </blocks>
35
+ <helpers>
36
+ <inside>
37
+ <class>Inside_Analytics_Helper</class>
38
+ </inside>
39
+ </helpers>
40
+ <resources>
41
+ <inside_setup>
42
+ <setup>
43
+ <module>Inside_Analytics</module>
44
+ <class>Mage_Eav_Model_Entity_Setup</class>
45
+ </setup>
46
+ <connection>
47
+ <use>core_setup</use>
48
+ </connection>
49
+ </inside_setup>
50
+ <inside_write>
51
+ <connection>
52
+ <use>core_write</use>
53
+ </connection>
54
+ </inside_write>
55
+ <inside_read>
56
+ <connection>
57
+ <use>core_read</use>
58
+ </connection>
59
+ </inside_read>
60
+ </resources>
61
+ </global>
62
+ <frontend>
63
+ <events>
64
+ <checkout_onepage_controller_success_action>
65
+ <observers>
66
+ <insideanalytics_order_success>
67
+ <class>inside/observer</class>
68
+ <method>setOrderSuccessPageView</method>
69
+ </insideanalytics_order_success>
70
+ </observers>
71
+ </checkout_onepage_controller_success_action>
72
+ <checkout_multishipping_controller_success_action>
73
+ <observers>
74
+ <insideanalytics_order_success>
75
+ <class>inside/observer</class>
76
+ <method>setOrderSuccessPageView</method>
77
+ </insideanalytics_order_success>
78
+ </observers>
79
+ </checkout_multishipping_controller_success_action>
80
+ <controller_front_send_response_after>
81
+ <observers>
82
+ <insideanalytics_front_response_after>
83
+ <class>inside/observer</class>
84
+ <method>setAjax</method>
85
+ </insideanalytics_front_response_after>
86
+ </observers>
87
+ </controller_front_send_response_after>
88
+ </events>
89
+ <layout>
90
+ <updates>
91
+ <inside>
92
+ <file>inside/analytics.xml</file>
93
+ </inside>
94
+ </updates>
95
+ </layout>
96
+ </frontend>
97
+ <adminhtml>
98
+ <layout>
99
+ <updates>
100
+ <inside>
101
+ <file>inside/analytics.xml</file>
102
+ </inside>
103
+ </updates>
104
+ </layout>
105
+ </adminhtml>
106
+ <admin>
107
+ <routers>
108
+ <inside>
109
+ <use>admin</use>
110
+ <args>
111
+ <module>Inside_Analytics</module>
112
+ <frontName>inside</frontName>
113
+ </args>
114
+ </inside>
115
+ </routers>
116
+ </admin>
117
+ </config>
app/code/community/Inside/Analytics/etc/system.xml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ -->
11
+ <config>
12
+ <sections>
13
+ <inside translate="label" module="inside">
14
+ <label>Inside</label>
15
+ <tab>sales</tab>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>345</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <groups>
22
+ <analytics translate="label">
23
+ <label>Inside</label>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>10</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
+ <comment>
30
+ <![CDATA[
31
+ <div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
32
+ In order for your plugin to work you need to obtain a unique Account Key for your domain.
33
+ Please <a href="http://www.inside.tm/getstarted/" target="_blank">click here</a> or visit www.inside.tm/getstarted
34
+ to register your website and we will generate a Key that will be sent back to you. Once you receive the Key, please
35
+ enter it in the relevant field below and save.
36
+ </div>
37
+ ]]>
38
+ </comment>
39
+ <fields>
40
+ <active translate="label">
41
+ <label>Enable</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <sort_order>10</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </active>
49
+ <account translate="label">
50
+ <label>Account ID</label>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>20</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </account>
57
+ </fields>
58
+ </analytics>
59
+ <debug translate="label">
60
+ <label>Debug</label>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>20</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ <fields>
67
+ <log translate="label">
68
+ <label>Enable Logging</label>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>adminhtml/system_config_source_yesno</source_model>
71
+ <sort_order>10</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ <comment><![CDATA[Enable extension logging: /var/log/inside-analytics.log]]></comment>
76
+ </log>
77
+ <show translate="label">
78
+ <label>Show Request</label>
79
+ <frontend_type>select</frontend_type>
80
+ <source_model>adminhtml/system_config_source_yesno</source_model>
81
+ <sort_order>20</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
+ <comment><![CDATA[Display current request module, controller and action name at the top of every page.]]></comment>
86
+ </show>
87
+ </fields>
88
+ </debug>
89
+ </groups>
90
+ </inside>
91
+ </sections>
92
+ </config>
app/code/community/Inside/Analytics/sql/inside_setup/mysql4-upgrade-1.1.2-2.0.0.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ set_time_limit(0);
4
+
5
+ /* @var $this Mage_Eav_Model_Entity_Setup */
6
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
7
+
8
+ $installer = $this;
9
+ $installer->startSetup();
10
+
11
+ // Create custom track route table
12
+ $installer->run("
13
+ DROP TABLE IF EXISTS {$this->getTable('insideanalytics_route')};
14
+ CREATE TABLE {$this->getTable('insideanalytics_route')} (
15
+ `id` int(13) UNSIGNED NOT NULL AUTO_INCREMENT,
16
+ `module` varchar(100) NOT NULL,
17
+ `controller` varchar(100) NULL DEFAULT NULL,
18
+ `action` varchar(100) NULL DEFAULT NULL,
19
+ `full_qualifier` varchar(255) NOT NULL,
20
+ `type` varchar(50) NOT NULL,
21
+ `search_param` varchar(50) NULL DEFAULT NULL,
22
+ `user_defined` boolean NOT NULL DEFAULT 1,
23
+ PRIMARY KEY (`id`),
24
+ UNIQUE KEY `UNIQUE_ROUTE_NAME` (`full_qualifier`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26
+
27
+ INSERT INTO {$this->getTable('insideanalytics_route')} (`id`, `module`, `controller`, `action`, `full_qualifier`, `type`, `search_param`, `user_defined`) VALUES
28
+ (1, 'cms', 'index', 'index', 'cms_index_index', 'homepage', NULL, 0),
29
+ (2, 'cms', 'page', 'view', 'cms_page_view', 'article', NULL, 0),
30
+ (3, 'catalog', 'seo_sitemap', 'category', 'catalog_seo_sitemap_category', 'article', NULL, 0),
31
+ (4, 'catalogsearch', 'result', 'index', 'catalogsearch_result_index', 'search', 'q', 0),
32
+ (5, 'catalogsearch', 'advanced', 'index', 'catalogsearch_advanced_index', 'search', 'q', 0),
33
+ (6, 'sli', 'search', NULL, 'sli_search', 'search', 'w', 0),
34
+ (7, 'catalog', 'category', 'view', 'catalog_category_view', 'productcategory', NULL, 0),
35
+ (8, 'amshopby', 'index', 'index', 'amshopby_index_index', 'productcategory', NULL, 0),
36
+ (9, 'catalog', 'product', 'view', 'catalog_product_view', 'product', NULL, 0),
37
+ (10, 'customer', 'account', 'login', 'customer_account_login', 'login', NULL, 0),
38
+ (11, 'checkout', 'multishipping', 'login', 'checkout_multishipping_login', 'login', NULL, 0),
39
+ (12, 'checkout', 'cart', 'index', 'checkout_cart_index', 'checkout', NULL, 0),
40
+ (13, 'checkout', 'onepage', 'index', 'checkout_onepage_index', 'checkout', NULL, 0),
41
+ (14, 'onestepcheckout', NULL, NULL, 'onestepcheckout', 'checkout', NULL, 0),
42
+ (15, 'checkout', 'multishipping', 'index', 'checkout_multishipping', 'checkout', NULL, 0),
43
+ (16, 'checkout', 'onepage', 'success', 'checkout_onepage_success', 'orderconfirmed', NULL, 0),
44
+ (17, 'checkout', 'multishipping', 'success', 'checkout_multishipping_success', 'orderconfirmed', NULL, 0),
45
+ (18, 'cms', 'index', 'noRoute', 'cms_index_noRoute', 'pagenotfound', NULL, 0)
46
+ ");
47
+
48
+ $installer->endSetup();
app/code/community/Inside/Analytics/sql/inside_setup/mysql4-upgrade-2.0.0-2.1.0.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ set_time_limit(0);
4
+
5
+ /* @var $this Mage_Eav_Model_Entity_Setup */
6
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
7
+
8
+ $installer = $this;
9
+ $installer->startSetup();
10
+
11
+ // Add support for Ajax requests
12
+ $installer->run("
13
+ ALTER TABLE {$this->getTable('insideanalytics_route')}
14
+ ADD `is_ajax` boolean NOT NULL DEFAULT 0
15
+ ;
16
+ ");
17
+
18
+ $installer->endSetup();
app/code/community/Inside/Analytics/sql/inside_setup/mysql4-upgrade-2.1.0-2.2.0.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ set_time_limit(0);
4
+
5
+ /* @var $this Mage_Eav_Model_Entity_Setup */
6
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
7
+
8
+ $installer = $this;
9
+ $installer->startSetup();
10
+
11
+ // Add support for Ajax requests
12
+ $installer->run("
13
+ ALTER TABLE {$this->getTable('insideanalytics_route')}
14
+ ADD `is_active` boolean NOT NULL DEFAULT 1
15
+ ;
16
+ ");
17
+
18
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/inside/analytics.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout>
3
+ <inside_adminhtml_route_index>
4
+ <reference name="content">
5
+ <block type="inside/adminhtml_route" name="inside_route">
6
+ <block type="inside/adminhtml_route_grid" name="inside_route_grid" />
7
+ </block>
8
+ </reference>
9
+ </inside_adminhtml_route_index>
10
+
11
+ <inside_adminhtml_route_edit>
12
+ <reference name="head">
13
+ <action method="addItem"><type>skin_js</type><name>inside/route.js</name></action>
14
+ </reference>
15
+ <reference name="left">
16
+ <block type="inside/adminhtml_route_edit_tabs" name="inside_route_edit_tabs">
17
+ <block type="inside/adminhtml_route_edit_tab_general" name="inside_route_edit_tab_general" />
18
+ <action method="addTab"><name>general_section</name><block>inside_route_edit_tab_general</block></action>
19
+ </block>
20
+ </reference>
21
+ <reference name="content">
22
+ <block type="inside/adminhtml_route_edit" name="inside_route_edit" />
23
+ </reference>
24
+ </inside_adminhtml_route_edit>
25
+ </layout>
app/design/frontend/base/default/layout/inside/analytics.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Description of class...
5
+ *
6
+ * @category Inside
7
+ * @package Inside_Analytics
8
+ * @author Inside <martin.novak@inside.tm>
9
+ */
10
+ -->
11
+ <layout version="0.1.0">
12
+ <default>
13
+ <!-- Inside_Analytics -->
14
+ <reference name="head">
15
+ <block type="inside/analytics" name="inside_analytics" as="inside_analytics" template="inside/analytics.phtml" />
16
+ </reference>
17
+ </default>
18
+ </layout>
app/design/frontend/base/default/template/inside/analytics.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!Mage::helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
2
+ <!-- BEGIN INSIDE ANALYTICS CODE -->
3
+ <?php echo $this->_getDebugCode() ?>
4
+ <script type="text/javascript">
5
+ //<![CDATA[
6
+ var _inside = _inside || [];
7
+ <?php echo $this->_getAccountCode() ?>
8
+ <?php echo $this->_getPageTrackingCode() ?>
9
+ <?php echo $this->_getOrdersTrackingCode() ?>
10
+ <?php echo $this->_getSaleTrackingCode() ?>
11
+
12
+ (function () {
13
+ var inside = document.createElement('script'); inside.type = 'text/javascript'; inside.async = true;
14
+ inside.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'inside-graph.com/ig.js?hn=' + encodeURIComponent(document.location.hostname) + '&_=' + Math.random();
15
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(inside, s);
16
+ })();
17
+ //]]>
18
+ </script>
19
+ <!-- END INSIDE ANALYTICS CODE -->
20
+ <?php endif; ?>
app/etc/modules/Inside_Analytics.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Inside_Analytics>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Inside_Analytics>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Inside_Analytics</name>
4
+ <version>2.2.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.inside.tm/servicecontract">Inside Service Contract</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Inside allows you SEE your website visitors in real-time, CHAT and CONVERT more !</summary>
10
+ <description>&lt;p&gt;INSIDE is a Real Time Online Customer Engagement System, which changes everything! For the first time, etailers can view their website\cart\webstore LIVE, view customers&#x2019; behavior, chat to customers, give coupons through chat in order to convert when it&#x2019;s matter the most! &lt;/p&gt;&#xD;
11
+ &#xD;
12
+ &lt;p&gt;Objective: Increase your online conversion by 100 basis points!&lt;/p&gt;&#xD;
13
+ &#xD;
14
+ &lt;p&gt;Gain critical insight into your online business with INSIDE, a groundbreaking service that lifts the lid on your web traffic, giving you live interaction with your customers and allowing you to act in REAL TIME &#x2013; via a user-super-friendly interface that you can understand in minutes.&lt;/p&gt;&#xD;
15
+ &#xD;
16
+ &lt;p&gt;INSIDE is a must-have weapon for increasing online conversion (up to 10 times higher!) and generating high quality leads instantly, without great expense. This innovative, world-first service is suitable for any type of website or online store, regardless of size or platform.&lt;/p&gt;&#xD;
17
+ &#xD;
18
+ &lt;p&gt;INSIDE allows businesses to view their website LIVE, by presenting avatars moving around the store representing real customers and their actions. &lt;/p&gt;&#xD;
19
+ &#xD;
20
+ &lt;p&gt;How cool is that? &lt;/p&gt;&#xD;
21
+ &#xD;
22
+ &lt;p&gt;INSIDE is the latest revolution in eCommerce presenting you real-time information about your store.&lt;/p&gt;&#xD;
23
+ &#xD;
24
+ &lt;p&gt;By using INSIDE, you will suddenly start to see 'a person' and not just statistics. You will learn much more by seeing your customer movements LIVE. For example, when you see your customer searching over and over, you will have the ability to step in and help... &lt;br /&gt;&#xD;
25
+ Or &lt;br /&gt;&#xD;
26
+ when you see a customer walking to the Checkout and spending 10 minutes there, your retail instincts from pre-online era, are woken up and you can step right in to help the customer.&lt;/p&gt;&#xD;
27
+ &#xD;
28
+ &lt;a href="http://www.inside.tm"&gt;Visit www.inside.tm&lt;/a&gt;&#xD;
29
+ &lt;p /&gt;&#xD;
30
+ Call us for an online presentation:&lt;br /&gt;&#xD;
31
+ USA Call Hadar on 310.661.0308 9AM - 6PM PST &lt;br /&gt;&#xD;
32
+ AUS Call Michael on 03 8637 1534 9AM - 5PM EST </description>
33
+ <notes>Dynamic route configuration with support for all existing Magento extensions.</notes>
34
+ <authors><author><name>Hadar Paz</name><user>MAG001834167</user><email>hadar.paz@inside.tm</email></author></authors>
35
+ <date>2013-12-22</date>
36
+ <time>06:18:06</time>
37
+ <contents><target name="magecommunity"><dir name="Inside"><dir name="Analytics"><dir name="Block"><dir name="Adminhtml"><dir name="Route"><dir name="Edit"><file name="Form.php" hash="1d33f13c65cd268aa609904a598a4a43"/><dir name="Tab"><file name="General.php" hash="3fb90a753247c42454d942b9c7c12b6a"/></dir><file name="Tabs.php" hash="aeb4125bde86d7d07a1b263e9a776274"/></dir><file name="Edit.php" hash="b250cc9a5b7252d3c8b78fac93bee273"/><file name="Grid.php" hash="6819b33d1e77a64724d3d0d0b61fe894"/></dir><file name="Route.php" hash="1116daacd2d91c25c1b11c238482e9ae"/></dir><file name="Analytics.php" hash="031b0554fcddd862a24df13701b7b0a7"/></dir><dir name="Helper"><file name="Data.php" hash="5bb9b6a14bed00717127bdd96eaedbd6"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Route"><file name="Collection.php" hash="8aceeaea4490909d1536f953ba1e28c1"/></dir><file name="Route.php" hash="ef1d9069d996c6e2886a73941fb44c61"/></dir><file name="Observer.php" hash="568b8de05d02ce6e5e8f8922bcd6e343"/><dir name="PageView"><file name="Type.php" hash="31dab4d32a850c8ebfdbea472732df2b"/></dir><file name="PageView.php" hash="d14626cc4bff93481e4999ae184b97db"/><file name="Route.php" hash="1179a02300794c50bd3ee78cfdcdd72e"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Abstract.php" hash="ffd23e007fa3f9fea473c9183bf58bc7"/><dir name="Page"><file name="Type.php" hash="4991eba0607d35132c16b0c7deec0ec0"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="RouteController.php" hash="333445550bd1f8eedf1fc3e7321e1b0d"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="11fbacf4dd6153fdff62b160f3a3cf17"/><file name="config.xml" hash="52e8d5a2008b0857766386bbc1316862"/><file name="system.xml" hash="7e86d020ee3522b783a47288440c947e"/></dir><dir name="sql"><dir name="inside_setup"><file name="mysql4-upgrade-1.1.2-2.0.0.php" hash="e123452c8d68d8961663fe6508ca580c"/><file name="mysql4-upgrade-2.0.0-2.1.0.php" hash="59426151530545b4efc807fe22002a18"/><file name="mysql4-upgrade-2.1.0-2.2.0.php" hash="4543cc4128ef9345923e9ac71c05621d"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="inside"><file name="analytics.xml" hash="76a3e04439048e976f23cf7330851ddd"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="inside"><file name="analytics.xml" hash="5d64993f4dec32725664d4ac1073b431"/></dir></dir><dir name="template"><dir name="inside"><file name="analytics.phtml" hash="b276904d6404e5ff773ac4523ea1b729"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Inside_Analytics.xml" hash="4a6e86a99302b7ddecadffb844c4c3a8"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="inside"><file name="route.js" hash="0067644797c73ca5be7c052fdcfaa78d"/></dir></dir></dir></dir></target></contents>
38
+ <compatible/>
39
+ <dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
40
+ </package>
skin/adminhtml/default/default/inside/route.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function showHide(value) {
2
+ switch(value) {
3
+ case 'search':
4
+ $("route_search_param").up().up().show();
5
+ $("route_search_param").addClassName('required-entry');
6
+ break;
7
+ default:
8
+ $("route_search_param").up().up().hide();
9
+ $("route_search_param").removeClassName('required-entry');
10
+ break;
11
+ }
12
+ }
13
+ Event.observe(window, "load", function () {
14
+ var pageType = $("route_type");
15
+ showHide(pageType.options[pageType.options.selectedIndex].value);
16
+
17
+ $("route_type").observe("change", function () {
18
+ showHide(this.options[this.options.selectedIndex].value);
19
+ });
20
+ });
21
+