Tagman_Intellitag - Version 1.0.0

Version Notes

First stable version of TagMan Intellitag extension

Download this release

Release Info

Developer Toby Doig
Extension Tagman_Intellitag
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (23) hide show
  1. app/code/community/Tagman/Intellitag/Block/Adminhtml/Variables.php +14 -0
  2. app/code/community/Tagman/Intellitag/Block/Adminhtml/Variables/Edit.php +26 -0
  3. app/code/community/Tagman/Intellitag/Block/Adminhtml/Variables/Edit/Form.php +267 -0
  4. app/code/community/Tagman/Intellitag/Block/Adminhtml/Variables/Grid.php +75 -0
  5. app/code/community/Tagman/Intellitag/Block/Field.php +87 -0
  6. app/code/community/Tagman/Intellitag/Block/JsInjector.php +190 -0
  7. app/code/community/Tagman/Intellitag/Block/Select.php +14 -0
  8. app/code/community/Tagman/Intellitag/Block/Text.php +14 -0
  9. app/code/community/Tagman/Intellitag/Helper/Data.php +4 -0
  10. app/code/community/Tagman/Intellitag/Model/Mysql4/Variables.php +8 -0
  11. app/code/community/Tagman/Intellitag/Model/Mysql4/Variables/Collection.php +8 -0
  12. app/code/community/Tagman/Intellitag/Model/System/Config/Source/Model/Select.php +20 -0
  13. app/code/community/Tagman/Intellitag/Model/Variables.php +8 -0
  14. app/code/community/Tagman/Intellitag/controllers/Adminhtml/VariablesController.php +157 -0
  15. app/code/community/Tagman/Intellitag/etc/adminhtml.xml +50 -0
  16. app/code/community/Tagman/Intellitag/etc/config.xml +90 -0
  17. app/code/community/Tagman/Intellitag/etc/system.xml +78 -0
  18. app/code/community/Tagman/Intellitag/sql/tagman_intellitag_setup/mysql4-install-1.0.0.php +34 -0
  19. app/design/adminhtml/default/default/layout/tagman/intellitag.xml +8 -0
  20. app/design/frontend/base/default/layout/tagman_intellitag.xml +31 -0
  21. app/design/frontend/base/default/template/tagman_intellitag/jsinjector.phtml +1 -0
  22. app/etc/modules/Tagman_Intellitag.xml +9 -0
  23. package.xml +19 -0
app/code/community/Tagman/Intellitag/Block/Adminhtml/Variables.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Block_Adminhtml_Variables extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ $this->_blockGroup = 'tagman_intellitag';
9
+ $this->_controller = 'adminhtml_variables';
10
+ $this->_headerText = $this->__('Variables');
11
+
12
+
13
+ }
14
+ }
app/code/community/Tagman/Intellitag/Block/Adminhtml/Variables/Edit.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Block_Adminhtml_Variables_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'tagman_intellitag';
8
+ $this->_controller = 'adminhtml_variables';
9
+
10
+ $this->_updateButton('save', 'label', $this->__('Save Variable'));
11
+ $this->_updateButton('delete', 'label', $this->__('Delete Variable'));
12
+
13
+ parent::__construct();
14
+
15
+ }
16
+
17
+ public function getHeaderText()
18
+ {
19
+ if (Mage::registry('tagman_intellitag')->getId()) {
20
+ return $this->__('Edit Variable');
21
+ }
22
+ else {
23
+ return $this->__('New Variable');
24
+ }
25
+ }
26
+ }
app/code/community/Tagman/Intellitag/Block/Adminhtml/Variables/Edit/Form.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Block_Adminhtml_Variables_Edit_Form extends Mage_Adminhtml_Block_Widget_Form{
3
+
4
+ public function __construct(){
5
+ parent::__construct();
6
+ $this->setId('tagman_intelllitag_variables_form');
7
+ $this->setTitle($this->__('Variable Information'));
8
+ }
9
+
10
+ protected function _prepareForm(){
11
+ $lmModelFromRegistry = Mage::registry('tagman_intellitag');
12
+
13
+ $loForm = new Varien_Data_Form(array(
14
+ 'id' => 'edit_form',
15
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
16
+ 'method' => 'post'
17
+ ));
18
+ $loFieldSet = $loForm->addFieldset('information_fieldset', array(
19
+ 'legend' => Mage::helper('tagman_intellitag')->__('Variable Information'),
20
+ 'class' => 'fieldset-wide',
21
+ ));
22
+ if ($lmModelFromRegistry->getId()){
23
+ $loFieldSet->addField('id', 'hidden', array(
24
+ 'name' => 'id',
25
+ ));
26
+ }
27
+ $loFieldSet->addField('value', 'hidden', array(
28
+ 'name' => 'value'
29
+ ));
30
+ $loFieldSet->addField('name', 'text', array(
31
+ 'name' => 'name',
32
+ 'label' => Mage::helper('tagman_intellitag')->__('Name'),
33
+ 'title' => Mage::helper('tagman_intellitag')->__('Name'),
34
+ 'required' => true
35
+ ));
36
+ $loFieldVariableType = $loFieldSet->addField('is_static', 'select', array(
37
+ 'name' => 'is_static',
38
+ 'label' => Mage::helper('tagman_intellitag')->__('Type'),
39
+ 'title' => Mage::helper('tagman_intellitag')->__('is_static'),
40
+ 'options' => array('1' => 'Static Variable','2' => 'Magento Variable'),
41
+ 'required' => true
42
+ ));
43
+ $loFieldMagentoValue = $loFieldSet->addField('magento_value', 'hidden', array(
44
+ 'name' => 'magento_value',
45
+ 'label' => Mage::helper('tagman_intellitag')->__('Value'),
46
+ 'title' => Mage::helper('tagman_intellitag')->__('Magento Varaible')
47
+ ));
48
+ $loFieldStaticValue = $loFieldSet->addField('static_value', 'text', array(
49
+ 'name' => 'static_value',
50
+ 'label' => Mage::helper('tagman_intellitag')->__('Value'),
51
+ 'title' => Mage::helper('tagman_intellitag')->__('Static Variable'),
52
+ 'required' => true
53
+ ));
54
+
55
+ //define models for dropdown
56
+
57
+ $laModelsForDropdownList=array('catalog/category'=>'catalog/category',
58
+ 'catalog/product'=>'catalog/product',
59
+ 'customer/customer'=>'customer/customer',
60
+ 'sales/order'=>'sales/order',
61
+ 'sales/quote'=>'sales/quote');
62
+
63
+ $loFieldMagentoModelSelect = $loFieldSet->addField('magento_model', 'select', array(
64
+ 'name' => 'magento_model',
65
+ 'label' => Mage::helper('tagman_intellitag')->__('Model'),
66
+ 'title' => Mage::helper('tagman_intellitag')->__('Magento Model'),
67
+ 'required' => true,
68
+ 'options' => $laModelsForDropdownList
69
+ ));
70
+
71
+ foreach($laModelsForDropdownList as $tsCurrentModelName){
72
+ $taPropertiesForDropdownList=null;
73
+ $tmCurrentlyLoadedModel = Mage::getModel($tsCurrentModelName);
74
+ $tsPropertyIdForHTML=str_replace("/","_",$tsCurrentModelName);
75
+ $tsPropertyIdForHTML.="_property";
76
+ $tsPropertyNameForHTML=$tsPropertyIdForHTML;
77
+
78
+ foreach (get_class_methods(get_class($tmCurrentlyLoadedModel)) as $tsCurrentMethodName){
79
+ $tsFormatedMethodName=substr($tsCurrentMethodName,3,strlen($tsCurrentMethodName));
80
+ $toReflectionMethod = new ReflectionMethod(get_class($tmCurrentlyLoadedModel),$tsCurrentMethodName);
81
+ $toReflectionParameters = $toReflectionMethod->getParameters();
82
+
83
+ //define dynamic methods that shouldn't be displayed
84
+ switch($tsCurrentModelName){
85
+ case 'catalog/category':
86
+ $laFilteredOutMethods = array('getDesignAttributes','getUrlInstance','getCacheIdTags','getCacheTags');
87
+ break;
88
+ case 'customer/customer':
89
+ $laFilteredOutMethods = array('getEntityType','getStore','getCacheIdTags','getCacheTags','getPrimaryBillingAddress','getDefaultBillingAddress','getPrimaryShippingAddress','getDefaultShippingAddress');
90
+ break;
91
+ case 'sales/order':
92
+ $laFilteredOutMethods = array('getCacheIdTags','getCacheTags','getBillingAddress','getShippingAddress','getPayment','getShippingCarrier');
93
+ break;
94
+ case 'sales/quote':
95
+ $laFilteredOutMethods = array('getStore','getCacheIdTags','getCacheTags');
96
+ break;
97
+ case 'catalog/product':
98
+ $laFilteredOutMethods = array('getCacheIdTags','getCacheTags');
99
+ break;
100
+ default:
101
+ break;
102
+ }
103
+ if(preg_match('/get/',$tsCurrentMethodName) && substr($tsCurrentMethodName,0,1)!="_" && count($toReflectionParameters)==0 && !in_array($tsCurrentMethodName,$laFilteredOutMethods)){
104
+ try{
105
+ $property_type = gettype($tmCurrentlyLoadedModel->$tsCurrentMethodName());
106
+ }
107
+ catch(Exception $e){
108
+ $property_type="NULL";
109
+ }
110
+ switch($property_type){
111
+ case 'object':
112
+ $loObject=$tmCurrentlyLoadedModel->$tsCurrentMethodName();
113
+ $loObjectVariables=get_object_vars($loObject);
114
+ if(count($loObjectVariables)>0){
115
+ $taReturnedDataArray=$loObject->getData();
116
+ $taKeysList=array_keys($taReturnedDataArray);
117
+ foreach($taKeysList as $tsKey){
118
+ $tsMethodNameExtension=str_replace("_"," ",$tsKey);
119
+ $tsMethodNameExtension=ucwords($tsMethodNameExtension);
120
+ $tsMethodNameExtension=str_replace(" ","",$tsMethodNameExtension);
121
+ $tsPropertyDropdownValue = $tsCurrentMethodName."&&get".$tsMethodNameExtension;
122
+ $taPropertiesForDropdownList[$tsPropertyDropdownValue]=$tsFormatedMethodName.' / '.$tsMethodNameExtension;
123
+ }
124
+ }
125
+ break;
126
+ case 'array':
127
+ $taReturnedArray = $tmCurrentlyLoadedModel->$tsCurrentMethodName();
128
+ if(count($taReturnedArray)>0){
129
+ switch($taReturnedArray[0]){
130
+ case 'string':
131
+ case 'integer':
132
+ case 'double':
133
+ case 'boolean':
134
+ $taPropertiesForDropdownList[$tsCurrentMethodName]=$tsFormatedMethodName;
135
+ break;
136
+ case 'NULL':
137
+ case 'array':
138
+ break;
139
+ case 'object':
140
+ $loObjectArray=$tmCurrentlyLoadedModel->$tsCurrentMethodName();
141
+ foreach($loObjectArray as $loObject){
142
+ $loObjectVariables=get_object_vars($loObject);
143
+ if(count($loObjectVariables)>0){
144
+ $taReturnedDataArray = $loObject->getData();
145
+ $taKeysList=array_keys($taReturnedDataArray);
146
+ foreach($taKeysList as $tsKey){
147
+ $tsMethodNameExtension = str_replace("_"," ",$tsKey);
148
+ $tsMethodNameExtension = ucwords($tsMethodNameExtension);
149
+ $tsMethodNameExtension = str_replace(" ","",$tsMethodNameExtension);
150
+ $tsPropertyDropdownValue = $tsCurrentMethodName."&&get".$tsMethodNameExtension;
151
+ $taPropertiesForDropdownList[$tsPropertyDropdownValue]=$tsFormatedMethodName.' / '.$tsMethodNameExtension;
152
+ }
153
+ }
154
+ }
155
+ default:
156
+ break;
157
+ }
158
+ }
159
+ break;
160
+ case 'string':
161
+ case 'integer':
162
+ case 'boolean':
163
+ case 'double':
164
+ $taPropertiesForDropdownList[$tsCurrentMethodName]=$tsFormatedMethodName;
165
+ break;
166
+ case 'NULL':
167
+ break;
168
+ default:
169
+ $taPropertiesForDropdownList[$tsCurrentMethodName]=$tsFormatedMethodName.'('.$property_type.') - NOT HANDELD';
170
+ break;
171
+ }
172
+ }
173
+
174
+ // add options manualy for models/methodes that are not initiated in backend
175
+
176
+ switch($tsCurrentModelName){
177
+ case 'catalog/category':
178
+ $taHardcodedMethodsList=array('getName','getId','getStoreIds');
179
+ break;
180
+ case 'catalog/product':
181
+ $taHardcodedMethodsList=array('getName','getPrice','getGroupPrice','getCalculatedFinalPrice','getMinimalPrice','getSpecialPrice','getSpecialFromDate','getSpecialToDate','getSku','getWeight','getId','getCategoryIds','getStoreIds','getRelatedProductIds','getUpSellProductIds','getCrossSellProductIds','getPrimaryAddressIds');
182
+ break;
183
+ case 'sales/order':
184
+ $taHardcodedMethodsList=array('getRealOrderId','getStoreCurrency','getId','getTrackingNumbers');
185
+ if($tsCurrentMethodName=="getAllItems"){
186
+ $laObjectPropertyStrings = array('getProductId','getName','getSku','getQty','getPrice');
187
+ foreach($laObjectPropertyStrings as $tsObjectProperty){
188
+ $tsNameExtension=substr($tsObjectProperty,3);
189
+ $tsPropertyDropdownValue = $tsCurrentMethodName."&&".$tsObjectProperty;
190
+ $taPropertiesForDropdownList[$tsPropertyDropdownValue]=$tsFormatedMethodName.' / '.$tsNameExtension;
191
+ next($laObjectPropertyStrings);
192
+ }
193
+ }
194
+ break;
195
+ case 'customer/customer':
196
+ $taHardcodedMethodsList=array('getId','getPrimaryAddressIds');
197
+ break;
198
+ case 'sales/quote':
199
+ $taHardcodedMethodsList=array('getId');
200
+ if($tsCurrentMethodName=="getAllItems"){
201
+ $laObjectPropertyStrings = array('getProductId','getName','getSku','getQty','getPrice');
202
+ foreach($laObjectPropertyStrings as $tsObjectProperty){
203
+ $tsNameExtension=substr($tsObjectProperty,3);
204
+ $tsPropertyDropdownValue = $tsCurrentMethodName."&&".$tsObjectProperty;
205
+ $taPropertiesForDropdownList[$tsPropertyDropdownValue]=$tsFormatedMethodName.' / '.$tsNameExtension;
206
+ next($laObjectPropertyStrings);
207
+ }
208
+ }
209
+ break;
210
+ default:
211
+ $taHardcodedMethodsList=array('');
212
+ break;
213
+ }
214
+ if (in_array($tsCurrentMethodName, $taHardcodedMethodsList)) {
215
+ $taPropertiesForDropdownList[$tsCurrentMethodName]=$tsFormatedMethodName;
216
+ }
217
+ }
218
+ $laFieldModelProperty[] = $loFieldSet->addField($tsPropertyIdForHTML, 'select', array(
219
+ 'name' => $tsPropertyNameForHTML,
220
+ 'label' => Mage::helper('tagman_intellitag')->__('Property'),
221
+ 'title' => Mage::helper('tagman_intellitag')->__($tsPropertyIdForHTML),
222
+ 'required' => true,
223
+ 'options' => $taPropertiesForDropdownList
224
+
225
+ ));
226
+ }
227
+ if($lmModelFromRegistry->getData('is_static')==2){
228
+ $taData=explode("&&",$lmModelFromRegistry->getData('magento_value'));
229
+ $tsFieldName=str_replace("/","_",$taData[0]);
230
+ $tsFieldName.="_property";
231
+ $lmModelFromRegistry->setData('magento_model',$taData[0]);
232
+ if(isset($taData[2])){
233
+ $lmModelFromRegistry->setData($tsFieldName,$taData[1].'&&'.$taData[2]);
234
+ }
235
+ else{
236
+ $lmModelFromRegistry->setData($tsFieldName,$taData[1]);
237
+ }
238
+ }
239
+ $loForm->setValues($lmModelFromRegistry->getData());
240
+ $loForm->setUseContainer(true);
241
+ $this->setForm($loForm);
242
+
243
+ $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence','dependence_fields')
244
+ ->addFieldMap($loFieldVariableType->getHtmlId(), $loFieldVariableType->getName())
245
+ ->addFieldMap($loFieldMagentoValue->getHtmlId(), $loFieldMagentoValue->getName())
246
+ ->addFieldMap($loFieldStaticValue->getHtmlId(), $loFieldStaticValue->getName())
247
+ ->addFieldMap($loFieldMagentoModelSelect->getHtmlId(), $loFieldMagentoModelSelect->getName())
248
+ ->addFieldDependence(
249
+ $loFieldStaticValue->getName(),
250
+ $loFieldVariableType->getName(),
251
+ '1')
252
+ ->addFieldDependence(
253
+ $loFieldMagentoModelSelect->getName(),
254
+ $loFieldVariableType->getName(),
255
+ '2'));
256
+ foreach($laModelsForDropdownList as $tsCurrentModelName){
257
+ $modelName[]=$tsCurrentModelName;
258
+ }
259
+ $block = $this->getChild('form_after');
260
+ for($i=0;$i<count($laFieldModelProperty);$i++){
261
+ $block->addFieldMap($laFieldModelProperty[$i]->getHtmlId(), $laFieldModelProperty[$i]->getName());
262
+ $block->addFieldDependence($laFieldModelProperty[$i]->getName(),$loFieldMagentoModelSelect->getName(),$modelName[$i]);
263
+ $block->addFieldDependence($laFieldModelProperty[$i]->getName(),$loFieldVariableType->getName(),'2');
264
+ }
265
+ return parent::_prepareForm();
266
+ }
267
+ }
app/code/community/Tagman/Intellitag/Block/Adminhtml/Variables/Grid.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Block_Adminhtml_Variables_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ // Set some defaults for our grid
9
+ $this->setDefaultSort('id');
10
+ $this->setId('tagman_intellitag_variables_grid');
11
+ $this->setDefaultDir('asc');
12
+ $this->setSaveParametersInSession(true);
13
+ $this->setUseAjax(true);
14
+ //$this->setPagerVisibility(false);
15
+ //$this->setFilterVisibility(false);
16
+
17
+ }
18
+
19
+ protected function _getCollectionClass()
20
+ {
21
+ // This is the model we are using for the grid
22
+ return 'tagman_intellitag/variables_collection';
23
+ }
24
+
25
+ protected function _prepareCollection()
26
+ {
27
+ // Get and set our collection for the grid
28
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
29
+ $this->setCollection($collection);
30
+
31
+ return parent::_prepareCollection();
32
+ }
33
+
34
+ protected function _prepareColumns()
35
+ {
36
+ // Add the columns that should appear in the grid
37
+ $this->addColumn('id',
38
+ array(
39
+ 'header'=> $this->__('ID'),
40
+ 'align' =>'right',
41
+ 'width' => '50px',
42
+ 'index' => 'id'
43
+ )
44
+ );
45
+
46
+ $this->addColumn('name',
47
+ array(
48
+ 'header'=> $this->__('Name'),
49
+ 'index' => 'name'
50
+ )
51
+ );
52
+
53
+ $this->addColumn('value',
54
+ array(
55
+ 'header'=> $this->__('Value'),
56
+ 'index' => 'value'
57
+ )
58
+ );
59
+
60
+
61
+ return parent::_prepareColumns();
62
+ }
63
+
64
+ public function getRowUrl($row)
65
+ {
66
+ // This is where our row data will link to
67
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
68
+ }
69
+
70
+ public function getGridUrl()
71
+ {
72
+ return $this->getUrl('*/*/grid', array('_current'=>true));
73
+
74
+ }
75
+ }
app/code/community/Tagman/Intellitag/Block/Field.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagman_Intellitag_Block_Field
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
5
+ {
6
+ protected $_DropDownRenderer;
7
+ protected $_TextFieldRenderer;
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ }
13
+
14
+ protected function _getDropDownRenderer()
15
+ {
16
+ if (!$this->_DropDownRenderer) {
17
+ $this->_DropDownRenderer = $this->getLayout()
18
+ ->createBlock('tagman_intellitag/select')
19
+ ->setIsRenderToJsTemplate(true);
20
+ }
21
+ return $this->_DropDownRenderer;
22
+ }
23
+
24
+ protected function _getTextFieldRenderer()
25
+ {
26
+ if (!$this->_TextFieldRenderer) {
27
+ $this->_TextFieldRenderer = $this->getLayout()
28
+ ->createBlock('tagman_intellitag/text')
29
+ ->setIsRenderToJsTemplate(true);
30
+ }
31
+ return $this->_TextFieldRenderer;
32
+ }
33
+
34
+ protected function _prepareToRender()
35
+ {
36
+ $this->_DropDownRenderer = null;
37
+ $this->_TextFieldRenderer = null;
38
+
39
+ $this->addColumn('text_field', array(
40
+ 'label' => Mage::helper('tagman_intellitag')->__('Name'),
41
+ 'renderer' => 'false'
42
+
43
+ ));
44
+ $this->addColumn('drop_down', array(
45
+ 'label' => Mage::helper('tagman_intellitag')->__('Value')
46
+ ));
47
+
48
+
49
+ // Disables "Add after" button
50
+ $this->_addAfter = false;
51
+ $this->_addButtonLabel = Mage::helper('tagman_intellitag')->__('Add New');
52
+ }
53
+
54
+ protected function _renderCellTemplate($columnName)
55
+ {
56
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
57
+
58
+ if ($columnName=="drop_down") {
59
+ return $this->_getDropDownRenderer()
60
+ ->setName($inputName)
61
+ ->setTitle($columnName)
62
+ ->setExtraParams('style="width:200px"')
63
+ ->setOptions(
64
+ // The source model defined in system config XML!
65
+ $this->getElement()->getValues())
66
+ ->toHtml();
67
+ }
68
+
69
+ return parent::_renderCellTemplate($columnName);
70
+ }
71
+
72
+ protected function _prepareArrayRow(Varien_Object $row)
73
+ {
74
+ $row->setData(
75
+ 'option_extra_attr_' . $this->_getDropDownRenderer()->calcOptionHash(
76
+ $row->getData('drop_down')),
77
+ 'selected="selected"'
78
+ );
79
+ /*
80
+ $row->setData(
81
+ 'option_extra_attr_' . $this->_getSeconFieldRenderer()->calcOptionHash(
82
+ $row->getData('second_field')),
83
+ 'selected="selected"'
84
+ );
85
+ */
86
+ }
87
+ }
app/code/community/Tagman/Intellitag/Block/JsInjector.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Block_JsInjector
3
+ extends Mage_Core_Block_Template
4
+ {
5
+
6
+ public function addTagManJavascriptBlock()
7
+ {
8
+
9
+ $client = Mage::getStoreConfig('tab1/credentials/client_id_text_field',Mage::app()->getStore());
10
+ $site = Mage::getStoreConfig('tab1/credentials/site_id_text_field',Mage::app()->getStore());
11
+ $host = Mage::getStoreConfig('tab1/credentials/host_text_field',Mage::app()->getStore());
12
+
13
+ //page_type
14
+ $controlerName = Mage::app()->getRequest()->getControllerName();
15
+
16
+ $tmParams = $this->getTmParams();
17
+
18
+
19
+ $js = '
20
+ <script type="text/javascript">
21
+ window.tmParam = {
22
+ page_type: "'.$controlerName.'"'.$tmParams.'
23
+ };
24
+ </script>
25
+
26
+ <script type="text/javascript">
27
+
28
+ (function(d,s){
29
+ var client = "'.$client.'";
30
+ var siteId = '.$site.';
31
+ // do not edit
32
+ var a=d.createElement(s),b=d.getElementsByTagName(s)[0];
33
+ a.async=true;a.type="text/javascript";
34
+ a.src="//'.$host.'/clients/"+client+"/"+siteId+".js";
35
+ a.tagman="st=(" + new Date() +")&c=" + client + "&sid=" + siteId;
36
+ b.parentNode.insertBefore(a,b);
37
+ })(document,"script");
38
+
39
+ </script>';
40
+
41
+ return ($js);
42
+ }
43
+
44
+ private function getTmParams()
45
+ {
46
+ $variables = unserialize(Mage::getStoreConfig("tab1/variables/field"));
47
+ $cModel = Mage::getModel('tagman_intellitag/variables');
48
+ $tmParam = '';
49
+ $prefix = ',
50
+ ';
51
+ foreach($variables as $var){
52
+ $name = $var['text_field'];
53
+ $varId = $var['drop_down'];
54
+ $cModel->load($varId);
55
+ $isStatic=$cModel->getData('is_static');
56
+ if($isStatic==1){
57
+ $tmParam .= $prefix . $name.': '. '"' . $cModel->getValue() .'"';
58
+ } else {
59
+ $dynamic = explode('&&', $cModel->getData('magento_value'));
60
+ $tmp_model = Mage::getModel($dynamic[0]);
61
+
62
+ switch($dynamic[0]){
63
+ case 'catalog/product':
64
+ $tmParam .= $this->getCatalogProduct($prefix, $name, $tmp_model, $dynamic);
65
+ break;
66
+ case 'catalog/category':
67
+ $tmParam .= $this->getCatalogCategory($prefix, $name, $tmp_model, $dynamic);
68
+ break;
69
+ case 'customer/customer':
70
+ $tmParam .= $this->getCustomerCustomer($prefix, $name, $tmp_model, $dynamic);
71
+ break;
72
+ case 'sales/order':
73
+ $tmParam .= $this->getSalesOrder($prefix, $name, $tmp_model, $dynamic);
74
+ break;
75
+ case 'sales/quote':
76
+ $tmParam .= $this->getSalesQuote($prefix, $name, $tmp_model, $dynamic);
77
+ break;
78
+ default:
79
+
80
+ break;
81
+ }
82
+ }
83
+ }
84
+ return ($tmParam);
85
+ }
86
+
87
+ private function getCatalogProduct($prefix, $name, $tmp_model, $dynamic){
88
+ $lParam = '';
89
+ if(Mage::registry('current_product')){
90
+ $id=Mage::registry('current_product')->getId();
91
+ $tmp_model->load($id);
92
+ $methodVal = $tmp_model->$dynamic[1]();
93
+
94
+ if (gettype($methodVal)=="object"){
95
+
96
+ $methodVal = $methodVal->$dynamic[2]();
97
+ }
98
+ if(gettype($methodVal)=="array"){
99
+ $methodVal=implode("|", $methodVal);
100
+ }
101
+ $methodVal = strip_tags($methodVal);
102
+ $lParam .= $prefix . $name.': "'.$methodVal.'"';
103
+
104
+ }
105
+ return ($lParam);
106
+ }
107
+
108
+ private function getCatalogCategory($prefix, $name, $tmp_model, $dynamic){
109
+ $lParam = '';
110
+ if(Mage::registry('current_category')){
111
+ $id=Mage::registry('current_category')->getId();
112
+ $tmp_model->load($id);
113
+ $methodVal = $tmp_model->$dynamic[1]();
114
+ if (gettype($methodVal)=="object"){
115
+ $methodVal = $methodVal->$dynamic[2]();
116
+ }
117
+ if(gettype($methodVal)=="array"){
118
+ $methodVal=implode("|", $methodVal);
119
+ }
120
+
121
+ $lParam .= $prefix . $name.': "'.$methodVal.'"';
122
+ }
123
+ return ($lParam);
124
+ }
125
+
126
+ private function getCustomerCustomer($prefix, $name, $tmp_model, $dynamic){
127
+ $lParam = '';
128
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
129
+ $id=Mage::getSingleton('customer/session')->getId();
130
+ $tmp_model->load($id);
131
+ $methodVal = $tmp_model->$dynamic[1]();
132
+ //var_dump('1'.$dynamic[1]);
133
+ if (gettype($methodVal)=="object"){
134
+ //var_dump('2'.$dynamic[2]);
135
+ $methodVal = $methodVal->$dynamic[2]();
136
+ }
137
+ if(gettype($methodVal)=="array"){
138
+ $methodVal=implode("|", $methodVal);
139
+ }
140
+ $lParam .= $prefix . $name.': "'.$methodVal.'"';
141
+ }
142
+ return ($lParam);
143
+ }
144
+
145
+ private function getSalesOrder($prefix, $name, $tmp_model, $dynamic){
146
+ $lParam = '';
147
+ $tmp_model->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
148
+ $methodVal = $tmp_model->$dynamic[1]();
149
+
150
+ if (gettype($methodVal)=="object"){
151
+ $methodVal = $methodVal->$dynamic[2]();
152
+ }
153
+ if($dynamic[1]=="getAllItems"){
154
+ $methodVal = $this->getAllItems($methodVal, $dynamic);
155
+ }
156
+ elseif(gettype($methodVal)=="array"){
157
+ $methodVal=implode("|", $methodVal);
158
+ }
159
+ $lParam .= $prefix . $name.': "'.$methodVal.'"';
160
+ return ($lParam);
161
+ }
162
+
163
+ private function getSalesQuote($prefix, $name, $tmp_model, $dynamic){
164
+ $lParam = '';
165
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
166
+ $methodVal = $quote->$dynamic[1]();
167
+
168
+ if($dynamic[1]=="getAllItems"){
169
+ $methodVal = $this->getAllItems($methodVal, $dynamic);
170
+ }
171
+
172
+ elseif(gettype($methodVal)=="array"){
173
+ $methodVal=implode("|", $methodVal);
174
+ }
175
+ $lParam .= $prefix . $name.': "'.$methodVal.'"';
176
+ return ($lParam);
177
+ }
178
+
179
+ private function getAllItems($method, $dynamic){
180
+ $allItemsVal='';
181
+ $pipe = '';
182
+ foreach($method as $item) {
183
+ if($item->getOriginalPrice()> 0){
184
+ $allItemsVal .= $pipe . addslashes($item->$dynamic[2]());
185
+ $pipe = '|';
186
+ }
187
+ }
188
+ return ($allItemsVal);
189
+ }
190
+ }
app/code/community/Tagman/Intellitag/Block/Select.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Block_Select
3
+ extends Mage_Core_Block_Html_Select
4
+ {
5
+ /**
6
+ * Return output in one line
7
+ *
8
+ * @return string
9
+ */
10
+ public function _toHtml()
11
+ {
12
+ return trim(preg_replace('/\s+/', ' ',parent::_toHtml()));
13
+ }
14
+ }
app/code/community/Tagman/Intellitag/Block/Text.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Block_Text
3
+ extends Mage_Core_Block_Text
4
+ {
5
+ /**
6
+ * Return output in one line
7
+ *
8
+ * @return string
9
+ */
10
+ public function _toHtml()
11
+ {
12
+ parent::_toHtml();
13
+ }
14
+ }
app/code/community/Tagman/Intellitag/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/community/Tagman/Intellitag/Model/Mysql4/Variables.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Model_Mysql4_Variables extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('tagman_intellitag/variables', 'id');
7
+ }
8
+ }
app/code/community/Tagman/Intellitag/Model/Mysql4/Variables/Collection.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Model_Mysql4_Variables_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('tagman_intellitag/variables');
7
+ }
8
+ }
app/code/community/Tagman/Intellitag/Model/System/Config/Source/Model/Select.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Model_System_Config_Source_Model_Select
3
+ {
4
+
5
+
6
+ public function toOptionArray()
7
+ {
8
+ $collection = Mage::getModel('tagman_intellitag/variables')->getCollection();
9
+ $options = array();
10
+ foreach ($collection as $variable) {
11
+ $options[] = array(
12
+ 'value' => $variable->getId(),
13
+ 'label' => $variable->getName()
14
+ );
15
+
16
+ }
17
+
18
+ return $options;
19
+ }
20
+ }
app/code/community/Tagman/Intellitag/Model/Variables.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Model_Variables extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('tagman_intellitag/variables');
7
+ }
8
+ }
app/code/community/Tagman/Intellitag/controllers/Adminhtml/VariablesController.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagman_Intellitag_Adminhtml_VariablesController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ // Let's call our initAction method which will set some basic params for each action
7
+ $this->_initAction()
8
+ ->renderLayout();
9
+ //$this->removeButton('add');
10
+ }
11
+
12
+ public function newAction()
13
+ {
14
+ // We just forward the new action to a blank edit form
15
+ $this->_forward('edit');
16
+ }
17
+
18
+ public function editAction()
19
+ {
20
+ $this->_initAction();
21
+
22
+ // Get id if available
23
+ $id = $this->getRequest()->getParam('id');
24
+ $model = Mage::getModel('tagman_intellitag/variables');
25
+
26
+ if ($id) {
27
+ // Load record
28
+ $model->load($id);
29
+
30
+ // Check if record is loaded
31
+ if (!$model->getId()) {
32
+ Mage::getSingleton('adminhtml/session')->addError($this->__('This variable no longer exists.'));
33
+ $this->_redirect('*/*/');
34
+
35
+ return;
36
+ }
37
+ }
38
+
39
+ $this->_title($model->getId() ? $model->getName() : $this->__('New Variable'));
40
+
41
+ $data = Mage::getSingleton('adminhtml/session')->getVariableData(true);
42
+ if (!empty($data)) {
43
+ $model->setData($data);
44
+ }
45
+
46
+ Mage::register('tagman_intellitag', $model);
47
+
48
+ $this->_initAction()
49
+ ->_addBreadcrumb($id ? $this->__('Edit Variable') : $this->__('New Variable'), $id ? $this->__('Edit Variable') : $this->__('New Variable'))
50
+ ->_addContent($this->getLayout()->createBlock('tagman_intellitag/adminhtml_variables_edit')->setData('action', $this->getUrl('*/*/save')))
51
+
52
+ ->renderLayout();
53
+
54
+ }
55
+
56
+ public function saveAction()
57
+ {
58
+ if ($postData = $this->getRequest()->getPost()) {
59
+ $model = Mage::getSingleton('tagman_intellitag/variables');
60
+
61
+
62
+ if($postData['is_static']==1){
63
+ $postData['value']=$postData['static_value'];
64
+ $postData['magento_value']="";
65
+ }
66
+ else{
67
+ $postData['magento_value']=$postData['magento_model'];
68
+ $postData['magento_value'].="&&";
69
+
70
+ $tmp_data=str_replace("/","_",$postData['magento_model']);
71
+ $tmp_data.="_property";
72
+
73
+ $postData['magento_value'].=$postData[$tmp_data];
74
+ $postData['value']= "dynamic value";
75
+ $postData['static_value']="";
76
+ }
77
+
78
+ $model->setData($postData);
79
+ try {
80
+
81
+ $model->save();
82
+
83
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The variable has been saved.'));
84
+ $this->_redirect('*/*/');
85
+
86
+ return;
87
+ }
88
+ catch (Mage_Core_Exception $e) {
89
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
90
+ }
91
+ catch (Exception $e) {
92
+ Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this variable.'));
93
+ }
94
+
95
+ Mage::getSingleton('adminhtml/session')->setVariableData($postData);
96
+ $this->_redirectReferer();
97
+ }
98
+ }
99
+
100
+ public function messageAction()
101
+ {
102
+ $data = Mage::getModel('tagman_intellitag/variables')->load($this->getRequest()->getParam('id'));
103
+ echo $data->getContent();
104
+ }
105
+ public function deleteAction() {
106
+ if( $this->getRequest()->getParam('id') > 0 ) {
107
+ try {
108
+ $model = Mage::getModel('tagman_intellitag/variables');
109
+
110
+ $model->setId($this->getRequest()->getParam('id'))
111
+ ->delete();
112
+
113
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
114
+ $this->_redirect('*/*/');
115
+ } catch (Exception $e) {
116
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
117
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
118
+ }
119
+ }
120
+ $this->_redirect('*/*/');
121
+ }
122
+ /**
123
+ * Initialize action
124
+ *
125
+ * Here, we set the breadcrumbs and the active menu
126
+ *
127
+ * @return Mage_Adminhtml_Controller_Action
128
+ */
129
+ protected function _initAction()
130
+ {
131
+ $this->loadLayout()
132
+ // Make the active menu match the menu config nodes (without 'children' inbetween)
133
+ ->_setActiveMenu('tagman_menu')
134
+ ->_title($this->__('tagman_menu'))->_title($this->__('Variables'))
135
+ ->_addBreadcrumb($this->__('tagman_menu'), $this->__('tagman_intellitag'))
136
+ ->_addBreadcrumb($this->__('Variables'), $this->__('Variables'));
137
+
138
+ return $this;
139
+ }
140
+ public function gridAction()
141
+ {
142
+ $this->loadLayout();
143
+ $this->getResponse()->setBody(
144
+ $this->getLayout()->createBlock('tagman_intellitag/adminhtml_variables_grid')->toHtml()
145
+ );
146
+ }
147
+
148
+ /**
149
+ * Check currently called action by permissions for current user
150
+ *
151
+ * @return bool
152
+ */
153
+ protected function _isAllowed()
154
+ {
155
+ return Mage::getSingleton('admin/session')->isAllowed('tagman_intellitag/tagman_intellitag_variables');
156
+ }
157
+ }
app/code/community/Tagman/Intellitag/etc/adminhtml.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <tagman_menu translate="title" module="tagman_intellitag">
5
+ <title>Tagman Manager</title>
6
+ <sort_order>300</sort_order>
7
+ <children>
8
+
9
+ <variables_menu_item translate="title" module="tagman_intellitag">
10
+ <title>Variables</title>
11
+ <sort_order>20</sort_order>
12
+ <action>adminhtml/variables</action>
13
+
14
+ </variables_menu_item>
15
+
16
+ </children>
17
+ </tagman_menu>
18
+ </menu>
19
+ <acl>
20
+ <resources>
21
+ <admin>
22
+ <children>
23
+ <tagman_menu translate="title" module="tagman_intellitag">
24
+ <title>Tagman Manager</title>
25
+ <sort_order>300</sort_order>
26
+ <children>
27
+
28
+ <variables_menu_item translate="title" module="tagman_intellitag">
29
+ <title>Variables</title>
30
+ <sort_order>10</sort_order>
31
+ </variables_menu_item>
32
+
33
+ </children>
34
+ </tagman_menu>
35
+ <system>
36
+ <children>
37
+ <config>
38
+ <children>
39
+ <tab1>
40
+ <title>Tagman_Intellitag</title> <!-- Used in resources tree -->
41
+ </tab1>
42
+ </children>
43
+ </config>
44
+ </children>
45
+ </system>
46
+ </children>
47
+ </admin>
48
+ </resources>
49
+ </acl>
50
+ </config>
app/code/community/Tagman/Intellitag/etc/config.xml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tagman_Intellitag>
5
+ <version>1.0.0</version>
6
+ </Tagman_Intellitag>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+
11
+ <!-- a unique short name for our block files -->
12
+ <tagman_intellitag>
13
+
14
+ <!-- the location of our module's blocks -->
15
+ <class>Tagman_Intellitag_Block</class>
16
+
17
+ </tagman_intellitag>
18
+
19
+ </blocks>
20
+
21
+
22
+ <models>
23
+ <tagman_intellitag>
24
+ <class>Tagman_Intellitag_Model</class>
25
+ <resourceModel>tagman_intellitag_mysql4</resourceModel>
26
+ </tagman_intellitag>
27
+ <tagman_intellitag_mysql4>
28
+ <class>Tagman_Intellitag_Model_Mysql4</class>
29
+ <entities>
30
+ <variables>
31
+ <table>tagman_intellitag_variables</table>
32
+ </variables>
33
+ </entities>
34
+ </tagman_intellitag_mysql4>
35
+ </models>
36
+
37
+ <helpers>
38
+ <tagman_intellitag>
39
+ <class>Tagman_Intellitag_Helper</class>
40
+ </tagman_intellitag>
41
+ </helpers>
42
+
43
+ <resources>
44
+ <tagman_intellitag_setup>
45
+ <setup>
46
+ <module>Tagman_Intellitag</module>
47
+ </setup>
48
+ </tagman_intellitag_setup>
49
+ </resources>
50
+ </global>
51
+ <frontend>
52
+ <layout>
53
+ <updates>
54
+ <tagman_intellitag module="Tagman_Intellitag">
55
+ <file>tagman_intellitag.xml</file>
56
+ </tagman_intellitag>
57
+ </updates>
58
+ </layout>
59
+ </frontend>
60
+ <default>
61
+ <tab1>
62
+ <credentials>
63
+ <client_id_text_field>CLIENT ID SAMPLE</client_id_text_field>
64
+ <site_id_text_field>SITE ID SAMPLE</site_id_text_field>
65
+ <host_text_field>CDN HOST SAMPLE</host_text_field>
66
+ </credentials>
67
+ </tab1>
68
+ </default>
69
+ <admin>
70
+ <routers>
71
+ <adminhtml>
72
+ <args>
73
+ <modules>
74
+ <Tagman_Intellitag before="Mage_Adminhtml">Tagman_Intellitag_Adminhtml</Tagman_Intellitag>
75
+ </modules>
76
+ </args>
77
+ </adminhtml>
78
+ </routers>
79
+ </admin>
80
+
81
+ <adminhtml>
82
+ <layout>
83
+ <updates>
84
+ <tagman_intellitag>
85
+ <file>tagman/intellitag.xml</file>
86
+ </tagman_intellitag>
87
+ </updates>
88
+ </layout>
89
+ </adminhtml>
90
+ </config>
app/code/community/Tagman/Intellitag/etc/system.xml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <myconf translate="label">
5
+ <label>TAGMAN</label>
6
+ <sort_order>150</sort_order>
7
+ </myconf>
8
+ </tabs>
9
+ <sections>
10
+ <tab1 translate="label" module="adminhtml">
11
+ <label>Settings</label>
12
+ <tab>myconf</tab>
13
+ <sort_order>10</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <credentials translate="label comment">
19
+ <label>Client Credentials</label>
20
+ <sort_order>50</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <comment><![CDATA[ <img src="http://www.tagman.com/wp-content/themes/tagman-0-1/images/logo.jpg" /><br><p>Please fill in the required data</p>]]></comment>
25
+ <fields>
26
+ <client_id_text_field translate="label comment">
27
+ <label>CLIENT ID</label>
28
+ <comment>Client ID provided from Tagman</comment>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>10</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ </client_id_text_field>
35
+ <site_id_text_field translate="label comment">
36
+ <label>SITE ID</label>
37
+ <comment>Site ID</comment>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>20</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </site_id_text_field>
44
+ <host_text_field translate="label comment">
45
+ <label>CDN HOST</label>
46
+ <comment>Production and Staging CDN Host</comment>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>30</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ </host_text_field>
53
+ </fields>
54
+ </credentials>
55
+ <variables translate="label comment">
56
+ <label>Variable List</label>
57
+ <sort_order>60</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ <comment><![CDATA[The variable <strong>page_type</strong> will be added automaticly]]></comment>
62
+ <fields>
63
+ <field translate="label">
64
+ <label>Variables</label>
65
+ <frontend_model>tagman_intellitag/field</frontend_model>
66
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
67
+ <source_model>tagman_intellitag/system_config_source_model_select</source_model>
68
+ <sort_order>100</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ </field>
73
+ </fields>
74
+ </variables>
75
+ </groups>
76
+ </tab1>
77
+ </sections>
78
+ </config>
app/code/community/Tagman/Intellitag/sql/tagman_intellitag_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+
7
+ $table_variables = $installer->getConnection()
8
+
9
+ ->newTable($installer->getTable('tagman_intellitag/variables'))
10
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
11
+ 'identity' => true,
12
+ 'unsigned' => true,
13
+ 'nullable' => false,
14
+ 'primary' => true,
15
+ ), 'ID')
16
+ ->addColumn('name', Varien_Db_Ddl_Table::TYPE_CLOB, 0, array(
17
+ 'nullable' => false,
18
+ ), 'Name')
19
+ ->addColumn('is_static', Varien_Db_Ddl_Table::TYPE_BOOLEAN, 1, array(
20
+ 'nullable' => false,
21
+ ),'Type of Value')
22
+ ->addColumn('static_value', Varien_Db_Ddl_Table::TYPE_CLOB, 0, array(
23
+ 'nullable' => false,
24
+ ), 'Static Value')
25
+ ->addColumn('magento_value', Varien_Db_Ddl_Table::TYPE_CLOB, 0, array(
26
+ 'nullable' => false,
27
+ ), 'Magento Value')
28
+ ->addColumn('value', Varien_Db_Ddl_Table::TYPE_CLOB, 0, array(
29
+ 'nullable' => false,
30
+ ), 'Value');
31
+
32
+ $installer->getConnection()->createTable($table_variables);
33
+
34
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/tagman/intellitag.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_variables_index>
4
+ <reference name="content">
5
+ <block type="tagman_intellitag/adminhtml_variables" name="tagman_intellitag_variables" />
6
+ </reference>
7
+ </adminhtml_variables_index>
8
+ </layout>
app/design/frontend/base/default/layout/tagman_intellitag.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <!-- all layout files begin with this node -->
4
+ <layout>
5
+
6
+ <!-- this is the layout handle we are interested in -->
7
+ <default>
8
+
9
+
10
+ <reference name="head">
11
+ <block type="tagman_intellitag/jsinjector"
12
+ name="tagman_intellitag_jsinjector"
13
+ template="tagman_intellitag/jsinjector.phtml" />
14
+
15
+ </reference>
16
+
17
+ <!--<reference name="head">
18
+ <block type="core/text" name="simple_example_javascript_block">
19
+ <action method="setText">
20
+ <text><![CDATA[
21
+ <script type="text/javascript">
22
+ alert("Tagman js alert from tagman_intellitag.xml");
23
+ </script>
24
+ ]]></text>
25
+ </action>
26
+ </block>
27
+ </reference>-->
28
+
29
+ </default>
30
+
31
+ </layout>
app/design/frontend/base/default/template/tagman_intellitag/jsinjector.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php echo $this->addTagManJavascriptBlock(); ?>
app/etc/modules/Tagman_Intellitag.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tagman_Intellitag>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Tagman_Intellitag>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Tagman_Intellitag</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Extension injects TagMan javascript code into every client page to provide TagMan's experience.</summary>
10
+ <description>Provides TagMan experience to Magento web sites. Data contained in TagMan Intellitag are pushed automatically to TagMan&amp;#x2019;s Intellitag platform.&amp;#xD;&#xD;
11
+ This extension plugs into your Magento installation and automatically inserts TagMan Intellitag to the top of your pages, taking away 99% of the development work of implementing Universal Variable on your site.</description>
12
+ <notes>First stable version of TagMan Intellitag extension</notes>
13
+ <authors><author><name>TagMan Ltd.</name><user>tobyattagman</user><email>toby.doig@tagman.com</email></author></authors>
14
+ <date>2013-09-18</date>
15
+ <time>09:02:15</time>
16
+ <contents><target name="magecommunity"><dir name="Tagman"><dir name="Intellitag"><dir name="Block"><dir name="Adminhtml"><dir name="Variables"><dir name="Edit"><file name="Form.php" hash="6e2a841521829e4e74f407d9ff8f2d6a"/></dir><file name="Edit.php" hash="c27734e57889971ae4cafff4ddb08ed8"/><file name="Grid.php" hash="3e6b1c8e49e60af21aa1d1c55ec7ef69"/></dir><file name="Variables.php" hash="9d5fa2b7442f92bfa5840abb2017d067"/></dir><file name="Field.php" hash="50b4bace6bec94d4693923b79ace1f44"/><file name="JsInjector.php" hash="259b793fef80f22e3822cb6fadf748df"/><file name="Select.php" hash="01aa8523ede2440a5d3de5dc32085866"/><file name="Text.php" hash="0ef1ce4825caa74406ee9b37a397c0b3"/></dir><dir name="Helper"><file name="Data.php" hash="906f295b2d648c9a349c2565e09ddc18"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Variables"><file name="Collection.php" hash="dc0ef1f229e89cef8c52ac20adbc395b"/></dir><file name="Variables.php" hash="1b5357557412cdfa258b3bf532c869f3"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Model"><file name="Select.php" hash="61b6852fdf992661525d1da63dfdca4e"/></dir></dir></dir></dir><file name="Variables.php" hash="2d3ed7cf392258cd8868c9c8cd45e7d6"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="VariablesController.php" hash="b281e1de3d527046960aad9ba4890e35"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="61187b3ac51a10ca5ba73ccd0880db7f"/><file name="config.xml" hash="2a519044f823d2bddb54ca95cbfd3e16"/><file name="system.xml" hash="8484f9945f5246b2d9f44dc76e3ae0bf"/></dir><dir name="sql"><dir name="tagman_intellitag_setup"><file name="mysql4-install-1.0.0.php" hash="a91da3d51779b91d218caa9482268c45"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="tagman"><file name="intellitag.xml" hash="444a905ddb69a1062501acd3984e80b1"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="tagman_intellitag"><file name="jsinjector.phtml" hash="58add90971f6d8ff56b6f80930d8b4a9"/></dir></dir><dir name="layout"><file name="tagman_intellitag.xml" hash="2c9db0e32a9075302a7beae53b925971"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Tagman_Intellitag.xml" hash="333d03b67ee4a65f9a78910b2f901803"/></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.3.24</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.2</min><max>1.7.0.2</max></package></required></dependencies>
19
+ </package>