Mage_Codi - Version 4.0.0

Version Notes

some notes

Download this release

Release Info

Developer catalogondemand
Extension Mage_Codi
Version 4.0.0
Comparing to
See all releases


Code changes from version 3.0.9 to 4.0.0

Files changed (33) hide show
  1. app/code/community/Mage/Codi/Block/Adminhtml/Menu.php +0 -10
  2. app/code/community/Mage/Codi/Block/Adminhtml/Switcher.php +0 -109
  3. app/code/community/Mage/Codi/Block/Customer/Codi.php +0 -526
  4. app/code/community/Mage/Codi/Codi_Process.php +0 -20
  5. app/code/community/Mage/Codi/Helper/Createzip.php +0 -87
  6. app/code/community/Mage/Codi/Helper/Data.php +0 -322
  7. app/code/community/Mage/Codi/Model/Codi.php +0 -1447
  8. app/code/community/Mage/Codi/controllers/Adminhtml/MenuController.php +0 -327
  9. app/code/community/Mage/Codi/controllers/DeleteController.php +0 -37
  10. app/code/community/Mage/Codi/controllers/NsyncController.php +0 -178
  11. app/code/community/Mage/Codi/controllers/SyncController.php +0 -215
  12. app/code/community/Mage/Codi/etc/config.xml +0 -146
  13. app/code/community/Mage/Codi/sql/codi_setup/mysql4-install-3.0.4.php +0 -19
  14. app/code/community/Mage/Codi/sql/codi_setup/mysql4-install-3.0.6.php +0 -19
  15. app/code/community/Mage/CodiScript/Helper/Data.php +11 -0
  16. app/code/community/Mage/CodiScript/Model/Files.php +759 -0
  17. app/code/community/Mage/CodiScript/controllers/IndexController.php +192 -0
  18. app/code/community/Mage/CodiScript/etc/adminhtml.xml +22 -0
  19. app/code/community/Mage/CodiScript/etc/config.xml +49 -0
  20. app/code/community/Mage/CodiScript/etc/system.xml +44 -0
  21. app/design/adminhtml/default/default/layout/codi.xml +0 -12
  22. app/design/adminhtml/default/default/layout/codiscript.xml +9 -0
  23. app/design/adminhtml/default/default/template/codi/index.phtml +0 -1095
  24. app/design/frontend/default/default/template/catalog/product/view.phtml +0 -203
  25. app/etc/modules/{Mage_Codi.xml → Mage_CodiScript.xml} +2 -2
  26. app/locale/en_US/Mage_CodiScript.csv +1 -0
  27. js/codi/password_validation.js +7 -0
  28. js/jquery/jquery-1.2.6.noConflict.min.js +0 -34
  29. js/jquery/jquery.tooltip.js +0 -294
  30. package.xml +9 -9
  31. skin/adminhtml/default/default/images/codimport_run.gif +0 -0
  32. skin/adminhtml/default/default/images/codimport_yes.gif +0 -0
  33. skin/adminhtml/default/default/images/preview_field_help.png +0 -0
app/code/community/Mage/Codi/Block/Adminhtml/Menu.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- class Mage_Codi_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Template
4
- {
5
- public function __construct()
6
- {
7
- parent::__construct();
8
- $this->setTemplate('codi/index.phtml');
9
- }
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Block/Adminhtml/Switcher.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Mage
22
- * @package Mage_Adminhtml
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
-
28
- class Mage_Codi_Block_Adminhtml_Switcher extends Mage_Adminhtml_Block_Template
29
- {
30
- protected function _prepareLayout()
31
- {
32
- $this->setTemplate('codi/switcher.phtml');
33
- return parent::_prepareLayout();
34
- }
35
-
36
- /**
37
- * Enter description here...
38
- *
39
- * @return array
40
- */
41
- public function getStoreSelectOptions()
42
- {
43
- $section = $this->getRequest()->getParam('section');
44
-
45
- $curWebsite = $this->getRequest()->getParam('website');
46
- $curStore = $this->getRequest()->getParam('store');
47
-
48
- $storeModel = Mage::getSingleton('adminhtml/system_store');
49
- /* @var $storeModel Mage_Adminhtml_Model_System_Store */
50
-
51
- $url = Mage::getModel('adminhtml/url');
52
-
53
- $options = array();
54
- $options['default'] = array(
55
- 'label' => Mage::helper('adminhtml')->__('Default Config'),
56
- 'url' => $url->getUrl('*/*/*', array('section'=>$section)),
57
- 'selected' => !$curWebsite && !$curStore,
58
- 'style' => 'background:#ccc; font-weight:bold;',
59
- );
60
-
61
- foreach ($storeModel->getWebsiteCollection() as $website) {
62
- $websiteShow = false;
63
- foreach ($storeModel->getGroupCollection() as $group) {
64
- if ($group->getWebsiteId() != $website->getId()) {
65
- continue;
66
- }
67
- $groupShow = false;
68
- foreach ($storeModel->getStoreCollection() as $store) {
69
- if ($store->getGroupId() != $group->getId()) {
70
- continue;
71
- }
72
- if ($websiteShow) {
73
- $websiteShow = true;
74
- $options['website_' . $website->getCode()] = array(
75
- 'label' => $website->getName(),
76
- 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
77
- 'selected' => !$curStore && $curWebsite == $website->getCode(),
78
- 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
79
- );
80
- }
81
- if (!$groupShow) {
82
- $groupShow = true;
83
- $options['group_' . $group->getId() . '_open'] = array(
84
- 'is_group' => true,
85
- 'is_close' => false,
86
- 'label' => $group->getName(),
87
- 'style' => 'padding-left:32px;'
88
- );
89
- }
90
- $options['store_' . $store->getCode()] = array(
91
- 'label' => $store->getName(),
92
- 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode(), 'store'=>$store->getCode())),
93
- 'selected' => $curStore == $store->getCode(),
94
- 'style' => '',
95
- );
96
- }
97
- if ($groupShow) {
98
- $options['group_' . $group->getId() . '_close'] = array(
99
- 'is_group' => true,
100
- 'is_close' => true,
101
- );
102
- }
103
- }
104
- }
105
-
106
- return $options;
107
- }
108
-
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Block/Customer/Codi.php DELETED
@@ -1,526 +0,0 @@
1
- <?php
2
- ini_set("max_execution_time", 3600);
3
- ini_set('session.gc_maxlifetime', 3600);
4
- ini_set("memory_limit","256M");
5
-
6
- class Mage_Codi_Block_Customer_Codi extends Mage_Wishlist_Block_Customer_Wishlist
7
- {
8
-
9
- protected $_wishlistLoaded = false;
10
- public $m_DataFile = "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo";
11
- // public $ProductModel ;
12
- // public $ConfigurableModel ;
13
- public $mediaurl ;
14
- public $RootCategories ;
15
- public $enablereviews ;
16
- public $StoreId ;
17
- public $reviewsModel ;
18
- public $ratingModel ;
19
-
20
- public function _construct()
21
- {
22
- // $this->ProductModel = Mage::getModel('catalog/product') ;
23
- // $this->ConfigurableModel = Mage::getModel('catalog/product_type_configurable') ;
24
- $this->mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) ;
25
-
26
- // Get Root Categories to eliminate them from being send -Start
27
- $RootCategoriesArray = Mage::getModel('adminhtml/system_config_source_category')->toOptionArray();
28
- $RootCategories = array();
29
- foreach($RootCategoriesArray as $RootCategory):
30
- if($RootCategory['value']) array_push($RootCategories, $RootCategory['value'] );
31
- endforeach;
32
-
33
- $this->RootCategories = $RootCategories ;
34
- // Get Root Categories to eliminate them from being send -End
35
-
36
- $this->enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
37
- $this->fromchild = Mage::getStoreConfig('codi/codi/fromchild') ;
38
-
39
- // Get StoreID -Start
40
- foreach (Mage::app()->getWebsites() as $website)
41
- {
42
- $defaultGroup = $website->getDefaultGroup();
43
- $StoreId = $defaultGroup->getDefaultStoreId();
44
- }
45
-
46
- $this->StoreId = $StoreId ;
47
- // Get StoreID -End
48
-
49
- $this->reviewsModel = Mage::getModel('review/review') ;
50
- $this->ratingModel = Mage::getModel('rating/rating_option_vote') ;
51
-
52
- $this->_logFile = "Catalog-on-demand.log";
53
- }
54
-
55
-
56
- protected function _prepareLayout()
57
- {
58
- if ($headBlock = $this->getLayout()->getBlock('head')) {
59
- $headBlock->setTitle($this->__('My Wishlist'));
60
- }
61
- }
62
-
63
- public function getWishlist()
64
- {
65
- if(!$this->_wishlistLoaded) {
66
- Mage::registry('wishlist')
67
- ->loadByCustomer(Mage::getSingleton('customer/session')->getCustomer());
68
-
69
- $collection = Mage::registry('wishlist')->getProductCollection()
70
- ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
71
- ->addStoreFilter();
72
-
73
- Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
74
- Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
75
-
76
- $this->_wishlistLoaded = true;
77
- }
78
- return Mage::registry('wishlist')->getProductCollection();
79
- }
80
-
81
- public function ProcessDataFileImport($m_DataFile)
82
- {
83
- $codimodel = Mage::getSingleton('codi/codi');
84
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
85
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
86
- $url = "https://webservices.catalog-on-demand.com/onDemandPublishingProcessor.do" ;
87
- $paramsarray = array(
88
- 'Operation' => "ProcessDataFileImport" ,
89
- 'UserID' => $userid ,
90
- 'Password' => $password ,
91
- 'ClearDatabase' => "All" ,
92
- 'CatalogProject'=> "Magento" ,
93
- 'DataFileText' => str_replace("'" , "&apos;" , $m_DataFile) );
94
-
95
- $Responsemsg = $codimodel->Call( $url, $paramsarray );
96
- if( $Responsemsg )
97
- {
98
- if($Responsemsg->Message=="OK")
99
- {
100
- echo "Your site data has been posted to the Catalog-On-Demand database and will be available for sharing and/or publishing within 5-10 minutes.";
101
- }
102
- }
103
- else
104
- echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
105
- }
106
-
107
- public function LaunchSponsoredCoDSite($m_DataFile)
108
- {
109
- $codimodel = Mage::getSingleton('codi/codi');
110
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
111
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
112
-
113
- $customerid = "" ;
114
- $customerdatasourceid = "" ;
115
- $validateuser = "" ;
116
- $url = "https://webservices.catalog-on-demand.com/smanager/api.do?Operation=ValidateUser&ResponseGroups=All&FunctionGroups=All" ;
117
- $paramsarray = array('UserID' => $userid ,
118
- 'Password' => $password );
119
- $Responsemsg = $codimodel->Call( $url, $paramsarray );
120
- if( $Responsemsg )
121
- {
122
- if($Responsemsg->Message=="OK")
123
- {
124
- $customerid = (string)$Responsemsg->ValidateUserResponse->User->Customer->CustomerID ;
125
- $customername = (string)$Responsemsg->ValidateUserResponse->User->Customer->Name ;
126
- $customerdatasourceid = (string)$Responsemsg->ValidateUserResponse->User->Customer->DataSource->ID ;
127
- $validateuser = (string)$Responsemsg->Message;
128
- }
129
-
130
- echo "<html><body>" ;
131
- $form = ""; for ($i=0 ; $i<=100 ; $i++) { $form .= "<br>" ; } echo $form ; //hide tmp characters
132
- ?>
133
- <FORM name='publishitems' method='POST' enctype='multipart/form-data' action='https://webservices.catalog-on-demand.com/aservices/api.do'>
134
- <input type='hidden' name='Operation' value='LaunchSponsoredCoDSite'>
135
- <input type='hidden' name='HideScreens' value='SelectItems'>
136
- <input type='hidden' name='UserID' value='<?php echo htmlentities($userid) ?>'>
137
- <input type='hidden' name='Password' value='<?php echo htmlentities($password) ?>'>
138
- <input type='hidden' name='Sponsor' value='<?php echo htmlentities($customerid) ?>'>
139
- <input type='hidden' name='DataFileText' value='<?php echo str_replace("'" , "&apos;" , $m_DataFile) ?>'>
140
- </FORM>
141
- <SCRIPT language="JavaScript">
142
- document.publishitems.submit();
143
- </SCRIPT>
144
- </body></html>
145
- <?php
146
- }
147
- else
148
- echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
149
- }
150
-
151
- public function ProducttoString( $product , $from )
152
- {
153
- if( $product->isConfigurable() )
154
- {
155
- return $this->ProducttoStringConfigurable( $product , $from ) ;
156
- }
157
- else
158
- {
159
- return $this->ProducttoStringSimple( $product , $from ) ;
160
- }
161
- }
162
-
163
- public function ProducttoStringConfigurable( $product , $from )
164
- {
165
- set_time_limit(0);
166
-
167
- $ProducttoString = '' ;
168
- $UsedProductIds = Mage::getModel('catalog/product_type_configurable')->getUsedProductIds($product);
169
-
170
- if( $from == "wishlist" )
171
- {
172
- $myproduct = '';
173
- $Comment = '' ;
174
- //Add Comment if exist
175
- $defaultcomment = $this->helper('wishlist')->defaultCommentString() ;
176
- if ( $product->getWishlistItemDescription() !== $defaultcomment )
177
- $Comment = "\\par{\\b Comment}\\par" . $product->getWishlistItemDescription() ;
178
- //Get Full Product
179
- $myproduct = Mage::getModel('catalog/product')->load($product->getProductID());
180
- //Get Product Description
181
- $ProductDescription = $myproduct->getDescription() ;
182
- $ProductDescription .= $Comment ;
183
- }
184
- else
185
- {
186
- $ProductDescription = $product->getDescription() ;
187
- }
188
-
189
- //Get Product Attributes Start
190
- //$excludeAttr = array() ;
191
- $attributes = $product->getAttributes();
192
-
193
- $ProductAttributes = "" ;
194
- foreach ($attributes as $attribute) {
195
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
196
- $value = $attribute->getFrontend()->getValue($product);
197
- if (is_string($value))
198
- {
199
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
200
- {
201
- $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
202
- }
203
- }
204
- }
205
- }
206
- $ProductAttributes = substr($ProductAttributes, 0, strlen($ProductAttributes)-1 ) ;
207
- //Get Product Attributes End
208
-
209
- foreach($UsedProductIds as $UsedProductid)
210
- {
211
- $UsedProduct = Mage::getModel('catalog/product')->load($UsedProductid);
212
- if( Mage::getStoreConfig('codi/codi/fromchild') )
213
- $UsedProductPrice = $UsedProduct->getFinalPrice() ;
214
- else
215
- $UsedProductPrice = $product->getFinalPrice() ; //default behavior
216
- //************************ Get Attributes Start *******************************
217
- //Extract Attributes
218
- //$ImageURL = (string)$this->helper('catalog/image')->init($UsedProduct, 'image');
219
- //$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
220
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
221
-
222
- //Get Item Attributes Start
223
- //$excludeAttr = array() ;
224
- $attributes = $UsedProduct->getAttributes();
225
-
226
- $ItemitemAttributes = "" ;
227
- $AllowAttributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
228
- foreach ($AllowAttributes as $attribute)
229
- {
230
- $AttributeCode = $attribute->getProductAttribute()->getAttributeCode() ;
231
- $AttributeLabel = $attribute->getProductAttribute()->getFrontend()->getLabel() ;
232
- $AttribId = $UsedProduct->getData($AttributeCode) ;
233
-
234
- $AttributeValue = "" ;
235
- foreach ( $attribute->getProductAttribute()->getSource()->getAllOptions() as $option )
236
- {
237
- if( $option['value'] == $AttribId )
238
- {
239
- $AttributeValue = $option['label'];
240
- }
241
- }
242
-
243
- $ItemitemAttributes .= $AttributeLabel . "=" . $AttributeValue . "|" ;
244
-
245
- //Get Delta Price Start
246
- foreach( $attribute->getPrices() as $addedPrice )
247
- {
248
- if ( $AttributeValue == $addedPrice['label'])
249
- {
250
- if( $addedPrice['is_percent'] )
251
- $UsedProductPrice += $UsedProductPrice * $addedPrice['pricing_value'] / 100;
252
- else
253
- $UsedProductPrice += $addedPrice['pricing_value'] ;
254
- }
255
- }
256
- //Get Delta Price End
257
- }
258
-
259
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 );
260
-
261
- //Get Item Attributes End
262
- //************************ Get Attributes End ************************************
263
-
264
- //************************* Get Categories names Start ***************************
265
-
266
- $categories = $product->getCategoryIds();
267
-
268
- $CategoriesString = "" ;
269
- foreach($categories as $k => $_category_id){
270
-
271
- $_category = Mage::getModel('catalog/category')->load($_category_id) ;
272
- $path = $_category->getPathInStore();
273
- $pathIds = array_reverse(explode(',', $path));
274
-
275
- foreach($pathIds as $m => $_cat_id){
276
- $_cat = Mage::getModel('catalog/category')->load($_cat_id) ;
277
- // if( $_cat->getName() != '' && (string)$_cat->getLevel() != '1' && !(in_array($_cat_id, $this->RootCategories)) )
278
- if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
279
- $CategoriesString .= $_cat->getName() . "#$#" ;
280
- }
281
-
282
- if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
283
- {
284
- $CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 ) ;
285
- $CategoriesString .= "|";
286
- }
287
-
288
- }
289
-
290
- $CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
291
-
292
- if ($CategoriesString=='') $CategoriesString = 'Uncategorized' ;
293
-
294
- //************************* Get Categories names End ***************************
295
-
296
- //************************* Get Reviews Start ***********************
297
- //$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
298
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
299
- //************************* Get Reviews End *************************
300
-
301
- //************************* Concatenate Product Info Start ***********************
302
- $ProducttoString .= "\r\n" . $this->cleanStr( $UsedProduct->getSku() ) ; //ItemID
303
- $ProducttoString .= "\t" . "" ; //ItemQty
304
- $ProducttoString .= "\t" . "" ; //ItemUom
305
- // $ProducttoString .= "\t" . $this->cleanStr( $product->getPrice() ) ; //ItemPrice
306
- $ProducttoString .= "\t" . $this->cleanStr( $UsedProductPrice ) ; //ItemPrice
307
- $ProducttoString .= "\t" . ""; //ItemDescription
308
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
309
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ItemitemAttributes
310
- $ProducttoString .= "\t" . ""; //ItemitemGraphic
311
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
312
- $ProducttoString .= "\t" . "" ; //ProductMfg
313
- $ProducttoString .= "\t" . $this->cleanStr( $ProductDescription ) ; //ProductDescription
314
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
315
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
316
- $ProducttoString .= "\t" . $this->cleanStr( $ProductAttributes ) ; //ProductAttributes
317
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
318
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
319
- $ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
320
- //************************* Concatenate Product Info End ************************* cleanStr
321
- }
322
-
323
- return $ProducttoString ;
324
- }
325
- /////////////////////////////////////////// Simple Products ///////////////////////////////////////////////////////////////////
326
- public function ProducttoStringSimple( $product , $from )
327
- {
328
- set_time_limit(0);
329
-
330
- $ProducttoString = '' ;
331
- if($from == "wishlist")
332
- {
333
- $Comment = '' ;
334
- //Add Comment if exist
335
- $defaultcomment = $this->helper('wishlist')->defaultCommentString() ;
336
- if ( $product->getWishlistItemDescription() !== $defaultcomment )
337
- $Comment = "\\par{\\b Comment}\\par" . $product->getWishlistItemDescription() ;
338
- //Get Full Product
339
- $product = Mage::getModel('catalog/product')->load($product->getProductID());
340
- //Get Product Description
341
- $ProductDescription = $product->getDescription() ;
342
- $ProductDescription .= $Comment ;
343
- }
344
- else
345
- {
346
- $ProductDescription = $product->getDescription() ;
347
- }
348
-
349
- //************************ Get Attributes Start *******************************
350
- //Extract Attributes
351
- //$ImageURL = (string)$this->helper('catalog/image')->init($product, 'image');
352
- //$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
353
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
354
-
355
- //$excludeAttr = array() ;
356
- $attributes = $product->getAttributes();
357
- $ItemitemAttributes = "" ;
358
- foreach ($attributes as $attribute) {
359
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
360
- $value = $attribute->getFrontend()->getValue($product);
361
- if (is_string($value))
362
- {
363
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
364
- {
365
- $ItemitemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
366
- }
367
- }
368
- }
369
- }
370
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 ) ;
371
- //************************ Get Attributes End ************************************
372
-
373
- //************************* Get Categories names Start ***************************
374
-
375
- $categories = $product->getCategoryIds();
376
- $CategoriesString = "" ;
377
- foreach($categories as $k => $_category_id){
378
-
379
- $_category = Mage::getModel('catalog/category')->load($_category_id) ;
380
- $path = $_category->getPathInStore();
381
- $pathIds = array_reverse(explode(',', $path));
382
-
383
- foreach($pathIds as $m => $_cat_id){
384
- $_cat = Mage::getModel('catalog/category')->load($_cat_id) ;
385
- // if( $_cat->getName() != '' && (string)$_cat->getLevel() != '1' && !(in_array($_cat_id, $this->RootCategories)) )
386
- if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
387
- $CategoriesString .= $_cat->getName() . "#$#" ;
388
- }
389
-
390
- if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
391
- {
392
- $CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 );
393
- $CategoriesString .= "|";
394
- }
395
- }
396
-
397
- $CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
398
- if ($CategoriesString == '' ) $CategoriesString = 'Uncategorized' ;
399
- //************************* Get Categories names End ***************************
400
-
401
- //************************* Get Reviews Start ***********************
402
- //$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
403
- //if($enablereviews) { $Reviews = $this->getReviews($product->getId()) ; }
404
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
405
- //************************* Get Reviews End *************************
406
-
407
- //************************* Concatenate Product Info Start ***********************
408
-
409
- $ProducttoString .= "\r\n" . $this->cleanStr( $product->getSku() ) ; //ItemID
410
- $ProducttoString .= "\t" . "" ; //ItemQty
411
- $ProducttoString .= "\t" . "" ; //ItemUom
412
- $ProducttoString .= "\t" . $this->cleanStr( $product->getFinalPrice() ) ; //ItemPrice
413
- $ProducttoString .= "\t" . ""; //ItemDescription
414
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
415
- $ProducttoString .= "\t" . ""; //ItemitemAttributes
416
- $ProducttoString .= "\t" . ""; //ItemitemGraphic
417
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
418
- $ProducttoString .= "\t" . "" ; //ProductMfg
419
- $ProducttoString .= "\t" . $this->cleanStr( $ProductDescription ) ; //ProductDescription
420
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
421
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
422
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ProductAttributes
423
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
424
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
425
- $ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
426
- //************************* Concatenate Product Info End ************************* cleanStr
427
-
428
- return $ProducttoString ;
429
- }
430
-
431
- public function getReviews( $productid )
432
- {
433
- $reviewsCollection = $this->reviewsModel->getCollection()
434
- ->addStoreFilter($this->StoreId)
435
- ->addStatusFilter('approved')
436
- ->addEntityFilter('product', $productid)
437
- ->setDateOrder();
438
-
439
- $Reviews = "" ;
440
- foreach($reviewsCollection as $review)
441
- {
442
- $ratingCollection = $this->ratingModel
443
- ->getResourceCollection()
444
- ->setReviewFilter($review->getReviewId())
445
- ->setStoreFilter($this->StoreId)
446
- ->addRatingInfo($this->StoreId)
447
- ->load();
448
- $Reviews .= "<p><b>".$review->getTitle()."(". $review->getNickname() .")</b><br>".$review->getDetail()."</p>" ;
449
- }
450
- return $Reviews ;
451
- }
452
-
453
- public function getWishListDataFile()
454
- {
455
- $m_DataFile = '' ;
456
-
457
- foreach($this->getWishlist() as $item):
458
- $m_DataFile .= $this->ProducttoString($item , "wishlist" ) ;
459
- endforeach ;
460
-
461
- return $this->m_DataFile . $m_DataFile ;
462
- }
463
-
464
- public function getcurrencysign()
465
- {
466
- try {
467
- $currencystr = Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE) ;
468
- $currency = new Zend_Currency($currencystr);
469
- Zend_Registry::set('Zend_Currency', $currency);
470
- return $currency->getSymbol();
471
- } catch (Exception $e) {
472
- return "US";
473
- }
474
- }
475
-
476
- public function ProcessBackgroundJob()
477
- {
478
- $m_DataFile = $this->getWishListDataFile() ;
479
-
480
- $codimodel = Mage::getSingleton('codi/codi');
481
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
482
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
483
-
484
- //Get Currency Sign
485
- $currencysign = $this->getcurrencysign() ;
486
- //Preparing the call
487
- $UserEmail = $this->getuseremail() ;
488
- $JobName = $this->getRequest()->getParam('JobName') ;
489
-
490
- $options = "_JobName=" . $JobName ;
491
- $options .= "||CurrencySymbol=" . $currencysign ;
492
- $options .= "||ClientAppVersion=" . "Magento" . Mage::getVersion() . "-Codi" . $codimodel->version ;
493
-
494
- $url = "https://webservices.catalog-on-demand.com/onDemandPublishingProcessor.do?Operation=ProcessBackgroundJob";
495
- $paramsarray = array('UserID' => $userid,
496
- 'Password' => $password,
497
- 'Email' => $UserEmail,
498
- 'Options' => $options,
499
- 'DataFileText' => $m_DataFile);
500
- //Calling
501
- $UserEmail = Mage::getSingleton('customer/session')->getCustomer()->getEmail() ; //Get User Email
502
- $Responsemsg = $codimodel->Call( $url, $paramsarray );
503
- if( $Responsemsg )
504
- {
505
- if($Responsemsg->Message=="OK")
506
- echo "Your Wishlist has been submitted to Catalog-On-Demand for publishing and should be complete within 5-10 minutes. Please monitor your email ($UserEmail) for a link to your PDF publication." ;
507
- else
508
- {
509
- echo "Error No. " . $Responsemsg->Errors->Error->Code . "<br>";
510
- echo $Responsemsg->Errors->Error->Description . "<br>";
511
- }
512
- }
513
- else
514
- echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
515
- }
516
-
517
- public function cleanStr($localstr)
518
- {
519
- $localstr = str_replace("\t","", $localstr ) ;
520
- $localstr = str_replace("\r\n","<br>", $localstr ) ;
521
- $localstr = str_replace("\r","<br>", $localstr ) ;
522
- $localstr = str_replace("\n","<br>", $localstr ) ;
523
- return $localstr ;
524
- }
525
-
526
- }// class end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Codi_Process.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- $baseDir = dirname(__FILE__);
4
-
5
- $_baseDirArray = explode("app", $baseDir);
6
- $basePath = $_baseDirArray[0].'/';
7
-
8
- require $baseDir . '/../../../../../app/Mage.php';
9
-
10
- Mage::app();
11
-
12
- Mage::log("Notice: Start Create data file.", null, "Catalog-on-demand.log");
13
-
14
- $CodiModel = Mage::getModel('codi/codi');
15
-
16
- $CodiModel->run_codi_import($basePath);
17
-
18
- Mage::log("Notice: Finish Create data file.", null, "Catalog-on-demand.log");
19
-
20
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Helper/Createzip.php DELETED
@@ -1,87 +0,0 @@
1
- <?php
2
- /* Create zip of the files */
3
-
4
- class Mage_Codi_Helper_Createzip extends Mage_Core_Helper_Abstract
5
- {
6
- function get_files_from_folder($directory,$filename='',$put_into='') {
7
- if ($handle = opendir($directory)) {
8
- while (false !== ($file = readdir($handle))) {
9
- if (is_file($directory.$file)) {
10
- $fileContents = file_get_contents($directory.$file);
11
- $this->addFile($fileContents, $put_into.$file);
12
- } elseif ($file != '.' and $file != '..' and is_dir($directory.$file)) {
13
- $this->addDirectory($put_into.$file.'/');
14
- $this->get_files_from_folder($directory.$file.'/',$filename, $put_into.$file.'/');
15
- }
16
- }
17
- $data = $this->getZippedfile();
18
- $f = fopen($directory."/".$filename,"wb");
19
- fwrite($f,$data);
20
- fclose($f);
21
- }
22
- closedir($handle);
23
- }
24
- /* creates a compressed zip file */
25
- function create_zip($files = array(),$destination = '',$overwrite = false,$strreplace='')
26
- {
27
- //if the zip file already exists and overwrite is false, return false
28
- if(file_exists($destination) && !$overwrite) { return false; }
29
- //vars
30
- $valid_files = array();
31
- //if files were passed in...
32
- if(is_array($files)) {
33
- //cycle through each file
34
- foreach($files as $file) {
35
- //make sure the file exists
36
- if(file_exists($file)) {
37
- $valid_files[] = $file;
38
- }
39
- }
40
- }
41
- //if we have good files...
42
- if(count($valid_files)) {
43
- //create the archive
44
- $zip = new ZipArchive();
45
- if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
46
- return false;
47
- }
48
- //add the files
49
- foreach($valid_files as $file) {
50
- $newfile=str_replace($strreplace,"",$file);
51
- $zip->addFile($file,$newfile);
52
- }
53
- //debug
54
- //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;
55
- //close the zip -- done!
56
- $zip->close();
57
- //check to make sure the file exists
58
- return file_exists($destination);
59
- }
60
- else
61
- {
62
- return false;
63
- }
64
- }
65
- //Fuction to create zip for import the data
66
- function createimportzip($filename){
67
- $zipfilename=$filename.'.zip';
68
- $DataFile = $filename.'.txt';
69
- $catalogSection='CatalogSection.txt';
70
- $catalogProject='CatalogProject.txt';
71
- $helper=Mage::helper('codi');
72
- //Change for zip
73
- $files_to_zip = array($basePath.'CoDzip/CoDfiles/'.$filename.'.txt',
74
- $basePath.'CoDzip/CoDfiles/CatalogSection.txt',
75
- $basePath.'CoDzip/CoDfiles/CatalogProject.txt');
76
- //if true, good; if false, zip creation failed
77
- $result=$this->create_zip($files_to_zip,'CoDzip/'.$zipfilename,true,$basePath.'CoDzip/CoDfiles/');
78
-
79
- if($result)
80
- {
81
- //Deleting files
82
- if (copy($basePath.'CoDzip/CoDfiles/'.$zipfilename,$basePath.'CoDzip/'.$zipfilename)) {
83
- unlink($basePath.'CoDzip/CoDfiles/'.$zipfilename);
84
- }
85
- }
86
- }
87
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Helper/Data.php DELETED
@@ -1,322 +0,0 @@
1
- <?php
2
- class Mage_Codi_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
4
- function output_file($file, $name, $mime_type='')
5
- {
6
- /*
7
- This function takes a path to a file to output ($file),
8
- the filename that the browser will see ($name) and
9
- the MIME type of the file ($mime_type, optional).
10
-
11
- */
12
- if(!is_readable($file)) die('File not found or inaccessible!');
13
-
14
- $size = filesize($file);
15
- $name = rawurldecode($name);
16
-
17
- /* Figure out the MIME type (if not specified) */
18
- $known_mime_types=array(
19
- "pdf" => "application/pdf",
20
- "txt" => "text/plain",
21
- "html" => "text/html",
22
- "htm" => "text/html",
23
- "exe" => "application/octet-stream",
24
- "zip" => "application/zip",
25
- "doc" => "application/msword",
26
- "xls" => "application/vnd.ms-excel",
27
- "ppt" => "application/vnd.ms-powerpoint",
28
- "gif" => "image/gif",
29
- "png" => "image/png",
30
- "jpeg"=> "image/jpg",
31
- "jpg" => "image/jpg",
32
- "php" => "text/plain"
33
- );
34
-
35
- if($mime_type==''){
36
- $file_extension = strtolower(substr(strrchr($file,"."),1));
37
- if(array_key_exists($file_extension, $known_mime_types)){
38
- $mime_type=$known_mime_types[$file_extension];
39
- } else {
40
- $mime_type="application/force-download";
41
- };
42
- };
43
-
44
- @ob_end_clean(); //turn off output buffering to decrease cpu usage
45
-
46
- // required for IE, otherwise Content-Disposition may be ignored
47
- if(ini_get('zlib.output_compression'))
48
- ini_set('zlib.output_compression', 'Off');
49
-
50
- header('Content-Type: ' . $mime_type);
51
- header('Content-Disposition: attachment; filename="'.$name.'"');
52
- header("Content-Transfer-Encoding: binary");
53
- header('Accept-Ranges: bytes');
54
-
55
- /* The three lines below basically make the
56
- download non-cacheable */
57
- header("Cache-control: private");
58
- header('Pragma: private');
59
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
60
-
61
- // multipart-download and download resuming support
62
- if(isset($_SERVER['HTTP_RANGE']))
63
- {
64
- list($a, $range) = explode("=",$_SERVER['HTTP_RANGE'],2);
65
- list($range) = explode(",",$range,2);
66
- list($range, $range_end) = explode("-", $range);
67
- $range=intval($range);
68
- if(!$range_end) {
69
- $range_end=$size-1;
70
- } else {
71
- $range_end=intval($range_end);
72
- }
73
-
74
- $new_length = $range_end-$range+1;
75
- header("HTTP/1.1 206 Partial Content");
76
- header("Content-Length: $new_length");
77
- header("Content-Range: bytes $range-$range_end/$size");
78
- } else {
79
- $new_length=$size;
80
- header("Content-Length: ".$size);
81
- }
82
-
83
- /* output the file itself */
84
- $chunksize = 1*(1024*1024); //you may want to change this
85
- $bytes_send = 0;
86
- if ($file = fopen($file, 'r'))
87
- {
88
- if(isset($_SERVER['HTTP_RANGE']))
89
- fseek($file, $range);
90
-
91
- while(!feof($file) &&
92
- (!connection_aborted()) &&
93
- ($bytes_send<$new_length)
94
- )
95
- {
96
- $buffer = fread($file, $chunksize);
97
- print($buffer); //echo($buffer); // is also possible
98
- flush();
99
- $bytes_send += strlen($buffer);
100
- }
101
- fclose($file);
102
- } else die('Error - can not open file.');
103
-
104
- die();
105
- }
106
-
107
- function deleteFile($basePath='',$filename='')
108
- {
109
- @unlink($basePath.$filename);
110
- //remove text files
111
- $filesn = glob($basePath."CoDzip/CoDfiles/*.txt");
112
- foreach($filesn as $filen)
113
- {
114
- unlink($filen);
115
- }
116
- }
117
- //function for get the theme
118
- function getTheme()
119
- {
120
- foreach (Mage::app()->getWebsites() as $website)
121
- {
122
- $defaultGroup = $website->getDefaultGroup();
123
- $StoreId = $defaultGroup->getDefaultStoreId();
124
- }
125
-
126
- $design = Mage::getSingleton('core/design')->loadChange($StoreId);
127
-
128
- $package = $design->getPackage();
129
- $default_theme = $design->getTheme();
130
-
131
- if ( $package == "" && $default_theme == "" ){
132
-
133
- $package = Mage::getStoreConfig('design/package/name', $StoreId);
134
- $default_theme = Mage::getStoreConfig('design/theme/default', $StoreId);
135
- }
136
-
137
- if ( $package == "" ) $package = "default";
138
- if ( $default_theme == "" ) $default_theme = "default";
139
-
140
- return $package.'/'.$default_theme;
141
-
142
-
143
-
144
- }
145
- function array2json($arr) {
146
-
147
- if(function_exists('json_encode')) return json_encode($arr); //Lastest versions of PHP already has this functionality.
148
- $parts = array();
149
- $is_list = false;
150
-
151
- //Find out if the given array is a numerical array
152
- $keys = array_keys($arr);
153
- $max_length = count($arr)-1;
154
- if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {//See if the first key is 0 and last key is length - 1
155
- $is_list = true;
156
- for($i=0; $i<count($keys); $i++) { //See if each key correspondes to its position
157
- if($i != $keys[$i]) { //A key fails at position check.
158
- $is_list = false; //It is an associative array.
159
- break;
160
- }
161
- }
162
- }
163
-
164
- foreach($arr as $key=>$value) {
165
- if(is_array($value)) { //Custom handling for arrays
166
- if($is_list) $parts[] = array2json($value); /* :RECURSION: */
167
- else $parts[] = '"' . $key . '":' . array2json($value); /* :RECURSION: */
168
- } else {
169
- $str = '';
170
- if(!$is_list) $str = '"' . $key . '":';
171
-
172
- //Custom handling for multiple data types
173
- if(is_numeric($value)) $str .= $value; //Numbers
174
- elseif($value === false) $str .= 'false'; //The booleans
175
- elseif($value === true) $str .= 'true';
176
- else $str .= '"' . addslashes($value) . '"'; //All other things
177
- // :TODO: Is there any more datatype we should be in the lookout for? (Object?)
178
-
179
- $parts[] = $str;
180
- }
181
- }
182
- $json = implode(',',$parts);
183
-
184
- if($is_list) return '[' . $json . ']';//Return numerical JSON
185
- return '{' . $json . '}';//Return associative JSON
186
- }
187
-
188
-
189
- function geTierprice($product)
190
- {
191
-
192
- if (is_null($product)) {
193
- return array();
194
- }
195
- $res='';
196
- $codquantity=Mage::getStoreConfig('codi/codi/codquantity');
197
- $codprice=Mage::getStoreConfig('codi/codi/codprice');
198
- $codsavings=Mage::getStoreConfig('codi/codi/codsavings');
199
-
200
- //[tier qty 1]#$#[tier price 1]#$#[(product price-tier price 1)/product price%]#$$#
201
-
202
- $prices = $product->getFormatedTierPrice();
203
-
204
- $rightstr = '';
205
- if (is_array($prices)) {
206
-
207
- $i='1';
208
- $count=count($prices);
209
- if($count>0)
210
- $res='[TierPriceTable]#$$#'.$codquantity.'#$#'.$codprice.'#$#'.$codsavings."=";
211
-
212
- foreach ($prices as $price) {
213
- $price['price_qty'] = $price['price_qty']*1;
214
- $rightstr.=$price['price_qty'].'#$#';
215
- if ($product->getPrice() != $product->getFinalPrice()) {
216
- if ($price['price']<$product->getFinalPrice()) {
217
-
218
- $rightstr.=Mage::helper('tax')->getPrice($product, $price['website_price'], true).'#$#';
219
-
220
- if($i==$count)
221
- {
222
- $rightstr.=ceil(100 - (( 100/$product->getFinalPrice() ) * $price['price'] )).'%';
223
- }
224
- else
225
- {
226
- $rightstr.=ceil(100 - (( 100/$product->getFinalPrice() ) * $price['price'] )).'%#$$#';
227
- }
228
-
229
- }
230
- } else {
231
- if ($price['price']<$product->getPrice()) {
232
- $rightstr.=Mage::helper('tax')->getPrice($product, $price['website_price'], true).'#$#';
233
-
234
- if($i==$count)
235
- $rightstr.= ceil(100 - (( 100/$product->getPrice() ) * $price['price'] )).'%';
236
- else
237
- $rightstr.= ceil(100 - (( 100/$product->getPrice() ) * $price['price'] )).'%#$$#';
238
- }
239
- }
240
- $i++;
241
- }
242
- }
243
-
244
- return $res.$rightstr;
245
-
246
- }
247
- //Code for Catalog section code
248
- function drawItem($category, $level=0,$name='',$i=1,$j=1,$path='')
249
- {
250
- $html='';
251
-
252
- $catalogSectionModel=Mage::getModel('codi/codi');
253
- //Get Category child
254
- $childrennew=$category->getChildrenCategories();
255
-
256
- $id=$category->getId();
257
- if($level!=1)
258
- {
259
- $path.='-'.$j;
260
- $name=$name.'#$#'.$category->getName();//.' '.$i.$path;
261
- $sql_name=addslashes($name);
262
- $sec_path.=str_replace("-",",",$path);
263
- $seq=$i.$sec_path;
264
- }
265
- else
266
- {
267
- $name=$category->getName();//.' '.$i;
268
- $sql_name=addslashes($name);
269
- $seq=$i;
270
- }
271
-
272
- $catalogSectionModel->addCatalogSection($id,$sql_name);
273
- $html= "General\t".$seq."\t".$name."\t". $sec_Flag . "\n";
274
-
275
- if(count($childrennew))
276
- {
277
- $j = 1;
278
- foreach ($childrennew as $cat)
279
- {
280
- //$cat=$this->createCategoryObj($child->getID());
281
- if($cat!=false)
282
- $htmlChildren.= $this->drawItem($cat, $level+1,$name,$i,$j,$path);
283
- $j++;
284
- }
285
- }
286
- return $html.= $htmlChildren;
287
- }
288
- //Create category object
289
- function createCategoryObj($cid)
290
- {
291
- $collection = Mage::getModel('catalog/category')->getCollection()
292
- ->setStoreId('1')
293
- ->addAttributeToSelect('name')
294
- ->addAttributeToSelect('is_active')
295
- ->addAttributeToFilter('entity_id', array('eq' => $cid));
296
- foreach($collection as $category)
297
- {
298
- if($category)
299
- return $category;
300
- else
301
- return false;
302
- }
303
- }
304
- //get product Postion
305
- function productPostion($category_id,$productId)
306
- {
307
-
308
- $category = Mage::getModel('catalog/category')
309
- ->setStoreId(1)
310
- ->load($category_id);
311
- $positions = $category->getProductsPosition();
312
- if(count($positions)>0)
313
- $position=$positions[$productId];
314
- else
315
- $position='';
316
-
317
- return $position;
318
-
319
- }
320
-
321
- }
322
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Model/Codi.php DELETED
@@ -1,1447 +0,0 @@
1
- <?php
2
-
3
- class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
4
- {
5
- public $target ;
6
- public $codigrid ; //this flag is to know whether we are displaying our grid or a general grid
7
- public $userid ;
8
- public $password ;
9
- public $disableextension ;
10
- public $version = "3.0.9";
11
-
12
- public $customerid ;
13
- public $customerdatasourceid ;
14
- public $validateuser ;
15
- public $extensionName='Mage_Codi';
16
- public $StoreId ;
17
- public $reviewsModel ;
18
- public $ratingModel ;
19
- public $enablereviews ;
20
- public $mediaurl ;
21
-
22
- public function _construct()
23
- {
24
- parent::_construct();
25
- $this->_init('codi/codi');
26
- $this->_logFile = "Catalog-on-demand-items.log";
27
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
28
-
29
- $this->enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews');
30
-
31
- // Get StoreID -Start
32
- foreach (Mage::app()->getWebsites() as $website)
33
- {
34
- $defaultGroup = $website->getDefaultGroup();
35
- $StoreId = $defaultGroup->getDefaultStoreId();
36
- }
37
-
38
- $this->StoreId = $StoreId ;
39
- // Get StoreID -End
40
-
41
- $this->reviewsModel = Mage::getModel('review/review') ;
42
- $this->ratingModel = Mage::getModel('rating/rating_option_vote') ;
43
- $this->mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
44
- }
45
-
46
- public function setStoreConfig( $myarray )
47
- {
48
- $section = 'codi' ;
49
- $website = '' ;
50
- $store = '';
51
-
52
- $groups =
53
- array(
54
- 'codi' =>
55
- array(
56
- 'fields' => $myarray
57
- ));
58
- Mage::getModel('adminhtml/config_data')
59
- ->setSection($section)
60
- ->setWebsite($website)
61
- ->setStore($store)
62
- ->setGroups($groups)
63
- ->save();
64
- }
65
-
66
- public function adminstart()
67
- {
68
- Mage::log("Notice : Admin Start", null, $this->_logFile);
69
-
70
- $AdminNotified = Mage::getSingleton('core/session')->getAdminNotified();
71
- if (!$AdminNotified)
72
- {
73
- Mage::getSingleton('core/session')->setAdminNotified(true);
74
- try
75
- {
76
- $codimodel = Mage::getSingleton('codi/codi');
77
- //Get Application Parameters Response (Notification)
78
- $url = "https://webservices.catalog-on-demand.com/smanager/api.do?Operation=GetApplicationParameters&Application=CoDExtensionForMagento" ;
79
- $paramsarray = array('UserID' => Mage::getStoreConfig('codi/codi/codusername'),
80
- 'Password' => Mage::getStoreConfig('codi/codi/codpassword') );
81
- $Responsemsg = $this->Call( $url, $paramsarray );
82
- if ( $Responsemsg )
83
- {
84
- if (!$Responsemsg->Errors)
85
- {
86
- foreach ($Responsemsg->GetApplicationParametersResponse->ApplicationParameter as $ApplicationParameter)
87
- {
88
- //Get Version
89
- if ((string)$ApplicationParameter->Name == "Version")
90
- $Version = (string)$ApplicationParameter->Value;
91
- //Get Release Notes Link
92
- if ((string)$ApplicationParameter->Name == "ReleaseNotesLink")
93
- $ReleaseNotesLink = (string)$ApplicationParameter->Value;
94
- //Get the Notification Message
95
- if ((string)$ApplicationParameter->Name == "NotificationMessage")
96
- $NotificationMessage = (string)$ApplicationParameter->Value;
97
- }
98
-
99
- $title = "Catalog-On-Demand version " . $Version . " now available";
100
-
101
- $feedData[] = array(
102
- 'severity' => 2,
103
- 'date_added' => NOW(),
104
- 'title' => (string)$title,
105
- 'description' => (string)$NotificationMessage,
106
- 'url' => (string)$ReleaseNotesLink,
107
- );
108
-
109
- if ( version_compare($Version, $codimodel->version) == 1) {
110
- Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData)); }
111
- }
112
- }
113
- }
114
- catch(Exception $e){}
115
- }
116
- }
117
-
118
- public function InitImportStatuses(){
119
-
120
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
121
-
122
- $write->query("DROP TABLE IF EXISTS codi_import_status");
123
- $write->query("CREATE TABLE codi_import_status(
124
- id int(11) NOT NULL auto_increment PRIMARY KEY,
125
- message varchar(50),
126
- finished int(1) default 0)"
127
- );
128
- }
129
-
130
- public function existTable(){
131
-
132
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
133
-
134
- $write->query("CREATE TABLE IF NOT EXISTS codi_import_status(
135
- id int(11) NOT NULL auto_increment PRIMARY KEY,
136
- message varchar(50),
137
- finished int(1) default 0)"
138
- );
139
-
140
- }
141
-
142
- public function addImportStatus( $message, $finished = 0 ){
143
-
144
- $this->existTable();
145
-
146
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
147
- $query = "insert into codi_import_status (message, finished) values('".$message."', $finished)";
148
- $write->query($query);
149
- }
150
-
151
- public function getImportStatuses(){
152
-
153
- $this->existTable();
154
-
155
- $read= Mage::getSingleton('core/resource')->getConnection('core_read');
156
-
157
- $query = "select id, message, finished from codi_import_status order by id desc limit 1";
158
-
159
- $messages = null;
160
-
161
- $result = $read->query($query);
162
-
163
- if($row = $result->fetch() ){
164
- $messages = array('message'=>$row['message'], 'id'=>$row['id'], 'finished'=>$row['finished']);
165
- }
166
-
167
- return $messages;
168
- }
169
-
170
- public function deleteTable(){
171
-
172
- $this->existTable();
173
-
174
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
175
- $query = "delete from codi_import_status";
176
- $write->query($query);
177
- }
178
-
179
- public function isStart(){
180
-
181
- $this->existTable();
182
-
183
- $read= Mage::getSingleton('core/resource')->getConnection('core_read');
184
-
185
- $query = "select id, message, finished from codi_import_status where message = 'start' order by id desc limit 1";
186
-
187
- $result = $read->query($query);
188
-
189
- if($row = $result->fetch() ){
190
- return true;
191
- }
192
-
193
- return false;
194
- }
195
- //Changed in 3.0.3
196
- public function createFile($basePath){
197
-
198
- $fh = fopen($basePath.'CoDzip/CoDfiles/temp.txt', 'w');
199
-
200
- if ( !$fh )
201
- {
202
- return false;
203
- }
204
-
205
- fclose($fh);
206
-
207
- //unlink($basePath.'CoDzip/CoDfiles/temp.txt');
208
- return true;
209
- }
210
-
211
- //Changed in 3.0.6
212
- public function createFileInit($basePath){
213
-
214
- $fh = fopen($basePath.'CoDzip/CoDfiles/ttemp.txt', 'w');
215
-
216
- if ( !$fh )
217
- {
218
- return false;
219
- }
220
-
221
- fclose($fh);
222
-
223
- unlink($basePath.'CoDzip/CoDfiles/ttemp.txt');
224
- return true;
225
- }
226
-
227
- public function run_codi_import_manually($basepath){
228
-
229
- $this->run_codi_import($basepath);
230
- }
231
-
232
- public function run_codi_import($basePath)
233
- {
234
- Mage::log("Notice : Codi Import Start", null, $this->_logFile);
235
-
236
- ini_set('memory_limit','1024M');
237
-
238
- $this->InitImportStatuses();
239
-
240
- $fh = fopen($basePath.'CoDzip/CoDfiles/temp.txt', 'w');
241
-
242
- if ( !$fh )
243
- {
244
- Mage::log("ERROR : Cann't open file for building data file:".$basePath, null, $this->_logFile);
245
- $this->addImportStatus("fileerror", 1);
246
- return;
247
- }
248
-
249
- fwrite($fh, "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo");
250
-
251
- $products = Mage::getModel('catalog/product')->getCollection();
252
- $products->addAttributeToFilter('status', 1);//enabled
253
- $products->addAttributeToFilter('visibility', 4);//catalog, search
254
- $products->addAttributeToSelect('*');
255
- $prodIds = $products->getAllIds();
256
-
257
- $this->addImportStatus("start");
258
-
259
- $status = "end";
260
- foreach($prodIds as $productId) {
261
-
262
- set_time_limit(0);
263
-
264
- $message = $this->getImportStatuses();
265
- if ( isset($message) && $message['message'] == "cancel") {
266
- $status = "cancel";
267
- break;
268
- }
269
-
270
- $product = Mage::getModel('catalog/product');
271
- $product->load($productId);
272
-
273
- fwrite($fh, $this->ProducttoString($product, "product"));
274
- }
275
-
276
- fclose($fh);
277
- Mage::log("Notice : Codi Import End : ".$status, null, $this->_logFile);
278
- //Clean up
279
- unset($products);
280
- unset($product);
281
-
282
- if ( $status == "end" )
283
- $this->addImportStatus($status, 1);
284
- }
285
-
286
- public function ProducttoString( $product , $from )
287
- {
288
-
289
- if( $product->isConfigurable() )
290
- {
291
- return $this->ProducttoStringConfigurable( $product , $from ) ;
292
- }
293
-
294
- elseif( $product->isGrouped() )
295
- {
296
- return $this->ProducttoStringGrouped( $product , $from ) ;
297
- }
298
- else
299
- {
300
- return $this->ProducttoStringSimple( $product , $from ) ;
301
- }
302
- }
303
- ////////////////////////////////////// Grouped Products //////////////////////////////////////////////////////////
304
- public function ProducttoStringGrouped( $product , $from )
305
- {
306
- $ProducttoString = '' ;
307
- $getAssociatedProductIds = Mage::getModel('catalog/product_type_grouped')->getAssociatedProductIds($product);
308
-
309
- $ProductDescription = '';
310
- if(Mage::getStoreConfig('codi/codi/codincludeshortdescription')=="checked")
311
- {
312
- $shortDescription = $product->getShortDescription();
313
- if(strpos($shortDescription,'<p>')!==false)
314
- {
315
- $new=strlen($shortDescription);
316
- $pos = strrpos($shortDescription, '</p>')+4;
317
- if($new!=$pos)
318
- {
319
- $extra="<p>";
320
- $pextra="</p>";
321
- $ProductDescription .= substr($shortDescription, 0, $pos) . $extra . substr($shortDescription, $pos).$pextra;
322
- }
323
- else $ProductDescription .= $shortDescription ;
324
- }
325
- else
326
- $ProductDescription .= "<p>".$shortDescription ."</p>";
327
-
328
- }
329
- $longDescription = $product->getDescription() ;
330
- if(strpos($longDescription,'<p>')!==false)
331
- {
332
- $new=strlen($longDescription);
333
- $pos = strrpos($longDescription, '</p>')+4;
334
- if($new!=$pos)
335
- {
336
- $extra="<p>";
337
- $pextra="</p>";
338
- $ProductDescription .= substr($longDescription, 0, $pos) . $extra . substr($longDescription, $pos).$pextra;
339
- }
340
- else $ProductDescription .= $longDescription ;
341
- }
342
- else
343
- $ProductDescription .= "<p>".$longDescription ."</p>" ;
344
- //Get Product Attributes Start
345
- $attributes = $product->getAttributes();
346
-
347
- $ProductAttributes = "" ;
348
- foreach ($attributes as $attribute) {
349
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
350
- $value = $attribute->getFrontend()->getValue($product);
351
- if (is_string($value))
352
- {
353
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
354
- {
355
- $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
356
- }
357
- }
358
- }
359
- }
360
- $ProductAttributes = substr($ProductAttributes, 0, strlen($ProductAttributes)-1 ) ;
361
- //Get Product Attributes End
362
-
363
- //******************** Get Tier Price option *********************//
364
-
365
- if(Mage::getStoreConfig('codi/codi/codpublishtieredpricing')=='checked')
366
- {
367
- $TierPriceAttributes =Mage::helper('codi')->geTierprice($product);
368
- $sp="|";
369
- if(($ProductAttributes=='') || ($TierPriceAttributes==''))
370
- $sp='';
371
-
372
- if($ProductAttributes=='')
373
-
374
-
375
- $ProductAttributes.= $sp.$TierPriceAttributes;
376
- }
377
- //************End Tier Price option *************//
378
- //************************* Get Categories names Start ***************************
379
- //Changed in 3.0.3 removed the category names
380
- $CategoriesString = "" ;
381
-
382
- //************************* Get Categories names End ***************************
383
-
384
-
385
- foreach($getAssociatedProductIds as $UsedProductid)
386
- {
387
- $UsedProduct = Mage::getModel('catalog/product')->load($UsedProductid);
388
- $ItemName= $UsedProduct->getName() ;
389
- if( Mage::getStoreConfig('codi/codi/fromchild') )
390
- $UsedProductPrice = $UsedProduct->getFinalPrice() ;
391
- else
392
- $UsedProductPrice = $UsedProduct->getFinalPrice() ; //default behavior
393
- //************************ Get Attributes Start *******************************
394
-
395
- //Extract Attributes
396
-
397
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
398
- $ItemImageURL = $this->mediaurl . "catalog/product" . $UsedProduct->getImage();
399
- //Get Item Attributes Start
400
-
401
- //$excludeAttr = array() ;
402
- $attributes = $UsedProduct->getAttributes();
403
- $ItemitemAttributes = "" ;
404
- foreach ($attributes as $attribute) {
405
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
406
- $value = $attribute->getFrontend()->getValue($UsedProduct);
407
- if (is_string($value))
408
- {
409
- if (strlen($value) && $UsedProduct->hasData($attribute->getAttributeCode()))
410
- {
411
- $ItemitemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
412
- }
413
- }
414
- }
415
- }
416
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 ) ;
417
-
418
-
419
-
420
- //Get Item Attributes End
421
- //************************ Get Attributes End ************************************
422
- //************************* Get Reviews Start ***********************
423
- //$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
424
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
425
- //************************* Get Reviews End *************************
426
-
427
- //************************* Concatenate Product Info Start ***********************
428
- $ProducttoString .= "\r\n" . $this->cleanStr( $UsedProduct->getSku() ) ; //ItemID
429
- $ProducttoString .= "\t" . "" ; //ItemQty
430
- $ProducttoString .= "\t" . "" ; //ItemUom
431
- // $ProducttoString .= "\t" . $this->cleanStr( $product->getPrice() ) ; //ItemPrice
432
- $ProducttoString .= "\t" . $this->cleanStr( $UsedProductPrice ) ; //ItemPrice
433
- $ProducttoString .= "\t" . $this->cleanStr( $ItemName) ; //ItemDescription
434
- $ProducttoString .= "\t" . $this->cleanStr( $UsedProduct ->getProductUrl() ); //ItemLink
435
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ItemitemAttributes
436
- $ProducttoString .= "\t" . $this->cleanStr( $ItemImageURL ) ; //ItemitemGraphic
437
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
438
- $ProducttoString .= "\t" . "" ;
439
- //add paragraph tag in description
440
-
441
- $ProducttoString .= "\t" . $this->cleanStr($ProductDescription) ;
442
-
443
- //ProductDescription
444
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
445
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
446
- $ProducttoString .= "\t" . $this->cleanStr( $ProductAttributes ) ; //ProductAttributes
447
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
448
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
449
- $shortdescription=$product->getShortDescription();
450
- if(strpos($shortdescription,'<p>')!==false)
451
-
452
- $ProducttoString .= "\t" . $this->cleanStr($shortdescription) ;
453
-
454
- else $ProducttoString .= "\t" . $this->cleanStr( "<p>".$shortdescription ."</p>") ; //ShortDescription (Quick Overview)
455
- //************************* Concatenate Product Info End ************************* cleanStr
456
- }
457
- unset($ProductDescription);
458
- unset($ImageURL);
459
- unset($product);
460
- unset($ItemitemAttributes);
461
- unset($CategoriesString);
462
- unset($Reviews);
463
- unset($UsedProduct);
464
-
465
- return $ProducttoString ;
466
- }
467
-
468
-
469
- ////////////////////////////////////// Configurable Products //////////////////////////////////////////////////////////
470
- public function ProducttoStringConfigurable( $product , $from )
471
- {
472
- $ProducttoString = '' ;
473
- $UsedProductIds = Mage::getModel('catalog/product_type_configurable')->getUsedProductIds($product);
474
-
475
- $ProductDescription = '';
476
- if(Mage::getStoreConfig('codi/codi/codincludeshortdescription')=="checked")
477
- {
478
- $shortDescription = $product->getShortDescription();
479
- if(strpos($shortDescription,'<p>')!==false)
480
- {
481
- $new=strlen($shortDescription);
482
- $pos = strrpos($shortDescription, '</p>')+4;
483
- if($new!=$pos)
484
- {
485
- $extra="<p>";
486
- $pextra="</p>";
487
- $ProductDescription .= substr($shortDescription, 0, $pos) . $extra . substr($shortDescription, $pos).$pextra;
488
- }
489
- else $ProductDescription .= $shortDescription ;
490
- }
491
- else
492
- $ProductDescription .= "<p>".$shortDescription ."</p>";
493
-
494
- }
495
- $longDescription = $product->getDescription() ;
496
- if(strpos($longDescription,'<p>')!==false)
497
- {
498
- $new=strlen($longDescription);
499
- $pos = strrpos($longDescription, '</p>')+4;
500
- if($new!=$pos)
501
- {
502
- $extra="<p>";
503
- $pextra="</p>";
504
- $ProductDescription .= substr($longDescription, 0, $pos) . $extra . substr($longDescription, $pos).$pextra;
505
- }
506
- else $ProductDescription .= $longDescription ;
507
-
508
- }
509
- else
510
- $ProductDescription .= "<p>".$longDescription ."</p>" ;
511
- //Get Product Attributes Start
512
- //$excludeAttr = array() ;
513
- $attributes = $product->getAttributes();
514
-
515
- $ProductAttributes = "" ;
516
- foreach ($attributes as $attribute) {
517
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
518
- $value = $attribute->getFrontend()->getValue($product);
519
- if (is_string($value))
520
- {
521
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
522
- {
523
- $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
524
- }
525
- }
526
- }
527
- }
528
- $ProductAttributes = substr($ProductAttributes, 0, strlen($ProductAttributes)-1 ) ;
529
- //Get Product Attributes End
530
-
531
- //******************** Get Tier Price option *********************//
532
-
533
- if(Mage::getStoreConfig('codi/codi/codpublishtieredpricing')=='checked')
534
- {
535
- $TierPriceAttributes =Mage::helper('codi')->geTierprice($product);
536
- $sp="|";
537
- if(($ProductAttributes=='') || ($TierPriceAttributes==''))
538
- $sp='';
539
-
540
- if($ProductAttributes=='')
541
-
542
-
543
- $ProductAttributes.= $sp.$TierPriceAttributes;
544
- }
545
- //************End Tier Price option *************//
546
- //************************* Get Categories names Start ***************************
547
- //Changed in 3.0.3 removed the category names
548
- $CategoriesString = "" ;
549
-
550
- //************************* Get Categories names End ***************************
551
-
552
- foreach($UsedProductIds as $UsedProductid)
553
- {
554
- $UsedProduct = Mage::getModel('catalog/product')->load($UsedProductid);
555
- if( Mage::getStoreConfig('codi/codi/fromchild') )
556
- $UsedProductPrice = $UsedProduct->getFinalPrice() ;
557
- else
558
- $UsedProductPrice = $product->getFinalPrice() ; //default behavior
559
- //************************ Get Attributes Start *******************************
560
-
561
- //Extract Attributes
562
-
563
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
564
-
565
- //Get Item Attributes Start
566
-
567
- $attributes = $UsedProduct->getAttributes();
568
-
569
- $ItemitemAttributes = "" ;
570
- $AllowAttributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
571
- foreach ($AllowAttributes as $attribute)
572
- {
573
- $AttributeCode = $attribute->getProductAttribute()->getAttributeCode() ;
574
- $AttributeLabel = $attribute->getProductAttribute()->getFrontend()->getLabel() ;
575
- $AttribId = $UsedProduct->getData($AttributeCode) ;
576
-
577
- $AttributeValue = "" ;
578
- foreach ( $attribute->getProductAttribute()->getSource()->getAllOptions() as $option )
579
- {
580
- if( $option['value'] == $AttribId )
581
- {
582
- $AttributeValue = $option['label'];
583
- }
584
- }
585
-
586
- $ItemitemAttributes .= $AttributeLabel . "=" . $AttributeValue . "|" ;
587
-
588
- //Get Delta Price Start
589
- foreach( $attribute->getPrices() as $addedPrice )
590
- {
591
- if ( $AttributeValue == $addedPrice['label'])
592
- {
593
- if( $addedPrice['is_percent'] )
594
- $UsedProductPrice += $UsedProductPrice * $addedPrice['pricing_value'] / 100;
595
- else
596
- $UsedProductPrice += $addedPrice['pricing_value'] ;
597
- }
598
- }
599
- //Get Delta Price End
600
- }
601
-
602
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 );
603
-
604
-
605
-
606
- //Get Item Attributes End
607
- //************************ Get Attributes End ************************************
608
- //************************* Get Reviews Start ***********************
609
- //$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
610
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
611
- //************************* Get Reviews End *************************
612
-
613
- //************************* Concatenate Product Info Start ***********************
614
- $ProducttoString .= "\r\n" . $this->cleanStr( $UsedProduct->getSku() ) ; //ItemID
615
- $ProducttoString .= "\t" . "" ; //ItemQty
616
- $ProducttoString .= "\t" . "" ; //ItemUom
617
- // $ProducttoString .= "\t" . $this->cleanStr( $product->getPrice() ) ; //ItemPrice
618
- $ProducttoString .= "\t" . $this->cleanStr( $UsedProductPrice ) ; //ItemPrice
619
- $ProducttoString .= "\t" . ""; //ItemDescription
620
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
621
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ItemitemAttributes
622
- $ProducttoString .= "\t" . ""; //ItemitemGraphic
623
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
624
- $ProducttoString .= "\t" . "" ;
625
-
626
- $ProducttoString .= "\t" . $this->cleanStr($ProductDescription) ;
627
-
628
- //ProductDescription
629
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
630
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
631
- $ProducttoString .= "\t" . $this->cleanStr( $ProductAttributes ) ; //ProductAttributes
632
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
633
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
634
- $shortdescription=$product->getShortDescription();
635
- if(strpos($shortdescription,'<p>')!==false)
636
-
637
- $ProducttoString .= "\t" . $this->cleanStr($shortdescription) ;
638
-
639
- else $ProducttoString .= "\t" . $this->cleanStr( "<p>".$shortdescription ."</p>") ; //ShortDescription (Quick Overview)
640
- //************************* Concatenate Product Info End ************************* cleanStr
641
- }
642
- unset($ProductDescription);
643
- unset($ImageURL);
644
- unset($product);
645
- unset($ItemitemAttributes);
646
- unset($CategoriesString);
647
- unset($Reviews);
648
-
649
-
650
- return $ProducttoString ;
651
- }
652
-
653
-
654
- /////////////////////////////////////////// Simple Products ///////////////////////////////////////////////////////////////////
655
- public function ProducttoStringSimple( $product , $from )
656
- {
657
- $ProducttoString = '' ;
658
- //Change for short description
659
- //$ProductDescription = $product->getDescription() ;
660
- $ProductDescription = '';
661
-
662
- if(Mage::getStoreConfig('codi/codi/codincludeshortdescription')=="checked")
663
- {
664
- $shortDescription = $product->getShortDescription();
665
- if(strpos($shortDescription,'<p>')!==false)
666
- {
667
- $new=strlen($shortDescription);
668
- $pos = strrpos($shortDescription, '</p>')+4;
669
- if($new!=$pos)
670
- {
671
- $extra="<p>";
672
- $pextra="</p>";
673
- $ProductDescription .= substr($shortDescription, 0, $pos) . $extra . substr($shortDescription, $pos).$pextra;
674
- }
675
- else $ProductDescription .= $shortDescription ;
676
- }
677
- else
678
- $ProductDescription .= "<p>".$shortDescription ."</p>";
679
-
680
- }
681
- $longDescription = $product->getDescription() ;
682
- if(strpos($longDescription,'<p>')!==false)
683
- {
684
- $new=strlen($longDescription);
685
- $pos = strrpos($longDescription, '</p>')+4;
686
- if($new!=$pos)
687
- {
688
- $extra="<p>";
689
- $pextra="</p>";
690
- $ProductDescription .= substr($longDescription, 0, $pos) . $extra . substr($longDescription, $pos).$pextra;
691
- }
692
- else $ProductDescription .= $longDescription ;
693
- }
694
- else
695
- $ProductDescription .= "<p>".$longDescription ."</p>" ;
696
-
697
- //************************ Get Attributes Start *******************************
698
- //Extract Attributes
699
-
700
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
701
-
702
- //$excludeAttr = array() ;
703
- $attributes = $product->getAttributes();
704
- $ItemitemAttributes = "" ;
705
- foreach ($attributes as $attribute) {
706
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
707
- $value = $attribute->getFrontend()->getValue($product);
708
- if (is_string($value))
709
- {
710
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
711
- {
712
- $ItemitemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
713
- }
714
- }
715
- }
716
- }
717
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 ) ;
718
- //************************ Get Attributes End ************************************
719
- //******************** Get Tier Price option *********************//
720
-
721
- if(Mage::getStoreConfig('codi/codi/codpublishtieredpricing')=='checked')
722
- {
723
- $TierPriceAttributes =Mage::helper('codi')->geTierprice($product);
724
- $sp="|";
725
- if(($ItemitemAttributes=='') || ($TierPriceAttributes==''))
726
- $sp='';
727
-
728
- $ItemitemAttributes.= $sp.$TierPriceAttributes;
729
- }
730
- //************End Tier Price option *************//
731
-
732
-
733
-
734
- //************************* Get Categories names Start ***************************
735
- //Changed into 3.0.3 removed the category name
736
-
737
- $CategoriesString = "" ;
738
-
739
- //************************* Get Categories names End ***************************
740
-
741
- //************************* Get Reviews Start ***********************
742
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
743
- //************************* Get Reviews End *************************
744
-
745
- //************************* Concatenate Product Info Start ***********************
746
-
747
- $ProducttoString .= "\r\n" . $this->cleanStr( $product->getSku() ) ; //ItemID
748
- $ProducttoString .= "\t" . "" ; //ItemQty
749
- $ProducttoString .= "\t" . "" ; //ItemUom
750
- $ProducttoString .= "\t" . $this->cleanStr( $product->getFinalPrice() ) ; //ItemPrice
751
- $ProducttoString .= "\t" . ""; //ItemDescription
752
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
753
- $ProducttoString .= "\t" . ""; //ItemitemAttributes
754
- $ProducttoString .= "\t" . ""; //ItemitemGraphic
755
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
756
- $ProducttoString .= "\t" . "" ;
757
- //ProductMfg
758
- $ProducttoString .= "\t" . $this->cleanStr( $ProductDescription) ; //ProductDescription
759
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
760
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
761
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ProductAttributes
762
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
763
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
764
- $shortdescription=$product->getShortDescription();
765
- if(strpos($shortdescription,'<p>')!==false)
766
-
767
- $ProducttoString .= "\t" . $this->cleanStr($shortdescription) ;
768
-
769
- else $ProducttoString .= "\t" . $this->cleanStr( "<p>".$shortdescription ."</p>") ; //ShortDescription (Quick Overview)
770
- //************************* Concatenate Product Info End ************************* cleanStr
771
-
772
- unset($ProductDescription);
773
- unset($ImageURL);
774
- unset($product);
775
- unset($ItemitemAttributes);
776
- unset($CategoriesString);
777
- unset($Reviews);
778
-
779
- return $ProducttoString ;
780
- }
781
-
782
- public function cleanStr($localstr)
783
- {
784
- //$specialChar=array('&#11;'=>'','&#27;'=>'');
785
-
786
- $localstr = str_replace("\t","", $localstr ) ;
787
- $localstr = str_replace("\r\n","<br>", $localstr ) ;
788
- $localstr = str_replace("\r","<br>", $localstr ) ;
789
- $localstr = str_replace("\n","<br>", $localstr ) ;
790
- $localstr = str_replace("","",$localstr) ;
791
- //Changed for special character
792
-
793
-
794
-
795
- return $localstr ;
796
- }
797
-
798
- public function getReviews( $productid )
799
- {
800
- $reviewsCollection = $this->reviewsModel->getCollection()
801
- ->addStoreFilter($this->StoreId)
802
- ->addStatusFilter('approved')
803
- ->addEntityFilter('product', $productid)
804
- ->setDateOrder();
805
-
806
- $Reviews = "" ;
807
- foreach($reviewsCollection as $review)
808
- {
809
- $ratingCollection = $this->ratingModel
810
- ->getResourceCollection()
811
- ->setReviewFilter($review->getReviewId())
812
- ->setStoreFilter($this->StoreId)
813
- ->addRatingInfo($this->StoreId)
814
- ->load();
815
- $Reviews .= "<p><b>".$review->getTitle()."(". $review->getNickname() .")</b><br>".$review->getDetail()."</p>" ;
816
- }
817
- return $Reviews ;
818
- }
819
-
820
- public function checkvalidity()
821
- {
822
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
823
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
824
- $url = "https://webservices.catalog-on-demand.com/smanager/api.do?Operation=ValidateUser&ResponseGroups=All&FunctionGroups=All" ;
825
- $paramsarray = array('UserID' => $userid ,
826
- 'Password' => $password );
827
- $Responsemsg = $this->Call( $url, $paramsarray );
828
- if( $Responsemsg )
829
- return $Responsemsg->Message=="OK" ? true : false ;
830
- else
831
- return false ;
832
- }
833
-
834
- //////////////////////////////////// Calling Start /////////////////////////////////////////////////////
835
- public function CallusingZend( $url, $paramsarray )
836
- {
837
- $client = new Zend_Http_Client();
838
- $client->setUri($url);
839
- $client->setParameterPost('UserID', $this->userid);
840
- $client->setParameterPost('Password', $this->password);
841
-
842
- $mystr = '';
843
- foreach($paramsarray as $key=>$value)
844
- {
845
- $client->setParameterPost($key, $value);
846
- $mystr .= $key . $value ;
847
- }
848
-
849
- $response = $client->request('POST');
850
- $result = $response->getBody() ;
851
- return $result;
852
- }
853
-
854
- public function CallusingCurl( $url, $paramsarray )
855
- {
856
- $poststr = '';
857
- foreach($paramsarray as $key=>$value)
858
- {
859
- $poststr .= $key ."=". urlencode($value) ."&";
860
- }
861
-
862
- $ch = curl_init();
863
- curl_setopt($ch, CURLOPT_URL,$url);
864
- curl_setopt($ch, CURLOPT_FAILONERROR, 1);
865
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
866
- curl_setopt($ch, CURLOPT_POST,1);
867
- curl_setopt($ch, CURLOPT_POSTFIELDS, $poststr);
868
- $result = curl_exec($ch);
869
- curl_close($ch);
870
-
871
- return $result;
872
- }
873
-
874
- public function Call( $url, $paramsarray )
875
- {
876
- $result = "" ;
877
- try
878
- {
879
- $result = $this->CallusingZend( $url, $paramsarray );
880
- }
881
- catch(Exception $e)
882
- {
883
- try
884
- {
885
- $result = $this->CallusingCurl( $url, $paramsarray );
886
- }
887
- catch(Exception $e){}
888
- }
889
-
890
- $Responsemsg = false ;
891
-
892
- return $result ;
893
- }
894
- //////////////////////////////////// Calling End /////////////////////////////////////////////////////
895
- public function getComment($datetime='')
896
- {
897
- $Comment = "";
898
- ////////////////////////////////////////////////////////////
899
- $extension_version = $this->version;//(string) Mage::getConfig()->getNode()->modules->Mage_Codi->version;
900
- $app_version = Mage::getVersion();
901
- $php_version = phpversion();
902
-
903
- foreach (Mage::app()->getWebsites() as $website)
904
- {
905
- $defaultGroup = $website->getDefaultGroup();
906
- $StoreId = $defaultGroup->getDefaultStoreId();
907
- }
908
-
909
- $design = Mage::getSingleton('core/design')->loadChange($StoreId);
910
- $package = $design->getPackage();
911
- $default_theme = $design->getTheme();
912
-
913
- if ( $package == "" && $default_theme == "" ){
914
-
915
- $package = Mage::getStoreConfig('design/package/name', $StoreId);
916
- $default_theme = Mage::getStoreConfig('design/theme/default', $StoreId);
917
- }
918
-
919
- if ( $package == "" ) $package = "default";
920
- if ( $default_theme == "" ) $default_theme = "default";
921
-
922
- $theme = "default";
923
- if ( $package != "default" || $default_theme != "default" )
924
- $theme = $package."/".$default_theme;
925
-
926
- $codbgcheck = ( Mage::getStoreConfig('codi/codi/codbgcheck') == '1' )?'Yes':'No' ;
927
-
928
- $enablefreshflyers = ( Mage::getStoreConfig('codi/codi/enablefreshflyers') == 'checked' )?'Yes':'No' ;
929
- $enablereviews = ( Mage::getStoreConfig('codi/codi/codenablereviews') == 'checked' )?'Yes':'No' ;
930
- $fromchild = ( Mage::getStoreConfig('codi/codi/fromchild') == 'checked' )?'Yes':'No' ;
931
-
932
- $codflyerlinkimgurl = Mage::getStoreConfig('codi/codi/codflyerlinkimgurl') ;
933
- $codflyerlinkimg = ( Mage::getStoreConfig('codi/codi/codflyerlinkimg') == 'Custom' )? $codflyerlinkimgurl:'Default';
934
- $codflyerlinkimgalt = Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') ;
935
-
936
- $codbeforename = ( Mage::getStoreConfig('codi/codi/codbeforename') == 'checked' )?'Yes':'No' ;
937
- $codaftername = ( Mage::getStoreConfig('codi/codi/codaftername') == 'checked' )?'Yes':'No' ;
938
- $codbeforeemailto = ( Mage::getStoreConfig('codi/codi/codbeforeemailto') == 'checked' )?'Yes':'No' ;
939
- $codafteremailto = ( Mage::getStoreConfig('codi/codi/codafteremailto') == 'checked' )?'Yes':'No' ;
940
- $codbeforeOR = ( Mage::getStoreConfig('codi/codi/codbeforeOR') == 'checked' )?'Yes':'No' ;
941
- $codafterOR = ( Mage::getStoreConfig('codi/codi/codafterOR') == 'checked' )?'Yes':'No' ;
942
- $codbeforeoverview = ( Mage::getStoreConfig('codi/codi/codbeforeoverview') == 'checked' ) ?'Yes':'No';
943
- $codafteroverview = ( Mage::getStoreConfig('codi/codi/codafteroverview') == 'checked' )?'Yes':'No';
944
- //Changed for include short description
945
- $includeshortdescription = (Mage::getStoreConfig('codi/codi/codincludeshortdescription')== 'checked' )?'Yes':'No';
946
-
947
- $Comment = "App extension version: ".$extension_version." \r\n";
948
- $Comment .= "Magento version: ".$app_version." \r\n";
949
- $Comment .= "PHP: ".$php_version." \r\n";
950
- $Comment .= "Theme: ".$theme." \r\n";
951
- $Comment .= "Create data file using background process: ".$codbgcheck." \r\n";
952
- $Comment .= "Enable Always Fresh Flyers: ".$enablefreshflyers." \r\n";
953
- $Comment .= "Include Short Description: ".$includeshortdescription." \r\n";
954
- $Comment .= "Enable Reviews: ".$enablereviews." \r\n";
955
- $Comment .= "Get price from associated products: ".$fromchild." \r\n";
956
- $Comment .= "Image to be used for flyer link: ".$codflyerlinkimg." \r\n";
957
- $Comment .= "Alt text for flyer link image: ".$codflyerlinkimgalt." \r\n";
958
- $Comment .= "Display options: \r\n";
959
- $Comment .= " Display before product name: ".$codbeforename." \r\n";
960
- $Comment .= " Display after product name: ".$codaftername." \r\n";
961
- $Comment .= " Display before Email to a friend: ".$codbeforeemailto." \r\n";
962
- $Comment .= " Display after Email to a friend: ".$codafteremailto." \r\n";
963
- $Comment .= " Display before OR: ".$codbeforeOR." \r\n";
964
- $Comment .= " Display after OR: ".$codafterOR." \r\n";
965
- $Comment .= " Display before Quick Overview: ".$codbeforeoverview." \r\n";
966
- $Comment .= " Display after Quick Overview: ".$codafteroverview." \r\n";
967
-
968
- //Change for site url
969
- $siteurl = Mage::getUrl('/');
970
- $Comment .="Site Url: ".$siteurl."\r\n";
971
- $datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
972
- if($datafilelaunch=='magento')
973
- {
974
- $datafilelaunch='cronjob';
975
-
976
- }
977
-
978
- //code for version 2.2.16
979
-
980
- $Comment .="Data File Launch Mode: ".$datafilelaunch."\r\n";
981
-
982
- $url = Mage::getUrl('codi/nsync') ;
983
- $pos = strrpos ($url , 'key') ;
984
- if ( $pos != 0 )
985
- $cronjoburl = substr( $url , 0 , $pos ) ;
986
- else
987
- $cronjoburl = $url;
988
-
989
- if(($datafilelaunch=='cronjob') || ($datafilelaunch=='manual'))
990
- {
991
- $Comment .="Cron job command: wget ".$cronjoburl."\r\n";
992
- }
993
- else{
994
- $waitforminute=Mage::getStoreConfig('codi/codi/codwaitforminute')/60;
995
- $Comment .="WaitFor: ".number_format($waitforminute,2,'.','')."\r\n";
996
-
997
- }
998
-
999
- $Comment .="Extension Name: ".$this->extensionName."\r\n";
1000
- $Comment .="Date and time of most recent data file: ".$datetime."\r\n";
1001
- //Changed for Tier Price options
1002
-
1003
- $publishtieredpricing=Mage::getStoreConfig('codi/codi/codpublishtieredpricing');
1004
- if($publishtieredpricing=='checked')
1005
- {
1006
- $codquantity=Mage::getStoreConfig('codi/codi/codquantity');
1007
- $codprice=Mage::getStoreConfig('codi/codi/codprice');
1008
- $codsavings=Mage::getStoreConfig('codi/codi/codsavings');
1009
- $publish=($publishtieredpricing == 'checked' )?'Yes':'No';
1010
- $Comment .= "Tiered Pricing Options: \r\n";
1011
- $Comment .= " Publish tiered pricing: ".$publish." \r\n";
1012
- $Comment .= " Label for quantity column: ".$codquantity." \r\n";
1013
- $Comment .= " Label for price column: ".$codprice." \r\n";
1014
- $Comment .= " Label for savings: ".$codsavings." \r\n";
1015
-
1016
- }
1017
-
1018
-
1019
- return $Comment;
1020
- ////////////////////////////////////////////////////////////
1021
- }
1022
- //code for version 2.2.16
1023
- public function new_run_codi_import($basePath)
1024
- {
1025
-
1026
- Mage::log("Notice : Codi Import Start", null, $this->_logFile);
1027
-
1028
- ini_set('memory_limit','1024M');
1029
-
1030
- $this->InitImportStatuses();
1031
-
1032
- $fh = fopen($basePath.'CoDzip/CoDfiles/temp.txt', 'w');
1033
-
1034
- if ( !$fh )
1035
- {
1036
- Mage::log("ERROR : Cann't open file for building data file:".$basePath, null, $this->_logFile);
1037
- $this->addImportStatus("fileerror", 1);
1038
- return;
1039
- }
1040
-
1041
- fwrite($fh, "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo");
1042
-
1043
- $products = Mage::getModel('catalog/product')->getCollection();
1044
- $products->addAttributeToFilter('status', 1);//enabled
1045
- $products->addAttributeToFilter('visibility', 4);//catalog, search
1046
- $products->addAttributeToSelect('*');
1047
-
1048
- $prodIds = $products->getAllIds();
1049
-
1050
- $this->addImportStatus("start");
1051
-
1052
- $status = "end";
1053
- $i='0';
1054
- try{
1055
- foreach($prodIds as $productId)
1056
- {
1057
- set_time_limit(20);
1058
- $message = $this->getImportStatuses();
1059
- if ( isset($message) && $message['message'] == "cancel") {
1060
- $status = "cancel";
1061
- break;
1062
- }
1063
- $product = Mage::getModel('catalog/product');
1064
- $product->load($productId);
1065
- Mage::log("Notice : Codi Import Products :".$i, null, $this->_logFile);
1066
- fwrite($fh, $this->ProducttoString($product, "product"));
1067
- $i++;
1068
- }
1069
- }
1070
-
1071
- catch (Exception $e)
1072
- {
1073
- Mage::log("Notice : Codi Import Products Exception :".$e->getMessage(), null, $this->_logFile);
1074
- }
1075
- //clean up the memory
1076
- unset($product);
1077
- unset($prodIds);
1078
- unset($products);
1079
-
1080
- fclose($fh);
1081
- Mage::log("Notice : Codi Import End : ".$status, null, $this->_logFile);
1082
-
1083
- if ( $status == "end" )
1084
- $this->addImportStatus($status, 1);
1085
-
1086
- }
1087
- //code for create CatalogSection.txt
1088
- public function createCatalogSection()
1089
- {
1090
- Mage::log("Notice : Create Catalog Section Start: ", null, $this->_logFile);
1091
-
1092
- $helper=Mage::helper('codi');
1093
- $dir = dirname(__FILE__);
1094
- $_baseDirArray = explode("app", $dir);
1095
- $basePath = $_baseDirArray[0];
1096
- $progress=100;
1097
- /*
1098
- //Create object for Codi Model
1099
- //Create table Codi Catalog Section for insert category hirarchy path
1100
- */
1101
- $catalogSectionModel=Mage::getModel('codi/codi');
1102
- $catalogSectionModel->InitCatalogSectionTable();
1103
-
1104
- $collection = Mage::getModel('catalog/category')->getCollection()
1105
- ->setStoreId('1')
1106
- ->addAttributeToSelect('name')
1107
- ->addAttributeToSelect('is_active')
1108
- ->addAttributeToFilter('level', array('eq' => 2))
1109
- ->addAttributeToFilter('is_active', array('eq' => 1))
1110
- ->addAttributeToSort('position', 'asc');
1111
- //echo $collection->getSelect();
1112
-
1113
-
1114
- $i=1;
1115
- $count=count($collection);
1116
- if($count>0)
1117
- {
1118
-
1119
- foreach($collection as $category)
1120
- {
1121
- $name=$category->getName();
1122
- $id=$category->getId();
1123
- $file = $basePath.'/CoDzip/CoDfiles/CatalogSection.txt';
1124
- file_put_contents($file,"sec_Project\tsec_Sequence\tsec_HierarchyPath\tsec_Flag\n");
1125
- $stringe.=$helper->drawItem($category,1,$name,$i);
1126
- file_put_contents($file,$stringe,FILE_APPEND);
1127
- $i++;
1128
- }
1129
- }
1130
- $lastId=$i;
1131
- $str="General\t".$lastId."\tUncategorized\t". $sec_Flag . "\n";
1132
- file_put_contents($file,$str,FILE_APPEND);
1133
- if($count==0)
1134
- {
1135
- $progress=0;
1136
- }
1137
-
1138
- //clean up the memory
1139
- unset($catalogSectionModel);
1140
- unset($collection);
1141
- unset($stringe);
1142
-
1143
- Mage::log("Notice : Create Catalog Section End: ", null, $this->_logFile);
1144
- return $progress;
1145
- }
1146
- //code for create Catalog Project
1147
- public function createCatalogProject($fromcron=0)
1148
- {
1149
- $dir = dirname(__FILE__);
1150
- $_baseDirArray = explode("app", $dir);
1151
- $basePath = $_baseDirArray[0];
1152
- Mage::log("Notice : Create Catalog Project Start", null, $this->_logFile);
1153
-
1154
- ini_set('memory_limit','1024M');
1155
-
1156
- $this->InitImportStatuses();
1157
-
1158
- $fh = fopen($basePath.'CoDzip/CoDfiles/CatalogProject.txt', 'w');
1159
-
1160
- if ( !$fh )
1161
- {
1162
- Mage::log("ERROR : Cann't open file for building data file:".$basePath, null, $this->_logFile);
1163
- return;
1164
- }
1165
-
1166
- fwrite($fh, "proj_Key\tproj_ProdName\tproj_Sequence\tproj_Name\tproj_HierarchyPath\tproj_Flag\tproj_ProdLayout");
1167
-
1168
- $products = Mage::getModel('catalog/product')->getCollection();
1169
- $products->addAttributeToFilter('status', 1);//enabled
1170
- $products->addAttributeToFilter('visibility', 4);//catalog, search
1171
- $products->addAttributeToSelect('*');
1172
-
1173
- $prodIds = $products->getAllIds();
1174
- $totalproduct=count($prodIds);
1175
- $this->addImportStatus("start");
1176
-
1177
- $status = "end";
1178
- $i='0';
1179
-
1180
- try{
1181
-
1182
- foreach($prodIds as $productId)
1183
- {
1184
- set_time_limit(20);
1185
- $message = $this->getImportStatuses();
1186
- if ( isset($message) && $message['message'] == "cancel") {
1187
- $status = "cancel";
1188
- break;
1189
- }
1190
- $product = Mage::getModel('catalog/product');
1191
- $product->load($productId);
1192
- Mage::log("Notice : Codi Import Products :".$i, null, $this->_logFile);
1193
- fwrite($fh, $this->CatalogProjucttoString($product, "product"));
1194
- $i++;
1195
-
1196
- }
1197
- //Change for zip code if not call from cronjob
1198
- if($fromcron==0)
1199
- {
1200
- $DataFile = 'CoDMagento';
1201
- Mage::helper('codi/createzip')->createimportzip($DataFile);
1202
- }
1203
- }
1204
- catch (Exception $e)
1205
- {
1206
- return 'error';
1207
- Mage::log("Notice : Codi Catalog Project Exception :".$e->getMessage(), null, $this->_logFile);
1208
- }
1209
- //clean up the memory
1210
- unset($products);
1211
- unset($prodIds);
1212
- unset($product);
1213
- fclose($fh);
1214
- $progress='10';
1215
- Mage::log("Notice :Codi Catalog Project End : ".$status, null, $this->_logFile);
1216
-
1217
- return $progress;
1218
- }
1219
- //Code for Catalog projuct section
1220
- public function CatalogProjucttoString( $product , $from )
1221
- {
1222
-
1223
- if( $product->isConfigurable() )
1224
- {
1225
- return $this->ProjucttoStringConfigurable( $product , $from ) ;
1226
- }
1227
- else
1228
- {
1229
- return $this->ProjucttoStringSimple( $product , $from ) ;
1230
- }
1231
- }
1232
-
1233
- public function ProjucttoStringConfigurable( $product , $from )
1234
- {
1235
- //get All associated products
1236
- $UsedProductIds = Mage::getModel('catalog/product_type_configurable')->getUsedProductIds($product);
1237
- $countUsedProductIds=count($UsedProductIds);
1238
- if($countUsedProductIds>0)
1239
- {
1240
- ini_set('memory_limit','1024M');
1241
- $ProducttoString = '' ;
1242
- //************************* Get Categories names Start ***************************
1243
- $categories = $product->getCategoryIds();
1244
- $CategoriesString = "" ;
1245
- $helper=Mage::helper('codi');
1246
- $catelogSectionModel=Mage::getModel('codi/codi');
1247
- if($categories)
1248
- {
1249
- foreach($categories as $k => $_category_id)
1250
- {
1251
- set_time_limit(20);
1252
- $_cat = Mage::getModel('catalog/category')->load($_category_id);
1253
- if(($_cat->getName() != '') && ($_cat->getIsActive() == 1) && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
1254
- {
1255
- $data=$catelogSectionModel->isCatalogSectionStart($_category_id);
1256
- $CategoriesString=$data['category_hirarchy_path'];
1257
- //code for product position
1258
- $position=$helper->productPostion($_category_id,$product->getId());
1259
- if ($CategoriesString==false) $CategoriesString = 'Uncategorized' ;
1260
- //************************* Concatenate Product Info Start ***********************
1261
- $ProducttoString .= "\r\n" . $product->getId().'#$#'. $this->cleanStr( $product->getName()); //ProductKey
1262
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
1263
- $ProducttoString .= "\t" . $this->cleanStr( $position ) ; //Prod Sequence
1264
- $ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
1265
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Hirarachi Path
1266
- $ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
1267
- $ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
1268
- //************************* Concatenate Product Info End ************************* cleanStr
1269
- }
1270
- }
1271
- }
1272
- else
1273
- {
1274
- $ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
1275
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
1276
- $ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
1277
- $ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
1278
- $ProducttoString .= "\t" . $this->cleanStr('Uncategorized'); //Hirarachi Path
1279
- $ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
1280
- $ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
1281
-
1282
-
1283
-
1284
- }
1285
- //Clean up
1286
- unset($categories);
1287
- unset($catelogSectionModel);
1288
- unset($CategoriesString);
1289
- unset($position);
1290
- unset($product);
1291
- }
1292
- else
1293
- {
1294
- $ProducttoString='';
1295
- }
1296
-
1297
-
1298
- return $ProducttoString ;
1299
- }
1300
-
1301
- /////////////////////////////////////////// Simple Products ///////////////////////////////////////////////////////////////////
1302
- public function ProjucttoStringSimple( $product , $from )
1303
- {
1304
- ini_set('memory_limit','1024M');
1305
- $ProducttoString = '' ;
1306
- //************************* Get Categories names Start ***************************
1307
- $categories = $product->getCategoryIds();
1308
- $CategoriesString = "" ;
1309
- $catelogSectionModel=Mage::getModel('codi/codi');
1310
- $helper=Mage::helper('codi');
1311
- if($categories)
1312
- {
1313
- foreach($categories as $k => $_category_id){
1314
- set_time_limit(20);
1315
- //Code for add category hirarchi_path
1316
- $_cat = Mage::getModel('catalog/category')->load($_category_id);
1317
- if(($_cat->getName() != '') && ($_cat->getIsActive() == 1) && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
1318
- {
1319
- $data=$catelogSectionModel->isCatalogSectionStart($_category_id);
1320
- $CategoriesString=$data['category_hirarchy_path'];
1321
- //code for product position
1322
- $position=$helper->productPostion($_category_id,$product->getId());
1323
-
1324
- if ($CategoriesString == false ) $CategoriesString = 'Uncategorized' ;
1325
- //************************* Concatenate Product Info Start ***********************
1326
- $ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
1327
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
1328
- $ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
1329
- $ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
1330
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Hirarachi Path
1331
- $ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
1332
- $ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
1333
- //************************* Concatenate Product Info End ************************* cleanStr
1334
- }
1335
- }
1336
- }
1337
- else
1338
- {
1339
- $ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
1340
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
1341
- $ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
1342
- $ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
1343
- $ProducttoString .= "\t" . $this->cleanStr('Uncategorized'); //Hirarachi Path
1344
- $ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
1345
- $ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
1346
-
1347
-
1348
-
1349
- }
1350
- //Clean up
1351
- unset($categories);
1352
- unset($catelogSectionModel);
1353
- unset($CategoriesString);
1354
- unset($position);
1355
- unset($product);
1356
-
1357
- return $ProducttoString ;
1358
- }
1359
- //Functions for Codi CatalogSection Table
1360
- public function InitCatalogSectionTable(){
1361
-
1362
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1363
-
1364
- $write->query("DROP TABLE IF EXISTS codi_catalog_section");
1365
- $write->query("CREATE TABLE codi_catalog_section(
1366
- category_id int(11) NOT NULL PRIMARY KEY,
1367
- category_hirarchy_path text)"
1368
- );
1369
- }
1370
-
1371
- public function existCatalogSectionTable(){
1372
-
1373
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1374
-
1375
- $write->query("CREATE TABLE IF NOT EXISTS codi_catalog_section(
1376
- category_id int(11) NOT NULL PRIMARY KEY,
1377
- category_hirarchy_path text)"
1378
- );
1379
-
1380
- }
1381
-
1382
- public function addCatalogSection( $category_id=1, $category_hirarchy_path = 'Uncategorized' ){
1383
-
1384
- $this->existCatalogSectionTable();
1385
-
1386
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1387
- $query = "insert into codi_catalog_section (category_id, category_hirarchy_path) values('".$category_id."', '".$category_hirarchy_path."')";
1388
- $write->query($query);
1389
- }
1390
- public function deleteCatalogSectionTable(){
1391
-
1392
- $this->existCatalogSectionTable();
1393
-
1394
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1395
- $query = "delete from codi_catalog_section";
1396
- $write->query($query);
1397
- }
1398
-
1399
- public function isCatalogSectionStart($category_id=1){
1400
-
1401
- $this->existCatalogSectionTable();
1402
-
1403
- $read= Mage::getSingleton('core/resource')->getConnection('core_read');
1404
-
1405
- $query = "select category_hirarchy_path from codi_catalog_section where category_id = '".$category_id."' order by category_id desc limit 1";
1406
-
1407
- $result = $read->query($query);
1408
-
1409
- if($row = $result->fetch() ){
1410
-
1411
- return $row;
1412
- }
1413
-
1414
- return false;
1415
- } //Function for save data import progress status
1416
-
1417
- public function saveProgressData($message='start',$finished=0,$created_time='',$update=0,$var='')
1418
- {
1419
- $tableName = Mage::getSingleton('core/resource')->getTableName('codi_progress_status');
1420
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1421
- if($update==0)
1422
- {
1423
- $query = "insert into ".$tableName." (message, finished,created_time) values('".$message."', $finished,$created_time)";
1424
- }
1425
- else
1426
- {
1427
- /*$query = "update ".$tableName." set message='".$message."', finished=".$finished.", created_time =".$created_time." where id=".$var;*/
1428
- $query = "delete FROM ".$tableName." where finished=1";
1429
-
1430
- }
1431
- $write->query($query);
1432
- return $write->lastInsertId();
1433
- }
1434
-
1435
- //Function to get last row details
1436
- public function getstatus()
1437
- {
1438
- $tableName = Mage::getSingleton('core/resource')->getTableName('codi_progress_status');
1439
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1440
-
1441
- $query = "select message,finished,created_time from ".$tableName." where finished=1 order by id desc limit 1";
1442
- $var=$write->query($query);
1443
-
1444
- return $var;
1445
- }
1446
-
1447
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/controllers/Adminhtml/MenuController.php DELETED
@@ -1,327 +0,0 @@
1
- <?php
2
- ini_set("max_execution_time", 3600);
3
- ini_set('session.gc_maxlifetime', 3600);
4
- ini_set("memory_limit","512M");
5
-
6
- class Mage_Codi_Adminhtml_MenuController extends Mage_Adminhtml_Controller_Action
7
- {
8
-
9
- public $CodiBlock ;
10
-
11
- protected function _construct()
12
- {
13
- $this->CodiBlock = $this->getLayout()->createBlock('codi/customer_codi');
14
- $this->_logFile = "Catalog-on-demand.log";
15
- }
16
-
17
- public function indexAction()
18
- {
19
- $this->loadLayout();
20
- $this->_setActiveMenu('catalog');
21
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
22
- $this->renderLayout();
23
- }
24
-
25
- public function authAction()
26
- {
27
- $codimodel = Mage::getSingleton('codi/codi');
28
- $codimodel->target = "auth";
29
- $this->loadLayout();
30
- $this->_setActiveMenu('catalog');
31
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
32
- $this->renderLayout();
33
- }
34
-
35
- public function systemtestAction(){
36
-
37
- $codimodel = Mage::getSingleton('codi/codi');
38
- $codimodel->target = "systemtest";
39
- $this->loadLayout();
40
- $this->_setActiveMenu('catalog');
41
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
42
- $this->renderLayout();
43
- }
44
-
45
- public function createAction(){
46
-
47
- $codimodel = Mage::getSingleton('codi/codi');
48
- $codimodel->target = "create";
49
- $this->loadLayout();
50
- $this->_setActiveMenu('catalog');
51
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
52
- $this->renderLayout();
53
- }
54
-
55
- public function createfileAction(){
56
-
57
- $codimodel = Mage::getSingleton('codi/codi');
58
-
59
- $dir = dirname(__FILE__);
60
-
61
- $_baseDirArray = explode("app", $dir);
62
- $basePath = $_baseDirArray[0].'/';
63
-
64
- if ( !$codimodel->createFile($basePath) ){
65
- Mage::log("ERROR : Cannot create file : ".$basePath, null, $this->_logFile);
66
- print '{"error": "1"}';
67
- return;
68
- }
69
-
70
- $is_process = $this->getRequest()->getParam('is_process');
71
-
72
- Mage::log("Notice: Mage_Codi_MenuController Process : ".$is_process, null, $this->_logFile);
73
-
74
- if ( $is_process == 1 ){
75
-
76
- if( false !== strpos(ini_get("disable_functions"), "exec") ) {
77
-
78
- $this->bgCheckSave();
79
-
80
- print '{"exec": "1"}';
81
-
82
- }else if ( false !== strpos(ini_get("disable_functions"), "shell_exec") ){
83
-
84
- $this->bgCheckSave();
85
-
86
- print '{"shellexec": "1"}';
87
- }else{
88
-
89
- $output = shell_exec("ps ax | grep php");
90
-
91
- Mage::log("Notice: Mage_Codi_MenuController Process : ".$output, null, $this->_logFile);
92
-
93
- if ( strpos($output, "php5") !== false ){
94
- exec("nohup php5 ".$dir."/../../Codi_Process.php > /dev/null & echo $!");
95
- Mage::log("Notice: Mage_Codi_MenuController Process : php5 ", null, $this->_logFile);
96
- }else{
97
- exec("nohup php ".$dir."/../../Codi_Process.php > /dev/null & echo $!");
98
- Mage::log("Notice: Mage_Codi_MenuController Process : php ", null, $this->_logFile);
99
- }
100
-
101
- $codimodel->addImportStatus('auto', 0);
102
- Mage::log("Notice: Mage_Codi_MenuController Process : auto ", null, $this->_logFile);
103
-
104
- print '{"success": "1"}';
105
- }
106
- }
107
- else{
108
-
109
- $codimodel->addImportStatus('manual', 0);
110
-
111
- print '{"success": "1"}';
112
-
113
- }
114
- }
115
-
116
- public function cancelAction(){
117
-
118
- $codimodel = Mage::getSingleton('codi/codi');
119
- $codimodel->addImportStatus('cancel', 1);
120
-
121
- print "cancel";
122
- }
123
-
124
- public function updatestatusAction()
125
- {
126
- $codimodel = Mage::getSingleton('codi/codi');
127
- $message = $codimodel->getImportStatuses();
128
-
129
- $dir = dirname(__FILE__);
130
- $_baseDirArray = explode("app", $dir);
131
- $basePath = $_baseDirArray[0].'/';
132
-
133
- $status = 0;
134
- if ( isset($message) ){
135
-
136
- $status = $message['message'];
137
-
138
- if ( $status== "end" && $message['finished'] == 1 ){
139
-
140
- @unlink($basePath."CoDZip/CoDfiles/temp.txt");
141
- $codimodel->deleteTable();
142
- print '{"finished": "1"}';
143
-
144
- }else if ( $status== "cancel" && $message['finished'] == 1 ) {
145
-
146
- @unlink($basePath."CoDZip/CoDfiles/temp.txt");
147
- $codimodel->deleteTable();
148
- print '{"canceled": "1"}';
149
-
150
- }else if ( $status== "start" && $message['finished'] == 0 ) {
151
-
152
- print '{"processed": "1"}';
153
-
154
- }else if ( $status== "fileerror" && $message['finished'] == 1 ) {
155
-
156
- @unlink($basePath."CoDZip/CoDfiles/temp.txt");
157
- $codimodel->deleteTable();
158
- print '{"fileerror": "1"}';
159
-
160
- }else if ( $status== "manual" && $message['finished'] == 0 ) {
161
-
162
- print '{"processed": "1"}';
163
- $codimodel->run_codi_import_manually($basePath);
164
-
165
- }else if ( $status== "auto" && $message['finished'] == 0 ){
166
- if ( !$codimodel->isStart() ){
167
- @unlink($basePath."CoDZip/CoDfiles/temp.txt");
168
- $codimodel->deleteTable();
169
- print '{"error": "1"}';
170
- }
171
- }
172
- }
173
- }
174
-
175
- public function bgcheckAction(){
176
-
177
- $checked = $this->getRequest()->getParam('check');
178
-
179
- $this->bgCheckSave($checked);
180
- }
181
-
182
- public function bgCheckSave($checked=0){
183
-
184
- $codimodel = Mage::getSingleton('codi/codi');
185
-
186
- $codimodel->setStoreConfig(
187
- array(
188
- "codbgcheck" => array ('value' => $checked)
189
- )
190
- );
191
-
192
- Mage::app()->getCacheInstance()->cleanType('config');
193
- }
194
-
195
- public function authsaveAction()
196
- {
197
- $userid = strtolower((string)$this->getRequest()->getParam('userid'));
198
- $password = (string)$this->getRequest()->getParam('password');
199
- $secretkey = (string)$this->getRequest()->getParam('secretkey');
200
- $enablefreshflyers = (string)$this->getRequest()->getParam('enablefreshflyers');
201
- $enablereviews = (string)$this->getRequest()->getParam('enablereviews');
202
- $fromchild = (string)$this->getRequest()->getParam('fromchild');
203
-
204
- $codflyerlinkimg = (string)$this->getRequest()->getParam('codflyerlinkimg');
205
- $codflyerlinkimgurl = (string)$this->getRequest()->getParam('codflyerlinkimgurl');
206
- $codflyerlinkimgalt = (string)$this->getRequest()->getParam('codflyerlinkimgalt');
207
-
208
- $codbeforename = (string)$this->getRequest()->getParam('codbeforename');
209
- $codaftername = (string)$this->getRequest()->getParam('codaftername');
210
-
211
- $codbeforeemailto = (string)$this->getRequest()->getParam('codbeforeemailto');
212
- $codafteremailto = (string)$this->getRequest()->getParam('codafteremailto');
213
-
214
- $codbeforeOR = (string)$this->getRequest()->getParam('codbeforeOR');
215
- $codafterOR = (string)$this->getRequest()->getParam('codafterOR');
216
-
217
- $codbeforeoverview = (string)$this->getRequest()->getParam('codbeforeoverview');
218
- $codafteroverview = (string)$this->getRequest()->getParam('codafteroverview');
219
-
220
- //ver 2.2.16
221
- $coddatafilelaunch = (string)$this->getRequest()->getParam('datafilelaunch');
222
- //for waitfor minute
223
-
224
- $waitforminute = (string)$this->getRequest()->getParam('waitforminute');
225
- $includeshortdescription = (string)$this->getRequest()->getParam('includeshortdescription');
226
-
227
- //Code for Tier pricing
228
- $codpublishtieredpricing=(string)$this->getRequest()->getParam('publishtieredpricing');
229
- $codquantity=(string)$this->getRequest()->getParam('codquantity');
230
- $codprice=(string)$this->getRequest()->getParam('codprice');
231
- $codsavings=(string)$this->getRequest()->getParam('codsavings');
232
-
233
-
234
- $codimodel = Mage::getSingleton('codi/codi');
235
-
236
- $codimodel->setStoreConfig(
237
- array(
238
- "codusername" => array ('value' => $userid) ,
239
- "codpassword" => array ('value' => $password) ,
240
- "secretkey" => array ('value' => $secretkey) ,
241
- "enablefreshflyers" => array ('value' => $enablefreshflyers) ,
242
- "codenablereviews" => array ('value' => $enablereviews) ,
243
- "fromchild" => array ('value' => $fromchild) ,
244
- "codflyerlinkimg" => array ('value' => $codflyerlinkimg) ,
245
- "codflyerlinkimgurl" => array ('value' => $codflyerlinkimgurl) ,
246
- "codflyerlinkimgalt" => array ('value' => $codflyerlinkimgalt) ,
247
- "codbeforename" => array ('value' => $codbeforename) ,
248
- "codaftername" => array ('value' => $codaftername) ,
249
- "codbeforeemailto" => array ('value' => $codbeforeemailto) ,
250
- "codafteremailto" => array ('value' => $codafteremailto) ,
251
- "codbeforeOR" => array ('value' => $codbeforeOR) ,
252
- "codafterOR" => array ('value' => $codafterOR) ,
253
- "codbeforeoverview" => array ('value' => $codbeforeoverview) ,
254
- "codafteroverview" => array ('value' => $codafteroverview) ,
255
- "coddatafilelaunch" => array ('value' => $coddatafilelaunch) ,
256
- "codwaitforminute" => array ('value' => $waitforminute),
257
- "codincludeshortdescription" => array ('value' => $includeshortdescription),
258
- "codpublishtieredpricing" => array ('value' => $codpublishtieredpricing),
259
- "codquantity" => array ('value' => $codquantity),
260
- "codprice" => array ('value' => $codprice),
261
- "codsavings" => array ('value' => $codsavings),
262
- )
263
- );
264
-
265
- Mage::app()->getCacheInstance()->cleanType('config');
266
-
267
- $this->_redirect('codi/adminhtml_menu/auth');
268
- }
269
-
270
- public function registerAction()
271
- {
272
- $codimodel = Mage::getSingleton('codi/codi');
273
- $codimodel->target = "register";
274
- $this->loadLayout();
275
- $this->_setActiveMenu('catalog');
276
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
277
- $this->renderLayout();
278
- }
279
-
280
- public function documentationAction()
281
- {
282
- $codimodel = Mage::getSingleton('codi/codi');
283
- $codimodel->target = "documentation";
284
- $this->loadLayout();
285
- $this->_setActiveMenu('catalog');
286
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
287
- $this->renderLayout();
288
- }
289
-
290
- //Change for version 2.2.15
291
- public function downloadtestAction(){
292
-
293
- $codimodel = Mage::getSingleton('codi/codi');
294
- $codimodel->target = "auth";
295
- $helper=Mage::helper('codi');
296
- $filename='CoDMagento.zip';
297
- //Change for zip code
298
- $helper->output_file('CoDzip/CoDMagento.zip',$filename , 'application/zip');
299
- $this->loadLayout();
300
- $this->_setActiveMenu('catalog');
301
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
302
- $this->renderLayout();
303
- }
304
- public function deletetestAction()
305
- {
306
- $dir = dirname(__FILE__);
307
-
308
- $_baseDirArray = explode("app", $dir);
309
- $basePath = $_baseDirArray[0].'/';
310
-
311
-
312
- $codimodel = Mage::getSingleton('codi/codi');
313
- $codimodel->target = "auth";
314
- $helper=Mage::helper('codi');
315
- //change for zip file
316
- $filename='/CoDzip/CoDMagento.zip';
317
- $helper->deleteFile($basePath,$filename);
318
- $this->loadLayout();
319
- $this->_setActiveMenu('catalog');
320
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
321
- $this->renderLayout();
322
- $this->_redirect('codi/adminhtml_menu/auth');
323
-
324
-
325
- }
326
-
327
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/controllers/DeleteController.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- require_once 'Mage/Core/Controller/Front/Action.php';
3
- class Mage_Codi_DeleteController extends Mage_Core_Controller_Front_Action
4
- {
5
-
6
- public function indexAction()
7
- {
8
- $this->_logFile = "Catalog-on-demand.log";
9
-
10
- Mage::log("Notice : Mage_Codi_DeleteController", null, $this->_logFile);
11
-
12
- $dir = dirname(__FILE__);
13
- $_baseDirArray = explode("app", $dir);
14
- $basePath = $_baseDirArray[0];
15
-
16
- //code for remove zip files
17
- $files = glob($basePath."CoDzip/*.zip");
18
- foreach($files as $file)
19
- {
20
- //changed for zip file
21
- if($file!=$basePath."CoDzip/CoDMagento.zip")
22
- unlink($file);
23
- }
24
-
25
- //remove text files
26
- $filesn = glob($basePath."CoDzip/CoDfiles/*.txt");
27
-
28
- foreach($filesn as $filen)
29
- {
30
- //if(($filen!=$basePath."CoDzip/CoDfiles/CoDMagento.txt")&&($filen!=$basePath."CoDzip/CoDfiles/CatalogProject.txt")&&($filen!=$basePath."CoDzip/CoDfiles/CatalogSection.txt"))
31
- unlink($filen);
32
-
33
- }
34
-
35
- Mage::log("Notice : DeleteindexAction End", null, $this->_logFile);
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/controllers/NsyncController.php DELETED
@@ -1,178 +0,0 @@
1
- <?php
2
- ini_set("max_execution_time", 3600);
3
- ini_set("memory_limit","1024M");
4
- require_once 'Mage/Core/Controller/Front/Action.php';
5
- class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
6
- {
7
- public $CodiBlock ;
8
-
9
- public function indexAction()
10
- {
11
- $this->_logFile = "Catalog-on-demand.log";
12
- //Code for progress
13
- $message='start';
14
- $finished=1;
15
- $created_time=time();
16
- $CodiModel = Mage::getModel('codi/codi');
17
-
18
- $var=$CodiModel->saveProgressData($message,$finished,$created_time);
19
- //echo $var;die();
20
-
21
-
22
- Mage::log("Notice: Mage_Codi_NSyncController", null, $this->_logFile);
23
-
24
- $error_msg = "";
25
-
26
-
27
- $dir = dirname(__FILE__);
28
- $_baseDirArray = explode("app", $dir);
29
- $basePath = $_baseDirArray[0].'/';
30
-
31
- //Create folder if not exist.
32
- if ( !is_dir($basePath.'CoDzip/CoDfiles/') )
33
- mkdir($basePath.'CoDzip/CoDfiles/');
34
-
35
- $DataFile = 'CoDMagento.txt';
36
- $CodiModel->new_run_codi_import($basePath);
37
-
38
-
39
- $error = "";
40
- $message = $CodiModel->getImportStatuses();
41
- $mes=implode(',',$message);
42
- $status = 0;
43
- if (isset($message) ){
44
- $status = $message['message'];
45
- if ( $status== "end" && $message['finished'] == 1 ){
46
- rename($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/'.$DataFile);
47
- $CodiModel->deleteTable();
48
- $CodiModel->addImportStatus('end', 1);
49
- print '{"success": "1"}';
50
- Mage::log("ERROR : Finished to create product file", null, $this->_logFile);
51
-
52
- }else if ( $status== "cancel" && $message['finished'] == 1 ) {
53
-
54
- $error = "ERROR\nCanceled to create product file";
55
- $CodiModel->deleteTable();
56
- Mage::log("ERROR : Canceled to create product file", null, $this->_logFile);
57
-
58
- }else if ( $status== "fileerror" && $message['finished'] == 1 ) {
59
-
60
- $error = "ERROR\nFailed to create product file";
61
- $CodiModel->deleteTable();
62
- Mage::log("ERROR : Failed to create product file", null, $this->_logFile);
63
-
64
- }else{
65
- $error = "ERROR\nFailed to create product file";
66
- $CodiModel->deleteTable();
67
- Mage::log("ERROR : Failed to create product file 1", null, $this->_logFile);
68
- }
69
- }else{
70
- $error = "ERROR\nFailed to create product file";
71
- $CodiModel->deleteTable();
72
- Mage::log("ERROR : Failed to create product file 2", null, $this->_logFile);
73
- }
74
- // Calling function to create Catalog Section
75
- $CodiModel->createCatalogSection();
76
- //Calling function to create Catalog Project
77
- $CodiModel->createCatalogProject('1');
78
-
79
- //Code for Update values after file download
80
- $message='start';
81
- $update=1;
82
- $finished=2;
83
- $created_time=time();
84
- $CodiModel->saveProgressData($message,$finished,$created_time,$update,$var);
85
- }
86
-
87
- // Below function is for the loader
88
-
89
- public function manualAction()
90
- {
91
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
92
- $products = Mage::getModel('catalog/product')->getCollection();
93
- $products->addAttributeToFilter('status', 1);//enabled
94
- $products->addAttributeToFilter('visibility', 4);//catalog, search
95
- $products->addAttributeToSelect('sku');
96
- $prodIds = $products->getAllIds();
97
-
98
- print Mage::helper('codi')->array2json($prodIds);
99
- }
100
- //create file
101
- public function updatestatusAction()
102
- {
103
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
104
- ini_set('memory_limit','1024M');
105
- set_time_limit(0);
106
- $this->_logFile = "Catalog-on-demand.log";
107
- Mage::log("Notice: Mage_Codi_NSyncController", null, $this->_logFile);
108
-
109
-
110
- $CodiModel = Mage::getModel('codi/codi');
111
- //product is id of the product
112
- $productid=$this->getRequest()->getParam('product');
113
- // counter is no. of product passed
114
- $counter=$this->getRequest()->getParam('counter');
115
- // Total product . counter and total is for calculating how many percent of data is transfered.
116
- $total=$this->getRequest()->getParam('total');
117
- //basepath
118
- $basepath=$this->getRequest()->getParam('basepath');
119
- $fh = fopen($basepath.'CoDzip/CoDfiles/temp.txt', 'a');
120
- try{
121
- // below condition is for the write all heading only first time after that it will not write.
122
- if($counter==1){
123
-
124
- fwrite($fh, "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo");
125
-
126
- }
127
-
128
- $product = Mage::getModel('catalog/product');
129
- $product->load($productid);
130
-
131
- Mage::log("Notice : Codi Import Products :".$productid, null, $this->_logFile);
132
- fwrite($fh, $CodiModel->ProducttoString($product, "product"));
133
- }catch(Exception $e)
134
- {
135
- echo "error";
136
- return;
137
- }
138
- fclose($fh);
139
- $progress=(string)(($counter/$total)*100);
140
- if($progress=='100'){
141
- $DataFile = 'CoDMagento.txt';
142
- rename($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/'.$DataFile);
143
- //die();
144
- }
145
- unset($product);
146
- echo floor($progress);
147
-
148
-
149
-
150
- }
151
- //Create Catalog section file
152
- public function createcatalogsectionAction()
153
- {
154
- ini_set('memory_limit','1024M');
155
- set_time_limit(0);
156
- //create object of Codi Model
157
- $CodiModel = Mage::getModel('codi/codi');
158
- // Calling function to create CatalogSection
159
- $progress=$CodiModel->createCatalogSection();
160
-
161
- echo $progress;
162
- }
163
-
164
- //Create Catalog section file
165
- public function createcatalogprojectAction()
166
- {
167
- ini_set('memory_limit','1024M');
168
- set_time_limit(0);
169
- //create object of Codi Model
170
- $CodiModel = Mage::getModel('codi/codi');
171
- // Calling function to create CatalogProject
172
- $progress=$CodiModel->createCatalogProject();
173
- echo $progress;
174
-
175
- }
176
-
177
-
178
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/controllers/SyncController.php DELETED
@@ -1,215 +0,0 @@
1
- <?php
2
- ini_set("max_execution_time", 3600);
3
- ini_set("memory_limit","512M");
4
- require_once 'Mage/Core/Controller/Front/Action.php';
5
- class Mage_Codi_SyncController extends Mage_Core_Controller_Front_Action
6
- {
7
- public function indexAction()
8
- {
9
- $this->_logFile = "Catalog-on-demand.log";
10
-
11
- Mage::log("Notice: Mage_Codi_SyncController", null, $this->_logFile);
12
-
13
- $error_msg = "";
14
- //Check validity of Secret Key
15
- if ( $this->getRequest()->getParam('SecretKey') != Mage::getStoreConfig('codi/codi/secretkey') )
16
- {
17
- Mage::log("ERROR : Secret Key Not accepted", null, $this->_logFile);
18
- $error_msg = "ERROR\nSecret Key Not accepted.";
19
- }
20
-
21
- $CodiModel = Mage::getModel('codi/codi');
22
-
23
- $dir = dirname(__FILE__);
24
- $_baseDirArray = explode("app", $dir);
25
- $basePath = $_baseDirArray[0];
26
-
27
- //Create folder if not exist. change for zip
28
- if ( !is_dir($basePath.'CoDzip/') )
29
- {
30
- mkdir($basePath.'CoDzip/');
31
- chmod($basePath.'CoDzip/',777);
32
- if ( !is_dir($basePath.'CoDzip/CoDfiles/') )
33
- {
34
- mkdir($basePath.'CoDzip/CoDfiles/');
35
- chmod($basePath.'CoDzip/CoDfiles/',777);
36
- }
37
- }
38
- /*
39
- if ( !is_dir($basePath.'CoDzip/') )
40
- mkdir($basePath.'CODdataFiles/');
41
- */
42
-
43
- if ( !$CodiModel->createFile($basePath) ){
44
- Mage::log("ERROR : Cannot create file : ".$basePath, null, $this->_logFile);
45
- $error_msg = "ERROR\nThe Magento extension was prevented from creating a file in the folder CoDzip/CoDfiles. The import has been cancelled. Please notify your Magento administrator.";
46
- }
47
- $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
48
- if ( $url == "http://" || $url == "https://" ){
49
-
50
- Mage::log("ERROR : Cannot prepare the callback link : ".$url, null, $this->_logFile);
51
- $error_msg = "ERROR\nCannot prepare the callback link.";
52
- }
53
- if ( $error_msg == "" )
54
- {
55
- $error_msg = "OK";
56
- //respond immediately
57
- $datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
58
- $wait='';
59
- if($datafilelaunch=='cod')
60
- {
61
-
62
- $waitforminute=Mage::getStoreConfig('codi/codi/codwaitforminute')/60;
63
- $wait="\r\nWaitFor=".number_format($waitforminute,2,'.','');
64
- }
65
- }
66
- @ob_end_clean();
67
- header("Connection: close\r\n");
68
- header("Content-Encoding: none\r\n");
69
- ignore_user_abort(true);
70
- ob_start();
71
- echo $error_msg.$wait;
72
- header("Content-Length: ".ob_get_length());
73
- ob_end_flush();
74
- flush();
75
- @ob_end_clean();
76
-
77
- Mage::log("Notice: Response ". $error_msg, null, $this->_logFile);
78
-
79
- if ( $error_msg != "OK" ){
80
- exit(0);
81
- }
82
-
83
- //Code for progress
84
- $message='start';
85
- $finished=1;
86
- $created_time=time();
87
- $CodiModel = Mage::getModel('codi/codi');
88
-
89
- $var=$CodiModel->saveProgressData($message,$finished,$created_time);
90
-
91
- $DataFile = (string)$this->getRequest()->getParam('FileName');
92
- $filename = $basePath.'CoDzip/CoDfiles/CoDMagento.txt';
93
- //Check code for file is exists or not
94
- $fExist=0;
95
- $modifie='';
96
- if (file_exists($filename)) {
97
- $fExist=1;
98
- $modifie=date("M d, Y H:i:s.", filemtime($filename));
99
- copy($filename, $basePath.'CoDzip/CoDfiles/'.$DataFile.'.txt');
100
- }
101
-
102
-
103
- Mage::log("Notice: Response ". $DataFile, null, $this->_logFile);
104
- $datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
105
-
106
- if((($datafilelaunch=="magento") || ($datafilelaunch=="manual") ) && ($fExist==1))
107
- {
108
- Mage::helper('codi/createzip')->createimportzip($DataFile);
109
- Mage::log("Notice: Import Products using Magento Cron job: ".$datafilelaunch, null, $this->_logFile);
110
-
111
- }
112
- else
113
- {
114
- Mage::log("Notice: Import Products using Catalog on demand: ".$datafilelaunch, null, $this->_logFile);
115
- $CodiModel->run_codi_import($basePath);
116
- $error = "";
117
- $message = $CodiModel->getImportStatuses();
118
-
119
- $status = 0;
120
- if ( isset($message) ){
121
- $status = $message['message'];
122
-
123
- if ( $status== "end" && $message['finished'] == 1 ){
124
- $modifie=date("M d, Y H:i:s.", filemtime($basePath.'CoDzip/CoDfiles/temp.txt'));
125
-
126
- // Calling function to create Catalog Section
127
- $progress=$CodiModel->createCatalogSection();
128
- $progress=$CodiModel->createCatalogProject(1);
129
- copy($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/CoDMagento.txt');
130
- rename($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/'.$DataFile.'.txt');
131
- Mage::helper('codi/createzip')->createimportzip($DataFile);
132
- $CodiModel->deleteTable();
133
-
134
- Mage::log("ERROR : Finished to create product file", null, $this->_logFile);
135
-
136
- }else if ( $status== "cancel" && $message['finished'] == 1 ) {
137
-
138
- $error = "ERROR\nCanceled to create product file";
139
- $CodiModel->deleteTable();
140
- Mage::log("ERROR : Canceled to create product file", null, $this->_logFile);
141
-
142
- }else if ( $status== "fileerror" && $message['finished'] == 1 ) {
143
-
144
- $error = "ERROR\nFailed to create product file";
145
- $CodiModel->deleteTable();
146
- Mage::log("ERROR : Failed to create product file", null, $this->_logFile);
147
-
148
- }else{
149
- $error = "ERROR\nFailed to create product file";
150
- $CodiModel->deleteTable();
151
- Mage::log("ERROR : Failed to create product file 1", null, $this->_logFile);
152
- }
153
- }else{
154
- $error = "ERROR\nFailed to create product file";
155
- $CodiModel->deleteTable();
156
- Mage::log("ERROR : Failed to create product file 2", null, $this->_logFile);
157
- }
158
- }
159
- //Prepare the callback parameters
160
-
161
- $pos = strpos($url, 'index.php');
162
- $DataFileLink = substr($url, 0, $pos ) . 'CoDzip/' . $DataFile.'.zip';
163
-
164
- Mage::log("Notice: Prepare the callback parameters link: ". $DataFileLink, null, $this->_logFile);
165
-
166
- $ProcessID = (string)$this->getRequest()->getParam('ProcessID');
167
- $url = (string)$this->getRequest()->getParam('CallbackURL');
168
- $DeleteDataFileURL = (string)Mage::getUrl('codi/delete') ;
169
-
170
- $Comment = $CodiModel->getComment($modifie);
171
- Mage::log("Notice: Prepare the Comment : ". $Comment, null, $this->_logFile);
172
- //code for getTheme
173
- $helper=Mage::helper('codi');
174
- $TemplateName=(string)$helper->getTheme();
175
-
176
-
177
- $paramsarray = array( 'ProcessID' => $ProcessID,
178
- 'TemplateName' => $TemplateName,
179
- 'DataFileLink' => $DataFileLink ,
180
- 'DeleteDataFileURL' => $DeleteDataFileURL ,
181
- 'Encoding' => 'utf-8' ,
182
- 'ClearDatabase' => 'MissingOnly' ,
183
- 'PartnerID' => 'CoDMagento' ,
184
- 'CatalogProject' => 'magento',
185
- 'Comment' => $Comment);
186
- if ( $error != "" ) {
187
- $paramsarray = array('ProcessID' => $ProcessID,
188
- 'TemplateName' => $TemplateName,
189
- 'DataFileLink' => $DataFileLink ,
190
- 'DeleteDataFileURL' => $DeleteDataFileURL ,
191
- 'Encoding' => 'utf-8' ,
192
- 'ClearDatabase' => 'MissingOnly' ,
193
- 'PartnerID' => 'CoDMagento' ,
194
- 'CatalogProject' => 'magento',
195
- 'Comment' => $Comment,
196
- 'Error' => $error);
197
- }
198
-
199
- Mage::log("Notice: Prepare the DataFileLink : ". $DataFileLink, null, $this->_logFile);
200
- Mage::log("Notice: Prepare the process ID : ". $ProcessID, null, $this->_logFile);
201
- Mage::log("Notice: Prepare the delete url : ". $DeleteDataFileURL, null, $this->_logFile);
202
- Mage::log("Notice: Prepare the callback url : ". $url, null, $this->_logFile);
203
- Mage::log("Notice: Prepare the template theme : ". $TemplateName, null, $this->_logFile);
204
- $Responsemsg = $CodiModel->Call( $url, $paramsarray );
205
-
206
- //Code for Update values after file download
207
- $message='start';
208
- $update=1;
209
- $finished=2;
210
- $created_time=time();
211
- $CodiModel->saveProgressData($message,$finished,$created_time,$update,$var);
212
-
213
- Mage::log("Notice: Prepare the callback response message ". $Responsemsg, null, $this->_logFile);
214
- }
215
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/etc/config.xml DELETED
@@ -1,146 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Mage_Codi>
5
- <version>3.0.9</version>
6
- </Mage_Codi>
7
- </modules>
8
- <adminhtml>
9
- <menu>
10
- <catalog translate="title" module="catalog">
11
- <title>Catalog</title>
12
- <depends>
13
- <module>Mage_Catalog</module>
14
- </depends>
15
- <children>
16
- <codi translate="title" module="catalog">
17
- <sort_order>-1</sort_order>
18
- <title>Catalog-On-Demand</title>
19
- <action>codi/adminhtml_menu/</action>
20
- </codi>
21
- </children>
22
- </catalog>
23
- </menu>
24
- </adminhtml>
25
- <global> <resources> <codi_setup> <setup> <module>Mage_Codi</module> </setup> <connection> <use>core_setup</use> </connection> </codi_setup> </resources>
26
- <!--
27
- <fieldsets>
28
- <customer_account>
29
- <codinternaluser><create>1</create><update>1</update></codinternaluser>
30
- </customer_account>
31
- </fieldsets>
32
- -->
33
-
34
- <!--
35
- <blocks>
36
- <adminhtml>
37
- <rewrite>
38
- <widget_grid>Mage_Codi_Block_Widget_Grid</widget_grid>
39
- </rewrite>
40
- </adminhtml>
41
- </blocks>
42
- <blocks>
43
- <adminhtml>
44
- <rewrite>
45
- <widget_grid_massaction>Mage_Codi_Block_Widget_Grid_Massaction</widget_grid_massaction>
46
- </rewrite>
47
- </adminhtml>
48
- </blocks>
49
- <blocks>
50
- <adminhtml>
51
- <rewrite>
52
- <catalog_product_grid>Mage_Codi_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
53
- </rewrite>
54
- </adminhtml>
55
- </blocks>
56
- <blocks>
57
- <adminhtml>
58
- <rewrite>
59
- <catalog_product>Mage_Codi_Block_Adminhtml_Catalog_Product</catalog_product>
60
- </rewrite>
61
- </adminhtml>
62
- </blocks>
63
- -->
64
- <!-- V2 Start-->
65
- <models>
66
- <codi>
67
- <class>Mage_Codi_Model</class>
68
- </codi>
69
- </models>
70
- <blocks>
71
- <codi>
72
- <class>Mage_Codi_Block</class>
73
- </codi>
74
- </blocks>
75
- <!--
76
- <events>
77
- <adminhtml_controller_action_predispatch_start>
78
- <observers>
79
- <mage_codi_codi>
80
- <type>singleton</type>
81
- <class>mage_codi_model_codi</class>
82
- <method>adminstart</method>
83
- </mage_codi_codi>
84
- </observers>
85
- </adminhtml_controller_action_predispatch_start>
86
- </events>
87
- <rewrite>
88
- <codi_index_update>
89
- <from><![CDATA[#^/wishlist/index/update/#]]></from>
90
- <to>codi/index/update</to>
91
- </codi_index_update>
92
-
93
- <codi_index_index>
94
- <from><![CDATA[#^/wishlist/$#]]></from>
95
- <to>codi/codifront/index</to>
96
- </codi_index_index>
97
-
98
- <codi_codifront_index1>
99
- <from><![CDATA[#^/wishlist/codifront#]]></from>
100
- <to>codi/codifront/index</to>
101
- </codi_codifront_index1>
102
- </rewrite>
103
- -->
104
- </global>
105
- <frontend>
106
- <routers>
107
- <codi>
108
- <use>standard</use>
109
- <args>
110
- <module>Mage_Codi</module>
111
- <frontName>codi</frontName>
112
- </args>
113
- </codi>
114
- </routers>
115
- <!--
116
- <layout>
117
- <updates>
118
- <codi>
119
- <file>codi.xml</file>
120
- </codi>
121
- </updates>
122
- </layout>
123
- -->
124
- </frontend>
125
- <admin>
126
- <routers>
127
- <codi>
128
- <use>admin</use>
129
- <args>
130
- <module>Mage_Codi</module>
131
- <frontName>codi</frontName>
132
- </args>
133
- </codi>
134
- </routers>
135
- </admin>
136
- <!--<adminhtml>
137
- <layout>
138
- <updates>
139
- <codi>
140
- <file>codi.xml</file>
141
- </codi>
142
- </updates>
143
- </layout>
144
- </adminhtml> -->
145
- <!-- V2 End-->
146
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/sql/codi_setup/mysql4-install-3.0.4.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- $installer->run("
8
-
9
- DROP TABLE IF EXISTS {$this->getTable('codi_progress_status')};
10
- CREATE TABLE {$this->getTable('codi_progress_status')} (
11
- `id` int(11) unsigned NOT NULL auto_increment,
12
- `message` varchar(50) NOT NULL default '',
13
- `finished` smallint(1) NOT NULL default '0',
14
- `created_time` varchar(50) NULL,
15
- PRIMARY KEY (`id`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
- ");
18
-
19
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/sql/codi_setup/mysql4-install-3.0.6.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- $installer->run("
8
-
9
- DROP TABLE IF EXISTS {$this->getTable('codi_progress_status')};
10
- CREATE TABLE {$this->getTable('codi_progress_status')} (
11
- `id` int(11) unsigned NOT NULL auto_increment,
12
- `message` varchar(50) NOT NULL default '',
13
- `finished` smallint(1) NOT NULL default '0',
14
- `created_time` varchar(50) NULL,
15
- PRIMARY KEY (`id`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
- ");
18
-
19
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/CodiScript/Helper/Data.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_CodiScript_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ public function getCodiPassword()
5
+ {
6
+ if($password = Mage::getStoreConfig('codiscript/config/password')){
7
+ return $password;
8
+ }
9
+ return '';
10
+ }
11
+ }
app/code/community/Mage/CodiScript/Model/Files.php ADDED
@@ -0,0 +1,759 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
3
+ public $version = VERSION;
4
+ public $Store;
5
+ public $StoreId;
6
+ public $reviewsModel;
7
+ public $productTypeGroupedModel;
8
+ public $productTypeConfigurableModel;
9
+ public $enablereviews = FALSE;
10
+ public $ignoretopcategory = FALSE;
11
+ public $includeshortdescription = FALSE;
12
+ public $getpricefromfromchild = FALSE;
13
+ public $publishtieredpricing = FALSE;
14
+ public $includetaxes = FALSE;
15
+ public $ignoreexcludedimages = FALSE;
16
+ public $address = FALSE;
17
+ public $quantitylabel;
18
+ public $pricelabel;
19
+ public $savingslabel;
20
+ public $mediaurl;
21
+ public $prodmediaurl;
22
+ public $taxhelper;
23
+ public $unCatPosition;
24
+ public $catpathmap;
25
+ public $catmap;
26
+ public $_DEBUG;
27
+ const TAG_P_CLOSE = '</p>';
28
+ const TAG_P = '<p>';
29
+ const SCRIPTNAME = 'cod_exporter_for_magento.php';
30
+ public function _construct() {
31
+ parent::_construct();
32
+ $this->_init('codi/codi2');
33
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
34
+ }
35
+ // Class=DataFile
36
+ public function renderDataFile(){
37
+ if($this->_DEBUG){
38
+ echo "memory_get_usage real: ".memory_get_usage(TRUE)." allocated: ".memory_get_usage()."
39
+ ";
40
+ foreach ( Mage::app()->getStores() as $store ) echo "store: ".$store->getId()." code=".$store->getCode()." isActive=".$store->getIsActive()."
41
+ ";
42
+ }
43
+ $this->productTypeConfigurableModel = Mage::getModel('catalog/product_type_configurable');
44
+ $this->productTypeGroupedModel = Mage::getModel('catalog/product_type_grouped');
45
+ $this->reviewsModel = Mage::getModel('review/review');
46
+ $this->mediaurl = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_MEDIA );
47
+ $this->prodmediaurl = $this->mediaurl."catalog/product";
48
+ $products = Mage::getModel('catalog/product')->getCollection();
49
+ $products->addAttributeToFilter('status', 1);//enabled
50
+ $products->addAttributeToFilter('visibility', 4);//catalog, search
51
+ $prodIds = $this->_DEBUG ? $products->getAllIds(1000,0) : $products->getAllIds();
52
+ if($this->_DEBUG) echo "StoreId: ".$this->StoreId."
53
+ Products: ".count($prodIds)."
54
+ Media URL: ".$this->mediaurl."
55
+ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
56
+ ";
57
+ echo "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tManufacturer\tCategory\tReviews\tSupplementalInfo
58
+ ";
59
+ $count = 0;
60
+ foreach( $prodIds as $productId ){
61
+ $product = Mage::getModel('catalog/product')->setStoreId( $this->StoreId )->load( $productId );
62
+ $count++;
63
+ if( $product->isConfigurable() )
64
+ echo $this->ProducttoStringConfigurable( $product );
65
+ else if( $product->isGrouped() )
66
+ echo $this->ProducttoStringGrouped( $product );
67
+ else
68
+ echo $this->ProducttoStringSimple( $product );
69
+ unset( $product );
70
+ if($this->_DEBUG) echo "#".$count.": memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
71
+ ";
72
+ }
73
+ echo "==EOF==";
74
+ }
75
+ public function ProducttoStringGrouped( &$product ){
76
+ $ProducttoString = "";
77
+ $AssociatedProductIds = $this->productTypeGroupedModel->getAssociatedProductIds( $product );
78
+ $ProductDescription = "";
79
+ $shortDescription = $product->getShortDescription();
80
+ if( !empty( $shortDescription ) ){
81
+ $shortDescription = $this->cleanStr( $shortDescription );
82
+ if( strpos( $shortDescription, self::TAG_P ) !== false ){
83
+ $new = strlen( $shortDescription );
84
+ $pos = strrpos( $shortDescription, self::TAG_P_CLOSE ) + 4;
85
+ if( $new != $pos )
86
+ $shortDescription = substr( $shortDescription, 0, $pos ).self::TAG_P.substr( $shortDescription, $pos ).self::TAG_P_CLOSE;
87
+ } else
88
+ $shortDescription = self::TAG_P.$shortDescription .self::TAG_P_CLOSE;
89
+ }
90
+ if( $this->includeshortdescription && !empty( $shortDescription ) )
91
+ $ProductDescription = $shortDescription;
92
+ $longDescription = $product->getDescription();
93
+ if( !empty( $longDescription ) ){
94
+ $longDescription = $this->cleanStr( $longDescription );
95
+ if( strpos( $longDescription, self::TAG_P ) !== false ){
96
+ $new = strlen( $longDescription );
97
+ $pos = strrpos( $longDescription, self::TAG_P_CLOSE ) + 4;
98
+ if( $new != $pos )
99
+ $longDescription = substr( $longDescription, 0, $pos ).self::TAG_P.substr( $longDescription, $pos ).self::TAG_P_CLOSE;
100
+ } else
101
+ $longDescription = self::TAG_P.$longDescription.self::TAG_P_CLOSE;
102
+ $ProductDescription .= $longDescription;
103
+ }
104
+ $attributes = $product->getAttributes();
105
+ $Manufacturer = "";
106
+ $ProductAttributes = "";
107
+ foreach ($attributes as $attribute) {
108
+ if( $attribute->getAttributeCode()=="manufacturer" ){
109
+ $Manufacturer = $attribute->getFrontend()->getValue( $product );
110
+ if( $Manufacturer == NULL || $Manufacturer == "No" || $Manufacturer == "Other" )
111
+ $Manufacturer = "";
112
+ continue;
113
+ }
114
+ if( $attribute->getIsVisibleOnFront() ){
115
+ $value = $attribute->getFrontend()->getValue( $product );
116
+ if( is_string( $value ) && strlen( $value ) ){
117
+ if( !empty( $ProductAttributes ) )
118
+ $ProductAttributes .= "|";
119
+ $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
120
+ }
121
+ }
122
+ }
123
+ if($this->publishtieredpricing == "1"){
124
+ $TierPriceAttributes = $this->getTierPrices( $product );
125
+ $sp = ( empty( $ProductAttributes ) || empty( $TierPriceAttributes ) ) ? "" : "|";
126
+ $ProductAttributes .= $sp.$TierPriceAttributes;
127
+ }
128
+ if( !empty( $ProductAttributes ) )
129
+ $ProductAttributes = $this->cleanStr( $ProductAttributes );
130
+
131
+ if($this->_DEBUG) echo "product image : ".$product->getImage()."
132
+ product small image: ".$product->getSmallImage()."
133
+ product thumbnail : ".$product->getThumbnail()."
134
+ ";
135
+ $prodImages = array();
136
+ $prodImageArray = $product->getMediaGallery('images');
137
+ if( is_array($prodImageArray) ){
138
+ foreach( $prodImageArray as $image ){
139
+ if($this->_DEBUG) echo "gallery image ".$image['file']." disabled=".$image['disabled']."
140
+ ";
141
+ if( $this->ignoreexcludedimages && $image['disabled'] )
142
+ continue;
143
+ $prodImages[] = "Print#=#".$this->prodmediaurl.$image['file'];
144
+ }
145
+ }
146
+ $prodImages = implode( "#|#", $prodImages );
147
+
148
+ $ProductURL = $product->getProductUrl();
149
+ if( !empty( $ProductURL ) )
150
+ $ProductURL = $this->correctProdUrlStr( $ProductURL );
151
+ $productName = $product->getId().'#$#'.$this->cleanStr( $product->getName() );
152
+ $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '';
153
+ if( !empty( $Reviews ) )
154
+ $Reviews = $this->cleanStr( $Reviews );
155
+ foreach($AssociatedProductIds as $UsedProductid){
156
+ $UsedProduct = Mage::getModel('catalog/product')->load( $UsedProductid );
157
+ $ItemName= $UsedProduct->getName();
158
+ if( $this->getpricefromfromchild )
159
+ $Price = $this->includetaxes ?
160
+ $this->taxhelper->getPrice($UsedProduct,$UsedProduct->getFinalPrice(),true) :
161
+ $UsedProduct->getFinalPrice();
162
+ else
163
+ $Price = $this->includetaxes ?
164
+ $this->taxhelper->getPrice($product,$product->getFinalPrice(),true) :
165
+ $product->getFinalPrice();
166
+
167
+ if($this->_DEBUG) echo "item image : ".$UsedProduct->getImage()."
168
+ item small image: ".$UsedProduct->getSmallImage()."
169
+ item thumbnail : ".$UsedProduct->getThumbnail()."
170
+ ";
171
+ $itemImages = array();
172
+ $itemImageArray = $UsedProduct->getMediaGallery('images');
173
+ if( is_array($itemImageArray) ){
174
+ foreach( $itemImageArray as $image ){
175
+ if($this->_DEBUG) echo "gallery image ".$image['file']." disabled=".$image['disabled']."
176
+ ";
177
+ if( $this->ignoreexcludedimages && $image['disabled'] )
178
+ continue;
179
+ $itemImages[] = "Print#=#".$this->prodmediaurl.$image['file'];
180
+ }
181
+ }
182
+ $itemImages = implode( "#|#", $itemImages );
183
+
184
+ $attributes = $UsedProduct->getAttributes();
185
+ $ItemAttributes = "";
186
+ foreach ($attributes as $attribute) {
187
+ if($attribute->getAttributeCode()=="manufacturer"){
188
+ if( empty( $Manufacturer ) )
189
+ $Manufacturer = $attribute->getFrontend()->getValue( $product );
190
+ if( $Manufacturer == "No" || $Manufacturer == "Other" )
191
+ $Manufacturer = "";
192
+ continue;
193
+ }
194
+ if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )){
195
+ $value = $attribute->getFrontend()->getValue( $UsedProduct );
196
+ if( is_string( $value ) && strlen( $value ) )
197
+ $ItemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|";
198
+ }
199
+ }
200
+ $ItemAttributes = substr($ItemAttributes, 0, strlen($ItemAttributes)-1 );
201
+ $Price = $this->improvePrice( $Price );
202
+ $ProducttoString .= $this->cleanStr( $UsedProduct->getSku() ) //ItemID
203
+ . "\t" //ItemQty
204
+ . "\t" //ItemUom
205
+ . "\t". $Price //ItemPrice
206
+ . "\t". $this->cleanStr( $ItemName) //ItemDescription
207
+ . "\t" //ItemLink
208
+ . "\t". $this->cleanStr( $ItemAttributes ) //ItemAttributes
209
+ . "\t". $itemImages //ItemGraphic
210
+ . "\t". $productName //ProductName
211
+ . "\t". $ProductDescription
212
+ . "\t". $prodImages //ProductGraphic
213
+ . "\t". $ProductURL //ProductLink
214
+ . "\t". $ProductAttributes //ProductAttributes
215
+ . "\t". $Manufacturer //Manufacturer
216
+ . "\t" //Category
217
+ . "\t". $Reviews //Reviews
218
+ . "\t". $shortDescription
219
+ . "\n";
220
+ unset( $UsedProduct );
221
+ }
222
+ unset( $AssociatedProductIds );
223
+ return $ProducttoString;
224
+ }
225
+ public function ProducttoStringConfigurable( &$product ){
226
+ $ProducttoString = "";
227
+ $UsedProductIds = $this->productTypeConfigurableModel->getUsedProductIds($product);
228
+ $ProductDescription = "";
229
+ $shortDescription = $product->getShortDescription();
230
+ if( !empty( $shortDescription ) ){
231
+ $shortDescription = $this->cleanStr( $shortDescription );
232
+ if( strpos( $shortDescription, self::TAG_P ) !== false ){
233
+ $new = strlen( $shortDescription );
234
+ $pos = strrpos( $shortDescription, self::TAG_P_CLOSE ) + 4;
235
+ if( $new != $pos )
236
+ $shortDescription = substr( $shortDescription, 0, $pos ).self::TAG_P.substr( $shortDescription, $pos ).self::TAG_P_CLOSE;
237
+ } else
238
+ $shortDescription = self::TAG_P.$shortDescription .self::TAG_P_CLOSE;
239
+ }
240
+ if( $this->includeshortdescription && !empty( $shortDescription ) )
241
+ $ProductDescription = $shortDescription;
242
+ $longDescription = $product->getDescription();
243
+ if( !empty( $longDescription ) ){
244
+ $longDescription = $this->cleanStr( $longDescription );
245
+ if( strpos( $longDescription, self::TAG_P ) !== false ){
246
+ $new = strlen( $longDescription );
247
+ $pos = strrpos( $longDescription, self::TAG_P_CLOSE ) + 4;
248
+ if( $new != $pos )
249
+ $longDescription = substr( $longDescription, 0, $pos ).self::TAG_P.substr( $longDescription, $pos ).self::TAG_P_CLOSE;
250
+ } else
251
+ $longDescription = self::TAG_P.$longDescription.self::TAG_P_CLOSE;
252
+ $ProductDescription .= $longDescription;
253
+ }
254
+ $attributes = $product->getAttributes();
255
+ $Manufacturer = "";
256
+ $ProductAttributes = "";
257
+ foreach ($attributes as $attribute) {
258
+ if( $attribute->getAttributeCode()=="manufacturer" ){
259
+ $Manufacturer = $attribute->getFrontend()->getValue( $product );
260
+ if( $Manufacturer == NULL || $Manufacturer == "No" || $Manufacturer == "Other" )
261
+ $Manufacturer = "";
262
+ continue;
263
+ }
264
+ if ($attribute->getIsVisibleOnFront() ) {
265
+ $value = $attribute->getFrontend()->getValue($product);
266
+ if( is_string($value) && strlen( $value ) ){
267
+ if( !empty( $ProductAttributes ) )
268
+ $ProductAttributes .= "|";
269
+ $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
270
+ }
271
+ }
272
+ }
273
+ if($this->publishtieredpricing == "1"){
274
+ $TierPriceAttributes = $this->getTierPrices($product);
275
+ $sp = ( empty( $ProductAttributes ) || empty( $TierPriceAttributes ) ) ? "" : "|";
276
+ $ProductAttributes.= $sp.$TierPriceAttributes;
277
+ }
278
+ if( !empty( $ProductAttributes ) )
279
+ $ProductAttributes = $this->cleanStr( $ProductAttributes );
280
+
281
+ if($this->_DEBUG) echo "product image : ".$product->getImage()."
282
+ product small image: ".$product->getSmallImage()."
283
+ product thumbnail : ".$product->getThumbnail()."
284
+ ";
285
+ $prodImages = array();
286
+ $prodImageArray = $product->getMediaGallery('images');
287
+ if( is_array($prodImageArray) ){
288
+ foreach( $prodImageArray as $image ){
289
+ if($this->_DEBUG) echo "gallery image ".$image['file']." disabled=".$image['disabled']."
290
+ ";
291
+ if( $this->ignoreexcludedimages && $image['disabled'] )
292
+ continue;
293
+ $prodImages[] = "Print#=#".$this->prodmediaurl.$image['file'];
294
+ }
295
+ }
296
+ $prodImages = implode( "#|#", $prodImages );
297
+
298
+ $ProductURL = $product->getProductUrl();
299
+ if( !empty( $ProductURL ) )
300
+ $ProductURL = $this->correctProdUrlStr( $ProductURL );
301
+ $productName = $product->getId().'#$#'.$this->cleanStr( $product->getName() );
302
+ $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '';
303
+ if( !empty( $Reviews ) )
304
+ $Reviews = $this->cleanStr( $Reviews );
305
+ foreach($UsedProductIds as $UsedProductid){
306
+ $UsedProduct = Mage::getModel('catalog/product')->load( $UsedProductid );
307
+ if( $this->getpricefromfromchild )
308
+ $Price = $this->includetaxes ?
309
+ $this->taxhelper->getPrice($UsedProduct,$UsedProduct->getFinalPrice(),true) :
310
+ $UsedProduct->getFinalPrice();
311
+ else
312
+ $Price = $this->includetaxes ?
313
+ $this->taxhelper->getPrice($product,$product->getFinalPrice(),true) :
314
+ $product->getFinalPrice();
315
+ $attributes = $UsedProduct->getAttributes();
316
+ $ItemAttributes = "";
317
+ $AllowAttributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
318
+ foreach ($AllowAttributes as $attribute){
319
+ $AttributeCode = $attribute->getProductAttribute()->getAttributeCode();
320
+ $AttributeLabel = $attribute->getProductAttribute()->getFrontend()->getLabel();
321
+ $AttribId = $UsedProduct->getData($AttributeCode);
322
+ $AttributeValue = "";
323
+ foreach ( $attribute->getProductAttribute()->getSource()->getAllOptions() as $option ){
324
+ if( $option['value'] == $AttribId ){
325
+ $AttributeValue = $option['label'];
326
+ break;
327
+ }
328
+ }
329
+ if( !empty( $ItemAttributes ) )
330
+ $ItemAttributes .= "|";
331
+ $ItemAttributes .= $AttributeLabel."=".$AttributeValue;
332
+ foreach( $attribute->getPrices() as $addedPrice ){
333
+ if( $AttributeValue == $addedPrice['label']){
334
+ if( $addedPrice['is_percent'] )
335
+ $Price += $Price * $addedPrice['pricing_value'] / 100;
336
+ else
337
+ $Price += $addedPrice['pricing_value'];
338
+ $Price = $this->includetaxes ?
339
+ $this->taxhelper->getPrice($product,$Price,true) :
340
+ $Price;
341
+ }
342
+ }
343
+ }
344
+ $Price = $this->improvePrice( $Price );
345
+
346
+ if($this->_DEBUG) echo "item image : ".$UsedProduct->getImage()."
347
+ item small image: ".$UsedProduct->getSmallImage()."
348
+ item thumbnail : ".$UsedProduct->getThumbnail()."
349
+ ";
350
+ $itemImages = array();
351
+ $itemImageArray = $UsedProduct->getMediaGallery('images');
352
+ if( is_array($itemImageArray) ){
353
+ foreach( $itemImageArray as $image ){
354
+ if($this->_DEBUG) echo "gallery image ".$image['file']." disabled=".$image['disabled']."
355
+ ";
356
+ if( $this->ignoreexcludedimages && $image['disabled'] )
357
+ continue;
358
+ $itemImages[] = "Print#=#".$this->prodmediaurl.$image['file'];
359
+ }
360
+ }
361
+ $itemImages = implode( "#|#", $itemImages );
362
+
363
+ $ProducttoString .= $this->cleanStr( $UsedProduct->getSku() ) //ItemID
364
+ . "\t" //ItemQty
365
+ . "\t" //ItemUom
366
+ . "\t" . $Price //ItemPrice
367
+ . "\t" //ItemDescription
368
+ . "\t" //ItemLink
369
+ . "\t" . $this->cleanStr( $ItemAttributes ) //ItemAttributes
370
+ . "\t" . $itemImages //ItemitemGraphic
371
+ . "\t" . $productName //ProductName
372
+ . "\t" . $ProductDescription
373
+ . "\t" . $prodImages //ProductGraphic
374
+ . "\t" . $ProductURL //ProductLink
375
+ . "\t" . $ProductAttributes //ProductAttributes
376
+ . "\t" . $Manufacturer //Manufacturer
377
+ . "\t" //Category
378
+ . "\t" . $Reviews //Reviews
379
+ . "\t" . $shortDescription
380
+ . "\n";
381
+ unset( $UsedProduct );
382
+ }
383
+ unset( $UsedProductIds );
384
+ return $ProducttoString;
385
+ }
386
+ public function ProducttoStringSimple( &$product ){
387
+ $ProductDescription = "";
388
+ $shortDescription = $product->getShortDescription();
389
+ if( !empty( $shortDescription ) ){
390
+ $shortDescription = $this->cleanStr( $shortDescription );
391
+ if( strpos( $shortDescription, self::TAG_P ) !== false ){
392
+ $new = strlen( $shortDescription );
393
+ $pos = strrpos( $shortDescription, self::TAG_P_CLOSE ) + 4;
394
+ if( $new != $pos )
395
+ $shortDescription = substr( $shortDescription, 0, $pos ).self::TAG_P.substr( $shortDescription, $pos ).self::TAG_P_CLOSE;
396
+ } else
397
+ $shortDescription = self::TAG_P.$shortDescription .self::TAG_P_CLOSE;
398
+ }
399
+ if( $this->includeshortdescription && !empty( $shortDescription ) )
400
+ $ProductDescription = $shortDescription;
401
+ $longDescription = $product->getDescription();
402
+ if( !empty( $longDescription ) ){
403
+ $longDescription = $this->cleanStr( $longDescription );
404
+ if( strpos( $longDescription, self::TAG_P ) !== false ){
405
+ $new = strlen( $longDescription );
406
+ $pos = strrpos( $longDescription, self::TAG_P_CLOSE ) + 4;
407
+ if( $new != $pos )
408
+ $longDescription = substr( $longDescription, 0, $pos ).self::TAG_P.substr( $longDescription, $pos ).self::TAG_P_CLOSE;
409
+ } else
410
+ $longDescription = self::TAG_P.$longDescription.self::TAG_P_CLOSE;
411
+ $ProductDescription .= $longDescription;
412
+ }
413
+
414
+ if($this->_DEBUG) echo "product image : ".$product->getImage()."
415
+ product small image: ".$product->getSmallImage()."
416
+ product thumbnail : ".$product->getThumbnail()."
417
+ ";
418
+ $prodImages = array();
419
+ $prodImageArray = $product->getMediaGallery('images');
420
+ if( is_array($prodImageArray) ){
421
+ foreach( $prodImageArray as $image ){
422
+ if($this->_DEBUG) echo "gallery image ".$image['file']." disabled=".$image['disabled']."
423
+ ";
424
+ if( $this->ignoreexcludedimages && $image['disabled'] )
425
+ continue;
426
+ $prodImages[] = "Print#=#".$this->prodmediaurl.$image['file'];
427
+ }
428
+ }
429
+ $prodImages = implode( "#|#", $prodImages );
430
+
431
+ $URL = $product->getProductUrl();
432
+ if( !empty( $URL ) )
433
+ $URL = $this->correctProdUrlStr( $URL );
434
+ $attributes = $product->getAttributes();
435
+ $Manufacturer = "";
436
+ $ProductAttributes = "";
437
+ foreach ($attributes as $attribute) {
438
+ if( $attribute->getAttributeCode()=="manufacturer" ){
439
+ $Manufacturer = $attribute->getFrontend()->getValue( $product );
440
+ if( $Manufacturer == NULL || $Manufacturer == "No" || $Manufacturer == "Other" )
441
+ $Manufacturer = "";
442
+ continue;
443
+ }
444
+ if ($attribute->getIsVisibleOnFront() ){
445
+ $value = $attribute->getFrontend()->getValue( $product );
446
+ if( is_string($value) && strlen( $value ) ){
447
+ if( !empty( $ProductAttributes ) )
448
+ $ProductAttributes .= "|";
449
+ $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
450
+ }
451
+ }
452
+ }
453
+ if($this->publishtieredpricing == "1"){
454
+ $TierPriceAttributes = $this->getTierPrices( $product );
455
+ $sp = ( empty( $ProductAttributes ) || empty( $TierPriceAttributes ) ) ? "" : "|";
456
+ $ProductAttributes.= $sp.$TierPriceAttributes;
457
+ }
458
+ if( !empty( $ProductAttributes ) )
459
+ $ProductAttributes = $this->cleanStr( $ProductAttributes );
460
+ $prodFinalPrice = $this->includetaxes ?
461
+ $this->taxhelper->getPrice($product,$product->getFinalPrice(),true) :
462
+ $product->getFinalPrice();
463
+ $Price = $this->improvePrice( $prodFinalPrice );
464
+ $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '';
465
+ if( !empty( $Reviews ) )
466
+ $Reviews = $this->cleanStr( $Reviews );
467
+ $ProducttoString = $this->cleanStr( $product->getSku() ) //ItemID
468
+ . "\t" //ItemQty
469
+ . "\t" //ItemUom
470
+ . "\t" . $Price //ItemPrice
471
+ . "\t" //ItemDescription
472
+ . "\t" //ItemLink
473
+ . "\t" //ItemitemAttributes
474
+ . "\t" //ItemitemGraphic
475
+ . "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ) //ProductName
476
+ . "\t" . $ProductDescription //ProductDescription
477
+ . "\t" . $prodImages //ProductGraphic
478
+ . "\t" . $URL //ProductLink
479
+ . "\t" . $ProductAttributes //ProductAttributes
480
+ . "\t" . $Manufacturer //Manufacturer
481
+ . "\t" //Category
482
+ . "\t" . $Reviews //Reviews
483
+ . "\t" . $shortDescription
484
+ . "\n";
485
+ return $ProducttoString;
486
+ }
487
+ public function cleanStr( &$str ){
488
+ return str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $str ) ) ) );
489
+ }
490
+ public function correctProdUrlStr( &$str ){
491
+ $str = str_replace( self::SCRIPTNAME, "index.php", $str );
492
+ $pos = strpos( $str, "?" );
493
+ if( $pos === false )
494
+ return $str;
495
+ else
496
+ return substr( $str, 0, $pos );
497
+ }
498
+ public function getReviews( $productid ){
499
+ $reviewsCollection = $this->reviewsModel->getCollection()
500
+ ->addStoreFilter($this->StoreId)
501
+ ->addStatusFilter('approved')
502
+ ->addEntityFilter('product', $productid)
503
+ ->setDateOrder();
504
+ $Reviews = "";
505
+ foreach( $reviewsCollection as $review )
506
+ $Reviews .= "<p><b>".$review->getTitle()."(". $review->getNickname() .")</b><br>".$review->getDetail().self::TAG_P_CLOSE;
507
+ unset( $reviewsCollection );
508
+ return $Reviews;
509
+ }
510
+ private function improvePrice( $Price ){
511
+ $rv = str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $Price ) ) ) );
512
+ if( empty( $rv ) || $rv == "0" )
513
+ return "";
514
+ $tail = strrchr( $rv, "." );
515
+ if( !empty( $tail ) && strlen( $tail ) > 3 )
516
+ $rv = substr( $rv, 0, strlen( $rv ) - ( strlen( $tail ) - 3 ) );
517
+ else if( !$tail )
518
+ $rv = $rv.".00";
519
+ return $rv;
520
+ }
521
+ private function getTierPrices( &$product ){
522
+ $res="";
523
+ $prices = $product->getFormatedTierPrice();
524
+ $rightstr = "";
525
+ if( is_array( $prices ) ){
526
+ $count = count( $prices );
527
+ if( $count > 0 ){
528
+ $prodFinalPrice=$this->includetaxes ?
529
+ $this->taxhelper->getPrice($product,$product->getFinalPrice(),true) :
530
+ $product->getFinalPrice();
531
+ $res='[TierPriceTable]#$$#'.$this->quantitylabel.'#$#'.$this->pricelabel.'#$#'.$this->savingslabel."=";
532
+ $i = 1;
533
+ foreach( $prices as $price ){
534
+ $price['price_qty'] = $price['price_qty'] * 1;
535
+ $tierPrice = $this->includetaxes ?
536
+ $this->taxhelper->getPrice($product,$price['price'],true) :
537
+ $price['price'];
538
+ if( $tierPrice < $prodFinalPrice ){
539
+ $rightstr .= $price['price_qty'].'#$#';
540
+ $rightstr.=$tierPrice.'#$#';
541
+ if( $i == $count )
542
+ $rightstr .= ceil(100 - (( 100/$prodFinalPrice ) * $tierPrice )).'%';
543
+ else
544
+ $rightstr .= ceil(100 - (( 100/$prodFinalPrice ) * $tierPrice )).'%#$$#';
545
+ }
546
+ $i++;
547
+ }
548
+ }
549
+ }
550
+ unset( $prices );
551
+ return $res.$rightstr;
552
+ }
553
+ // Class=CatalogSection
554
+ public function renderCatalogSection(){
555
+ $categories = Mage::getModel('catalog/category')->getCollection()
556
+ ->setStoreId( $this->StoreId )
557
+ ->addAttributeToSelect('name')
558
+ ->addAttributeToFilter('level', array('eq' => 2))
559
+ ->addAttributeToFilter('is_active', array('eq' => 1))
560
+ ->addAttributeToSort('position', 'asc');
561
+ $i = 1;
562
+ $count = count( $categories );
563
+ if($this->_DEBUG) echo "StoreId: ".$this->StoreId." Top categories: ".$count."
564
+ ";
565
+ echo "sec_Project\tsec_Sequence\tsec_HierarchyPath\tsec_Flag\n";
566
+ if( $count > 0 ){
567
+ if($this->ignoretopcategory){
568
+ foreach( $categories as $topcategory ){
569
+ $children = $topcategory->getChildrenCategories();
570
+ foreach ( $children as $category ){
571
+ $name = $category->getName();
572
+ $id = $category->getId();
573
+ echo $this->_drawCategory( $category, 1, $name, $i );
574
+ $i++;
575
+ }
576
+ }
577
+ }else{
578
+ foreach( $categories as $category ){
579
+ $name = $category->getName();
580
+ $id = $category->getId();
581
+ echo $this->_drawCategory( $category, 1, $name, $i );
582
+ $i++;
583
+ }
584
+ }
585
+ }
586
+ $lastId = $i;
587
+ echo "General\t".$lastId."\tUncategorized\t
588
+ ";
589
+ echo "==EOF==";
590
+ }
591
+ private function _drawCategory( &$category, $level=0, $hpath='', $i=1, $j=1, $path='' ){
592
+ $html = "";
593
+ $children = $category->getChildrenCategories();
594
+ $id = $category->getId();
595
+ if( $level != 1 ){
596
+ $path .= '-' . $j;
597
+ $hpath = $hpath.'#$#'.$category->getName(); //.' '.$i.$path;
598
+ $sec_path .= str_replace( "-", ",", $path );
599
+ $seq = $i.$sec_path;
600
+ }else{
601
+ $hpath = $category->getName(); //.' '.$i;
602
+ $seq = $i;
603
+ }
604
+ $html = "General\t".$seq."\t".$hpath."\t". $sec_Flag . "\n";
605
+ if( count( $children ) ){
606
+ $j = 1;
607
+ foreach ( $children as $cat ){
608
+ $htmlChildren .= $this->_drawCategory( $cat, $level + 1, $hpath, $i, $j, $path );
609
+ $j++;
610
+ }
611
+ }
612
+ unset( $children );
613
+ return $html .= $htmlChildren;
614
+ }
615
+ // Class=CatalogProject
616
+ public function renderCatalogProject(){
617
+ $this->productTypeConfigurableModel = Mage::getModel('catalog/product_type_configurable');
618
+ $categories = Mage::getModel('catalog/category')->getCollection()
619
+ ->setStoreId( $this->StoreId )
620
+ ->addAttributeToSelect('name')
621
+ ->addAttributeToFilter('level', array('eq' => 2))
622
+ ->addAttributeToFilter('is_active', array('eq' => 1))
623
+ ->addAttributeToSort('position', 'asc');
624
+ $count = count( $categories );
625
+ if($this->_DEBUG) echo "StoreId: ".$this->StoreId." Top categories: ".$count."
626
+ ";
627
+ if( $count > 0 ){
628
+ if($this->ignoretopcategory){
629
+ foreach( $categories as $topcategory ){
630
+ $children = $topcategory->getChildrenCategories();
631
+ foreach ( $children as $category ){
632
+ $this->catmap[ $category->getId() ] = $category;
633
+ $this->_processCategory( $category, 1, $name );
634
+ }
635
+ }
636
+ }else{
637
+ foreach( $categories as $category ){
638
+ $this->catmap[ $category->getId() ] = $category;
639
+ $this->_processCategory( $category, 1, $name );
640
+ }
641
+ }
642
+ }
643
+ $this->unCatPosition = 1;
644
+ echo "proj_Key\tproj_ProdName\tproj_Sequence\tproj_Name\tproj_HierarchyPath\tproj_Flag\tproj_ProdLayout
645
+ ";
646
+ $products = Mage::getModel('catalog/product')->getCollection();
647
+ $products->addAttributeToFilter('status', 1);//enabled
648
+ $products->addAttributeToFilter('visibility', 4);//catalog, search
649
+ $prodIds = $this->_DEBUG ? $products->getAllIds(1000,0) : $products->getAllIds();
650
+ if($this->_DEBUG) echo "StoreId: ".$this->StoreId."
651
+ Products: ".count( $prodIds )."
652
+ ";
653
+ foreach( $prodIds as $productId ){
654
+ $product = Mage::getModel('catalog/product')->setStoreId( $this->StoreId )->load( $productId );
655
+ echo $product->isConfigurable() ? $this->CatalogProjectStringConfigurable( $product ) : $this->CatalogProjectStringSimple( $product );
656
+ unset( $product );
657
+ }
658
+ echo "==EOF==";
659
+ }
660
+ private function _processCategory( &$category, $level=0, $hpath='', $path='' ){
661
+ $hpath = $level != 1 ? $hpath.'#$#'.$category->getName() : $hpath = $category->getName();
662
+ $this->catpathmap[ $category->getId() ] = $hpath;
663
+ if($this->_DEBUG) echo "Category: ".$category->getId()." path=".$hpath."
664
+ ";
665
+ $children = $category->getChildrenCategories();
666
+ if( count( $children ) ) foreach ( $children as $childcategory ){
667
+ $this->catmap[ $childcategory->getId() ] = $childcategory;
668
+ $htmlChildren .= $this->_processCategory( $childcategory, $level + 1, $hpath, $path );
669
+ }
670
+ }
671
+ public function CatalogProjectStringSimple( &$product ){
672
+ $ProducttoString = "";
673
+ $categoryIds = $product->getCategoryIds();
674
+ $listed = FALSE;
675
+ if( $categoryIds ){
676
+ foreach( $categoryIds as $k => $category_id ){
677
+ $category = $this->catmap[ $category_id ];
678
+ if( !isset( $category ) ){
679
+ if($this->_DEBUG) echo "No category: ".$category_id."
680
+ ";
681
+ continue;
682
+ }
683
+ $hpath = $this->catpathmap[ $category_id ];
684
+ $position = "";
685
+ $positions = $category->getProductsPosition();
686
+ if( count( $positions ) > 0 )
687
+ $position = $positions[ $product->getId() ];
688
+ $ProducttoString .= $product->getId().'#$#'.$this->cleanStr( $product->getName()) //ProductKey
689
+ . "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()) //Product Name
690
+ . "\t" . $position //Prod Sequence
691
+ . "\tGeneral" //Proj Name
692
+ . "\t" . $hpath //Hirarachi Path
693
+ . "\t" //Proj Flag
694
+ . "\t" //Proj Prod layout
695
+ . "\n";
696
+ $listed = TRUE;
697
+ }
698
+ }
699
+ if( !$listed ){
700
+ $ProducttoString .= $product->getId().'#$#'.$this->cleanStr( $product->getName()) //ProductKey
701
+ . "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()) //Product Name
702
+ . "\t" . $this->unCatPosition //Prod Sequence
703
+ . "\tGeneral" //Proj Name
704
+ . "\tUncategorized" //Hirarachi Path
705
+ . "\t" //Proj Flag
706
+ . "\t" //Proj Prod layout
707
+ . "\n";
708
+ $this->unCatPosition++;
709
+ }
710
+ return $ProducttoString;
711
+ }
712
+ public function CatalogProjectStringConfigurable( &$product ){
713
+ $UsedProductIds = $this->productTypeConfigurableModel->getUsedProductIds($product);
714
+ $countUsedProductIds = count( $UsedProductIds );
715
+ if( $countUsedProductIds > 0 ){
716
+ $listed = FALSE;
717
+ $ProducttoString = "";
718
+ $categoryIds = $product->getCategoryIds();
719
+ if( $categoryIds ){
720
+ foreach( $categoryIds as $k => $category_id ){
721
+ $category = $this->catmap[ $category_id ];
722
+ if( !isset( $category ) ){
723
+ if($this->_DEBUG) echo "No category: ".$category_id."
724
+ ";
725
+ continue;
726
+ }
727
+ $hpath = $this->catpathmap[ $category_id ];
728
+ $position = "";
729
+ $positions = $category->getProductsPosition();
730
+ if( count( $positions ) > 0 )
731
+ $position = $positions[ $product->getId() ];
732
+ $ProducttoString .= $product->getId().'#$#'. $this->cleanStr( $product->getName()) //ProductKey
733
+ . "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()) //Product Name
734
+ . "\t" . $position //Prod Sequence
735
+ . "\tGeneral" //Proj Name
736
+ . "\t" . $hpath //Hirarachi Path
737
+ . "\t" //Proj Flag
738
+ . "\t" //Proj Prod layout
739
+ . "\n";
740
+ $listed = TRUE;
741
+ }
742
+ }
743
+ if( !$listed ){
744
+ $ProducttoString .= $product->getId().'#$#'.$this->cleanStr( $product->getName()) //ProductKey
745
+ . "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()) //Product Name
746
+ . "\t" . $this->unCatPosition //Prod Sequence
747
+ . "\tGeneral" //Proj Name
748
+ . "\tUncategorized" //Hirarachi Path
749
+ . "\t" //Proj Flag
750
+ . "\t" //Proj Prod layout
751
+ . "\n";
752
+ $this->unCatPosition++;
753
+ }
754
+ } else
755
+ $ProducttoString = "";
756
+ unset( $UsedProductIds );
757
+ return $ProducttoString;
758
+ }
759
+ } // Mage_CodiScript_Model_Files
app/code/community/Mage/CodiScript/controllers/IndexController.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define("VERSION","2012-11-05");
3
+
4
+ class Mage_CodiScript_IndexController extends Mage_Core_Controller_Front_Action{
5
+ public function indexAction(){
6
+ //==============================================================================
7
+ $_DEBUG = isset($_REQUEST["_DEBUG"]) ? $_REQUEST["_DEBUG"] : "0";
8
+ $_INFO = isset($_REQUEST["_INFO"]) ? $_REQUEST["_INFO"] : "0";
9
+ $StoreCode = isset($_REQUEST["Store"]) ? $_REQUEST["Store"] : FALSE;
10
+ $Class = isset($_REQUEST["Class"]) ? $_REQUEST["Class"] : "";
11
+ $Password = isset($_REQUEST["Password"]) ? $_REQUEST["Password"] : "";
12
+ // Headers
13
+ $gmdate_mod = gmdate('D, d M Y H:i:s', time()).' GMT';
14
+ header('Last-Modified: '.$gmdate_mod);
15
+ header('Content-Type: text/plain; charset=UTF-8');
16
+ header('Content-Disposition: inline; filename="'.$Class.'.txt"');
17
+ header('X-CoDSoftware-Version: '.VERSION);
18
+ // Enable errors display / list versions
19
+ if($_DEBUG || $_INFO){
20
+ ini_set('display_errors', '1');
21
+ ini_set('error_reporting', E_ALL);
22
+ $started_time = time();
23
+ echo "PHP version: ".phpversion()."
24
+ Magento version: ".Mage::getVersion()."
25
+ Script version: ".VERSION."
26
+ --------------------------------------------------------------------------------
27
+ ";
28
+ }
29
+ if($_DEBUG) echo "Class=".$Class."
30
+ Password=".$Password."
31
+ ";
32
+ $codiScriptPassword = Mage::helper('codiscript')->getCodiPassword();
33
+ // Check if a password is defined
34
+ if( $codiScriptPassword == '' )
35
+ die('ERROR: A blank password is not allowed. Edit the password at System > Configuration > Catalog-on-Demand Configuration.');
36
+ // Check the password
37
+ if( $Password != $codiScriptPassword )
38
+ die('ERROR: The specified password is invalid.');
39
+ if( $Class=="DataFile" ){
40
+ $enablereviews = ( isset($_REQUEST["enablereviews"]) && $_REQUEST["enablereviews"] == "1" );
41
+ $ignoretopcategory = ( isset($_REQUEST["ignoretopcategory"]) && $_REQUEST["ignoretopcategory"] == "1" );
42
+ $includeshortdescription = ( isset($_REQUEST["includeshortdescription"]) && $_REQUEST["includeshortdescription"] == "1" );
43
+ $getpricefromfromchild = ( isset($_REQUEST["getpricefromfromchild"]) && $_REQUEST["getpricefromfromchild"] == "1" );
44
+ $publishtieredpricing = ( isset($_REQUEST["publishtieredpricing"]) && $_REQUEST["publishtieredpricing"] == "1" );
45
+ $quantitylabel = isset($_REQUEST["quantitylabel"]) ? $_REQUEST["quantitylabel"] : "Quantity";
46
+ $pricelabel = isset($_REQUEST["pricelabel"]) ? $_REQUEST["pricelabel"] : "Price";
47
+ $savingslabel = isset($_REQUEST["savingslabel"]) ? $_REQUEST["savingslabel"] : "Savings";
48
+ $includetaxes = ( isset($_REQUEST["includetaxes"]) && $_REQUEST["includetaxes"] == "1" );
49
+ $ignoreexcludedimages = ( isset($_REQUEST["ignoreexcludedimages"]) && $_REQUEST["ignoreexcludedimages"] == "1" );
50
+ if($_DEBUG) echo "enablereviews=".$enablereviews."
51
+ ignoretopcategory=".$ignoretopcategory."
52
+ includeshortdescription=".$includeshortdescription."
53
+ getpricefromfromchild=".$getpricefromfromchild."
54
+ publishtieredpricing=".$publishtieredpricing."
55
+ quantitylabel=".$quantitylabel."
56
+ pricelabel=".$pricelabel."
57
+ savingslabel=".$savingslabel."
58
+ includetaxes=".$includetaxes."
59
+ ignoreexcludedimages=".$ignoreexcludedimages."
60
+ ";
61
+ }else if( $Class=="CatalogSection" ){
62
+ $ignoretopcategory = ( isset($_REQUEST["ignoretopcategory"]) && $_REQUEST["ignoretopcategory"] == "1" );
63
+ if($_DEBUG) echo "ignoretopcategory=".$ignoretopcategory."
64
+ ";
65
+ }else if( $Class=="CatalogProject" ){
66
+ $ignoretopcategory = ( isset($_REQUEST["ignoretopcategory"]) && $_REQUEST["ignoretopcategory"] == "1" );
67
+ if($_DEBUG) echo "ignoretopcategory=".$ignoretopcategory."
68
+ ";
69
+ }
70
+ // Increase memory limit to 1024M
71
+ ini_set('memory_limit','1024M');
72
+ // Increase maximum execution time to 6 hours
73
+ ini_set('max_execution_time',28800);
74
+ // Make sure GC is enabled
75
+ if( function_exists( "gc_enable" ) )
76
+ gc_enable();
77
+ else if($_DEBUG || $_INFO)
78
+ echo "gc_enable does not exist.
79
+ ";
80
+ if($_INFO){
81
+ foreach ( Mage::app()->getStores() as $store )
82
+ echo "store: ".$store->getId()." code=".$store->getCode()." name=".$store->getName()." isActive=".$store->getIsActive()."
83
+ ";
84
+ if( function_exists( "gc_enabled" ) ) echo "gc_enabled=".gc_enabled()."
85
+ ";
86
+ else echo "gc_enabled does not exist.
87
+ ";
88
+ echo "--------------------------------------------------------------------------------
89
+ ";
90
+ die();
91
+ }
92
+ // Determine / check store
93
+ $StoreId = 0;
94
+ $Store = FALSE;
95
+ $Stores = Mage::app()->getStores( false, true );
96
+ if( !empty( $StoreCode ) && !$Stores[ $StoreCode ] )
97
+ die( "ERROR: Store \"".$StoreCode."\" not found.");
98
+ else if( !empty( $StoreCode ) && !$Stores[ $StoreCode ]->getIsActive() )
99
+ die( "ERROR: Store \"".$StoreCode."\" is inactive (disabled).");
100
+ else if( !empty( $StoreCode ) ){
101
+ $Store = $Stores[ $StoreCode ];
102
+ $StoreId = $Store->getId();
103
+ }else{
104
+ $count = 0;
105
+ foreach ( $Stores as $_Store )
106
+ if( $_Store->getIsActive() ){
107
+ $count++;
108
+ $Store = $_Store;
109
+ $StoreId = $Store->getId();
110
+ }
111
+ if( $count > 1 )
112
+ die( "ERROR: Store specification is required (there are more than 1 active / enabled stores).");
113
+ if( $count < 1 )
114
+ die( "ERROR: No active stores.");
115
+ }
116
+ $cfModel = Mage::getModel('codiscript/files');
117
+ if($Class=="DataFile"){
118
+ $cfModel->enablereviews = $enablereviews;
119
+ $cfModel->ignoretopcategory = $ignoretopcategory;
120
+ $cfModel->includeshortdescription = $includeshortdescription;
121
+ $cfModel->getpricefromfromchild = $getpricefromfromchild;
122
+ $cfModel->publishtieredpricing = $publishtieredpricing;
123
+ $cfModel->quantitylabel = $quantitylabel;
124
+ $cfModel->pricelabel = $pricelabel;
125
+ $cfModel->savingslabel = $savingslabel;
126
+ $cfModel->includetaxes = $includetaxes;
127
+ $cfModel->ignoreexcludedimages = $ignoreexcludedimages;
128
+ if($cfModel->includetaxes)
129
+ $cfModel->taxhelper=Mage::helper('tax');
130
+ }else if( $Class=="CatalogSection" ){
131
+ $cfModel->ignoretopcategory = $ignoretopcategory;
132
+ }else if( $Class=="CatalogProject" ){
133
+ $cfModel->ignoretopcategory = $ignoretopcategory;
134
+ }
135
+ $cfModel->_DEBUG = $_DEBUG;
136
+ $cfModel->StoreId = $StoreId;
137
+ $cfModel->Store = $Store;
138
+ if($Class=="DataFile") $cfModel->renderDataFile();
139
+ else if($Class=="CatalogSection") $cfModel->renderCatalogSection();
140
+ else if($Class=="CatalogProject") $cfModel->renderCatalogProject();
141
+ else if($_DEBUG){
142
+ foreach ( Mage::app()->getStores() as $store ){
143
+ echo "store: ".$store->getId()." code=".$store->getCode()." name=".$store->getName()." isActive=".$store->getIsActive()."
144
+ website=".$store->getWebsite()."
145
+ base currency=".$store->getBaseCurrency()."
146
+ ";
147
+ }
148
+ echo "max_execution_time=".ini_get("max_execution_time")."
149
+ memory_limit=".ini_get("memory_limit")."
150
+ ";
151
+ if( function_exists( "gc_enabled" ) ) echo "gc_enabled=".gc_enabled()."
152
+ ";
153
+ else echo "gc_enabled does not exist.
154
+ ";
155
+ echo "--------------------------------------------------------------------------------
156
+ ";
157
+ phpinfo(INFO_GENERAL);
158
+ phpinfo(INFO_CONFIGURATION);
159
+ echo "--------------------------------------------------------------------------------";
160
+ } else {
161
+ echo "==EOF==";
162
+ }
163
+ if($_DEBUG) echo "
164
+ executed in ".( time() - $started_time )." sec.
165
+ ";
166
+ die();
167
+ /* RELEASE NOTES
168
+ *
169
+ * 2012-11-05
170
+ * 1. Updated multiple images import
171
+ * 1. Added "Ignore excluded images" option support
172
+ *
173
+ * 2012-11-01
174
+ * 1. Updated debugging outout
175
+ *
176
+ * 2012-10-30
177
+ * 1. Added "Include taxes" option support
178
+ * 2. Updated images import: all product images are imported, not only the base one
179
+ *
180
+ * 2012-10-22
181
+ * 1. Added "Ignore top category" option support
182
+ *
183
+ * 2012-07-26
184
+ * 1. Added store spefification
185
+ * 2. Minor performance improvements
186
+ *
187
+ * 2012-07-25
188
+ * Minor performance improvements
189
+ */
190
+ //==============================================================================
191
+ }
192
+ }
app/code/community/Mage/CodiScript/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <codiscript module="codiscript">
12
+ <title>Codi Script Section</title>
13
+ </codiscript>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Mage/CodiScript/etc/config.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mage_CodiScript>
5
+ <version>0.1.0</version>
6
+ </Mage_CodiScript>
7
+ </modules>
8
+ <adminhtml>
9
+ <layout>
10
+ <updates>
11
+ <codiscript module="codiscript">
12
+ <file>codiscript.xml</file>
13
+ </codiscript>
14
+ </updates>
15
+ </layout>
16
+ <translate>
17
+ <modules>
18
+ <Mage_CodiScript>
19
+ <files>
20
+ <default>Mage_CodiScript.csv</default>
21
+ </files>
22
+ </Mage_CodiScript>
23
+ </modules>
24
+ </translate>
25
+ </adminhtml>
26
+ <frontend>
27
+ <routers>
28
+ <codi>
29
+ <use>standard</use>
30
+ <args>
31
+ <module>Mage_CodiScript</module>
32
+ <frontName>codiscript</frontName>
33
+ </args>
34
+ </codi>
35
+ </routers>
36
+ </frontend>
37
+ <global>
38
+ <models>
39
+ <codiscript>
40
+ <class>Mage_CodiScript_Model</class>
41
+ </codiscript>
42
+ </models>
43
+ <helpers>
44
+ <codiscript>
45
+ <class>Mage_CodiScript_Helper</class>
46
+ </codiscript>
47
+ </helpers>
48
+ </global>
49
+ </config>
app/code/community/Mage/CodiScript/etc/system.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <codiscript translate="label" module="codiscript">
5
+ <label>Catalog-on-Demand</label>
6
+ <sort_order>100</sort_order>
7
+ </codiscript>
8
+ </tabs>
9
+ <sections>
10
+ <codiscript translate="label" module="codiscript">
11
+ <class>separator-top</class>
12
+ <label>Catalog-on-Demand Configuration</label>
13
+ <tab>codiscript</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>40</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <config translate="label">
21
+ <label>Configuration</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>100</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <password translate="label comment">
29
+ <label>Password</label>
30
+ <comment>Use Valide Symbols</comment>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>100</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <validate>validate-codi-password</validate>
37
+ </password>
38
+ </fields>
39
+ </config>
40
+ </groups>
41
+ </codiscript>
42
+ </sections>
43
+ </config>
44
+
app/design/adminhtml/default/default/layout/codi.xml DELETED
@@ -1,12 +0,0 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
-
4
- <mage_codi_index>
5
- <block type="core/template" name="codi" template="codi/index.phtml" >
6
- <!--<block type="adminhtml/system_config_switcher" name="store_switcher" template="codi/switcher.phtml">
7
- <action method="setUseConfirm"><params>0</params></action>
8
- </block>-->
9
- </block>
10
- </mage_codi_index>
11
-
12
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/layout/codiscript.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_system_config_edit>
4
+ <reference name="head">
5
+ <action method="addJs"><script>codi/password_validation.js</script></action>
6
+ </reference>
7
+ </adminhtml_system_config_edit>
8
+
9
+ </layout>
app/design/adminhtml/default/default/template/codi/index.phtml DELETED
@@ -1,1095 +0,0 @@
1
- <?php
2
- error_reporting(E_WARNING);
3
-
4
- $codimodel = Mage::getSingleton('codi/codi');
5
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
6
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
7
- $secretkey = Mage::getStoreConfig('codi/codi/secretkey') ;
8
-
9
- $enablefreshflyers = Mage::getStoreConfig('codi/codi/enablefreshflyers') ;
10
- $enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
11
- $fromchild = Mage::getStoreConfig('codi/codi/fromchild') ;
12
-
13
- $codflyerlinkimg = Mage::getStoreConfig('codi/codi/codflyerlinkimg') ;
14
- $codflyerlinkimgurl = Mage::getStoreConfig('codi/codi/codflyerlinkimgurl') ;
15
- $codflyerlinkimgalt = Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') ;
16
-
17
- $codbeforename = Mage::getStoreConfig('codi/codi/codbeforename') ;
18
- $codaftername = Mage::getStoreConfig('codi/codi/codaftername') ;
19
-
20
- $codbeforeemailto = Mage::getStoreConfig('codi/codi/codbeforeemailto') ;
21
- $codafteremailto = Mage::getStoreConfig('codi/codi/codafteremailto') ;
22
-
23
- $codbeforeOR = Mage::getStoreConfig('codi/codi/codbeforeOR') ;
24
- $codafterOR = Mage::getStoreConfig('codi/codi/codafterOR') ;
25
-
26
- $codbeforeoverview = Mage::getStoreConfig('codi/codi/codbeforeoverview') ;
27
- $codafteroverview = Mage::getStoreConfig('codi/codi/codafteroverview') ;
28
-
29
- $codbgcheck = Mage::getStoreConfig('codi/codi/codbgcheck') ;
30
-
31
- $post_url = $this->getUrl('codi/nsync/manual');
32
- $post_url_upd = $this->getUrl('codi/adminhtml_menu/updatestatus');
33
- $post_url_cancel = $this->getUrl('codi/adminhtml_menu/cancel');
34
- $post_bgprocess_check = $this->getUrl('codi/adminhtml_menu/bgcheck');
35
- //chagned ver 3.0.1
36
- $newpostupdate = $this->getUrl('codi/nsync/updatestatus');
37
- //Changed for category section file
38
- $createCatalogSection = $this->getUrl('codi/nsync/createcatalogsection');
39
-
40
- //Changed for Category project section
41
- $createCatalogProject = $this->getUrl('codi/nsync/createcatalogproject');
42
-
43
- //Changed ver 2.2.15
44
- $download_url = $this->getUrl('codi/adminhtml_menu/downloadtest');
45
- $delete_codi_url = $this->getUrl('codi/adminhtml_menu/deletetest');
46
-
47
- //Chagned ver 2.2.16
48
- $datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
49
-
50
- $codbg_checked = "";
51
- if ( $codbgcheck == 1 ) $codbg_checked = "checked";
52
-
53
- $extensionName="Mage_Codi";
54
- $currentVer = Mage::getConfig()->getModuleConfig('Mage_Codi')->version;
55
-
56
- //Changed ver 3.0.1 Added wait for minute parameter
57
- $waitforminute=Mage::getStoreConfig('codi/codi/codwaitforminute');
58
- $includeshortdescription = Mage::getStoreConfig('codi/codi/codincludeshortdescription');
59
-
60
- //Chagned ver 3.0.2 Added Tier price display settings
61
- $publishtieredpricing=Mage::getStoreConfig('codi/codi/codpublishtieredpricing');
62
- $codquantity=Mage::getStoreConfig('codi/codi/codquantity');
63
- $codprice=Mage::getStoreConfig('codi/codi/codprice');
64
- $codsavings=Mage::getStoreConfig('codi/codi/codsavings');
65
-
66
- //Changed for show download zip file url
67
- $zipurl = $this->getUrl('CoDzip/') ;
68
- $pos = strrpos ($zipurl , 'key') ;
69
- if ( $pos != 0 )
70
- $zipurl = substr( $zipurl , 0 , $pos ) ;
71
- else
72
- $zipurl = $zipurl;
73
-
74
- $zipurl=str_replace("index.php/CoDzip/index/index/", "CoDzip/",$zipurl);
75
-
76
- ?>
77
- <style>
78
- #codi_status_template_button{
79
- margin-bottom:0.5em;
80
- width:329px;
81
- }
82
- #codi_status_template{
83
- margin-bottom:0.5em;
84
- width:330px;
85
- }
86
- #tooltip {
87
- position: absolute;
88
- z-index: 3000;
89
- border: 1px solid #111;
90
- background-color: #eee;
91
- padding: 5px;
92
- max-width:500px;
93
- }
94
- #tooltip h3, #tooltip div { margin: 0; }
95
- #tooltip ul{list-style:disc outside none;margin-left:12px;margin-bottom:12px;padding-left:40px;}
96
- .hidden{display:none;}
97
- .waitforminute{width:59px;}
98
- .tiredprice{width:155px;visibility:visible;height:12px;display:block;}
99
- .displayOption{width:120px;visibility:visible;height:12px;display:block;}
100
- </style>
101
-
102
- <div id="page:main-container">
103
- <div class="columns ">
104
- <div class="side-col" id="page:left">
105
- <h3>Catalog-On-Demand®</h3>
106
- <?php
107
- $CodiModel = Mage::getModel('codi/codi');
108
- $vari=$CodiModel->getstatus();// check status for datafile
109
-
110
- foreach ($vari as $var)
111
- {
112
- $message=$var['message'];
113
- $finished=$var['finished'];
114
- $start_time=$var['created_time'];
115
- }
116
-
117
- $end_time=strtotime('+1 hours',$start_time);
118
- $endwait_time=strtotime('+'.$waitforminute. 'minutes',$start_time);
119
- $current_time=time();
120
-
121
-
122
- if($finished==1 && $endwait_time<$current_time &&$end_time<$current_time)
123
- {
124
- $mess='Sorry! Your last product import failed. Please use Manual mode to create the data file. Click on the help icon for instructions.';
125
-
126
- }
127
-
128
-
129
- if($start_time<$current_time && $current_time<$end_time)
130
- {
131
- $data='Data file is in process';
132
-
133
- ?>
134
- <ul id="product_info_tabs" class="tabs">
135
- <li >
136
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/register');?>" onclick="return false;">
137
- <span>Sign Up</span>
138
- </a>
139
- </li>
140
- <li >
141
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/auth');?>" onclick="return false;" >
142
- <span>Configuration Settings</span>
143
- </a>
144
- </li>
145
- <li >
146
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/systemtest');?>" onclick="return false;">
147
- <span>System Test</span>
148
- </a>
149
- </li>
150
- <li >
151
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/documentation');?>" onclick="return false;">
152
- <span>Documentation</span>
153
- </a>
154
- </li>
155
- </ul>
156
- <?php
157
- }
158
-
159
- else
160
- {
161
- ?>
162
-
163
- <ul id="product_info_tabs" class="tabs">
164
- <li >
165
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/register');?>" class="tab-item-link "
166
- <?php if ( $codimodel->target == "register") echo "style='background-color:#ffffff;'" ; ?>
167
- onclick="window.open ('https://www.catalog-on-demand.com/signup/');" >
168
- <span>Sign Up</span>
169
- </a>
170
- </li>
171
- <li >
172
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/auth');?>" class="tab-item-link "
173
- <?php if ( $codimodel->target == "auth") echo "style='background-color:#ffffff;'" ; ?> >
174
- <span>Configuration Settings</span>
175
- </a>
176
- </li>
177
- <li >
178
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/systemtest');?>" class="tab-item-link "
179
- <?php if ( $codimodel->target == "systemtest") echo "style='background-color:#ffffff;'" ; ?> >
180
- <span>System Test</span>
181
- </a>
182
- </li>
183
- <li >
184
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/documentation');?>" class="tab-item-link "
185
- <?php if ( $codimodel->target == "documentation") echo "style='background-color:#ffffff;'" ; ?>
186
- onclick="window.open ('http://www.catalog-on-demand.com/plans/catalog-on-demand_for_magento.php');">
187
- <span>Documentation</span>
188
- </a>
189
- </li>
190
- </ul>
191
- <?php
192
- }?>
193
- </div>
194
- <div class="main-col" id="content">
195
- <div class="main-col-inner">
196
- <div class="content-header"></div>
197
- <!-- Show message when data file is in process or stopped -->
198
- <div style="color: red;"><?php echo $mess; ?></div>
199
- <div style="color: green;font: 12px/1.5em "><?php echo $data; ?></div>
200
- <?php
201
- $extensions = array('curl','dom', 'hash','iconv','mcrypt' );
202
-
203
- $fail = '';
204
- $pass = '';
205
-
206
- if(version_compare(phpversion(), '5.2.0', '<')) {
207
- $fail .= '<li>You need<strong> PHP 5.2.0</strong> (or greater). Your current version is '.phpversion().'</li>';
208
- }
209
- else {
210
- $pass .='<li>You have<strong> PHP '.phpversion().'</strong></li>';
211
- }
212
-
213
- if( !ini_get('safe_mode') ) {
214
- $pass .='<li>Safe Mode is <strong>off</strong></li>';
215
- }
216
- else { $fail .= '<li>Safe Mode is <strong>on</strong></li>'; }
217
-
218
- foreach($extensions as $extension) {
219
- if( !extension_loaded($extension) ) {
220
- $fail .= '<li> You are missing the <strong>'.$extension.'</strong> extension</li>';
221
- }
222
- else{
223
- $pass .= '<li>You have the <strong>'.$extension.'</strong> extension</li>';
224
- }
225
- }
226
-
227
-
228
- $baseDir = dirname(__FILE__);
229
-
230
- $_baseDirArray = explode("app", $baseDir);
231
- $basePath = $_baseDirArray[0];
232
-
233
- //Create folder if not exist. change for zip
234
- if (!is_dir($basePath.'CoDzip/') )
235
- {
236
- if (!mkdir($basePath.'CoDzip/'))
237
- {
238
- $fail .= "<li>Could not create <strong>CoDzip</strong> folder.</li>";
239
- $fail .= "<li>Please create <strong>CoDzip manually</strong> in ".$basePath."</li>";
240
-
241
- }
242
- }
243
- if (is_dir($basePath.'CoDzip/') )
244
- {
245
- if (!is_dir($basePath.'CoDzip/CoDfiles/') )
246
- {
247
- if (!mkdir($basePath.'CoDzip/CoDfiles/'))
248
- {
249
- $fail .= "<li>Could not create <strong>CoDzip/CoDfiles</strong> folder.</li>";
250
- $fail .= "<li>Please create <strong>CoDzip/CoDfiles manually</strong> in ".$basePath."</li>";
251
- }
252
- }
253
- }
254
- /*if ( !is_dir($basePath.'CoDzip/CoDfiles/') ){
255
- if ( !mkdir($basePath.'CoDzip/CoDFiles/') ){
256
-
257
- $fail .= "<li>Could not create <strong>CoDzip</strong> folder.</li>";
258
- $fail .= "<li>Please create <strong>CoDzip manually</strong> in ".$basePath."</li>";
259
- }
260
- }*/
261
-
262
- $is_file = true;
263
-
264
- if ( !$codimodel->createFileInit($basePath) ){
265
- $fail .= "<li>The Magento extension was prevented from creating a file in the folder CoDzip. Please notify your Magento administrator.</li>";
266
- $is_file = false;
267
- }
268
-
269
- $target = $codimodel->target;
270
-
271
- if ( $target == "auth" && $fail != "" ){
272
- $target = "systemtest";
273
- }
274
-
275
- switch ($target)
276
- {
277
- case "register":
278
- break;
279
- case "documentation":
280
- break;
281
- case "systemtest":
282
-
283
- echo "<div class='entry-edit'>
284
- <div class='entry-edit-head'>
285
- <h4 class='icon-head head-edit-form fieldset-legend'>System Test</h4>
286
- <div>&nbsp;</div>
287
- </div>
288
- <div class='fieldset'>
289
- ";
290
-
291
- if( $fail ) {
292
- echo '<p><strong>Your server is not properly configured to run the Catalog-on-Demand® for Magento® extension.</strong>';
293
- echo '<br>Please contact your hosting provider to report the failure of the following tests:';
294
- echo '<br><ul>'.$fail.'</ul></p>';
295
- echo '<br>The following tests were successfully met:';
296
- echo '<ul>'.$pass.'</ul>';
297
- } else {
298
- echo '<p><strong>Congratulations!</strong>&nbsp; Your server has passed all the tests to properly run the Catalog-on-Demand® for Magento® extension.</p>';
299
- echo '<ul>'.$pass.'</ul>';
300
- }
301
-
302
- echo "<br/>";
303
-
304
-
305
- echo '<p> Current Extension Name : <b>'.$extensionName.'</b></p>';
306
-
307
- echo '<p>Current Extension Version: <b>'.$currentVer.'</b></p>';
308
-
309
-
310
-
311
-
312
- $exec_command = "";
313
-
314
- if( (false !== strpos(ini_get("disable_functions"), "exec")) || (false !== strpos(ini_get("disable_functions"), "shell_exec")) ) {
315
- $exec_command = "<p>The <strong>exec</strong> and/or <strong>shell_exec</strong> functions are disabled in your php.ini. See the line starting with <strong>'disable_functions ='</strong>. Unless you remove both <strong>'exec'</strong> and <strong>'shell_exec'</strong> from this line, you may not use the background process to create data files. This may be a problem if you have a large product database.</p>";
316
- }else{
317
- $exec_command = "The <strong>exec</strong> and <strong>shell_exec</strong> functions are enabled. You may use the background process to create data files.";
318
- }
319
-
320
- echo $exec_command;
321
-
322
- echo "<br/><br/>";
323
-
324
- foreach (Mage::app()->getWebsites() as $website)
325
- {
326
- $defaultGroup = $website->getDefaultGroup();
327
- $StoreId = $defaultGroup->getDefaultStoreId();
328
- }
329
-
330
- $design = Mage::getSingleton('core/design')->loadChange($StoreId);
331
-
332
- $package = $design->getPackage();
333
- $default_theme = $design->getTheme();
334
-
335
- if ( $package == "" && $default_theme == "" ){
336
-
337
- $package = Mage::getStoreConfig('design/package/name', $StoreId);
338
- $default_theme = Mage::getStoreConfig('design/theme/default', $StoreId);
339
- }
340
-
341
- if ( $package == "" ) $package = "default";
342
- if ( $default_theme == "" ) $default_theme = "default";
343
-
344
- $update_guide = "<ul style='list-style:decimal outside none;padding-left:30px;'>";
345
- $update_guide .= "<li><p>Open this file : /app/design/frontend/default/default/template/catalog/product/view.phtml. This will be your 'source' file.</p></li>";
346
- $update_guide .= "<li><p>Your view.phtml ( /app/design/frontend/".$package."/".$default_theme."/template/catalog/product/view.phtml ) will be your 'target' file. </p><p>Please copy the code as follows: </p>";
347
- $update_guide .= "<ul style='list-style:square outside none;padding-left:30px;'>";
348
- $update_guide .= "<li><p>Copy lines 37-50, and paste after the line containing getProduct().</p></li>";
349
- $update_guide .= "<li><p>Copy line 69 and paste before the line containing 'name'.</p></li>";
350
- $update_guide .= "<li><p>Copy line 71 and paste after the line containing 'name'.</p></li>";
351
- $update_guide .= "<li><p>Copy line 79 and paste before the line containing 'Email to a Friend'.</p></li>";
352
- $update_guide .= "<li><p>Copy line 81 and paste after the line containing 'Email to a Friend'.</p></li>";
353
- $update_guide .= "<li><p>Copy line 99 and paste before the line containing 'OR'.</p></li>";
354
- $update_guide .= "<li><p>Copy line 101 and paste after the line containing 'OR'.</p></li>";
355
- $update_guide .= "<li><p>Copy line 115 and paste before the line containing 'Quick Overview'.</p></li>";
356
- $update_guide .= "<li><p>Copy line 117 and paste after the line containing 'Quick Overview'.</p></li>";
357
- $update_guide .= "</ul>";
358
- $update_guide .= "</li>";
359
- $update_guide .= "<ul>";
360
-
361
- if ( $package != "default" || $default_theme != "default" ){
362
-
363
- echo "<p>This is important if you intend to use the Always Fresh™ 'flyer-per-product-page' feature of Catalog-on-Demand®.</p>";
364
- echo "<p>You are using the following theme : <strong>".$package." / ".$default_theme."</strong></p>";
365
- echo "<p>Your site admin will need to edit the view.html for this theme, as follows:</p>";
366
- echo $update_guide;
367
-
368
- }else{
369
- echo "<p>You have the default theme.</p>";
370
- }
371
-
372
- echo "</div></div>";
373
- echo "<br />";
374
-
375
- $text = "";
376
-
377
- if ( $is_file ){
378
-
379
- $message = $codimodel->getImportStatuses();
380
-
381
- if ( isset($message) ){
382
-
383
- $status = $message['message'];
384
-
385
- if ( $status== "end" && $message['finished'] == 1 ){
386
- $text = "<p id='codi_status_template_button'>Your test data file was created successfully. &nbsp;<img src='".$this->getSkinUrl($this->__('images/codimport_yes.gif'))."' /> <button type='button' onclick='download_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Download Data File</span></button> <button type='button' onclick='delete_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Delete Data File</span></button></p>";
387
- $codimodel->deleteTable();
388
- }else if ( $status== "start" && $message['finished'] == 0 ) {
389
- $text = "<p>A test data file is now being created. <span style='margin-left:15px;'><img src='".$this->getSkinUrl($this->__('images/codimport_run.gif'))."' /></span>&nbsp;&nbsp;&nbsp;</p>" ;
390
- }else if ( $status== "fileerror" && $message['finished'] == 0 ) {
391
- $text = "<p>Your test data file was not created. Please contact your administrator.</p>";
392
- $codimodel->deleteTable();
393
- }else{
394
- $text = "<p>Your test data file was not created. Please contact your administrator.</p>";
395
- $codimodel->deleteTable();
396
- }
397
- }
398
- else{
399
- //Changed on version 2.2.15
400
- //$text .= "<a href='#datafilebackground_tooltip'><img src='".$this->getSkinUrl($this->__('images/preview_field_help.png'))."' /></a><input type='checkbox' id='background_process' name='background_process' ".$codbg_checked." style='margin:0px 5px 0px 15px;cursor:pointer' onclick='onBackgroundProcess(this)' />Create data file using background process<br /><br />";
401
- $text .= "<button type='button' class='scalable add' onclick='start_codi_import()' style='margin-left:25px;' ><span>Test</span></button>";
402
- }
403
-
404
-
405
- }
406
- break;
407
- case "auth":
408
- ?>
409
-
410
- <?php echo $this->getStoreSwitcherHtml() ?>
411
-
412
- <form name="codiform" action="<?php echo $this->getUrl('codi/adminhtml_menu/authsave') ?>" method="post" id="codiform">
413
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
414
- <input name="store" type="hidden" value="<?php echo $this->getRequest()->getParam('store'); ?>" />
415
- <div class="entry-edit">
416
- <div class="entry-edit-head">
417
- <h4 class="icon-head head-edit-form fieldset-legend">Configuration Settings</h4>
418
- <div class="form-buttons" align="right">
419
- <button type="submit" class="scalable add" ><span>Save</span></button>
420
- </div>
421
- <div>&nbsp;</div>
422
- </div>
423
- <div class="fieldset " id="group_fields12">
424
- <div class="hor-scroll">
425
- <table cellspacing="0" class="form-list">
426
- <tbody>
427
- <tr>
428
- <td class="scope-label"><a href="#accountid_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
429
- <td class="label"><label for="userid">Account ID</label></td>
430
- <td class="value"><input name="userid" onchange="makeLowercase();" id="userid" value="<?php echo $userid ?>" class=" input-text" type="text"/></td>
431
- <td><small>&nbsp;</small></td>
432
- </tr>
433
- <tr>
434
- <td class="scope-label"><a href="#secretkey_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
435
- <td class="label"><label for="secretkey">Secret Key</label></td>
436
- <td class="value"><input name="secretkey" id="secretkey" value="<?php echo $secretkey ?>" class=" input-text" type="text"/></td>
437
- <td><small>&nbsp;</small></td>
438
- </tr>
439
- <tr>
440
- <td class="scope-label"><a href="#kickoffurl_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
441
- <td class="label"><label for="secretkey">Kick-off URL</label></td>
442
- <td class="value"><label>
443
- <?php
444
- $url = $this->getUrl('codi/sync') ;
445
- $pos = strrpos ($url , 'key') ;
446
- if ( $pos != 0 )
447
- $kickoffurl = substr( $url , 0 , $pos ) ;
448
- else
449
- $kickoffurl = $url;
450
-
451
- echo "<input class='input-text' type='text' name='kickoffurl' value='".$kickoffurl."'>" ;
452
- ?></label>
453
- </td>
454
- <td><small>&nbsp;</small></td>
455
- </tr>
456
- <tr><td class="scope-label"></td><td class="label"></td><td class="value"></td><td><small>&nbsp;</small></td></tr>
457
- <!-- Changed for version 2.2.16 to add data file launch mode -->
458
- <tr>
459
- <td class="scope-label"><a href="#data_file_launch_mode_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
460
- <td class="label"><label for="DataFileLaunchMode">Data File Launch Mode</label></td>
461
- <td class="value">
462
- <input type="radio" value="manual" id="manual" name="datafilelaunch" <?php if ($datafilelaunch =="manual") echo "checked" ?> onclick="displayBlock('codi_status_template','cronjob','0');"/>&nbsp;<label for="manual">Manual&nbsp;<a href="#manual_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></label><br>
463
- <p id="codi_status_template" name="codi_status_template" style="display:<?php if ($datafilelaunch =="manual") echo 'block'; else echo 'none';?>;">
464
- <?php
465
- $filename = $basePath.'CoDzip/CoDMagento.zip';
466
- if (file_exists($filename)) {
467
-
468
- $url = $this->getUrl('CoDzip/CoDMagento.zip') ;
469
- $pos = strrpos ($url , 'key') ;
470
- if ( $pos != 0 )
471
- $url = substr( $url , 0 , $pos ) ;
472
- else
473
- $url = $url;
474
-
475
- $zipfileurl=str_replace("index.php/CoDzip/CoDMagento.zip/index/", "CoDzip/CoDMagento.zip",$url);
476
- $modifie="<input class='input-text' type='text' name='zipfileurl' value='".$zipfileurl."'><br/>" ;
477
- $modifie.="Last Created Date: " . date("M d, Y H:i:s.", filemtime($filename))."(GMT)";
478
- echo $modifie." <button type='button' onclick='download_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Download Data File</span></button> <button type='button' onclick='delete_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Delete Data File</span></button>";
479
- }
480
- else{
481
- ?>
482
- <button type='button' class='scalable add' onclick='start_codi_import()' style='margin-left:25px;' ><span>Create Data File</span></button>
483
- <?php }?>
484
- </p>
485
-
486
-
487
- <input type="radio" value="cod" id="cod" name="datafilelaunch" <?php if ($datafilelaunch =="cod") echo "checked" ?> onclick="displayBlock('codi_status_template','cronjob','1');" />&nbsp;<label for="cod">Catalog-on-Demand&nbsp;<a href="#codoption_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></label>
488
- <span style="display:<?php if ($datafilelaunch =="cod") echo ''; else echo 'none';?>;" id="waitforminute"><br>Minutes to wait for data file creation : <input type="text" name="waitforminute" onchange="valuevalidation(this.value,5,999,'Please enter only integer value between 5 and 999.','I');" class="waitforminute" width="60px" value="<?php echo $waitforminute;?>">&nbsp;<a href="#waitforminute_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></span><br>
489
- <input type="radio" value="magento" id="magento" name="datafilelaunch" <?php if ($datafilelaunch =="magento") echo "checked" ?> onclick="displayBlock('cronjob','codi_status_template','0');" />&nbsp;<label for="magento">Cron-job &nbsp;<a href="#cronjoburl_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></label>
490
- </td>
491
- <td><small>&nbsp;</small></td>
492
- </tr>
493
- <tr>
494
-
495
- <td class="scope-label"></td>
496
- <td class="label"></td>
497
- <td class="value">
498
- <p id="cronjob" name="cronjob" style="display:<?php if ($datafilelaunch =="magento") echo 'block'; else echo 'none';?>;">
499
- <?php
500
- $url = $this->getUrl('codi/nsync') ;
501
- $pos = strrpos ($url , 'key') ;
502
- if ( $pos != 0 )
503
- $cronjoburl = substr( $url , 0 , $pos ) ;
504
- else
505
- $cronjoburl = $url;
506
-
507
- echo '<input type="text" class="input-text" name="cronjoburl" width="60px" value="wget '.$cronjoburl.'">' ;
508
- ?></p>
509
- </td>
510
- <td><small>&nbsp;</small></td>
511
- </tr>
512
-
513
- <tr>
514
- <td class="scope-label"><a href="#enablefreshflyers_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
515
- <td class="label"><label for="enablefreshflyers">Enable Always Fresh™ Flyers</label></td>
516
- <td class="value"><input name="enablefreshflyers" id="enablefreshflyers" value="checked" <?php if ($enablefreshflyers =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
517
- <td><small>&nbsp;</small></td>
518
- </tr>
519
- <!-- Code for Include Short Description -->
520
- <tr>
521
- <td class="scope-label"><a href="#includeshortdescription_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
522
- <td class="label"><label for="includeshortdescription">Include Short Description</label></td>
523
- <td class="value"><input name="includeshortdescription" id="includeshortdescription" value="checked" <?php if ($includeshortdescription =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
524
- <td><small>&nbsp;</small></td>
525
- </tr>
526
- <tr>
527
- <td class="scope-label"><a href="#enablereviews_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
528
- <td class="label"><label for="enablereviews">Enable Reviews</label></td>
529
- <td class="value"><input name="enablereviews" id="enablereviews" value="checked" <?php if ($enablereviews =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
530
- <td><small>&nbsp;</small></td>
531
- </tr>
532
- <tr>
533
- <td class="scope-label"><a href="#getpricefromchild_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
534
- <td class="label"><label for="fromchild">Get price from associated products</label></td>
535
- <td class="value"><input name="fromchild" id="fromchild" value="checked" <?php if ($fromchild =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
536
- <td><small>&nbsp;</small></td>
537
-
538
- </tr>
539
- <!-- Changes for Tired price option -->
540
- </table>
541
-
542
- <fieldset style="width:460px;">
543
- <legend class="tiredprice"><a href="#tieredpricingoptions_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a>&nbsp; Tiered Pricing Options</legend>
544
- <table class="form-list" cellpadding='0'>
545
- <tr>
546
- <td class="label"><label for="publishtieredpricing">Publish tiered pricing</label></td>
547
- <td class="value"><input name="publishtieredpricing" id="publishtieredpricing" value="checked" <?php if ($publishtieredpricing =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
548
- <td class="scope-label"></td>
549
- <td><small>&nbsp;</small></td>
550
- </tr>
551
-
552
- <tr>
553
- <td class="label"><label for="codquantity">Label for quantity column</label></td>
554
- <td class="value"><input type="text" id="codquantity" name="codquantity" class="input-text" value="<?php if ($codquantity == '') echo 'Quantity'; else echo $codquantity ;?>"></td>
555
- <td class="scope-label"></td>
556
- <td><small>&nbsp;</small></td>
557
- </tr>
558
-
559
- <tr>
560
- <td class="label"><label for="codprice">Label for price column</label></td>
561
- <td class="value"><input type="text" id="codprice" name="codprice" class=" input-text" value="<?php if ($codprice == '') echo 'Price'; else echo $codprice;?>"> </td>
562
- <td class="scope-label"></td>
563
- <td><small>&nbsp;</small></td>
564
- </tr>
565
- <tr>
566
- <td class="label"><label for="codsavings">Label for savings</label></td>
567
- <td class="value"><input type="text" id="codsavings" name="codsavings" class=" input-text" value="<?php if ($codsavings == '') echo 'Savings'; else echo $codsavings;?>" ></td>
568
- <td class="scope-label"></td>
569
- <td><small>&nbsp;</small></td>
570
- </tr>
571
- </table>
572
-
573
- </fieldset>
574
- <!-- End changes for Tired price option -->
575
- <table class="form-list">
576
- <tr><td class="scope-label"></td><td class="label"></td><td class="value"></td><td><small>&nbsp;</small></td></tr>
577
- <tr>
578
- <td class="scope-label"><a href="#codflyerlinkimg_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
579
- <td class="label"><label for="usedimage">Image to be used for flyer link</label></td>
580
- <td class="value">
581
- <input type="radio" value="Default" id="Default" name="codflyerlinkimg" <?php if ($codflyerlinkimg !="Custom") echo "checked" ?> onclick="document.getElementById('codflyerlinkimgurl').style.display='none';"/>&nbsp;<label for="Default">Default</label><br>
582
- <input type="radio" value="Custom" id="Custom" name="codflyerlinkimg" <?php if ($codflyerlinkimg =="Custom") echo "checked" ?> onclick="document.getElementById('codflyerlinkimgurl').style.display='block';"/>
583
- &nbsp;<label for="Custom">Custom</label>
584
- </td>
585
- <td>
586
- <img src="<?php if ($codflyerlinkimg =='Custom') echo $codflyerlinkimgurl ; else echo 'http://www.catalog-on-demand.com/print-catalog.png'?>"></td>
587
- </tr>
588
- <tr>
589
- <td class="scope-label"></td>
590
- <td class="label"></td>
591
- <td class="value">
592
- <input type="text" id="codflyerlinkimgurl" name="codflyerlinkimgurl" class=" input-text"
593
- value="<?php if ($codflyerlinkimg =='Custom') echo $codflyerlinkimgurl; else echo '';?>"
594
- style="display:<?php if ($codflyerlinkimg =='Custom') echo 'block'; else echo 'none';?>" />
595
- </td>
596
- <td><small>&nbsp;</small></td>
597
- </tr>
598
- <tr>
599
- <td class="scope-label"><a href="#codflyerlinkimgalt_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
600
- <td class="label"><label for="usedimage">Alt text for flyer link image</label></td>
601
- <td class="value">
602
- <input type="text" id="codflyerlinkimgalt" name="codflyerlinkimgalt" class=" input-text"
603
- value="<?php if ($codflyerlinkimgalt == '') echo 'Click for PDF of this product'; else echo $codflyerlinkimgalt ;?>" />
604
- </td>
605
- <td><small>&nbsp;</small></td>
606
- </tr>
607
- <tr><td class="scope-label"></td><td class="label"></td><td class="value"></td><td><small>&nbsp;</small></td></tr>
608
- </table>
609
- <fieldset style="width:460px;">
610
- <legend class="displayOption"><a href="#displayoptions_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a>&nbsp; Display Options</legend>
611
- <table class="form-list" cellpadding='0'>
612
- <tr>
613
- <td class="label"><label for="codbeforename">Display before product name</label></td>
614
- <td class="value"><input name="codbeforename" id="codbeforename" value="checked" <?php if ($codbeforename =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
615
- <td class="scope-label"></td>
616
- <td><small>&nbsp;</small></td>
617
- </tr>
618
- <tr>
619
- <td class="label"><label for="codaftername">Display after product name</label></td>
620
- <td class="value"><input name="codaftername" id="codaftername" value="checked" <?php if ($codaftername =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
621
- <td class="scope-label"></td>
622
- <td><small>&nbsp;</small></td>
623
- </tr>
624
-
625
- <tr>
626
- <td class="label"><label for="codbeforeemailto">Display before 'Email to a friend'</label></td>
627
- <td class="value"><input name="codbeforeemailto" id="codbeforeemailto" value="checked" <?php if ($codbeforeemailto =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
628
- <td class="scope-label"></td>
629
- <td><small>&nbsp;</small></td>
630
- </tr>
631
- <tr>
632
- <td class="label"><label for="codafteremailto">Display after 'Email to a friend'</label></td>
633
- <td class="value"><input name="codafteremailto" id="codafteremailto" value="checked" <?php if ($codafteremailto =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
634
- <td class="scope-label"></td>
635
- <td><small>&nbsp;</small></td>
636
- </tr>
637
-
638
- <tr>
639
- <td class="label"><label for="codbeforeOR">Display before 'OR'</label></td>
640
- <td class="value"><input name="codbeforeOR" id="codbeforeOR" value="checked" <?php if ($codbeforeOR =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
641
- <td class="scope-label"></td>
642
- <td><small>&nbsp;</small></td>
643
- </tr>
644
- <tr>
645
- <td class="label"><label for="codafterOR">Display after 'OR'</label></td>
646
- <td class="value"><input name="codafterOR" id="codafterOR" value="checked" <?php if ($codafterOR =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
647
- <td class="scope-label"></td>
648
- <td><small>&nbsp;</small></td>
649
- </tr>
650
-
651
- <tr>
652
- <td class="label"><label for="codbeforeoverview">Display before 'Quick Overview'</label></td>
653
- <td class="value"><input name="codbeforeoverview" id="codbeforeoverview" value="checked" <?php if ($codbeforeoverview =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
654
- <td class="scope-label"></td>
655
- <td><small>&nbsp;</small></td>
656
- </tr>
657
- <tr>
658
- <td class="label"><label for="codafteroverview">Display after 'Quick Overview'</label></td>
659
- <td class="value"><input name="codafteroverview" id="codafteroverview" value="checked" <?php if ($codafteroverview =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
660
- <td class="scope-label"></td>
661
- <td><small>&nbsp;</small></td>
662
- </tr>
663
- </table>
664
- </fieldset>
665
-
666
- </tbody>
667
- </table>
668
- </div>
669
- </div>
670
- </div>
671
- </form>
672
- <?php
673
- break;
674
- }
675
- ?>
676
-
677
- </div>
678
- </div>
679
- </div>
680
- </div>
681
- <div id="accountid_tooltip" class="hidden">
682
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/accountid.html'); ?>
683
- </div>
684
- <div id="secretkey_tooltip" class="hidden">
685
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/secretkey.html'); ?>
686
- </div>
687
- <div id="kickoffurl_tooltip" class="hidden">
688
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/kickoffurl.html'); ?>
689
- </div>
690
- <div id="enablefreshflyers_tooltip" class="hidden">
691
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/enablefreshflyers.html'); ?>
692
- </div>
693
- <div id="enablereviews_tooltip" class="hidden">
694
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/enablereviews.html'); ?>
695
- </div>
696
- <div id="getpricefromchild_tooltip" class="hidden">
697
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/getpricefromchild.html'); ?>
698
- </div>
699
- <div id="codflyerlinkimg_tooltip" class="hidden">
700
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/codflyerlinkimg.html'); ?>
701
- </div>
702
- <div id="codflyerlinkimgalt_tooltip" class="hidden">
703
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/codflyerlinkimgalt.html'); ?>
704
- </div>
705
- <div id="displayoptions_tooltip" class="hidden">
706
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/displayoptions.html'); ?>
707
- </div>
708
- <div id="datafilebackground_tooltip" class="hidden">
709
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/datafilebackground.html'); ?>
710
- </div>
711
- <div id="data_file_launch_mode_tooltip" class="hidden">
712
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/datafilelaunchmode.html'); ?>
713
- </div>
714
- <div id="cronjoburl_tooltip" class="hidden">
715
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/cronjoburl.html'); ?>
716
- </div>
717
- <div id="codoption_tooltip" class="hidden">
718
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/CoDDataFileLaunch.html'); ?>
719
- </div>
720
- <div id="manual_tooltip" class="hidden">
721
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/ManualDataFileLaunch.html'); ?>
722
- </div>
723
-
724
- <div id="waitforminute_tooltip" class="hidden">
725
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/waitforminute.html'); ?>
726
- </div>
727
- <div id="includeshortdescription_tooltip" class="hidden">
728
- <?php echo file_get_contents('http://www.catalog-on-demand.com/support/magento/shortdesc.html'); ?>
729
- </div>
730
-
731
- <script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/jquery-1.2.6.noConflict.min.js') ?>"></script>
732
- <script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/jquery.tooltip.js') ?>"></script>
733
- <script type="text/javascript">
734
- jQuery("#content a").tooltip({
735
- bodyHandler: function() {
736
- return jQuery(jQuery(this).attr("href")).html();
737
- },
738
- delay: 0,
739
- showURL: false
740
- });
741
-
742
- function start_codi_import(){
743
- codi = new Codi('<?=$post_url?>','<?=$post_url_upd?>');
744
- codi.startCodiImport();
745
- }
746
-
747
- function onBackgroundProcess(obj){
748
- var value = 0;
749
- if ( obj.checked == true )
750
- value = 1;
751
-
752
- var url = "<?php echo $post_bgprocess_check; ?>";
753
- var param = "check=" + value;
754
- new Ajax.Request(url,
755
- {
756
- method:'post',
757
- parameters: param,
758
- onSuccess: function(transport) {
759
- }
760
- });
761
-
762
- }
763
-
764
- var Codi = Class.create();
765
-
766
- Codi.prototype = {
767
- initialize: function(postUrl, postUrlUpd) {
768
-
769
- this.postUrl = postUrl; //'https://techatcost.com/purchases/ajax/';
770
- this.postUrlUpd = postUrlUpd;
771
- this.failureUrl = document.URL;
772
- // object with event message data
773
- this.objectMsg = null;
774
- // interval object
775
- this.updateTimer = null;
776
- // default shipping code. Display on errors
777
-
778
- elem = 'checkoutSteps';
779
- clickableEntity = '.head';
780
-
781
- // overwrite Accordion class method
782
- var headers = $$('#' + elem + ' .section ' + clickableEntity);
783
- headers.each(function(header) {
784
- Event.observe(header,'click',this.sectionClicked.bindAsEventListener(this));
785
- }.bind(this));
786
- },
787
- startCodiImport: function () {
788
- _this = this;
789
- var param = "is_process=";
790
- if ( jQuery('#background_process').is(':checked') == true )
791
- param += "1";
792
- else
793
- param += "0";
794
- new Ajax.Request(this.postUrl,
795
- {
796
- method:'post',
797
- parameters: param,
798
- requestTimeout: 100,
799
-
800
- onSuccess: function(transport) {
801
- var ret_msg = transport.responseText.evalJSON();
802
- var status_div = document.getElementById('codi_status_template');
803
- var v;
804
- var totalproduct=ret_msg.length;
805
- //check total products
806
- if(totalproduct==0)
807
- {
808
- status_div.innerHTML = "<p>Your test data file was not created. Please contact your administrator.</p>";
809
- }
810
- else
811
- {
812
- for (var i=0;i<ret_msg.length;i++)
813
- {
814
- //alert(ret_msg[i]);
815
- productid=ret_msg[i];
816
- var j=i+1;
817
- v=createfilenew(productid,j,totalproduct);
818
- }
819
- }
820
-
821
- if ( ret_msg.success == 1 ){
822
- status_div.innerHTML = "<p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span>&nbsp;&nbsp;&nbsp;</p>";
823
- _this.updateTimer = setInterval(function(){_this.updateEvent();}, 10000);
824
- }else if ( ret_msg.error == 1 ){
825
- status_div.innerHTML = "<p>The Magento extension was prevented from creating a file in the folder CoDDataFile. Please notify your Magento administrator.</p>";
826
- }else if ( ret_msg.exec == 1 || ret_msg.shellexec == 1 ) {
827
- status_div.innerHTML = "<p>The <strong>exec</strong> and/or <strong>shell_exec</strong> functions are disabled in your php.ini. See the line starting with <strong>'disable_functions ='</strong>. Unless you remove both <strong>'exec'</strong> and <strong>'shell_exec'</strong> from this line, you may not use the background process to create data files. This may be a problem if you have a large product database.</p>";
828
- }
829
- },
830
- onTimeout: function() {
831
- var status_div = document.getElementById('codi_status_template');
832
- status_div.innerHTML = "<p>Your test data file was not created. Please contact your administrator.</p>";
833
- },
834
- onFailure: function() {
835
- var status_div = document.getElementById('codi_status_template');
836
- status_div.innerHTML = "<p>Your test data file was not created. Please contact your administrator.</p>";
837
- }
838
- });
839
- },
840
-
841
- updateEvent: function () {
842
- _this = this;
843
- new Ajax.Request(this.postUrlUpd,
844
- {
845
- method: 'post',
846
- onSuccess: function(transport) {
847
- _this.objectMsg = transport.responseText.evalJSON();
848
-
849
- if (_this.objectMsg.canceled == 1) {
850
- _this.clearUpdateInterval();
851
- _this.objectMsg.message = 'canceled';
852
- _this.updateStatusHtml();
853
- }
854
-
855
- if (_this.objectMsg.processed == 1) {
856
- }
857
-
858
- if (_this.objectMsg.fileerror == 1) {
859
- _this.clearUpdateInterval();
860
- _this.objectMsg.message = 'fileerror';
861
- _this.updateStatusHtml();
862
- }
863
-
864
- if (_this.objectMsg.error == 1) {
865
- _this.clearUpdateInterval();
866
- _this.objectMsg.message = 'error';
867
- _this.updateStatusHtml();
868
- }
869
-
870
- if (_this.objectMsg.finished == 1) {
871
- _this.objectMsg.message = 'finished';
872
- _this.updateStatusHtml();
873
- _this.clearUpdateInterval();
874
- }
875
- },
876
- onFailure: this.ajaxFailure.bind(),
877
- });
878
- },
879
-
880
- updateStatusHtml: function(){
881
- message = this.objectMsg.message.toLowerCase();
882
- var status_div = document.getElementById('codi_status_template');
883
- var img_url = "<?php echo $this->getSkinUrl($this->__('images/codimport_yes.gif')) ?>";
884
-
885
- if ( message == 'finished' ){
886
- status_div.innerHTML="<p id='codi_status_template_button'>Your test data file was created successfully. &nbsp;<img src='" + img_url + "' /><button type='button' class='scalable add' style='margin-left:25px;' onclick='download_codi_file();' ><span>Download Data File</span></button><button type='button' class='scalable add' style='margin-left:25px;' onclick='delete_codi_file();' ><span>Delete Data File</span></button></p>";
887
- this.clearUpdateInterval();
888
- }
889
-
890
- if ( message == 'canceled' ){
891
- this.clearUpdateInterval();
892
- }
893
-
894
- if ( message == 'processed' ){
895
- }
896
-
897
- if ( message == 'fileerror' ){
898
- status_div.innerHTML="<p>Your test data file was not created. Please contact your administrator( File Error ).</p>";
899
- this.clearUpdateInterval();
900
- }
901
-
902
- if ( message == 'error' ){
903
- status_div.innerHTML="<p>Your test data file was not created. Please contact your administrator.</p>";
904
- this.clearUpdateInterval();
905
- }
906
-
907
- },
908
-
909
- ajaxFailure: function(){
910
- this.clearUpdateInterval();
911
- var status_div = document.getElementById('codi_status_template');
912
- status_div.innerHTML = "<p>Your test data file was not created. Please contact your administrator(Ajax failure).</p>";
913
- },
914
-
915
- clearUpdateInterval: function () {
916
- clearInterval(this.updateTimer);
917
- },
918
- }
919
- function download_codi_file()
920
- {
921
- window.location.href="<?php echo $download_url?>";
922
-
923
- }
924
- function delete_codi_file()
925
- {
926
- window.location.href="<?php echo $delete_codi_url?>";
927
-
928
- }
929
-
930
-
931
- function displayBlock(show,hide,hideboth)
932
- {
933
-
934
- if(hideboth=='1')
935
- {
936
- document.getElementById(show).style.display='none';
937
- document.getElementById(hide).style.display='none';
938
- document.getElementById('waitforminute').style.display='';
939
-
940
- }
941
- else
942
- {
943
- document.getElementById('waitforminute').style.display='none';
944
- document.getElementById(show).style.display='';
945
- document.getElementById(hide).style.display='none';
946
- }
947
-
948
- }
949
- function cancel_codi_import(){
950
-
951
- var url = "<?php echo $post_url_cancel; ?>";
952
- new Ajax.Request(url,
953
- {
954
- method:'post',
955
- onSuccess: function(transport) {
956
- var ret_msg = transport.responseText;
957
-
958
- if ( ret_msg ){
959
-
960
- //var text = "<a href='#datafilebackground_tooltip'><img src=\"<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>\" /></a><br />";
961
- text = "<button type='button' class='scalable add' onclick='start_codi_import()' style='margin-left:25px;' ><span>Create Data File</span></button>";
962
-
963
- var status_div = document.getElementById('codi_status_template');
964
- status_div.innerHTML = text;
965
- }
966
- }
967
- });
968
- }
969
-
970
- function makeLowercase() {
971
- document.getElementById('userid').value = document.getElementById('userid').value.toLowerCase();
972
- }
973
-
974
- function valuevalidation(value, min, max, alertbox, datatype)
975
- {
976
-
977
- with (value)
978
- {
979
- checkvalue=parseFloat(value);
980
- if (datatype)
981
- { smalldatatype=datatype.toLowerCase();
982
- if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
983
- }
984
- if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
985
- {if (alertbox!="") {alert(alertbox);} return false;}
986
- else {return true;}
987
- }
988
- }
989
-
990
- function createfilenew(productid,i,totalproduct)
991
- { var img_url = "<?php echo $this->getSkinUrl($this->__('images/codimport_yes.gif')) ?>";
992
- var r;
993
- var base = "<?php echo $basePath ?>";
994
- var status_div = document.getElementById('codi_status_template');
995
- var a = new Ajax.Request("<?php echo $newpostupdate; ?>",
996
- { asynchronous:false,
997
- method: 'post',
998
- parameters: "product="+productid+"&counter="+i+"&total="+totalproduct+"&basepath="+base,
999
- onSuccess: function(transport) {
1000
- r= transport.responseText;
1001
- if(r=='100'){
1002
- //alert(r+'create');
1003
- status_div.innerHTML="Building Hierarchy";
1004
- createfileCatalogSection();
1005
- }
1006
- else{
1007
- if(r!="error"){
1008
- status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p><p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span>&nbsp;&nbsp;&nbsp;</p>";
1009
- }
1010
- }
1011
- if(r=="error")
1012
- {
1013
- status_div.innerHTML="<p>Your test data file was not created. Please contact your administrator( File Error ).</p>";
1014
- }
1015
-
1016
- }
1017
-
1018
- //onFailure: this.ajaxFailure.bind(),
1019
- });
1020
- return r;
1021
- }
1022
- function createfileCatalogSection()
1023
- {
1024
- var img_url = "<?php echo $this->getSkinUrl($this->__('images/codimport_yes.gif')) ?>";
1025
- var r;
1026
- var base = "<?php echo $basePath ?>";
1027
- var status_div = document.getElementById('codi_status_template');
1028
- status_div.innerHTML='Building Hierarchy';
1029
- var a = new Ajax.Request("<?php echo $createCatalogSection; ?>",
1030
- { asynchronous:false,
1031
- method: 'post',
1032
- parameters: "basepath="+base,
1033
- onSuccess: function(transport) {
1034
- r= transport.responseText;
1035
- //alert(r+'section');
1036
- if(r=='100'){
1037
- t=createfileCatalogProject();
1038
- if(t=='10'){
1039
- status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p> <input class='input-text' type='text' name='zipfileurl' value='<?php echo $zipurl?>CoDMagento.zip'><br/> Your test data file was created successfully.<img src='" + img_url + "' /><button type='button' class='scalable add' style='margin-left:25px;' onclick='download_codi_file();' ><span>Download Data File</span></button><button type='button' class='scalable add' style='margin-left:25px;' onclick='delete_codi_file();' ><span>Delete Data File</span></button> ";
1040
- }
1041
-
1042
- }
1043
- else{
1044
- if(r!="error"){
1045
- status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p><p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span>&nbsp;&nbsp;&nbsp;</p>";
1046
- }
1047
- }
1048
- if(r=="0")
1049
- {
1050
- status_div.innerHTML="<p>Your test data file was not created. Please contact your administrator( File Error ).</p>";
1051
- }
1052
-
1053
- }
1054
-
1055
- //onFailure: this.ajaxFailure.bind(),
1056
- });
1057
- return r;
1058
- }
1059
-
1060
- function createfileCatalogProject()
1061
- {
1062
- var img_url = "<?php echo $this->getSkinUrl($this->__('images/codimport_yes.gif')) ?>";
1063
- var r;
1064
- var base = "<?php echo $basePath ?>";
1065
- var status_div = document.getElementById('codi_status_template');
1066
- status_div.innerHTML='Merging with Hierarchy';
1067
- var a = new Ajax.Request("<?php echo $createCatalogProject; ?>",
1068
- { asynchronous:false,
1069
- method: 'post',
1070
- parameters: "basepath="+base,
1071
- onSuccess: function(transport) {
1072
- r= transport.responseText;
1073
- if(r=='10'){
1074
- status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p> Your test data file was created successfully.<img src='" + img_url + "' /><button type='button' class='scalable add' style='margin-left:25px;' onclick='download_codi_file();' ><span>Download Data File</span></button><button type='button' class='scalable add' style='margin-left:25px;' onclick='delete_codi_file();' ><span>Delete Data File</span></button> ";
1075
-
1076
- }
1077
- else{
1078
- if(r!="error"){
1079
- status_div.innerHTML="<p id='codi_status_template_button'>"+transport.responseText+"% </p><p>A test data file is now being created. <span style='margin-left:15px;'><img src=\"<?=$this->getSkinUrl($this->__('images/codimport_run.gif'))?>\" ></span>&nbsp;&nbsp;&nbsp;</p>";
1080
- }
1081
- }
1082
- if(r=="error")
1083
- {
1084
- status_div.innerHTML="<p>Your test data file was not created. Please contact your administrator( File Error ).</p>";
1085
- }
1086
-
1087
- }
1088
-
1089
- //onFailure: this.ajaxFailure.bind(),
1090
- });
1091
- return r;
1092
- }
1093
-
1094
-
1095
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/default/default/template/catalog/product/view.phtml DELETED
@@ -1,203 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
-
27
- /**
28
- * Product view template
29
- *
30
- * @see Mage_Catalog_Block_Product_View
31
- * @see Mage_Review_Block_Product_View
32
- */
33
- ?>
34
- <?php $_helper = $this->helper('catalog/output'); ?>
35
- <?php $_product = $this->getProduct();?>
36
-
37
- <?php
38
- //Catalog-on-Demand
39
-
40
- if ( Mage::getStoreConfig('codi/codi/codflyerlinkimg') =='Custom')
41
- $codflyerlinkimgurl = Mage::getStoreConfig('codi/codi/codflyerlinkimgurl');
42
- else
43
- $codflyerlinkimgurl = 'http://www.catalog-on-demand.com/print-catalog.png';
44
-
45
- $enablefreshflyers = Mage::getStoreConfig('codi/codi/enablefreshflyers');
46
-
47
- /*$flyerlink = '<a target="_blank" href="http://catalog-on-demand.com/PDF-e-Link/?FlyerA&AID=' . Mage::getStoreConfig('codi/codi/codusername'). '|' . urlencode($_product->getId() . '#$#' . $_product->getName()) . '">'. '<img id="codflyerlinkimgalt" title="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" alt="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" src="' . $codflyerlinkimgurl . '">'. '</a>';*/
48
-
49
- //Change on 5-Dec-2011
50
-
51
- $flyerlink = '<a target="_blank" href="http://www.catalog-on-demand.com/PDF-e-Link/?AID=' . Mage::getStoreConfig('codi/codi/codusername'). '|' . urlencode($_product->getId()) . '">'. '<img id="codflyerlinkimgalt" title="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" alt="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" src="' . $codflyerlinkimgurl . '">'. '</a>';
52
-
53
- //Catalog-on-Demand
54
- ?>
55
-
56
-
57
- <script type="text/javascript">
58
- var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
59
- </script>
60
- <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
61
- <div class="product-view">
62
- <div class="product-essential">
63
- <form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
64
- <div class="no-display">
65
- <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
66
- <input type="hidden" name="related_product" id="related-products-field" value="" />
67
- </div>
68
-
69
- <div class="product-shop">
70
- <div class="product-name">
71
- <h1>
72
- <!--Catalog-on-Demand-->
73
- <?php if(Mage::getStoreConfig('codi/codi/codbeforename')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
74
- <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
75
- <?php if(Mage::getStoreConfig('codi/codi/codaftername')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
76
- <!--Catalog-on-Demand-->
77
- </h1>
78
- </div>
79
-
80
- <?php if ($this->canEmailToFriend()): ?>
81
- <p class="email-friend">
82
- <!--Catalog-on-Demand-->
83
- <?php if(Mage::getStoreConfig('codi/codi/codbeforeemailto')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
84
- <a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a>
85
- <?php if(Mage::getStoreConfig('codi/codi/codafteremailto')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
86
- <!--Catalog-on-Demand-->
87
- </p>
88
- <?php endif; ?>
89
-
90
- <?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
91
- <?php echo $this->getChildHtml('alert_urls') ?>
92
- <?php echo $this->getChildHtml('product_type_data') ?>
93
- <?php echo $this->getTierPriceHtml() ?>
94
- <?php echo $this->getChildHtml('extrahint') ?>
95
-
96
- <?php if (!$this->hasOptions()):?>
97
- <div class="add-to-box">
98
- <?php if($_product->isSaleable()): ?>
99
- <?php echo $this->getChildHtml('addtocart') ?>
100
- <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
101
- <span class="or">
102
- <!--Catalog-on-Demand-->
103
- <?php if(Mage::getStoreConfig('codi/codi/codbeforeOR')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
104
- <?php echo $this->__('OR') ?>
105
- <?php if(Mage::getStoreConfig('codi/codi/codafterOR')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
106
- <!--Catalog-on-Demand-->
107
- </span>
108
- <?php endif; ?>
109
- <?php endif; ?>
110
- <?php echo $this->getChildHtml('addto') ?>
111
- </div>
112
- <?php echo $this->getChildHtml('extra_buttons') ?>
113
- <?php endif; ?>
114
-
115
- <?php if ($_product->getShortDescription()):?>
116
- <div class="short-description">
117
- <h2>
118
- <!--Catalog-on-Demand-->
119
- <?php if(Mage::getStoreConfig('codi/codi/codbeforeoverview')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
120
- <?php echo $this->__('Quick Overview') ?>
121
- <?php if(Mage::getStoreConfig('codi/codi/codafteroverview')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
122
- <!--Catalog-on-Demand-->
123
- </h2>
124
- <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
125
- </div>
126
- <?php endif;?>
127
-
128
- <?php echo $this->getChildHtml('other');?>
129
-
130
- <?php if ($_product->isSaleable() && $this->hasOptions()):?>
131
- <?php echo $this->getChildChildHtml('container1', '', true, true) ?>
132
- <?php endif;?>
133
-
134
- </div>
135
-
136
- <div class="product-img-box">
137
- <?php echo $this->getChildHtml('media') ?>
138
- </div>
139
-
140
- <div class="clearer"></div>
141
- <?php if ($_product->isSaleable() && $this->hasOptions()):?>
142
- <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
143
- <?php endif;?>
144
- </form>
145
- <script type="text/javascript">
146
- //<![CDATA[
147
- var productAddToCartForm = new VarienForm('product_addtocart_form');
148
- productAddToCartForm.submit = function(button, url) {
149
- if (this.validator.validate()) {
150
- var form = this.form;
151
- var oldUrl = form.action;
152
-
153
- if (url) {
154
- form.action = url;
155
- }
156
- var e = null;
157
- try {
158
- this.form.submit();
159
- } catch (e) {
160
- }
161
- this.form.action = oldUrl;
162
- if (e) {
163
- throw e;
164
- }
165
-
166
- if (button && button != 'undefined') {
167
- button.disabled = true;
168
- }
169
- }
170
- }.bind(productAddToCartForm);
171
-
172
- productAddToCartForm.submitLight = function(button, url){
173
- if(this.validator) {
174
- var nv = Validation.methods;
175
- delete Validation.methods['required-entry'];
176
- delete Validation.methods['validate-one-required'];
177
- delete Validation.methods['validate-one-required-by-name'];
178
- if (this.validator.validate()) {
179
- if (url) {
180
- this.form.action = url;
181
- }
182
- this.form.submit();
183
- }
184
- Object.extend(Validation.methods, nv);
185
- }
186
- }.bind(productAddToCartForm);
187
- //]]>
188
- </script>
189
- </div>
190
-
191
- <div class="product-collateral">
192
- <?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
193
- <div class="box-collateral <?php echo "box-{$alias}"?>">
194
- <?php if ($title = $this->getChildData($alias, 'title')):?>
195
- <h2><?php echo $this->escapeHtml($title); ?></h2>
196
- <?php endif;?>
197
- <?php echo $html; ?>
198
- </div>
199
- <?php endforeach;?>
200
- <?php echo $this->getChildHtml('upsell_products') ?>
201
- <?php echo $this->getChildHtml('product_additional_data') ?>
202
- </div>
203
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/{Mage_Codi.xml → Mage_CodiScript.xml} RENAMED
@@ -1,9 +1,9 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
- <Mage_Codi>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- </Mage_Codi>
8
  </modules>
9
  </config>
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
+ <Mage_CodiScript>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ </Mage_CodiScript>
8
  </modules>
9
  </config>
app/locale/en_US/Mage_CodiScript.csv ADDED
@@ -0,0 +1 @@
 
1
+ "Use Valide Symbols","Allowed Characters A-Z a-z 0-9 <br/>Special Chars: ` ~ @ # % ^ & * ( ) – _ = + [ ] { } \ | ; : ' "" , . < > / ?"
js/codi/password_validation.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ Validation.add('validate-codi-password', 'Please enter valid password.', function (v,elm) {
2
+ var expr = /^[A-Za-z0-9`~@#%\^&\*\(\)–_=\+\[\]\{\}\\|;:'",\.\<\>/\?]+$/;
3
+ if(expr.test(elm.value)){
4
+ return true;
5
+ }
6
+ return false
7
+ });
js/jquery/jquery-1.2.6.noConflict.min.js DELETED
@@ -1,34 +0,0 @@
1
- /*
2
- * jQuery 1.2.6 - New Wave Javascript
3
- *
4
- * Copyright (c) 2008 John Resig (jquery.com)
5
- * Dual licensed under the MIT (MIT-LICENSE.txt)
6
- * and GPL (GPL-LICENSE.txt) licenses.
7
- *
8
- * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
9
- * $Rev: 5685 $
10
- */
11
- (function(){var _jQuery=window.jQuery,_$=window.$;var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);};var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3])return jQuery().find(selector);return jQuery(elem);}selector=[];}}else
12
- return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(jQuery.makeArray(selector));},jquery:"1.2.6",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value===undefined)return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else
13
- return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else
14
- selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=='string'?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)return value;values.push(value);}}return values;}else
15
- return(this[0].value||"").replace(/\r/g,"");}return undefined;}if(value.constructor==Number)value+='';return this.each(function(){if(this.nodeType!=1)return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else
16
- this.value=value;});},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else
17
- return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script"))scripts=scripts.add(elem);else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
18
- jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}function now(){return+new Date;}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==i){target=this;--i;}for(;i<length;i++)if((options=arguments[i])!=null)for(var name in options){var src=target[name],copy=options[name];if(target===copy)continue;if(deep&&copy&&typeof copy=="object"&&!copy.nodeType)target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)target[name]=copy;}return target;};var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)script.text=data;else
19
- script.appendChild(document.createTextNode(data));head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])jQuery.cache[id]={};if(data!==undefined)jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])break;if(!name)jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)elem.removeAttribute(expando);}delete jQuery.cache[id];}},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length==undefined){for(name in object)if(callback.apply(object[name],args)===false)break;}else
20
- for(;i<length;)if(callback.apply(object[i++],args)===false)break;}else{if(length==undefined){for(name in object)if(callback.call(object[name],name,object[name])===false)break;}else
21
- for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else
22
- jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;function color(elem){if(!jQuery.browser.safari)return false;var ret=defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=style.outline;style.outline="0 solid black";style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&style&&style[name])ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle&&!color(elem))ret=computedStyle.getPropertyValue(name);else{var swap=[],stack=[],a=elem,i=0;for(;a&&color(a);a=a.parentNode)stack.unshift(a);for(;i<stack.length;i++)if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";for(i=0;i<swap.length;i++)if(swap[i]!=null)stack[i].style.display=swap[i];}if(name=="opacity"&&ret=="")ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)return;if(elem.constructor==Number)elem+='';if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
23
- ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&&notxml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else
24
- while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)if(array[i]===elem)return i;return-1;},merge:function(first,second){var i=0,elem,pos=first.length;if(jQuery.browser.msie){while(elem=second[i++])if(elem.nodeType!=8)first[pos++]=elem;}else
25
- while(elem=second[i++])first[pos++]=elem;return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)if(!inv!=!callback(elems[i],i))ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!=null)ret[ret.length]=value;}return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return i<m[3]-0;},gt:function(a,i,m){return i>m[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}if(m=="+")break;}}ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}if(m[1]==".")r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}r=tmp;}ret=r;}t=t.replace(re2,"");}}if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}if(t)ret=[];if(ret&&context==ret[0])ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)if(n.nodeType==1)n.nodeIndex=c++;merge[id]=true;}var add=false;if(first==0){if(node.nodeIndex==last)add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
26
- for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i<args.length)jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else
27
- jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}if(numStyles===undefined)numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}jQuery.ready();})();}jQuery.event.add(window,"load",jQuery.ready);}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!='string')return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(s.username)xhr.open(type,s.url,s.async,s.username,s.password);else
28
- xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else
29
- jQuery.handleError(s,xhr,status);complete();if(s.async)xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xhr){xhr.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xhr,s]);}function complete(){if(s.complete)s.complete(xhr,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(filter)data=filter(data,type);if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
30
- for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
31
- s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return opt.complete.call(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
32
- e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.call(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(elem){type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));}return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].call(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)if(!timers[i]())timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=now();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done)this.options.complete.call(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}}});jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l,10)||0;top+=parseInt(t,10)||0;}return results;};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);};jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);};});})();
33
-
34
- jQuery.noConflict();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/jquery/jquery.tooltip.js DELETED
@@ -1,294 +0,0 @@
1
- /*
2
- * jQuery Tooltip plugin 1.3
3
- *
4
- * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
5
- * http://docs.jquery.com/Plugins/Tooltip
6
- *
7
- * Copyright (c) 2006 - 2008 Jörn Zaefferer
8
- *
9
- * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
10
- *
11
- * Dual licensed under the MIT and GPL licenses:
12
- * http://www.opensource.org/licenses/mit-license.php
13
- * http://www.gnu.org/licenses/gpl.html
14
- */
15
-
16
- ;(function($) {
17
-
18
- // the tooltip element
19
- var helper = {},
20
- // the current tooltipped element
21
- current,
22
- // the title of the current element, used for restoring
23
- title,
24
- // timeout id for delayed tooltips
25
- tID,
26
- // IE 5.5 or 6
27
- IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
28
- // flag for mouse tracking
29
- track = false;
30
-
31
- $.tooltip = {
32
- blocked: false,
33
- defaults: {
34
- delay: 200,
35
- fade: false,
36
- showURL: true,
37
- extraClass: "",
38
- top: 15,
39
- left: 15,
40
- id: "tooltip"
41
- },
42
- block: function() {
43
- $.tooltip.blocked = !$.tooltip.blocked;
44
- }
45
- };
46
-
47
- $.fn.extend({
48
- tooltip: function(settings) {
49
- settings = $.extend({}, $.tooltip.defaults, settings);
50
- createHelper(settings);
51
- return this.each(function() {
52
- $.data(this, "tooltip", settings);
53
- this.tOpacity = helper.parent.css("opacity");
54
- // copy tooltip into its own expando and remove the title
55
- this.tooltipText = this.title;
56
- $(this).removeAttr("title");
57
- // also remove alt attribute to prevent default tooltip in IE
58
- this.alt = "";
59
- })
60
- .mouseover(save)
61
- .mouseout(hide)
62
- .click(hide);
63
- },
64
- fixPNG: IE ? function() {
65
- return this.each(function () {
66
- var image = $(this).css('backgroundImage');
67
- if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
68
- image = RegExp.$1;
69
- $(this).css({
70
- 'backgroundImage': 'none',
71
- 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
72
- }).each(function () {
73
- var position = $(this).css('position');
74
- if (position != 'absolute' && position != 'relative')
75
- $(this).css('position', 'relative');
76
- });
77
- }
78
- });
79
- } : function() { return this; },
80
- unfixPNG: IE ? function() {
81
- return this.each(function () {
82
- $(this).css({'filter': '', backgroundImage: ''});
83
- });
84
- } : function() { return this; },
85
- hideWhenEmpty: function() {
86
- return this.each(function() {
87
- $(this)[ $(this).html() ? "show" : "hide" ]();
88
- });
89
- },
90
- url: function() {
91
- return this.attr('href') || this.attr('src');
92
- }
93
- });
94
-
95
- function createHelper(settings) {
96
- // there can be only one tooltip helper
97
- if( helper.parent )
98
- return;
99
- // create the helper, h3 for title, div for url
100
- helper.parent = $('<div id="' + settings.id + '"><h3></h3><div class="body"></div><div class="url"></div></div>')
101
- // add to document
102
- .appendTo(document.body)
103
- // hide it at first
104
- .hide();
105
-
106
- // apply bgiframe if available
107
- if ( $.fn.bgiframe )
108
- helper.parent.bgiframe();
109
-
110
- // save references to title and url elements
111
- helper.title = $('h3', helper.parent);
112
- helper.body = $('div.body', helper.parent);
113
- helper.url = $('div.url', helper.parent);
114
- }
115
-
116
- function settings(element) {
117
- return $.data(element, "tooltip");
118
- }
119
-
120
- // main event handler to start showing tooltips
121
- function handle(event) {
122
- // show helper, either with timeout or on instant
123
- if( settings(this).delay )
124
- tID = setTimeout(show, settings(this).delay);
125
- else
126
- show();
127
-
128
- // if selected, update the helper position when the mouse moves
129
- track = !!settings(this).track;
130
- $(document.body).bind('mousemove', update);
131
-
132
- // update at least once
133
- update(event);
134
- }
135
-
136
- // save elements title before the tooltip is displayed
137
- function save() {
138
- // if this is the current source, or it has no title (occurs with click event), stop
139
- if ( $.tooltip.blocked || this == current || (!this.tooltipText && !settings(this).bodyHandler) )
140
- return;
141
-
142
- // save current
143
- current = this;
144
- title = this.tooltipText;
145
-
146
- if ( settings(this).bodyHandler ) {
147
- helper.title.hide();
148
- var bodyContent = settings(this).bodyHandler.call(this);
149
- if (bodyContent.nodeType || bodyContent.jquery) {
150
- helper.body.empty().append(bodyContent)
151
- } else {
152
- helper.body.html( bodyContent );
153
- }
154
- helper.body.show();
155
- } else if ( settings(this).showBody ) {
156
- var parts = title.split(settings(this).showBody);
157
- helper.title.html(parts.shift()).show();
158
- helper.body.empty();
159
- for(var i = 0, part; (part = parts[i]); i++) {
160
- if(i > 0)
161
- helper.body.append("<br/>");
162
- helper.body.append(part);
163
- }
164
- helper.body.hideWhenEmpty();
165
- } else {
166
- helper.title.html(title).show();
167
- helper.body.hide();
168
- }
169
-
170
- // if element has href or src, add and show it, otherwise hide it
171
- if( settings(this).showURL && $(this).url() )
172
- helper.url.html( $(this).url().replace('http://', '') ).show();
173
- else
174
- helper.url.hide();
175
-
176
- // add an optional class for this tip
177
- helper.parent.addClass(settings(this).extraClass);
178
-
179
- // fix PNG background for IE
180
- if (settings(this).fixPNG )
181
- helper.parent.fixPNG();
182
-
183
- handle.apply(this, arguments);
184
- }
185
-
186
- // delete timeout and show helper
187
- function show() {
188
- tID = null;
189
- if ((!IE || !$.fn.bgiframe) && settings(current).fade) {
190
- if (helper.parent.is(":animated"))
191
- helper.parent.stop().show().fadeTo(settings(current).fade, current.tOpacity);
192
- else
193
- helper.parent.is(':visible') ? helper.parent.fadeTo(settings(current).fade, current.tOpacity) : helper.parent.fadeIn(settings(current).fade);
194
- } else {
195
- helper.parent.show();
196
- }
197
- update();
198
- }
199
-
200
- /**
201
- * callback for mousemove
202
- * updates the helper position
203
- * removes itself when no current element
204
- */
205
- function update(event) {
206
- if($.tooltip.blocked)
207
- return;
208
-
209
- if (event && event.target.tagName == "OPTION") {
210
- return;
211
- }
212
-
213
- // stop updating when tracking is disabled and the tooltip is visible
214
- if ( !track && helper.parent.is(":visible")) {
215
- $(document.body).unbind('mousemove', update)
216
- }
217
-
218
- // if no current element is available, remove this listener
219
- if( current == null ) {
220
- $(document.body).unbind('mousemove', update);
221
- return;
222
- }
223
-
224
- // remove position helper classes
225
- helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");
226
-
227
- var left = helper.parent[0].offsetLeft;
228
- var top = helper.parent[0].offsetTop;
229
- if (event) {
230
- // position the helper 15 pixel to bottom right, starting from mouse position
231
- left = event.pageX + settings(current).left;
232
- top = event.pageY + settings(current).top;
233
- var right='auto';
234
- if (settings(current).positionLeft) {
235
- right = $(window).width() - left;
236
- left = 'auto';
237
- }
238
- helper.parent.css({
239
- left: left,
240
- right: right,
241
- top: top
242
- });
243
- }
244
-
245
- var v = viewport(),
246
- h = helper.parent[0];
247
- // check horizontal position
248
- if (v.x + v.cx < h.offsetLeft + h.offsetWidth) {
249
- left -= h.offsetWidth + 20 + settings(current).left;
250
- helper.parent.css({left: left + 'px'}).addClass("viewport-right");
251
- }
252
- // check vertical position
253
- if (v.y + v.cy < h.offsetTop + h.offsetHeight) {
254
- top -= h.offsetHeight + 20 + settings(current).top;
255
- helper.parent.css({top: top + 'px'}).addClass("viewport-bottom");
256
- }
257
- }
258
-
259
- function viewport() {
260
- return {
261
- x: $(window).scrollLeft(),
262
- y: $(window).scrollTop(),
263
- cx: $(window).width(),
264
- cy: $(window).height()
265
- };
266
- }
267
-
268
- // hide helper and restore added classes and the title
269
- function hide(event) {
270
- if($.tooltip.blocked)
271
- return;
272
- // clear timeout if possible
273
- if(tID)
274
- clearTimeout(tID);
275
- // no more current element
276
- current = null;
277
-
278
- var tsettings = settings(this);
279
- function complete() {
280
- helper.parent.removeClass( tsettings.extraClass ).hide().css("opacity", "");
281
- }
282
- if ((!IE || !$.fn.bgiframe) && tsettings.fade) {
283
- if (helper.parent.is(':animated'))
284
- helper.parent.stop().fadeTo(tsettings.fade, 0, complete);
285
- else
286
- helper.parent.stop().fadeOut(tsettings.fade, complete);
287
- } else
288
- complete();
289
-
290
- if( settings(this).fixPNG )
291
- helper.parent.unfixPNG();
292
- }
293
-
294
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Codi</name>
4
- <version>3.0.9</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Catalog-On-Demand</summary>
10
- <description>Catalog-On-Demand</description>
11
- <notes>3.0.9- Allow apostrophe and other special characters in category name</notes>
12
- <authors><author><name>catalogondemand</name><user>auto-converted</user><email>timh@catalog-on-demand.com</email></author></authors>
13
- <date>2012-04-24</date>
14
- <time>11:45:59</time>
15
- <contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="codimport_run.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/><file name="codimport_yes.gif" hash="0afb20898a704a106cb4c598868abf32"/><file name="preview_field_help.png" hash="1b1601459d25e8b1a6b1d109782078d2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="codi"><file name="index.phtml" hash="df58bb2b117412f2a61e4493596b94ca"/></dir></dir><dir name="layout"><file name="codi.xml" hash="9407985f30403744eb4e758312d62aef"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="ed36b7697b537fb4ff4100530450a832"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="jquery"><file name="jquery-1.2.6.noConflict.min.js" hash="090fdb3fbcb4727c0ca20cca87e7e12d"/><file name="jquery.tooltip.js" hash="8217c6611da6cfe45094e58485d013f0"/></dir></dir></target><target name="magecommunity"><dir name="Mage"><dir name="Codi"><dir name="Block"><dir name="Adminhtml"><file name="Menu.php" hash="ae8a9d1be49f00102911ef5fbe97c126"/><file name="Switcher.php" hash="62f36d23f039d7c21ec84b42fd0532ff"/></dir><dir name="Customer"><file name="Codi.php" hash="17c557dbcfadd336dc7ba773d6304fc0"/></dir></dir><dir name="Helper"><file name="Createzip.php" hash="03fe07641f6f3f480b1d1c47b5ab3901"/><file name="Data.php" hash="20fb4b3deed697fd80f61f6b5c36e416"/></dir><dir name="Model"><file name="Codi.php" hash="99ea40bb8dea2bea105bde3b2b8d1c82"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MenuController.php" hash="0db56a3c8d2bdd2564c8231b1efa8860"/></dir><file name="DeleteController.php" hash="8030915b46c87e5369a7c34d979873b4"/><file name="NsyncController.php" hash="d4bb9b709c9c907731d2f4e609205934"/><file name="SyncController.php" hash="ce7dfa71ab6214fbb825578ea81f55d2"/></dir><dir name="etc"><file name="config.xml" hash="72185be863584c38ffc1bc226afe89b9"/></dir><dir name="sql"><dir name="codi_setup"><file name="mysql4-install-3.0.4.php" hash="ffa1c82119aa4a56a6123dd1c5feca8f"/><file name="mysql4-install-3.0.6.php" hash="ffa1c82119aa4a56a6123dd1c5feca8f"/></dir></dir><file name="Codi_Process.php" hash="07b09ec755a1ae56c3a9f3945aa72035"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_Codi.xml" hash="5d635cd2a0d415b67f095bda0298445d"/></dir></target></contents>
16
  <compatible/>
17
- <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Codi</name>
4
+ <version>4.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Catalog-on-Demand</summary>
10
+ <description>Extension to connect to the Catalog-on-Demand service for making print catalogs, brochures, and flyers.</description>
11
+ <notes>some notes</notes>
12
+ <authors><author><name>catalogondemand</name><user>catalogondemand</user><email>timh@catalog-on-demand.com</email></author></authors>
13
+ <date>2012-11-07</date>
14
+ <time>23:47:39</time>
15
+ <contents><target name="magecommunity"><dir name="Mage"><dir name="CodiScript"><dir name="Helper"><file name="Data.php" hash="3f99660cb06a9dc09f024b9993d43a3f"/></dir><dir name="Model"><file name="Files.php" hash="4fba0c46ff1a3eaaea8b78d58a23ce2c"/></dir><dir name="controllers"><file name="IndexController.php" hash="b62d33bf331bf89be761e2271428047d"/></dir><dir name="etc"><file name="adminhtml.xml" hash="40ab0bd86928c5ba175988926a9f6aee"/><file name="config.xml" hash="b960e9bd106f0c94559baa2bc5761e18"/><file name="system.xml" hash="1b5e5b18bfdce6b85e304fb4ef877274"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_CodiScript.xml" hash="f0502cac7918fc798b3b02d3d4b7e7fd"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="codiscript.xml" hash="066f99333a6054e11943a75413f65ff0"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="codi"><file name="password_validation.js" hash="7223aeed118bb5774c73f951460ae0b0"/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Mage_CodiScript.csv" hash="183fc591065ced83f878a4c3e23f854c"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
skin/adminhtml/default/default/images/codimport_run.gif DELETED
Binary file
skin/adminhtml/default/default/images/codimport_yes.gif DELETED
Binary file
skin/adminhtml/default/default/images/preview_field_help.png DELETED
Binary file