Magento_Mobile - Version 1.7.0.0.22.1

Version Notes

1.7.0.0.22.1 version of package internal svn revision #121425

Download this release

Release Info

Developer Magento Core Team
Extension Magento_Mobile
Version 1.7.0.0.22.1
Comparing to
See all releases


Code changes from version 1.6.0.0.23.0 to 1.7.0.0.22.1

Files changed (236) hide show
  1. app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit.php +0 -71
  2. app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit/Form.php +0 -55
  3. app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit/Tab/Settings.php +0 -108
  4. app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit/Tabs.php +0 -62
  5. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Config.php +0 -68
  6. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard.php +0 -249
  7. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/BestSellers.php +0 -113
  8. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/Customers.php +0 -129
  9. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphAmountsData.php +0 -71
  10. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphDataAbstract.php +0 -350
  11. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphInfo.php +0 -160
  12. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphOrderData.php +0 -71
  13. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphTotalsData.php +0 -123
  14. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/LastOrders.php +0 -85
  15. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/LastSearchTerms.php +0 -118
  16. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/MostViewedProducts.php +0 -117
  17. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/NewCustomers.php +0 -129
  18. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/SalesInfo.php +0 -119
  19. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/StoreSwitcher.php +0 -198
  20. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/TopSearchTerms.php +0 -114
  21. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Loginform.php +0 -70
  22. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile.php +6 -2
  23. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit.php +2 -1
  24. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Submission.php +2 -1
  25. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Content.php +34 -54
  26. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Accordion.php +1 -1
  27. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Accordion/Images.php +8 -23
  28. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Images.php +0 -192
  29. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Preview.php +6 -3
  30. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/General.php +8 -8
  31. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/OfflineCatalog.php +0 -115
  32. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Payment.php +14 -2
  33. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Settings.php +14 -10
  34. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Social.php +26 -11
  35. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Submission/History.php +1 -1
  36. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tabs.php +5 -2
  37. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Addrow.php +18 -8
  38. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Color.php +2 -1
  39. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Country.php +2 -1
  40. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Datetime.php +2 -1
  41. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Font.php +5 -2
  42. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Image.php +2 -1
  43. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Page.php +6 -3
  44. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Tabs.php +6 -3
  45. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Theme.php +5 -3
  46. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Grid/Renderer/Bool.php +6 -2
  47. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Form.php +2 -1
  48. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Tab/Container/Submission.php +17 -17
  49. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Tabs.php +2 -1
  50. app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Edit.php +4 -2
  51. app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Edit/Form.php +10 -7
  52. app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Grid.php +4 -3
  53. app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Grid/Renderer/Action.php +2 -2
  54. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Edit.php +4 -5
  55. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Edit/Form.php +8 -3
  56. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Grid/Renderer/Name.php +1 -1
  57. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Preview/Form.php +2 -1
  58. app/code/core/Mage/XmlConnect/Block/Cart.php +18 -30
  59. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals.php +0 -95
  60. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Default.php +0 -93
  61. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Grandtotal.php +0 -107
  62. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Nodes/Default.php +0 -63
  63. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Nodes/Giftcardaccount.php +0 -69
  64. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Shipping.php +0 -113
  65. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Subtotal.php +0 -108
  66. app/code/core/Mage/XmlConnect/Block/Cart/Crosssell.php +6 -6
  67. app/code/core/Mage/XmlConnect/Block/Cart/Item/Renderer.php +64 -259
  68. app/code/core/Mage/XmlConnect/Block/Cart/Items.php +0 -254
  69. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Details.php +9 -5
  70. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/OrderDetails.php +0 -83
  71. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Review.php +13 -15
  72. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Shippingmethods.php +28 -104
  73. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php +4 -1
  74. app/code/core/Mage/XmlConnect/Block/Cart/Totals.php +8 -5
  75. app/code/core/Mage/XmlConnect/Block/Catalog.php +5 -59
  76. app/code/core/Mage/XmlConnect/Block/Catalog/Category.php +6 -10
  77. app/code/core/Mage/XmlConnect/Block/Catalog/Filters.php +1 -2
  78. app/code/core/Mage/XmlConnect/Block/Catalog/Product.php +25 -35
  79. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Attributes.php +1 -1
  80. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Gallery.php +14 -13
  81. app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice.php +0 -98
  82. app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice/Bundle.php +0 -426
  83. app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice/Default.php +0 -740
  84. app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice/Giftcard.php +0 -98
  85. app/code/core/Mage/XmlConnect/Block/Catalog/Product/List.php +9 -17
  86. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options.php +1 -84
  87. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Bundle.php +16 -32
  88. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Configurable.php +26 -35
  89. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Downloadable.php +0 -113
  90. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Giftcard.php +1 -0
  91. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Grouped.php +11 -11
  92. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Bundle.php +158 -140
  93. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Default.php +267 -265
  94. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Giftcard.php +7 -8
  95. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Related.php +2 -2
  96. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review.php +0 -1
  97. app/code/core/Mage/XmlConnect/Block/Catalog/Search.php +4 -4
  98. app/code/core/Mage/XmlConnect/Block/Catalog/Search/Suggest.php +0 -1
  99. app/code/core/Mage/XmlConnect/Block/Checkout/Address/Billing.php +3 -2
  100. app/code/core/Mage/XmlConnect/Block/Checkout/Address/Form.php +94 -43
  101. app/code/core/Mage/XmlConnect/Block/Checkout/Address/Shipping.php +0 -1
  102. app/code/core/Mage/XmlConnect/Block/Checkout/Agreements.php +1 -1
  103. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer.php +0 -48
  104. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Bundle.php +0 -49
  105. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Configurable.php +0 -53
  106. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Downloadable.php +0 -49
  107. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Giftcard.php +0 -49
  108. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Grouped.php +0 -52
  109. app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Address.php +0 -69
  110. app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Address/Form.php +0 -114
  111. app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Address/List.php +0 -112
  112. app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Review.php +0 -64
  113. app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review/Info.php +18 -28
  114. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Ccsave.php +3 -3
  115. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Ccsave.php +2 -2
  116. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Checkmo.php +3 -1
  117. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Paypal/Abstract.php +7 -4
  118. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Pbridge/Verisign.php +5 -3
  119. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/List.php +60 -119
  120. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/ListApi23.php +0 -133
  121. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Paypal/Payflow.php +9 -9
  122. app/code/core/Mage/XmlConnect/Block/Checkout/Pbridge/Result.php +1 -1
  123. app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Available.php +16 -17
  124. app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/AvailableList.php +0 -82
  125. app/code/core/Mage/XmlConnect/Block/Configuration.php +20 -39
  126. app/code/core/Mage/XmlConnect/Block/Customer/Address/Form.php +78 -45
  127. app/code/core/Mage/XmlConnect/Block/Customer/Address/List.php +12 -12
  128. app/code/core/Mage/XmlConnect/Block/Customer/Downloads.php +0 -80
  129. app/code/core/Mage/XmlConnect/Block/Customer/Form.php +47 -150
  130. app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Date.php +14 -16
  131. app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Text.php +4 -5
  132. app/code/core/Mage/XmlConnect/Block/Customer/Order/Details.php +13 -10
  133. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Bundle.php +11 -142
  134. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Default.php +0 -73
  135. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Downloadable.php +13 -84
  136. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Giftcard.php +2 -2
  137. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Grouped.php +3 -5
  138. app/code/core/Mage/XmlConnect/Block/Customer/Order/Items.php +2 -1
  139. app/code/core/Mage/XmlConnect/Block/Customer/Order/List.php +15 -13
  140. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals.php +10 -60
  141. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance.php +1 -25
  142. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance/Refunded.php +3 -25
  143. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Giftcards.php +5 -39
  144. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Tax.php +3 -44
  145. app/code/core/Mage/XmlConnect/Block/Customer/Storecredit.php +1 -1
  146. app/code/core/Mage/XmlConnect/Block/Home.php +3 -5
  147. app/code/core/Mage/XmlConnect/Block/Homebanners.php +0 -156
  148. app/code/core/Mage/XmlConnect/Block/Localization.php +0 -55
  149. app/code/core/Mage/XmlConnect/Block/Review/Form.php +1 -2
  150. app/code/core/Mage/XmlConnect/Block/ShoppingCart.php +0 -108
  151. app/code/core/Mage/XmlConnect/Block/Wishlist.php +5 -6
  152. app/code/core/Mage/XmlConnect/Controller/Action.php +11 -36
  153. app/code/core/Mage/XmlConnect/Controller/AdminAction.php +0 -192
  154. app/code/core/Mage/XmlConnect/Helper/AdminApplication.php +0 -134
  155. app/code/core/Mage/XmlConnect/Helper/Adminhtml/Dashboard/Order.php +0 -68
  156. app/code/core/Mage/XmlConnect/Helper/Android.php +64 -42
  157. app/code/core/Mage/XmlConnect/Helper/Catalog/Category/Image.php +4 -58
  158. app/code/core/Mage/XmlConnect/Helper/Catalog/Product/Image.php +0 -46
  159. app/code/core/Mage/XmlConnect/Helper/Customer/Form/Renderer.php +0 -178
  160. app/code/core/Mage/XmlConnect/Helper/Customer/Order.php +31 -193
  161. app/code/core/Mage/XmlConnect/Helper/Data.php +32 -127
  162. app/code/core/Mage/XmlConnect/Helper/Device/Abstract.php +0 -309
  163. app/code/core/Mage/XmlConnect/Helper/Image.php +22 -49
  164. app/code/core/Mage/XmlConnect/Helper/Ipad.php +112 -65
  165. app/code/core/Mage/XmlConnect/Helper/Iphone.php +204 -39
  166. app/code/core/Mage/XmlConnect/Helper/OfflineCatalog.php +0 -307
  167. app/code/core/Mage/XmlConnect/Helper/Theme.php +8 -49
  168. app/code/core/Mage/XmlConnect/Helper/Translate.php +0 -514
  169. app/code/core/Mage/XmlConnect/Model/Adminhtml/Search/Catalog.php +0 -71
  170. app/code/core/Mage/XmlConnect/Model/Adminhtml/Search/Category.php +0 -70
  171. app/code/core/Mage/XmlConnect/Model/Adminhtml/System/Config/Backend/Currency/Default.php +1 -1
  172. app/code/core/Mage/XmlConnect/Model/Application.php +76 -194
  173. app/code/core/Mage/XmlConnect/Model/Catalog/Category/Image.php +11 -28
  174. app/code/core/Mage/XmlConnect/Model/ConfigData.php +9 -121
  175. app/code/core/Mage/XmlConnect/Model/Configuration.php +0 -271
  176. app/code/core/Mage/XmlConnect/Model/Device/Abstract.php +0 -179
  177. app/code/core/Mage/XmlConnect/Model/Device/Android.php +0 -111
  178. app/code/core/Mage/XmlConnect/Model/Device/Ipad.php +0 -174
  179. app/code/core/Mage/XmlConnect/Model/Device/Iphone.php +0 -117
  180. app/code/core/Mage/XmlConnect/Model/ImageAction.php +0 -321
  181. app/code/core/Mage/XmlConnect/Model/ImageLimits.php +0 -366
  182. app/code/core/Mage/XmlConnect/Model/ImageLimits/Abstract.php +0 -295
  183. app/code/core/Mage/XmlConnect/Model/Images.php +0 -551
  184. app/code/core/Mage/XmlConnect/Model/Observer.php +7 -77
  185. app/code/core/Mage/XmlConnect/Model/OfflineCatalog.php +0 -117
  186. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Abstract.php +0 -66
  187. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Category.php +0 -120
  188. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Category/Category.php +0 -61
  189. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Category/IndexCategory.php +0 -61
  190. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Config.php +0 -77
  191. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Home.php +0 -61
  192. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Homebanners.php +0 -61
  193. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Product.php +0 -111
  194. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Product/Gallery.php +0 -61
  195. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Product/Product.php +0 -61
  196. app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Product/Review.php +0 -61
  197. app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Config.php +0 -15
  198. app/code/core/Mage/XmlConnect/Model/Paypal/Mecl/Checkout.php +0 -24
  199. app/code/core/Mage/XmlConnect/Model/Preview/Abstract.php +5 -57
  200. app/code/core/Mage/XmlConnect/Model/Preview/Android.php +6 -13
  201. app/code/core/Mage/XmlConnect/Model/Preview/Ipad.php +44 -49
  202. app/code/core/Mage/XmlConnect/Model/Preview/Iphone.php +5 -14
  203. app/code/core/Mage/XmlConnect/Model/Queue.php +2 -31
  204. app/code/core/Mage/XmlConnect/Model/Resource/Application.php +1 -17
  205. app/code/core/Mage/XmlConnect/Model/Resource/CategorySearch/Collection.php +0 -120
  206. app/code/core/Mage/XmlConnect/Model/Resource/ConfigData.php +3 -3
  207. app/code/core/Mage/XmlConnect/Model/Resource/ConfigData/Collection.php +3 -1
  208. app/code/core/Mage/XmlConnect/Model/Resource/Filter/Collection.php +1 -0
  209. app/code/core/Mage/XmlConnect/Model/Resource/Images.php +0 -89
  210. app/code/core/Mage/XmlConnect/Model/Resource/Images/Collection.php +0 -91
  211. app/code/core/Mage/XmlConnect/Model/Simplexml/Element.php +2 -2
  212. app/code/core/Mage/XmlConnect/Model/Simplexml/Form.php +1 -25
  213. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Abstract.php +1 -1
  214. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Abstract.php +3 -9
  215. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/CountryListSelect.php +18 -45
  216. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Custom.php +0 -71
  217. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Date.php +2 -1
  218. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Email.php +2 -1
  219. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Fieldset.php +0 -2
  220. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/File.php +2 -1
  221. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Image.php +2 -1
  222. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Multiline.php +4 -1
  223. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Multiselect.php +5 -1
  224. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Password.php +0 -47
  225. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Select.php +13 -4
  226. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Text.php +2 -1
  227. app/code/core/Mage/XmlConnect/Model/Simplexml/Message.php +0 -267
  228. app/code/core/Mage/XmlConnect/Model/Simplexml/Message/Abstract.php +0 -142
  229. app/code/core/Mage/XmlConnect/Model/Simplexml/Message/Error.php +0 -125
  230. app/code/core/Mage/XmlConnect/Model/Simplexml/Message/Success.php +0 -56
  231. app/code/core/Mage/XmlConnect/Model/Theme.php +5 -6
  232. app/code/core/Mage/XmlConnect/controllers/Adminhtml/Admin/ApplicationController.php +0 -69
  233. app/code/core/Mage/XmlConnect/controllers/Adminhtml/Connect/ConfigController.php +0 -126
  234. app/code/core/Mage/XmlConnect/controllers/Adminhtml/Connect/DashboardController.php +0 -55
  235. app/code/core/Mage/XmlConnect/controllers/Adminhtml/Connect/UserController.php +0 -165
  236. app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php +72 -274
app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit.php DELETED
@@ -1,71 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect edit admin application settings block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Admin_Application_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
35
- {
36
- /**
37
- * Setting action buttons for admin application settings
38
- */
39
- public function __construct()
40
- {
41
- $this->_objectId = 'id';
42
- $this->_controller = 'adminhtml_admin_application';
43
- $this->_blockGroup = 'xmlconnect';
44
- parent::__construct();
45
-
46
- $this->_removeButton('back');
47
- $this->_removeButton('reset');
48
- $this->_removeButton('delete');
49
- }
50
-
51
- /**
52
- * Get header text
53
- *
54
- * @return string
55
- */
56
- public function getHeaderText()
57
- {
58
- return $this->__('Admin Application Settings');
59
- }
60
-
61
- /**
62
- * Check permission for passed action
63
- *
64
- * @param string $action
65
- * @return bool
66
- */
67
- protected function _isAllowedAction($action)
68
- {
69
- return true;
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit/Form.php DELETED
@@ -1,55 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin application form block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Admin_Application_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
35
- {
36
- /**
37
- * Prepare form before rendering HTML
38
- * Setting Form Fieldsets and fields
39
- *
40
- * @return Mage_Adminhtml_Block_Widget_Form
41
- */
42
- protected function _prepareForm()
43
- {
44
- /** @var $form Varien_Data_Form */
45
- $form = Mage::getModel('varien/data_form', array(
46
- 'id' => 'edit_form',
47
- 'action' => $this->getUrl('*/admin_application', array('_current' => true)),
48
- 'method' => 'post'
49
- ));
50
-
51
- $form->setUseContainer(true);
52
- $this->setForm($form);
53
- return parent::_prepareForm();
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit/Tab/Settings.php DELETED
@@ -1,108 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Tab for Settings Management
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Admin_Application_Edit_Tab_Settings
35
- extends Mage_Adminhtml_Block_Widget_Form
36
- implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
- {
38
- /**
39
- * Prepare form before rendering HTML
40
- * Setting Form Fieldsets and fields
41
- *
42
- * @return Mage_Adminhtml_Block_Widget_Form
43
- */
44
- protected function _prepareForm()
45
- {
46
- /** @var $form Varien_Data_Form */
47
- $form = Mage::getModel('varien/data_form', array(
48
- 'id' => 'edit_form',
49
- 'action' => $this->getUrl('*/admin_application', array('_current' => true)),
50
- 'method' => 'post'
51
- ));
52
-
53
- $form->setHtmlIdPrefix('admin_app_');
54
- $fieldset = $form->addFieldset('base_fieldset', array('legend' => $this->__('Admin Application Settings')));
55
-
56
- $fieldset->addField('type', 'select', array(
57
- 'name' => 'is_active',
58
- 'label' => $this->__('Enable Admin Application'),
59
- 'title' => $this->__('Enable Admin Application'),
60
- 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
61
- 'required' => true,
62
- 'value' => (int)Mage::getSingleton('xmlconnect/configuration')->isActiveAdminApp()
63
- ));
64
-
65
- $this->setForm($form);
66
- return parent::_prepareForm();
67
- }
68
-
69
- /**
70
- * Tab label getter
71
- *
72
- * @return string
73
- */
74
- public function getTabLabel()
75
- {
76
- return $this->__('Settings');
77
- }
78
-
79
- /**
80
- * Tab title getter
81
- *
82
- * @return string
83
- */
84
- public function getTabTitle()
85
- {
86
- return $this->__('Settings');
87
- }
88
-
89
- /**
90
- * Check if tab can be shown
91
- *
92
- * @return bool
93
- */
94
- public function canShowTab()
95
- {
96
- return true;
97
- }
98
-
99
- /**
100
- * Check if tab hidden
101
- *
102
- * @return bool
103
- */
104
- public function isHidden()
105
- {
106
- return false;
107
- }
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit/Tabs.php DELETED
@@ -1,62 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin Application Settings Tabs block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Admin_Application_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35
- {
36
- /**
37
- * Setting tab id, DOM destination element id, title
38
- */
39
- public function __construct()
40
- {
41
- parent::__construct();
42
- $this->setId('admin_application_app_tabs');
43
- $this->setDestElementId('edit_form');
44
- $this->setTitle($this->__('Admin Mobile Application'));
45
- }
46
-
47
- /**
48
- * Preparing global layout
49
- *
50
- * @return Mage_Core_Block_Abstract
51
- */
52
- protected function _prepareLayout()
53
- {
54
- $this->addTab('set', array(
55
- 'label' => $this->__('Settings'),
56
- 'content' => $this->getLayout()->createBlock('xmlconnect/adminhtml_admin_application_edit_tab_settings')
57
- ->toHtml(),
58
- 'active' => true
59
- ));
60
- return parent::_prepareLayout();
61
- }
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Config.php DELETED
@@ -1,68 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin application config renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Config extends Mage_Core_Block_Abstract
35
- {
36
- /**
37
- * Render login form xml
38
- *
39
- * @return string
40
- */
41
- protected function _toHtml()
42
- {
43
- /** @var Mage_XmlConnect_Model_Simplexml_Element $configXmlObj */
44
- $configXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<configuration></configuration>');
45
- $this->_addLocalization($configXmlObj);
46
- $configXmlObj->addCustomChild('xmlconnect_version', Mage::getConfig()->getNode(
47
- Mage_XmlConnect_Model_Application::XML_PATH_MODULE_VERSION
48
- ));
49
-
50
- return $configXmlObj->asNiceXml();
51
- }
52
-
53
- /**
54
- * Add localization data to xml object
55
- *
56
- * @param Mage_XmlConnect_Model_Simplexml_Element $xml
57
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Config
58
- */
59
- protected function _addLocalization(Mage_XmlConnect_Model_Simplexml_Element $xml)
60
- {
61
- /** @var $translateHelper Mage_XmlConnect_Helper_Translate */
62
- $translateHelper = Mage::helper('xmlconnect/translate');
63
- $xml->addCustomChild('localization', $this->getUrl('*/*/localization'), array(
64
- 'hash' => sha1(serialize($translateHelper->getLocalizationArray()))
65
- ));
66
- return $this;
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard.php DELETED
@@ -1,249 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin application dashboard renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard extends Mage_Core_Block_Abstract
35
- {
36
- /**
37
- * Simple xml object
38
- *
39
- * @var Mage_XmlConnect_Model_Simplexml_Element
40
- */
41
- protected $_xmlObject;
42
-
43
- /**
44
- * Render dashboard xml
45
- *
46
- * @return string
47
- */
48
- protected function _toHtml()
49
- {
50
- return $this->setXmlObject(Mage::getModel('xmlconnect/simplexml_element', '<dashboard></dashboard>'))
51
- ->_addStoreSwitcher()->_addSalesInfo()->_addGraphInfo()->_addDashboardFormData()->getXmlObject()
52
- ->asNiceXml();
53
- }
54
-
55
- /**
56
- * Add store switcher xml
57
- *
58
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
59
- */
60
- protected function _addStoreSwitcher()
61
- {
62
- $this->getChild('store_switcher')->addSwitcherToXmlObj($this->getXmlObject());
63
- return $this;
64
- }
65
-
66
- /**
67
- * Add sales info
68
- *
69
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
70
- */
71
- protected function _addSalesInfo()
72
- {
73
- $this->getChild('sales_info')->addSalesInfoToXmlObj($this->getXmlObject());
74
- return $this;
75
- }
76
-
77
- /**
78
- * Add graph info to xml object
79
- *
80
- * Add orders and amounts info to show diagram by selected range in application
81
- *
82
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
83
- */
84
- protected function _addGraphInfo()
85
- {
86
- $this->getChild('graph_info')->addGraphInfoToXmlObj($this->getXmlObject());
87
- return $this;
88
- }
89
-
90
- /**
91
- * Add dashboard form data
92
- *
93
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
94
- */
95
- protected function _addDashboardFormData()
96
- {
97
- /** @var Mage_XmlConnect_Model_Simplexml_Form $fromXmlObj */
98
- $fromXmlObj = Mage::getModel('xmlconnect/simplexml_form', array(
99
- 'xml_id' => 'dashboard_form', 'action' => '', 'use_container' => true
100
- ));
101
-
102
- $recentActivityFieldset = $fromXmlObj->addFieldset('recent_activity', array(
103
- 'title' => $this->__('Recent Activity')
104
- ));
105
-
106
- $this->_addLastOrders($recentActivityFieldset)->_addLastSearchTerms($recentActivityFieldset)
107
- ->_addNewCustomers($recentActivityFieldset);
108
-
109
- $overallActivityFieldset = $fromXmlObj->addFieldset('overall_activity', array(
110
- 'title' => $this->__('Overall Activity')
111
- ));
112
-
113
- $this->_addTopSearchTerms($overallActivityFieldset)->_addMostViewedProducts($overallActivityFieldset)
114
- ->_addBestSellers($overallActivityFieldset)->_addCustomers($overallActivityFieldset);
115
-
116
- $this->getXmlObject()->appendChild($fromXmlObj->toXmlObject());
117
- return $this;
118
- }
119
-
120
- /**
121
- * Add last orders info to xml object
122
- *
123
- * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $recentActivityFieldset
124
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
125
- */
126
- protected function _addLastOrders(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $recentActivityFieldset)
127
- {
128
- $lastOrdersField = $recentActivityFieldset->addField('last_orders', 'custom', array(
129
- 'label' => $this->__('Last 5 Orders')
130
- ));
131
- $this->getChild('last_orders')->addLastOrdersToXmlObj($lastOrdersField->getXmlObject());
132
- return $this;
133
- }
134
-
135
- /**
136
- * Add last search terms data
137
- *
138
- * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $recentActivityFieldset
139
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
140
- */
141
- protected function _addLastSearchTerms(
142
- Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $recentActivityFieldset
143
- ) {
144
- $lastSearchTermsField = $recentActivityFieldset->addField('last_search', 'custom', array(
145
- 'label' => $this->__('Last 5 Search Terms')
146
- ));
147
- $this->getChild('last_search_terms')->addLastSearchTermsToXmlObj($lastSearchTermsField->getXmlObject());
148
- return $this;
149
- }
150
-
151
- /**
152
- * Add new customers info to xml object
153
- *
154
- * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $recentActivityFieldset
155
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
156
- */
157
- protected function _addNewCustomers(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $recentActivityFieldset)
158
- {
159
- $newCustomersField = $recentActivityFieldset->addField('new_customers', 'custom', array(
160
- 'label' => $this->__('New Customers')
161
- ));
162
- $this->getChild('new_customers')->addNewCustomersToXmlObj($newCustomersField->getXmlObject());
163
- return $this;
164
- }
165
-
166
- /**
167
- * Add top search queries info to xml object
168
- *
169
- * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $overallActivityFieldset
170
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
171
- */
172
- protected function _addTopSearchTerms(
173
- Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $overallActivityFieldset
174
- ) {
175
- $topSearchField = $overallActivityFieldset->addField('top_search', 'custom', array(
176
- 'label' => $this->__('Top Search Terms')
177
- ));
178
- $this->getChild('top_search_terms')->addTopSearchTermsToXmlObj($topSearchField->getXmlObject());
179
- return $this;
180
- }
181
-
182
- /**
183
- * Add most viewed products to xml object
184
- *
185
- * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $overallActivityFieldset
186
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
187
- */
188
- protected function _addMostViewedProducts(
189
- Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $overallActivityFieldset
190
- ) {
191
- $mostViewedField = $overallActivityFieldset->addField('most_viewed', 'custom', array(
192
- 'label' => $this->__('Most Viewed Products')
193
- ));
194
- $this->getChild('most_viewed')->addMostViewedProductsToXmlObj($mostViewedField->getXmlObject());
195
- return $this;
196
- }
197
-
198
- /**
199
- * Add best sellers info to xml object
200
- *
201
- * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $overallActivityFieldset
202
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
203
- */
204
- protected function _addBestSellers(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $overallActivityFieldset)
205
- {
206
- $bestSellersField = $overallActivityFieldset->addField('best_sellers', 'custom', array(
207
- 'label' => $this->__('Best Sellers')
208
- ));
209
- $this->getChild('best_sellers')->addBestSellersToXmlObj($bestSellersField->getXmlObject());
210
- return $this;
211
- }
212
-
213
- /**
214
- * Add customer info to xml object
215
- *
216
- * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $overallActivityFieldset
217
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
218
- */
219
- protected function _addCustomers(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $overallActivityFieldset)
220
- {
221
- $customersField = $overallActivityFieldset->addField('customers', 'custom', array(
222
- 'label' => $this->__('Customers')
223
- ));
224
- $this->getChild('customers')->addCustomersToXmlObj($customersField->getXmlObject());
225
- return $this;
226
- }
227
-
228
- /**
229
- * Get xml object
230
- *
231
- * @return Mage_XmlConnect_Model_Simplexml_Element
232
- */
233
- public function getXmlObject()
234
- {
235
- return $this->_xmlObject;
236
- }
237
-
238
- /**
239
- * Set xml object
240
- *
241
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObject
242
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard
243
- */
244
- public function setXmlObject($xmlObject)
245
- {
246
- $this->_xmlObject = $xmlObject;
247
- return $this;
248
- }
249
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/BestSellers.php DELETED
@@ -1,113 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Best sellers products xml renderer block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_BestSellers
35
- extends Mage_Adminhtml_Block_Dashboard_Tab_Products_Ordered
36
- {
37
- /**
38
- * Best sellers count to display
39
- */
40
- const BESTSELLERS_COUNT_LIMIT = 5;
41
-
42
- /**
43
- * Get rid of unnecessary collection initialization
44
- *
45
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_BestSellers
46
- */
47
- protected function _prepareCollection()
48
- {
49
- return $this;
50
- }
51
-
52
- /**
53
- * Init last search terms collection
54
- *
55
- * @param int|null $storeId
56
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_BestSellers
57
- */
58
- protected function _initCollection($storeId)
59
- {
60
- /** @var $collection Mage_Sales_Model_Resource_Report_Bestsellers_Collection */
61
- $collection = Mage::getResourceModel('sales/report_bestsellers_collection')->setModel('catalog/product')
62
- ->addStoreFilter($storeId)->setPageSize(self::BESTSELLERS_COUNT_LIMIT);
63
- $this->setCollection($collection);
64
- return $this;
65
- }
66
-
67
- /**
68
- * Clear collection
69
- *
70
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_BestSellers
71
- */
72
- protected function _clearCollection()
73
- {
74
- $this->_collection = null;
75
- return $this;
76
- }
77
-
78
- /**
79
- * Add best sellers products to xml object
80
- *
81
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
82
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_BestSellers
83
- */
84
- public function addBestSellersToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
85
- {
86
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
87
- $this->_clearCollection()->_initCollection($storeId);
88
- $valuesXml = $xmlObj->addCustomChild('values', null, array(
89
- 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
90
- ));
91
-
92
- if(!count($this->getCollection()->getItems()) > 0) {
93
- continue;
94
- }
95
-
96
- /** @var $orderHelper Mage_XmlConnect_Helper_Adminhtml_Dashboard_Order */
97
- $orderHelper = Mage::helper('xmlconnect/adminhtml_dashboard_order');
98
-
99
- foreach ($this->getCollection()->getItems() as $item) {
100
- $itemListXml = $valuesXml->addCustomChild('item');
101
- $itemListXml->addCustomChild('name', $item->getName(), array(
102
- 'label' => Mage::helper('sales')->__('Product Name')
103
- ));
104
- $itemListXml->addCustomChild('price', $orderHelper->preparePrice($item->getProductPrice(), $storeId),
105
- array('label' => Mage::helper('sales')->__('Price')));
106
- $itemListXml->addCustomChild('qty_ordered', $item->getQtyOrdered(), array(
107
- 'label' => Mage::helper('sales')->__('Quantity Ordered')
108
- ));
109
- }
110
- }
111
- return $this;
112
- }
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/Customers.php DELETED
@@ -1,129 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Customers xml renderer block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_Customers
35
- extends Mage_Adminhtml_Block_Dashboard_Tab_Customers_Most
36
- {
37
- /**
38
- * Customers count to display
39
- */
40
- const CUSTOMERS_COUNT_LIMIT = 5;
41
-
42
- /**
43
- * Get rid of unnecessary collection initialization
44
- *
45
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_Customers
46
- */
47
- protected function _prepareCollection()
48
- {
49
- return $this;
50
- }
51
-
52
- /**
53
- * Init order collection
54
- *
55
- * @param int|null $storeId
56
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_Customers
57
- */
58
- protected function _initCollection($storeId)
59
- {
60
- /** @var $collection Mage_Reports_Model_Resource_Order_Collection */
61
- $collection = Mage::getResourceModel('reports/order_collection');
62
- $collection->groupByCustomer()->addOrdersCount()->joinCustomerName()->setPageSize(self::CUSTOMERS_COUNT_LIMIT);
63
-
64
- $storeFilter = 0;
65
- if ($storeId) {
66
- $collection->addAttributeToFilter('store_id', $storeId);
67
- $storeFilter = 1;
68
- }
69
-
70
- $collection->addSumAvgTotals($storeFilter)->orderByTotalAmount();
71
- $this->setCollection($collection);
72
- return $this;
73
- }
74
-
75
- /**
76
- * Clear collection
77
- *
78
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_Customers
79
- */
80
- protected function _clearCollection()
81
- {
82
- $this->_collection = null;
83
- return $this;
84
- }
85
-
86
- /**
87
- * Add customers statistic to xml object
88
- *
89
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
90
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_Customers
91
- */
92
- public function addCustomersToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
93
- {
94
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
95
- $this->_clearCollection()->_initCollection($storeId);
96
- $valuesXml = $xmlObj->addCustomChild('values', null, array(
97
- 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
98
- ));
99
-
100
- if(!count($this->getCollection()->getItems()) > 0) {
101
- continue;
102
- }
103
-
104
- /** @var $orderHelper Mage_XmlConnect_Helper_Adminhtml_Dashboard_Order */
105
- $orderHelper = Mage::helper('xmlconnect/adminhtml_dashboard_order');
106
-
107
- foreach ($this->getCollection()->getItems() as $item) {
108
- $itemListXml = $valuesXml->addCustomChild('item');
109
- $itemListXml->addCustomChild('name', $item->getName(), array(
110
- 'label' => $this->__('Customer Name')
111
- ));
112
- $itemListXml->addCustomChild('orders_count', $item->getOrdersCount(), array(
113
- 'label' => $this->__('Number of Orders')
114
- ));
115
- $itemListXml->addCustomChild(
116
- 'orders_avg_amount',
117
- $orderHelper->preparePrice($item->getOrdersAvgAmount(), $storeId),
118
- array('label' => $this->__('Average Order Amount'))
119
- );
120
- $itemListXml->addCustomChild(
121
- 'orders_sum_amount',
122
- $orderHelper->preparePrice($item->getOrdersSumAmount(), $storeId),
123
- array('label' => $this->__('Total Order Amount'))
124
- );
125
- }
126
- }
127
- return $this;
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphAmountsData.php DELETED
@@ -1,71 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Amounts chart data xml renderer block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphAmountsData
35
- extends Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphDataAbstract
36
- {
37
- /**
38
- * Initialize object
39
- */
40
- public function __construct()
41
- {
42
- $this->setHtmlId('amounts');
43
- parent::__construct();
44
- }
45
-
46
- /**
47
- * Prepare chart data
48
- *
49
- * @return null
50
- */
51
- protected function _prepareData()
52
- {
53
- $this->setDataHelperName('xmlconnect/adminhtml_dashboard_order');
54
- $this->setDataRows('revenue');
55
- $this->_axisMaps = array('x' => 'range', 'y' => 'revenue');
56
- parent::_prepareData();
57
- }
58
-
59
- /**
60
- * Add order chart data to xml object
61
- *
62
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
63
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphAmountsData
64
- */
65
- public function addAmountsChartDataToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
66
- {
67
- $this->_xmlObj = $xmlObj->addCustomChild('chart_data_details', null, array('id' => 'amounts'));
68
- $this->_addAllStoreData();
69
- return $this;
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphDataAbstract.php DELETED
@@ -1,350 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Chart data xml renderer block abstract
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- abstract class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphDataAbstract
35
- extends Mage_Adminhtml_Block_Dashboard_Graph
36
- {
37
- /**
38
- * X axis param
39
- */
40
- const AXIS_X = 'x';
41
-
42
- /**
43
- * Y axis param
44
- */
45
- const AXIS_Y = 'y';
46
-
47
- /**
48
- * Date range param for 24 hours
49
- */
50
- const DATE_RANGE_24H = '24h';
51
-
52
- /**
53
- * Date range param for 7 days
54
- */
55
- const DATE_RANGE_7D = '7d';
56
-
57
- /**
58
- * Date range param for 1 month
59
- */
60
- const DATE_RANGE_1M = '1m';
61
-
62
- /**
63
- * Date range param for 1 year
64
- */
65
- const DATE_RANGE_1Y = '1y';
66
-
67
- /**
68
- * Date range param for 2 years
69
- */
70
- const DATE_RANGE_2Y = '2y';
71
-
72
- /**
73
- * Chart xml object
74
- *
75
- * @var Mage_XmlConnect_Model_Simplexml_Element
76
- */
77
- protected $_xmlObj;
78
-
79
- /**
80
- * Add chart data from all stores
81
- *
82
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphDataAbstract
83
- */
84
- protected function _addAllStoreData()
85
- {
86
- $dataValuesXml = $this->getXmlObj()->addCustomChild('chart_data_values');
87
- $dataDescriptionXml = $this->getXmlObj()->addCustomChild('chart_data_description');
88
-
89
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeFilter) {
90
- $this->getDataHelper()->setParam('store', $storeFilter ? $storeFilter : null);
91
- $storeId = $this->getDataHelper()->getParam('store');
92
- $storeId = $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS;
93
-
94
- $valuesXml = $dataValuesXml->addCustomChild('values', null, array(
95
- 'store_id' => $storeId
96
- ));
97
-
98
- $descriptionXml = $dataDescriptionXml->addCustomChild('values', null, array(
99
- 'store_id' => $storeId
100
- ));
101
-
102
- foreach ($this->getRangeOptions() as $rangeFilter) {
103
- $this->getDataHelper()->setParam('period', $rangeFilter['value']);
104
- $this->getDataHelper()->initCollection();
105
- $chartData = $this->getChartData();
106
- $valuesXml->addCustomChild('item', $chartData['values'], array(
107
- 'range_id' => $this->getDataHelper()->getParam('period')
108
- ));
109
- $descriptionXml->addCustomChild('item', $chartData['description'], array(
110
- 'range_id' => $this->getDataHelper()->getParam('period')
111
- ));
112
- }
113
- }
114
- return $this;
115
- }
116
-
117
- /**
118
- * Get chart data array as chart values => chart reference axis description
119
- *
120
- * @throws Mage_Core_Exception
121
- * @return array
122
- */
123
- public function getChartData()
124
- {
125
- if (!$this->getCount()) {
126
- return array('values' => '', 'description' => '');
127
- }
128
-
129
- $this->_allSeries = $this->getRowsData($this->_dataRows);
130
-
131
- foreach ($this->_axisMaps as $axis => $attr) {
132
- $this->setAxisLabels($axis, $this->getRowsData($attr, true));
133
- }
134
-
135
- list($dateSeries, $dataSeries) = $this->_getRangeAndData();
136
-
137
- $this->_axisLabels[self::AXIS_X] = $this->_normalizeDateSeries($dateSeries);
138
- $this->_allSeries = $dataSeries;
139
-
140
- $valueBuffer = array();
141
- $params = array();
142
-
143
- if (sizeof($this->_axisLabels) > 0) {
144
- $indexId = 0;
145
- foreach ($this->_axisLabels as $idx => $labels) {
146
- if ($idx == self::AXIS_X) {
147
- $valueBuffer[] = $indexId . ":|" . implode('|', $this->_getXLabels());
148
- } elseif ($idx == self::AXIS_Y) {
149
- $valueBuffer[] = $indexId . ":|" . implode('|', $this->_getYLabels());
150
- }
151
- $indexId++;
152
- }
153
- $params['description'] = implode('|', $valueBuffer);
154
- };
155
-
156
- foreach ($this->getAllSeries() as $row) {
157
- array_walk($row, create_function('&$val', '$val = ceil($val);'));
158
- $params['values'] = implode('|', $row);
159
- }
160
- return $params;
161
- }
162
-
163
- /**
164
- * Get array of date range and values range series
165
- *
166
- * @return array
167
- */
168
- protected function _getRangeAndData()
169
- {
170
- $timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
171
-
172
- list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
173
- ->getDateRange($this->getDataHelper()->getParam('period'), '', '', true);
174
-
175
- $dateStart->setTimezone($timezoneLocal);
176
- $dateEnd->setTimezone($timezoneLocal);
177
-
178
- $dateSeries = array();
179
- $dataSeries = array();
180
- while ($dateStart->compare($dateEnd) < 0) {
181
- switch ($this->getDataHelper()->getParam('period')) {
182
- case self::DATE_RANGE_24H:
183
- $date = $dateStart->toString('yyyy-MM-dd HH:00');
184
- $dateStart->addHour(1);
185
- break;
186
- case self::DATE_RANGE_7D:
187
- case self::DATE_RANGE_1M:
188
- $date = $dateStart->toString('yyyy-MM-dd');
189
- $dateStart->addDay(1);
190
- break;
191
- case self::DATE_RANGE_1Y:
192
- case self::DATE_RANGE_2Y:
193
- $date = $dateStart->toString('yyyy-MM');
194
- $dateStart->addMonth(1);
195
- break;
196
- }
197
- foreach ($this->getAllSeries() as $index => $series) {
198
- if (in_array($date, $this->_axisLabels[self::AXIS_X])) {
199
- $dataSeries[$index][] = (float)array_shift($this->_allSeries[$index]);
200
- } else {
201
- $dataSeries[$index][] = 0;
202
- }
203
- }
204
- $dateSeries[] = $date;
205
- }
206
- return array($dateSeries, $dataSeries);
207
- }
208
-
209
- /**
210
- * Skip excess values of date series
211
- *
212
- * Keep count of date series up to 15 items
213
- *
214
- * @param array $dateSeries
215
- * @return array
216
- */
217
- protected function _normalizeDateSeries($dateSeries)
218
- {
219
- /**
220
- * setting skip step
221
- */
222
- if (count($dateSeries) > 8 && count($dateSeries) < 15) {
223
- $skipStep = 1;
224
- } elseif (count($dateSeries) >= 15) {
225
- $skipStep = 2;
226
- } else {
227
- $skipStep = 0;
228
- }
229
- /**
230
- * skipping some x labels for good reading
231
- */
232
- $i = 0;
233
- foreach ($dateSeries as $index => $date) {
234
- if ($i == $skipStep) {
235
- $dateSeries[$index] = $date;
236
- $i = 0;
237
- } else {
238
- $dateSeries[$index] = '';
239
- ++$i;
240
- }
241
- }
242
- return $dateSeries;
243
- }
244
-
245
- /**
246
- * Get X axis params array
247
- *
248
- * @return array
249
- */
250
- protected function _getXLabels()
251
- {
252
- /**
253
- * Format date
254
- */
255
- foreach ($this->_axisLabels[self::AXIS_X] as $index => $label) {
256
- if ($label != '') {
257
- switch ($this->getDataHelper()->getParam('period')) {
258
- case self::DATE_RANGE_24H:
259
- $this->_axisLabels[self::AXIS_X][$index] = $this->formatTime(
260
- new Zend_Date($label, 'yyyy-MM-dd HH:00'), 'short', false
261
- );
262
- break;
263
- case self::DATE_RANGE_7D:
264
- case self::DATE_RANGE_1M:
265
- $this->_axisLabels[self::AXIS_X][$index] = $this->formatDate(
266
- new Zend_Date($label, 'yyyy-MM-dd')
267
- );
268
- break;
269
- case self::DATE_RANGE_1Y:
270
- case self::DATE_RANGE_2Y:
271
- $formats = Mage::app()->getLocale()->getTranslationList('datetime');
272
- $format = isset($formats['yyMM']) ? $formats['yyMM'] : 'MM/yyyy';
273
- $format = str_replace(array("yyyy", "yy", "MM"), array("Y", "y", "m"), $format);
274
- $this->_axisLabels[self::AXIS_X][$index] = date($format, strtotime($label));
275
- break;
276
- default:
277
- Mage::throwException($this->__('Range param doesn\'t recognized'));
278
- break;
279
- }
280
- } else {
281
- $this->_axisLabels[self::AXIS_X][$index] = '';
282
- }
283
- }
284
- return $this->_axisLabels[self::AXIS_X];
285
- }
286
-
287
- /**
288
- * Get Y axis params array
289
- *
290
- * @return array
291
- */
292
- protected function _getYLabels()
293
- {
294
- $localMaxValue = $localMinValue = array();
295
- // process each string in the array, and find the max length
296
- foreach ($this->getAllSeries() as $index => $series) {
297
- $localMaxValue[$index] = max($series);
298
- $localMinValue[$index] = min($series);
299
- }
300
-
301
- if (is_numeric($this->_max)) {
302
- $maxvalue = $this->_max;
303
- } else {
304
- $maxvalue = max($localMaxValue);
305
- }
306
- if (is_numeric($this->_min)) {
307
- $minvalue = $this->_min;
308
- } else {
309
- $minvalue = min($localMinValue);
310
- }
311
-
312
- // default values
313
- $yLabels = array();
314
-
315
- if ($minvalue >= 0 && $maxvalue >= 0) {
316
- $miny = 0;
317
- if ($maxvalue > 10) {
318
- $p = pow(10, $this->_getPow($maxvalue));
319
- $maxy = ceil($maxvalue / $p) * $p;
320
- $yLabels = range($miny, $maxy, $p);
321
- } else {
322
- $maxy = ceil($maxvalue + 1);
323
- $yLabels = range($miny, $maxy, 1);
324
- }
325
- }
326
- return $yLabels;
327
- }
328
-
329
- /**
330
- * Get chart xml object
331
- *
332
- * @return Mage_XmlConnect_Model_Simplexml_Element
333
- */
334
- public function getXmlObj()
335
- {
336
- return $this->_xmlObj;
337
- }
338
-
339
- /**
340
- * Set chart xml object
341
- *
342
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
343
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphDataAbstract
344
- */
345
- public function setXmlObj($xmlObj)
346
- {
347
- $this->_xmlObj = $xmlObj;
348
- return $this;
349
- }
350
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphInfo.php DELETED
@@ -1,160 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin application diagram info renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphInfo extends Mage_Core_Block_Abstract
35
- {
36
- /**
37
- * Time range filter options
38
- *
39
- * @var array
40
- */
41
- protected $_timeRangeOptions;
42
-
43
- /**
44
- * Add last orders info to xml object
45
- *
46
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
47
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphInfo
48
- */
49
- public function addGraphInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
50
- {
51
- /** @var $graphInfoXmlObj Mage_XmlConnect_Model_Simplexml_Element */
52
- $graphInfoXmlObj = $xmlObj->addCustomChild('chart');
53
- $this->_addRangeValues($graphInfoXmlObj)->_addDataSelector($graphInfoXmlObj)->_addTotalsBar($graphInfoXmlObj);
54
-
55
- $graphInfoXmlObj = $graphInfoXmlObj->addCustomChild('chart_data');
56
- $this->_addChartDataOrders($graphInfoXmlObj)->_addChartDataAmounts($graphInfoXmlObj);
57
- return $this;
58
- }
59
-
60
- /**
61
- * Add time range select filed to xml object
62
- *
63
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
64
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphInfo
65
- */
66
- protected function _addRangeValues(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
67
- {
68
- $options = $this->_getRangeOptions();
69
-
70
- /** @var $rangeXmlObj Mage_XmlConnect_Model_Simplexml_Form_Element_Select */
71
- $rangeXmlObj = Mage::getModel('xmlconnect/simplexml_form_element_select', array(
72
- 'label' => $this->__('Select Range'),
73
- 'options' => $options,
74
- 'value' => $options[0]['value']
75
- ));
76
- $rangeXmlObj->setId('range_id');
77
- $xmlObj->appendChild($rangeXmlObj->toXmlObject());
78
- return $this;
79
- }
80
-
81
- /**
82
- * Get range filter options
83
- *
84
- * @return array
85
- */
86
- protected function _getRangeOptions()
87
- {
88
- if (null === $this->_timeRangeOptions) {
89
- $options = array();
90
- foreach ($this->helper('adminhtml/dashboard_data')->getDatePeriods() as $value => $label) {
91
- if (in_array($value, array('custom'))) {
92
- continue;
93
- }
94
- $options[] = array('label' => $label, 'value' => $value);
95
- }
96
- $this->_timeRangeOptions = $options;
97
- }
98
- return $this->_timeRangeOptions;
99
- }
100
-
101
- /**
102
- * Add data select field to xml object
103
- *
104
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
105
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphInfo
106
- */
107
- protected function _addDataSelector(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
108
- {
109
- /** @var $rangeXmlObj Mage_XmlConnect_Model_Simplexml_Form_Element_Select */
110
- $rangeXmlObj = Mage::getModel('xmlconnect/simplexml_form_element_select', array(
111
- 'label' => $this->__('Select Chart'),
112
- 'value' => 'orders',
113
- 'options' => array(
114
- array('label' => $this->__('Orders'), 'value' => 'orders'),
115
- array('label' => $this->__('Amounts'), 'value' => 'amounts')
116
- )));
117
- $rangeXmlObj->setId('data_details_id');
118
- $xmlObj->appendChild($rangeXmlObj->toXmlObject());
119
- return $this;
120
- }
121
-
122
- /**
123
- * Add orders chart data to xml object
124
- *
125
- * @param Mage_XmlConnect_Model_Simplexml_Element $graphInfoXmlObj
126
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphInfo
127
- */
128
- protected function _addChartDataOrders(Mage_XmlConnect_Model_Simplexml_Element $graphInfoXmlObj)
129
- {
130
- $this->getChild('graph_order_data')->setRangeOptions($this->_getRangeOptions())
131
- ->addOrderChartDataToXmlObj($graphInfoXmlObj);
132
- return $this;
133
- }
134
-
135
- /**
136
- * Add amounts chart data to xml object
137
- *
138
- * @param Mage_XmlConnect_Model_Simplexml_Element $graphInfoXmlObj
139
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphInfo
140
- */
141
- protected function _addChartDataAmounts(Mage_XmlConnect_Model_Simplexml_Element $graphInfoXmlObj)
142
- {
143
- $this->getChild('graph_amounts_data')->setRangeOptions($this->_getRangeOptions())
144
- ->addAmountsChartDataToXmlObj($graphInfoXmlObj);
145
- return $this;
146
- }
147
-
148
- /**
149
- * Add totals chart data to xml object
150
- *
151
- * @param Mage_XmlConnect_Model_Simplexml_Element $graphInfoXmlObj
152
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphInfo
153
- */
154
- protected function _addTotalsBar(Mage_XmlConnect_Model_Simplexml_Element $graphInfoXmlObj)
155
- {
156
- $this->getChild('graph_totals_data')->setRangeOptions($this->_getRangeOptions())
157
- ->addTotalsDataToXmlObj($graphInfoXmlObj);
158
- return $this;
159
- }
160
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphOrderData.php DELETED
@@ -1,71 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Orders chart data xml renderer block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphOrderData
35
- extends Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphDataAbstract
36
- {
37
- /**
38
- * Initialize object
39
- */
40
- public function __construct()
41
- {
42
- $this->setHtmlId('orders');
43
- parent::__construct();
44
- }
45
-
46
- /**
47
- * Prepare chart data
48
- *
49
- * @return null
50
- */
51
- protected function _prepareData()
52
- {
53
- $this->setDataHelperName('xmlconnect/adminhtml_dashboard_order');
54
- $this->setDataRows('quantity');
55
- $this->_axisMaps = array('x' => 'range', 'y' => 'quantity');
56
- parent::_prepareData();
57
- }
58
-
59
- /**
60
- * Add order chart data to xml object
61
- *
62
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
63
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphOrderData
64
- */
65
- public function addOrderChartDataToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
66
- {
67
- $this->_xmlObj = $xmlObj->addCustomChild('chart_data_details', null, array('id' => 'orders'));
68
- $this->_addAllStoreData();
69
- return $this;
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphTotalsData.php DELETED
@@ -1,123 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Totals chart data xml renderer block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphTotalsData extends Mage_Adminhtml_Block_Dashboard_Totals
35
- {
36
- /**
37
- * Get rid of unnecessary collection initialization by parent
38
- *
39
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphTotalsData
40
- */
41
- protected function _prepareLayout()
42
- {
43
- return $this;
44
- }
45
-
46
- /**
47
- * Init totals collection and assign totals values
48
- *
49
- * @param null|int $storeId
50
- * @param string $rangeId
51
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphTotalsData
52
- */
53
- protected function _initCollection($storeId, $rangeId)
54
- {
55
- if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
56
- return $this;
57
- }
58
-
59
- /* @var $collection Mage_Reports_Model_Mysql4_Order_Collection */
60
- $collection = Mage::getResourceModel('reports/order_collection')->addCreateAtPeriodFilter($rangeId)
61
- ->calculateTotals((bool)$storeId);
62
-
63
- if ($storeId) {
64
- $collection->addFieldToFilter('store_id', $storeId);
65
- } elseif (!$collection->isLive()) {
66
- $collection->addFieldToFilter('store_id', array(
67
- 'eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId()
68
- ));
69
- }
70
-
71
- $collection->load();
72
- $totals = $collection->getFirstItem();
73
-
74
- $this->addTotal($this->__('Revenue'), $totals->getRevenue());
75
- $this->addTotal($this->__('Tax'), $totals->getTax());
76
- $this->addTotal($this->__('Shipping'), $totals->getShipping());
77
- $this->addTotal($this->__('Quantity'), $totals->getQuantity() * 1, true);
78
- return $this;
79
- }
80
-
81
- /**
82
- * Add cart totals data to xml object
83
- *
84
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
85
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphTotalsData
86
- */
87
- public function addTotalsDataToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
88
- {
89
- $dataValuesXml = $xmlObj->addCustomChild('chart_totals');
90
-
91
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeFilter) {
92
- $storeId = $storeFilter ? $storeFilter : null;
93
-
94
- $totalsXml = $dataValuesXml->addCustomChild('totals', null, array(
95
- 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
96
- ));
97
-
98
- foreach ($this->getRangeOptions() as $rangeFilter) {
99
- $this->_initCollection($storeId, $rangeFilter['value']);
100
- $valuesXml = $totalsXml->addCustomChild('values', null, array(
101
- 'range_id' => $rangeFilter['value']
102
- ));
103
- foreach ($this->getTotals() as $total) {
104
- $totalValue = $valuesXml->escapeXml($total['value'] . $total['decimals']);
105
- $valuesXml->addCustomChild('item', $totalValue, array('label' => $total['label']));
106
- }
107
- $this->_clearTotals();
108
- }
109
- }
110
- return $this;
111
- }
112
-
113
- /**
114
- * Clear totals values array
115
- *
116
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphTotalsData
117
- */
118
- protected function _clearTotals()
119
- {
120
- $this->_totals = array();
121
- return $this;
122
- }
123
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/LastOrders.php DELETED
@@ -1,85 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin application last orders renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_LastOrders extends Mage_Adminhtml_Block_Dashboard_Orders_Grid
35
- {
36
- /**
37
- * Last orders count limit
38
- */
39
- const LAST_ORDER_COUNT_LIMIT = 5;
40
-
41
- /**
42
- * Add last orders info to xml object
43
- *
44
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
45
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_LastOrders
46
- */
47
- public function addLastOrdersToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
48
- {
49
- if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
50
- return $this;
51
- }
52
-
53
- /** @var $collection Mage_Reports_Model_Resource_Order_Collection */
54
- $collection = Mage::getResourceModel('reports/order_collection')->addItemCountExpr()
55
- ->joinCustomerName('customer')->orderByCreatedAt()->setPageSize(self::LAST_ORDER_COUNT_LIMIT);
56
-
57
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
58
- if ($storeId) {
59
- $collection->addAttributeToFilter('store_id', $storeId);
60
- $collection->addRevenueToSelect();
61
- } else {
62
- $collection->addRevenueToSelect(true);
63
- }
64
-
65
- $this->setCollection($collection);
66
- $orderList = $this->_prepareColumns()->getCollection()->load();
67
- $valuesXmlObj = $xmlObj->addCustomChild('values', null, array(
68
- 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
69
- ));
70
-
71
- foreach ($orderList as $order) {
72
- $itemXmlObj = $valuesXmlObj->addCustomChild('item');
73
- $itemXmlObj->addCustomChild('customer', $order->getCustomer(), array('label' => $this->__('Customer')));
74
- $itemXmlObj->addCustomChild('items_count', $order->getItemsCount(), array(
75
- 'label' => $this->__('Items')
76
- ));
77
- $currency_code = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
78
- $itemXmlObj->addCustomChild('currency', Mage::app()->getLocale()->currency($currency_code)
79
- ->toCurrency($order->getRevenue()), array('label' => $this->__('Grand Total')));
80
- }
81
- $collection->clear();
82
- }
83
- return $this;
84
- }
85
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/LastSearchTerms.php DELETED
@@ -1,118 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin application last search terms xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_LastSearchTerms
35
- extends Mage_Adminhtml_Block_Dashboard_Searches_Last
36
- {
37
- /**
38
- * Search terms count to display
39
- */
40
- const TERMS_COUNT_LIMIT = 5;
41
-
42
- /**
43
- * Get rid of unnecessary collection initialization
44
- *
45
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_LastSearchTerms
46
- */
47
- protected function _prepareCollection()
48
- {
49
- return $this;
50
- }
51
-
52
- /**
53
- * Init last search terms collection
54
- *
55
- * @param int|null $storeId
56
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_LastSearchTerms
57
- */
58
- protected function _initCollection($storeId)
59
- {
60
- if (!Mage::helper('core')->isModuleEnabled('Mage_CatalogSearch')) {
61
- return $this;
62
- }
63
- /** @var $_collection Mage_CatalogSearch_Model_Resource_Query_Collection */
64
- $this->_collection = Mage::getModel('catalogsearch/query')->getResourceCollection();
65
- $this->_collection->setRecentQueryFilter()->setPageSize(self::TERMS_COUNT_LIMIT);
66
-
67
- if ($storeId) {
68
- $this->_collection->addFieldToFilter('store_id', $storeId);
69
- }
70
- $this->setCollection($this->_collection);
71
- return $this;
72
- }
73
-
74
- /**
75
- * Clear collection
76
- *
77
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_LastSearchTerms
78
- */
79
- protected function _clearCollection()
80
- {
81
- $this->_collection = null;
82
- return $this;
83
- }
84
-
85
- /**
86
- * Add last search terms info to xml object
87
- *
88
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
89
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_LastSearchTerms
90
- */
91
- public function addLastSearchTermsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
92
- {
93
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
94
- $this->_clearCollection()->_initCollection($storeId);
95
- $valuesXml = $xmlObj->addCustomChild('values', null, array(
96
- 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
97
- ));
98
-
99
- if(!count($this->getCollection()->getItems()) > 0) {
100
- continue;
101
- }
102
-
103
- foreach ($this->getCollection()->getItems() as $item) {
104
- $itemListXml = $valuesXml->addCustomChild('item');
105
- $itemListXml->addCustomChild('query_text', $item->getQueryText(), array(
106
- 'label' => $this->__('Search Term')
107
- ));
108
- $itemListXml->addCustomChild('num_results', $item->getNumResults(), array(
109
- 'label' => $this->__('Results')
110
- ));
111
- $itemListXml->addCustomChild('popularity', $item->getPopularity(), array(
112
- 'label' => $this->__('Number of Uses')
113
- ));
114
- }
115
- }
116
- return $this;
117
- }
118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/MostViewedProducts.php DELETED
@@ -1,117 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Most viewed products xml renderer block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_MostViewedProducts
35
- extends Mage_Adminhtml_Block_Dashboard_Tab_Products_Viewed
36
- {
37
- /**
38
- * Products count to display
39
- */
40
- const PRODUCTS_COUNT_LIMIT = 5;
41
-
42
- /**
43
- * Get rid of unnecessary collection initialization
44
- *
45
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_MostViewedProducts
46
- */
47
- protected function _prepareCollection()
48
- {
49
- return $this;
50
- }
51
-
52
- /**
53
- * Init last search terms collection
54
- *
55
- * @param int|null $storeId
56
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_MostViewedProducts
57
- */
58
- protected function _initCollection($storeId)
59
- {
60
- $collection = Mage::getResourceModel('reports/product_collection')->addAttributeToSelect('*')->addViewsCount()
61
- ->setStoreId($storeId)->addStoreFilter($storeId)->setPageSize(self::PRODUCTS_COUNT_LIMIT);
62
- $this->setCollection($collection);
63
- return $this;
64
- }
65
-
66
- /**
67
- * Clear collection
68
- *
69
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_MostViewedProducts
70
- */
71
- protected function _clearCollection()
72
- {
73
- $this->_collection = null;
74
- return $this;
75
- }
76
-
77
- /**
78
- * Add most viewed products to xml object
79
- *
80
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
81
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_MostViewedProducts
82
- */
83
- public function addMostViewedProductsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
84
- {
85
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
86
- $this->_clearCollection()->_initCollection($storeId);
87
- $valuesXml = $xmlObj->addCustomChild('values', null, array(
88
- 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
89
- ));
90
-
91
- if(!count($this->getCollection()->getItems()) > 0) {
92
- continue;
93
- }
94
-
95
- /** @var $orderHelper Mage_XmlConnect_Helper_Adminhtml_Dashboard_Order */
96
- $orderHelper = Mage::helper('xmlconnect/adminhtml_dashboard_order');
97
-
98
- foreach ($this->getCollection()->getItems() as $item) {
99
- $itemListXml = $valuesXml->addCustomChild('item');
100
- $itemListXml->addCustomChild('name', $item->getName(), array(
101
- 'label' => Mage::helper('reports')->__('Product Name')
102
- ));
103
- $itemListXml->addCustomChild(
104
- 'price',
105
- $orderHelper->preparePrice($item->getPrice(), $storeId),
106
- array('label' => Mage::helper('reports')->__('Price'))
107
- );
108
- $itemListXml->addCustomChild(
109
- 'views',
110
- $item->getViews(),
111
- array('label' => Mage::helper('reports')->__('Number of Views'))
112
- );
113
- }
114
- }
115
- return $this;
116
- }
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/NewCustomers.php DELETED
@@ -1,129 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * New customers xml block renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_NewCustomers
35
- extends Mage_Adminhtml_Block_Dashboard_Tab_Customers_Newest
36
- {
37
- /**
38
- * Customers count to display
39
- */
40
- const CUSTOMERS_COUNT_LIMIT = 5;
41
-
42
- /**
43
- * Get rid of unnecessary collection initialization
44
- *
45
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_NewCustomers
46
- */
47
- protected function _prepareCollection()
48
- {
49
- return $this;
50
- }
51
-
52
- /**
53
- * Init new customers collection
54
- *
55
- * @param int|null $storeId
56
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_NewCustomers
57
- */
58
- protected function _initCollection($storeId)
59
- {
60
- /** @var $collection Mage_Reports_Model_Resource_Customer_Collection */
61
- $collection = Mage::getResourceModel('reports/customer_collection')->addCustomerName()
62
- ->setPageSize(self::CUSTOMERS_COUNT_LIMIT);
63
-
64
- $storeFilter = 0;
65
- if ($storeId) {
66
- $collection->addAttributeToFilter('store_id', $storeId);
67
- $storeFilter = 1;
68
- }
69
-
70
- $collection->addOrdersStatistics($storeFilter)->orderByCustomerRegistration();
71
- $this->setCollection($collection);
72
- return $this;
73
- }
74
-
75
- /**
76
- * Clear collection
77
- *
78
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_NewCustomers
79
- */
80
- protected function _clearCollection()
81
- {
82
- $this->_collection = null;
83
- return $this;
84
- }
85
-
86
- /**
87
- * Add new customers statistic to xml object
88
- *
89
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
90
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_NewCustomers
91
- */
92
- public function addNewCustomersToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
93
- {
94
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
95
- $this->_clearCollection()->_initCollection($storeId);
96
- $valuesXml = $xmlObj->addCustomChild('values', null, array(
97
- 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
98
- ));
99
-
100
- if(!count($this->getCollection()->getItems()) > 0) {
101
- continue;
102
- }
103
-
104
- /** @var $orderHelper Mage_XmlConnect_Helper_Adminhtml_Dashboard_Order */
105
- $orderHelper = Mage::helper('xmlconnect/adminhtml_dashboard_order');
106
-
107
- foreach ($this->getCollection()->getItems() as $item) {
108
- $itemListXml = $valuesXml->addCustomChild('item');
109
- $itemListXml->addCustomChild('name', $item->getName(), array(
110
- 'label' => $this->__('Customer Name')
111
- ));
112
- $itemListXml->addCustomChild('orders_count', $item->getOrdersCount(), array(
113
- 'label' => $this->__('Number of Orders')
114
- ));
115
- $itemListXml->addCustomChild(
116
- 'orders_avg_amount',
117
- $orderHelper->preparePrice($item->getOrdersAvgAmount(), $storeId),
118
- array('label' => $this->__('Average Order Amount'))
119
- );
120
- $itemListXml->addCustomChild(
121
- 'orders_sum_amount',
122
- $orderHelper->preparePrice($item->getOrdersSumAmount(), $storeId),
123
- array('label' => $this->__('Total Order Amount'))
124
- );
125
- }
126
- }
127
- return $this;
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/SalesInfo.php DELETED
@@ -1,119 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin application sales info renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_SalesInfo extends Mage_Adminhtml_Block_Dashboard_Sales
35
- {
36
- /**
37
- * Add sales info to xml object
38
- *
39
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
40
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_SalesInfo
41
- */
42
- public function addSalesInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
43
- {
44
- if (count($this->getTotals()) > 0) {
45
- /** @var $salesInfoField Mage_XmlConnect_Model_Simplexml_Form_Element_Custom */
46
- $salesInfoField = Mage::getModel('xmlconnect/simplexml_form_element_custom', array(
47
- 'label' => ''
48
- ));
49
- $salesInfoField->setId('sales_info');
50
- $salesInfoXmlObj = $salesInfoField->toXmlObject();
51
- $storeId = null;
52
- foreach ($this->getTotals() as $total) {
53
- if (null === $storeId || $storeId !== $total['store_id']) {
54
- $storeId = $total['store_id'];
55
- $valuesXmlObj = $salesInfoXmlObj->addCustomChild('values', null, array('store_id' => $storeId));
56
- }
57
- $valuesXmlObj->addCustomChild('item', strip_tags($total['value']), array(
58
- 'label' => $total['label']
59
- ));
60
- }
61
- $xmlObj->appendChild($salesInfoXmlObj);
62
- }
63
- return $this;
64
- }
65
-
66
- /**
67
- * Prepare sales data collection
68
- *
69
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_SalesInfo
70
- */
71
- protected function _prepareLayout()
72
- {
73
- if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
74
- return $this;
75
- }
76
-
77
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $filter) {
78
- $this->setCurrentStore($filter);
79
- if ($filter) {
80
- Mage::app()->getStore($filter);
81
- }
82
- $collection = Mage::getResourceModel('reports/order_collection')
83
- ->calculateSales($filter);
84
-
85
- if ($filter) {
86
- $collection->addFieldToFilter('store_id', $filter);
87
- }
88
-
89
- $collection->load();
90
- $sales = $collection->getFirstItem();
91
-
92
- $this->addTotal($this->__('Lifetime Sales'), $sales->getLifetime());
93
- $this->addTotal($this->__('Average Orders'), $sales->getAverage());
94
- }
95
- }
96
-
97
- /**
98
- * Add totals data with current store id to totals array
99
- *
100
- * @param string $label
101
- * @param string $value
102
- * @param bool $isQuantity
103
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_SalesInfo
104
- */
105
- public function addTotal($label, $value, $isQuantity = false)
106
- {
107
- if (!$isQuantity) {
108
- $value = $this->format($value);
109
- }
110
- $this->_totals[] = array(
111
- 'label' => $label,
112
- 'value' => $value,
113
- 'store_id' => $this->getCurrentStore() ? $this->getCurrentStore()
114
- : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
115
- );
116
-
117
- return $this;
118
- }
119
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/StoreSwitcher.php DELETED
@@ -1,198 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin application store switcher renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_StoreSwitcher extends Mage_Adminhtml_Block_Store_Switcher
35
- {
36
- /**
37
- * Add sales info to xml object
38
- *
39
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
40
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_StoreSwitcher
41
- */
42
- public function addSwitcherToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
43
- {
44
- $websites = $this->getWebsites();
45
- if ($websites) {
46
- $this->setUseConfirm(false);
47
-
48
- /** @var $storeSwitcherField Mage_XmlConnect_Model_Simplexml_Form_Element_Custom */
49
- $storeSwitcherField = Mage::getModel('xmlconnect/simplexml_form_element_custom', array(
50
- 'label' => $this->__('Choose Store View')
51
- ));
52
- $storeSwitcherField->setId('store_id');
53
- $storeSwitcherXmlObj = $storeSwitcherField->toXmlObject();
54
- $this->_createStoreItemList($websites, $storeSwitcherXmlObj);
55
-
56
- if (!$storeSwitcherXmlObj->getAttribute('value')) {
57
- $storeSwitcherXmlObj->addAttribute('value', Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS);
58
- }
59
- $xmlObj->appendChild($storeSwitcherXmlObj);
60
- }
61
- return $this;
62
- }
63
-
64
- /**
65
- * Create store item list for xml object
66
- *
67
- * @param array $websites
68
- * @param Mage_XmlConnect_Model_Simplexml_Element $storeSwitcherXmlObj
69
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_StoreSwitcher
70
- */
71
- protected function _createStoreItemList($websites, Mage_XmlConnect_Model_Simplexml_Element $storeSwitcherXmlObj)
72
- {
73
- $switcherItemsXmlObj = $storeSwitcherXmlObj->addCustomChild('values');
74
-
75
- if ($this->hasDefaultOption()) {
76
- $this->_addSwitcherItem($switcherItemsXmlObj, Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS,
77
- array('label' => $this->getDefaultStoreName(), 'level' => 1));
78
- }
79
-
80
- foreach ($websites as $website) {
81
- foreach ($website->getGroups() as $group) {
82
- $this->_setStoreItemsByNestingLevel($storeSwitcherXmlObj, $switcherItemsXmlObj, $website, $group);
83
- }
84
- }
85
- return $this;
86
- }
87
-
88
- /**
89
- * Set store items to xml object by nesting level
90
- *
91
- * @param Mage_XmlConnect_Model_Simplexml_Element $storeSwitcherXmlObj
92
- * @param Mage_XmlConnect_Model_Simplexml_Element $switcherItemsXmlObj
93
- * @param array $website
94
- * @param array $group
95
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_StoreSwitcher
96
- */
97
- protected function _setStoreItemsByNestingLevel($storeSwitcherXmlObj, $switcherItemsXmlObj, $website, $group)
98
- {
99
- $showWebsite = $showGroup = false;
100
- foreach ($this->getStores($group) as $store) {
101
- if ($showWebsite == false) {
102
- $showWebsite = true;
103
- $this->_addSwitcherItem($switcherItemsXmlObj, null, array(
104
- 'label' => $website->getName(), 'level' => 1
105
- ), true);
106
- }
107
-
108
- if ($showGroup == false) {
109
- $showGroup = true;
110
- $this->_addSwitcherItem($switcherItemsXmlObj, null, array(
111
- 'label' => $group->getName(), 'level' => 2
112
- ), true);
113
- }
114
-
115
- if ($this->getStoreId() == $store->getId()) {
116
- $storeSwitcherXmlObj->addAttribute('value', $this->getStoreId());
117
- }
118
-
119
- $this->_addSwitcherItem($switcherItemsXmlObj, $store->getId(), array(
120
- 'label' => $store->getName(), 'level' => 3
121
- ));
122
- }
123
- return $this;
124
- }
125
-
126
- /**
127
- * Add switcher item to xml object
128
- *
129
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
130
- * @param string $value
131
- * @param array $config
132
- * @param bool $isDisabled
133
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_StoreSwitcher
134
- */
135
- protected function _addSwitcherItem($xmlObj, $value, $config, $isDisabled = false)
136
- {
137
- if ($isDisabled) {
138
- $config += array('disabled' => 1);
139
- }
140
- $xmlObj->addCustomChild('item', $value, $config);
141
- return $this;
142
- }
143
-
144
- /**
145
- * Get store switcher params as array
146
- *
147
- * @return array
148
- */
149
- protected function _getStoreSwitcherParams()
150
- {
151
- $result = array();
152
- $websites = $this->getWebsites();
153
- foreach ($websites as $website) {
154
- $showWebsite = false;
155
- foreach ($website->getGroups() as $group) {
156
- $showGroup = false;
157
- foreach ($this->getStores($group) as $store) {
158
- if ($showWebsite == false) {
159
- $showWebsite = true;
160
- $result[$website->getId()]['name'] = $website->getName();
161
- $result[$website->getId()]['store_list'] = array();
162
- }
163
-
164
- if ($showGroup == false) {
165
- $showGroup = true;
166
- $result[$website->getId()]['store_list'][$group->getId()]['name'] = $group->getName();
167
- $result[$website->getId()]['store_list'][$group->getId()]['view_list'] = array();
168
- }
169
- $result[$website->getId()]['store_list'][$group->getId()]['view_list'][$store->getId()] = $store
170
- ->getName();
171
- }
172
- }
173
- }
174
- return $result;
175
- }
176
-
177
- /**
178
- * Prepare sales data collection
179
- *
180
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_SalesInfo
181
- */
182
- protected function _prepareLayout()
183
- {
184
- $this->registerStoreSwitcher();
185
- return parent::_prepareLayout();
186
- }
187
-
188
- /**
189
- * Set store switcher to registry
190
- *
191
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_StoreSwitcher
192
- */
193
- public function registerStoreSwitcher()
194
- {
195
- Mage::register('store_switcher', $this->_getStoreSwitcherParams());
196
- return $this;
197
- }
198
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/TopSearchTerms.php DELETED
@@ -1,114 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Top search terms xml renderer block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_TopSearchTerms
35
- extends Mage_Adminhtml_Block_Dashboard_Searches_Top
36
- {
37
- /**
38
- * Search terms count to display
39
- */
40
- const TERMS_COUNT_LIMIT = 5;
41
-
42
- /**
43
- * Get rid of unnecessary collection initialization
44
- *
45
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_TopSearchTerms
46
- */
47
- protected function _prepareCollection()
48
- {
49
- return $this;
50
- }
51
-
52
- /**
53
- * Init last search terms collection
54
- *
55
- * @param int|null $storeId
56
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_TopSearchTerms
57
- */
58
- protected function _initCollection($storeId)
59
- {
60
- if (!Mage::helper('core')->isModuleEnabled('Mage_CatalogSearch')) {
61
- return $this;
62
- }
63
- /** @var $_collection Mage_CatalogSearch_Model_Resource_Query_Collection */
64
- $this->_collection = Mage::getModel('catalogsearch/query')->getResourceCollection();
65
- $this->_collection->setPopularQueryFilter($storeId ? $storeId : '')->setPageSize(self::TERMS_COUNT_LIMIT);
66
- $this->setCollection($this->_collection);
67
- return $this;
68
- }
69
-
70
- /**
71
- * Clear collection
72
- *
73
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_TopSearchTerms
74
- */
75
- protected function _clearCollection()
76
- {
77
- $this->_collection = null;
78
- return $this;
79
- }
80
-
81
- /**
82
- * Add last search terms info to xml object
83
- *
84
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
85
- * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_TopSearchTerms
86
- */
87
- public function addTopSearchTermsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
88
- {
89
- foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
90
- $this->_clearCollection()->_initCollection($storeId);
91
- $valuesXml = $xmlObj->addCustomChild('values', null, array(
92
- 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
93
- ));
94
-
95
- if(!count($this->getCollection()->getItems()) > 0) {
96
- continue;
97
- }
98
-
99
- foreach ($this->getCollection()->getItems() as $item) {
100
- $itemListXml = $valuesXml->addCustomChild('item');
101
- $itemListXml->addCustomChild('name', $item->getName(), array(
102
- 'label' => $this->__('Search Term')
103
- ));
104
- $itemListXml->addCustomChild('num_results', $item->getNumResults(), array(
105
- 'label' => $this->__('Results')
106
- ));
107
- $itemListXml->addCustomChild('popularity', $item->getPopularity(), array(
108
- 'label' => $this->__('Number of Uses')
109
- ));
110
- }
111
- }
112
- return $this;
113
- }
114
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Loginform.php DELETED
@@ -1,70 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Admin application login form renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Connect_Loginform extends Mage_Core_Block_Abstract
35
- {
36
- /**
37
- * Render login form xml
38
- *
39
- * @return string
40
- */
41
- protected function _toHtml()
42
- {
43
- $action = $this->getUrl('*/*/login');
44
-
45
- /** @var Mage_XmlConnect_Model_Simplexml_Form $fromXmlObj */
46
- $fromXmlObj = Mage::getModel('xmlconnect/simplexml_form', array(
47
- 'xml_id' => 'login_form',
48
- 'action' => $action,
49
- 'use_container' => true
50
- ))->setFieldNameSuffix('login_info');
51
-
52
- $formFieldset = $fromXmlObj->addFieldset('account_info', array(
53
- 'title' => $this->__('Log in to Admin Panel')
54
- ));
55
-
56
- $formFieldset->addField('username', 'text', array(
57
- 'label' => $this->__('User Name:'),
58
- 'name' => 'username',
59
- 'required' => 1
60
- ));
61
-
62
- $formFieldset->addField('password', 'password', array(
63
- 'label' => $this->__('Password:'),
64
- 'name' => 'password',
65
- 'required' => 1
66
- ));
67
-
68
- return $fromXmlObj->getXml();
69
- }
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile.php CHANGED
@@ -40,8 +40,12 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile extends Mage_Adminhtml_Block_Widget
40
  {
41
  $this->_controller = 'adminhtml_mobile';
42
  $this->_blockGroup = 'xmlconnect';
43
- $xmlconnectVersion = Mage::getConfig()->getNode(Mage_XmlConnect_Model_Application::XML_PATH_MODULE_VERSION);
44
- $this->_headerText = $this->__('Manage Apps') . ' ' . $this->__('ver. %s', $xmlconnectVersion);
 
 
 
 
45
  $this->_addButtonLabel = $this->__('Add App');
46
 
47
  parent::__construct();
40
  {
41
  $this->_controller = 'adminhtml_mobile';
42
  $this->_blockGroup = 'xmlconnect';
43
+ $xmlconnectVersion = Mage::getConfig()->getNode(
44
+ Mage_XmlConnect_Model_Application::XML_PATH_MODULE_VERSION
45
+ );
46
+ $this->_headerText = $this->__('Manage Apps')
47
+ . ' '
48
+ . $this->__('ver. %s', $xmlconnectVersion);
49
  $this->_addButtonLabel = $this->__('Add App');
50
 
51
  parent::__construct();
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
 
35
  {
36
  /**
37
  * Setting app action buttons for application
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit
35
+ extends Mage_Adminhtml_Block_Widget_Form_Container
36
  {
37
  /**
38
  * Setting app action buttons for application
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Submission.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Submission extends Mage_Adminhtml_Block_Widget_Tabs
 
35
  {
36
  /**
37
  * Constructor
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Submission
35
+ extends Mage_Adminhtml_Block_Widget_Tabs
36
  {
37
  /**
38
  * Constructor
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Content.php CHANGED
@@ -35,11 +35,6 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Content
35
  extends Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
36
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
  {
38
- /**
39
- * List of static CMS pages
40
- *
41
- * @var array
42
- */
43
  protected $_pages;
44
 
45
  /**
@@ -50,58 +45,63 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Content
50
  {
51
  parent::__construct();
52
  $this->setShowGlobalIcon(true);
53
- $this->setTemplate('/xmlconnect/edit/tab/content.phtml');
54
- $this->_pages = Mage::getResourceModel('xmlconnect/cms_page_collection')->toOptionIdArray();
55
  }
56
 
57
  /**
58
  * Add page input to fieldset
59
  *
60
- * @deprecated will delete in the next version
61
  * @param Varien_Data_Form_Element_Fieldset $fieldset
62
  * @param string $fieldPrefix
63
- * @return null
64
  */
65
  protected function _addPage($fieldset, $fieldPrefix)
66
  {
67
- $element = $fieldset->addField($fieldPrefix, 'page', array('name' => $fieldPrefix));
68
- $element->initFields(array('name' => $fieldPrefix, 'values' => $this->_pages));
 
 
 
 
 
69
  }
70
 
71
  /**
72
  * Prepare form before rendering HTML
 
73
  *
74
  * @return Mage_Adminhtml_Block_Widget_Form
75
  */
76
  protected function _prepareForm()
77
  {
78
- $this->_prepareButtons();
79
- return parent::_prepareForm();
80
- }
 
81
 
82
- /**
83
- * Prepare add and delete buttons for content tab
84
- *
85
- * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Content
86
- */
87
- protected function _prepareButtons()
88
- {
89
- $addButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
90
- 'label' => $this->__('Add Page'),
91
- 'onclick' => 'cmsPageActionHelper.insertPage(); return false;',
92
- 'class' => 'add'
93
- ))->setName('add_page_item_button');
94
 
95
- $this->setChild('add_button', $addButton);
 
96
 
97
- $deleteButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
98
- 'label' => $this->__('Delete'),
99
- 'onclick' => "$(\'config_data[{{deleteId}}][tr]\').remove(); return false;",
100
- 'class' => 'delete'
101
- ))->setName('add_page_item_button');
 
 
102
 
103
- $this->setChild('delete_button', $deleteButton);
104
- return $this;
 
 
 
 
 
 
 
 
105
  }
106
 
107
  /**
@@ -143,24 +143,4 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Content
143
  {
144
  return false;
145
  }
146
-
147
- /**
148
- * Return cms page list
149
- *
150
- * @return array
151
- */
152
- public function getPages()
153
- {
154
- return $this->_pages;
155
- }
156
-
157
- /**
158
- * Return saved static page list
159
- *
160
- * @return array
161
- */
162
- public function getStaticPageList()
163
- {
164
- return Mage::getSingleton('xmlconnect/configuration')->getDeviceStaticPages();
165
- }
166
  }
35
  extends Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
36
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
  {
 
 
 
 
 
38
  protected $_pages;
39
 
40
  /**
45
  {
46
  parent::__construct();
47
  $this->setShowGlobalIcon(true);
 
 
48
  }
49
 
50
  /**
51
  * Add page input to fieldset
52
  *
 
53
  * @param Varien_Data_Form_Element_Fieldset $fieldset
54
  * @param string $fieldPrefix
 
55
  */
56
  protected function _addPage($fieldset, $fieldPrefix)
57
  {
58
+ $element = $fieldset->addField($fieldPrefix, 'page', array(
59
+ 'name' => $fieldPrefix,
60
+ ));
61
+ $element->initFields(array(
62
+ 'name' => $fieldPrefix,
63
+ 'values' => $this->_pages,
64
+ ));
65
  }
66
 
67
  /**
68
  * Prepare form before rendering HTML
69
+ * Setting Form Fieldsets and fields
70
  *
71
  * @return Mage_Adminhtml_Block_Widget_Form
72
  */
73
  protected function _prepareForm()
74
  {
75
+ $model = Mage::helper('xmlconnect')->getApplication();
76
+ $conf = $model->getConf();
77
+ $form = new Varien_Data_Form();
78
+ $this->setForm($form);
79
 
80
+ $pages = Mage::getResourceModel('xmlconnect/cms_page_collection')->toOptionIdArray();
81
+ $dummy = array(array( 'value' => '', 'label' => '' ));
82
+ $this->_pages = array_merge($dummy, $pages);
 
 
 
 
 
 
 
 
 
83
 
84
+ $fieldset = $form->addFieldset('cms_pages', array('legend' => $this->__('Pages')));
85
+ $this->_addElementTypes($fieldset);
86
 
87
+ $fieldset->addField('page_row_add', 'addrow', array(
88
+ 'onclick' => 'insertNewTableRow(this)',
89
+ 'options' => $this->_pages,
90
+ 'class' => ' scalable save ',
91
+ 'label' => $this->__('Label'),
92
+ 'before_element_html' => $this->__('Get Content from CMS Page').'</td><td class="label">',
93
+ ));
94
 
95
+ if (!empty($conf['native']['pages'])) {
96
+ foreach ($conf['native']['pages'] as $key=>$dummy) {
97
+ $this->_addPage($fieldset, 'conf[native][pages]['.$key.']');
98
+ }
99
+ }
100
+
101
+ $data = $model->getFormData();
102
+ $data['page_row_add'] = $this->__('Add Page');
103
+ $form->setValues($data);
104
+ return parent::_prepareForm();
105
  }
106
 
107
  /**
143
  {
144
  return false;
145
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Accordion.php CHANGED
@@ -25,7 +25,7 @@
25
  */
26
 
27
  /**
28
- * Tab design accordion block renderer
29
  *
30
  * @category Mage
31
  * @package Mage_Xmlconnect
25
  */
26
 
27
  /**
28
+ * Tab design accordion xml renderer
29
  *
30
  * @category Mage
31
  * @package Mage_Xmlconnect
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Accordion/Images.php CHANGED
@@ -27,7 +27,6 @@
27
  /**
28
  * Tab design Accordion Images xml renderer
29
  *
30
- * @deprecated will delete in the next version
31
  * @category Mage
32
  * @package Mage_Xmlconnect
33
  * @author Magento Core Team <core@magentocommerce.com>
@@ -38,7 +37,6 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
38
  /**
39
  * Getter for accordion item title
40
  *
41
- * @deprecated will delete in the next version
42
  * @return string
43
  */
44
  public function getTitle()
@@ -49,7 +47,6 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
49
  /**
50
  * Getter for accordion item is open flag
51
  *
52
- * @deprecated will delete in the next version
53
  * @return bool
54
  */
55
  public function getIsOpen()
@@ -60,7 +57,6 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
60
  /**
61
  * Prepare form
62
  *
63
- * @deprecated will delete in the next version
64
  * @throws Mage_Core_Exception
65
  * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
66
  */
@@ -73,7 +69,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
73
  $this->addImage($fieldset,
74
  'conf[native][navigationBar][icon]',
75
  $this->__('Logo in Header'),
76
- $this->__('Recommended size %spx x %spx.', 35, 35),
77
  $this->_getDesignPreviewImageUrl('conf/native/navigationBar/icon'),
78
  true
79
  );
@@ -84,18 +80,14 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
84
  $this->addImage($fieldset,
85
  'conf[native][body][bannerImage]',
86
  $this->__('Banner on Home Screen'),
87
- $this->__('Recommended size %spx x %spx.', 320, 230)
88
- . $this->__(' Note: Image size affects the performance of your app.')
89
- . $this->__('Keep your image size below %s KB for optimal performance.', 50),
90
  $this->_getDesignPreviewImageUrl('conf/native/body/bannerImage'),
91
  true
92
  );
93
  $this->addImage($fieldset,
94
  'conf[native][body][backgroundImage]',
95
  $this->__('App Background'),
96
- $this->__('Recommended size %spx x %spx.', 320, 367)
97
- . $this->__('Note: Image size affects the performance of your app.')
98
- . $this->__('Keep your image size below %s KB for optimal performance.', 75),
99
  $this->_getDesignPreviewImageUrl('conf/native/body/backgroundImage'),
100
  true
101
  );
@@ -104,32 +96,28 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
104
  $this->addImage($fieldset,
105
  'conf[native][body][bannerIpadLandscapeImage]',
106
  $this->__('Banner on Home Screen <br />(landscape mode)'),
107
- $this->__('Recommended size %spx x %spx.', 1024, 344)
108
- . $this->__('Note: Image size affects the performance of your app.'),
109
  $this->_getDesignPreviewImageUrl('conf/native/body/bannerIpadLandscapeImage'),
110
  true
111
  );
112
  $this->addImage($fieldset,
113
  'conf[native][body][bannerIpadImage]',
114
  $this->__('Banner on Home Screen <br />(portrait mode)'),
115
- $this->__('Recommended size %spx x %spx.', 768, 294)
116
- . $this->__('Note: Image size affects the performance of your app.'),
117
  $this->_getDesignPreviewImageUrl('conf/native/body/bannerIpadImage'),
118
  true
119
  );
120
  $this->addImage($fieldset,
121
  'conf[native][body][backgroundIpadLandscapeImage]',
122
  $this->__('App Background <br />(landscape mode)'),
123
- $this->__('Recommended size %spx x %spx.', 1024, 704)
124
- . $this->__('Note: Image size affects the performance of your app.'),
125
  $this->_getDesignPreviewImageUrl('conf/native/body/backgroundIpadLandscapeImage'),
126
  true
127
  );
128
  $this->addImage($fieldset,
129
  'conf[native][body][backgroundIpadPortraitImage]',
130
  $this->__('App Background <br />(portrait mode)'),
131
- $this->__('Recommended size %spx x %spx.', 768, 960)
132
- . $this->__('Note: Image size affects the performance of your app.'),
133
  $this->_getDesignPreviewImageUrl('conf/native/body/backgroundIpadPortraitImage'),
134
  true
135
  );
@@ -138,9 +126,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
138
  $this->addImage($fieldset,
139
  'conf[native][body][bannerAndroidImage]',
140
  $this->__('Banner on Home Screen'),
141
- $this->__('Recommended size %spx x %spx.', 320, 258)
142
- . $this->__('Note: Image size affects the performance of your app.')
143
- . $this->__('Keep your image size below %s KB for optimal performance.', 50),
144
  $this->_getDesignPreviewImageUrl('conf/native/body/bannerAndroidImage'),
145
  true
146
  );
@@ -160,7 +146,6 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
160
  /**
161
  * Retrieve url for images in the skin folder
162
  *
163
- * @deprecated will delete in the next version
164
  * @param string $name - path to file name relative to the skin dir
165
  * @return string
166
  */
27
  /**
28
  * Tab design Accordion Images xml renderer
29
  *
 
30
  * @category Mage
31
  * @package Mage_Xmlconnect
32
  * @author Magento Core Team <core@magentocommerce.com>
37
  /**
38
  * Getter for accordion item title
39
  *
 
40
  * @return string
41
  */
42
  public function getTitle()
47
  /**
48
  * Getter for accordion item is open flag
49
  *
 
50
  * @return bool
51
  */
52
  public function getIsOpen()
57
  /**
58
  * Prepare form
59
  *
 
60
  * @throws Mage_Core_Exception
61
  * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
62
  */
69
  $this->addImage($fieldset,
70
  'conf[native][navigationBar][icon]',
71
  $this->__('Logo in Header'),
72
+ $this->__('Recommended size 35px x 35px.'),
73
  $this->_getDesignPreviewImageUrl('conf/native/navigationBar/icon'),
74
  true
75
  );
80
  $this->addImage($fieldset,
81
  'conf[native][body][bannerImage]',
82
  $this->__('Banner on Home Screen'),
83
+ $this->__('Recommended size 320px x 230px. Note: Image size affects the performance of your app. Keep your image size below 50 KB for optimal performance.'),
 
 
84
  $this->_getDesignPreviewImageUrl('conf/native/body/bannerImage'),
85
  true
86
  );
87
  $this->addImage($fieldset,
88
  'conf[native][body][backgroundImage]',
89
  $this->__('App Background'),
90
+ $this->__('Recommended size 320px x 367px. Note: Image size affects the performance of your app. Keep your image size below 75 KB for optimal performance.'),
 
 
91
  $this->_getDesignPreviewImageUrl('conf/native/body/backgroundImage'),
92
  true
93
  );
96
  $this->addImage($fieldset,
97
  'conf[native][body][bannerIpadLandscapeImage]',
98
  $this->__('Banner on Home Screen <br />(landscape mode)'),
99
+ $this->__('Recommended size 1024px x 344px. Note: Image size affects the performance of your app.'),
 
100
  $this->_getDesignPreviewImageUrl('conf/native/body/bannerIpadLandscapeImage'),
101
  true
102
  );
103
  $this->addImage($fieldset,
104
  'conf[native][body][bannerIpadImage]',
105
  $this->__('Banner on Home Screen <br />(portrait mode)'),
106
+ $this->__('Recommended size 768px x 294px. Note: Image size affects the performance of your app.'),
 
107
  $this->_getDesignPreviewImageUrl('conf/native/body/bannerIpadImage'),
108
  true
109
  );
110
  $this->addImage($fieldset,
111
  'conf[native][body][backgroundIpadLandscapeImage]',
112
  $this->__('App Background <br />(landscape mode)'),
113
+ $this->__('Recommended size 1024px x 704px. Note: Image size affects the performance of your app.'),
 
114
  $this->_getDesignPreviewImageUrl('conf/native/body/backgroundIpadLandscapeImage'),
115
  true
116
  );
117
  $this->addImage($fieldset,
118
  'conf[native][body][backgroundIpadPortraitImage]',
119
  $this->__('App Background <br />(portrait mode)'),
120
+ $this->__('Recommended size 768px x 960px. Note: Image size affects the performance of your app.'),
 
121
  $this->_getDesignPreviewImageUrl('conf/native/body/backgroundIpadPortraitImage'),
122
  true
123
  );
126
  $this->addImage($fieldset,
127
  'conf[native][body][bannerAndroidImage]',
128
  $this->__('Banner on Home Screen'),
129
+ $this->__('Recommended size 320px x 258px. Note: Image size affects the performance of your app. Keep your image size below 50 KB for optimal performance.'),
 
 
130
  $this->_getDesignPreviewImageUrl('conf/native/body/bannerAndroidImage'),
131
  true
132
  );
146
  /**
147
  * Retrieve url for images in the skin folder
148
  *
 
149
  * @param string $name - path to file name relative to the skin dir
150
  * @return string
151
  */
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Images.php DELETED
@@ -1,192 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Tab design images block renderer
29
- *
30
- * @category Mage
31
- * @package Mage_Xmlconnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Images extends Mage_Adminhtml_Block_Template
35
- {
36
- /**
37
- * Init block, set preview template
38
- */
39
- public function __construct()
40
- {
41
- parent::__construct();
42
-
43
- $device = Mage::helper('xmlconnect')->getDeviceType();
44
- if (array_key_exists($device, Mage::helper('xmlconnect')->getSupportedDevices())) {
45
- $template = 'xmlconnect/edit/tab/design/images_' . strtolower($device) . '.phtml';
46
- } else {
47
- Mage::throwException($this->__('Device doesn\'t recognized. Unable to load a template.'));
48
- }
49
-
50
- $this->setTemplate($template);
51
- }
52
-
53
- /**
54
- * Get application id
55
- *
56
- * @return int
57
- */
58
- public function getApplicationId()
59
- {
60
- return Mage::helper('xmlconnect')->getApplicationId();
61
- }
62
-
63
- /**
64
- * Get image data array for uploader needs
65
- *
66
- * @param string $type
67
- * @param int $imageLimit
68
- * @return array
69
- */
70
- public function getImagesData($type, $imageLimit = 1)
71
- {
72
- if (!$this->{'get' . ucwords($type)}()) {
73
- /** @var $imagesModel Mage_XmlConnect_Model_Images */
74
- $imagesModel = Mage::getModel('xmlconnect/images');
75
- $this->setImageCount($imagesModel->getImageCount($type));
76
- $result = $imagesModel->getDeviceImagesByType($type, $imageLimit);
77
- $imageCount = count($result);
78
- $this->setIsShowUploder(true);
79
- if ($imageCount < $imageLimit) {
80
- $result[] = array('image_type' => $type, 'order' => ++$imageCount,
81
- 'application_id' => $this->getApplicationId(), 'show_uploader' => (int)$this->getIsShowUploder());
82
- $this->setIsShowUploder(false);
83
- }
84
- $this->{'set' . ucwords($type)}($result);
85
- }
86
- return $this->{'get' . ucwords($type)}();
87
- }
88
-
89
- /**
90
- * Get image list by type and limit
91
- *
92
- * @param string $imageType
93
- * @param int $count
94
- * @return array
95
- */
96
- public function getImageList($imageType, $count)
97
- {
98
- $imageList = $this->getImagesData($imageType, $count);
99
- $result = array();
100
- foreach ($imageList as $image) {
101
- $result[] = $this->_prepareImagesData($image);
102
- }
103
- return $result;
104
- }
105
-
106
- /**
107
- * Prepare image data for uploader
108
- *
109
- * @param array $image
110
- * @return array
111
- */
112
- protected function _prepareImagesData($image)
113
- {
114
- $this->clearConfig();
115
- $params = array('image_type' => $image['image_type'], '_secure' => true, 'order' => $image['order'],
116
- 'application_id' => $this->getApplicationId());
117
-
118
- if (isset($image['image_id'])) {
119
- $this->getConfig()->setFileSave(Mage::getModel('xmlconnect/images')->getImageUrl($image['image_file']))
120
- ->setImageId($image['image_id']);
121
-
122
- $this->getConfig()->setThumbnail(Mage::getModel('xmlconnect/images')->getCustomSizeImageUrl(
123
- $image['image_file'],
124
- Mage_XmlConnect_Helper_Data::THUMBNAIL_IMAGE_WIDTH,
125
- Mage_XmlConnect_Helper_Data::THUMBNAIL_IMAGE_HEIGHT
126
- ))->setImageId($image['image_id']);
127
-
128
- $imageActionData = Mage::helper('xmlconnect')->getApplication()->getImageActionModel()
129
- ->getImageActionData($image['image_id']);
130
- if ($imageActionData) {
131
- $this->getConfig()->setImageActionData($imageActionData);
132
- }
133
- }
134
-
135
- if (isset($image['show_uploader'])) {
136
- $this->getConfig()->setShowUploader($image['show_uploader']);
137
- }
138
-
139
- $this->getConfig()->setUrl(
140
- Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/uploadimages', $params)
141
- );
142
- $this->getConfig()->setParams(array('form_key' => $this->getFormKey()));
143
- $this->getConfig()->setFileField($image['image_type']);
144
- $this->getConfig()->setFilters(array(
145
- 'images' => array(
146
- 'label' => Mage::helper('adminhtml')->__('Images (.gif, .jpg, .png)'),
147
- 'files' => array('*.gif', '*.jpg','*.jpeg', '*.png')
148
- )));
149
- $this->getConfig()->setReplaceBrowseWithRemove(true);
150
- $this->getConfig()->setWidth('32');
151
- $this->getConfig()->setHideUploadButton(true);
152
- $this->getConfig()->setImageCount($this->getImageCount());
153
-
154
- return $this->getConfig()->getData();
155
- }
156
-
157
- /**
158
- * Retrieve config json
159
- *
160
- * @param array $image
161
- * @return string
162
- */
163
- public function getConfigJson($image)
164
- {
165
- return Mage::helper('core')->jsonEncode($this->_prepareImagesData($image));
166
- }
167
-
168
- /**
169
- * Retrieve image config object
170
- *
171
- * @return Varien_Object
172
- */
173
- public function getConfig()
174
- {
175
- if(is_null($this->_config)) {
176
- $this->_config = new Varien_Object();
177
- }
178
-
179
- return $this->_config;
180
- }
181
-
182
- /**
183
- * Clear Image config object
184
- *
185
- * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Images
186
- */
187
- public function clearConfig()
188
- {
189
- $this->_config = null;
190
- return $this;
191
- }
192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Preview.php CHANGED
@@ -25,13 +25,14 @@
25
  */
26
 
27
  /**
28
- * Tab design preview renderer
29
  *
30
  * @category Mage
31
  * @package Mage_Xmlconnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Preview extends Mage_Adminhtml_Block_Template
 
35
  {
36
  /**
37
  * Set preview template
@@ -44,7 +45,9 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Preview extends Mag
44
  if (array_key_exists($device, Mage::helper('xmlconnect')->getSupportedDevices())) {
45
  $template = 'xmlconnect/edit/tab/design/preview_' . strtolower($device) . '.phtml';
46
  } else {
47
- Mage::throwException($this->__('Device doesn\'t recognized. Unable to load a template.'));
 
 
48
  }
49
 
50
  $this->setTemplate($template);
25
  */
26
 
27
  /**
28
+ * Tab design preview xml renderer
29
  *
30
  * @category Mage
31
  * @package Mage_Xmlconnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Preview
35
+ extends Mage_Adminhtml_Block_Template
36
  {
37
  /**
38
  * Set preview template
45
  if (array_key_exists($device, Mage::helper('xmlconnect')->getSupportedDevices())) {
46
  $template = 'xmlconnect/edit/tab/design/preview_' . strtolower($device) . '.phtml';
47
  } else {
48
+ Mage::throwException(
49
+ $this->__('Device doesn\'t recognized. Unable to load a template.')
50
+ );
51
  }
52
 
53
  $this->setTemplate($template);
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/General.php CHANGED
@@ -100,16 +100,16 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_General
100
  }
101
 
102
  $fieldset->addField('showdev', 'select', array(
103
- 'name' => 'showdev',
104
- 'label' => $this->__('Device Type'),
105
- 'title' => $this->__('Device Type'),
106
- 'values' => array($model->getType() => $model->getDevtype()),
107
- 'disabled' => true,
108
  ));
109
 
110
  $fieldset->addField('devtype', 'hidden', array(
111
- 'name' => 'devtype',
112
- 'value' => $model->getType(),
113
  ));
114
 
115
  $yesNoValues = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
@@ -153,7 +153,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_General
153
  */
154
  public function canShowTab()
155
  {
156
- return (bool)!Mage::getSingleton('adminhtml/session')->getNewApplication();
157
  }
158
 
159
  /**
100
  }
101
 
102
  $fieldset->addField('showdev', 'select', array(
103
+ 'name' => 'showdev',
104
+ 'label' => $this->__('Device Type'),
105
+ 'title' => $this->__('Device Type'),
106
+ 'values' => array($model->getType() => $model->getDevtype()),
107
+ 'disabled' => true,
108
  ));
109
 
110
  $fieldset->addField('devtype', 'hidden', array(
111
+ 'name' => 'devtype',
112
+ 'value' => $model->getType(),
113
  ));
114
 
115
  $yesNoValues = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
153
  */
154
  public function canShowTab()
155
  {
156
+ return (bool) !Mage::getSingleton('adminhtml/session')->getNewApplication();
157
  }
158
 
159
  /**
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/OfflineCatalog.php DELETED
@@ -1,115 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Tab for offline catalog management
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_OfflineCatalog
35
- extends Mage_Adminhtml_Block_Template
36
- implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
- {
38
- /**
39
- * Set design tab template
40
- * Set to show global icon
41
- */
42
- public function __construct()
43
- {
44
- parent::__construct();
45
- $this->setShowGlobalIcon(true);
46
- $this->setTemplate('xmlconnect/edit/tab/offlinecatalog.phtml');
47
- }
48
-
49
- /**
50
- * Prepare layout
51
- *
52
- * @return Mage_Core_Block_Abstract
53
- */
54
- protected function _prepareLayout()
55
- {
56
- $this->_addGenerateButton();
57
- return parent::_prepareLayout();
58
- }
59
-
60
- /**
61
- * Add generate button
62
- *
63
- * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_OfflineCatalog
64
- */
65
- protected function _addGenerateButton()
66
- {
67
- $generateButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
68
- 'label' => $this->__('Generate Offline Catalog'),
69
- 'onclick' => 'generateOfflineCatalog(); return false;',
70
- 'class' => 'save'
71
- ))->setName('generate_offline_catalog_button');
72
- $this->setChild('offline_catalog', $generateButton);
73
- return $this;
74
- }
75
-
76
- /**
77
- * Tab label getter
78
- *
79
- * @return string
80
- */
81
- public function getTabLabel()
82
- {
83
- return $this->__('Offline Catalog');
84
- }
85
-
86
- /**
87
- * Tab title getter
88
- *
89
- * @return string
90
- */
91
- public function getTabTitle()
92
- {
93
- return $this->__('Offline Catalog');
94
- }
95
-
96
- /**
97
- * Check if tab can be shown
98
- *
99
- * @return bool
100
- */
101
- public function canShowTab()
102
- {
103
- return (bool) !Mage::getSingleton('adminhtml/session')->getNewApplication();
104
- }
105
-
106
- /**
107
- * Check if tab hidden
108
- *
109
- * @return bool
110
- */
111
- public function isHidden()
112
- {
113
- return false;
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Payment.php CHANGED
@@ -80,6 +80,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Payment
80
 
81
  $deviceType = Mage::helper('xmlconnect')->getDeviceType();
82
  switch ($deviceType) {
 
83
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD:
84
  /**
85
  * PayPal MEP management
@@ -191,13 +192,13 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Payment
191
  )
192
  );
193
  break;
194
- case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPHONE:
195
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID:
196
  /**
197
  * PayPal MECL management
198
  */
199
  if (Mage::app()->isSingleStoreMode() || Mage::helper('xmlconnect')->getApplication()->getId()) {
200
- $paypalMeclIsAvailable = Mage::getModel('xmlconnect/payment_method_paypal_mecl')->isAvailable();
 
201
  $activateMeclMethodNote = $this->__('You need to enable PayPal Express Checkout first from the Payment configuration before enabling PayPal MECL.');
202
  } else {
203
  $paypalMeclIsAvailable = false;
@@ -223,6 +224,17 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Payment
223
  'value' => $paypalMeclActive,
224
  'disabled' => !$paypalMeclIsAvailable
225
  ));
 
 
 
 
 
 
 
 
 
 
 
226
  break;
227
  default:
228
  Mage::throwException(
80
 
81
  $deviceType = Mage::helper('xmlconnect')->getDeviceType();
82
  switch ($deviceType) {
83
+ case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPHONE:
84
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD:
85
  /**
86
  * PayPal MEP management
192
  )
193
  );
194
  break;
 
195
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID:
196
  /**
197
  * PayPal MECL management
198
  */
199
  if (Mage::app()->isSingleStoreMode() || Mage::helper('xmlconnect')->getApplication()->getId()) {
200
+ $paypalMeclIsAvailable = Mage::getModel('xmlconnect/payment_method_paypal_mecl')
201
+ ->isAvailable();
202
  $activateMeclMethodNote = $this->__('You need to enable PayPal Express Checkout first from the Payment configuration before enabling PayPal MECL.');
203
  } else {
204
  $paypalMeclIsAvailable = false;
224
  'value' => $paypalMeclActive,
225
  'disabled' => !$paypalMeclIsAvailable
226
  ));
227
+
228
+ /**
229
+ * PayPal MEP management
230
+ */
231
+ $fieldsetPaypal = $form->addFieldset('paypal_mep_checkout', array(
232
+ 'legend' => $this->__('PayPal Mobile Embedded Payment (MEP)')
233
+ ));
234
+ $fieldsetPaypal->addField('paypal_note', 'note', array(
235
+ 'label' => $this->__('Notice'),
236
+ 'text' => $this->__('Currently, PayPal MEP is not available for the Android application')
237
+ ));
238
  break;
239
  default:
240
  Mage::throwException(
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Settings.php CHANGED
@@ -37,11 +37,15 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Settings
37
  {
38
  protected function _prepareLayout()
39
  {
40
- $this->setChild('continue_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
41
- 'label' => Mage::helper('catalog')->__('Continue'),
42
- 'onclick' => "if (editForm.submit()) { return false }",
43
- 'class' => 'save'
44
- )));
 
 
 
 
45
  return parent::_prepareLayout();
46
  }
47
 
@@ -59,11 +63,11 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Settings
59
  $fieldset = $form->addFieldset('base_fieldset', array('legend' => $this->__('Device Information')));
60
 
61
  $fieldset->addField('type', 'select', array(
62
- 'name' => 'type',
63
- 'label' => $this->__('Device Type'),
64
- 'title' => $this->__('Device Type'),
65
- 'values' => Mage::helper('xmlconnect')->getDeviceTypeOptions(),
66
- 'required' => true
67
  ));
68
 
69
  $fieldset->addField('continue_button', 'note', array(
37
  {
38
  protected function _prepareLayout()
39
  {
40
+ $this->setChild('continue_button',
41
+ $this->getLayout()->createBlock('adminhtml/widget_button')
42
+ ->setData(array(
43
+ 'label' => Mage::helper('catalog')->__('Continue'),
44
+ 'onclick' => "if (editForm.submit()) { return false }",
45
+ 'class' => 'save'
46
+ )
47
+ )
48
+ );
49
  return parent::_prepareLayout();
50
  }
51
 
63
  $fieldset = $form->addFieldset('base_fieldset', array('legend' => $this->__('Device Information')));
64
 
65
  $fieldset->addField('type', 'select', array(
66
+ 'name' => 'type',
67
+ 'label' => $this->__('Device Type'),
68
+ 'title' => $this->__('Device Type'),
69
+ 'values' => Mage::helper('xmlconnect')->getDeviceTypeOptions(),
70
+ 'required' => true
71
  ));
72
 
73
  $fieldset->addField('continue_button', 'note', array(
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Social.php CHANGED
@@ -60,7 +60,9 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Social
60
  /**
61
  * Twitter fieldset options
62
  */
63
- $fieldsetTwitter = $form->addFieldset('twitter', array('legend' => $this->__('Twitter API')));
 
 
64
 
65
  if (isset($data['conf[native][socialNetworking][twitter][isActive]'])) {
66
  $twitterStatus = (int)$data['conf[native][socialNetworking][twitter][isActive]'];
@@ -111,11 +113,16 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Social
111
  )
112
  );
113
 
114
- $fieldsetTwitter->addField('twitterNote', 'note', array(
115
- 'text' => sprintf(
116
- $noteText,
117
- Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_TWITTER_URL)
118
- )));
 
 
 
 
 
119
 
120
  /**
121
  * Facebook fieldset options
@@ -156,15 +163,23 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Social
156
  )
157
  );
158
 
159
- $fieldsetFacebook->addField('facebookNote', 'note', array(
160
- 'text' => sprintf(
161
- $noteText, Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_FACEBOOK_URL)
162
- )));
 
 
 
 
 
 
163
 
164
  /**
165
  * LinkedIn fieldset options
166
  */
167
- $fieldsetLinkedin = $form->addFieldset('linkedin', array('legend' => $this->__('LinkedIn API')));
 
 
168
 
169
  if (isset($data['conf[native][socialNetworking][linkedin][isActive]'])) {
170
  $linkedinStatus = (int)$data['conf[native][socialNetworking][linkedin][isActive]'];
60
  /**
61
  * Twitter fieldset options
62
  */
63
+ $fieldsetTwitter = $form->addFieldset('twitter', array(
64
+ 'legend' => $this->__('Twitter API')
65
+ ));
66
 
67
  if (isset($data['conf[native][socialNetworking][twitter][isActive]'])) {
68
  $twitterStatus = (int)$data['conf[native][socialNetworking][twitter][isActive]'];
113
  )
114
  );
115
 
116
+ $fieldsetTwitter->addField(
117
+ 'twitterNote',
118
+ 'note',
119
+ array(
120
+ 'text' => sprintf(
121
+ $noteText,
122
+ Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_TWITTER_URL)
123
+ ),
124
+ )
125
+ );
126
 
127
  /**
128
  * Facebook fieldset options
163
  )
164
  );
165
 
166
+ $fieldsetFacebook->addField(
167
+ 'facebookNote',
168
+ 'note',
169
+ array(
170
+ 'text' => sprintf(
171
+ $noteText,
172
+ Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_FACEBOOK_URL)
173
+ ),
174
+ )
175
+ );
176
 
177
  /**
178
  * LinkedIn fieldset options
179
  */
180
+ $fieldsetLinkedin = $form->addFieldset('linkedin', array(
181
+ 'legend' => $this->__('LinkedIn API'),
182
+ ));
183
 
184
  if (isset($data['conf[native][socialNetworking][linkedin][isActive]'])) {
185
  $linkedinStatus = (int)$data['conf[native][socialNetworking][linkedin][isActive]'];
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Submission/History.php CHANGED
@@ -79,7 +79,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Submission_History
79
  */
80
  public function canShowTab()
81
  {
82
- return (bool)$this->_getApplication()->getId();
83
  }
84
 
85
  /**
79
  */
80
  public function canShowTab()
81
  {
82
+ return (bool) !Mage::getSingleton('adminhtml/session')->getNewApplication();
83
  }
84
 
85
  /**
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tabs.php CHANGED
@@ -31,9 +31,11 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
 
35
  {
36
  /**
 
37
  * Setting grid_id, DOM destination element id, Title
38
  */
39
  public function __construct()
@@ -54,7 +56,8 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tabs extends Mage_Adminhtml_Bl
54
  if (Mage::getSingleton('adminhtml/session')->getNewApplication()) {
55
  $this->addTab('set', array(
56
  'label' => $this->__('Settings'),
57
- 'content' => $this->getLayout()->createBlock('xmlconnect/adminhtml_mobile_edit_tab_settings')
 
58
  ->toHtml(),
59
  'active' => true
60
  ));
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tabs
35
+ extends Mage_Adminhtml_Block_Widget_Tabs
36
  {
37
  /**
38
+ * Constructor
39
  * Setting grid_id, DOM destination element id, Title
40
  */
41
  public function __construct()
56
  if (Mage::getSingleton('adminhtml/session')->getNewApplication()) {
57
  $this->addTab('set', array(
58
  'label' => $this->__('Settings'),
59
+ 'content' => $this->getLayout()
60
+ ->createBlock('xmlconnect/adminhtml_mobile_edit_tab_settings')
61
  ->toHtml(),
62
  'active' => true
63
  ));
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Addrow.php CHANGED
@@ -27,12 +27,12 @@
27
  /**
28
  * Xmlconnect Add row form element
29
  *
30
- * @deprecated will be removed
31
  * @category Mage
32
  * @package Mage_XmlConnect
33
  * @author Magento Core Team <core@magentocommerce.com>
34
  */
35
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Addrow extends Varien_Data_Form_Element_Button
 
36
  {
37
  /**
38
  * Render Element Html
@@ -41,9 +41,17 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Addrow extends Varien_
41
  */
42
  public function getElementHtml()
43
  {
44
- $html = $this->getBeforeElementHtml() . '<button id="'.$this->getHtmlId() . '" name="' . $this->getName()
45
- . '" value="'.$this->getEscapedValue() . '" ' . $this->serialize($this->getHtmlAttributes()) . ' ><span>'
46
- . $this->getEscapedValue() . '</span></button>' . $this->getAfterElementHtml();
 
 
 
 
 
 
 
 
47
  return $html;
48
  }
49
 
@@ -66,8 +74,10 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Addrow extends Varien_
66
  public function getLabelHtml($idSuffix = '')
67
  {
68
  if ($this->getLabel() !== null) {
69
- $html = '<label for="' . $this->getHtmlId() . $idSuffix . '">' . $this->getLabel()
70
- . ($this->getRequired() ? ' <span class="required">*</span>' : '') . '</label>';
 
 
71
  } else {
72
  $html = '';
73
  }
@@ -83,7 +93,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Addrow extends Varien_
83
  public function toHtml()
84
  {
85
  $blockClassName = Mage::getConfig()->getBlockClassName('adminhtml/template');
86
- $jsBlock = Mage::getModel($blockClassName);
87
  $jsBlock->setTemplate('xmlconnect/form/element/addrow.phtml');
88
  $jsBlock->setOptions($this->getOptions());
89
  return parent::toHtml() . $jsBlock->toHtml();
27
  /**
28
  * Xmlconnect Add row form element
29
  *
 
30
  * @category Mage
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Addrow
35
+ extends Varien_Data_Form_Element_Button
36
  {
37
  /**
38
  * Render Element Html
41
  */
42
  public function getElementHtml()
43
  {
44
+ $html = $this->getBeforeElementHtml()
45
+ . '<button id="'.$this->getHtmlId()
46
+ . '" name="'
47
+ . $this->getName()
48
+ . '" value="'.$this->getEscapedValue()
49
+ . '" '
50
+ . $this->serialize($this->getHtmlAttributes())
51
+ . ' ><span>'
52
+ . $this->getEscapedValue()
53
+ . '</span></button>'
54
+ . $this->getAfterElementHtml();
55
  return $html;
56
  }
57
 
74
  public function getLabelHtml($idSuffix = '')
75
  {
76
  if ($this->getLabel() !== null) {
77
+ $html = '<label for="' . $this->getHtmlId() . $idSuffix . '">'
78
+ . $this->getLabel()
79
+ . ($this->getRequired() ? ' <span class="required">*</span>' : '')
80
+ . '</label>';
81
  } else {
82
  $html = '';
83
  }
93
  public function toHtml()
94
  {
95
  $blockClassName = Mage::getConfig()->getBlockClassName('adminhtml/template');
96
+ $jsBlock = new $blockClassName;
97
  $jsBlock->setTemplate('xmlconnect/form/element/addrow.phtml');
98
  $jsBlock->setOptions($this->getOptions());
99
  return parent::toHtml() . $jsBlock->toHtml();
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Color.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Color extends Varien_Data_Form_Element_Text
 
35
  {
36
  /**
37
  * Return html code for current block
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Color
35
+ extends Varien_Data_Form_Element_Text
36
  {
37
  /**
38
  * Return html code for current block
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Country.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Country extends Varien_Data_Form_Element_Checkboxes
 
35
  {
36
  /**
37
  * Flag of using the border in the table's TD
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Country
35
+ extends Varien_Data_Form_Element_Checkboxes
36
  {
37
  /**
38
  * Flag of using the border in the table's TD
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Datetime.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Datetime extends Varien_Data_Form_Element_Abstract
 
35
  {
36
  /**
37
  * Date
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Datetime
35
+ extends Varien_Data_Form_Element_Abstract
36
  {
37
  /**
38
  * Date
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Font.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Font extends Varien_Data_Form_Element_Abstract
 
35
  {
36
  /**
37
  * Init font element
@@ -96,7 +97,9 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Font extends Varien_Da
96
  foreach ($this->getElements() as $element) {
97
  $elementsArray[] .= $element->toHtml();
98
  }
99
- return $elementsArray[0] . $elementsArray[1] . '</td><td class="label" style="width: 2em !important">'
 
 
100
  . $elementsArray[2];
101
  }
102
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Font
35
+ extends Varien_Data_Form_Element_Abstract
36
  {
37
  /**
38
  * Init font element
97
  foreach ($this->getElements() as $element) {
98
  $elementsArray[] .= $element->toHtml();
99
  }
100
+ return $elementsArray[0]
101
+ . $elementsArray[1]
102
+ . '</td><td class="label" style="width: 2em !important">'
103
  . $elementsArray[2];
104
  }
105
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Image.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Image extends Varien_Data_Form_Element_Image
 
35
  {
36
  /**
37
  * Function fetches image Url actual or default
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Image
35
+ extends Varien_Data_Form_Element_Image
36
  {
37
  /**
38
  * Function fetches image Url actual or default
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Page.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Page extends Varien_Data_Form_Element_Abstract
 
35
  {
36
  /**
37
  * Init page element
@@ -97,8 +98,10 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Page extends Varien_Da
97
  public function getElementHtml()
98
  {
99
  list($label, $element) = $this->getElements();
100
- return $element->toHtml() . '</td><td class="label" style="width: 5em">'
 
101
  . '<button class=" scalable save onclick_button" value="&minus;"><span>'
102
- . Mage::helper('xmlconnect')->__('Delete') . '</span></button>';
 
103
  }
104
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Page
35
+ extends Varien_Data_Form_Element_Abstract
36
  {
37
  /**
38
  * Init page element
98
  public function getElementHtml()
99
  {
100
  list($label, $element) = $this->getElements();
101
+ return $element->toHtml()
102
+ . '</td><td class="label" style="width: 5em">'
103
  . '<button class=" scalable save onclick_button" value="&minus;"><span>'
104
+ . Mage::helper('xmlconnect')->__('Delete')
105
+ . '</span></button>';
106
  }
107
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Tabs.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Tabs extends Varien_Data_Form_Element_Text
 
35
  {
36
  /**
37
  * Generate application tabs html
@@ -45,12 +46,14 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Tabs extends Varien_Da
45
  }
46
 
47
  $blockClassName = Mage::getConfig()->getBlockClassName('adminhtml/template');
48
- $block = Mage::getModel($blockClassName);
49
  $device = Mage::helper('xmlconnect')->getDeviceType();
50
  if (array_key_exists($device, Mage::helper('xmlconnect')->getSupportedDevices())) {
51
  $template = 'xmlconnect/form/element/app_tabs_' . strtolower($device) . '.phtml';
52
  } else {
53
- Mage::throwException($this->__('Device doesn\'t recognized. Unable to load a template.'));
 
 
54
  }
55
 
56
  $block->setTemplate($template);
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Tabs
35
+ extends Varien_Data_Form_Element_Text
36
  {
37
  /**
38
  * Generate application tabs html
46
  }
47
 
48
  $blockClassName = Mage::getConfig()->getBlockClassName('adminhtml/template');
49
+ $block = new $blockClassName;
50
  $device = Mage::helper('xmlconnect')->getDeviceType();
51
  if (array_key_exists($device, Mage::helper('xmlconnect')->getSupportedDevices())) {
52
  $template = 'xmlconnect/form/element/app_tabs_' . strtolower($device) . '.phtml';
53
  } else {
54
+ Mage::throwException(
55
+ $this->__('Device doesn\'t recognized. Unable to load a template.')
56
+ );
57
  }
58
 
59
  $block->setTemplate($template);
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Theme.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Theme extends Varien_Data_Form_Element_Text
 
35
  {
36
  /**
37
  * Generate themes (colors) html
@@ -40,8 +41,9 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Theme extends Varien_D
40
  */
41
  public function getHtml()
42
  {
43
- $blockClassName = Mage::getConfig()->getBlockClassName('xmlconnect/adminhtml_mobile_edit_tab_design_themes');
44
- $block = Mage::getModel($blockClassName);
 
45
  $block->setThemes($this->getThemes());
46
  $block->setName($this->getName());
47
  $block->setValue($this->getValue());
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Theme
35
+ extends Varien_Data_Form_Element_Text
36
  {
37
  /**
38
  * Generate themes (colors) html
41
  */
42
  public function getHtml()
43
  {
44
+ $blockClassName = Mage::getConfig()
45
+ ->getBlockClassName('xmlconnect/adminhtml_mobile_edit_tab_design_themes');
46
+ $block = new $blockClassName;
47
  $block->setThemes($this->getThemes());
48
  $block->setName($this->getName());
49
  $block->setValue($this->getValue());
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Grid/Renderer/Bool.php CHANGED
@@ -46,10 +46,14 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Grid_Renderer_Bool
46
  $status = (int) $row->getData($this->getColumn()->getIndex());
47
  $options = Mage::helper('xmlconnect')->getStatusOptions();
48
  if ($status == Mage_XmlConnect_Model_Application::APP_STATUS_SUCCESS) {
49
- $result = '<img src="' . Mage::helper('xmlconnect/image')->getSkinImagesUrl('gel_green.png') . '" >&nbsp;'
 
 
50
  . (isset($options[$status]) ? $options[$status] : '');
51
  } else if ($status == Mage_XmlConnect_Model_Application::APP_STATUS_INACTIVE) {
52
- $result = '<img src="' . Mage::helper('xmlconnect/image')->getSkinImagesUrl('gel_red.png') . '" >&nbsp;'
 
 
53
  . (isset($options[$status]) ? $options[$status] : '');
54
  }
55
  return $result;
46
  $status = (int) $row->getData($this->getColumn()->getIndex());
47
  $options = Mage::helper('xmlconnect')->getStatusOptions();
48
  if ($status == Mage_XmlConnect_Model_Application::APP_STATUS_SUCCESS) {
49
+ $result = '<img src="'
50
+ . Mage::helper('xmlconnect/image')->getSkinImagesUrl('gel_green.png')
51
+ . '" >&nbsp;'
52
  . (isset($options[$status]) ? $options[$status] : '');
53
  } else if ($status == Mage_XmlConnect_Model_Application::APP_STATUS_INACTIVE) {
54
+ $result = '<img src="'
55
+ . Mage::helper('xmlconnect/image')->getSkinImagesUrl('gel_red.png')
56
+ . '" >&nbsp;'
57
  . (isset($options[$status]) ? $options[$status] : '');
58
  }
59
  return $result;
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Form.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Form extends Mage_Adminhtml_Block_Widget_Form
 
35
  {
36
  /**
37
  * Prepare form before rendering HTML
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Form
35
+ extends Mage_Adminhtml_Block_Widget_Form
36
  {
37
  /**
38
  * Prepare form before rendering HTML
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Tab/Container/Submission.php CHANGED
@@ -191,7 +191,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Tab_Container_Submission
191
  $fieldset->addField('conf/submit_text/contact_email', 'text', array(
192
  'name' => 'conf[submit_text][email]',
193
  'label' => $this->__('Contact Email'),
194
- 'class' => 'validate-email email',
195
  'maxlength' => '40',
196
  'value' => isset($formData['conf[submit_text][email]']) ? $formData['conf[submit_text][email]'] : null,
197
  'note' => $this->__('Administrative contact for this app and for app submission issues.'),
@@ -270,54 +270,54 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Tab_Container_Submission
270
  switch ($deviceType) {
271
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPHONE:
272
  $this->addImage($fieldset, 'conf/submit/icon', $this->__('Large iTunes Icon'),
273
- $this->__('Large icon that appears in the iTunes App Store. You do not need to apply a gradient or soft edges (this is done automatically by Apple).') . $this->__('Required size: %spx x %spx.', 512, 512), '', true);
274
 
275
  $this->addImage($fieldset, 'conf/submit/loader_image', $this->__('Loader Splash Screen'),
276
- $this->__('Image that appears on first screen while your app is loading.') . $this->__('Required size: %spx x %spx.', 320, 460), '', true);
277
 
278
  $this->addImage($fieldset, 'conf/submit/loader_image_i4', $this->__('Loader Splash Screen <br />(iPhone 4 retina)'),
279
- $this->__('Image that appears on first screen while your app is loading.') . $this->__('Required size: %spx x %spx.', 640, 920), '', false);
280
 
281
  $this->addImage($fieldset, 'conf/submit/logo', $this->__('Custom App Icon'),
282
- $this->__('Icon that will appear on the user\'s phone after they download your app. You do not need to apply a gradient or soft edges (this is done automatically by Apple).') . $this->__('Recommended size: %spx x %spx at %s dpi.', 57, 57, 72), '', true);
283
 
284
  $this->addImage($fieldset, 'conf/submit/logo_i4', $this->__('Custom App Icon <br />(iPhone 4 retina)'),
285
- $this->__('Icon that will appear on the user\'s phone after they download your app. You do not need to apply a gradient or soft edges (this is done automatically by Apple).') . $this->__('Recommended size: %spx x %spx.', 114, 114), '', false);
286
 
287
  $this->addImage($fieldset, 'conf/submit/big_logo', $this->__('Copyright Page Logo'),
288
- $this->__('Store logo that is displayed on copyright page of app.') . $this->__('Preferred size: %spx x %spx.', 100, 100), '', true);
289
 
290
  $this->addImage($fieldset, 'conf/submit/big_logo_i4', $this->__('Copyright Page Logo <br />(iPhone 4 retina)'),
291
- $this->__('Store logo that is displayed on copyright page of app.') . $this->__('Preferred size: %spx x %spx.', 200, 200), '', false);
292
  break;
293
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD:
294
  $this->addImage($fieldset, 'conf/submit/icon', $this->__('Large iTunes Icon'),
295
- $this->__('Large icon that appears in the iTunes App Store. You do not need to apply a gradient or soft edges (this is done automatically by Apple).') . $this->__('Required size: %spx x %spx.', 512, 512), '', true);
296
 
297
  $this->addImage($fieldset, 'conf/submit/ipad_loader_portrait_image', $this->__('Loader Splash Screen <br />(portrait mode)'),
298
- $this->__('Image that appears on first screen while your app is loading.') . $this->__('Required size: %spx x %spx.', 768, 1024), '', true);
299
 
300
  $this->addImage($fieldset, 'conf/submit/ipad_loader_landscape_image', $this->__('Loader Splash Screen <br />(landscape mode)'),
301
- $this->__('Image that appears on first screen while your app is loading.') . $this->__('Required size: %spx x %spx.', 1024, 768), '', true);
302
 
303
  $this->addImage($fieldset, 'conf/submit/ipad_logo', $this->__('Custom App Icon'),
304
- $this->__('Icon that will appear on the user\'s device after they download your app. You do not need to apply a gradient or soft edges (this is done automatically by Apple).') . $this->__('Recommended size: %spx x %spx.', 72, 72), '', true);
305
 
306
  $this->addImage($fieldset, 'conf/submit/big_logo', $this->__('Copyright Page Logo'),
307
- $this->__('Store logo that is displayed on copyright page of app.') . $this->__('Preferred size: %spx x %spx.', 100, 100), '', true);
308
  break;
309
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID:
310
  $this->addImage($fieldset, 'conf/submit/icon', $this->__('High Resolution Application Icon'),
311
- $this->__('The icon that appears in the Android Market.') . $this->__('Recommended size: %spx x %spx.', 512, 512) . $this->__('Maximum size: %s KB.', 1024), '', true);
312
 
313
  $this->addImage($fieldset, 'conf/submit/android_loader_image', $this->__('Loader Splash Screen'),
314
- $this->__('Image that appears on first screen while your app is loading.') . $this->__('Required size: %spx x %spx.', 320, 455), '', true);
315
 
316
  $this->addImage($fieldset, 'conf/submit/android_logo', $this->__('Custom App Icon'),
317
- $this->__('Icon that will appear on the user\'s device after they download your app.') . $this->__('Recommended size: %spx x %spx.', 48, 48), '', true);
318
 
319
  $this->addImage($fieldset, 'conf/submit/big_logo', $this->__('Copyright Page Logo'),
320
- $this->__('Store logo that is displayed on copyright page of app.') . $this->__('Preferred size: %spx x %spx.', 100, 100), '', true);
321
  break;
322
  }
323
 
191
  $fieldset->addField('conf/submit_text/contact_email', 'text', array(
192
  'name' => 'conf[submit_text][email]',
193
  'label' => $this->__('Contact Email'),
194
+ 'class' => 'email',
195
  'maxlength' => '40',
196
  'value' => isset($formData['conf[submit_text][email]']) ? $formData['conf[submit_text][email]'] : null,
197
  'note' => $this->__('Administrative contact for this app and for app submission issues.'),
270
  switch ($deviceType) {
271
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPHONE:
272
  $this->addImage($fieldset, 'conf/submit/icon', $this->__('Large iTunes Icon'),
273
+ $this->__('Large icon that appears in the iTunes App Store. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Required size: 512px x 512px.'), '', true);
274
 
275
  $this->addImage($fieldset, 'conf/submit/loader_image', $this->__('Loader Splash Screen'),
276
+ $this->__('Image that appears on first screen while your app is loading. Required size: 320px x 460px.'), '', true);
277
 
278
  $this->addImage($fieldset, 'conf/submit/loader_image_i4', $this->__('Loader Splash Screen <br />(iPhone 4 retina)'),
279
+ $this->__('Image that appears on first screen while your app is loading. Required size: 640px x 920px.'), '', false);
280
 
281
  $this->addImage($fieldset, 'conf/submit/logo', $this->__('Custom App Icon'),
282
+ $this->__('Icon that will appear on the users phone after they download your app. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Recommended size: 57px x 57px at 72 dpi.'), '', true);
283
 
284
  $this->addImage($fieldset, 'conf/submit/logo_i4', $this->__('Custom App Icon <br />(iPhone 4 retina)'),
285
+ $this->__('Icon that will appear on the user\'s phone after they download your app. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Recommended size: 114px x 114px.'), '', false);
286
 
287
  $this->addImage($fieldset, 'conf/submit/big_logo', $this->__('Copyright Page Logo'),
288
+ $this->__('Store logo that is displayed on copyright page of app. Preferred size: 100px x 100px.'), '', true);
289
 
290
  $this->addImage($fieldset, 'conf/submit/big_logo_i4', $this->__('Copyright Page Logo <br />(iPhone 4 retina)'),
291
+ $this->__('Store logo that is displayed on copyright page of app. Preferred size: 200px x 200px.'), '', false);
292
  break;
293
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD:
294
  $this->addImage($fieldset, 'conf/submit/icon', $this->__('Large iTunes Icon'),
295
+ $this->__('Large icon that appears in the iTunes App Store. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Required size: 512px x 512px.'), '', true);
296
 
297
  $this->addImage($fieldset, 'conf/submit/ipad_loader_portrait_image', $this->__('Loader Splash Screen <br />(portrait mode)'),
298
+ $this->__('Image that appears on first screen while your app is loading. Required size: 768px x 1024px.'), '', true);
299
 
300
  $this->addImage($fieldset, 'conf/submit/ipad_loader_landscape_image', $this->__('Loader Splash Screen <br />(landscape mode)'),
301
+ $this->__('Image that appears on first screen while your app is loading. Required size: 1024px x 768px.'), '', true);
302
 
303
  $this->addImage($fieldset, 'conf/submit/ipad_logo', $this->__('Custom App Icon'),
304
+ $this->__('Icon that will appear on the user\'s device after they download your app. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Recommended size: 72px x 72px.'), '', true);
305
 
306
  $this->addImage($fieldset, 'conf/submit/big_logo', $this->__('Copyright Page Logo'),
307
+ $this->__('Store logo that is displayed on copyright page of app. Preferred size: 100px x 100px.'), '', true);
308
  break;
309
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID:
310
  $this->addImage($fieldset, 'conf/submit/icon', $this->__('High Resolution Application Icon'),
311
+ $this->__('The icon that appears in the Android Market. Recommended size: 512px x 512px. Maximum size: 1024 KB.'), '', true);
312
 
313
  $this->addImage($fieldset, 'conf/submit/android_loader_image', $this->__('Loader Splash Screen'),
314
+ $this->__('Image that appears on first screen while your app is loading. Required size: 320px x 455px.'), '', true);
315
 
316
  $this->addImage($fieldset, 'conf/submit/android_logo', $this->__('Custom App Icon'),
317
+ $this->__('Icon that will appear on the user\'s device after they download your app. Recommended size: 48px x 48px.'), '', true);
318
 
319
  $this->addImage($fieldset, 'conf/submit/big_logo', $this->__('Copyright Page Logo'),
320
+ $this->__('Store logo that is displayed on copyright page of app. Preferred size: 100px x 100px.'), '', true);
321
  break;
322
  }
323
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Tabs.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
 
35
  {
36
  /**
37
  * Constructor
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Tabs
35
+ extends Mage_Adminhtml_Block_Widget_Tabs
36
  {
37
  /**
38
  * Constructor
app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Edit.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Queue_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
 
35
  {
36
  /**
37
  * Constructor
@@ -65,7 +66,8 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Edit extends Mage_Adminhtml_Block_Wi
65
  {
66
  $template = Mage::registry('current_template');
67
  $message = Mage::registry('current_message');
68
- return $message && !$message->getId() && $template && $template->getId() ? $this->getUrl('*/*/template')
 
69
  : $this->getUrl('*/*/queue');
70
  }
71
 
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Queue_Edit
35
+ extends Mage_Adminhtml_Block_Widget_Form_Container
36
  {
37
  /**
38
  * Constructor
66
  {
67
  $template = Mage::registry('current_template');
68
  $message = Mage::registry('current_message');
69
+ return $message && !$message->getId() && $template && $template->getId()
70
+ ? $this->getUrl('*/*/template')
71
  : $this->getUrl('*/*/queue');
72
  }
73
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Edit/Form.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Queue_Edit_Form extends Mage_XmlConnect_Block_Adminhtml_Template_Edit_Form
 
35
  {
36
  /**
37
  * Prepare form before rendering HTML
@@ -58,11 +59,15 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Edit_Form extends Mage_XmlConnect_Bl
58
  }
59
 
60
  $fieldset = $this->getForm()->addFieldset(
61
- "message_settings", array('legend' => $this->__('Message Settings')), '^'
 
 
62
  );
63
 
64
  if ($model->getId()) {
65
- $fieldset->addField('message_id', 'hidden', array('name' => 'message_id'));
 
 
66
  }
67
 
68
  // set exec_time for showing accordingly to locale datetime settings
@@ -150,14 +155,12 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Edit_Form extends Mage_XmlConnect_Bl
150
  if (!$model->getTemplateId()) {
151
  $model->setTemplateId($templateModel->getId());
152
  }
153
- if (!$model->getApplicationId()) {
154
- $model->setApplicationId($templateModel->getApplicationId());
155
- }
156
  $model->setMessageId($model->getId());
 
157
 
158
  $this->getForm()->setAction($this->getUrl('*/*/saveMessage'));
159
  $this->getForm()->setValues($model->getData());
160
 
161
  $this->setForm($this->getForm());
162
- }
163
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Queue_Edit_Form
35
+ extends Mage_XmlConnect_Block_Adminhtml_Template_Edit_Form
36
  {
37
  /**
38
  * Prepare form before rendering HTML
59
  }
60
 
61
  $fieldset = $this->getForm()->addFieldset(
62
+ "message_settings",
63
+ array('legend' => $this->__('Message Settings')),
64
+ '^'
65
  );
66
 
67
  if ($model->getId()) {
68
+ $fieldset->addField('message_id', 'hidden', array(
69
+ 'name' => 'message_id'
70
+ ));
71
  }
72
 
73
  // set exec_time for showing accordingly to locale datetime settings
155
  if (!$model->getTemplateId()) {
156
  $model->setTemplateId($templateModel->getId());
157
  }
 
 
 
158
  $model->setMessageId($model->getId());
159
+ $model->setData('app_code', $templateModel->getData('app_code'));
160
 
161
  $this->getForm()->setAction($this->getUrl('*/*/saveMessage'));
162
  $this->getForm()->setValues($model->getData());
163
 
164
  $this->setForm($this->getForm());
165
+ }
166
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Grid.php CHANGED
@@ -55,7 +55,8 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Grid extends Mage_Adminhtml_Block_Wi
55
  $collection = Mage::getModel('xmlconnect/queue')->getCollection();
56
 
57
  $collection->addFieldToFilter(
58
- 'main_table.status', array('neq' => Mage_XmlConnect_Model_Queue::STATUS_DELETED)
 
59
  );
60
  $this->setCollection($collection);
61
  return parent::_prepareCollection();
@@ -158,13 +159,13 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Grid extends Mage_Adminhtml_Block_Wi
158
  $this->getMassactionBlock()->addItem('delete', array(
159
  'label' => $this->__('Delete'),
160
  'url' => $this->getUrl('*/*/massDeleteQueue'),
161
- 'confirm' => $this->__('Are you sure you want to delete selected records?')
162
  ));
163
 
164
  $this->getMassactionBlock()->addItem('cancel', array(
165
  'label' => $this->__('Cancel'),
166
  'url' => $this->getUrl('*/*/massCancelQueue'),
167
- 'confirm' => $this->__('Are you sure you want to cancel selected records?')
168
  ));
169
  return $this;
170
  }
55
  $collection = Mage::getModel('xmlconnect/queue')->getCollection();
56
 
57
  $collection->addFieldToFilter(
58
+ 'main_table.status',
59
+ array('neq' => Mage_XmlConnect_Model_Queue::STATUS_DELETED)
60
  );
61
  $this->setCollection($collection);
62
  return parent::_prepareCollection();
159
  $this->getMassactionBlock()->addItem('delete', array(
160
  'label' => $this->__('Delete'),
161
  'url' => $this->getUrl('*/*/massDeleteQueue'),
162
+ 'confirm' => $this->__('Are you sure you what to delete selected records?')
163
  ));
164
 
165
  $this->getMassactionBlock()->addItem('cancel', array(
166
  'label' => $this->__('Cancel'),
167
  'url' => $this->getUrl('*/*/massCancelQueue'),
168
+ 'confirm' => $this->__('Are you sure you what to cancel selected records?')
169
  ));
170
  return $this;
171
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Grid/Renderer/Action.php CHANGED
@@ -58,14 +58,14 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Grid_Renderer_Action
58
  $actions[] = array(
59
  'caption' => $this->__('Cancel'),
60
  'url' => $this->getUrl('*/*/cancelQueue', array('id' => $row->getId())),
61
- 'confirm' => $this->__('Are you sure you want to cancel a message?')
62
  );
63
  }
64
 
65
  $actions[] = array(
66
  'caption' => $this->__('Delete'),
67
  'url' => $this->getUrl('*/*/deleteQueue', array('id' => $row->getId())),
68
- 'confirm' => $this->__('Are you sure you want to delete a message?')
69
  );
70
 
71
  $this->getColumn()->setActions($actions);
58
  $actions[] = array(
59
  'caption' => $this->__('Cancel'),
60
  'url' => $this->getUrl('*/*/cancelQueue', array('id' => $row->getId())),
61
+ 'confirm' => $this->__('Are you sure you whant to cancel a message?')
62
  );
63
  }
64
 
65
  $actions[] = array(
66
  'caption' => $this->__('Delete'),
67
  'url' => $this->getUrl('*/*/deleteQueue', array('id' => $row->getId())),
68
+ 'confirm' => $this->__('Are you sure you whant to delete a message?')
69
  );
70
 
71
  $this->getColumn()->setActions($actions);
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Edit.php CHANGED
@@ -43,8 +43,9 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Edit extends Mage_Adminhtml_Block
43
  $this->_blockGroup = 'xmlconnect';
44
  parent::__construct();
45
 
46
- $this->_updateButton('delete', 'onclick', 'deleteConfirm(\'' . $this->__('Warning: All related AirMail messages will be deleted!')
47
- . '\n' . $this->__('Are you sure you want to do this?') .'\', \'' . $this->getDeleteUrl() . '\')'
 
48
  );
49
  $this->_updateButton('save', 'label', $this->__('Save'));
50
  $this->_updateButton('save', 'onclick', 'if (editForm.submit()) {disableElements(\'save\')}');
@@ -58,9 +59,7 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Edit extends Mage_Adminhtml_Block
58
  */
59
  public function getDeleteUrl()
60
  {
61
- return $this->getUrl('*/*/deletetemplate', array(
62
- $this->_objectId => $this->getRequest()->getParam($this->_objectId)
63
- ));
64
  }
65
 
66
  /**
43
  $this->_blockGroup = 'xmlconnect';
44
  parent::__construct();
45
 
46
+ $this->_updateButton('delete', 'onclick', 'deleteConfirm(\''
47
+ . $this->__('Warning: All related AirMail messages will be deleted!') . PHP_EOL
48
+ . $this->__('Are you sure you want to do this?') .'\', \'' . $this->getDeleteUrl() . '\')'
49
  );
50
  $this->_updateButton('save', 'label', $this->__('Save'));
51
  $this->_updateButton('save', 'onclick', 'if (editForm.submit()) {disableElements(\'save\')}');
59
  */
60
  public function getDeleteUrl()
61
  {
62
+ return $this->getUrl('*/*/deletetemplate', array($this->_objectId => $this->getRequest()->getParam($this->_objectId)));
 
 
63
  }
64
 
65
  /**
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Edit/Form.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Template_Edit_Form extends Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
 
35
  {
36
  /**
37
  * Enabled fields flag
@@ -85,8 +86,12 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Edit_Form extends Mage_XmlConnect
85
  $this->_addElementTypes($fieldset);
86
 
87
  if ($model->getId()) {
88
- $fieldset->addField('id', 'hidden', array('name' => 'id'));
89
- $fieldset->addField('template_id', 'hidden', array('name' => 'template_id'));
 
 
 
 
90
  }
91
 
92
  $fieldset->addField('application_id', 'select', array(
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Template_Edit_Form
35
+ extends Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
36
  {
37
  /**
38
  * Enabled fields flag
86
  $this->_addElementTypes($fieldset);
87
 
88
  if ($model->getId()) {
89
+ $fieldset->addField('id', 'hidden', array(
90
+ 'name' => 'id',
91
+ ));
92
+ $fieldset->addField('template_id', 'hidden', array(
93
+ 'name' => 'template_id',
94
+ ));
95
  }
96
 
97
  $fieldset->addField('application_id', 'select', array(
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Grid/Renderer/Name.php CHANGED
@@ -44,5 +44,5 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Grid_Renderer_Name
44
  {
45
  $str = $this->escapeHtml($row->getName());
46
  return $str;
47
- }
48
  }
44
  {
45
  $str = $this->escapeHtml($row->getName());
46
  return $str;
47
+ }
48
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Preview/Form.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Adminhtml_Template_Preview_Form extends Mage_Adminhtml_Block_Widget_Form
 
35
  {
36
  /**
37
  * Preparing from for revision page
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Adminhtml_Template_Preview_Form
35
+ extends Mage_Adminhtml_Block_Widget_Form
36
  {
37
  /**
38
  * Preparing from for revision page
app/code/core/Mage/XmlConnect/Block/Cart.php CHANGED
@@ -49,8 +49,6 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
49
  if (strlen($quote->getCouponCode())) {
50
  $xmlObject->addAttribute('has_coupon_code', 1);
51
  }
52
-
53
- $productSmallImageSize = Mage::getModel('xmlconnect/images')->getImageLimitParam('content/product_small');
54
  $products = $xmlObject->addChild('products');
55
  /* @var $item Mage_Sales_Model_Quote_Item */
56
  foreach ($this->getItems() as $item) {
@@ -66,9 +64,12 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
66
  $itemXml->addChild('name', $xmlObject->escapeXml($renderer->getProductName()));
67
  $itemXml->addChild('code', 'cart[' . $item->getId() . '][qty]');
68
  $itemXml->addChild('qty', $renderer->getQty());
69
- $icon = $renderer->getProductThumbnail()->resize($productSmallImageSize);
 
 
70
  $iconXml = $itemXml->addChild('icon', $icon);
71
- $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
 
72
  /**
73
  * Price
74
  */
@@ -78,19 +79,19 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
78
  && $item->getWeeeTaxAppliedAmount()
79
  ) {
80
  $exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount()
81
- + $item->getWeeeTaxDisposition();
82
  } else {
83
  $exclPrice = $item->getCalculationPrice();
84
  }
85
  }
86
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
87
- $incl = $this->helper('checkout')->getPriceInclTax($item);
88
  if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
89
  && $item->getWeeeTaxAppliedAmount()
90
  ) {
91
- $inclPrice = $incl + $item->getWeeeTaxAppliedAmount();
92
  } else {
93
- $inclPrice = $incl - $item->getWeeeTaxDisposition();
94
  }
95
  }
96
  $exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice);
@@ -150,13 +151,13 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
150
  }
151
  }
152
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
153
- $incl = $this->helper('checkout')->getSubtotalInclTax($item);
154
  if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
155
  && $item->getWeeeTaxAppliedAmount()
156
  ) {
157
- $inclPrice = $incl + $item->getWeeeTaxAppliedRowAmount();
158
  } else {
159
- $inclPrice = $incl - $item->getWeeeTaxRowDisposition();
160
  }
161
  }
162
 
@@ -189,27 +190,14 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
189
  /**
190
  * Options list
191
  */
192
- $options = $renderer->getOptionList();
193
- if ($options) {
194
  $itemOptionsXml = $itemXml->addChild('options');
195
- foreach ($options as $option) {
196
- $formattedOptionValue = $renderer->getFormatedOptionValue($option);
197
  $optionXml = $itemOptionsXml->addChild('option');
198
- $optionXml->addAttribute('label', $xmlObject->xmlAttribute($option['label']));
199
- $optionXml->addAttribute('text', $xmlObject->xmlAttribute($formattedOptionValue['value']));
200
- }
201
- }
202
-
203
- /**
204
- * Downloadable products
205
- */
206
- $links = $renderer->getLinks();
207
- if ($links) {
208
- $itemOptionsXml = $itemXml->addCustomChild('options', null, array(
209
- 'label' => $renderer->getLinksTitle()
210
- ));
211
- foreach ($links as $link) {
212
- $itemOptionsXml->addCustomChild('option', null, array('label' => $link->getTitle()));
213
  }
214
  }
215
 
49
  if (strlen($quote->getCouponCode())) {
50
  $xmlObject->addAttribute('has_coupon_code', 1);
51
  }
 
 
52
  $products = $xmlObject->addChild('products');
53
  /* @var $item Mage_Sales_Model_Quote_Item */
54
  foreach ($this->getItems() as $item) {
64
  $itemXml->addChild('name', $xmlObject->escapeXml($renderer->getProductName()));
65
  $itemXml->addChild('code', 'cart[' . $item->getId() . '][qty]');
66
  $itemXml->addChild('qty', $renderer->getQty());
67
+ $icon = $renderer->getProductThumbnail()->resize(
68
+ Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small')
69
+ );
70
  $iconXml = $itemXml->addChild('icon', $icon);
71
+ $file = Mage::helper('xmlconnect')->urlToPath($icon);
72
+ $iconXml->addAttribute('modification_time', filemtime($file));
73
  /**
74
  * Price
75
  */
79
  && $item->getWeeeTaxAppliedAmount()
80
  ) {
81
  $exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount()
82
+ + $item->getWeeeTaxDisposition();
83
  } else {
84
  $exclPrice = $item->getCalculationPrice();
85
  }
86
  }
87
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
88
+ $_incl = $this->helper('checkout')->getPriceInclTax($item);
89
  if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
90
  && $item->getWeeeTaxAppliedAmount()
91
  ) {
92
+ $inclPrice = $_incl + $item->getWeeeTaxAppliedAmount();
93
  } else {
94
+ $inclPrice = $_incl - $item->getWeeeTaxDisposition();
95
  }
96
  }
97
  $exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice);
151
  }
152
  }
153
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
154
+ $_incl = $this->helper('checkout')->getSubtotalInclTax($item);
155
  if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
156
  && $item->getWeeeTaxAppliedAmount()
157
  ) {
158
+ $inclPrice = $_incl + $item->getWeeeTaxAppliedRowAmount();
159
  } else {
160
+ $inclPrice = $_incl - $item->getWeeeTaxRowDisposition();
161
  }
162
  }
163
 
190
  /**
191
  * Options list
192
  */
193
+ $_options = $renderer->getOptionList();
194
+ if ($_options) {
195
  $itemOptionsXml = $itemXml->addChild('options');
196
+ foreach ($_options as $_option) {
197
+ $_formattedOptionValue = $renderer->getFormatedOptionValue($_option);
198
  $optionXml = $itemOptionsXml->addChild('option');
199
+ $optionXml->addAttribute('label', $xmlObject->xmlAttribute($_option['label']));
200
+ $optionXml->addAttribute('text', $xmlObject->xmlAttribute($_formattedOptionValue['value']));
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  }
202
  }
203
 
app/code/core/Mage/XmlConnect/Block/Cart/CartTotals.php DELETED
@@ -1,95 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Shopping cart totals xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_Xmlconnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Cart_CartTotals extends Mage_Checkout_Block_Cart_Totals
35
- {
36
- /**
37
- * Default totals renderer
38
- *
39
- * @var string
40
- */
41
- protected $_defaultRenderer = 'xmlconnect/cart_cartTotals_default';
42
-
43
- /**
44
- * Render cart totals xml
45
- *
46
- * @return Mage_XmlConnect_Model_Simplexml_Element
47
- */
48
- protected function _toHtml()
49
- {
50
- /** @var $cartXmlObject Mage_XmlConnect_Model_Simplexml_Element */
51
- $cartXmlObject = $this->getCartXmlObject();
52
- /** @var $totalsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
53
- $totalsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<totals></totals>');
54
-
55
- foreach($this->getTotals() as $total) {
56
- $code = $total->getCode();
57
- if ($total->getAs()) {
58
- $code = $total->getAs();
59
- }
60
- $isNode = Mage::getConfig()->getNode("global/xmlconnect/sales/quote/totals/{$code}/is_node");
61
- if ($isNode) {
62
- $this->_getTotalRenderer($code)->setTotal($total)->setCartObject($cartXmlObject)->toHtml();
63
- } else {
64
- $this->_getTotalRenderer($code)->setTotal($total)->setCartObject($totalsXmlObj)->toHtml();
65
- }
66
- }
67
- $cartXmlObject->appendChild($totalsXmlObj);
68
- return $this;
69
- }
70
-
71
- /**
72
- * Get renderer block
73
- *
74
- * @param string $code
75
- * @return Mage_Core_Block_Abstract
76
- */
77
- protected function _getTotalRenderer($code)
78
- {
79
- $blockName = $code . '_total_renderer';
80
- $block = $this->getLayout()->getBlock($blockName);
81
- if (!$block) {
82
- $block = $this->_defaultRenderer;
83
- $config = Mage::getConfig()->getNode("global/xmlconnect/sales/quote/totals/{$code}/renderer");
84
- if ($config) {
85
- $block = (string) $config;
86
- }
87
- $block = $this->getLayout()->createBlock($block, $blockName);
88
- }
89
- /**
90
- * Transfer totals to renderer
91
- */
92
- $block->setTotals($this->getTotals());
93
- return $block;
94
- }
95
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Default.php DELETED
@@ -1,93 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Cart totals default renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Cart_CartTotals_Default extends Mage_Checkout_Block_Total_Default
35
- {
36
- /**
37
- * Total id prefix
38
- *
39
- * @var string
40
- */
41
- protected $_totalIdPrefix = 'total_';
42
-
43
- /**
44
- * Add cart total to xml
45
- *
46
- * @return Mage_XmlConnect_Model_Simplexml_Element
47
- */
48
- protected function _toHtml()
49
- {
50
- if (!$this->getTotal()->getValue()) {
51
- return;
52
- }
53
- /** @var $cartXmlObject Mage_XmlConnect_Model_Simplexml_Element */
54
- $cartXmlObject = $this->getCartObject();
55
- $currentTotal = $this->getTotal();
56
-
57
- /** @var $xmlObj Mage_XmlConnect_Model_Simplexml_Element */
58
- $xmlObj = $cartXmlObject->addCustomChild('total', null, array(
59
- 'id' => $this->getTotalIdPrefix() . $currentTotal->getCode()
60
- ));
61
- $value = Mage::helper('xmlconnect')->formatPriceForXml($currentTotal->getValue());
62
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value, false);
63
-
64
- $xmlObj->addCustomChild('item', $value, array(
65
- 'id' => $currentTotal->getCode(),
66
- 'label' => $currentTotal->getTitle(),
67
- 'formatted_value' => $formattedValue
68
- ));
69
- return $xmlObj;
70
- }
71
-
72
- /**
73
- * Set total id prefix
74
- *
75
- * @param string $totalIdPrefix
76
- * @return Mage_Xmlconnect_Block_Cart_CartTotals_Default
77
- */
78
- public function setTotalIdPrefix($totalIdPrefix)
79
- {
80
- $this->_totalIdPrefix = $totalIdPrefix;
81
- return $this;
82
- }
83
-
84
- /**
85
- * Get total id prefix
86
- *
87
- * @return string
88
- */
89
- public function getTotalIdPrefix()
90
- {
91
- return $this->_totalIdPrefix;
92
- }
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Grandtotal.php DELETED
@@ -1,107 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Cart totals grand total renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Cart_CartTotals_Grandtotal extends Mage_Tax_Block_Checkout_Grandtotal
35
- {
36
- /**
37
- * Total id prefix
38
- *
39
- * @var string
40
- */
41
- protected $_totalIdPrefix = 'total_';
42
-
43
- /**
44
- * Add cart grand total to xml
45
- *
46
- * @return Mage_XmlConnect_Model_Simplexml_Element
47
- */
48
- protected function _toHtml()
49
- {
50
- $grandTotalValue = $this->getTotal()->getValue() ? $this->getTotal()->getValue(): 0;
51
-
52
- /** @var $cartXmlObject Mage_XmlConnect_Model_Simplexml_Element */
53
- $cartXmlObject = $this->getCartObject();
54
- $grandTotal = $this->getTotal();
55
- $code = $grandTotal->getCode();
56
-
57
- /** @var $helper Mage_XmlConnect_Helper_Data */
58
- $helper = Mage::helper('xmlconnect');
59
-
60
- /** @var $xmlObj Mage_XmlConnect_Model_Simplexml_Element */
61
- $xmlObj = $cartXmlObject->addCustomChild('total', null, array(
62
- 'id' => $this->getTotalIdPrefix() . $code
63
- ));
64
-
65
- if ($this->includeTax() && $this->getTotalExclTax() >= 0) {
66
- $label = $this->__('Grand Total (Excl. Tax)');
67
- $excludingTaxCode = $code . '_excl_tax';
68
- $value = $this->getTotalExclTax();
69
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value);
70
- $helper->addTotalItemToXmlObj($xmlObj, $excludingTaxCode, $label, $value, $formattedValue);
71
-
72
- $label = $this->__('Grand Total (Incl. Tax)');
73
- $includingTaxCode = $code . '_incl_tax';
74
- $value = $grandTotalValue;
75
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value);
76
- $helper->addTotalItemToXmlObj($xmlObj, $includingTaxCode, $label, $value, $formattedValue);
77
- } else {
78
- $label = $this->__('Grand Total');
79
- $value = $grandTotalValue;
80
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value);
81
- $helper->addTotalItemToXmlObj($xmlObj, $code, $label, $value, $formattedValue);
82
- }
83
- return $xmlObj;
84
- }
85
-
86
- /**
87
- * Set total id prefix
88
- *
89
- * @param string $totalIdPrefix
90
- * @return Mage_Xmlconnect_Block_Cart_CartTotals_Grandtotal
91
- */
92
- public function setTotalIdPrefix($totalIdPrefix)
93
- {
94
- $this->_totalIdPrefix = $totalIdPrefix;
95
- return $this;
96
- }
97
-
98
- /**
99
- * Get total id prefix
100
- *
101
- * @return string
102
- */
103
- public function getTotalIdPrefix()
104
- {
105
- return $this->_totalIdPrefix;
106
- }
107
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Nodes/Default.php DELETED
@@ -1,63 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Cart totals default node renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Cart_CartTotals_Nodes_Default extends Mage_Checkout_Block_Total_Default
35
- {
36
- /**
37
- * Add cart total node to xml
38
- *
39
- * @return Mage_XmlConnect_Model_Simplexml_Element
40
- */
41
- protected function _toHtml()
42
- {
43
- if (!$this->getTotal()->getValue()) {
44
- return;
45
- }
46
- /** @var $cartXmlObject Mage_XmlConnect_Model_Simplexml_Element */
47
- $cartXmlObject = $this->getCartObject();
48
- $total = $this->getTotal();
49
-
50
- /** @var $nodeXmlObj Mage_XmlConnect_Model_Simplexml_Element */
51
- $nodeXmlObj = $cartXmlObject->addCustomChild($total->getCode());
52
- $value = Mage::helper('xmlconnect')->formatPriceForXml($total->getValue());
53
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value, false);
54
-
55
- $nodeXmlObj->addCustomChild('item', $value, array(
56
- 'id' => $total->getCode(),
57
- 'label' => $total->getTitle(),
58
- 'formatted_value' => $formattedValue
59
- ));
60
-
61
- return $nodeXmlObj;
62
- }
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Nodes/Giftcardaccount.php DELETED
@@ -1,69 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Cart totals gift card renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Cart_CartTotals_Nodes_Giftcardaccount extends Mage_Checkout_Block_Total_Default
35
- {
36
- /**
37
- * Add gift card balance to xml
38
- *
39
- * @return Mage_XmlConnect_Model_Simplexml_Element
40
- */
41
- protected function _toHtml()
42
- {
43
- if (!$this->getTotal()->getValue()) {
44
- return;
45
- }
46
- /** @var $cartXmlObject Mage_XmlConnect_Model_Simplexml_Element */
47
- $cartXmlObject = $this->getCartObject();
48
- $cards = $this->getTotal()->getGiftCards();
49
- if (!$cards) {
50
- $cards = $this->getQuoteGiftCards();
51
- }
52
- $code = $this->getTotal()->getCode();
53
-
54
- /** @var $giftCardsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
55
- $giftCardsXmlObj = $cartXmlObject->addCustomChild($code);
56
-
57
- foreach ($cards as $cardCode) {
58
- $giftCardValue = Mage::helper('xmlconnect')->formatPriceForXml($cardCode['a']);
59
- $formattedValue = $this->getQuote()->getStore()->formatPrice($giftCardValue, false);
60
- $giftCardsXmlObj->addCustomChild('item', '-' . $giftCardValue, array(
61
- 'id' => $code . '_' . $cardCode['i'],
62
- 'label' => $this->__('Gift Card (%s)', $cardCode['c']),
63
- 'formatted_value' => '-' . $formattedValue,
64
- 'code' => $cardCode['c']
65
- ));
66
- }
67
- return $giftCardsXmlObj;
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Shipping.php DELETED
@@ -1,113 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Cart totals shipping renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Cart_CartTotals_Shipping extends Mage_Tax_Block_Checkout_Shipping
35
- {
36
- /**
37
- * Total id prefix
38
- *
39
- * @var string
40
- */
41
- protected $_totalIdPrefix = 'total_';
42
-
43
- /**
44
- * Add cart grand total to xml
45
- *
46
- * @return Mage_XmlConnect_Model_Simplexml_Element
47
- */
48
- protected function _toHtml()
49
- {
50
- if (!$this->getTotal()->getValue()) {
51
- return;
52
- }
53
- /** @var $cartXmlObject Mage_XmlConnect_Model_Simplexml_Element */
54
- $cartXmlObject = $this->getCartObject();
55
- $shippingTotal = $this->getTotal();
56
- $code = $shippingTotal->getCode();
57
-
58
- /** @var $helper Mage_XmlConnect_Helper_Data */
59
- $helper = Mage::helper('xmlconnect');
60
-
61
- /** @var $xmlObj Mage_XmlConnect_Model_Simplexml_Element */
62
- $xmlObj = $cartXmlObject->addCustomChild('total', null, array(
63
- 'id' => $this->getTotalIdPrefix() . $code
64
- ));
65
-
66
- if ($this->displayBoth()) {
67
- $label = $this->getExcludeTaxLabel();
68
- $excludingTaxCode = $code . '_excl_tax';
69
- $value = $this->getShippingIncludeTax();
70
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value);
71
- $helper->addTotalItemToXmlObj($xmlObj, $excludingTaxCode, $label, $value, $formattedValue);
72
-
73
- $label = $this->getIncludeTaxLabel();
74
- $includingTaxCode = $code . '_incl_tax';
75
- $value = $this->getShippingIncludeTax();
76
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value);
77
- $helper->addTotalItemToXmlObj($xmlObj, $includingTaxCode, $label, $value, $formattedValue);
78
- } else {
79
- if ($this->displayIncludeTax()) {
80
- $label = $this->getIncludeTaxLabel();
81
- $value = $this->getShippingIncludeTax();
82
- } else {
83
- $label = $this->getExcludeTaxLabel();
84
- $value = $this->getShippingIncludeTax();
85
- }
86
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value);
87
- $helper->addTotalItemToXmlObj($xmlObj, $code, $label, $value, $formattedValue);
88
- }
89
- return $xmlObj;
90
- }
91
-
92
- /**
93
- * Set total id prefix
94
- *
95
- * @param string $totalIdPrefix
96
- * @return Mage_Xmlconnect_Block_Cart_CartTotals_Shipping
97
- */
98
- public function setTotalIdPrefix($totalIdPrefix)
99
- {
100
- $this->_totalIdPrefix = $totalIdPrefix;
101
- return $this;
102
- }
103
-
104
- /**
105
- * Get total id prefix
106
- *
107
- * @return string
108
- */
109
- public function getTotalIdPrefix()
110
- {
111
- return $this->_totalIdPrefix;
112
- }
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Subtotal.php DELETED
@@ -1,108 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Cart totals subtotal renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Cart_CartTotals_Subtotal extends Mage_Tax_Block_Checkout_Subtotal
35
- {
36
- /**
37
- * Total id prefix
38
- *
39
- * @var string
40
- */
41
- protected $_totalIdPrefix = 'total_';
42
-
43
- /**
44
- * Add cart subtotal to xml
45
- *
46
- * @return Mage_XmlConnect_Model_Simplexml_Element
47
- */
48
- protected function _toHtml()
49
- {
50
- if (!$this->getTotal()->getValue()) {
51
- return;
52
- }
53
- /** @var $cartXmlObject Mage_XmlConnect_Model_Simplexml_Element */
54
- $cartXmlObject = $this->getCartObject();
55
- $subtotal = $this->getTotal();
56
- $code = $subtotal->getCode();
57
-
58
- /** @var $helper Mage_XmlConnect_Helper_Data */
59
- $helper = Mage::helper('xmlconnect');
60
-
61
- /** @var $xmlObj Mage_XmlConnect_Model_Simplexml_Element */
62
- $xmlObj = $cartXmlObject->addCustomChild('total', null, array(
63
- 'id' => $this->getTotalIdPrefix() . $code
64
- ));
65
-
66
- if ($this->displayBoth()) {
67
- $label = $this->__('Subtotal (Excl. Tax)');
68
- $excludingTaxCode = $code . '_excl_tax';
69
- $value = $subtotal->getValueExclTax();
70
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value);
71
- $helper->addTotalItemToXmlObj($xmlObj, $excludingTaxCode, $label, $value, $formattedValue);
72
-
73
- $label = $this->__('Subtotal (Incl. Tax)');
74
- $includingTaxCode = $code . '_incl_tax';
75
- $value = $subtotal->getValueInclTax();
76
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value);
77
- $helper->addTotalItemToXmlObj($xmlObj, $includingTaxCode, $label, $value, $formattedValue);
78
- } else {
79
- $label = $this->__('Subtotal');
80
- $value = $subtotal->getValue();
81
- $formattedValue = $this->getQuote()->getStore()->formatPrice($value);
82
- $helper->addTotalItemToXmlObj($xmlObj, $code, $label, $value, $formattedValue);
83
- }
84
- return $xmlObj;
85
- }
86
-
87
- /**
88
- * Set total id prefix
89
- *
90
- * @param string $totalIdPrefix
91
- * @return Mage_Xmlconnect_Block_Cart_CartTotals_Subtotal
92
- */
93
- public function setTotalIdPrefix($totalIdPrefix)
94
- {
95
- $this->_totalIdPrefix = $totalIdPrefix;
96
- return $this;
97
- }
98
-
99
- /**
100
- * Get total id prefix
101
- *
102
- * @return string
103
- */
104
- public function getTotalIdPrefix()
105
- {
106
- return $this->_totalIdPrefix;
107
- }
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Cart/Crosssell.php CHANGED
@@ -45,23 +45,23 @@ class Mage_XmlConnect_Block_Cart_Crosssell extends Mage_Checkout_Block_Cart_Cros
45
  $this->getLayout()->createBlock($blockRenderer, $blockName);
46
  $this->setItems($this->getLayout()->getBlock($blockName)->getItemCollection());
47
  }
48
- /** @var $crossSellXmlObj Mage_XmlConnect_Model_Simplexml_Element */
49
  $crossSellXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<crosssell></crosssell>');
50
  if (!$this->getItemCount()) {
51
  return $crossSellXmlObj->asNiceXml();
52
  }
53
 
54
- $productSmallImageSize = Mage::getModel('xmlconnect/images')->getImageLimitParam('content/product_small');
55
- /** @var $productImageHelper Mage_XmlConnect_Helper_Catalog_Product_Image */
56
- $productImageHelper = $this->helper('xmlconnect/catalog_product_image');
57
  /** @var $product Mage_Catalog_Model_Product */
58
  foreach ($this->getItems() as $product) {
59
  $itemXmlObj = $crossSellXmlObj->addChild('item');
60
  $itemXmlObj->addChild('name', $crossSellXmlObj->escapeXml($product->getName()));
61
- $icon = $productImageHelper->init($product, 'thumbnail')->resize($productSmallImageSize);
 
62
 
63
  $iconXml = $itemXmlObj->addChild('icon', $icon);
64
- $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
 
 
65
 
66
  $itemXmlObj->addChild('entity_id', $product->getId());
67
  $itemXmlObj->addChild('entity_type', $product->getTypeId());
45
  $this->getLayout()->createBlock($blockRenderer, $blockName);
46
  $this->setItems($this->getLayout()->getBlock($blockName)->getItemCollection());
47
  }
48
+
49
  $crossSellXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<crosssell></crosssell>');
50
  if (!$this->getItemCount()) {
51
  return $crossSellXmlObj->asNiceXml();
52
  }
53
 
 
 
 
54
  /** @var $product Mage_Catalog_Model_Product */
55
  foreach ($this->getItems() as $product) {
56
  $itemXmlObj = $crossSellXmlObj->addChild('item');
57
  $itemXmlObj->addChild('name', $crossSellXmlObj->escapeXml($product->getName()));
58
+ $icon = $this->helper('catalog/image')->init($product, 'thumbnail')
59
+ ->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small'));
60
 
61
  $iconXml = $itemXmlObj->addChild('icon', $icon);
62
+
63
+ $file = Mage::helper('xmlconnect')->urlToPath($icon);
64
+ $iconXml->addAttribute('modification_time', filemtime($file));
65
 
66
  $itemXmlObj->addChild('entity_id', $product->getId());
67
  $itemXmlObj->addChild('entity_type', $product->getTypeId());
app/code/core/Mage/XmlConnect/Block/Cart/Item/Renderer.php CHANGED
@@ -40,238 +40,36 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
40
  */
41
  public function addProductToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj)
42
  {
43
- $item = $this->getItem();
44
  $productXmlObj = $reviewXmlObj->addCustomChild('item');
45
  $productXmlObj->addCustomChild('name', $this->escapeHtml($this->getProductName()));
46
 
47
- if ($options = $this->getOptionList()) {
48
  $optionsXmlObj = $productXmlObj->addChild('options');
49
- foreach ($options as $option) {
50
- $formattedOptionValue = $this->getFormatedOptionValue($option);
51
 
52
- if (isset($formattedOptionValue['full_view'])) {
53
- $value = $formattedOptionValue['full_view'];
54
  } else {
55
  $value = null;
56
  }
57
 
58
  $optionsXmlObj->addCustomChild('option', $value, array(
59
- 'label' => $this->escapeHtml($option['label']),
60
- 'value' => $formattedOptionValue['value']
61
  ));
62
  }
63
  }
64
 
65
- if (Mage::helper('xmlconnect')->checkApiVersion(Mage_XmlConnect_Helper_Data::DEVICE_API_V_23)) {
66
- $priceListXmlObj = $productXmlObj->addCustomChild('price_list');
67
- $this->_addPriceToXmlObj23($priceListXmlObj);
68
- $this->_addSubtotalToXmlObj23($priceListXmlObj);
69
- } else {
70
- $this->_addPriceToXmlObj($productXmlObj);
71
- $this->_addSubtotalToXmlObj($productXmlObj);
72
- }
73
 
74
- $productXmlObj->addCustomChild('qty', $item->getQty());
75
- $icon = $this->helper('xmlconnect/catalog_product_image')->init($this->getProduct(), 'thumbnail')
76
- ->resize(Mage::getModel('xmlconnect/images')->getImageLimitParam('content/product_small'));
77
- $iconXml = $productXmlObj->addChild('icon', $icon);
78
- $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
79
 
80
  return $reviewXmlObj;
81
  }
82
 
83
- /**
84
- * Add product price info to xml object. API version 23
85
- *
86
- * @param Mage_XmlConnect_Model_Simplexml_Element $priceListXmlObj
87
- * @return Mage_XmlConnect_Model_Simplexml_Element
88
- */
89
- protected function _addPriceToXmlObj23(Mage_XmlConnect_Model_Simplexml_Element $priceListXmlObj)
90
- {
91
- $item = $this->getItem();
92
- $priceType = 'price';
93
- $priceXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => $priceType));
94
-
95
- if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
96
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
97
- && $item->getWeeeTaxAppliedAmount()
98
- ) {
99
- $exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount()
100
- + $item->getWeeeTaxDisposition();
101
- } else {
102
- $exclPrice = $item->getCalculationPrice();
103
- }
104
- $exclPrice = $this->_formatPrice($exclPrice);
105
- $priceXmlObj->addCustomChild('price', $exclPrice, array(
106
- 'id' => $priceType . '_excluding_tax',
107
- 'label' => $this->__('Excl. Tax'),
108
- 'formatted_value' => $priceXmlObj->escapeXml($exclPrice)
109
- ));
110
- }
111
-
112
- if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
113
- $incl = $this->helper('checkout')->getPriceInclTax($item);
114
-
115
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
116
- && $item->getWeeeTaxAppliedAmount()
117
- ) {
118
- $inclPrice = $incl + $item->getWeeeTaxAppliedAmount();
119
- } else {
120
- $inclPrice = $incl - $item->getWeeeTaxDisposition();
121
- }
122
- $inclPrice = $this->_formatPrice($inclPrice);
123
-
124
- $priceXmlObj->addCustomChild('price', $inclPrice, array(
125
- 'id' => $priceType . '_including_tax',
126
- 'label' => $this->__('Incl. Tax'),
127
- 'formatted_value' => $priceXmlObj->escapeXml($inclPrice)
128
- ));
129
- }
130
-
131
- if (Mage::helper('weee')->getApplied($item)) {
132
- $this->_addWeeeToXmlObj23($priceXmlObj);
133
- }
134
-
135
- return $priceListXmlObj;
136
- }
137
-
138
- /**
139
- * Add product subtotal info to xml object. API version 23
140
- *
141
- * @param Mage_XmlConnect_Model_Simplexml_Element $priceListXmlObj
142
- * @return Mage_XmlConnect_Model_Simplexml_Element
143
- */
144
- protected function _addSubtotalToXmlObj23(Mage_XmlConnect_Model_Simplexml_Element $priceListXmlObj)
145
- {
146
- $item = $this->getItem();
147
- $priceType = 'subtotal';
148
- $subtotalXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => $priceType));
149
-
150
- if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
151
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
152
- && $item->getWeeeTaxAppliedAmount()) {
153
- $exclPrice = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
154
- + $item->getWeeeTaxRowDisposition();
155
- } else {
156
- $exclPrice = $item->getRowTotal();
157
- }
158
- $exclPrice = $this->_formatPrice($exclPrice);
159
-
160
- $subtotalXmlObj->addCustomChild('price', null, array(
161
- 'id' => $priceType . '_excluding_tax',
162
- 'label' => $this->__('Subtotal Excl. Tax'),
163
- 'formatted_value' => $subtotalXmlObj->escapeXml($exclPrice)
164
- ));
165
- }
166
-
167
- if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
168
- $incl = $this->helper('checkout')->getSubtotalInclTax($item);
169
-
170
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
171
- && $item->getWeeeTaxAppliedAmount()
172
- ) {
173
- $inclPrice = $incl + $item->getWeeeTaxAppliedRowAmount();
174
- } else {
175
- $inclPrice = $incl - $item->getWeeeTaxRowDisposition();
176
- }
177
- $inclPrice = $this->_formatPrice($inclPrice);
178
-
179
- $subtotalXmlObj->addCustomChild('price', null, array(
180
- 'id' => $priceType . '_including_tax',
181
- 'label' => $this->__('Subtotal Incl. Tax'),
182
- 'formatted_value' => $subtotalXmlObj->escapeXml($inclPrice)
183
- ));
184
- }
185
-
186
- if (Mage::helper('weee')->getApplied($item)) {
187
- $this->_addWeeeToXmlObj23($subtotalXmlObj, true);
188
- }
189
-
190
- return $priceListXmlObj;
191
- }
192
-
193
- /**
194
- * Add weee tax product info to xml object API version 23
195
- *
196
- * @param Mage_XmlConnect_Model_Simplexml_Element $priceListXmlObj
197
- * @param bool $subtotalFlag use true to get subtotal product info
198
- * @return Mage_XmlConnect_Model_Simplexml_Element
199
- */
200
- protected function _addWeeeToXmlObj23($priceListXmlObj, $subtotalFlag = false)
201
- {
202
- $item = $this->getItem();
203
- $weeeXmlObj = $priceListXmlObj->addCustomChild('price', null, array('id' => 'weee'));
204
-
205
- if ($subtotalFlag) {
206
- $incl = $this->helper('checkout')->getSubtotalInclTax($item);
207
- } else {
208
- $incl = $this->helper('checkout')->getPriceInclTax($item);
209
- }
210
-
211
- $typeOfDisplay2 = Mage::helper('weee')->typeOfDisplay($item, 2, 'sales');
212
-
213
- if (Mage::helper('weee')->typeOfDisplay($item, 1, 'sales') && $item->getWeeeTaxAppliedAmount()) {
214
- foreach (Mage::helper('weee')->getApplied($item) as $tax) {
215
-
216
- if ($subtotalFlag) {
217
- $amount = $tax['row_amount'];
218
- } else {
219
- $amount = $tax['amount'];
220
- }
221
-
222
- $weeeXmlObj->addCustomChild('item', $amount * 1, array(
223
- 'id' => 'weee_tax', 'label' => $tax['title'], 'formatted_value' => $this->_formatPrice($amount)
224
- ));
225
- }
226
- } elseif ($item->getWeeeTaxAppliedAmount()
227
- && ($typeOfDisplay2 || Mage::helper('weee')->typeOfDisplay($item, 4, 'sales'))
228
- ) {
229
- foreach (Mage::helper('weee')->getApplied($item) as $tax) {
230
- if ($subtotalFlag) {
231
- $amount = $tax['row_amount_incl_tax'];
232
- } else {
233
- $amount = $tax['amount_incl_tax'];
234
- }
235
-
236
- $weeeXmlObj->addCustomChild('item', $amount * 1, array(
237
- 'id' => 'weee_tax', 'label' => $tax['title'], 'formatted_value' => $this->_formatPrice($amount)
238
- ));
239
- }
240
- }
241
-
242
- if ($typeOfDisplay2 && $item->getWeeeTaxAppliedAmount()) {
243
- if ($subtotalFlag) {
244
- $totalExcl = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
245
- + $item->getWeeeTaxRowDisposition();
246
- } else {
247
- $totalExcl = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount()
248
- + $item->getWeeeTaxDisposition();
249
- }
250
-
251
- $weeeXmlObj->addCustomChild('item', $totalExcl * 1, array(
252
- 'id' => 'total_excluding_tax',
253
- 'label' => $this->__('Total'),
254
- 'formatted_value' => $priceListXmlObj->escapeXml($this->_formatPrice($totalExcl))
255
- ));
256
- }
257
-
258
- if ($typeOfDisplay2 && $item->getWeeeTaxAppliedAmount()) {
259
- if ($subtotalFlag) {
260
- $totalIncl = $incl + $item->getWeeeTaxAppliedRowAmount();
261
- } else {
262
- $totalIncl = $incl + $item->getWeeeTaxAppliedAmount();
263
- }
264
-
265
- $weeeXmlObj->addCustomChild('item', $totalIncl * 1, array(
266
- 'id' => 'total_including_tax',
267
- 'label' => $this->__('Total incl. tax'),
268
- 'formatted_value' => $priceListXmlObj->escapeXml($this->_formatPrice($totalIncl))
269
- ));
270
- }
271
-
272
- return $priceListXmlObj;
273
- }
274
-
275
  /**
276
  * Add product subtotal info to xml object
277
  *
@@ -280,38 +78,38 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
280
  */
281
  protected function _addSubtotalToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $productXmlObj)
282
  {
283
- $item = $this->getItem();
284
  $subtotalXmlObj = $productXmlObj->addCustomChild('subtotal');
285
 
286
  if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
287
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
288
- && $item->getWeeeTaxAppliedAmount()) {
289
- $exclPrice = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
290
- + $item->getWeeeTaxRowDisposition();
 
291
  } else {
292
- $exclPrice = $item->getRowTotal();
293
  }
294
  $exclPrice = $this->_formatPrice($exclPrice);
295
-
296
  $subtotalXmlObj->addAttribute('excluding_tax', $subtotalXmlObj->escapeXml($exclPrice));
297
  }
298
 
299
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
300
- $incl = $this->helper('checkout')->getSubtotalInclTax($item);
301
 
302
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
303
- && $item->getWeeeTaxAppliedAmount()
304
  ) {
305
- $inclPrice = $incl + $item->getWeeeTaxAppliedRowAmount();
306
  } else {
307
- $inclPrice = $incl - $item->getWeeeTaxRowDisposition();
308
  }
309
  $inclPrice = $this->_formatPrice($inclPrice);
310
 
311
  $subtotalXmlObj->addAttribute('including_tax', $subtotalXmlObj->escapeXml($inclPrice));
312
  }
313
 
314
- if (Mage::helper('weee')->getApplied($item)) {
315
  $this->_addWeeeToXmlObj($subtotalXmlObj, true);
316
  }
317
 
@@ -337,38 +135,43 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
337
  */
338
  protected function _addPriceToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $productXmlObj)
339
  {
340
- $item = $this->getItem();
341
  $priceXmlObj = $productXmlObj->addCustomChild('price');
342
 
343
- if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
344
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
345
- && $item->getWeeeTaxAppliedAmount()
 
 
346
  ) {
347
- $exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount()
348
- + $item->getWeeeTaxDisposition();
349
  } else {
350
- $exclPrice = $item->getCalculationPrice();
351
  }
352
  $exclPrice = $this->_formatPrice($exclPrice);
 
353
  $priceXmlObj->addAttribute('excluding_tax', $priceXmlObj->escapeXml($exclPrice));
354
  }
355
 
356
- if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
357
- $incl = $this->helper('checkout')->getPriceInclTax($item);
 
 
358
 
359
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
360
- && $item->getWeeeTaxAppliedAmount()
361
  ) {
362
- $inclPrice = $incl + $item->getWeeeTaxAppliedAmount();
363
  } else {
364
- $inclPrice = $incl - $item->getWeeeTaxDisposition();
365
  }
366
  $inclPrice = $this->_formatPrice($inclPrice);
367
 
368
  $priceXmlObj->addAttribute('including_tax', $priceXmlObj->escapeXml($inclPrice));
369
  }
370
 
371
- if (Mage::helper('weee')->getApplied($item)) {
372
  $this->_addWeeeToXmlObj($priceXmlObj);
373
  }
374
 
@@ -384,19 +187,19 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
384
  */
385
  protected function _addWeeeToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $priceXmlObj, $subtotalFlag = false)
386
  {
387
- $item = $this->getItem();
388
  $weeeXmlObj = $priceXmlObj->addCustomChild('weee');
389
 
390
  if ($subtotalFlag) {
391
- $incl = $this->helper('checkout')->getSubtotalInclTax($item);
392
  } else {
393
- $incl = $this->helper('checkout')->getPriceInclTax($item);
394
  }
395
 
396
- $typeOfDisplay2 = Mage::helper('weee')->typeOfDisplay($item, 2, 'sales');
397
 
398
- if (Mage::helper('weee')->typeOfDisplay($item, 1, 'sales') && $item->getWeeeTaxAppliedAmount()) {
399
- foreach (Mage::helper('weee')->getApplied($item) as $tax) {
400
 
401
  if ($subtotalFlag) {
402
  $amount = $tax['row_amount'];
@@ -405,13 +208,14 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
405
  }
406
 
407
  $weeeXmlObj->addCustomChild('item', null, array(
408
- 'name' => $tax['title'], 'amount' => $this->_formatPrice($amount)
 
409
  ));
410
  }
411
- } elseif ($item->getWeeeTaxAppliedAmount()
412
- && ($typeOfDisplay2 || Mage::helper('weee')->typeOfDisplay($item, 4, 'sales'))
413
  ) {
414
- foreach (Mage::helper('weee')->getApplied($item) as $tax) {
415
  if ($subtotalFlag) {
416
  $amount = $tax['row_amount_incl_tax'];
417
  } else {
@@ -419,29 +223,30 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
419
  }
420
 
421
  $weeeXmlObj->addCustomChild('item', null, array(
422
- 'name' => $tax['title'], 'amount' => $this->_formatPrice($amount)
 
423
  ));
424
  }
425
  }
426
 
427
- if ($typeOfDisplay2 && $item->getWeeeTaxAppliedAmount()) {
428
  if ($subtotalFlag) {
429
- $totalExcl = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
430
- + $item->getWeeeTaxRowDisposition();
431
  } else {
432
- $totalExcl = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount()
433
- + $item->getWeeeTaxDisposition();
434
  }
435
 
436
  $totalExcl = $this->_formatPrice($totalExcl);
437
  $priceXmlObj->addAttribute('total_excluding_tax', $priceXmlObj->escapeXml($totalExcl));
438
  }
439
 
440
- if ($typeOfDisplay2 && $item->getWeeeTaxAppliedAmount()) {
441
  if ($subtotalFlag) {
442
- $totalIncl = $incl + $item->getWeeeTaxAppliedRowAmount();
443
  } else {
444
- $totalIncl = $incl + $item->getWeeeTaxAppliedAmount();
445
  }
446
 
447
  $totalIncl = $this->_formatPrice($totalIncl);
40
  */
41
  public function addProductToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj)
42
  {
43
+ $_item = $this->getItem();
44
  $productXmlObj = $reviewXmlObj->addCustomChild('item');
45
  $productXmlObj->addCustomChild('name', $this->escapeHtml($this->getProductName()));
46
 
47
+ if ($_options = $this->getOptionList()) {
48
  $optionsXmlObj = $productXmlObj->addChild('options');
49
+ foreach ($_options as $_option) {
50
+ $_formattedOptionValue = $this->getFormatedOptionValue($_option);
51
 
52
+ if (isset($_formattedOptionValue['full_view'])) {
53
+ $value = $_formattedOptionValue['full_view'];
54
  } else {
55
  $value = null;
56
  }
57
 
58
  $optionsXmlObj->addCustomChild('option', $value, array(
59
+ 'label' => $this->escapeHtml($_option['label']),
60
+ 'value' => $_formattedOptionValue['value']
61
  ));
62
  }
63
  }
64
 
65
+ $this->_addPriceToXmlObj($productXmlObj);
66
+ $this->_addSubtotalToXmlObj($productXmlObj);
 
 
 
 
 
 
67
 
68
+ $productXmlObj->addCustomChild('qty', $_item->getQty());
 
 
 
 
69
 
70
  return $reviewXmlObj;
71
  }
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  /**
74
  * Add product subtotal info to xml object
75
  *
78
  */
79
  protected function _addSubtotalToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $productXmlObj)
80
  {
81
+ $_item = $this->getItem();
82
  $subtotalXmlObj = $productXmlObj->addCustomChild('subtotal');
83
 
84
  if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
85
+ if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')
86
+ && $_item->getWeeeTaxAppliedAmount()
87
+ ) {
88
+ $exclPrice = $_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount()
89
+ + $_item->getWeeeTaxRowDisposition();
90
  } else {
91
+ $exclPrice = $_item->getRowTotal();
92
  }
93
  $exclPrice = $this->_formatPrice($exclPrice);
 
94
  $subtotalXmlObj->addAttribute('excluding_tax', $subtotalXmlObj->escapeXml($exclPrice));
95
  }
96
 
97
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
98
+ $_incl = $this->helper('checkout')->getSubtotalInclTax($_item);
99
 
100
+ if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')
101
+ && $_item->getWeeeTaxAppliedAmount()
102
  ) {
103
+ $inclPrice = $_incl + $_item->getWeeeTaxAppliedRowAmount();
104
  } else {
105
+ $inclPrice = $_incl - $_item->getWeeeTaxRowDisposition();
106
  }
107
  $inclPrice = $this->_formatPrice($inclPrice);
108
 
109
  $subtotalXmlObj->addAttribute('including_tax', $subtotalXmlObj->escapeXml($inclPrice));
110
  }
111
 
112
+ if (Mage::helper('weee')->getApplied($_item)) {
113
  $this->_addWeeeToXmlObj($subtotalXmlObj, true);
114
  }
115
 
135
  */
136
  protected function _addPriceToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $productXmlObj)
137
  {
138
+ $_item = $this->getItem();
139
  $priceXmlObj = $productXmlObj->addCustomChild('price');
140
 
141
+ if ($this->helper('tax')->displayCartPriceExclTax()
142
+ || $this->helper('tax')->displayCartBothPrices()
143
+ ) {
144
+ if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')
145
+ && $_item->getWeeeTaxAppliedAmount()
146
  ) {
147
+ $exclPrice = $_item->getCalculationPrice() + $_item->getWeeeTaxAppliedAmount()
148
+ + $_item->getWeeeTaxDisposition();
149
  } else {
150
+ $exclPrice = $_item->getCalculationPrice();
151
  }
152
  $exclPrice = $this->_formatPrice($exclPrice);
153
+
154
  $priceXmlObj->addAttribute('excluding_tax', $priceXmlObj->escapeXml($exclPrice));
155
  }
156
 
157
+ if ($this->helper('tax')->displayCartPriceInclTax()
158
+ || $this->helper('tax')->displayCartBothPrices()
159
+ ) {
160
+ $_incl = $this->helper('checkout')->getPriceInclTax($_item);
161
 
162
+ if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')
163
+ && $_item->getWeeeTaxAppliedAmount()
164
  ) {
165
+ $inclPrice = $_incl + $_item->getWeeeTaxAppliedAmount();
166
  } else {
167
+ $inclPrice = $_incl - $_item->getWeeeTaxDisposition();
168
  }
169
  $inclPrice = $this->_formatPrice($inclPrice);
170
 
171
  $priceXmlObj->addAttribute('including_tax', $priceXmlObj->escapeXml($inclPrice));
172
  }
173
 
174
+ if (Mage::helper('weee')->getApplied($_item)) {
175
  $this->_addWeeeToXmlObj($priceXmlObj);
176
  }
177
 
187
  */
188
  protected function _addWeeeToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $priceXmlObj, $subtotalFlag = false)
189
  {
190
+ $_item = $this->getItem();
191
  $weeeXmlObj = $priceXmlObj->addCustomChild('weee');
192
 
193
  if ($subtotalFlag) {
194
+ $_incl = $this->helper('checkout')->getSubtotalInclTax($_item);
195
  } else {
196
+ $_incl = $this->helper('checkout')->getPriceInclTax($_item);
197
  }
198
 
199
+ $typeOfDisplay2 = Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales');
200
 
201
+ if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()) {
202
+ foreach (Mage::helper('weee')->getApplied($_item) as $tax) {
203
 
204
  if ($subtotalFlag) {
205
  $amount = $tax['row_amount'];
208
  }
209
 
210
  $weeeXmlObj->addCustomChild('item', null, array(
211
+ 'name' => $tax['title'],
212
+ 'amount' => $this->_formatPrice($amount)
213
  ));
214
  }
215
+ } elseif ($_item->getWeeeTaxAppliedAmount()
216
+ && ($typeOfDisplay2 || Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales'))
217
  ) {
218
+ foreach (Mage::helper('weee')->getApplied($_item) as $tax) {
219
  if ($subtotalFlag) {
220
  $amount = $tax['row_amount_incl_tax'];
221
  } else {
223
  }
224
 
225
  $weeeXmlObj->addCustomChild('item', null, array(
226
+ 'name' => $tax['title'],
227
+ 'amount' => $this->_formatPrice($amount)
228
  ));
229
  }
230
  }
231
 
232
+ if ($typeOfDisplay2 && $_item->getWeeeTaxAppliedAmount()) {
233
  if ($subtotalFlag) {
234
+ $totalExcl = $_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount()
235
+ + $_item->getWeeeTaxRowDisposition();
236
  } else {
237
+ $totalExcl = $_item->getCalculationPrice() + $_item->getWeeeTaxAppliedAmount()
238
+ + $_item->getWeeeTaxDisposition();
239
  }
240
 
241
  $totalExcl = $this->_formatPrice($totalExcl);
242
  $priceXmlObj->addAttribute('total_excluding_tax', $priceXmlObj->escapeXml($totalExcl));
243
  }
244
 
245
+ if ($typeOfDisplay2 && $_item->getWeeeTaxAppliedAmount()) {
246
  if ($subtotalFlag) {
247
+ $totalIncl = $_incl + $_item->getWeeeTaxAppliedRowAmount();
248
  } else {
249
+ $totalIncl = $_incl + $_item->getWeeeTaxAppliedAmount();
250
  }
251
 
252
  $totalIncl = $this->_formatPrice($totalIncl);
app/code/core/Mage/XmlConnect/Block/Cart/Items.php DELETED
@@ -1,254 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Shopping cart items renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Cart_Items extends Mage_Checkout_Block_Cart_Abstract
35
- {
36
- /**
37
- * Add product block to cart
38
- *
39
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObject
40
- * @param Mage_Sales_Model_Quote $quote
41
- * @return null
42
- */
43
- public function addCartProductsToXmlObj($xmlObject, $quote)
44
- {
45
- $productSmallImageSize = Mage::getModel('xmlconnect/images')->getImageLimitParam('content/product_small');
46
- $products = $xmlObject->addCustomChild('products');
47
- /* @var $item Mage_Sales_Model_Quote_Item */
48
- foreach ($this->getItems() as $item) {
49
- $type = $item->getProductType();
50
- $renderer = $this->getItemRenderer($type)->setItem($item);
51
- /**
52
- * General information
53
- */
54
- $itemXml = $products->addCustomChild('item', null, array('entity_id' => $item->getProduct()->getId()));
55
- $itemXml->addCustomChild('entity_type', $type);
56
- $itemXml->addCustomChild('item_id', $item->getId());
57
- $itemXml->addCustomChild('name', $xmlObject->escapeXml($renderer->getProductName()));
58
- $itemXml->addCustomChild('code', 'cart[' . $item->getId() . '][qty]');
59
- $itemXml->addCustomChild('qty', $renderer->getQty());
60
- $icon = $renderer->getProductThumbnail()->resize($productSmallImageSize);
61
- $iconXml = $itemXml->addChild('icon', $icon);
62
- $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
63
-
64
- /**
65
- * Price
66
- */
67
- $pricesXmlObj = $itemXml->addCustomChild('price_list');
68
- $exclPrice = $inclPrice = 0;
69
- if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
70
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
71
- && $item->getWeeeTaxAppliedAmount()
72
- ) {
73
- $exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount()
74
- + $item->getWeeeTaxDisposition();
75
- } else {
76
- $exclPrice = $item->getCalculationPrice();
77
- }
78
- }
79
- if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
80
- $incl = $this->helper('checkout')->getPriceInclTax($item);
81
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
82
- && $item->getWeeeTaxAppliedAmount()
83
- ) {
84
- $inclPrice = $incl + $item->getWeeeTaxAppliedAmount();
85
- } else {
86
- $inclPrice = $incl - $item->getWeeeTaxDisposition();
87
- }
88
- }
89
- $exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice);
90
- $paypalPrice = Mage::helper('xmlconnect')->formatPriceForXml($item->getCalculationPrice());
91
- $formattedExclPrice = $quote->getStore()->formatPrice($exclPrice, false);
92
- $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice);
93
- $formattedInclPrice = $quote->getStore()->formatPrice($inclPrice, false);
94
-
95
- $priceXmlObj = $pricesXmlObj->addCustomChild('prices', null, array('id' => 'price'));
96
-
97
- if ($this->helper('tax')->displayCartBothPrices()) {
98
- $priceXmlObj->addCustomChild('price', $exclPrice, array(
99
- 'id' => 'excluding_tax',
100
- 'label' => $this->__('Excl. Tax'),
101
- 'formatted_value' => $formattedExclPrice
102
- ));
103
-
104
- $priceXmlObj->addCustomChild('price', $inclPrice, array(
105
- 'id' => 'including_tax',
106
- 'label' => $this->__('Incl. Tax'),
107
- 'formatted_value' => $formattedInclPrice
108
- ));
109
- } else {
110
- if ($this->helper('tax')->displayCartPriceExclTax()) {
111
- $priceXmlObj->addCustomChild('price', $exclPrice, array(
112
- 'id' => 'regular',
113
- 'label' => $this->__('Unit Price'),
114
- 'formatted_value' => $formattedExclPrice
115
- ));
116
- }
117
- if ($this->helper('tax')->displayCartPriceInclTax()) {
118
- $priceXmlObj->addCustomChild('price', $inclPrice, array(
119
- 'id' => 'regular',
120
- 'label' => $this->__('Unit Price'),
121
- 'formatted_value' => $formattedInclPrice
122
- ));
123
- }
124
- }
125
-
126
- /**
127
- * Info for paypal MEP if it's enabled
128
- */
129
- $appConfig = Mage::helper('xmlconnect')->getApplication()->loadConfiguration()->getRenderConf();
130
- $isMepActive = $appConfig['paypal']['isActive'];
131
-
132
- $paypalMepIsAvailable = Mage::getModel('xmlconnect/payment_method_paypal_mep')->isAvailable(null);
133
- if ($paypalMepIsAvailable && $isMepActive) {
134
- $paypalPriceXmlObj = $pricesXmlObj->addCustomChild('prices', null, array('id' => 'paypal'));
135
-
136
- $paypalPriceXmlObj->addCustomChild('price', $paypalPrice, array(
137
- 'id' => 'regular',
138
- 'label' => $this->__('Unit Price'),
139
- 'formatted_value' => $quote->getStore()->formatPrice($paypalPrice, false)
140
- ));
141
-
142
- $paypalSubtotalPrice = Mage::helper('xmlconnect')->formatPriceForXml($item->getRowTotal());
143
- $paypalPriceXmlObj->addCustomChild('price', $paypalSubtotalPrice, array(
144
- 'id' => 'subtotal',
145
- 'label' => $this->__('Subtotal'),
146
- 'formatted_value' => $quote->getStore()->formatPrice($paypalSubtotalPrice, false)
147
- ));
148
- }
149
-
150
- /**
151
- * Subtotal
152
- */
153
- $subtotalExclTax = $subtotalInclTax = 0;
154
- if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
155
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
156
- && $item->getWeeeTaxAppliedAmount()
157
- ) {
158
- $subtotalExclTax = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
159
- + $item->getWeeeTaxRowDisposition();
160
- } else {
161
- $subtotalExclTax = $item->getRowTotal();
162
- }
163
- }
164
- if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
165
- $incl = $this->helper('checkout')->getSubtotalInclTax($item);
166
- if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
167
- && $item->getWeeeTaxAppliedAmount()
168
- ) {
169
- $subtotalInclTax = $incl + $item->getWeeeTaxAppliedRowAmount();
170
- } else {
171
- $subtotalInclTax = $incl - $item->getWeeeTaxRowDisposition();
172
- }
173
- }
174
-
175
- $subtotalExclTax = Mage::helper('xmlconnect')->formatPriceForXml($subtotalExclTax);
176
- $formattedSubtotalExcl = $quote->getStore()->formatPrice($subtotalExclTax, false);
177
-
178
- $subtotalInclTax = Mage::helper('xmlconnect')->formatPriceForXml($subtotalInclTax);
179
- $formattedSubtotalIncl = $quote->getStore()->formatPrice($subtotalInclTax, false);
180
-
181
- $priceXmlObj = $pricesXmlObj->addCustomChild('prices', null, array('id' => 'subtotal'));
182
-
183
- if ($this->helper('tax')->displayCartBothPrices()) {
184
- $priceXmlObj->addCustomChild('price', $subtotalExclTax, array(
185
- 'id' => 'excluding_tax',
186
- 'label' => $this->__('Subtotal Excl. Tax'),
187
- 'formatted_value' => $formattedSubtotalExcl
188
- ));
189
-
190
- $priceXmlObj->addCustomChild('price', $subtotalInclTax, array(
191
- 'id' => 'including_tax',
192
- 'label' => $this->__('Subtotal Incl. Tax'),
193
- 'formatted_value' => $formattedSubtotalIncl
194
- ));
195
- } else {
196
- if ($this->helper('tax')->displayCartPriceExclTax()) {
197
- $priceXmlObj->addCustomChild('price', $subtotalExclTax, array(
198
- 'id' => 'regular',
199
- 'label' => $this->__('Subtotal'),
200
- 'formatted_value' => $formattedSubtotalExcl
201
- ));
202
- }
203
- if ($this->helper('tax')->displayCartPriceInclTax()) {
204
- $priceXmlObj->addCustomChild('price', $subtotalInclTax, array(
205
- 'id' => 'regular',
206
- 'label' => $this->__('Subtotal'),
207
- 'formatted_value' => $formattedSubtotalIncl
208
- ));
209
- }
210
- }
211
-
212
- /**
213
- * Options list
214
- */
215
- $options = $renderer->getOptionList();
216
- if ($options) {
217
- $itemOptionsXml = $itemXml->addCustomChild('options');
218
- foreach ($options as $_option) {
219
- $formattedOptionValue = $renderer->getFormatedOptionValue($_option);
220
- $itemOptionsXml->addCustomChild('option', null, array(
221
- 'label' => $xmlObject->xmlAttribute($_option['label']),
222
- 'text' => $xmlObject->xmlAttribute($formattedOptionValue['value'])
223
- ));
224
- }
225
- }
226
-
227
- /**
228
- * Downloadable products
229
- */
230
- $links = $renderer->getLinks();
231
- if ($links) {
232
- $itemOptionsXml = $itemXml->addCustomChild('options', null, array(
233
- 'label' => $renderer->getLinksTitle()
234
- ));
235
- foreach ($links as $link) {
236
- $itemOptionsXml->addCustomChild('option', null, array('label' => $link->getTitle()));
237
- }
238
- }
239
-
240
- /**
241
- * Item messages
242
- */
243
- $messages = $renderer->getMessages();
244
- if ($messages) {
245
- $itemMessagesXml = $itemXml->addCustomChild('messages');
246
- foreach ($messages as $message) {
247
- $messageXml = $itemMessagesXml->addCustomChild('option');
248
- $messageXml->addCustomChild('type', $message['type']);
249
- $messageXml->addCustomChild('text', $xmlObject->escapeXml($message['text']));
250
- }
251
- }
252
- }
253
- }
254
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Details.php CHANGED
@@ -42,8 +42,8 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Details extends Mage_Paypal_Block_E
42
  public function addDetailsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj)
43
  {
44
  $itemsXmlObj = $reviewXmlObj->addChild('ordered_items');
45
- foreach ($this->getItems() as $item) {
46
- $this->getItemXml($item, $itemsXmlObj);
47
  }
48
 
49
  $reviewXmlObj->appendChild($this->getChild('totals')->setReturnObjectFlag(true)->_toHtml());
@@ -59,8 +59,10 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Details extends Mage_Paypal_Block_E
59
  * @return Mage_XmlConnect_Model_Simplexml_Element
60
  */
61
  public function getItemXml(
62
- Mage_Sales_Model_Quote_Item $item, Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj
63
- ) {
 
 
64
  $renderer = $this->getItemRenderer($item->getProductType())->setItem($item)->setQuote($this->getQuote());
65
  return $renderer->addProductToXmlObj($reviewXmlObj);
66
  }
@@ -76,7 +78,9 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Details extends Mage_Paypal_Block_E
76
  public function addItemRender($productType, $blockType, $template)
77
  {
78
  $this->_itemRenders[$productType] = array(
79
- 'block' => $blockType, 'template' => $template, 'blockInstance' => null
 
 
80
  );
81
  return $this;
82
  }
42
  public function addDetailsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj)
43
  {
44
  $itemsXmlObj = $reviewXmlObj->addChild('ordered_items');
45
+ foreach ($this->getItems() as $_item) {
46
+ $this->getItemXml($_item, $itemsXmlObj);
47
  }
48
 
49
  $reviewXmlObj->appendChild($this->getChild('totals')->setReturnObjectFlag(true)->_toHtml());
59
  * @return Mage_XmlConnect_Model_Simplexml_Element
60
  */
61
  public function getItemXml(
62
+ Mage_Sales_Model_Quote_Item $item,
63
+ Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj
64
+ )
65
+ {
66
  $renderer = $this->getItemRenderer($item->getProductType())->setItem($item)->setQuote($this->getQuote());
67
  return $renderer->addProductToXmlObj($reviewXmlObj);
68
  }
78
  public function addItemRender($productType, $blockType, $template)
79
  {
80
  $this->_itemRenders[$productType] = array(
81
+ 'block' => $blockType,
82
+ 'template' => $template,
83
+ 'blockInstance' => null
84
  );
85
  return $this;
86
  }
app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/OrderDetails.php DELETED
@@ -1,83 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * PayPal MECL order details xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_Xmlconnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Cart_Paypal_Mecl_OrderDetails extends Mage_Paypal_Block_Express_Review_Details
35
- {
36
- /**
37
- * Add cart details to XML object
38
- *
39
- * @param Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj
40
- * @return Mage_XmlConnect_Model_Simplexml_Element
41
- */
42
- public function addDetailsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj)
43
- {
44
- $itemsXmlObj = $reviewXmlObj->addChild('ordered_items');
45
- foreach ($this->getItems() as $item) {
46
- $this->getItemXml($item, $itemsXmlObj);
47
- }
48
-
49
- $this->getChild('totals')->setCartXmlObject($reviewXmlObj)->_toHtml();
50
-
51
- return $reviewXmlObj;
52
- }
53
-
54
- /**
55
- * Get item row xml
56
- *
57
- * @param Mage_Sales_Model_Quote_Item $item
58
- * @param Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj
59
- * @return Mage_XmlConnect_Model_Simplexml_Element
60
- */
61
- public function getItemXml(
62
- Mage_Sales_Model_Quote_Item $item, Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj
63
- ) {
64
- $renderer = $this->getItemRenderer($item->getProductType())->setItem($item)->setQuote($this->getQuote());
65
- return $renderer->addProductToXmlObj($reviewXmlObj);
66
- }
67
-
68
- /**
69
- * Add renderer for item product type
70
- *
71
- * @param string $productType
72
- * @param string $blockType
73
- * @param string $template
74
- * @return Mage_Checkout_Block_Cart_Abstract
75
- */
76
- public function addItemRender($productType, $blockType, $template)
77
- {
78
- $this->_itemRenders[$productType] = array(
79
- 'block' => $blockType, 'template' => $template, 'blockInstance' => null
80
- );
81
- return $this;
82
- }
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Review.php CHANGED
@@ -44,14 +44,15 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Review extends Mage_Paypal_Block_Ex
44
  $reviewXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<mecl_cart_details></mecl_cart_details>');
45
 
46
  if ($this->getPaypalMessages()) {
47
- $reviewXmlObj->addChild('paypal_message', implode('\n', $this->getPaypalMessages()));
48
  }
49
 
50
  if ($this->getShippingAddress()) {
51
- $shipping = Mage::helper('xmlconnect')->trimLineBreaks($this->getShippingAddress()->format('text'));
52
- $reviewXmlObj->addCustomChild('shipping_address', $shipping, array(
53
- 'label' => $this->__('Shipping Address')
54
- ));
 
55
  }
56
 
57
  if ($this->_quote->isVirtual()) {
@@ -77,20 +78,17 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Review extends Mage_Paypal_Block_Ex
77
  $reviewXmlObj->addCustomChild('payment_method', $this->escapeHtml($this->getPaymentMethodTitle()), array(
78
  'label' => $this->__('Payment Method')
79
  ));
80
- $billing = Mage::helper('xmlconnect')->trimLineBreaks($this->getBillingAddress()->format('text'));
81
- $reviewXmlObj->addCustomChild('billing_address', $billing, array(
82
- 'label' => $this->__('Billing Address'),
83
- 'payer_email' => $this->__('Payer Email: %s', $this->getBillingAddress()->getEmail())
 
 
 
84
  ));
85
 
86
  $this->getChild('details')->addDetailsToXmlObj($reviewXmlObj);
87
 
88
- $agreements = $this->getChildHtml('agreements');
89
- if ($agreements) {
90
- $agreementsXmlObj = Mage::getModel('xmlconnect/simplexml_element', $agreements);
91
- $reviewXmlObj->appendChild($agreementsXmlObj);
92
- }
93
-
94
  return $reviewXmlObj->asNiceXml();
95
  }
96
  }
44
  $reviewXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<mecl_cart_details></mecl_cart_details>');
45
 
46
  if ($this->getPaypalMessages()) {
47
+ $reviewXmlObj->addChild('paypal_message', implode(PHP_EOL, $this->getPaypalMessages()));
48
  }
49
 
50
  if ($this->getShippingAddress()) {
51
+ $reviewXmlObj->addCustomChild(
52
+ 'shipping_address',
53
+ Mage::helper('xmlconnect')->trimLineBreaks($this->getShippingAddress()->format('text')),
54
+ array('label' => $this->__('Shipping Address'))
55
+ );
56
  }
57
 
58
  if ($this->_quote->isVirtual()) {
78
  $reviewXmlObj->addCustomChild('payment_method', $this->escapeHtml($this->getPaymentMethodTitle()), array(
79
  'label' => $this->__('Payment Method')
80
  ));
81
+
82
+ $reviewXmlObj->addCustomChild(
83
+ 'billing_address',
84
+ Mage::helper('xmlconnect')->trimLineBreaks($this->getBillingAddress()->format('text')),
85
+ array(
86
+ 'label' => $this->__('Billing Address'),
87
+ 'payer_email' => $this->__('Payer Email: %s', $this->getBillingAddress()->getEmail())
88
  ));
89
 
90
  $this->getChild('details')->addDetailsToXmlObj($reviewXmlObj);
91
 
 
 
 
 
 
 
92
  return $reviewXmlObj->asNiceXml();
93
  }
94
  }
app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Shippingmethods.php CHANGED
@@ -31,30 +31,9 @@
31
  * @package Mage_Xmlconnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods extends Mage_Paypal_Block_Express_Review
 
35
  {
36
- /**
37
- * Add price details to xml object
38
- *
39
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
40
- * @param Mage_Sales_Model_Quote_Address_Rate $rate
41
- * @return Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
42
- */
43
- protected function _addPriceToXmlObj($xmlObj, $rate)
44
- {
45
- $price = $this->_getShippingPrice($rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax());
46
- $incl = $this->_getShippingPrice($rate->getPrice(), true);
47
- $renderedInclTax = '';
48
- if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
49
- $inclTaxFormat = ' (%s %s)';
50
- $renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
51
- }
52
- $price .= $renderedInclTax;
53
- $xmlObj->addAttribute('price', $rate->getPrice() * 1);
54
- $xmlObj->addAttribute('formatted_price', $xmlObj->escapeXml($price));
55
- return $this;
56
- }
57
-
58
  /**
59
  * Render PayPal MECL shipping method list xml
60
  *
@@ -64,100 +43,45 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods extends Mage_Paypal
64
  {
65
  /** @var $listXmlObj Mage_XmlConnect_Model_Simplexml_Element */
66
  $methodListXmlObj = Mage::getModel(
67
- 'xmlconnect/simplexml_element', '<shipping_method_list></shipping_method_list>'
 
68
  );
 
69
  $methodListXmlObj->addAttribute('label', $this->__('Shipping Method'));
70
 
71
- if (Mage::helper('xmlconnect')->checkApiVersion(Mage_XmlConnect_Helper_Data::DEVICE_API_V_23)) {
72
- if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()) {
73
- $groups = $this->getShippingRateGroups();
74
- if ($groups) {
75
- $currentRate = $this->getCurrentShippingRate();
76
- foreach ($groups as $code => $rates) {
77
- $rateListXmlObj = $this->_addRatesToXmlObj($methodListXmlObj, $code);
78
- foreach ($rates as $rate) {
79
- $rateAttributes = array(
80
- 'label' => $rate->getMethodTitle(),
81
- 'code' => $this->renderShippingRateValue($rate)
82
- );
83
- $rateXmlObj = $rateListXmlObj->addCustomChild('rate', null, $rateAttributes);
84
- if ($rate->getErrorMessage()) {
85
- $rateXmlObj->addChild('error_message', $rateXmlObj->escapeXml(
86
- $rate->getErrorMessage()
87
- ));
88
- } else {
89
- $this->_addPriceToXmlObj($rateXmlObj, $rate);
90
- }
91
- if ($currentRate === $rate) {
92
- $rateXmlObj->addAttribute('selected', 1);
93
- }
94
  }
 
95
  }
96
- } else {
97
- $this->_addNoShippingMessage($methodListXmlObj);
98
  }
99
  } else {
100
- $rateListXmlObj = $this->_addRatesToXmlObj($methodListXmlObj);
101
- $rate = $this->getCurrentShippingRate();
102
- $rateXmlObj = $rateListXmlObj->addCustomChild('rate', null, array(
103
- 'label' => $rate->getMethodTitle(),
104
- 'code' => $this->renderShippingRateValue($rate),
105
- 'selected' => 1
106
- ));
107
- $this->_addPriceToXmlObj($rateXmlObj, $rate);
108
  }
109
  } else {
110
- if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()) {
111
- $groups = $this->getShippingRateGroups();
112
- if ($groups) {
113
- $currentRate = $this->getCurrentShippingRate();
114
- foreach ($groups as $code => $rates) {
115
- $rateListXmlObj = $this->_addRatesToXmlObj($methodListXmlObj, $code);
116
- foreach ($rates as $rate) {
117
- if ($rate->getErrorMessage()) {
118
- $title = $rate->getErrorMessage();
119
- } else {
120
- $title = $this->renderShippingRateOption($rate);
121
- }
122
- $rateAttributes = array(
123
- 'label' => $rateListXmlObj->escapeXml($title),
124
- 'code' => $this->renderShippingRateValue($rate)
125
- );
126
- if ($currentRate === $rate) {
127
- $rateAttributes += array('selected' => 1);
128
- }
129
- $rateListXmlObj->addCustomChild('rate', null, $rateAttributes);
130
- }
131
- }
132
- } else {
133
- $this->_addNoShippingMessage($methodListXmlObj);
134
- }
135
- } else {
136
- $rateXmlObj = $this->_addRatesToXmlObj($methodListXmlObj);
137
- $rateXmlObj->addCustomChild('rate', null, array(
138
- 'label' => $this->renderShippingRateOption($this->getCurrentShippingRate()),
139
- 'selected' => 1
140
- ));
141
- }
142
  }
143
 
144
  return $methodListXmlObj->asNiceXml();
145
  }
146
 
147
- /**
148
- * Add message to describe that shipping is not required or not available
149
- *
150
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodListXmlObj
151
- * @return Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
152
- */
153
- protected function _addNoShippingMessage($methodListXmlObj)
154
- {
155
- $message = $this->_quote->isVirtual() ? $this->__('No shipping method required.')
156
- : $this->__('Sorry, no quotes are available for this order at this time.');
157
- $methodListXmlObj->addCustomChild('method', null, array('label' => $message));
158
- return $this;
159
- }
160
-
161
  /**
162
  * Add cart details to XML object
163
  *
@@ -165,7 +89,7 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods extends Mage_Paypal
165
  * @param string $code
166
  * @return Mage_XmlConnect_Model_Simplexml_Element
167
  */
168
- protected function _addRatesToXmlObj($methodListXmlObj, $code = '')
169
  {
170
  $attributes = $code ? array('label' => $this->getCarrierName($code)) : array();
171
  return $methodListXmlObj->addCustomChild('method', null, $attributes)->addCustomChild('rates');
31
  * @package Mage_Xmlconnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
35
+ extends Mage_Paypal_Block_Express_Review
36
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  /**
38
  * Render PayPal MECL shipping method list xml
39
  *
43
  {
44
  /** @var $listXmlObj Mage_XmlConnect_Model_Simplexml_Element */
45
  $methodListXmlObj = Mage::getModel(
46
+ 'xmlconnect/simplexml_element',
47
+ '<shipping_method_list></shipping_method_list>'
48
  );
49
+
50
  $methodListXmlObj->addAttribute('label', $this->__('Shipping Method'));
51
 
52
+ if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()) {
53
+ $groups = $this->getShippingRateGroups();
54
+ if ($groups) {
55
+ $currentRate = $this->getCurrentShippingRate();
56
+ foreach ($groups as $code => $rates) {
57
+ $rateXmlObj = $this->_addRatesToXmlObj($methodListXmlObj, $code);
58
+ foreach ($rates as $rate) {
59
+ $rateAttributes = array(
60
+ 'label' => strip_tags($this->renderShippingRateOption($rate)),
61
+ 'code' => $this->renderShippingRateValue($rate)
62
+ );
63
+ if ($currentRate === $rate) {
64
+ $rateAttributes += array('selected' => 1);
 
 
 
 
 
 
 
 
 
 
65
  }
66
+ $rateXmlObj->addCustomChild('rate', null, $rateAttributes);
67
  }
 
 
68
  }
69
  } else {
70
+ $message = $this->_quote->isVirtual() ? $this->__('No shipping method required.')
71
+ : $this->__('Sorry, no quotes are available for this order at this time.');
72
+ $methodListXmlObj->addCustomChild('method', null, array('label' => $message));
 
 
 
 
 
73
  }
74
  } else {
75
+ $rateXmlObj = $this->_addRatesToXmlObj($methodListXmlObj);
76
+ $rateXmlObj->addCustomChild('rate', null, array(
77
+ 'label' => $this->renderShippingRateOption($this->getCurrentShippingRate()),
78
+ 'selected' => 1
79
+ ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
 
82
  return $methodListXmlObj->asNiceXml();
83
  }
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  /**
86
  * Add cart details to XML object
87
  *
89
  * @param string $code
90
  * @return Mage_XmlConnect_Model_Simplexml_Element
91
  */
92
+ protected function _addRatesToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $methodListXmlObj, $code = '')
93
  {
94
  $attributes = $code ? array('label' => $this->getCarrierName($code)) : array();
95
  return $methodListXmlObj->addCustomChild('method', null, $attributes)->addCustomChild('rates');
app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php CHANGED
@@ -59,7 +59,10 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mep_Totals extends Mage_Checkout_Block_C
59
  switch ($code) {
60
  case 'subtotal':
61
  $subtotal = intval($total->getValueExclTax()) ? $total->getValueExclTax() : $total->getValue();
62
- $paypalTotals->addAttribute($code, Mage::helper('xmlconnect')->formatPriceForXml($subtotal));
 
 
 
63
  break;
64
  case 'tax':
65
  $paypalTotals->addAttribute(
59
  switch ($code) {
60
  case 'subtotal':
61
  $subtotal = intval($total->getValueExclTax()) ? $total->getValueExclTax() : $total->getValue();
62
+ $paypalTotals->addAttribute(
63
+ $code,
64
+ Mage::helper('xmlconnect')->formatPriceForXml($subtotal)
65
+ );
66
  break;
67
  case 'tax':
68
  $paypalTotals->addAttribute(
app/code/core/Mage/XmlConnect/Block/Cart/Totals.php CHANGED
@@ -58,7 +58,10 @@ class Mage_XmlConnect_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Totals
58
  if ($renderer->displayBoth()) {
59
  $title = $this->__('Subtotal (Excl. Tax)');
60
  $this->_addTotalDataToXmlObj(
61
- $totalsXmlObj, $code . '_excl_tax', $title, $total->getValueExclTax()
 
 
 
62
  );
63
 
64
  $code = $code . '_incl_tax';
@@ -100,12 +103,12 @@ class Mage_XmlConnect_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Totals
100
  }
101
  continue 2;
102
  case 'giftcardaccount':
103
- $cards = $renderer->getTotal()->getGiftCards();
104
- if (!$cards) {
105
- $cards = $renderer->getQuoteGiftCards();
106
  }
107
  if ($renderer->getTotal()->getValue()) {
108
- foreach ($cards as $cardCode) {
109
  $title = $this->__('Gift Card (%s)', $cardCode['c']);
110
  $value = $cardCode['c'];
111
  $totalXmlObj = $totalsXmlObj->addChild($code);
58
  if ($renderer->displayBoth()) {
59
  $title = $this->__('Subtotal (Excl. Tax)');
60
  $this->_addTotalDataToXmlObj(
61
+ $totalsXmlObj,
62
+ $code . '_excl_tax',
63
+ $title,
64
+ $total->getValueExclTax()
65
  );
66
 
67
  $code = $code . '_incl_tax';
103
  }
104
  continue 2;
105
  case 'giftcardaccount':
106
+ $_cards = $renderer->getTotal()->getGiftCards();
107
+ if (!$_cards) {
108
+ $_cards = $renderer->getQuoteGiftCards();
109
  }
110
  if ($renderer->getTotal()->getValue()) {
111
+ foreach ($_cards as $cardCode) {
112
  $title = $this->__('Gift Card (%s)', $cardCode['c']);
113
  $value = $cardCode['c'];
114
  $totalXmlObj = $totalsXmlObj->addChild($code);
app/code/core/Mage/XmlConnect/Block/Catalog.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_Xmlconnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Catalog extends Mage_Catalog_Block_Product_List_Toolbar
35
  {
36
  /**
37
  * Limit for product sorting fields to return
@@ -39,48 +39,22 @@ class Mage_XmlConnect_Block_Catalog extends Mage_Catalog_Block_Product_List_Tool
39
  const PRODUCT_SORT_FIELDS_NUMBER = 3;
40
 
41
  /**
42
- * Prefix that used in specifying filters on request
43
- *
44
- * @deprecated renamed
45
  */
46
- const REQUEST_FILTER_PARAM_REFIX = self::REQUEST_FILTER_PARAM_PREFIX;
47
 
48
  /**
49
- * Prefix that used in specifying filters on request
50
- */
51
- const REQUEST_FILTER_PARAM_PREFIX = 'filter_';
52
-
53
- /**
54
- * Prefix that used in specifying sort order params on request
55
- *
56
- * @deprecated renamed
57
  */
58
- const REQUEST_SORT_ORDER_PARAM_REFIX = self::REQUEST_SORT_ORDER_PARAM_PREFIX;
59
-
60
- /**
61
- * Prefix that used in specifying sort order params on request
62
- */
63
- const REQUEST_SORT_ORDER_PARAM_PREFIX = 'order_';
64
 
65
  /**
66
  * Retrieve product sort fields as xml object
67
  *
68
- * @deprecated method renamed
69
  * @return Mage_XmlConnect_Model_Simplexml_Element
70
  */
71
  public function getProductSortFeildsXmlObject()
72
  {
73
- $this->getProductSortFieldsXmlObject();
74
- }
75
-
76
- /**
77
- * Retrieve product sort fields as xml object
78
- *
79
- * @return Mage_XmlConnect_Model_Simplexml_Element
80
- */
81
- public function getProductSortFieldsXmlObject()
82
- {
83
- /** @var $ordersXmlObject Mage_XmlConnect_Model_Simplexml_Element */
84
  $ordersXmlObject = Mage::getModel('xmlconnect/simplexml_element', '<orders></orders>');
85
  /* @var $category Mage_Catalog_Model_Category */
86
  $category = Mage::getModel('catalog/category');
@@ -98,32 +72,4 @@ class Mage_XmlConnect_Block_Catalog extends Mage_Catalog_Block_Product_List_Tool
98
 
99
  return $ordersXmlObject;
100
  }
101
-
102
- /**
103
- * Retrieve catalog search product sort fields as xml object
104
- *
105
- * @return Mage_XmlConnect_Model_Simplexml_Element
106
- */
107
- public function getSearchProductSortFieldsXmlObject()
108
- {
109
- /** @var $ordersXmlObject Mage_XmlConnect_Model_Simplexml_Element */
110
- $ordersXmlObject = Mage::getModel('xmlconnect/simplexml_element', '<orders></orders>');
111
- /* @var $category Mage_Catalog_Model_Category */
112
- $category = Mage::getModel('catalog/category');
113
- $sortOptions = $category->getAvailableSortByOptions();
114
- $sortOptions = array_slice($sortOptions, 0, self::PRODUCT_SORT_FIELDS_NUMBER);
115
- unset($sortOptions['position']);
116
- $sortOptions = array_merge(array('relevance' => $this->__('Relevance')), $sortOptions);
117
- $this->setAvailableOrders($sortOptions)->setDefaultDirection('desc')->setSortBy('relevance');
118
-
119
- foreach($this->getAvailableOrders() as $key => $order) {
120
- $item = $ordersXmlObject->addChild('item');
121
- if ($this->isOrderCurrent($key)) {
122
- $item->addAttribute('isDefault', 1);
123
- }
124
- $item->addChild('code', $key);
125
- $item->addChild('name', $ordersXmlObject->escapeXml($order));
126
- }
127
- return $ordersXmlObject;
128
- }
129
  }
31
  * @package Mage_Xmlconnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Catalog extends Mage_Core_Block_Template
35
  {
36
  /**
37
  * Limit for product sorting fields to return
39
  const PRODUCT_SORT_FIELDS_NUMBER = 3;
40
 
41
  /**
42
+ * Prefix that used in specifing filters on request
 
 
43
  */
44
+ const REQUEST_FILTER_PARAM_REFIX = 'filter_';
45
 
46
  /**
47
+ * Prefix that used in specifing sort order params on request
 
 
 
 
 
 
 
48
  */
49
+ const REQUEST_SORT_ORDER_PARAM_REFIX = 'order_';
 
 
 
 
 
50
 
51
  /**
52
  * Retrieve product sort fields as xml object
53
  *
 
54
  * @return Mage_XmlConnect_Model_Simplexml_Element
55
  */
56
  public function getProductSortFeildsXmlObject()
57
  {
 
 
 
 
 
 
 
 
 
 
 
58
  $ordersXmlObject = Mage::getModel('xmlconnect/simplexml_element', '<orders></orders>');
59
  /* @var $category Mage_Catalog_Model_Category */
60
  $category = Mage::getModel('catalog/category');
72
 
73
  return $ordersXmlObject;
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Category.php CHANGED
@@ -43,9 +43,8 @@ class Mage_XmlConnect_Block_Catalog_Category extends Mage_XmlConnect_Block_Catal
43
  /** @var $categoryXmlObj Mage_XmlConnect_Model_Simplexml_Element */
44
  $categoryXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<category></category>');
45
  $categoryId = $this->getRequest()->getParam('id', null);
46
- $rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
47
- if (null === $categoryId) {
48
- $categoryId = $rootCategoryId;
49
  }
50
 
51
  $productsXmlObj = $productListBlock = false;
@@ -74,15 +73,10 @@ class Mage_XmlConnect_Block_Catalog_Category extends Mage_XmlConnect_Block_Catal
74
  // subcategories are exists
75
  if (sizeof($categoryCollection)) {
76
  $itemsXmlObj = $categoryXmlObj->addChild('items');
77
- $categoryImageSize = Mage::getModel('xmlconnect/images')->getImageLimitParam('content/category');
78
  foreach ($categoryCollection as $item) {
79
  /** @var $item Mage_Catalog_Model_Category */
80
  $item = Mage::getModel('catalog/category')->load($item->getId());
81
 
82
- if ($categoryId == $rootCategoryId && !$item->getIncludeInMenu()) {
83
- continue;
84
- }
85
-
86
  $itemXmlObj = $itemsXmlObj->addChild('item');
87
  $itemXmlObj->addChild('label', $categoryXmlObj->escapeXml($item->getName()));
88
  $itemXmlObj->addChild('entity_id', $item->getId());
@@ -91,10 +85,12 @@ class Mage_XmlConnect_Block_Catalog_Category extends Mage_XmlConnect_Block_Catal
91
  $itemXmlObj->addChild('parent_id', $item->getParentId());
92
  }
93
  $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail')
94
- ->resize($categoryImageSize);
95
 
96
  $iconXml = $itemXmlObj->addChild('icon', $icon);
97
- $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
 
 
98
  }
99
  }
100
 
43
  /** @var $categoryXmlObj Mage_XmlConnect_Model_Simplexml_Element */
44
  $categoryXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<category></category>');
45
  $categoryId = $this->getRequest()->getParam('id', null);
46
+ if ($categoryId === null) {
47
+ $categoryId = Mage::app()->getStore()->getRootCategoryId();
 
48
  }
49
 
50
  $productsXmlObj = $productListBlock = false;
73
  // subcategories are exists
74
  if (sizeof($categoryCollection)) {
75
  $itemsXmlObj = $categoryXmlObj->addChild('items');
 
76
  foreach ($categoryCollection as $item) {
77
  /** @var $item Mage_Catalog_Model_Category */
78
  $item = Mage::getModel('catalog/category')->load($item->getId());
79
 
 
 
 
 
80
  $itemXmlObj = $itemsXmlObj->addChild('item');
81
  $itemXmlObj->addChild('label', $categoryXmlObj->escapeXml($item->getName()));
82
  $itemXmlObj->addChild('entity_id', $item->getId());
85
  $itemXmlObj->addChild('parent_id', $item->getParentId());
86
  }
87
  $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail')
88
+ ->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('category'));
89
 
90
  $iconXml = $itemXmlObj->addChild('icon', $icon);
91
+
92
+ $file = Mage::helper('xmlconnect')->urlToPath($icon);
93
+ $iconXml->addAttribute('modification_time', filemtime($file));
94
  }
95
  }
96
 
app/code/core/Mage/XmlConnect/Block/Catalog/Filters.php CHANGED
@@ -41,7 +41,6 @@ class Mage_XmlConnect_Block_Catalog_Filters extends Mage_XmlConnect_Block_Catalo
41
  protected function _toHtml()
42
  {
43
  $categoryId = $this->getRequest()->getParam('category_id', null);
44
- /** @var $categoryXmlObj Mage_XmlConnect_Model_Simplexml_Element */
45
  $categoryXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<category></category>');
46
  $filtersCollection = Mage::getResourceModel('xmlconnect/filter_collection')->setCategoryId($categoryId);
47
 
@@ -62,7 +61,7 @@ class Mage_XmlConnect_Block_Catalog_Filters extends Mage_XmlConnect_Block_Catalo
62
  $valueXmlObj->addChild('count', (int)$value->getProductsCount());
63
  }
64
  }
65
- $categoryXmlObj->appendChild($this->getProductSortFieldsXmlObject());
66
 
67
  return $categoryXmlObj->asNiceXml();
68
  }
41
  protected function _toHtml()
42
  {
43
  $categoryId = $this->getRequest()->getParam('category_id', null);
 
44
  $categoryXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<category></category>');
45
  $filtersCollection = Mage::getResourceModel('xmlconnect/filter_collection')->setCategoryId($categoryId);
46
 
61
  $valueXmlObj->addChild('count', (int)$value->getProductsCount());
62
  }
63
  }
64
+ $categoryXmlObj->appendChild($this->getProductSortFeildsXmlObject());
65
 
66
  return $categoryXmlObj->asNiceXml();
67
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product.php CHANGED
@@ -52,24 +52,23 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
52
  $description = Mage::helper('xmlconnect')->htmlize($item->xmlentities($product->getDescription()));
53
  $item->addChild('description', $description);
54
  $item->addChild('link', $product->getProductUrl());
55
- /** @var $imageLimitsModel Mage_XmlConnect_Model_Images */
56
- $imageLimitsModel = Mage::getModel('xmlconnect/images');
57
 
58
  if ($itemNodeName == 'item') {
59
- $imageToResize = $imageLimitsModel->getImageLimitParam('content/product_small');
60
  $propertyToResizeName = 'small_image';
61
  } else {
62
- $imageToResize = $imageLimitsModel->getImageLimitParam('content/product_big');
63
  $propertyToResizeName = 'image';
64
  }
65
 
66
- $icon = clone Mage::helper('xmlconnect/catalog_product_image')->init($product, $propertyToResizeName)
67
- ->resize($imageToResize);
68
 
69
  $iconXml = $item->addChild('icon', $icon);
70
- $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
71
 
72
- $item->addChild('in_stock', (int)$product->getStockItem()->getIsInStock());
 
 
 
73
  $item->addChild('is_salable', (int)$product->isSalable());
74
  /**
75
  * By default all products has gallery (because of collection not load gallery attribute)
@@ -88,14 +87,8 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
88
  }
89
  $item->addChild('has_options', (int)$product->getHasOptions());
90
 
91
- $minSaleQty = null;
92
- if ($product->hasPreconfiguredValues()) {
93
- $minSaleQty = $product->getPreconfiguredValues()->getData('qty');
94
- }
95
- $minSaleQty = $minSaleQty ? $minSaleQty : $this->_getMinimalQty($product);
96
-
97
- if ($minSaleQty) {
98
- $item->addChild('min_sale_qty', (int)$minSaleQty);
99
  }
100
 
101
  if (!$product->getRatingSummary()) {
@@ -106,7 +99,8 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
106
  $item->addChild('reviews_count', $product->getRatingSummary()->getReviewsCount());
107
 
108
  if ($this->getChild('product_price')) {
109
- $this->getChild('product_price')->setProduct($product)->setProductXmlObj($item)->collectProductPrices();
 
110
  }
111
 
112
  if ($this->getChild('additional_info')) {
@@ -142,28 +136,24 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
142
  protected function _toHtml()
143
  {
144
  /** @var $product Mage_Catalog_Model_Product */
145
- if ($this->getProduct()) {
146
- $product = $this->getProduct();
 
 
 
147
  } else {
148
- $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())
149
- ->load($this->getRequest()->getParam('id', 0));
150
- if (!$product) {
151
- Mage::throwException($this->__('Selected product is unavailable.'));
152
- } else {
153
- $this->setProduct($product);
 
154
  }
155
  }
156
- /** @var $productXmlObj Mage_XmlConnect_Model_Simplexml_Element */
157
- $productXmlObj = $this->productToXmlObject($product, 'product');
158
-
159
- /** @var $relatedProductsBlock Mage_XmlConnect_Block_Catalog_Product_Related */
160
- $relatedProductsBlock = $this->getChild('related_products');
161
- if ($relatedProductsBlock) {
162
- $relatedXmlObj = $relatedProductsBlock->getRelatedProductsXmlObj();
163
- $productXmlObj->appendChild($relatedXmlObj);
164
- }
165
 
166
- $productOptions = $this->getChild('xmlconnect.catalog.product.options')->getProductOptionsXmlObject($product);
 
167
  if ($productOptions instanceof Mage_XmlConnect_Model_Simplexml_Element) {
168
  $productXmlObj->appendChild($productOptions);
169
  }
52
  $description = Mage::helper('xmlconnect')->htmlize($item->xmlentities($product->getDescription()));
53
  $item->addChild('description', $description);
54
  $item->addChild('link', $product->getProductUrl());
 
 
55
 
56
  if ($itemNodeName == 'item') {
57
+ $imageToResize = Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small');
58
  $propertyToResizeName = 'small_image';
59
  } else {
60
+ $imageToResize = Mage::helper('xmlconnect/image')->getImageSizeForContent('product_big');
61
  $propertyToResizeName = 'image';
62
  }
63
 
64
+ $icon = clone Mage::helper('catalog/image')->init($product, $propertyToResizeName)->resize($imageToResize);
 
65
 
66
  $iconXml = $item->addChild('icon', $icon);
 
67
 
68
+ $file = Mage::helper('xmlconnect')->urlToPath($icon);
69
+ $iconXml->addAttribute('modification_time', filemtime($file));
70
+
71
+ $item->addChild('in_stock', (int)$product->getIsInStock());
72
  $item->addChild('is_salable', (int)$product->isSalable());
73
  /**
74
  * By default all products has gallery (because of collection not load gallery attribute)
87
  }
88
  $item->addChild('has_options', (int)$product->getHasOptions());
89
 
90
+ if ($minSaleQty = $this->_getMinimalQty($product)) {
91
+ $item->addChild('min_sale_qty', (int) $minSaleQty);
 
 
 
 
 
 
92
  }
93
 
94
  if (!$product->getRatingSummary()) {
99
  $item->addChild('reviews_count', $product->getRatingSummary()->getReviewsCount());
100
 
101
  if ($this->getChild('product_price')) {
102
+ $this->getChild('product_price')->setProduct($product)->setProductXmlObj($item)
103
+ ->collectProductPrices();
104
  }
105
 
106
  if ($this->getChild('additional_info')) {
136
  protected function _toHtml()
137
  {
138
  /** @var $product Mage_Catalog_Model_Product */
139
+ $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())
140
+ ->load($this->getRequest()->getParam('id', 0));
141
+
142
+ if (!$product) {
143
+ Mage::throwException($this->__('Selected product is unavailable.'));
144
  } else {
145
+ $this->setProduct($product);
146
+ $productXmlObj = $this->productToXmlObject($product, 'product');
147
+
148
+ $relatedProductsBlock = $this->getChild('related_products');
149
+ if ($relatedProductsBlock) {
150
+ $relatedXmlObj = $relatedProductsBlock->getRelatedProductsXmlObj();
151
+ $productXmlObj->appendChild($relatedXmlObj);
152
  }
153
  }
 
 
 
 
 
 
 
 
 
154
 
155
+ $productOptions = $this->getChild('xmlconnect.catalog.product.options')
156
+ ->getProductOptionsXmlObject($product);
157
  if ($productOptions instanceof Mage_XmlConnect_Model_Simplexml_Element) {
158
  $productXmlObj->appendChild($productOptions);
159
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Attributes.php CHANGED
@@ -53,7 +53,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Attributes extends Mage_Catalog_Bloc
53
  /** @var $attrXmlObject Mage_XmlConnect_Model_Simplexml_Element */
54
  $attrXmlObject = $attributesXmlObj->addChild('item');
55
  $attrXmlObject->addCustomChild('label', $data['label']);
56
- $attrXmlObject->addCustomChild('value', $attrXmlObject->escapeXml($attribute));
57
  }
58
  }
59
  }
53
  /** @var $attrXmlObject Mage_XmlConnect_Model_Simplexml_Element */
54
  $attrXmlObject = $attributesXmlObj->addChild('item');
55
  $attrXmlObject->addCustomChild('label', $data['label']);
56
+ $attrXmlObject->addCustomChild('value', strip_tags($attribute));
57
  }
58
  }
59
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Gallery.php CHANGED
@@ -40,42 +40,43 @@ class Mage_XmlConnect_Block_Catalog_Product_Gallery extends Mage_XmlConnect_Bloc
40
  */
41
  protected function _toHtml()
42
  {
43
- $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())
44
- ->load($this->getProductId());
45
  $collection = $product->getMediaGalleryImages();
46
 
47
  $imagesNode = Mage::getModel('xmlconnect/simplexml_element', '<images></images>');
48
- $productImageHelper = $this->helper('xmlconnect/catalog_product_image');
49
 
50
- /** @var $imageLimitsModel Mage_XmlConnect_Model_Images */
51
- $imageLimitsModel = Mage::getModel('xmlconnect/images');
52
- $gallerySmallImageSize = $imageLimitsModel->getImageLimitParam('content/product_gallery_small');
53
- $galleryBigImageSize = $imageLimitsModel->getImageLimitParam('content/product_gallery_big');
54
  foreach ($collection as $item) {
55
  $imageNode = $imagesNode->addChild('image');
56
 
57
  /**
58
  * Big image
59
  */
60
- $bigImage = $productImageHelper->init($product, 'image', $item->getFile())->constrainOnly(true)
61
- ->keepFrame(false)->resize($galleryBigImageSize);
62
 
63
  $fileNode = $imageNode->addChild('file');
64
  $fileNode->addAttribute('type', 'big');
65
  $fileNode->addAttribute('url', $bigImage);
 
 
 
66
  $fileNode->addAttribute('id', ($id = $item->getId()) ? (int) $id : 0);
67
- $fileNode->addAttribute('modification_time', filemtime($bigImage->getNewFile()));
68
 
69
  /**
70
  * Small image
71
  */
72
- $smallImage = $productImageHelper->init($product, 'thumbnail', $item->getFile())->constrainOnly(true)
73
- ->keepFrame(false)->resize($gallerySmallImageSize);
74
 
75
  $fileNode = $imageNode->addChild('file');
76
  $fileNode->addAttribute('type', 'small');
77
  $fileNode->addAttribute('url', $smallImage);
78
- $fileNode->addAttribute('modification_time', filemtime($smallImage->getNewFile()));
 
 
79
  }
80
  return $imagesNode->asNiceXml();
81
  }
40
  */
41
  protected function _toHtml()
42
  {
43
+ $productId = $this->getRequest()->getParam('id', null);
44
+ $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($productId);
45
  $collection = $product->getMediaGalleryImages();
46
 
47
  $imagesNode = Mage::getModel('xmlconnect/simplexml_element', '<images></images>');
48
+ $helper = $this->helper('catalog/image');
49
 
 
 
 
 
50
  foreach ($collection as $item) {
51
  $imageNode = $imagesNode->addChild('image');
52
 
53
  /**
54
  * Big image
55
  */
56
+ $bigImage = $helper->init($product, 'image', $item->getFile())->constrainOnly(true)->keepFrame(false)
57
+ ->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_gallery_big'));
58
 
59
  $fileNode = $imageNode->addChild('file');
60
  $fileNode->addAttribute('type', 'big');
61
  $fileNode->addAttribute('url', $bigImage);
62
+
63
+ $file = Mage::helper('xmlconnect')->urlToPath($bigImage);
64
+
65
  $fileNode->addAttribute('id', ($id = $item->getId()) ? (int) $id : 0);
66
+ $fileNode->addAttribute('modification_time', filemtime($file));
67
 
68
  /**
69
  * Small image
70
  */
71
+ $smallImage = $helper->init($product, 'thumbnail', $item->getFile())->constrainOnly(true)->keepFrame(false)
72
+ ->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_gallery_small'));
73
 
74
  $fileNode = $imageNode->addChild('file');
75
  $fileNode->addAttribute('type', 'small');
76
  $fileNode->addAttribute('url', $smallImage);
77
+
78
+ $file = Mage::helper('xmlconnect')->urlToPath($smallImage);
79
+ $fileNode->addAttribute('modification_time', filemtime($file));
80
  }
81
  return $imagesNode->asNiceXml();
82
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice.php DELETED
@@ -1,98 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Item price xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Catalog_Product_ItemPrice extends Mage_XmlConnect_Block_Catalog
35
- {
36
- /**
37
- * Default product price renderer block factory name
38
- *
39
- * @var string
40
- */
41
- protected $_defaultPriceRenderer = 'xmlconnect/catalog_product_itemPrice_default';
42
-
43
- /**
44
- * Store supported product price xml renderers based on product types
45
- *
46
- * @var array
47
- */
48
- protected $_renderers = array();
49
-
50
- /**
51
- * Store already initialized renderers instances
52
- *
53
- * @var array
54
- */
55
- protected $_renderersInstances = array();
56
-
57
- /**
58
- * Add new product price renderer
59
- *
60
- * @param string $type
61
- * @param string $renderer
62
- * @return Mage_XmlConnect_Block_Catalog_Product_ItemPrice
63
- */
64
- public function addRenderer($type, $renderer)
65
- {
66
- if (!isset($this->_renderers[$type])) {
67
- $this->_renderers[$type] = $renderer;
68
- }
69
- return $this;
70
- }
71
-
72
- /**
73
- * Collect product prices to current xml object
74
- */
75
- public function collectProductPrices()
76
- {
77
- $product = $this->getProduct();
78
- $xmlObject = $this->getProductXmlObj();
79
-
80
- if ($product && $product->getId()) {
81
- $type = $product->getTypeId();
82
- if (isset($this->_renderers[$type])) {
83
- $blockName = $this->_renderers[$type];
84
- } else {
85
- $blockName = $this->_defaultPriceRenderer;
86
- }
87
-
88
- $renderer = $this->getLayout()->getBlock($blockName);
89
- if (!$renderer) {
90
- $renderer = $this->getLayout()->createBlock($blockName);
91
- }
92
-
93
- if ($renderer) {
94
- $renderer->collectProductPrices($product, $xmlObject);
95
- }
96
- }
97
- }
98
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice/Bundle.php DELETED
@@ -1,426 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Bundle product price xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Catalog_Product_ItemPrice_Bundle extends Mage_Bundle_Block_Catalog_Product_Price
35
- {
36
- /**
37
- * Collect product prices to specified item xml object
38
- *
39
- * @param Mage_Catalog_Model_Product $product
40
- * @param Mage_XmlConnect_Model_Simplexml_Element $item
41
- */
42
- public function collectProductPrices(
43
- Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item
44
- ) {
45
- $this->setProduct($product)->setDisplayMinimalPrice(true)->setUseLinkForAsLowAs(false);
46
-
47
- $priceListXmlObj = $item->addCustomChild('price_list');
48
-
49
- /** @var $coreHelper Mage_Core_Helper_Data */
50
- $coreHelper = $this->helper('core');
51
- /** @var $weeeHelper Mage_Weee_Helper_Data */
52
- $weeeHelper = $this->helper('weee');
53
- /** @var $taxHelper Mage_Tax_Helper_Data */
54
- $taxHelper = $this->helper('tax');
55
-
56
- $tierPrices = $this->_getTierPrices($product);
57
-
58
- if (count($tierPrices) > 0) {
59
- $tierPricesTextArray = array();
60
- foreach ($tierPrices as $price) {
61
- $discount = ' ' . ($price['price'] * 1) . '%';
62
- $tierPricesTextArray[] = $this->__('Buy %1$s with %2$s discount each', $price['price_qty'], $discount);
63
- }
64
- $item->addCustomChild('price_tier', implode(PHP_EOL, $tierPricesTextArray));
65
- }
66
-
67
- list($minimalPrice, $maximalPrice) = $product->getPriceModel()->getPrices($product);
68
-
69
- $weeeTaxAmount = 0;
70
- $minimalPriceTax = $taxHelper->getPrice($product, $minimalPrice);
71
- $minimalPriceInclTax = $taxHelper->getPrice($product, $minimalPrice, true);
72
-
73
- if ($product->getPriceType() == 1) {
74
- $weeeTaxAmount = $weeeHelper->getAmount($product);
75
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
76
- $minimalPriceTax += $weeeTaxAmount;
77
- $minimalPriceInclTax += $weeeTaxAmount;
78
- }
79
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
80
- $minimalPriceInclTax += $weeeTaxAmount;
81
- }
82
-
83
- if ($weeeHelper->typeOfDisplay($product, array(1, 2, 4))) {
84
- $weeeTaxAttributes = $weeeHelper->getProductWeeeAttributesForDisplay($product);
85
- }
86
- }
87
-
88
- if ($product->getPriceView()) {
89
- if ($taxHelper->displayBothPrices()) {
90
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
91
- $pricesXmlObj->addCustomChild('price', $minimalPriceTax, array(
92
- 'id' => 'as_low_as_excluding_tax',
93
- 'label' => $this->__('As Low Excl. Tax'),
94
- 'formatted_value' => $coreHelper->currency($minimalPriceTax, true, false)
95
- ));
96
-
97
- if ($weeeTaxAmount && $product->getPriceType() == 1
98
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
99
- ) {
100
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
101
-
102
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
103
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
104
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
105
- } else {
106
- $amount = $weeeTaxAttribute->getAmount();
107
- }
108
-
109
- $priceWeeeXmlObj->addCustomChild('item', $amount, array(
110
- 'id' => 'weee_tax',
111
- 'label' => $weeeTaxAttribute->getName(),
112
- 'formatted_value' => $coreHelper->currency($amount, true, false)
113
- ));
114
- }
115
- }
116
-
117
- $pricesXmlObj->addCustomChild('price', $minimalPriceInclTax, array(
118
- 'id' => 'as_low_as_including_tax',
119
- 'label' => $this->__('As Low Incl. Tax'),
120
- 'formatted_value' => $coreHelper->currency($minimalPriceInclTax, true, false)
121
- ));
122
- } else {
123
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
124
- $pricesXmlObj->addCustomChild('price', $minimalPriceTax, array(
125
- 'id' => 'as_low_as',
126
- 'label' => $this->__('As Low As'),
127
- 'formatted_value' => $coreHelper->currency($minimalPriceTax, true, false)
128
- ));
129
-
130
- if ($weeeTaxAmount && $product->getPriceType() == 1
131
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
132
- ) {
133
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
134
-
135
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
136
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
137
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
138
- } else {
139
- $amount = $weeeTaxAttribute->getAmount();
140
- }
141
-
142
- $priceWeeeXmlObj->addCustomChild('item', $amount, array(
143
- 'id' => 'weee_tax',
144
- 'label' => $weeeTaxAttribute->getName(),
145
- 'formatted_value' => $coreHelper->currency($amount, true, false)
146
- ));
147
- }
148
- }
149
-
150
- if ($weeeHelper->typeOfDisplay($product, 2) && $weeeTaxAmount) {
151
- $pricesXmlObj->addCustomChild('price', $minimalPriceInclTax, array(
152
- 'id' => 'as_low_as_including_tax',
153
- 'label' => $this->__('As Low Incl. Tax'),
154
- 'formatted_value' => $coreHelper->currency($minimalPriceInclTax, true, false)
155
- ));
156
- }
157
- }
158
- /**
159
- * if ($product->getPriceView()) {
160
- */
161
- } else {
162
- if ($minimalPrice <> $maximalPrice) {
163
- if ($taxHelper->displayBothPrices()) {
164
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
165
- $pricesXmlObj->addCustomChild('price', $minimalPriceTax, array(
166
- 'id' => 'from_excluding_tax',
167
- 'label' => $this->__('From Excl. Tax'),
168
- 'formatted_value' => $coreHelper->currency($minimalPriceTax, true, false)
169
- ));
170
-
171
- if ($weeeTaxAmount && $product->getPriceType() == 1
172
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
173
- ) {
174
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'from_weee'));
175
-
176
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
177
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
178
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
179
- } else {
180
- $amount = $weeeTaxAttribute->getAmount();
181
- }
182
-
183
- $priceWeeeXmlObj->addCustomChild('item', $amount, array(
184
- 'id' => 'weee_tax',
185
- 'label' => $weeeTaxAttribute->getName(),
186
- 'formatted_value' => $coreHelper->currency($amount, true, false)
187
- ));
188
- }
189
- }
190
-
191
- $pricesXmlObj->addCustomChild('price', $minimalPriceInclTax, array(
192
- 'id' => 'from_including_tax',
193
- 'label' => $this->__('From Incl. Tax'),
194
- 'formatted_value' => $coreHelper->currency($minimalPriceInclTax, true, false)
195
- ));
196
- } else {
197
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
198
- $pricesXmlObj->addCustomChild('price', $minimalPriceTax, array(
199
- 'id' => 'from',
200
- 'label' => $this->__('From'),
201
- 'formatted_value' => $coreHelper->currency($minimalPriceTax, true, false)
202
- ));
203
-
204
- if ($weeeTaxAmount && $product->getPriceType() == 1
205
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
206
- ) {
207
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'from_weee'));
208
-
209
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
210
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
211
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
212
- } else {
213
- $amount = $weeeTaxAttribute->getAmount();
214
- }
215
-
216
- $priceWeeeXmlObj->addCustomChild('item', $amount, array(
217
- 'id' => 'weee_tax',
218
- 'label' => $weeeTaxAttribute->getName(),
219
- 'formatted_value' => $coreHelper->currency($amount, true, false)
220
- ));
221
- }
222
- }
223
-
224
- if ($weeeHelper->typeOfDisplay($product, 2) && $weeeTaxAmount) {
225
- $pricesXmlObj->addCustomChild('price', $minimalPriceInclTax, array(
226
- 'id' => 'from_including_tax',
227
- 'label' => $this->__('From Incl. Tax'),
228
- 'formatted_value' => $coreHelper->currency($minimalPriceInclTax, true, false)
229
- ));
230
- }
231
- }
232
-
233
- $maximalPriceTax = Mage::helper('tax')->getPrice($product, $maximalPrice);
234
- $maximalPriceInclTax = Mage::helper('tax')->getPrice($product, $maximalPrice, true);
235
-
236
- if ($product->getPriceType() == 1) {
237
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
238
- $maximalPriceTax += $weeeTaxAmount;
239
- $maximalPriceInclTax += $weeeTaxAmount;
240
- }
241
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
242
- $maximalPriceInclTax += $weeeTaxAmount;
243
- }
244
- }
245
-
246
- if ($taxHelper->displayBothPrices()) {
247
- $pricesXmlObj->addCustomChild('price', $maximalPriceTax, array(
248
- 'id' => 'to_excluding_tax',
249
- 'label' => $this->__('To Excl. Tax'),
250
- 'formatted_value' => $coreHelper->currency($maximalPriceTax, true, false)
251
- ));
252
-
253
- if ($weeeTaxAmount && $product->getPriceType() == 1
254
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
255
- ) {
256
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
257
-
258
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
259
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
260
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
261
- } else {
262
- $amount = $weeeTaxAttribute->getAmount();
263
- }
264
-
265
- $priceWeeeXmlObj->addCustomChild('item', $amount, array(
266
- 'id' => 'weee_tax',
267
- 'label' => $weeeTaxAttribute->getName(),
268
- 'formatted_value' => $coreHelper->currency($amount, true, false)
269
- ));
270
- }
271
- }
272
-
273
- $pricesXmlObj->addCustomChild('price', $maximalPriceInclTax, array(
274
- 'id' => 'to_including_tax',
275
- 'label' => $this->__('To Incl. Tax'),
276
- 'formatted_value' => $coreHelper->currency($maximalPriceInclTax, true, false)
277
- ));
278
- } else {
279
- $pricesXmlObj->addCustomChild('price', $maximalPriceTax, array(
280
- 'id' => 'to',
281
- 'label' => $this->__('To'),
282
- 'formatted_value' => $coreHelper->currency($maximalPriceTax, true, false)
283
- ));
284
-
285
- if ($weeeTaxAmount && $product->getPriceType() == 1
286
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
287
- ) {
288
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'to_weee'));
289
-
290
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
291
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
292
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
293
- } else {
294
- $amount = $weeeTaxAttribute->getAmount();
295
- }
296
-
297
- $priceWeeeXmlObj->addCustomChild('item', $amount, array(
298
- 'id' => 'weee_tax',
299
- 'label' => $weeeTaxAttribute->getName(),
300
- 'formatted_value' => $coreHelper->currency($amount, true, false)
301
- ));
302
- }
303
- }
304
-
305
- if ($weeeHelper->typeOfDisplay($product, 2) && $weeeTaxAmount) {
306
- $pricesXmlObj->addCustomChild('price', $maximalPriceInclTax, array(
307
- 'id' => 'to_including_tax',
308
- 'label' => $this->__('To Incl. Tax'),
309
- 'formatted_value' => $coreHelper->currency($maximalPriceInclTax, true, false)
310
- ));
311
- }
312
- }
313
- /**
314
- * if ($minimalPrice <> $maximalPrice) {
315
- */
316
- } else {
317
- if ($taxHelper->displayBothPrices()) {
318
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
319
- $pricesXmlObj->addCustomChild('price', $minimalPriceTax, array(
320
- 'id' => 'excluding_tax',
321
- 'label' => $this->__('Excl. Tax'),
322
- 'formatted_value' => $coreHelper->currency($minimalPriceTax, true, false)
323
- ));
324
-
325
- if ($weeeTaxAmount && $product->getPriceType() == 1
326
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
327
- ) {
328
- $priceWeeeXmlObj = $item->addCustomChild('price', null, array('id' => 'weee'));
329
-
330
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
331
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
332
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
333
- } else {
334
- $amount = $weeeTaxAttribute->getAmount();
335
- }
336
-
337
- $priceWeeeXmlObj->addCustomChild('item', $amount, array(
338
- 'id' => 'weee_tax',
339
- 'label' => $weeeTaxAttribute->getName(),
340
- 'formatted_value' => $coreHelper->currency($amount, true, false)
341
- ));
342
- }
343
- }
344
-
345
- $pricesXmlObj->addCustomChild('price', $minimalPriceInclTax, array(
346
- 'id' => 'including_tax',
347
- 'label' => $this->__('Incl. Tax'),
348
- 'formatted_value' => $coreHelper->currency($minimalPriceInclTax, true, false)
349
- ));
350
- } else {
351
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
352
- $pricesXmlObj->addCustomChild('price', $minimalPriceTax, array(
353
- 'id' => 'regular',
354
- 'label' => $this->__('Regular'),
355
- 'formatted_value' => $coreHelper->currency($minimalPriceTax, true, false)
356
- ));
357
-
358
- if ($weeeTaxAmount && $product->getPriceType() == 1
359
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
360
- ) {
361
- $priceWeeeXmlObj = $item->addCustomChild('price', null, array('id' => 'weee'));
362
-
363
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
364
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
365
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
366
- } else {
367
- $amount = $weeeTaxAttribute->getAmount();
368
- }
369
-
370
- $priceWeeeXmlObj->addCustomChild('item', $amount, array(
371
- 'id' => 'weee_tax',
372
- 'label' => $weeeTaxAttribute->getName(),
373
- 'formatted_value' => $coreHelper->currency($amount, true, false)
374
- ));
375
- }
376
- }
377
-
378
- if ($weeeHelper->typeOfDisplay($product, 2) && $weeeTaxAmount) {
379
- $pricesXmlObj->addCustomChild('price', $minimalPriceInclTax, array(
380
- 'id' => 'including_tax',
381
- 'label' => $this->__('Incl. Tax'),
382
- 'formatted_value' => $coreHelper->currency($minimalPriceInclTax, true, false)
383
- ));
384
- }
385
- }
386
- }
387
- }
388
- }
389
-
390
- /**
391
- * Get tier prices (formatted)
392
- *
393
- * @param Mage_Catalog_Model_Product $product
394
- * @return array
395
- */
396
- protected function _getTierPrices($product)
397
- {
398
- if (null === $product) {
399
- return array();
400
- }
401
- $prices = $product->getFormatedTierPrice();
402
-
403
- $res = array();
404
- if (is_array($prices)) {
405
- foreach ($prices as $price) {
406
- $price['price_qty'] = $price['price_qty'] * 1;
407
- $price['savePercent'] = ceil(100 - $price['price']);
408
- $price['formated_price'] = Mage::app()->getStore()->formatPrice(
409
- Mage::app()->getStore()->convertPrice(
410
- Mage::helper('tax')->getPrice($product, $price['website_price'])
411
- ),
412
- false
413
- );
414
- $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
415
- Mage::app()->getStore()->convertPrice(
416
- Mage::helper('tax')->getPrice($product, $price['website_price'], true)
417
- ),
418
- false
419
- );
420
- $res[] = $price;
421
- }
422
- }
423
-
424
- return $res;
425
- }
426
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice/Default.php DELETED
@@ -1,740 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Default product price xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Catalog_Product_ItemPrice_Default extends Mage_Catalog_Block_Product_Price
35
- {
36
- /**
37
- * Collect product prices to specified item xml object
38
- *
39
- * @param Mage_Catalog_Model_Product $product
40
- * @param Mage_XmlConnect_Model_Simplexml_Element $item
41
- */
42
- public function collectProductPrices(
43
- Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item
44
- ) {
45
- $this->setProduct($product)->setDisplayMinimalPrice(true)->setUseLinkForAsLowAs(false);
46
-
47
- $priceListXmlObj = $item->addCustomChild('price_list');
48
- $tierPrices = $this->_getTierPrices($product);
49
- if (count($tierPrices) > 0) {
50
- $tierPricesTextArray = $item->escapeXml(implode(
51
- PHP_EOL, $this->_getTierPricesTextArray($tierPrices, $product)
52
- ));
53
- $item->addCustomChild('price_tier', $tierPricesTextArray);
54
- }
55
-
56
- /** @var $coreHelper Mage_Core_Helper_Data */
57
- $coreHelper = $this->helper('core');
58
- /** @var $weeeHelper Mage_Weee_Helper_Data */
59
- $weeeHelper = $this->helper('weee');
60
- /** @var $taxHelper Mage_Tax_Helper_Data */
61
- $taxHelper = $this->helper('tax');
62
-
63
- $simplePricesTax = ($taxHelper->displayPriceIncludingTax() || $taxHelper->displayBothPrices());
64
- $minimalPriceValue = $product->getMinimalPrice();
65
- $minimalPrice = $taxHelper->getPrice($product, $minimalPriceValue, $simplePricesTax);
66
-
67
- if (!$product->isGrouped()) {
68
- $weeeTaxAmount = $weeeHelper->getAmountForDisplay($product);
69
- if ($weeeHelper->typeOfDisplay($product, array(1, 2, 4))) {
70
- $weeeTaxAmount = $weeeHelper->getAmount($product);
71
- $weeeTaxAttributes = $weeeHelper->getProductWeeeAttributesForDisplay($product);
72
- }
73
-
74
- $price = $taxHelper->getPrice($product, $product->getPrice());
75
- $regularPrice = $taxHelper->getPrice($product, $product->getPrice(), $simplePricesTax);
76
- $finalPrice = $taxHelper->getPrice($product, $product->getFinalPrice());
77
- $finalPriceInclTax = $taxHelper->getPrice($product, $product->getFinalPrice(), true);
78
- $weeeHelper->getPriceDisplayType();
79
- if ($finalPrice == $price) {
80
- if ($taxHelper->displayBothPrices()) {
81
- /**
82
- * Including
83
- */
84
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 0)) {
85
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
86
-
87
- $exclTaxValue = $price + $weeeTaxAmount;
88
- $pricesXmlObj->addCustomChild('price', $exclTaxValue, array(
89
- 'id' => 'excluding_tax',
90
- 'label' => $this->__('Excl. Tax'),
91
- 'formatted_value' => $coreHelper->currency($exclTaxValue, true, false)
92
- ));
93
-
94
- $inclTaxValue = $finalPriceInclTax + $weeeTaxAmount;
95
- $pricesXmlObj->addCustomChild('price', $inclTaxValue, array(
96
- 'id' => 'including_tax',
97
- 'label' => $this->__('Incl. Tax'),
98
- 'formatted_value' => $coreHelper->currency($inclTaxValue, true, false)
99
- ));
100
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 1)) {
101
- /**
102
- * Including + Weee
103
- */
104
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
105
-
106
- $exclTaxValue = $price + $weeeTaxAmount;
107
- $pricesXmlObj->addCustomChild('price', $exclTaxValue, array(
108
- 'id' => 'excluding_tax',
109
- 'label' => $this->__('Excl. Tax'),
110
- 'formatted_value' => $coreHelper->currency($exclTaxValue, true, false)
111
- ));
112
-
113
-
114
- $inclTaxValue = $finalPriceInclTax + $weeeTaxAmount;
115
- $pricesXmlObj->addCustomChild('price', $inclTaxValue, array(
116
- 'id' => 'including_tax',
117
- 'label' => $this->__('Incl. Tax'),
118
- 'formatted_value' => $coreHelper->currency($inclTaxValue, true, false)
119
- ));
120
-
121
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
122
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
123
- $priceWeeeXmlObj->addCustomChild('item', $weeeTaxAttribute->getAmount() * 1, array(
124
- 'id' => 'weee_tax',
125
- 'label' => $weeeTaxAttribute->getName(),
126
- 'formatted_value' => $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
127
- ));
128
- }
129
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 4)) {
130
- /**
131
- * Including + Weee
132
- */
133
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
134
-
135
- $exclTaxValue = $price + $weeeTaxAmount;
136
- $pricesXmlObj->addCustomChild('price', $exclTaxValue, array(
137
- 'id' => 'excluding_tax',
138
- 'label' => $this->__('Excl. Tax'),
139
- 'formatted_value' => $coreHelper->currency($exclTaxValue, true, false)
140
- ));
141
-
142
- $inclTaxValue = $finalPriceInclTax + $weeeTaxAmount;
143
- $pricesXmlObj->addCustomChild('price', $inclTaxValue, array(
144
- 'id' => 'including_tax',
145
- 'label' => $this->__('Incl. Tax'),
146
- 'formatted_value' => $coreHelper->currency($inclTaxValue, true, false)
147
- ));
148
-
149
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
150
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
151
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
152
- $priceWeeeXmlObj->addCustomChild('item', $amount * 1, array(
153
- 'id' => 'weee_tax',
154
- 'label' => $weeeTaxAttribute->getName(),
155
- 'formatted_value' => $coreHelper->currency($amount, true, false)
156
- ));
157
- }
158
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
159
- /**
160
- * Excluding + Weee + Final
161
- */
162
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
163
-
164
- $pricesXmlObj->addCustomChild('price', $price, array(
165
- 'id' => 'excluding_tax',
166
- 'label' => $this->__('Excl. Tax'),
167
- 'formatted_value' => $coreHelper->currency($price, true, false)
168
- ));
169
-
170
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
171
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
172
- $priceWeeeXmlObj->addCustomChild('item', $weeeTaxAttribute->getAmount() * 1, array(
173
- 'id' => 'weee_tax',
174
- 'label' => $weeeTaxAttribute->getName(),
175
- 'formatted_value' => $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
176
- ));
177
- }
178
-
179
- $inclTaxValue = $finalPriceInclTax + $weeeTaxAmount;
180
- $pricesXmlObj->addCustomChild('price', $inclTaxValue, array(
181
- 'id' => 'including_tax',
182
- 'label' => $this->__('Incl. Tax'),
183
- 'formatted_value' => $coreHelper->currency($inclTaxValue, true, false)
184
- ));
185
- } else {
186
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
187
- $pricesXmlObj->addCustomChild('price', $price, array(
188
- 'id' => 'excluding_tax',
189
- 'label' => $this->__('Excl. Tax'),
190
- 'formatted_value' => $coreHelper->currency($price, true, false)
191
- ));
192
-
193
- $pricesXmlObj->addCustomChild('price', $finalPriceInclTax, array(
194
- 'id' => 'including_tax',
195
- 'label' => $this->__('Incl. Tax'),
196
- 'formatted_value' => $coreHelper->currency($finalPriceInclTax, true, false)
197
- ));
198
- }
199
- /**
200
- * if ($taxHelper->displayBothPrices()) {
201
- */
202
- } else {
203
- /**
204
- * Including
205
- */
206
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 0)) {
207
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
208
- $pricesXmlObj->addCustomChild('price', $price + $weeeTaxAmount, array(
209
- 'id' => 'regular',
210
- 'label' => $this->__('Unit Price'),
211
- 'formatted_value' => $coreHelper->currency($price + $weeeTaxAmount, true, false)
212
- ));
213
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 1)) {
214
- /**
215
- * Including + Weee
216
- */
217
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
218
- $pricesXmlObj->addCustomChild('price', $price + $weeeTaxAmount, array(
219
- 'id' => 'regular',
220
- 'label' => $this->__('Unit Price'),
221
- 'formatted_value' => $coreHelper->currency($price + $weeeTaxAmount, true, false)
222
- ));
223
-
224
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
225
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
226
- $priceWeeeXmlObj->addCustomChild('item', $weeeTaxAttribute->getAmount() * 1, array(
227
- 'id' => 'weee_tax',
228
- 'label' => $weeeTaxAttribute->getName(),
229
- 'formatted_value' => $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
230
- ));
231
- }
232
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 4)) {
233
- /**
234
- * Including + Weee
235
- */
236
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
237
- $pricesXmlObj->addCustomChild('price', $price + $weeeTaxAmount, array(
238
- 'id' => 'regular',
239
- 'label' => $this->__('Unit Price'),
240
- 'formatted_value' => $coreHelper->currency($price + $weeeTaxAmount, true, false)
241
- ));
242
-
243
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
244
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
245
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
246
- $priceWeeeXmlObj->addCustomChild('item', $amount * 1, array(
247
- 'id' => 'weee_tax',
248
- 'label' => $weeeTaxAttribute->getName(),
249
- 'formatted_value' => $coreHelper->currency($amount, true, false)
250
- ));
251
- }
252
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
253
- /**
254
- * Excluding + Weee + Final
255
- */
256
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
257
- $pricesXmlObj->addCustomChild('price', $price, array(
258
- 'id' => 'regular',
259
- 'label' => $this->__('Unit Price'),
260
- 'formatted_value' => $coreHelper->currency($price, true, false)
261
- ));
262
-
263
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
264
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
265
- $priceWeeeXmlObj->addCustomChild('item', $weeeTaxAttribute->getAmount() * 1, array(
266
- 'id' => 'weee_tax',
267
- 'label' => $weeeTaxAttribute->getName(),
268
- 'formatted_value' => $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
269
- ));
270
- }
271
-
272
- $pricesXmlObj->addCustomChild('price', $price + $weeeTaxAmount, array(
273
- 'id' => 'including_tax',
274
- 'label' => $this->__('Incl. Tax'),
275
- 'formatted_value' => $coreHelper->currency($price + $weeeTaxAmount, true, false)
276
- ));
277
- } else {
278
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
279
- $pricesXmlObj->addCustomChild('price', $price, array(
280
- 'id' => 'regular',
281
- 'label' => $this->__('Unit Price'),
282
- 'formatted_value' => $coreHelper->currency($price, true, false)
283
- ));
284
- }
285
- }
286
- /**
287
- * if ($finalPrice == $price) {
288
- */
289
- } else {
290
- $originalWeeeTaxAmount = $weeeHelper->getOriginalAmount($product);
291
- /**
292
- * Including
293
- */
294
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 0)) {
295
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
296
-
297
- $unitPrice = $regularPrice + $originalWeeeTaxAmount;
298
- $pricesXmlObj->addCustomChild('price', $unitPrice, array(
299
- 'id' => 'regular',
300
- 'label' => $this->__('Unit Price'),
301
- 'formatted_value' => $coreHelper->currency($unitPrice, true, false)
302
- ));
303
- if ($taxHelper->displayBothPrices()) {
304
- $pricesXmlObj->addCustomChild('price', $finalPrice + $weeeTaxAmount, array(
305
- 'id' => 'special_excluding_tax',
306
- 'label' => $this->__('Special Excl. Tax'),
307
- 'formatted_value' => $coreHelper->currency($finalPrice + $weeeTaxAmount, true, false)
308
- ));
309
-
310
- $specialIncludingTax = $finalPriceInclTax + $weeeTaxAmount;
311
- $pricesXmlObj->addCustomChild('price', $specialIncludingTax, array(
312
- 'id' => 'special_including_tax',
313
- 'label' => $this->__('Special Incl. Tax'),
314
- 'formatted_value' => $coreHelper->currency($specialIncludingTax, true, false)
315
- ));
316
- } else {
317
- $pricesXmlObj->addCustomChild('price', $finalPrice + $weeeTaxAmount, array(
318
- 'id' => 'special',
319
- 'label' => $this->__('Special'),
320
- 'formatted_value' => $coreHelper->currency($finalPrice + $weeeTaxAmount, true, false)
321
- ));
322
- }
323
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 1)) {
324
- /**
325
- * Including + Weee
326
- */
327
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
328
-
329
- $unitPrice = $regularPrice + $originalWeeeTaxAmount;
330
- $pricesXmlObj->addCustomChild('price', $unitPrice, array(
331
- 'id' => 'regular',
332
- 'label' => $this->__('Unit Price'),
333
- 'formatted_value' => $coreHelper->currency($unitPrice, true, false)
334
- ));
335
-
336
- $pricesXmlObj->addCustomChild('price', $finalPrice + $weeeTaxAmount, array(
337
- 'id' => 'special_excluding_tax',
338
- 'label' => $this->__('Special Excl. Tax'),
339
- 'formatted_value' => $coreHelper->currency($finalPrice + $weeeTaxAmount, true, false)
340
- ));
341
-
342
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('prices', null, array('id' => 'weee'));
343
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
344
- $priceWeeeXmlObj->addCustomChild('item', $weeeTaxAttribute->getAmount() * 1, array(
345
- 'id' => 'weee_tax',
346
- 'label' => $weeeTaxAttribute->getName(),
347
- 'formatted_value' => $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
348
- ));
349
- }
350
-
351
- $pricesXmlObj->addCustomChild('price', $finalPriceInclTax + $weeeTaxAmount, array(
352
- 'id' => 'special_including_tax',
353
- 'label' => $this->__('Special Incl. Tax'),
354
- 'formatted_value' => $coreHelper->currency($finalPriceInclTax + $weeeTaxAmount, true, false)
355
- ));
356
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 4)) {
357
- /**
358
- * Including + Weee
359
- */
360
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
361
-
362
- $unitPrice = $regularPrice + $originalWeeeTaxAmount;
363
- $pricesXmlObj->addCustomChild('price', $unitPrice, array(
364
- 'id' => 'regular',
365
- 'label' => $this->__('Unit Price'),
366
- 'formatted_value' => $coreHelper->currency($unitPrice, true, false)
367
- ));
368
-
369
- $pricesXmlObj->addCustomChild('price', $finalPrice + $weeeTaxAmount, array(
370
- 'id' => 'special_excluding_tax',
371
- 'label' => $this->__('Special Excl. Tax'),
372
- 'formatted_value' => $coreHelper->currency($finalPrice + $weeeTaxAmount, true, false)
373
- ));
374
-
375
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
376
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
377
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
378
- $priceWeeeXmlObj->addCustomChild('item', $amount * 1, array(
379
- 'id' => 'weee_tax',
380
- 'label' => $weeeTaxAttribute->getName(),
381
- 'formatted_value' => $coreHelper->currency($amount, true, false)
382
- ));
383
- }
384
-
385
- $pricesXmlObj->addCustomChild('price', $finalPriceInclTax + $weeeTaxAmount, array(
386
- 'id' => 'special_including_tax',
387
- 'label' => $this->__('Special Incl. Tax'),
388
- 'formatted_value' => $coreHelper->currency($finalPriceInclTax + $weeeTaxAmount, true, false)
389
- ));
390
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
391
- /**
392
- * Excluding + Weee + Final
393
- */
394
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
395
- $pricesXmlObj->addCustomChild('price', $regularPrice, array(
396
- 'id' => 'regular',
397
- 'label' => $this->__('Unit Price'),
398
- 'formatted_value' => $coreHelper->currency($regularPrice, true, false)
399
- ));
400
-
401
- $pricesXmlObj->addCustomChild('price', $finalPrice, array(
402
- 'id' => 'special_excluding_tax',
403
- 'label' => $this->__('Special Excl. Tax'),
404
- 'formatted_value' => $coreHelper->currency($finalPrice, true, false)
405
- ));
406
-
407
- $priceWeeeXmlObj = $pricesXmlObj->addCustomChild('price', null, array('id' => 'weee'));
408
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
409
- $priceWeeeXmlObj->addCustomChild('item', $weeeTaxAttribute->getAmount() * 1, array(
410
- 'id' => 'weee_tax',
411
- 'label' => $weeeTaxAttribute->getName(),
412
- 'formatted_value' => $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
413
- ));
414
- }
415
-
416
- $pricesXmlObj->addCustomChild('price', $finalPriceInclTax + $weeeTaxAmount, array(
417
- 'id' => 'special_including_tax',
418
- 'label' => $this->__('Special Incl. Tax'),
419
- 'formatted_value' => $coreHelper->currency($finalPriceInclTax + $weeeTaxAmount, true, false)
420
- ));
421
- } else {
422
- /**
423
- * Excluding
424
- */
425
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
426
- $pricesXmlObj->addCustomChild('price', $regularPrice, array(
427
- 'id' => 'regular',
428
- 'label' => $this->__('Unit Price'),
429
- 'formatted_value' => $coreHelper->currency($regularPrice, true, false)
430
- ));
431
-
432
- if ($taxHelper->displayBothPrices()) {
433
- $pricesXmlObj->addCustomChild('price', $finalPrice, array(
434
- 'id' => 'special_excluding_tax',
435
- 'label' => $this->__('Special Excl. Tax'),
436
- 'formatted_value' => $coreHelper->currency($finalPrice, true, false)
437
- ));
438
-
439
- $pricesXmlObj->addCustomChild('price', $finalPriceInclTax, array(
440
- 'id' => 'special_including_tax',
441
- 'label' => $this->__('Special Incl. Tax'),
442
- 'formatted_value' => $coreHelper->currency($finalPriceInclTax, true, false)
443
- ));
444
- } else {
445
- $pricesXmlObj->addCustomChild('price', $finalPrice, array(
446
- 'id' => 'special',
447
- 'label' => $this->__('Special'),
448
- 'formatted_value' => $coreHelper->currency($finalPrice, true, false)
449
- ));
450
- }
451
- }
452
- }
453
-
454
- if ($this->getDisplayMinimalPrice() && $minimalPriceValue
455
- && $minimalPriceValue < $product->getFinalPrice()
456
- ) {
457
- $minimalPriceDisplayValue = $minimalPrice;
458
-
459
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
460
- $minimalPriceDisplayValue = $minimalPrice + $weeeTaxAmount;
461
- }
462
-
463
- if (!$this->getUseLinkForAsLowAs()) {
464
- $pricesXmlObj->addCustomChild('price', $minimalPriceDisplayValue, array(
465
- 'id' => 'as_low_as',
466
- 'label' => $this->__('As Low As'),
467
- 'formatted_value' => $coreHelper->currency($minimalPriceDisplayValue, true, false)
468
- ));
469
- }
470
- }
471
- /**
472
- * if (!$product->isGrouped()) {
473
- */
474
- } else {
475
- $exclTax = $taxHelper->getPrice($product, $minimalPriceValue, null);
476
- $inclTax = $taxHelper->getPrice($product, $minimalPriceValue, true);
477
-
478
- if ($this->getDisplayMinimalPrice() && $minimalPriceValue) {
479
- if ($taxHelper->displayBothPrices()) {
480
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
481
- $pricesXmlObj->addCustomChild('price', $exclTax, array(
482
- 'id' => 'starting_at_excluding_tax',
483
- 'label' => $this->__('Starting At Excl. Tax'),
484
- 'formatted_value' => $coreHelper->currency($exclTax, true, false)
485
- ));
486
-
487
- $pricesXmlObj->addCustomChild('price', $inclTax, array(
488
- 'id' => 'starting_at_including_tax',
489
- 'label' => $this->__('Starting At Incl. Tax'),
490
- 'formatted_value' => $coreHelper->currency($inclTax, true, false)
491
- ));
492
- } else {
493
- $showPrice = $inclTax;
494
- if (!$taxHelper->displayPriceIncludingTax()) {
495
- $showPrice = $exclTax;
496
- }
497
-
498
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
499
- $pricesXmlObj->addCustomChild('price', $showPrice, array(
500
- 'id' => 'starting_at',
501
- 'label' => $this->__('Starting At'),
502
- 'formatted_value' => $coreHelper->currency($showPrice, true, false)
503
- ));
504
- }
505
- }
506
- }
507
- }
508
-
509
- /**
510
- * Get tier prices (formatted)
511
- *
512
- * @param Mage_Catalog_Model_Product $product
513
- * @return array
514
- */
515
- protected function _getTierPrices(Mage_Catalog_Model_Product $product)
516
- {
517
- if (null === $product) {
518
- return array();
519
- }
520
- $prices = $product->getFormatedTierPrice();
521
-
522
- $res = array();
523
- if (is_array($prices)) {
524
- foreach ($prices as $price) {
525
- $price['price_qty'] = $price['price_qty']*1;
526
- if ($product->getPrice() != $product->getFinalPrice()) {
527
- if ($price['price'] < $product->getFinalPrice()) {
528
- $price['savePercent'] = ceil(100 - ((100 / $product->getFinalPrice()) * $price['price']));
529
- $price['formated_price'] = Mage::app()->getStore()->formatPrice(
530
- Mage::app()->getStore()->convertPrice(
531
- Mage::helper('tax')->getPrice($product, $price['website_price'])
532
- ),
533
- false
534
- );
535
- $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
536
- Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice(
537
- $product, $price['website_price'], true
538
- )),
539
- false
540
- );
541
- $res[] = $price;
542
- }
543
- } else {
544
- if ($price['price'] < $product->getPrice()) {
545
- $price['savePercent'] = ceil(100 - ((100 / $product->getPrice()) * $price['price']));
546
- $price['formated_price'] = Mage::app()->getStore()->formatPrice(
547
- Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice(
548
- $product, $price['website_price']
549
- )),
550
- false
551
- );
552
- $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
553
- Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice(
554
- $product, $price['website_price'], true
555
- )),
556
- false
557
- );
558
- $res[] = $price;
559
- }
560
- }
561
- }
562
- }
563
-
564
- return $res;
565
- }
566
-
567
- /**
568
- * Get tier prices (formatted) as array of strings
569
- *
570
- * @param array $tierPrices
571
- * @param Mage_Catalog_Model_Product $product
572
- * @return array
573
- */
574
- protected function _getTierPricesTextArray($tierPrices, $product)
575
- {
576
-
577
- $pricesArray = array();
578
- if (Mage::helper('weee')->typeOfDisplay($product, array(1, 2, 4))) {
579
- $weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($product);
580
- }
581
-
582
- if ($product->isGrouped()) {
583
- $tierPrices = $this->getTierPrices($product);
584
- }
585
- Mage::helper('weee')->processTierPrices($product, $tierPrices);
586
-
587
- foreach ($tierPrices as $price) {
588
- $s = '';
589
- if ($this->helper('tax')->displayBothPrices()) {
590
- if (Mage::helper('weee')->typeOfDisplay($product, 0)) {
591
- $s .= $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $price['price_qty'], $price['formated_price_incl_weee_only'], $price['formated_price_incl_weee']);
592
- } else if (Mage::helper('weee')->typeOfDisplay($product, 1)) {
593
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee_only']);
594
- if ($weeeTaxAttributes) {
595
- $s .= ' (' . $this->__('%1$s incl tax.', $price['formated_price_incl_weee']);
596
- $separator = ' + ';
597
- foreach ($weeeTaxAttributes as $attribute) {
598
- $s .= $separator . $attribute->getName() . ': ';
599
- $s .= Mage::helper('core')->currency($attribute->getAmount());
600
- }
601
- $s .= ')';
602
- }
603
- $s .= ' ' . $this->__('each');
604
- } else if (Mage::helper('weee')->typeOfDisplay($product, 4)) {
605
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee_only']);
606
- if ($weeeTaxAttributes) {
607
- $s .= ' (' . $this->__('%1$s incl tax.', $price['formated_price_incl_weee']);
608
- $separator = ' + ';
609
- foreach ($weeeTaxAttributes as $attribute) {
610
- $s .= $separator . $attribute->getName() . ': ';
611
- $s .= Mage::helper('core')->currency(
612
- $attribute->getAmount() + $attribute->getTaxAmount()
613
- );
614
- }
615
- $s .= ')';
616
- }
617
- $s .= ' ' . $this->__('each');
618
- } else if (Mage::helper('weee')->typeOfDisplay($product, 2)) {
619
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price']);
620
- if ($weeeTaxAttributes) {
621
- $s .= ' (';
622
- foreach ($weeeTaxAttributes as $attribute) {
623
- $s .= $attribute->getName() . ': ';
624
- $s .= Mage::helper('core')->currency($attribute->getAmount());
625
- }
626
- $s .= ' ' . $this->__('Total incl. Tax: %1$s', $price['formated_price_incl_weee']) . ')';
627
- }
628
- $s .= ' ' . $this->__('each');
629
- } else {
630
- $s .= $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $price['price_qty'], $price['formated_price'], $price['formated_price_incl_tax']);
631
- }
632
- } else {
633
- if ($this->helper('tax')->displayPriceIncludingTax()) {
634
- if (Mage::helper('weee')->typeOfDisplay($product, 0)) {
635
- $s .= $this->__('Buy %1$s for %2$s each', $price['price_qty'], $price['formated_price_incl_weee']);
636
- } else if (Mage::helper('weee')->typeOfDisplay($product, 1)) {
637
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee']);
638
- if ($weeeTaxAttributes) {
639
- $s .= ' (';
640
- $separator = '';
641
- foreach ($weeeTaxAttributes as $attribute) {
642
- $s .= $separator . $attribute->getName() . ': ';
643
- $s .= Mage::helper('core')->currency($attribute->getAmount());
644
- $separator = ' + ';
645
- }
646
- $s .= ')';
647
- }
648
- $s .= ' ' . $this->__('each');
649
- } else if (Mage::helper('weee')->typeOfDisplay($product, 4)) {
650
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee']);
651
- if ($weeeTaxAttributes) {
652
- $s .= ' (';
653
- $separator = '';
654
- foreach ($weeeTaxAttributes as $attribute) {
655
- $s .= $separator . $attribute->getName() . ': ';
656
- $s .= Mage::helper('core')->currency(
657
- $attribute->getAmount() + $attribute->getTaxAmount()
658
- );
659
- $separator = ' + ';
660
- }
661
- $s .= ')';
662
- }
663
- $s .= ' ' . $this->__('each');
664
- } else if (Mage::helper('weee')->typeOfDisplay($product, 2)) {
665
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_tax']);
666
- if ($weeeTaxAttributes) {
667
- $s .= ' (';
668
- foreach ($weeeTaxAttributes as $attribute) {
669
- $s .= $attribute->getName() . ': ';
670
- $s .= Mage::helper('core')->currency($attribute->getAmount());
671
- }
672
- $s .= ' ' . $this->__('Total incl. Tax: %1$s', $price['formated_price_incl_weee']) . ')';
673
- }
674
- $s .= ' ' . $this->__('each');
675
- } else {
676
- $s .= $this->__('Buy %1$s for %2$s each', $price['price_qty'], $price['formated_price_incl_tax']);
677
- }
678
- } else {
679
- if (Mage::helper('weee')->typeOfDisplay($product, 0)) {
680
- $s .= $this->__('Buy %1$s for %2$s each', $price['price_qty'], $price['formated_price_incl_weee_only']);
681
- } else if (Mage::helper('weee')->typeOfDisplay($product, 1)) {
682
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee_only']);
683
- if ($weeeTaxAttributes) {
684
- $s .= ' (';
685
- $separator = '';
686
- foreach ($weeeTaxAttributes as $attribute) {
687
- $s .= $separator . $attribute->getName() . ': ';
688
- $s .= Mage::helper('core')->currency($attribute->getAmount());
689
- $separator = ' + ';
690
- }
691
- $s .= ')';
692
- }
693
- $s .= ' ' . $this->__('each');
694
- } else if (Mage::helper('weee')->typeOfDisplay($product, 4)) {
695
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee_only']);
696
- if ($weeeTaxAttributes) {
697
- $s .= ' (';
698
- $separator = '';
699
- foreach ($weeeTaxAttributes as $attribute) {
700
- $s .= $separator . $attribute->getName() . ': ';
701
- $s .= Mage::helper('core')->currency(
702
- $attribute->getAmount() + $attribute->getTaxAmount()
703
- );
704
- $separator = ' + ';
705
- }
706
- $s .= ')';
707
- }
708
- $s .= ' ' . $this->__('each');
709
- } else if (Mage::helper('weee')->typeOfDisplay($product, 2)) {
710
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price']);
711
- if ($weeeTaxAttributes) {
712
- $s .= ' (';
713
- foreach ($weeeTaxAttributes as $attribute) {
714
- $s .= $attribute->getName() . ': ';
715
- $s .= Mage::helper('core')->currency($attribute->getAmount());
716
- }
717
- $s .= ' ' . $this->__('Total incl. Tax: %1$s', $price['formated_price_incl_weee_only']) . ')';
718
- }
719
- $s .= ' ' . $this->__('each');
720
- } else {
721
- $s .= $this->__('Buy %1$s for %2$s each', $price['price_qty'], $price['formated_price']);
722
- }
723
- }
724
- }
725
- if (!$product->isGrouped()) {
726
- $condition1 = ($product->getPrice() == $product->getFinalPrice()
727
- && $product->getPrice() > $price['price']);
728
-
729
- $condition2 = ($product->getPrice() != $product->getFinalPrice()
730
- && $product->getFinalPrice() > $price['price']);
731
-
732
- if ($condition1 || $condition2) {
733
- $s .= ' ' . $this->__('and') . ' ' . $this->__('save') . ' ' . $price['savePercent'] . '%';
734
- }
735
- }
736
- $pricesArray[] = $s;
737
- }
738
- return $pricesArray;
739
- }
740
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice/Giftcard.php DELETED
@@ -1,98 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Gift card product price xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Catalog_Product_ItemPrice_Giftcard extends Mage_Bundle_Block_Catalog_Product_Price
35
- {
36
- /**
37
- * Return minimal amount for Gift card product using price model
38
- *
39
- * @param Mage_Catalog_Model_Product $product
40
- * @return float
41
- */
42
- public function getMinAmount($product = null)
43
- {
44
- if (is_null($product)) {
45
- $product = $this->getProduct();
46
- }
47
- return $product->getPriceModel()->getMinAmount($product);
48
- }
49
-
50
- /**
51
- * Return maximal amount for Gift card product using price model
52
- *
53
- * @param Mage_Catalog_Model_Product $product
54
- * @return float
55
- */
56
- public function getMaxAmount($product = null)
57
- {
58
- if (is_null($product)) {
59
- $product = $this->getProduct();
60
- }
61
- return $product->getPriceModel()->getMaxAmount($product);
62
- }
63
-
64
- /**
65
- * Collect product prices to specified item xml object
66
- *
67
- * @param Mage_Catalog_Model_Product $product
68
- * @param Mage_XmlConnect_Model_Simplexml_Element $item
69
- * @return null
70
- */
71
- public function collectProductPrices(Mage_Catalog_Model_Product $product,
72
- Mage_XmlConnect_Model_Simplexml_Element $item)
73
- {
74
- $this->setProduct($product);
75
-
76
- if ($product->getCanShowPrice() !== false) {
77
- $priceListXmlObj = $item->addCustomChild('price_list');
78
-
79
- $min = $this->getMinAmount();
80
- $max = $this->getMaxAmount();
81
- if ($min && $max && $min == $max) {
82
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
83
- $pricesXmlObj->addCustomChild('price', $min, array(
84
- 'id' => 'regular',
85
- 'label' => $this->__('Regular'),
86
- 'formatted_value' => Mage::helper('core')->currency($min, true, false)
87
- ));
88
- } elseif ($min && $min != 0) {
89
- $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
90
- $pricesXmlObj->addCustomChild('price', $min, array(
91
- 'id' => 'regular',
92
- 'label' => $this->__('From'),
93
- 'formatted_value' => Mage::helper('core')->currency($min, true, false)
94
- ));
95
- }
96
- }
97
- }
98
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Catalog/Product/List.php CHANGED
@@ -41,7 +41,7 @@ class Mage_XmlConnect_Block_Catalog_Product_List extends Mage_XmlConnect_Block_C
41
  protected $_productCollection = null;
42
 
43
  /**
44
- * Store collected layered navigation filters while applying them
45
  *
46
  * @var array
47
  */
@@ -110,7 +110,7 @@ class Mage_XmlConnect_Block_Catalog_Product_List extends Mage_XmlConnect_Block_C
110
 
111
  $filterModel->setLayer($layer)->setAttributeModel($attributeItem);
112
 
113
- $filterParam = parent::REQUEST_FILTER_PARAM_PREFIX . $attributeCode;
114
  /**
115
  * Set new request var
116
  */
@@ -125,7 +125,7 @@ class Mage_XmlConnect_Block_Catalog_Product_List extends Mage_XmlConnect_Block_C
125
  * Separately apply and save category filter
126
  */
127
  list($categoryFilter, $categoryFilterBlock) = $this->helper('xmlconnect')->getFilterByKey('category');
128
- $filterParam = parent::REQUEST_FILTER_PARAM_PREFIX . $categoryFilter->getRequestVar();
129
  $categoryFilter->setLayer($layer)->setRequestVar($filterParam)
130
  ->apply($this->getRequest(), $categoryFilterBlock);
131
  $filters[] = $categoryFilter;
@@ -172,26 +172,18 @@ class Mage_XmlConnect_Block_Catalog_Product_List extends Mage_XmlConnect_Block_C
172
  /**
173
  * Apply sort params
174
  */
175
- $request = $this->getRequest();
176
- $isOrderValueExist = false;
177
- foreach ($request->getParams() as $key => $value) {
178
- if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_PREFIX)) {
179
- $key = str_replace(parent::REQUEST_SORT_ORDER_PARAM_PREFIX, '', $key);
180
  if ($value != 'desc') {
181
  $value = 'asc';
182
  }
183
- if ($key == 'relevance') {
184
- $collection->getSelect()->order("relevance {$value}");
185
- } else {
186
- $collection->addAttributeToSort($key, $value);
187
- }
188
- $isOrderValueExist = true;
189
  }
190
  }
191
- if (!$isOrderValueExist && ($collection instanceof Mage_CatalogSearch_Model_Resource_Fulltext_Collection)) {
192
- $collection->getSelect()->order("relevance desc");
193
- }
194
  $collection->addAttributeToSelect(array('image', 'name', 'description'));
 
195
  return $this;
196
  }
197
 
41
  protected $_productCollection = null;
42
 
43
  /**
44
+ * Store collected layered navigation filters whike applying them
45
  *
46
  * @var array
47
  */
110
 
111
  $filterModel->setLayer($layer)->setAttributeModel($attributeItem);
112
 
113
+ $filterParam = parent::REQUEST_FILTER_PARAM_REFIX . $attributeCode;
114
  /**
115
  * Set new request var
116
  */
125
  * Separately apply and save category filter
126
  */
127
  list($categoryFilter, $categoryFilterBlock) = $this->helper('xmlconnect')->getFilterByKey('category');
128
+ $filterParam = parent::REQUEST_FILTER_PARAM_REFIX . $categoryFilter->getRequestVar();
129
  $categoryFilter->setLayer($layer)->setRequestVar($filterParam)
130
  ->apply($this->getRequest(), $categoryFilterBlock);
131
  $filters[] = $categoryFilter;
172
  /**
173
  * Apply sort params
174
  */
175
+ $reguest = $this->getRequest();
176
+ foreach ($reguest->getParams() as $key => $value) {
177
+ if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_REFIX)) {
178
+ $key = str_replace(parent::REQUEST_SORT_ORDER_PARAM_REFIX, '', $key);
 
179
  if ($value != 'desc') {
180
  $value = 'asc';
181
  }
182
+ $collection->addAttributeToSort($key, $value);
 
 
 
 
 
183
  }
184
  }
 
 
 
185
  $collection->addAttributeToSelect(array('image', 'name', 'description'));
186
+
187
  return $this;
188
  }
189
 
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options.php CHANGED
@@ -33,13 +33,9 @@
33
  */
34
  class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Block_Catalog
35
  {
36
- /**#@+
37
- * Option input type
38
- */
39
  const OPTION_TYPE_SELECT = 'select';
40
  const OPTION_TYPE_CHECKBOX = 'checkbox';
41
  const OPTION_TYPE_TEXT = 'text';
42
- /**#@-*/
43
 
44
  /**
45
  * Store supported product options xml renderers based on product types
@@ -74,11 +70,6 @@ class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Bloc
74
  $xmlModel = Mage::getModel('xmlconnect/simplexml_element', '<product></product>');
75
  $optionsNode = $xmlModel->addChild('options');
76
 
77
- if ($product->hasPreconfiguredValues()) {
78
- $preConfiguredValues = $product->getPreconfiguredValues();
79
- $optionData = $preConfiguredValues->getData('options');
80
- }
81
-
82
  if (!$product->getId()) {
83
  return $xmlModel;
84
  }
@@ -110,12 +101,10 @@ class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Bloc
110
  $formattedPrice = Mage::app()->getStore($product->getStoreId())->formatPrice($price, false);
111
  $optionNode->addAttribute('formated_price', $formattedPrice);
112
  }
113
- $optionId = $option->getOptionId();
114
  if ($type == self::OPTION_TYPE_CHECKBOX || $type == self::OPTION_TYPE_SELECT) {
115
  foreach ($option->getValues() as $value) {
116
- $code = $value->getId();
117
  $valueNode = $optionNode->addChild('value');
118
- $valueNode->addAttribute('code', $code);
119
  $valueNode->addAttribute('label', $xmlModel->escapeXml($value->getTitle()));
120
 
121
  if ($value->getPrice() != 0) {
@@ -124,15 +113,6 @@ class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Bloc
124
  $formattedPrice = $this->_formatPriceString($price, $product);
125
  $valueNode->addAttribute('formated_price', $formattedPrice);
126
  }
127
- if ($product->hasPreconfiguredValues()) {
128
- $this->_setCartSelectedValue($valueNode, $type, $this->_getPreconfiguredOption(
129
- $optionData, $optionId, $code
130
- ));
131
- }
132
- }
133
- } else {
134
- if ($product->hasPreconfiguredValues() && array_key_exists($option->getOptionId(), $optionData)) {
135
- $this->_setCartSelectedValue($optionNode, $type, $optionData[$optionId]);
136
  }
137
  }
138
  }
@@ -223,7 +203,6 @@ class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Bloc
223
  }
224
 
225
  if ($product->getId()) {
226
- Mage::register('product', $product);
227
  $type = $product->getTypeId();
228
  if (isset($this->_renderers[$type])) {
229
  $renderer = $this->getLayout()->createBlock($this->_renderers[$type]);
@@ -234,66 +213,4 @@ class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Bloc
234
  }
235
  return '<?xml version="1.0" encoding="UTF-8"?><options/>';
236
  }
237
-
238
- /**
239
- * Retrieve option type name by specified option real type name
240
- *
241
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlItem
242
- * @param string $type
243
- * @param int|null $value
244
- * @return Mage_XmlConnect_Block_Catalog_Product_Options
245
- */
246
- protected function _setCartSelectedValue($xmlItem, $type, $value = null)
247
- {
248
- if (empty($value)) {
249
- return $this;
250
- }
251
-
252
- switch ($type) {
253
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN:
254
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO:
255
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE:
256
- case Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT:
257
- $xmlItem->addAttribute('selected', 1);
258
- break;
259
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX:
260
- $xmlItem->addAttribute('value', 1);
261
- break;
262
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_FIELD:
263
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_AREA:
264
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_FILE:
265
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE:
266
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_TIME:
267
- case Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME:
268
- default:
269
- $xmlItem->addAttribute('value', $value);
270
- break;
271
- }
272
- return $this;
273
- }
274
-
275
- /**
276
- * Get preConfigured option value
277
- *
278
- * @param array $optionsData
279
- * @param int $optionId
280
- * @param int $valueId
281
- * @return int|null
282
- */
283
- protected function _getPreconfiguredOption($optionsData, $optionId, $valueId)
284
- {
285
- $optionValue = $optionsData[$optionId];
286
- if (is_array($optionValue)) {
287
- if (in_array($valueId, $optionValue)) {
288
- return $valueId;
289
- }
290
- }
291
- if ($valueId == $optionValue) {
292
- return $valueId;
293
- }
294
-
295
- return null;
296
- }
297
  }
298
-
299
-
33
  */
34
  class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Block_Catalog
35
  {
 
 
 
36
  const OPTION_TYPE_SELECT = 'select';
37
  const OPTION_TYPE_CHECKBOX = 'checkbox';
38
  const OPTION_TYPE_TEXT = 'text';
 
39
 
40
  /**
41
  * Store supported product options xml renderers based on product types
70
  $xmlModel = Mage::getModel('xmlconnect/simplexml_element', '<product></product>');
71
  $optionsNode = $xmlModel->addChild('options');
72
 
 
 
 
 
 
73
  if (!$product->getId()) {
74
  return $xmlModel;
75
  }
101
  $formattedPrice = Mage::app()->getStore($product->getStoreId())->formatPrice($price, false);
102
  $optionNode->addAttribute('formated_price', $formattedPrice);
103
  }
 
104
  if ($type == self::OPTION_TYPE_CHECKBOX || $type == self::OPTION_TYPE_SELECT) {
105
  foreach ($option->getValues() as $value) {
 
106
  $valueNode = $optionNode->addChild('value');
107
+ $valueNode->addAttribute('code', $value->getId());
108
  $valueNode->addAttribute('label', $xmlModel->escapeXml($value->getTitle()));
109
 
110
  if ($value->getPrice() != 0) {
113
  $formattedPrice = $this->_formatPriceString($price, $product);
114
  $valueNode->addAttribute('formated_price', $formattedPrice);
115
  }
 
 
 
 
 
 
 
 
 
116
  }
117
  }
118
  }
203
  }
204
 
205
  if ($product->getId()) {
 
206
  $type = $product->getTypeId();
207
  if (isset($this->_renderers[$type])) {
208
  $renderer = $this->getLayout()->createBlock($this->_renderers[$type]);
213
  }
214
  return '<?xml version="1.0" encoding="UTF-8"?><options/>';
215
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  }
 
 
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Bundle.php CHANGED
@@ -49,10 +49,6 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Bundle extends Mage_XmlConne
49
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
50
  }
51
 
52
- if ($product->hasPreconfiguredValues()) {
53
- $optionData = $product->getPreconfiguredValues()->getData('bundle_option');
54
- }
55
-
56
  /**
57
  * Bundle options
58
  */
@@ -66,9 +62,8 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Bundle extends Mage_XmlConne
66
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
67
  }
68
 
69
- foreach ($bundleOptions as $option) {
70
- $selections = $option->getSelections();
71
- $optionId = $option->getOptionId();
72
  if (empty($selections)) {
73
  continue;
74
  }
@@ -76,43 +71,37 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Bundle extends Mage_XmlConne
76
  $optionNode = $optionsXmlObj->addChild('option');
77
 
78
  $type = parent::OPTION_TYPE_SELECT;
79
- if ($option->isMultiSelection()) {
80
  $type = parent::OPTION_TYPE_CHECKBOX;
81
  }
82
- $code = 'bundle_option[' . $option->getId() . ']';
83
  if ($type == parent::OPTION_TYPE_CHECKBOX) {
84
  $code .= '[]';
85
  }
86
  $optionNode->addAttribute('code', $code);
87
  $optionNode->addAttribute('type', $type);
88
- $optionNode->addAttribute('label', $optionsXmlObj->escapeXml($option->getTitle()));
89
- if ($option->getRequired()) {
90
  $optionNode->addAttribute('is_required', 1);
91
  }
92
 
93
- foreach ($selections as $selection) {
94
- if (!$selection->isSaleable()) {
95
  continue;
96
  }
97
- $qty = null;
98
- if ($product->hasPreconfiguredValues()) {
99
- $qty = $product->getPreconfiguredValues()->getData("bundle_option_qty/{$optionId}");
100
- }
101
- if (null === $qty) {
102
- $qty = !($selection->getSelectionQty() * 1) ? '1' : $selection->getSelectionQty() * 1;
103
- }
104
 
105
  $valueNode = $optionNode->addChild('value');
106
- $valueNode->addAttribute('code', $selection->getSelectionId());
107
- $valueNode->addAttribute('label', $optionsXmlObj->escapeXml($selection->getName()));
108
- if (!$option->isMultiSelection()) {
109
- if ($selection->getSelectionCanChangeQty()) {
110
  $valueNode->addAttribute('is_qty_editable', 1);
111
  }
112
  }
113
- $valueNode->addAttribute('qty', $qty);
114
 
115
- $price = $product->getPriceModel()->getSelectionPreFinalPrice($product, $selection);
116
  $price = Mage::helper('xmlconnect')->formatPriceForXml($price);
117
  if ((float)$price != 0.00) {
118
  $valueNode->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml(
@@ -120,14 +109,9 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Bundle extends Mage_XmlConne
120
  ));
121
  $valueNode->addAttribute('formated_price', $this->_formatPriceString($price, $product));
122
  }
123
-
124
- if ($product->hasPreconfiguredValues()) {
125
- $this->_setCartSelectedValue($valueNode, $type, $this->_getPreconfiguredOption(
126
- $optionData, $optionId, $selection->getSelectionId()
127
- ));
128
- }
129
  }
130
  }
 
131
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
132
  }
133
  }
49
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
50
  }
51
 
 
 
 
 
52
  /**
53
  * Bundle options
54
  */
62
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
63
  }
64
 
65
+ foreach ($bundleOptions as $_option) {
66
+ $selections = $_option->getSelections();
 
67
  if (empty($selections)) {
68
  continue;
69
  }
71
  $optionNode = $optionsXmlObj->addChild('option');
72
 
73
  $type = parent::OPTION_TYPE_SELECT;
74
+ if ($_option->isMultiSelection()) {
75
  $type = parent::OPTION_TYPE_CHECKBOX;
76
  }
77
+ $code = 'bundle_option[' . $_option->getId() . ']';
78
  if ($type == parent::OPTION_TYPE_CHECKBOX) {
79
  $code .= '[]';
80
  }
81
  $optionNode->addAttribute('code', $code);
82
  $optionNode->addAttribute('type', $type);
83
+ $optionNode->addAttribute('label', $optionsXmlObj->escapeXml($_option->getTitle()));
84
+ if ($_option->getRequired()) {
85
  $optionNode->addAttribute('is_required', 1);
86
  }
87
 
88
+ foreach ($selections as $_selection) {
89
+ if (!$_selection->isSaleable()) {
90
  continue;
91
  }
92
+ $_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1;
 
 
 
 
 
 
93
 
94
  $valueNode = $optionNode->addChild('value');
95
+ $valueNode->addAttribute('code', $_selection->getSelectionId());
96
+ $valueNode->addAttribute('label', $optionsXmlObj->escapeXml($_selection->getName()));
97
+ if (!$_option->isMultiSelection()) {
98
+ if ($_selection->getSelectionCanChangeQty()) {
99
  $valueNode->addAttribute('is_qty_editable', 1);
100
  }
101
  }
102
+ $valueNode->addAttribute('qty', $_qty);
103
 
104
+ $price = $product->getPriceModel()->getSelectionPreFinalPrice($product, $_selection);
105
  $price = Mage::helper('xmlconnect')->formatPriceForXml($price);
106
  if ((float)$price != 0.00) {
107
  $valueNode->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml(
109
  ));
110
  $valueNode->addAttribute('formated_price', $this->_formatPriceString($price, $product));
111
  }
 
 
 
 
 
 
112
  }
113
  }
114
+
115
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
116
  }
117
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Configurable.php CHANGED
@@ -42,10 +42,6 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Configurable extends Mage_Xm
42
  */
43
  public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObject = false)
44
  {
45
- if ($product->hasPreconfiguredValues()) {
46
- $optionData = $product->getPreconfiguredValues()->getData('super_attribute');
47
- }
48
-
49
  $xmlModel = $this->getProductCustomOptionsXmlObject($product);
50
  $optionsXmlObj = $xmlModel->options;
51
  $options = array();
@@ -57,28 +53,28 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Configurable extends Mage_Xm
57
  /**
58
  * Configurable attributes
59
  */
60
- $productAttributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
61
- if (!sizeof($productAttributes)) {
62
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
63
  }
64
 
65
- $allowProducts = array();
66
- $allProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product);
67
- foreach ($allProducts as $productItem) {
68
- if ($productItem->isSaleable()) {
69
- $allowProducts[] = $productItem;
70
  }
71
  }
72
 
73
  /**
74
  * Allowed products options
75
  */
76
- foreach ($allowProducts as $item) {
77
- $productId = $item->getId();
78
 
79
- foreach ($productAttributes as $attribute) {
80
  $productAttribute = $attribute->getProductAttribute();
81
- $attributeValue = $item->getData($productAttribute->getAttributeCode());
82
  if (!isset($options[$productAttribute->getId()])) {
83
  $options[$productAttribute->getId()] = array();
84
  }
@@ -86,11 +82,11 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Configurable extends Mage_Xm
86
  if (!isset($options[$productAttribute->getId()][$attributeValue])) {
87
  $options[$productAttribute->getId()][$attributeValue] = array();
88
  }
89
- $options[$productAttribute->getId()][$attributeValue][] = $productId;
90
  }
91
  }
92
 
93
- foreach ($productAttributes as $attribute) {
94
  $productAttribute = $attribute->getProductAttribute();
95
  $attributeId = $productAttribute->getId();
96
  $info = array(
@@ -129,8 +125,8 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Configurable extends Mage_Xm
129
 
130
  $isFirst = true;
131
 
132
- $productAttributes = $attributes;
133
- reset($productAttributes);
134
  foreach ($attributes as $id => $attribute) {
135
  $optionNode = $optionsXmlObj->addChild('option');
136
  $optionNode->addAttribute('code', 'super_attribute[' . $id . ']');
@@ -146,13 +142,8 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Configurable extends Mage_Xm
146
  $valueNode->addAttribute('price', $option['price']);
147
  $valueNode->addAttribute('formated_price', $option['formated_price']);
148
  }
149
- if (sizeof($productAttributes) > 1) {
150
- $this->_prepareRecursivelyRelatedValues($valueNode, $productAttributes, $option['products'], 1);
151
- }
152
- if ($product->hasPreconfiguredValues()) {
153
- $this->_setCartSelectedValue($valueNode, 'select', $this->_getPreconfiguredOption(
154
- $optionData, $id, $option['id']
155
- ));
156
  }
157
  }
158
  $isFirst = false;
@@ -194,21 +185,21 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Configurable extends Mage_Xm
194
  $relatedNode->addAttribute('to', 'super_attribute[' . $attrId . ']');
195
  }
196
 
197
- $nodeValue = $relatedNode->addChild('value');
198
- $nodeValue->addAttribute('code', $option['id']);
199
- $nodeValue->addAttribute('label', $nodeValue->escapeXml($option['label']));
200
  if ((float)$option['price'] != 0.00) {
201
- $nodeValue->addAttribute('price', $option['price']);
202
- $nodeValue->addAttribute('formated_price', $option['formated_price']);
203
  }
204
 
205
  /**
206
  * Recursive relation adding
207
  */
208
- $attrClone = $attributes;
209
- if (next($attrClone) != false) {
210
- reset($attrClone);
211
- $this->_prepareRecursivelyRelatedValues($nodeValue, $attrClone, $intersect, $cycle + 1);
212
  }
213
  }
214
  }
42
  */
43
  public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObject = false)
44
  {
 
 
 
 
45
  $xmlModel = $this->getProductCustomOptionsXmlObject($product);
46
  $optionsXmlObj = $xmlModel->options;
47
  $options = array();
53
  /**
54
  * Configurable attributes
55
  */
56
+ $_attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
57
+ if (!sizeof($_attributes)) {
58
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
59
  }
60
 
61
+ $_allowProducts = array();
62
+ $_allProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product);
63
+ foreach ($_allProducts as $_product) {
64
+ if ($_product->isSaleable()) {
65
+ $_allowProducts[] = $_product;
66
  }
67
  }
68
 
69
  /**
70
  * Allowed products options
71
  */
72
+ foreach ($_allowProducts as $_item) {
73
+ $_productId = $_item->getId();
74
 
75
+ foreach ($_attributes as $attribute) {
76
  $productAttribute = $attribute->getProductAttribute();
77
+ $attributeValue = $_item->getData($productAttribute->getAttributeCode());
78
  if (!isset($options[$productAttribute->getId()])) {
79
  $options[$productAttribute->getId()] = array();
80
  }
82
  if (!isset($options[$productAttribute->getId()][$attributeValue])) {
83
  $options[$productAttribute->getId()][$attributeValue] = array();
84
  }
85
+ $options[$productAttribute->getId()][$attributeValue][] = $_productId;
86
  }
87
  }
88
 
89
+ foreach ($_attributes as $attribute) {
90
  $productAttribute = $attribute->getProductAttribute();
91
  $attributeId = $productAttribute->getId();
92
  $info = array(
125
 
126
  $isFirst = true;
127
 
128
+ $_attributes = $attributes;
129
+ reset($_attributes);
130
  foreach ($attributes as $id => $attribute) {
131
  $optionNode = $optionsXmlObj->addChild('option');
132
  $optionNode->addAttribute('code', 'super_attribute[' . $id . ']');
142
  $valueNode->addAttribute('price', $option['price']);
143
  $valueNode->addAttribute('formated_price', $option['formated_price']);
144
  }
145
+ if (sizeof($_attributes) > 1) {
146
+ $this->_prepareRecursivelyRelatedValues($valueNode, $_attributes, $option['products'], 1);
 
 
 
 
 
147
  }
148
  }
149
  $isFirst = false;
185
  $relatedNode->addAttribute('to', 'super_attribute[' . $attrId . ']');
186
  }
187
 
188
+ $_valueNode = $relatedNode->addChild('value');
189
+ $_valueNode->addAttribute('code', $option['id']);
190
+ $_valueNode->addAttribute('label', $_valueNode->escapeXml($option['label']));
191
  if ((float)$option['price'] != 0.00) {
192
+ $_valueNode->addAttribute('price', $option['price']);
193
+ $_valueNode->addAttribute('formated_price', $option['formated_price']);
194
  }
195
 
196
  /**
197
  * Recursive relation adding
198
  */
199
+ $_attrClone = $attributes;
200
+ if (next($_attrClone) != false) {
201
+ reset($_attrClone);
202
+ $this->_prepareRecursivelyRelatedValues($_valueNode, $_attrClone, $intersect, $cycle + 1);
203
  }
204
  }
205
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Downloadable.php DELETED
@@ -1,113 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Downloadable product options xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Catalog_Product_Options_Downloadable extends Mage_XmlConnect_Block_Catalog_Product_Options
35
- {
36
- /**
37
- * Generate downloadable product options xml
38
- *
39
- * @param Mage_Catalog_Model_Product $product
40
- * @param bool $isObject
41
- * @return string | Mage_XmlConnect_Model_Simplexml_Element
42
- */
43
- public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObject = false)
44
- {
45
- /** set current product object */
46
- $this->setProduct($product);
47
-
48
- /** @var $xmlModel Mage_XmlConnect_Model_Simplexml_Element */
49
- $xmlModel = $this->getProductCustomOptionsXmlObject($product);
50
-
51
- /** @var $linksBlock Mage_Downloadable_Block_Catalog_Product_Links */
52
- $linksBlock = $this->getLayout()->addBlock('downloadable/catalog_product_links', 'product_links');
53
-
54
- if (!$product->isSalable() || !$linksBlock->hasLinks()) {
55
- return $isObject ? $xmlModel : $xmlModel->asNiceXml();
56
- }
57
-
58
- /** @var $optionsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
59
- $optionsXmlObj = $xmlModel->options;
60
-
61
- /** @var $samplesBlock Mage_Downloadable_Block_Catalog_Product_Samples */
62
- $samplesBlock = $this->getLayout()->addBlock('downloadable/catalog_product_samples', 'product_samples');
63
-
64
- if ($samplesBlock->hasSamples()) {
65
- $samplesXmlObj = $optionsXmlObj->addCustomChild('samples', null, array(
66
- 'label' => $samplesBlock->getSamplesTitle()
67
- ));
68
- $samples = $samplesBlock->getSamples();
69
- foreach ($samples as $sample) {
70
- $samplesXmlObj->addCustomChild('item', null, array(
71
- 'label' => $sample->getTitle(),
72
- 'url' => $samplesBlock->getSampleUrl($sample)
73
- ));
74
- }
75
- }
76
-
77
- $linksOptions = array('label' => $linksBlock->getLinksTitle());
78
- $selectionRequired = $linksBlock->getLinkSelectionRequired();
79
- if ($selectionRequired) {
80
- $linksOptions += array('code' => 'links[]');
81
- }
82
- $linksXmlObj = $optionsXmlObj->addCustomChild('links', null, $linksOptions);
83
- $links = $linksBlock->getLinks();
84
- foreach ($links as $link) {
85
- $linkOptions = array('label' => $link->getTitle());
86
-
87
- if ($selectionRequired) {
88
- $linkOptions += array('value' => $link->getId());
89
- $price = strip_tags($linksBlock->getFormattedLinkPrice($link));
90
- if ($price) {
91
- $linkOptions += array('formatted_price' => $price);
92
- }
93
- }
94
-
95
- if ($product->hasPreconfiguredValues()) {
96
- $optionData = $product->getPreconfiguredValues()->getData('links');
97
- }
98
- $isSelected = isset($optionData) ? in_array($link->getId(), $optionData) : false;
99
-
100
- if ($linksBlock->getLinkCheckedValue($link) || $isSelected) {
101
- $linkOptions += array('selected' => '1');
102
- }
103
-
104
- if ($link->getSampleFile() || $link->getSampleUrl()) {
105
- $linkOptions += array('sample_url' => $linksBlock->getLinkSamlpeUrl($link));
106
- }
107
-
108
- $linksXmlObj->addCustomChild('item', null, $linkOptions);
109
- }
110
-
111
- return $isObject ? $xmlModel : $xmlModel->asNiceXml();
112
- }
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Giftcard.php CHANGED
@@ -160,6 +160,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Giftcard extends Mage_XmlCon
160
  /**
161
  * Render fixed amounts options
162
  */
 
163
  /** @var $fixedAmountsNode Mage_XmlConnect_Model_Simplexml_Element */
164
  $fixedAmountsNode = $optionsXmlObj->addChild('fixed_amounts');
165
  if ($this->isAmountAvailable($product)) {
160
  /**
161
  * Render fixed amounts options
162
  */
163
+
164
  /** @var $fixedAmountsNode Mage_XmlConnect_Model_Simplexml_Element */
165
  $fixedAmountsNode = $optionsXmlObj->addChild('fixed_amounts');
166
  if ($this->isAmountAvailable($product)) {
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Grouped.php CHANGED
@@ -38,7 +38,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Grouped extends Mage_XmlConn
38
  *
39
  * @param Mage_Catalog_Model_Product $product
40
  * @param bool $isObject
41
- * @return string|Mage_XmlConnect_Model_Simplexml_Element
42
  */
43
  public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObject = false)
44
  {
@@ -55,30 +55,30 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Grouped extends Mage_XmlConn
55
  /**
56
  * Grouped (associated) products
57
  */
58
- $associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
59
- if (!sizeof($associatedProducts)) {
60
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
61
  }
62
 
63
- foreach ($associatedProducts as $item) {
64
- if (!$item->isSaleable()) {
65
  continue;
66
  }
67
  $optionNode = $optionsNode->addChild('option');
68
 
69
- $optionNode->addAttribute('code', 'super_group[' . $item->getId() . ']');
70
  $optionNode->addAttribute('type', 'product');
71
- $optionNode->addAttribute('label', $xmlModel->escapeXml($item->getName()));
72
  $optionNode->addAttribute('is_qty_editable', 1);
73
- $optionNode->addAttribute('qty', $item->getQty()*1);
74
 
75
  /**
76
  * Process product price
77
  */
78
- if ($item->getPrice() != $item->getFinalPrice()) {
79
- $productPrice = $item->getFinalPrice();
80
  } else {
81
- $productPrice = $item->getPrice();
82
  }
83
 
84
  if ($productPrice != 0) {
38
  *
39
  * @param Mage_Catalog_Model_Product $product
40
  * @param bool $isObject
41
+ * @return string | Mage_XmlConnect_Model_Simplexml_Element
42
  */
43
  public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObject = false)
44
  {
55
  /**
56
  * Grouped (associated) products
57
  */
58
+ $_associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
59
+ if (!sizeof($_associatedProducts)) {
60
  return $isObject ? $xmlModel : $xmlModel->asNiceXml();
61
  }
62
 
63
+ foreach ($_associatedProducts as $_item) {
64
+ if (!$_item->isSaleable()) {
65
  continue;
66
  }
67
  $optionNode = $optionsNode->addChild('option');
68
 
69
+ $optionNode->addAttribute('code', 'super_group[' . $_item->getId() . ']');
70
  $optionNode->addAttribute('type', 'product');
71
+ $optionNode->addAttribute('label', $xmlModel->escapeXml($_item->getName()));
72
  $optionNode->addAttribute('is_qty_editable', 1);
73
+ $optionNode->addAttribute('qty', $_item->getQty()*1);
74
 
75
  /**
76
  * Process product price
77
  */
78
+ if ($_item->getPrice() != $_item->getFinalPrice()) {
79
+ $productPrice = $_item->getFinalPrice();
80
  } else {
81
+ $productPrice = $_item->getPrice();
82
  }
83
 
84
  if ($productPrice != 0) {
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Bundle.php CHANGED
@@ -39,107 +39,109 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Bundle extends Mage_Bundle_Blo
39
  * @param Mage_Catalog_Model_Product $product
40
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
41
  */
42
- public function collectProductPrices(Mage_Catalog_Model_Product $product,
43
- Mage_XmlConnect_Model_Simplexml_Element $item)
44
- {
45
- $this->setProduct($product)->setDisplayMinimalPrice(true)->setUseLinkForAsLowAs(false);
46
 
47
  $priceXmlObj = $item->addChild('price');
48
 
49
- /** @var $coreHelper Mage_Core_Helper_Data */
50
- $coreHelper = $this->helper('core');
51
- /** @var $weeeHelper Mage_Weee_Helper_Data */
52
- $weeeHelper = $this->helper('weee');
53
- /** @var $taxHelper Mage_Tax_Helper_Data */
54
- $taxHelper = $this->helper('tax');
55
 
56
- $tierPrices = $this->_getTierPrices($product);
57
 
58
- if (count($tierPrices) > 0) {
59
  $tierPricesTextArray = array();
60
- foreach ($tierPrices as $price) {
61
- $discount = ' ' . ($price['price'] * 1) . '%';
62
- $tierPricesTextArray[] = $this->__('Buy %1$s with %2$s discount each', $price['price_qty'], $discount);
63
  }
64
  $item->addChild('price_tier', implode(PHP_EOL, $tierPricesTextArray));
65
  }
66
 
67
- list($minimalPrice, $maximalPrice) = $product->getPriceModel()->getPrices($product);
68
 
69
- $weeeTaxAmount = 0;
70
- $minimalPriceTax = $taxHelper->getPrice($product, $minimalPrice);
71
- $minimalPriceInclTax = $taxHelper->getPrice($product, $minimalPrice, true);
72
 
73
  if ($product->getPriceType() == 1) {
74
- $weeeTaxAmount = $weeeHelper->getAmount($product);
75
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
76
- $minimalPriceTax += $weeeTaxAmount;
77
- $minimalPriceInclTax += $weeeTaxAmount;
78
  }
79
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
80
- $minimalPriceInclTax += $weeeTaxAmount;
81
  }
82
 
83
- if ($weeeHelper->typeOfDisplay($product, array(1, 2, 4))) {
84
- $weeeTaxAttributes = $weeeHelper->getProductWeeeAttributesForDisplay($product);
85
  }
86
  }
87
 
88
  if ($product->getPriceView()) {
89
- if ($taxHelper->displayBothPrices()) {
90
  $priceXmlObj->addAttribute(
91
- 'as_low_as_excluding_tax', $coreHelper->currency($minimalPriceTax, true, false)
92
  );
93
- if ($weeeTaxAmount && $product->getPriceType() == 1
94
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
95
  ) {
96
  $weeeXmlObj = $priceXmlObj->addChild('weee');
97
- $weeeSeparator = ' + ';
98
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
99
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
100
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
101
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
102
  } else {
103
- $amount = $weeeTaxAttribute->getAmount();
104
  }
105
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
106
  $weeeItemXmlObj->addAttribute(
107
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
 
 
 
108
  );
109
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency($amount, true, false));
110
  }
111
  }
112
  $priceXmlObj->addAttribute(
113
- 'as_low_as_including_tax', $coreHelper->currency($minimalPriceInclTax, true, false)
114
  );
115
  } else {
116
  $priceXmlObj->addAttribute(
117
- 'as_low_as', $coreHelper->currency($minimalPriceTax, true, false)
118
  );
119
- if ($weeeTaxAmount && $product->getPriceType() == 1
120
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
121
  ) {
122
  $weeeXmlObj = $priceXmlObj->addChild('weee');
123
- $weeeSeparator = ' + ';
124
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
125
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
126
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
127
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
128
  } else {
129
- $amount = $weeeTaxAttribute->getAmount();
130
  }
131
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
132
  $weeeItemXmlObj->addAttribute(
133
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
134
  );
135
  $weeeItemXmlObj->addAttribute(
136
- 'amount', $coreHelper->currency($amount, true, false)
137
  );
138
  }
139
  }
140
- if ($weeeHelper->typeOfDisplay($product, 2) && $weeeTaxAmount) {
141
  $priceXmlObj->addAttribute(
142
- 'as_low_as_including_tax', $coreHelper->currency($minimalPriceInclTax, true, false)
143
  );
144
  }
145
  }
@@ -147,179 +149,195 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Bundle extends Mage_Bundle_Blo
147
  * if ($product->getPriceView()) {
148
  */
149
  } else {
150
- if ($minimalPrice <> $maximalPrice) {
151
- if ($taxHelper->displayBothPrices()) {
152
  $priceXmlObj->addAttribute(
153
- 'from_excluding_tax', $coreHelper->currency($minimalPriceTax, true, false)
154
  );
155
- if ($weeeTaxAmount && $product->getPriceType() == 1
156
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
157
  ) {
158
  $weeeXmlObj = $priceXmlObj->addChild('from_weee');
159
- $weeeSeparator = ' + ';
160
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
161
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
162
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
163
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
164
  } else {
165
- $amount = $weeeTaxAttribute->getAmount();
166
  }
167
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
168
  $weeeItemXmlObj->addAttribute(
169
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
 
 
 
170
  );
171
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency($amount, true, false));
172
  }
173
  }
174
  $priceXmlObj->addAttribute(
175
- 'from_including_tax', $coreHelper->currency($minimalPriceInclTax, true, false)
176
  );
177
  } else {
178
- $priceXmlObj->addAttribute('from', $coreHelper->currency($minimalPriceTax, true, false));
179
- if ($weeeTaxAmount && $product->getPriceType() == 1
180
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
181
  ) {
182
  $weeeXmlObj = $priceXmlObj->addChild('from_weee');
183
- $weeeSeparator = ' + ';
184
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
185
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
186
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
187
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
188
  } else {
189
- $amount = $weeeTaxAttribute->getAmount();
190
  }
191
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
192
  $weeeItemXmlObj->addAttribute(
193
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
194
  );
195
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency($amount, true, false));
196
  }
197
  }
198
- if ($weeeHelper->typeOfDisplay($product, 2) && $weeeTaxAmount) {
199
  $priceXmlObj->addAttribute(
200
- 'from_including_tax', $coreHelper->currency($minimalPriceInclTax, true, false)
201
  );
202
  }
203
  }
204
 
205
- $maximalPriceTax = Mage::helper('tax')->getPrice($product, $maximalPrice);
206
- $maximalPriceInclTax = Mage::helper('tax')->getPrice($product, $maximalPrice, true);
207
 
208
  if ($product->getPriceType() == 1) {
209
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
210
- $maximalPriceTax += $weeeTaxAmount;
211
- $maximalPriceInclTax += $weeeTaxAmount;
212
  }
213
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
214
- $maximalPriceInclTax += $weeeTaxAmount;
215
  }
216
  }
217
 
218
- if ($taxHelper->displayBothPrices()) {
219
  $priceXmlObj->addAttribute(
220
- 'to_excluding_tax', $coreHelper->currency($maximalPriceTax, true, false)
221
  );
222
- if ($weeeTaxAmount && $product->getPriceType() == 1
223
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
224
  ) {
225
  $weeeXmlObj = $priceXmlObj->addChild('to_weee');
226
- $weeeSeparator = ' + ';
227
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
228
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
229
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
230
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
231
  } else {
232
- $amount = $weeeTaxAttribute->getAmount();
233
  }
234
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
235
  $weeeItemXmlObj->addAttribute(
236
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
 
 
 
237
  );
238
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency($amount, true, false));
239
  }
240
  }
241
  $priceXmlObj->addAttribute(
242
- 'to_including_tax', $coreHelper->currency($maximalPriceInclTax, true, false)
243
  );
244
  } else {
245
- $priceXmlObj->addAttribute('to', $coreHelper->currency($maximalPriceTax, true, false));
246
- if ($weeeTaxAmount && $product->getPriceType() == 1
247
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
 
 
248
  ) {
249
  $weeeXmlObj = $priceXmlObj->addChild('to_weee');
250
- $weeeSeparator = ' + ';
251
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
252
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
253
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
254
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
255
  } else {
256
- $amount = $weeeTaxAttribute->getAmount();
257
  }
258
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
259
  $weeeItemXmlObj->addAttribute(
260
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
 
 
 
261
  );
262
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency($amount, true, false));
263
  }
264
  }
265
- if ($weeeHelper->typeOfDisplay($product, 2) && $weeeTaxAmount) {
266
  $priceXmlObj->addAttribute(
267
- 'to_including_tax', $coreHelper->currency($maximalPriceInclTax, true, false)
268
  );
269
  }
270
  }
271
  /**
272
- * if ($minimalPrice <> $maximalPrice) {
273
  */
274
  } else {
275
- if ($taxHelper->displayBothPrices()) {
276
- $priceXmlObj->addAttribute('excluding_tax', $coreHelper->currency($minimalPriceTax, true, false));
277
- if ($weeeTaxAmount && $product->getPriceType() == 1
278
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
 
 
279
  ) {
280
  $weeeXmlObj = $priceXmlObj->addChild('weee');
281
- $weeeSeparator = ' + ';
282
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
283
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
284
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
285
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
286
  } else {
287
- $amount = $weeeTaxAttribute->getAmount();
288
  }
289
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
290
  $weeeItemXmlObj->addAttribute(
291
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
 
 
 
292
  );
293
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency($amount, true, false));
294
  }
295
  }
296
  $priceXmlObj->addAttribute(
297
- 'including_tax',$coreHelper->currency($minimalPriceInclTax, true, false)
298
  );
299
  } else {
300
- $priceXmlObj->addAttribute('regular', $coreHelper->currency($minimalPriceTax, true, false));
301
- if ($weeeTaxAmount && $product->getPriceType() == 1
302
- && $weeeHelper->typeOfDisplay($product, array(2, 1, 4))
 
 
303
  ) {
304
  $weeeXmlObj = $priceXmlObj->addChild('weee');
305
- $weeeSeparator = ' + ';
306
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
307
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
308
- if ($weeeHelper->typeOfDisplay($product, array(2, 4))) {
309
- $amount = $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount();
310
  } else {
311
- $amount = $weeeTaxAttribute->getAmount();
312
  }
313
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
314
  $weeeItemXmlObj->addAttribute(
315
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
 
 
 
316
  );
317
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency($amount, true, false));
318
  }
319
  }
320
- if ($weeeHelper->typeOfDisplay($product, 2) && $weeeTaxAmount) {
321
  $priceXmlObj->addAttribute(
322
- 'including_tax', $coreHelper->currency($minimalPriceInclTax, true, false)
323
  );
324
  }
325
  }
39
  * @param Mage_Catalog_Model_Product $product
40
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
41
  */
42
+ public function collectProductPrices(
43
+ Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item
44
+ ) {
45
+ $this->setProduct($product)->setDisplayMinimalPrice(true) ->setUseLinkForAsLowAs(false);
46
 
47
  $priceXmlObj = $item->addChild('price');
48
 
49
+ /** @var $_coreHelper Mage_Core_Helper_Data */
50
+ $_coreHelper = $this->helper('core');
51
+ /** @var $_weeeHelper Mage_Weee_Helper_Data */
52
+ $_weeeHelper = $this->helper('weee');
53
+ /** @var $_taxHelper Mage_Tax_Helper_Data */
54
+ $_taxHelper = $this->helper('tax');
55
 
56
+ $_tierPrices = $this->_getTierPrices($product);
57
 
58
+ if (count($_tierPrices) > 0) {
59
  $tierPricesTextArray = array();
60
+ foreach ($_tierPrices as $_price) {
61
+ $discount = ' ' . ($_price['price'] * 1) . '%';
62
+ $tierPricesTextArray[] = $this->__('Buy %1$s with %2$s discount each', $_price['price_qty'], $discount);
63
  }
64
  $item->addChild('price_tier', implode(PHP_EOL, $tierPricesTextArray));
65
  }
66
 
67
+ list($_minimalPrice, $_maximalPrice) = $product->getPriceModel()->getPrices($product);
68
 
69
+ $_weeeTaxAmount = 0;
70
+ $_minimalPriceTax = $_taxHelper->getPrice($product, $_minimalPrice);
71
+ $_minimalPriceInclTax = $_taxHelper->getPrice($product, $_minimalPrice, true);
72
 
73
  if ($product->getPriceType() == 1) {
74
+ $_weeeTaxAmount = $_weeeHelper->getAmount($product);
75
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
76
+ $_minimalPriceTax += $_weeeTaxAmount;
77
+ $_minimalPriceInclTax += $_weeeTaxAmount;
78
  }
79
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 2)) {
80
+ $_minimalPriceInclTax += $_weeeTaxAmount;
81
  }
82
 
83
+ if ($_weeeHelper->typeOfDisplay($product, array(1, 2, 4))) {
84
+ $_weeeTaxAttributes = $_weeeHelper->getProductWeeeAttributesForDisplay($product);
85
  }
86
  }
87
 
88
  if ($product->getPriceView()) {
89
+ if ($_taxHelper->displayBothPrices()) {
90
  $priceXmlObj->addAttribute(
91
+ 'as_low_as_excluding_tax', $_coreHelper->currency($_minimalPriceTax, true, false)
92
  );
93
+ if ($_weeeTaxAmount && $product->getPriceType() == 1
94
+ && $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
95
  ) {
96
  $weeeXmlObj = $priceXmlObj->addChild('weee');
97
+ $_weeeSeparator = ' + ';
98
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
99
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
100
+ if ($_weeeHelper->typeOfDisplay($product, array(2, 4))) {
101
+ $amount = $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount();
102
  } else {
103
+ $amount = $_weeeTaxAttribute->getAmount();
104
  }
105
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
106
  $weeeItemXmlObj->addAttribute(
107
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
108
+ );
109
+ $weeeItemXmlObj->addAttribute(
110
+ 'amount', $_coreHelper->currency($amount, true, false)
111
  );
 
112
  }
113
  }
114
  $priceXmlObj->addAttribute(
115
+ 'as_low_as_including_tax', $_coreHelper->currency($_minimalPriceInclTax, true, false)
116
  );
117
  } else {
118
  $priceXmlObj->addAttribute(
119
+ 'as_low_as', $_coreHelper->currency($_minimalPriceTax, true, false)
120
  );
121
+ if ($_weeeTaxAmount && $product->getPriceType() == 1
122
+ && $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
123
  ) {
124
  $weeeXmlObj = $priceXmlObj->addChild('weee');
125
+ $_weeeSeparator = ' + ';
126
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
127
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
128
+ if ($_weeeHelper->typeOfDisplay($product, array(2, 4))) {
129
+ $amount = $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount();
130
  } else {
131
+ $amount = $_weeeTaxAttribute->getAmount();
132
  }
133
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
134
  $weeeItemXmlObj->addAttribute(
135
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
136
  );
137
  $weeeItemXmlObj->addAttribute(
138
+ 'amount', $_coreHelper->currency($amount, true, false)
139
  );
140
  }
141
  }
142
+ if ($_weeeHelper->typeOfDisplay($product, 2) && $_weeeTaxAmount) {
143
  $priceXmlObj->addAttribute(
144
+ 'as_low_as_including_tax', $_coreHelper->currency($_minimalPriceInclTax, true, false)
145
  );
146
  }
147
  }
149
  * if ($product->getPriceView()) {
150
  */
151
  } else {
152
+ if ($_minimalPrice <> $_maximalPrice) {
153
+ if ($_taxHelper->displayBothPrices()) {
154
  $priceXmlObj->addAttribute(
155
+ 'from_excluding_tax', $_coreHelper->currency($_minimalPriceTax, true, false)
156
  );
157
+ if ($_weeeTaxAmount && $product->getPriceType() == 1
158
+ && $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
159
  ) {
160
  $weeeXmlObj = $priceXmlObj->addChild('from_weee');
161
+ $_weeeSeparator = ' + ';
162
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
163
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
164
+ if ($_weeeHelper->typeOfDisplay($product, array(2, 4))) {
165
+ $amount = $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount();
166
  } else {
167
+ $amount = $_weeeTaxAttribute->getAmount();
168
  }
169
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
170
  $weeeItemXmlObj->addAttribute(
171
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
172
+ );
173
+ $weeeItemXmlObj->addAttribute(
174
+ 'amount', $_coreHelper->currency($amount, true, false)
175
  );
 
176
  }
177
  }
178
  $priceXmlObj->addAttribute(
179
+ 'from_including_tax', $_coreHelper->currency($_minimalPriceInclTax, true, false)
180
  );
181
  } else {
182
+ $priceXmlObj->addAttribute('from', $_coreHelper->currency($_minimalPriceTax, true, false));
183
+ if ($_weeeTaxAmount && $product->getPriceType() == 1
184
+ && $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
185
  ) {
186
  $weeeXmlObj = $priceXmlObj->addChild('from_weee');
187
+ $_weeeSeparator = ' + ';
188
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
189
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
190
+ if ($_weeeHelper->typeOfDisplay($product, array(2, 4))) {
191
+ $amount = $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount();
192
  } else {
193
+ $amount = $_weeeTaxAttribute->getAmount();
194
  }
195
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
196
  $weeeItemXmlObj->addAttribute(
197
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
198
  );
199
+ $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency($amount, true, false));
200
  }
201
  }
202
+ if ($_weeeHelper->typeOfDisplay($product, 2) && $_weeeTaxAmount) {
203
  $priceXmlObj->addAttribute(
204
+ 'from_including_tax', $_coreHelper->currency($_minimalPriceInclTax, true, false)
205
  );
206
  }
207
  }
208
 
209
+ $_maximalPriceTax = Mage::helper('tax')->getPrice($product, $_maximalPrice);
210
+ $_maximalPriceInclTax = Mage::helper('tax')->getPrice($product, $_maximalPrice, true);
211
 
212
  if ($product->getPriceType() == 1) {
213
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
214
+ $_maximalPriceTax += $_weeeTaxAmount;
215
+ $_maximalPriceInclTax += $_weeeTaxAmount;
216
  }
217
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 2)) {
218
+ $_maximalPriceInclTax += $_weeeTaxAmount;
219
  }
220
  }
221
 
222
+ if ($_taxHelper->displayBothPrices()) {
223
  $priceXmlObj->addAttribute(
224
+ 'to_excluding_tax', $_coreHelper->currency($_maximalPriceTax, true, false)
225
  );
226
+ if ($_weeeTaxAmount && $product->getPriceType() == 1
227
+ && $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
228
  ) {
229
  $weeeXmlObj = $priceXmlObj->addChild('to_weee');
230
+ $_weeeSeparator = ' + ';
231
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
232
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
233
+ if ($_weeeHelper->typeOfDisplay($product, array(2, 4))) {
234
+ $amount = $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount();
235
  } else {
236
+ $amount = $_weeeTaxAttribute->getAmount();
237
  }
238
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
239
  $weeeItemXmlObj->addAttribute(
240
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
241
+ );
242
+ $weeeItemXmlObj->addAttribute(
243
+ 'amount', $_coreHelper->currency($amount, true, false)
244
  );
 
245
  }
246
  }
247
  $priceXmlObj->addAttribute(
248
+ 'to_including_tax', $_coreHelper->currency($_maximalPriceInclTax, true, false)
249
  );
250
  } else {
251
+ $priceXmlObj->addAttribute(
252
+ 'to', $_coreHelper->currency($_maximalPriceTax, true, false)
253
+ );
254
+ if ($_weeeTaxAmount && $product->getPriceType() == 1
255
+ && $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
256
  ) {
257
  $weeeXmlObj = $priceXmlObj->addChild('to_weee');
258
+ $_weeeSeparator = ' + ';
259
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
260
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
261
+ if ($_weeeHelper->typeOfDisplay($product, array(2, 4))) {
262
+ $amount = $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount();
263
  } else {
264
+ $amount = $_weeeTaxAttribute->getAmount();
265
  }
266
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
267
  $weeeItemXmlObj->addAttribute(
268
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
269
+ );
270
+ $weeeItemXmlObj->addAttribute(
271
+ 'amount', $_coreHelper->currency($amount, true, false)
272
  );
 
273
  }
274
  }
275
+ if ($_weeeHelper->typeOfDisplay($product, 2) && $_weeeTaxAmount) {
276
  $priceXmlObj->addAttribute(
277
+ 'to_including_tax', $_coreHelper->currency($_maximalPriceInclTax, true, false)
278
  );
279
  }
280
  }
281
  /**
282
+ * if ($_minimalPrice <> $_maximalPrice) {
283
  */
284
  } else {
285
+ if ($_taxHelper->displayBothPrices()) {
286
+ $priceXmlObj->addAttribute(
287
+ 'excluding_tax', $_coreHelper->currency($_minimalPriceTax, true, false)
288
+ );
289
+ if ($_weeeTaxAmount && $product->getPriceType() == 1
290
+ && $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
291
  ) {
292
  $weeeXmlObj = $priceXmlObj->addChild('weee');
293
+ $_weeeSeparator = ' + ';
294
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
295
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
296
+ if ($_weeeHelper->typeOfDisplay($product, array(2, 4))) {
297
+ $amount = $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount();
298
  } else {
299
+ $amount = $_weeeTaxAttribute->getAmount();
300
  }
301
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
302
  $weeeItemXmlObj->addAttribute(
303
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
304
+ );
305
+ $weeeItemXmlObj->addAttribute(
306
+ 'amount', $_coreHelper->currency($amount, true, false)
307
  );
 
308
  }
309
  }
310
  $priceXmlObj->addAttribute(
311
+ 'including_tax', $_coreHelper->currency($_minimalPriceInclTax, true, false)
312
  );
313
  } else {
314
+ $priceXmlObj->addAttribute(
315
+ 'regular', $_coreHelper->currency($_minimalPriceTax, true, false)
316
+ );
317
+ if ($_weeeTaxAmount && $product->getPriceType() == 1
318
+ && $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
319
  ) {
320
  $weeeXmlObj = $priceXmlObj->addChild('weee');
321
+ $_weeeSeparator = ' + ';
322
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
323
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
324
+ if ($_weeeHelper->typeOfDisplay($product, array(2, 4))) {
325
+ $amount = $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount();
326
  } else {
327
+ $amount = $_weeeTaxAttribute->getAmount();
328
  }
329
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
330
  $weeeItemXmlObj->addAttribute(
331
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
332
+ );
333
+ $weeeItemXmlObj->addAttribute(
334
+ 'amount', $_coreHelper->currency($amount, true, false)
335
  );
 
336
  }
337
  }
338
+ if ($_weeeHelper->typeOfDisplay($product, 2) && $_weeeTaxAmount) {
339
  $priceXmlObj->addAttribute(
340
+ 'including_tax', $_coreHelper->currency($_minimalPriceInclTax, true, false)
341
  );
342
  }
343
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Default.php CHANGED
@@ -39,321 +39,322 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Default extends Mage_Catalog_B
39
  * @param Mage_Catalog_Model_Product $product
40
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
41
  */
42
- public function collectProductPrices(Mage_Catalog_Model_Product $product,
43
- Mage_XmlConnect_Model_Simplexml_Element $item)
44
- {
45
  $this->setProduct($product)->setDisplayMinimalPrice(true)->setUseLinkForAsLowAs(false);
46
 
47
  $priceXmlObj = $item->addChild('price');
48
- $tierPrices = $this->_getTierPrices($product);
49
- if (count($tierPrices) > 0) {
50
- $tierPricesTextArray = $item->escapeXml(implode(
51
- PHP_EOL, $this->_getTierPricesTextArray($tierPrices, $product)
52
- ));
53
- $item->addCustomChild('price_tier', $tierPricesTextArray);
54
  }
55
 
56
- /** @var $coreHelper Mage_Core_Helper_Data */
57
- $coreHelper = $this->helper('core');
58
- /** @var $weeeHelper Mage_Weee_Helper_Data */
59
- $weeeHelper = $this->helper('weee');
60
- /** @var $taxHelper Mage_Tax_Helper_Data */
61
- $taxHelper = $this->helper('tax');
62
 
63
- $simplePricesTax = ($taxHelper->displayPriceIncludingTax() || $taxHelper->displayBothPrices());
64
- $minimalPriceValue = $product->getMinimalPrice();
65
- $minimalPrice = $taxHelper->getPrice($product, $minimalPriceValue, $simplePricesTax);
66
 
67
  if (!$product->isGrouped()) {
68
- $weeeTaxAmount = $weeeHelper->getAmountForDisplay($product);
69
- if ($weeeHelper->typeOfDisplay($product, array(1, 2, 4))) {
70
- $weeeTaxAmount = $weeeHelper->getAmount($product);
71
- $weeeTaxAttributes = $weeeHelper->getProductWeeeAttributesForDisplay($product);
72
  }
73
 
74
- $price = $taxHelper->getPrice($product, $product->getPrice());
75
- $regularPrice = $taxHelper->getPrice($product, $product->getPrice(), $simplePricesTax);
76
- $finalPrice = $taxHelper->getPrice($product, $product->getFinalPrice());
77
- $finalPriceInclTax = $taxHelper->getPrice($product, $product->getFinalPrice(), true);
78
- $weeeHelper->getPriceDisplayType();
79
- if ($finalPrice == $price) {
80
- if ($taxHelper->displayBothPrices()) {
81
  /**
82
  * Including
83
  */
84
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 0)) {
85
  $priceXmlObj->addAttribute(
86
- 'excluding_tax', $coreHelper->currency($price + $weeeTaxAmount, true, false)
87
  );
88
  $priceXmlObj->addAttribute(
89
- 'including_tax', $coreHelper->currency($finalPriceInclTax + $weeeTaxAmount, true, false)
90
  );
91
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 1)) {
92
  /**
93
  * Including + Weee
94
  */
95
  $priceXmlObj->addAttribute(
96
- 'excluding_tax', $coreHelper->currency($price + $weeeTaxAmount, true, false)
97
  );
98
  $priceXmlObj->addAttribute(
99
- 'including_tax', $coreHelper->currency($finalPriceInclTax + $weeeTaxAmount, true, false)
100
  );
101
  $weeeXmlObj = $priceXmlObj->addChild('weee');
102
- $weeeSeparator = ' + ';
103
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
104
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
105
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
106
  $weeeItemXmlObj->addAttribute(
107
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
108
  );
109
  $weeeItemXmlObj->addAttribute(
110
- 'amount', $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
111
  );
112
  }
113
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 4)) {
114
  /**
115
  * Including + Weee
116
  */
117
  $priceXmlObj->addAttribute(
118
- 'excluding_tax', $coreHelper->currency($price + $weeeTaxAmount, true, false)
119
  );
120
  $priceXmlObj->addAttribute(
121
- 'including_tax', $coreHelper->currency($finalPriceInclTax + $weeeTaxAmount, true, false)
122
  );
123
  $weeeXmlObj = $priceXmlObj->addChild('weee');
124
- $weeeSeparator = ' + ';
125
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
126
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
127
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
128
  $weeeItemXmlObj->addAttribute(
129
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
130
  );
131
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency(
132
- $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount(), true, false
133
  ));
134
  }
135
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
136
  /**
137
  * Excluding + Weee + Final
138
  */
139
- $priceXmlObj->addAttribute('excluding_tax', $coreHelper->currency($price, true, false));
140
  $weeeXmlObj = $priceXmlObj->addChild('weee');
141
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
142
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
143
  $weeeItemXmlObj->addAttribute(
144
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
145
  );
146
  $weeeItemXmlObj->addAttribute(
147
- 'amount', $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
148
  );
149
  }
150
- $priceXmlObj->addAttribute('including_tax', $coreHelper->currency(
151
- $finalPriceInclTax + $weeeTaxAmount, true, false
152
  ));
153
  } else {
154
- $priceXmlObj->addAttribute('excluding_tax', $coreHelper->currency($price, true, false));
155
  $priceXmlObj->addAttribute(
156
- 'including_tax', $coreHelper->currency($finalPriceInclTax, true, false)
157
  );
158
  }
159
  /**
160
- * if ($taxHelper->displayBothPrices()) {
161
  */
162
  } else {
163
  /**
164
  * Including
165
  */
166
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 0)) {
167
- $priceXmlObj->addAttribute('regular', $coreHelper->currency(
168
- $price + $weeeTaxAmount, true, false
169
  ));
170
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 1)) {
171
  /**
172
  * Including + Weee
173
  */
174
- $priceXmlObj->addAttribute('regular', $coreHelper->currency(
175
- $price + $weeeTaxAmount, true, false
176
  ));
177
  $weeeXmlObj = $priceXmlObj->addChild('weee');
178
- $weeeSeparator = ' + ';
179
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
180
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
181
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
182
  $weeeItemXmlObj->addAttribute(
183
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
184
  );
185
  $weeeItemXmlObj->addAttribute(
186
- 'amount', $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
187
  );
188
  }
189
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 4)) {
190
  /**
191
  * Including + Weee
192
  */
193
- $priceXmlObj->addAttribute('regular', $coreHelper->currency(
194
- $price + $weeeTaxAmount, true, false
195
  ));
196
  $weeeXmlObj = $priceXmlObj->addChild('weee');
197
- $weeeSeparator = ' + ';
198
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
199
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
200
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
201
  $weeeItemXmlObj->addAttribute(
202
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
203
  );
204
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency(
205
- $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount(), true, false
206
  ));
207
  }
208
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
209
  /**
210
  * Excluding + Weee + Final
211
  */
212
- $priceXmlObj->addAttribute('regular', $coreHelper->currency($price, true, false));
 
 
213
  $weeeXmlObj = $priceXmlObj->addChild('weee');
214
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
215
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
216
  $weeeItemXmlObj->addAttribute(
217
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
218
  );
219
  $weeeItemXmlObj->addAttribute(
220
- 'amount', $coreHelper->currency($weeeTaxAttribute->getAmount(), true, false)
221
  );
222
  }
223
  $priceXmlObj->addAttribute(
224
- 'including_tax', $coreHelper->currency($price + $weeeTaxAmount, true, false)
225
  );
226
  } else {
227
- $priceXmlObj->addAttribute('regular', $coreHelper->currency($price, true, false));
228
  }
229
  }
230
  /**
231
- * if ($finalPrice == $price) {
232
  */
233
  } else {
234
- $originalWeeeTaxAmount = $weeeHelper->getOriginalAmount($product);
235
  /**
236
  * Including
237
  */
238
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 0)) {
239
- $priceXmlObj->addAttribute('regular', $coreHelper->currency(
240
- $regularPrice + $originalWeeeTaxAmount, true, false
241
  ));
242
- if ($taxHelper->displayBothPrices()) {
243
- $priceXmlObj->addAttribute('special_excluding_tax', $coreHelper->currency(
244
- $finalPrice + $weeeTaxAmount, true, false
245
  ));
246
- $priceXmlObj->addAttribute('special_including_tax', $coreHelper->currency(
247
- $finalPriceInclTax + $weeeTaxAmount, true, false
248
  ));
249
  } else {
250
- $priceXmlObj->addAttribute('special', $coreHelper->currency(
251
- $finalPrice + $weeeTaxAmount, true, false
252
  ));
253
  }
254
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 1)) {
255
  /**
256
  * Including + Weee
257
  */
258
- $priceXmlObj->addAttribute('regular', $coreHelper->currency(
259
- $regularPrice + $originalWeeeTaxAmount, true, false
260
  ));
261
- $priceXmlObj->addAttribute('special_excluding_tax', $coreHelper->currency(
262
- $finalPrice + $weeeTaxAmount, true, false
263
  ));
264
  $weeeXmlObj = $priceXmlObj->addChild('weee');
265
- $weeeSeparator = ' + ';
266
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
267
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
268
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
269
  $weeeItemXmlObj->addAttribute(
270
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
271
  );
272
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency(
273
- $weeeTaxAttribute->getAmount(), true, false
274
  ));
275
  }
276
- $priceXmlObj->addAttribute('special_including_tax', $coreHelper->currency(
277
- $finalPriceInclTax + $weeeTaxAmount, true, false
278
  ));
279
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 4)) {
280
  /**
281
  * Including + Weee
282
  */
283
- $priceXmlObj->addAttribute('regular', $coreHelper->currency(
284
- $regularPrice + $originalWeeeTaxAmount, true, false
285
  ));
286
- $priceXmlObj->addAttribute('special_excluding_tax', $coreHelper->currency(
287
- $finalPrice + $weeeTaxAmount, true, false
288
  ));
289
  $weeeXmlObj = $priceXmlObj->addChild('weee');
290
- $weeeSeparator = ' + ';
291
- $weeeXmlObj->addAttribute('separator', $weeeSeparator);
292
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
293
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
294
  $weeeItemXmlObj->addAttribute(
295
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
296
  );
297
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency(
298
- $weeeTaxAttribute->getAmount() + $weeeTaxAttribute->getTaxAmount(), true, false
299
  ));
300
  }
301
- $priceXmlObj->addAttribute('special_including_tax', $coreHelper->currency(
302
- $finalPriceInclTax + $weeeTaxAmount, true, false
303
  ));
304
- } elseif ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, 2)) {
305
  /**
306
  * Excluding + Weee + Final
307
  */
308
- $priceXmlObj->addAttribute('regular', $coreHelper->currency($regularPrice, true, false));
309
  $priceXmlObj->addAttribute(
310
- 'special_excluding_tax', $coreHelper->currency($finalPrice, true, false)
311
  );
312
  $weeeXmlObj = $priceXmlObj->addChild('weee');
313
- foreach ($weeeTaxAttributes as $weeeTaxAttribute) {
314
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
315
  $weeeItemXmlObj->addAttribute(
316
- 'name', $weeeItemXmlObj->escapeXml($weeeTaxAttribute->getName())
317
  );
318
- $weeeItemXmlObj->addAttribute('amount', $coreHelper->currency(
319
- $weeeTaxAttribute->getAmount(), true, false
320
  ));
321
  }
322
- $priceXmlObj->addAttribute('special_including_tax', $coreHelper->currency(
323
- $finalPriceInclTax + $weeeTaxAmount, true, false
324
  ));
325
  } else {
326
  /**
327
  * Excluding
328
  */
329
- $priceXmlObj->addAttribute('regular', $coreHelper->currency($regularPrice, true, false));
330
- if ($taxHelper->displayBothPrices()) {
331
  $priceXmlObj->addAttribute(
332
- 'special_excluding_tax', $coreHelper->currency($finalPrice, true, false)
333
  );
334
  $priceXmlObj->addAttribute(
335
- 'special_including_tax', $coreHelper->currency($finalPriceInclTax, true, false)
336
  );
337
  } else {
338
  $priceXmlObj->addAttribute(
339
- 'special', $coreHelper->currency($finalPrice, true, false)
340
  );
341
  }
342
  }
343
  }
344
 
345
- if ($this->getDisplayMinimalPrice() && $minimalPriceValue
346
- && $minimalPriceValue < $product->getFinalPrice()
 
347
  ) {
348
- $minimalPriceDisplayValue = $minimalPrice;
349
 
350
- if ($weeeTaxAmount && $weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
351
- $minimalPriceDisplayValue = $minimalPrice + $weeeTaxAmount;
352
  }
353
 
354
  if (!$this->getUseLinkForAsLowAs()) {
355
- $priceXmlObj->addAttribute('as_low_as', $coreHelper->currency(
356
- $minimalPriceDisplayValue, true, false
357
  ));
358
  }
359
  }
@@ -361,23 +362,23 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Default extends Mage_Catalog_B
361
  * if (!$product->isGrouped()) {
362
  */
363
  } else {
364
- $exclTax = $taxHelper->getPrice($product, $minimalPriceValue, null);
365
- $inclTax = $taxHelper->getPrice($product, $minimalPriceValue, true);
366
 
367
- if ($this->getDisplayMinimalPrice() && $minimalPriceValue) {
368
- if ($taxHelper->displayBothPrices()) {
369
- $priceXmlObj->addAttribute('starting_at_excluding_tax', $coreHelper->currency(
370
- $exclTax, true, false
371
  ));
372
- $priceXmlObj->addAttribute('starting_at_including_tax', $coreHelper->currency(
373
- $inclTax, true, false
374
  ));
375
  } else {
376
- $showPrice = $inclTax;
377
- if (!$taxHelper->displayPriceIncludingTax()) {
378
- $showPrice = $exclTax;
379
  }
380
- $priceXmlObj->addAttribute('starting_at', $coreHelper->currency($showPrice, true, false));
381
  }
382
  }
383
  }
@@ -410,9 +411,9 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Default extends Mage_Catalog_B
410
  false
411
  );
412
  $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
413
- Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice(
414
- $product, $price['website_price'], true
415
- )),
416
  false
417
  );
418
  $res[] = $price;
@@ -421,15 +422,15 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Default extends Mage_Catalog_B
421
  if ($price['price'] < $product->getPrice()) {
422
  $price['savePercent'] = ceil(100 - ((100 / $product->getPrice()) * $price['price']));
423
  $price['formated_price'] = Mage::app()->getStore()->formatPrice(
424
- Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice(
425
- $product, $price['website_price']
426
- )),
427
  false
428
  );
429
  $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
430
- Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice(
431
- $product, $price['website_price'], true
432
- )),
433
  false
434
  );
435
  $res[] = $price;
@@ -443,169 +444,170 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Default extends Mage_Catalog_B
443
  /**
444
  * Get tier prices (formatted) as array of strings
445
  *
446
- * @param array $tierPrices
447
- * @param Mage_Catalog_Model_Product $product
 
448
  * @return array
449
  */
450
- protected function _getTierPricesTextArray($tierPrices, $product)
451
  {
452
  $pricesArray = array();
453
- if (Mage::helper('weee')->typeOfDisplay($product, array(1, 2, 4))) {
454
- $weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($product);
455
  }
456
 
457
- if ($product->isGrouped()) {
458
- $tierPrices = $this->getTierPrices($product);
459
  }
460
- Mage::helper('weee')->processTierPrices($product, $tierPrices);
461
 
462
- foreach ($tierPrices as $price) {
463
  $s = '';
464
  if ($this->helper('tax')->displayBothPrices()) {
465
- if (Mage::helper('weee')->typeOfDisplay($product, 0)) {
466
- $s .= $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $price['price_qty'], $price['formated_price_incl_weee_only'], $price['formated_price_incl_weee']);
467
- } else if (Mage::helper('weee')->typeOfDisplay($product, 1)) {
468
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee_only']);
469
- if ($weeeTaxAttributes) {
470
- $s .= ' (' . $this->__('%1$s incl tax.', $price['formated_price_incl_weee']);
471
  $separator = ' + ';
472
- foreach ($weeeTaxAttributes as $attribute) {
473
- $s .= $separator . $attribute->getName() . ': ';
474
- $s .= Mage::helper('core')->currency($attribute->getAmount());
475
  }
476
  $s .= ')';
477
  }
478
- $s .= ' ' . $this->__('each');
479
- } else if (Mage::helper('weee')->typeOfDisplay($product, 4)) {
480
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee_only']);
481
- if ($weeeTaxAttributes) {
482
- $s .= ' (' . $this->__('%1$s incl tax.', $price['formated_price_incl_weee']);
483
  $separator = ' + ';
484
- foreach ($weeeTaxAttributes as $attribute) {
485
- $s .= $separator . $attribute->getName() . ': ';
486
  $s .= Mage::helper('core')->currency(
487
- $attribute->getAmount() + $attribute->getTaxAmount()
488
  );
489
  }
490
  $s .= ')';
491
  }
492
- $s .= ' ' . $this->__('each');
493
- } else if (Mage::helper('weee')->typeOfDisplay($product, 2)) {
494
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price']);
495
- if ($weeeTaxAttributes) {
496
- $s .= ' (';
497
- foreach ($weeeTaxAttributes as $attribute) {
498
- $s .= $attribute->getName() . ': ';
499
- $s .= Mage::helper('core')->currency($attribute->getAmount());
500
  }
501
- $s .= ' ' . $this->__('Total incl. Tax: %1$s', $price['formated_price_incl_weee']) . ')';
502
  }
503
- $s .= ' ' . $this->__('each');
504
  } else {
505
- $s .= $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $price['price_qty'], $price['formated_price'], $price['formated_price_incl_tax']);
506
  }
507
  } else {
508
  if ($this->helper('tax')->displayPriceIncludingTax()) {
509
- if (Mage::helper('weee')->typeOfDisplay($product, 0)) {
510
- $s .= $this->__('Buy %1$s for %2$s each', $price['price_qty'], $price['formated_price_incl_weee']);
511
- } else if (Mage::helper('weee')->typeOfDisplay($product, 1)) {
512
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee']);
513
- if ($weeeTaxAttributes) {
514
- $s .= ' (';
515
  $separator = '';
516
- foreach ($weeeTaxAttributes as $attribute) {
517
- $s .= $separator . $attribute->getName() . ': ';
518
- $s .= Mage::helper('core')->currency($attribute->getAmount());
519
  $separator = ' + ';
520
  }
521
  $s .= ')';
522
  }
523
- $s .= ' ' . $this->__('each');
524
- } else if (Mage::helper('weee')->typeOfDisplay($product, 4)) {
525
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee']);
526
- if ($weeeTaxAttributes) {
527
- $s .= ' (';
528
  $separator = '';
529
- foreach ($weeeTaxAttributes as $attribute) {
530
- $s .= $separator . $attribute->getName() . ': ';
531
  $s .= Mage::helper('core')->currency(
532
- $attribute->getAmount() + $attribute->getTaxAmount()
533
  );
534
  $separator = ' + ';
535
  }
536
  $s .= ')';
537
  }
538
- $s .= ' ' . $this->__('each');
539
- } else if (Mage::helper('weee')->typeOfDisplay($product, 2)) {
540
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_tax']);
541
- if ($weeeTaxAttributes) {
542
- $s .= ' (';
543
- foreach ($weeeTaxAttributes as $attribute) {
544
- $s .= $attribute->getName() . ': ';
545
- $s .= Mage::helper('core')->currency($attribute->getAmount());
546
  }
547
- $s .= ' ' . $this->__('Total incl. Tax: %1$s', $price['formated_price_incl_weee']) . ')';
548
  }
549
- $s .= ' ' . $this->__('each');
550
  } else {
551
- $s .= $this->__('Buy %1$s for %2$s each', $price['price_qty'], $price['formated_price_incl_tax']);
552
  }
553
  } else {
554
- if (Mage::helper('weee')->typeOfDisplay($product, 0)) {
555
- $s .= $this->__('Buy %1$s for %2$s each', $price['price_qty'], $price['formated_price_incl_weee_only']);
556
- } else if (Mage::helper('weee')->typeOfDisplay($product, 1)) {
557
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee_only']);
558
- if ($weeeTaxAttributes) {
559
- $s .= ' (';
560
  $separator = '';
561
- foreach ($weeeTaxAttributes as $attribute) {
562
- $s .= $separator . $attribute->getName() . ': ';
563
- $s .= Mage::helper('core')->currency($attribute->getAmount());
564
  $separator = ' + ';
565
  }
566
  $s .= ')';
567
  }
568
- $s .= ' ' . $this->__('each');
569
- } else if (Mage::helper('weee')->typeOfDisplay($product, 4)) {
570
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price_incl_weee_only']);
571
- if ($weeeTaxAttributes) {
572
- $s .= ' (';
573
  $separator = '';
574
- foreach ($weeeTaxAttributes as $attribute) {
575
- $s .= $separator . $attribute->getName() . ': ';
576
  $s .= Mage::helper('core')->currency(
577
- $attribute->getAmount() + $attribute->getTaxAmount()
578
  );
579
  $separator = ' + ';
580
  }
581
  $s .= ')';
582
  }
583
- $s .= ' ' . $this->__('each');
584
- } else if (Mage::helper('weee')->typeOfDisplay($product, 2)) {
585
- $s .= $this->__('Buy %1$s for %2$s', $price['price_qty'], $price['formated_price']);
586
- if ($weeeTaxAttributes) {
587
- $s .= ' (';
588
- foreach ($weeeTaxAttributes as $attribute) {
589
- $s .= $attribute->getName() . ': ';
590
- $s .= Mage::helper('core')->currency($attribute->getAmount());
591
  }
592
- $s .= ' ' . $this->__('Total incl. Tax: %1$s', $price['formated_price_incl_weee_only']) . ')';
593
  }
594
- $s .= ' ' . $this->__('each');
595
  } else {
596
- $s .= $this->__('Buy %1$s for %2$s each', $price['price_qty'], $price['formated_price']);
597
  }
598
  }
599
  }
600
- if (!$product->isGrouped()) {
601
- $condition1 = ($product->getPrice() == $product->getFinalPrice()
602
- && $product->getPrice() > $price['price']);
603
 
604
- $condition2 = ($product->getPrice() != $product->getFinalPrice()
605
- && $product->getFinalPrice() > $price['price']);
606
 
607
  if ($condition1 || $condition2) {
608
- $s .= ' ' . $this->__('and') . ' ' . $this->__('save') . ' ' . $price['savePercent'] . '%';
609
  }
610
  }
611
  $pricesArray[] = $s;
39
  * @param Mage_Catalog_Model_Product $product
40
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
41
  */
42
+ public function collectProductPrices(
43
+ Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item
44
+ ) {
45
  $this->setProduct($product)->setDisplayMinimalPrice(true)->setUseLinkForAsLowAs(false);
46
 
47
  $priceXmlObj = $item->addChild('price');
48
+ $_tierPrices = $this->_getTierPrices($product);
49
+ if (count($_tierPrices) > 0) {
50
+ $tierPricesTextArray = $this->_getTierPricesTextArray($_tierPrices, $product);
51
+ $item->addChild('price_tier', implode(PHP_EOL, $tierPricesTextArray));
 
 
52
  }
53
 
54
+ /** @var $_coreHelper Mage_Core_Helper_Data */
55
+ $_coreHelper = $this->helper('core');
56
+ /** @var $_weeeHelper Mage_Weee_Helper_Data */
57
+ $_weeeHelper = $this->helper('weee');
58
+ /** @var $_taxHelper Mage_Tax_Helper_Data */
59
+ $_taxHelper = $this->helper('tax');
60
 
61
+ $_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
62
+ $_minimalPriceValue = $product->getMinimalPrice();
63
+ $_minimalPrice = $_taxHelper->getPrice($product, $_minimalPriceValue, $_simplePricesTax);
64
 
65
  if (!$product->isGrouped()) {
66
+ $_weeeTaxAmount = $_weeeHelper->getAmountForDisplay($product);
67
+ if ($_weeeHelper->typeOfDisplay($product, array(1, 2, 4))) {
68
+ $_weeeTaxAmount = $_weeeHelper->getAmount($product);
69
+ $_weeeTaxAttributes = $_weeeHelper->getProductWeeeAttributesForDisplay($product);
70
  }
71
 
72
+ $_price = $_taxHelper->getPrice($product, $product->getPrice());
73
+ $_regularPrice = $_taxHelper->getPrice($product, $product->getPrice(), $_simplePricesTax);
74
+ $_finalPrice = $_taxHelper->getPrice($product, $product->getFinalPrice());
75
+ $_finalPriceInclTax = $_taxHelper->getPrice($product, $product->getFinalPrice(), true);
76
+ $_weeeHelper->getPriceDisplayType();
77
+ if ($_finalPrice == $_price) {
78
+ if ($_taxHelper->displayBothPrices()) {
79
  /**
80
  * Including
81
  */
82
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 0)) {
83
  $priceXmlObj->addAttribute(
84
+ 'excluding_tax', $_coreHelper->currency($_price + $_weeeTaxAmount, true, false)
85
  );
86
  $priceXmlObj->addAttribute(
87
+ 'including_tax', $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmount, true, false)
88
  );
89
+ } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 1)) {
90
  /**
91
  * Including + Weee
92
  */
93
  $priceXmlObj->addAttribute(
94
+ 'excluding_tax', $_coreHelper->currency($_price + $_weeeTaxAmount, true, false)
95
  );
96
  $priceXmlObj->addAttribute(
97
+ 'including_tax', $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmount, true, false)
98
  );
99
  $weeeXmlObj = $priceXmlObj->addChild('weee');
100
+ $_weeeSeparator = ' + ';
101
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
102
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
103
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
104
  $weeeItemXmlObj->addAttribute(
105
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
106
  );
107
  $weeeItemXmlObj->addAttribute(
108
+ 'amount', $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false)
109
  );
110
  }
111
+ } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 4)) {
112
  /**
113
  * Including + Weee
114
  */
115
  $priceXmlObj->addAttribute(
116
+ 'excluding_tax', $_coreHelper->currency($_price + $_weeeTaxAmount, true, false)
117
  );
118
  $priceXmlObj->addAttribute(
119
+ 'including_tax', $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmount, true, false)
120
  );
121
  $weeeXmlObj = $priceXmlObj->addChild('weee');
122
+ $_weeeSeparator = ' + ';
123
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
124
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
125
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
126
  $weeeItemXmlObj->addAttribute(
127
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
128
  );
129
+ $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
130
+ $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, false
131
  ));
132
  }
133
+ } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 2)) {
134
  /**
135
  * Excluding + Weee + Final
136
  */
137
+ $priceXmlObj->addAttribute('excluding_tax', $_coreHelper->currency($_price, true, false));
138
  $weeeXmlObj = $priceXmlObj->addChild('weee');
139
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
140
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
141
  $weeeItemXmlObj->addAttribute(
142
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
143
  );
144
  $weeeItemXmlObj->addAttribute(
145
+ 'amount', $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false)
146
  );
147
  }
148
+ $priceXmlObj->addAttribute('including_tax', $_coreHelper->currency(
149
+ $_finalPriceInclTax + $_weeeTaxAmount, true, false
150
  ));
151
  } else {
152
+ $priceXmlObj->addAttribute('excluding_tax', $_coreHelper->currency($_price, true, false));
153
  $priceXmlObj->addAttribute(
154
+ 'including_tax', $_coreHelper->currency($_finalPriceInclTax, true, false)
155
  );
156
  }
157
  /**
158
+ * if ($_taxHelper->displayBothPrices()) {
159
  */
160
  } else {
161
  /**
162
  * Including
163
  */
164
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 0)) {
165
+ $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
166
+ $_price + $_weeeTaxAmount, true, false
167
  ));
168
+ } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 1)) {
169
  /**
170
  * Including + Weee
171
  */
172
+ $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
173
+ $_price + $_weeeTaxAmount, true, false
174
  ));
175
  $weeeXmlObj = $priceXmlObj->addChild('weee');
176
+ $_weeeSeparator = ' + ';
177
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
178
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
179
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
180
  $weeeItemXmlObj->addAttribute(
181
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
182
  );
183
  $weeeItemXmlObj->addAttribute(
184
+ 'amount', $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false)
185
  );
186
  }
187
+ } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 4)) {
188
  /**
189
  * Including + Weee
190
  */
191
+ $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
192
+ $_price + $_weeeTaxAmount, true, false
193
  ));
194
  $weeeXmlObj = $priceXmlObj->addChild('weee');
195
+ $_weeeSeparator = ' + ';
196
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
197
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
198
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
199
  $weeeItemXmlObj->addAttribute(
200
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
201
  );
202
+ $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
203
+ $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, false
204
  ));
205
  }
206
+ } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 2)) {
207
  /**
208
  * Excluding + Weee + Final
209
  */
210
+ $priceXmlObj->addAttribute(
211
+ 'regular', $_coreHelper->currency($_price, true, false)
212
+ );
213
  $weeeXmlObj = $priceXmlObj->addChild('weee');
214
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
215
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
216
  $weeeItemXmlObj->addAttribute(
217
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
218
  );
219
  $weeeItemXmlObj->addAttribute(
220
+ 'amount', $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, false)
221
  );
222
  }
223
  $priceXmlObj->addAttribute(
224
+ 'including_tax', $_coreHelper->currency($_price + $_weeeTaxAmount, true, false)
225
  );
226
  } else {
227
+ $priceXmlObj->addAttribute('regular', $_coreHelper->currency($_price, true, false));
228
  }
229
  }
230
  /**
231
+ * if ($_finalPrice == $_price) {
232
  */
233
  } else {
234
+ $_originalWeeeTaxAmount = $_weeeHelper->getOriginalAmount($product);
235
  /**
236
  * Including
237
  */
238
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 0)) {
239
+ $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
240
+ $_regularPrice + $_originalWeeeTaxAmount, true, false
241
  ));
242
+ if ($_taxHelper->displayBothPrices()) {
243
+ $priceXmlObj->addAttribute('special_excluding_tax', $_coreHelper->currency(
244
+ $_finalPrice + $_weeeTaxAmount, true, false
245
  ));
246
+ $priceXmlObj->addAttribute('special_including_tax', $_coreHelper->currency(
247
+ $_finalPriceInclTax + $_weeeTaxAmount, true, false
248
  ));
249
  } else {
250
+ $priceXmlObj->addAttribute('special', $_coreHelper->currency(
251
+ $_finalPrice + $_weeeTaxAmount, true, false
252
  ));
253
  }
254
+ } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 1)) {
255
  /**
256
  * Including + Weee
257
  */
258
+ $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
259
+ $_regularPrice + $_originalWeeeTaxAmount, true, false
260
  ));
261
+ $priceXmlObj->addAttribute('special_excluding_tax', $_coreHelper->currency(
262
+ $_finalPrice + $_weeeTaxAmount, true, false
263
  ));
264
  $weeeXmlObj = $priceXmlObj->addChild('weee');
265
+ $_weeeSeparator = ' + ';
266
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
267
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
268
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
269
  $weeeItemXmlObj->addAttribute(
270
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
271
  );
272
+ $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
273
+ $_weeeTaxAttribute->getAmount(), true, false
274
  ));
275
  }
276
+ $priceXmlObj->addAttribute('special_including_tax', $_coreHelper->currency(
277
+ $_finalPriceInclTax + $_weeeTaxAmount, true, false
278
  ));
279
+ } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 4)) {
280
  /**
281
  * Including + Weee
282
  */
283
+ $priceXmlObj->addAttribute('regular', $_coreHelper->currency(
284
+ $_regularPrice + $_originalWeeeTaxAmount, true, false
285
  ));
286
+ $priceXmlObj->addAttribute('special_excluding_tax', $_coreHelper->currency(
287
+ $_finalPrice + $_weeeTaxAmount, true, false
288
  ));
289
  $weeeXmlObj = $priceXmlObj->addChild('weee');
290
+ $_weeeSeparator = ' + ';
291
+ $weeeXmlObj->addAttribute('separator', $_weeeSeparator);
292
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
293
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
294
  $weeeItemXmlObj->addAttribute(
295
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
296
  );
297
+ $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
298
+ $_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, false
299
  ));
300
  }
301
+ $priceXmlObj->addAttribute('special_including_tax', $_coreHelper->currency(
302
+ $_finalPriceInclTax + $_weeeTaxAmount, true, false
303
  ));
304
+ } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, 2)) {
305
  /**
306
  * Excluding + Weee + Final
307
  */
308
+ $priceXmlObj->addAttribute('regular', $_coreHelper->currency($_regularPrice, true, false));
309
  $priceXmlObj->addAttribute(
310
+ 'special_excluding_tax', $_coreHelper->currency($_finalPrice, true, false)
311
  );
312
  $weeeXmlObj = $priceXmlObj->addChild('weee');
313
+ foreach ($_weeeTaxAttributes as $_weeeTaxAttribute) {
314
  $weeeItemXmlObj = $weeeXmlObj->addChild('item');
315
  $weeeItemXmlObj->addAttribute(
316
+ 'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
317
  );
318
+ $weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency(
319
+ $_weeeTaxAttribute->getAmount(), true, false
320
  ));
321
  }
322
+ $priceXmlObj->addAttribute('special_including_tax', $_coreHelper->currency(
323
+ $_finalPriceInclTax + $_weeeTaxAmount, true, false
324
  ));
325
  } else {
326
  /**
327
  * Excluding
328
  */
329
+ $priceXmlObj->addAttribute('regular', $_coreHelper->currency($_regularPrice, true, false));
330
+ if ($_taxHelper->displayBothPrices()) {
331
  $priceXmlObj->addAttribute(
332
+ 'special_excluding_tax', $_coreHelper->currency($_finalPrice, true, false)
333
  );
334
  $priceXmlObj->addAttribute(
335
+ 'special_including_tax', $_coreHelper->currency($_finalPriceInclTax, true, false)
336
  );
337
  } else {
338
  $priceXmlObj->addAttribute(
339
+ 'special', $_coreHelper->currency($_finalPrice, true, false)
340
  );
341
  }
342
  }
343
  }
344
 
345
+ if ($this->getDisplayMinimalPrice()
346
+ && $_minimalPriceValue
347
+ && $_minimalPriceValue < $product->getFinalPrice()
348
  ) {
349
+ $_minimalPriceDisplayValue = $_minimalPrice;
350
 
351
+ if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($product, array(0, 1, 4))) {
352
+ $_minimalPriceDisplayValue = $_minimalPrice + $_weeeTaxAmount;
353
  }
354
 
355
  if (!$this->getUseLinkForAsLowAs()) {
356
+ $priceXmlObj->addAttribute('as_low_as', $_coreHelper->currency(
357
+ $_minimalPriceDisplayValue, true, false
358
  ));
359
  }
360
  }
362
  * if (!$product->isGrouped()) {
363
  */
364
  } else {
365
+ $_exclTax = $_taxHelper->getPrice($product, $_minimalPriceValue, null);
366
+ $_inclTax = $_taxHelper->getPrice($product, $_minimalPriceValue, true);
367
 
368
+ if ($this->getDisplayMinimalPrice() && $_minimalPriceValue) {
369
+ if ($_taxHelper->displayBothPrices()) {
370
+ $priceXmlObj->addAttribute('starting_at_excluding_tax', $_coreHelper->currency(
371
+ $_exclTax, true, false
372
  ));
373
+ $priceXmlObj->addAttribute('starting_at_including_tax', $_coreHelper->currency(
374
+ $_inclTax, true, false
375
  ));
376
  } else {
377
+ $_showPrice = $_inclTax;
378
+ if (!$_taxHelper->displayPriceIncludingTax()) {
379
+ $_showPrice = $_exclTax;
380
  }
381
+ $priceXmlObj->addAttribute('starting_at', $_coreHelper->currency($_showPrice, true, false));
382
  }
383
  }
384
  }
411
  false
412
  );
413
  $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
414
+ Mage::app()->getStore()->convertPrice(
415
+ Mage::helper('tax')->getPrice($product, $price['website_price'], true)
416
+ ),
417
  false
418
  );
419
  $res[] = $price;
422
  if ($price['price'] < $product->getPrice()) {
423
  $price['savePercent'] = ceil(100 - ((100 / $product->getPrice()) * $price['price']));
424
  $price['formated_price'] = Mage::app()->getStore()->formatPrice(
425
+ Mage::app()->getStore()->convertPrice(
426
+ Mage::helper('tax')->getPrice($product, $price['website_price'])
427
+ ),
428
  false
429
  );
430
  $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(
431
+ Mage::app()->getStore()->convertPrice(
432
+ Mage::helper('tax')->getPrice($product, $price['website_price'], true)
433
+ ),
434
  false
435
  );
436
  $res[] = $price;
444
  /**
445
  * Get tier prices (formatted) as array of strings
446
  *
447
+ * @param array $_tierPrices
448
+ * @param Mage_Catalog_Model_Product $_product
449
+ *
450
  * @return array
451
  */
452
+ protected function _getTierPricesTextArray($_tierPrices, $_product)
453
  {
454
  $pricesArray = array();
455
+ if (Mage::helper('weee')->typeOfDisplay($_product, array(1, 2, 4))) {
456
+ $_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($_product);
457
  }
458
 
459
+ if ($_product->isGrouped()) {
460
+ $_tierPrices = $this->getTierPrices($_product);
461
  }
462
+ Mage::helper('weee')->processTierPrices($_product, $_tierPrices);
463
 
464
+ foreach ($_tierPrices as $_price) {
465
  $s = '';
466
  if ($this->helper('tax')->displayBothPrices()) {
467
+ if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {
468
+ $s .= $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price_incl_weee_only'], $_price['formated_price_incl_weee']);
469
+ } else if (Mage::helper('weee')->typeOfDisplay($_product, 1)) {
470
+ $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
471
+ if ($_weeeTaxAttributes) {
472
+ $s .= '(' . $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']);
473
  $separator = ' + ';
474
+ foreach ($_weeeTaxAttributes as $_attribute) {
475
+ $s .= $separator . $_attribute->getName() . ': ';
476
+ $s .= Mage::helper('core')->currency($_attribute->getAmount());
477
  }
478
  $s .= ')';
479
  }
480
+ $s .= $this->__('each');
481
+ } else if (Mage::helper('weee')->typeOfDisplay($_product, 4)) {
482
+ $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
483
+ if ($_weeeTaxAttributes) {
484
+ $s .= '(' . $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']);
485
  $separator = ' + ';
486
+ foreach ($_weeeTaxAttributes as $_attribute) {
487
+ $s .= $separator . $_attribute->getName() . ': ';
488
  $s .= Mage::helper('core')->currency(
489
+ $_attribute->getAmount() + $_attribute->getTaxAmount()
490
  );
491
  }
492
  $s .= ')';
493
  }
494
+ $s .= $this->__('each');
495
+ } else if (Mage::helper('weee')->typeOfDisplay($_product, 2)) {
496
+ $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);
497
+ if ($_weeeTaxAttributes) {
498
+ $s .= '(';
499
+ foreach ($_weeeTaxAttributes as $_attribute) {
500
+ $s .= $_attribute->getName() . ': ';
501
+ $s .= Mage::helper('core')->currency($_attribute->getAmount());
502
  }
503
+ $s .= $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']) . ')';
504
  }
505
+ $s .= $this->__('each');
506
  } else {
507
+ $s .= $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price'], $_price['formated_price_incl_tax']);
508
  }
509
  } else {
510
  if ($this->helper('tax')->displayPriceIncludingTax()) {
511
+ if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {
512
+ $s .= $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee']);
513
+ } else if (Mage::helper('weee')->typeOfDisplay($_product, 1)) {
514
+ $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);
515
+ if ($_weeeTaxAttributes) {
516
+ $s .= '(';
517
  $separator = '';
518
+ foreach ($_weeeTaxAttributes as $_attribute) {
519
+ $s .= $separator . $_attribute->getName() . ': ';
520
+ $s .= Mage::helper('core')->currency($_attribute->getAmount());
521
  $separator = ' + ';
522
  }
523
  $s .= ')';
524
  }
525
+ $s .= $this->__('each');
526
+ } else if (Mage::helper('weee')->typeOfDisplay($_product, 4)) {
527
+ $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);
528
+ if ($_weeeTaxAttributes) {
529
+ $s .= '(';
530
  $separator = '';
531
+ foreach ($_weeeTaxAttributes as $_attribute) {
532
+ $s .= $separator . $_attribute->getName() . ': ';
533
  $s .= Mage::helper('core')->currency(
534
+ $_attribute->getAmount() + $_attribute->getTaxAmount()
535
  );
536
  $separator = ' + ';
537
  }
538
  $s .= ')';
539
  }
540
+ $s .= $this->__('each');
541
+ } else if (Mage::helper('weee')->typeOfDisplay($_product, 2)) {
542
+ $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_tax']);
543
+ if ($_weeeTaxAttributes) {
544
+ $s .= '(';
545
+ foreach ($_weeeTaxAttributes as $_attribute) {
546
+ $s .= $_attribute->getName() . ': ';
547
+ $s .= Mage::helper('core')->currency($_attribute->getAmount());
548
  }
549
+ $s .= $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']) . ')';
550
  }
551
+ $s .= $this->__('each');
552
  } else {
553
+ $s .= $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_tax']);
554
  }
555
  } else {
556
+ if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {
557
+ $s .= $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
558
+ } else if (Mage::helper('weee')->typeOfDisplay($_product, 1)) {
559
+ $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
560
+ if ($_weeeTaxAttributes) {
561
+ $s .= '(';
562
  $separator = '';
563
+ foreach ($_weeeTaxAttributes as $_attribute) {
564
+ $s .= $separator . $_attribute->getName() . ': ';
565
+ $s .= Mage::helper('core')->currency($_attribute->getAmount());
566
  $separator = ' + ';
567
  }
568
  $s .= ')';
569
  }
570
+ $s .= $this->__('each');
571
+ } else if (Mage::helper('weee')->typeOfDisplay($_product, 4)) {
572
+ $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);
573
+ if ($_weeeTaxAttributes) {
574
+ $s .= '(';
575
  $separator = '';
576
+ foreach ($_weeeTaxAttributes as $_attribute) {
577
+ $s .= $separator . $_attribute->getName() . ': ';
578
  $s .= Mage::helper('core')->currency(
579
+ $_attribute->getAmount() + $_attribute->getTaxAmount()
580
  );
581
  $separator = ' + ';
582
  }
583
  $s .= ')';
584
  }
585
+ $s .= $this->__('each');
586
+ } else if (Mage::helper('weee')->typeOfDisplay($_product, 2)) {
587
+ $s .= $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);
588
+ if ($_weeeTaxAttributes) {
589
+ $s .= '(';
590
+ foreach ($_weeeTaxAttributes as $_attribute) {
591
+ $s .= $_attribute->getName() . ': ';
592
+ $s .= Mage::helper('core')->currency($_attribute->getAmount());
593
  }
594
+ $s .= $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee_only']) . ')';
595
  }
596
+ $s .= $this->__('each');
597
  } else {
598
+ $s .= $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price']);
599
  }
600
  }
601
  }
602
+ if (!$_product->isGrouped()) {
603
+ $condition1 = ($_product->getPrice() == $_product->getFinalPrice()
604
+ && $_product->getPrice() > $_price['price']);
605
 
606
+ $condition2 = ($_product->getPrice() != $_product->getFinalPrice()
607
+ && $_product->getFinalPrice() > $_price['price']);
608
 
609
  if ($condition1 || $condition2) {
610
+ $s .= ' ' . $this->__('and') . ' ' . $this->__('save') . ' ' . $_price['savePercent'] . '%';
611
  }
612
  }
613
  $pricesArray[] = $s;
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Giftcard.php CHANGED
@@ -25,7 +25,7 @@
25
  */
26
 
27
  /**
28
- * Gift card product price xml renderer
29
  *
30
  * @category Mage
31
  * @package Mage_XmlConnect
@@ -68,22 +68,21 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Giftcard extends Mage_Bundle_B
68
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
69
  */
70
  public function collectProductPrices(
71
- Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item
 
72
  ) {
73
  $this->setProduct($product);
74
 
75
  if ($product->getCanShowPrice() !== false) {
76
  $priceXmlObj = $item->addChild('price');
77
 
78
- $min = $this->getMinAmount();
79
- $max = $this->getMaxAmount();
80
- if ($min && $max && $min == $max) {
81
- $priceXmlObj->addAttribute('regular', Mage::helper('core')->currency($min, true, false));
82
- } else if ($min && $min != 0) {
83
  $priceXmlObj->addAttribute(
84
  'regular',
85
  Mage::helper('enterprise_giftcard')->__('From') . ': '
86
- . Mage::helper('core')->currency($min, true, false)
87
  );
88
  }
89
  }
25
  */
26
 
27
  /**
28
+ * Giftcard product price xml renderer
29
  *
30
  * @category Mage
31
  * @package Mage_XmlConnect
68
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
69
  */
70
  public function collectProductPrices(
71
+ Mage_Catalog_Model_Product $product,
72
+ Mage_XmlConnect_Model_Simplexml_Element $item
73
  ) {
74
  $this->setProduct($product);
75
 
76
  if ($product->getCanShowPrice() !== false) {
77
  $priceXmlObj = $item->addChild('price');
78
 
79
+ if (($_min = $this->getMinAmount()) && ($_max = $this->getMaxAmount()) && ($_min == $_max)) {
80
+ $priceXmlObj->addAttribute('regular', Mage::helper('core')->currency($_min, true, false));
81
+ } elseif (($_min = $this->getMinAmount()) && $_min != 0) {
 
 
82
  $priceXmlObj->addAttribute(
83
  'regular',
84
  Mage::helper('enterprise_giftcard')->__('From') . ': '
85
+ . Mage::helper('core')->currency($_min, true, false)
86
  );
87
  }
88
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Related.php CHANGED
@@ -47,7 +47,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Related extends Mage_XmlConnect_Bloc
47
  $productObj = $this->getParentBlock()->getProduct();
48
 
49
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_TargetRule'))) {
50
- Mage::register('product', $productObj, true);
51
 
52
  $productBlock = $this->getLayout()->addBlock(
53
  'enterprise_targetrule/catalog_product_list_related', 'relatedProducts'
@@ -111,7 +111,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Related extends Mage_XmlConnect_Bloc
111
  */
112
  protected function _getProductCollection()
113
  {
114
- if ($this->_productCollection === null) {
115
  $collection = $this->getParentBlock()->getProduct()->getRelatedProductCollection();
116
  Mage::getSingleton('catalog/layer')->prepareProductCollection($collection);
117
  /**
47
  $productObj = $this->getParentBlock()->getProduct();
48
 
49
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_TargetRule'))) {
50
+ Mage::register('product', $productObj);
51
 
52
  $productBlock = $this->getLayout()->addBlock(
53
  'enterprise_targetrule/catalog_product_list_related', 'relatedProducts'
111
  */
112
  protected function _getProductCollection()
113
  {
114
+ if (is_null($this->_productCollection)) {
115
  $collection = $this->getParentBlock()->getProduct()->getRelatedProductCollection();
116
  Mage::getSingleton('catalog/layer')->prepareProductCollection($collection);
117
  /**
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review.php CHANGED
@@ -48,7 +48,6 @@ class Mage_XmlConnect_Block_Catalog_Product_Review extends Mage_XmlConnect_Block
48
  public function reviewToXmlObject(Mage_Review_Model_Review $review, $itemNodeName = 'item')
49
  {
50
  $rating = 0;
51
- /** @var $item Mage_XmlConnect_Model_Simplexml_Element */
52
  $item = Mage::getModel('xmlconnect/simplexml_element', '<' . $itemNodeName . '></' . $itemNodeName . '>');
53
  if ($review->getId()) {
54
  $item->addChild('review_id', $review->getId());
48
  public function reviewToXmlObject(Mage_Review_Model_Review $review, $itemNodeName = 'item')
49
  {
50
  $rating = 0;
 
51
  $item = Mage::getModel('xmlconnect/simplexml_element', '<' . $itemNodeName . '></' . $itemNodeName . '>');
52
  if ($review->getId()) {
53
  $item->addChild('review_id', $review->getId());
app/code/core/Mage/XmlConnect/Block/Catalog/Search.php CHANGED
@@ -35,7 +35,7 @@ class Mage_XmlConnect_Block_Catalog_Search extends Mage_XmlConnect_Block_Catalog
35
  {
36
  /**
37
  * Search results xml renderer
38
- * XML also contains filters that can be apply (accordingly already applied filters
39
  * and search query) and sort fields
40
  *
41
  * @return string
@@ -79,8 +79,8 @@ class Mage_XmlConnect_Block_Catalog_Search extends Mage_XmlConnect_Block_Catalog
79
  $showFiltersAndOrders = (bool) count($productsXmlObj);
80
  $requestParams = $this->getRequest()->getParams();
81
  foreach ($requestParams as $key => $value) {
82
- if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_PREFIX)
83
- || 0 === strpos($key, parent::REQUEST_FILTER_PARAM_PREFIX)
84
  ) {
85
  $showFiltersAndOrders = false;
86
  break;
@@ -118,7 +118,7 @@ class Mage_XmlConnect_Block_Catalog_Search extends Mage_XmlConnect_Block_Catalog
118
  * Sort fields
119
  */
120
  if ($showFiltersAndOrders) {
121
- $searchXmlObject->appendChild($this->getSearchProductSortFieldsXmlObject());
122
  }
123
 
124
  return $searchXmlObject->asNiceXml();
35
  {
36
  /**
37
  * Search results xml renderer
38
+ * XML also contains filters that can be apply (accorfingly already applyed filters
39
  * and search query) and sort fields
40
  *
41
  * @return string
79
  $showFiltersAndOrders = (bool) count($productsXmlObj);
80
  $requestParams = $this->getRequest()->getParams();
81
  foreach ($requestParams as $key => $value) {
82
+ if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_REFIX)
83
+ || 0 === strpos($key, parent::REQUEST_FILTER_PARAM_REFIX)
84
  ) {
85
  $showFiltersAndOrders = false;
86
  break;
118
  * Sort fields
119
  */
120
  if ($showFiltersAndOrders) {
121
+ $searchXmlObject->appendChild($this->getProductSortFeildsXmlObject());
122
  }
123
 
124
  return $searchXmlObject->asNiceXml();
app/code/core/Mage/XmlConnect/Block/Catalog/Search/Suggest.php CHANGED
@@ -45,7 +45,6 @@ class Mage_XmlConnect_Block_Catalog_Search_Suggest extends Mage_CatalogSearch_Bl
45
  */
46
  protected function _toHtml()
47
  {
48
- /** @var $suggestXmlObj Mage_XmlConnect_Model_Simplexml_Element */
49
  $suggestXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<suggestions></suggestions>');
50
 
51
  if (!$this->getRequest()->getParam(Mage_CatalogSearch_Helper_Data::QUERY_VAR_NAME, false)) {
45
  */
46
  protected function _toHtml()
47
  {
 
48
  $suggestXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<suggestions></suggestions>');
49
 
50
  if (!$this->getRequest()->getParam(Mage_CatalogSearch_Helper_Data::QUERY_VAR_NAME, false)) {
app/code/core/Mage/XmlConnect/Block/Checkout/Address/Billing.php CHANGED
@@ -40,7 +40,6 @@ class Mage_XmlConnect_Block_Checkout_Address_Billing extends Mage_Checkout_Block
40
  */
41
  protected function _toHtml()
42
  {
43
- /** @var $billingXmlObj Mage_XmlConnect_Model_Simplexml_Element */
44
  $billingXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<billing></billing>');
45
 
46
  $addressId = $this->getAddress()->getId();
@@ -55,7 +54,9 @@ class Mage_XmlConnect_Block_Checkout_Address_Billing extends Mage_Checkout_Block
55
  $item->addAttribute('selected', 1);
56
  }
57
  $this->getChild('address_list')->prepareAddressData($address, $item);
58
- $item->addChild('address_line', $billingXmlObj->escapeXml($address->format('oneline')));
 
 
59
  }
60
 
61
  return $billingXmlObj->asNiceXml();
40
  */
41
  protected function _toHtml()
42
  {
 
43
  $billingXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<billing></billing>');
44
 
45
  $addressId = $this->getAddress()->getId();
54
  $item->addAttribute('selected', 1);
55
  }
56
  $this->getChild('address_list')->prepareAddressData($address, $item);
57
+ $item->addChild(
58
+ 'address_line', $billingXmlObj->escapeXml($address->format('oneline'))
59
+ );
60
  }
61
 
62
  return $billingXmlObj->asNiceXml();
app/code/core/Mage/XmlConnect/Block/Checkout/Address/Form.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Checkout_Address_Form extends Mage_Core_Block_Abstract
35
  {
36
  /**
37
  * Render customer address form xml
@@ -40,82 +40,134 @@ class Mage_XmlConnect_Block_Checkout_Address_Form extends Mage_Core_Block_Abstra
40
  */
41
  protected function _toHtml()
42
  {
43
- $addressType = $this->getType() ? $this->getType() : 'billing';
44
-
45
- $action = Mage::helper('xmlconnect')->getActionUrl('xmlconnect/checkout/savebillingaddress');
46
-
47
- /** @var Mage_XmlConnect_Model_Simplexml_Form $fromXmlObj */
48
- $fromXmlObj = Mage::getModel('xmlconnect/simplexml_form', array(
49
- 'xml_id' => 'address_form', 'action' => $action, 'use_container' => true
50
- ))->setFieldNameSuffix($addressType);
 
51
 
52
  $isAllowedGuestCheckout = Mage::getSingleton('checkout/session')->getQuote()->isAllowedGuestCheckout();
53
 
54
- $fromXmlObj->addField('firstname', 'text', array(
55
- 'name' => 'firstname', 'label' => $this->__('First Name'), 'required' => 'true'
 
 
 
 
56
  ));
57
 
58
- $fromXmlObj->addField('lastname', 'text', array(
59
- 'name' => 'lastname', 'label' => $this->__('Last Name'), 'required' => 'true'
 
 
60
  ));
61
 
62
- $fromXmlObj->addField('company', 'text', array('name' => 'company', 'label' => $this->__('Company')));
 
 
 
 
63
 
64
  if ($isAllowedGuestCheckout && !Mage::getSingleton('customer/session')->isLoggedIn()
65
  && $addressType == 'billing'
66
  ) {
67
- $fromXmlObj->addField('email', 'text', array(
68
- 'name' => 'email', 'label' => $this->__('Email Address'), 'required' => 'true'
69
- ))->addValidator()->addRule(array('type' => 'email', 'message' => 'Wrong email format'));
 
 
 
 
 
70
  }
71
 
72
- $fromXmlObj->addField('street', 'text', array(
73
- 'name' => 'street[]', 'label' => $this->__('Address'), 'required' => 'true'
 
 
74
  ));
75
 
76
- $fromXmlObj->addField('street_2', 'text', array('name' => 'street[]', 'label' => $this->__('Address 2')));
77
-
78
- $fromXmlObj->addField('city', 'text', array(
79
- 'name' => 'city', 'label' => $this->__('City'), 'required' => 'true'
80
  ));
81
 
82
- $fromXmlObj->addField('country_id', 'countryListSelect', array(
83
- 'name' => 'country_id', 'label' => $this->__('Country'), 'required' => 'true', 'old_format' => true
 
 
84
  ));
85
 
86
- $fromXmlObj->addField('region', 'text', array('name' => 'region', 'label' => $this->__('State/Province')));
 
 
 
 
 
 
 
87
 
88
- $fromXmlObj->addField('region_id', 'select', array(
89
- 'name' => 'region_id', 'label' => $this->__('State/Province'), 'required' => 'true'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  ));
91
 
92
- $fromXmlObj->addField('postcode', 'text', array(
93
- 'name' => 'postcode', 'label' => $this->__('Zip/Postal Code'), 'required' => 'true'
 
 
94
  ));
95
 
96
- $fromXmlObj->addField('telephone', 'text', array(
97
- 'name' => 'telephone', 'label' => $this->__('Telephone'), 'required' => 'true'
 
 
98
  ));
99
 
100
- $fromXmlObj->addField('fax', 'text', array('name' => 'fax', 'label' => $this->__('Fax')));
 
 
 
 
101
 
102
- $fromXmlObj->addField('save_in_address_book', 'checkbox', array(
103
- 'name' => 'save_in_address_book','label' => $this->__('Save in address book')
 
104
  ));
105
 
106
- // Add custom address attributes
107
- Mage::helper('xmlconnect/customer_form_renderer')
108
- ->setAttributesBlockName('customer_form_billing_address_user_defined_attributes')
109
- ->setFormCode('customer_register_address')->setBlockEntity(Mage::getModel('customer/address'))
110
- ->addCustomAttributes($fromXmlObj, $this->getLayout(), $addressType);
111
 
112
- return $fromXmlObj->getXml();
113
  }
114
 
115
  /**
116
  * Retrieve regions by country
117
  *
118
- * @deprecated will delete in the next version
119
  * @param string $countryId
120
  * @return array
121
  */
@@ -139,7 +191,6 @@ class Mage_XmlConnect_Block_Checkout_Address_Form extends Mage_Core_Block_Abstra
139
  /**
140
  * Retrieve countries
141
  *
142
- * @deprecated will delete in the next version
143
  * @return array
144
  */
145
  protected function _getCountryOptions()
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Checkout_Address_Form extends Mage_Core_Block_Template
35
  {
36
  /**
37
  * Render customer address form xml
40
  */
41
  protected function _toHtml()
42
  {
43
+ /** @var $xmlModel Mage_XmlConnect_Model_Simplexml_Element */
44
+ $xmlModel = Mage::getModel('xmlconnect/simplexml_element', '<form></form>');
45
+ $xmlModel->addAttribute('name', 'address_form');
46
+ $xmlModel->addAttribute('method', 'post');
47
+
48
+ $addressType = $this->getType();
49
+ if (!$addressType) {
50
+ $addressType = 'billing';
51
+ }
52
 
53
  $isAllowedGuestCheckout = Mage::getSingleton('checkout/session')->getQuote()->isAllowedGuestCheckout();
54
 
55
+ $countries = $this->_getCountryOptions();
56
+
57
+ $xmlModel->addField($addressType . '[firstname]', 'text', array(
58
+ 'label' => $this->__('First Name'),
59
+ 'required' => 'true',
60
+ 'value' => ''
61
  ));
62
 
63
+ $xmlModel->addField($addressType . '[lastname]', 'text', array(
64
+ 'label' => $this->__('Last Name'),
65
+ 'required' => 'true',
66
+ 'value' => ''
67
  ));
68
 
69
+ $xmlModel->addField($addressType . '[company]', 'text', array(
70
+ 'label' => $this->__('Company'),
71
+ 'required' => 'true',
72
+ 'value' => ''
73
+ ));
74
 
75
  if ($isAllowedGuestCheckout && !Mage::getSingleton('customer/session')->isLoggedIn()
76
  && $addressType == 'billing'
77
  ) {
78
+ $emailField = $xmlModel->addField($addressType . '[email]', 'text', array(
79
+ 'label' => $this->__('Email Address'),
80
+ 'required' => 'true',
81
+ 'value' => ''
82
+ ));
83
+ $emailValidator = $emailField->addChild('validators')->addChild('validator');
84
+ $emailValidator->addAttribute('type', 'email');
85
+ $emailValidator->addAttribute('message', $this->__('Wrong email format'));
86
  }
87
 
88
+ $xmlModel->addField($addressType . '[street][]', 'text', array(
89
+ 'label' => $this->__('Address'),
90
+ 'required' => 'true',
91
+ 'value' => ''
92
  ));
93
 
94
+ $xmlModel->addField($addressType . '[street][]', 'text', array(
95
+ 'label' => $this->__('Address 2'),
96
+ 'value' => ''
 
97
  ));
98
 
99
+ $xmlModel->addField($addressType . '[city]', 'text', array(
100
+ 'label' => $this->__('City'),
101
+ 'required' => 'true',
102
+ 'value' => ''
103
  ));
104
 
105
+ $countryOptionsXml = $xmlModel->addField($addressType . '[country_id]', 'select', array(
106
+ 'label' => $this->__('Country'),
107
+ 'required' => 'true',
108
+ 'value' => ''
109
+ ))->addChild('values');
110
+
111
+ foreach ($countries as $data) {
112
+ $regions = array();
113
 
114
+ if ($data['value']) {
115
+ $regions = $this->_getRegionOptions($data['value']);
116
+ }
117
+
118
+ $regionStr = (!empty($regions) ? 'region_id' : 'region');
119
+
120
+ $countryXml = $countryOptionsXml->addCustomChild('item', null, array('relation' => $regionStr));
121
+ $countryXml->addCustomChild('label', (string)$data['label']);
122
+ $countryXml->addCustomChild('value', (string)$data['value']);
123
+ if (!empty($regions)) {
124
+ $regionXml = $countryXml->addChild('regions');
125
+ foreach ($regions as $_data) {
126
+ $regionItemXml = $regionXml->addChild('region_item');
127
+ $regionItemXml->addCustomChild('label', (string)$_data['label']);
128
+ $regionItemXml->addCustomChild('value', (string)$_data['value']);
129
+ }
130
+ }
131
+ }
132
+
133
+ $xmlModel->addField($addressType . '[region]', 'text', array(
134
+ 'label' => $this->__('State/Province'),
135
+ 'value' => ''
136
  ));
137
 
138
+ $xmlModel->addField($addressType . '[region_id]', 'select', array(
139
+ 'label' => $this->__('State/Province'),
140
+ 'required' => 'true',
141
+ 'value' => ''
142
  ));
143
 
144
+ $xmlModel->addField($addressType . '[postcode]', 'text', array(
145
+ 'label' => $this->__('Zip/Postal Code'),
146
+ 'required' => 'true',
147
+ 'value' => ''
148
  ));
149
 
150
+ $xmlModel->addField($addressType . '[telephone]', 'text', array(
151
+ 'label' => $this->__('Telephone'),
152
+ 'required' => 'true',
153
+ 'value' => ''
154
+ ));
155
 
156
+ $xmlModel->addField($addressType . '[fax]', 'text', array(
157
+ 'label' => $this->__('Fax'),
158
+ 'value' => ''
159
  ));
160
 
161
+ $xmlModel->addField($addressType . '[save_in_address_book]', 'checkbox', array(
162
+ 'label' => $this->__('Save in address book'),
163
+ ));
 
 
164
 
165
+ return $xmlModel->asNiceXml();
166
  }
167
 
168
  /**
169
  * Retrieve regions by country
170
  *
 
171
  * @param string $countryId
172
  * @return array
173
  */
191
  /**
192
  * Retrieve countries
193
  *
 
194
  * @return array
195
  */
196
  protected function _getCountryOptions()
app/code/core/Mage/XmlConnect/Block/Checkout/Address/Shipping.php CHANGED
@@ -40,7 +40,6 @@ class Mage_XmlConnect_Block_Checkout_Address_Shipping extends Mage_Checkout_Bloc
40
  */
41
  protected function _toHtml()
42
  {
43
- /** @var $shippingXmlObj Mage_XmlConnect_Model_Simplexml_Element */
44
  $shippingXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<shipping></shipping>');
45
 
46
  $addressId = $this->getAddress()->getId();
40
  */
41
  protected function _toHtml()
42
  {
 
43
  $shippingXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<shipping></shipping>');
44
 
45
  $addressId = $this->getAddress()->getId();
app/code/core/Mage/XmlConnect/Block/Checkout/Agreements.php CHANGED
@@ -49,7 +49,7 @@ class Mage_XmlConnect_Block_Checkout_Agreements extends Mage_Checkout_Block_Agre
49
  if (!$agreement->getIsHtml()) {
50
  $content = nl2br($agreementsXmlObj->escapeXml($content));
51
  } else {
52
- $content = $agreementsXmlObj->xmlentities($content);
53
  }
54
  $agreementText = $agreementsXmlObj->escapeXml($agreement->getCheckboxText());
55
  $itemXmlObj->addChild('label', $agreementText);
49
  if (!$agreement->getIsHtml()) {
50
  $content = nl2br($agreementsXmlObj->escapeXml($content));
51
  } else {
52
+ $agreementsXmlObj->xmlentities($content);
53
  }
54
  $agreementText = $agreementsXmlObj->escapeXml($agreement->getCheckboxText());
55
  $itemXmlObj->addChild('label', $agreementText);
app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer.php DELETED
@@ -1,48 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Shopping cart item render block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Checkout_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
35
- {
36
- /**
37
- * Get product thumbnail image
38
- *
39
- * @return Mage_XmlConnect_Helper_Catalog_Product_Image
40
- */
41
- public function getProductThumbnail()
42
- {
43
- if (!is_null($this->_productThumbnail)) {
44
- return $this->_productThumbnail;
45
- }
46
- return $this->helper('xmlconnect/catalog_product_image')->init($this->getProduct(), 'thumbnail');
47
- }
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Bundle.php DELETED
@@ -1,49 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Shopping cart bundle item render block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Checkout_Cart_Item_Renderer_Bundle
35
- extends Mage_Bundle_Block_Checkout_Cart_Item_Renderer
36
- {
37
- /**
38
- * Get product thumbnail image
39
- *
40
- * @return Mage_XmlConnect_Helper_Catalog_Product_Image
41
- */
42
- public function getProductThumbnail()
43
- {
44
- if (!is_null($this->_productThumbnail)) {
45
- return $this->_productThumbnail;
46
- }
47
- return $this->helper('xmlconnect/catalog_product_image')->init($this->getProduct(), 'thumbnail');
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Configurable.php DELETED
@@ -1,53 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Shopping cart configurable item render block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Checkout_Cart_Item_Renderer_Configurable
35
- extends Mage_Checkout_Block_Cart_Item_Renderer_Configurable
36
- {
37
- /**
38
- * Get product thumbnail image
39
- *
40
- * @return Mage_XmlConnect_Helper_Catalog_Product_Image
41
- */
42
- public function getProductThumbnail()
43
- {
44
- $product = $this->getChildProduct();
45
- if (!$product || !$product->getData('thumbnail')
46
- || ($product->getData('thumbnail') == 'no_selection')
47
- || (Mage::getStoreConfig(self::CONFIGURABLE_PRODUCT_IMAGE) == self::USE_PARENT_IMAGE)
48
- ) {
49
- $product = $this->getProduct();
50
- }
51
- return $this->helper('xmlconnect/catalog_product_image')->init($product, 'thumbnail');
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Downloadable.php DELETED
@@ -1,49 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Shopping cart downloadable item render block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Checkout_Cart_Item_Renderer_Downloadable
35
- extends Mage_Downloadable_Block_Checkout_Cart_Item_Renderer
36
- {
37
- /**
38
- * Get product thumbnail image
39
- *
40
- * @return Mage_XmlConnect_Helper_Catalog_Product_Image
41
- */
42
- public function getProductThumbnail()
43
- {
44
- if (!is_null($this->_productThumbnail)) {
45
- return $this->_productThumbnail;
46
- }
47
- return $this->helper('xmlconnect/catalog_product_image')->init($this->getProduct(), 'thumbnail');
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Giftcard.php DELETED
@@ -1,49 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Shopping cart giftcard item render block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Checkout_Cart_Item_Renderer_Giftcard
35
- extends Enterprise_GiftCard_Block_Checkout_Cart_Item_Renderer
36
- {
37
- /**
38
- * Get product thumbnail image
39
- *
40
- * @return Mage_XmlConnect_Helper_Catalog_Product_Image
41
- */
42
- public function getProductThumbnail()
43
- {
44
- if (!is_null($this->_productThumbnail)) {
45
- return $this->_productThumbnail;
46
- }
47
- return $this->helper('xmlconnect/catalog_product_image')->init($this->getProduct(), 'thumbnail');
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Grouped.php DELETED
@@ -1,52 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Shopping cart grouped item render block
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Block_Checkout_Cart_Item_Renderer_Grouped extends Mage_Checkout_Block_Cart_Item_Renderer_Grouped
35
- {
36
- /**
37
- * Get product thumbnail image
38
- *
39
- * @return Mage_XmlConnect_Helper_Catalog_Product_Image
40
- */
41
- public function getProductThumbnail()
42
- {
43
- $product = $this->getProduct();
44
- if (!$product->getData('thumbnail')
45
- ||($product->getData('thumbnail') == 'no_selection')
46
- || (Mage::getStoreConfig(self::GROUPED_PRODUCT_IMAGE) == self::USE_PARENT_IMAGE)
47
- ) {
48
- $product = $this->getGroupedProduct();
49
- }
50
- return $this->helper('xmlconnect/catalog_product_image')->init($product, 'thumbnail');
51
- }
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Address.php DELETED
@@ -1,69 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Customer saved addresses renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Checkout_Onepage_Address extends Mage_Core_Block_Abstract
35
- {
36
- /**
37
- * Save address action
38
- */
39
- const SAVE_ADDRESS_ACTION = 'xmlconnect/checkout/saveaddressinfo';
40
-
41
- /**
42
- * Render customer address form and saved addresses list
43
- *
44
- * @return string
45
- */
46
- protected function _toHtml()
47
- {
48
- /** @var $xmlObj Mage_XmlConnect_Model_Simplexml_Element */
49
- $xmlObj = Mage::getModel('xmlconnect/simplexml_element', '<address_massaction></address_massaction>');
50
-
51
- // Address saved list render
52
- $listChild = $xmlObj->addCustomChild('address_list');
53
- $this->getChild('address_list')->setXmlObj($listChild)->toHtml();
54
-
55
- // Address form render
56
- $formChild = $xmlObj->addCustomChild('form_list', null, array(
57
- 'id' => 'checkout_addresses', 'action' => self::SAVE_ADDRESS_ACTION
58
- ));
59
-
60
- $formBlock = $this->getChild('address_form');
61
- $isGuest = Mage::getSingleton('customer/session')->isLoggedIn() ? false : true;
62
-
63
- $billingFormXml = $formBlock->setType('billing')->setIsGuest($isGuest)->toHtml();
64
- $shippingFormXml = $formBlock->setType('shipping')->setIsGuest(false)->toHtml();
65
- $formChild->appendChild($billingFormXml)->appendChild($shippingFormXml);
66
-
67
- return $xmlObj->asNiceXml();
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Address/Form.php DELETED
@@ -1,114 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * One page address form renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Checkout_Onepage_Address_Form extends Mage_Core_Block_Abstract
35
- {
36
- /**
37
- * Render customer address form
38
- *
39
- * @return Mage_XmlConnect_Model_Simplexml_Element
40
- */
41
- protected function _toHtml()
42
- {
43
- $addressType = $this->getType() ? $this->getType() : 'billing';
44
- $isGuest = $this->getIsGuest();
45
-
46
- /** @var $formXmlObj Mage_XmlConnect_Model_Simplexml_Form */
47
- $formXmlObj = Mage::getModel('xmlconnect/simplexml_form', array(
48
- 'xml_id' => $addressType, 'action' => '', 'use_container' => true
49
- ))->setFieldNameSuffix($addressType);
50
-
51
- /** @var $formFieldset Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset */
52
- $formFieldset = $formXmlObj->addFieldset($addressType);
53
-
54
- $formFieldset->addField('firstname', 'text', array(
55
- 'name' => 'firstname', 'label' => $this->__('First Name'), 'required' => '1'
56
- ));
57
-
58
- $formFieldset->addField('lastname', 'text', array(
59
- 'name' => 'lastname', 'label' => $this->__('Last Name'), 'required' => '1'
60
- ));
61
-
62
- $formFieldset->addField('company', 'text', array(
63
- 'name' => 'company', 'label' => $this->__('Company'), 'required' => '1'
64
- ));
65
-
66
- if ($isGuest) {
67
- $emailField = $formFieldset->addField('email', 'text', array(
68
- 'name' => 'email', 'label' => $this->__('Email Address'), 'required' => '1'
69
- ));
70
- $emailValidator = $emailField->addValidator();
71
- $emailValidator->addRule(array('type' => 'email'));
72
- }
73
-
74
- $formFieldset->addField('street', 'text', array(
75
- 'name' => 'street[]',
76
- 'label' => $this->__('Address'),
77
- 'required' => '1',
78
- ));
79
-
80
- $formFieldset->addField('street_2', 'text', array(
81
- 'name' => 'street[]', 'label' => $this->__('Address 2')
82
- ));
83
-
84
- $formFieldset->addField('city', 'text', array(
85
- 'name' => 'city', 'label' => $this->__('City'), 'required' => '1'
86
- ));
87
-
88
- $formFieldset->addField('country_id', 'countryListSelect', array(
89
- 'name' => 'country_id', 'label' => $this->__('Country'), 'required' => '1',
90
- ));
91
-
92
- $formFieldset->addField('postcode', 'text', array(
93
- 'name' => 'postcode', 'label' => $this->__('Zip/Postal Code'), 'required' => '1'
94
- ));
95
-
96
- $formFieldset->addField('telephone', 'text', array(
97
- 'name' => 'telephone', 'label' => $this->__('Telephone'), 'required' => '1'
98
- ));
99
-
100
- $formFieldset->addField('fax', 'text', array('name' => 'fax', 'label' => $this->__('Fax')));
101
-
102
- // Add custom address attributes
103
- Mage::helper('xmlconnect/customer_form_renderer')->setAttributesBlockName('customer_address')
104
- ->setFormCode('customer_register_address')->setBlockEntity(Mage::getModel('sales/quote_address'))
105
- ->setBlockEntityType('customer_address')
106
- ->addCustomAttributes($formFieldset, $this->getLayout(), $addressType);
107
-
108
- $formFieldset->addField('save_in_address_book', 'checkbox', array(
109
- 'name' => 'save_in_address_book', 'label' => $this->__('Save in address book')
110
- ));
111
-
112
- return $formXmlObj->toXmlObject();
113
- }
114
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Address/List.php DELETED
@@ -1,112 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Customer saved addresses renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Checkout_Onepage_Address_List extends Mage_Checkout_Block_Onepage_Abstract
35
- {
36
- /**
37
- * Render customer address list xml
38
- *
39
- * @return Mage_XmlConnect_Block_Checkout_Onepage_Address_List
40
- */
41
- protected function _toHtml()
42
- {
43
- /** @var $listChild Mage_XmlConnect_Model_Simplexml_Element */
44
- $listChild = $this->getXmlObj();
45
-
46
- $billingAddress = $this->getCustomer()->getPrimaryBillingAddress();
47
- $shippingAddress = $this->getCustomer()->getPrimaryShippingAddress();
48
-
49
- foreach ($this->getCustomer()->getAddresses() as $address) {
50
- $childOptions = array();
51
- if ($billingAddress && ($billingAddress->getEntityId() == $address->getEntityId())) {
52
- $childOptions['default_billing'] = 1;
53
- }
54
- if ($shippingAddress && ($shippingAddress->getEntityId() == $address->getEntityId())) {
55
- $childOptions['default_shipping'] = 1;
56
- }
57
- $addressItem = $listChild->addCustomChild('item', null, $childOptions);
58
- $this->_prepareAddressData($address, $addressItem);
59
- }
60
- return $this;
61
- }
62
-
63
- /**
64
- * Collect address data to xml node
65
- * Remove objects from data array and escape data values
66
- *
67
- * @param Mage_Customer_Model_Address $address
68
- * @param Mage_XmlConnect_Model_Simplexml_Element $item
69
- * @return Mage_XmlConnect_Block_Checkout_Onepage_Address_List
70
- */
71
- protected function _prepareAddressData(
72
- Mage_Customer_Model_Address $address, Mage_XmlConnect_Model_Simplexml_Element $item
73
- ) {
74
- $attributes = Mage::helper('customer/address')->getAttributes();
75
- $data = array('entity_id' => $address->getId());
76
-
77
- foreach ($attributes as $attribute) {
78
- /* @var $attribute Mage_Customer_Model_Attribute */
79
- if (!$attribute->getIsVisible()) {
80
- continue;
81
- }
82
- if ($attribute->getAttributeCode() == 'country_id') {
83
- $data['country'] = $address->getCountryModel()->getName();
84
- $data['country_id'] = $address->getCountryId();
85
- } else if ($attribute->getAttributeCode() == 'region') {
86
- $data['region'] = $address->getRegion();
87
- } else {
88
- $dataModel = Mage_Customer_Model_Attribute_Data::factory($attribute, $address);
89
- $attributeValue = $dataModel->outputValue(
90
- Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ONELINE
91
- );
92
- if ($attribute->getFrontendInput() == 'multiline') {
93
- $values = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ARRAY);
94
- // explode lines
95
- foreach ($values as $attributeIndex => $attributeVal) {
96
- $key = sprintf('%s%d', $attribute->getAttributeCode(), $attributeIndex + 1);
97
- $data[$key] = $attributeVal;
98
- }
99
- }
100
- $data[$attribute->getAttributeCode()] = $attributeValue;
101
- }
102
- }
103
-
104
- foreach ($data as $key => $value) {
105
- if (empty($value)) {
106
- continue;
107
- }
108
- $item->addCustomChild($key, $value);
109
- }
110
- return $this;
111
- }
112
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Review.php DELETED
@@ -1,64 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * One page checkout order review xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Checkout_Onepage_Review extends Mage_Checkout_Block_Cart_Abstract
35
- {
36
- /**
37
- * Order review xml renderer
38
- *
39
- * @return string
40
- */
41
- protected function _toHtml()
42
- {
43
- /** @var $xmlObject Mage_XmlConnect_Model_Simplexml_Element */
44
- $xmlObject = Mage::getModel('xmlconnect/simplexml_element', '<order></order>');
45
- $quote = $this->getQuote();
46
-
47
- $this->getChild('items')->addCartProductsToXmlObj($xmlObject, $quote);
48
-
49
- /**
50
- * Cart Totals
51
- */
52
- $this->getChild('totals')->setCartXmlObject($xmlObject)->toHtml();
53
-
54
- /**
55
- * Agreements
56
- */
57
- $agreements = $this->getChildHtml('agreements');
58
- if ($agreements) {
59
- $agreementsXmlObj = Mage::getModel('xmlconnect/simplexml_element', $agreements);
60
- $xmlObject->appendChild($agreementsXmlObj);
61
- }
62
- return $xmlObject->asNiceXml();
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review/Info.php CHANGED
@@ -42,7 +42,6 @@ class Mage_XmlConnect_Block_Checkout_Order_Review_Info extends Mage_Checkout_Blo
42
  {
43
  $itemsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<products></products>');
44
  $quote = Mage::getSingleton('checkout/session')->getQuote();
45
- $productSmallImageSize = Mage::getModel('xmlconnect/images')->getImageLimitParam('content/product_small');
46
 
47
  /* @var $item Mage_Sales_Model_Quote_Item */
48
  foreach ($this->getItems() as $item) {
@@ -58,10 +57,14 @@ class Mage_XmlConnect_Block_Checkout_Order_Review_Info extends Mage_Checkout_Blo
58
  $itemXml->addChild('item_id', $item->getId());
59
  $itemXml->addChild('name', $itemsXmlObj->escapeXml($renderer->getProductName()));
60
  $itemXml->addChild('qty', $renderer->getQty());
61
- $icon = $renderer->getProductThumbnail()->resize($productSmallImageSize);
 
 
62
 
63
  $iconXml = $itemXml->addChild('icon', $icon);
64
- $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
 
 
65
 
66
  /**
67
  * Price
@@ -78,12 +81,12 @@ class Mage_XmlConnect_Block_Checkout_Order_Review_Info extends Mage_Checkout_Blo
78
  }
79
 
80
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
81
- $incl = $this->helper('checkout')->getPriceInclTax($item);
82
  $typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales');
83
  if ($typeOfDisplay && $item->getWeeeTaxAppliedAmount()) {
84
- $inclPrice = $incl + $item->getWeeeTaxAppliedAmount();
85
  } else {
86
- $inclPrice = $incl - $item->getWeeeTaxDisposition();
87
  }
88
  }
89
 
@@ -127,13 +130,13 @@ class Mage_XmlConnect_Block_Checkout_Order_Review_Info extends Mage_Checkout_Blo
127
  }
128
  }
129
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
130
- $incl = $this->helper('checkout')->getSubtotalInclTax($item);
131
  if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
132
  && $item->getWeeeTaxAppliedAmount()
133
  ) {
134
- $inclPrice = $incl + $item->getWeeeTaxAppliedRowAmount();
135
  } else {
136
- $inclPrice = $incl - $item->getWeeeTaxRowDisposition();
137
  }
138
  }
139
 
@@ -166,31 +169,18 @@ class Mage_XmlConnect_Block_Checkout_Order_Review_Info extends Mage_Checkout_Blo
166
  /**
167
  * Options list
168
  */
169
- $options = $renderer->getOptionList();
170
- if ($options) {
171
  $itemOptionsXml = $itemXml->addChild('options');
172
- foreach ($options as $option) {
173
- $formattedOptionValue = $renderer->getFormatedOptionValue($option);
174
  $optionXml = $itemOptionsXml->addChild('option');
175
- $labelValue = $itemsXmlObj->escapeXml($option['label']);
176
  $optionXml->addAttribute('label', $labelValue);
177
- $textValue = $itemsXmlObj->escapeXml($formattedOptionValue['value']);
178
  $optionXml->addAttribute('text', $textValue);
179
  }
180
  }
181
-
182
- /**
183
- * Downloadable product options
184
- */
185
- $links = $renderer->getLinks();
186
- if ($links) {
187
- $itemOptionsXml = $itemXml->addCustomChild('options', null, array(
188
- 'label' => $renderer->getLinksTitle()
189
- ));
190
- foreach ($links as $link) {
191
- $itemOptionsXml->addCustomChild('option', null, array('label' => $link->getTitle()));
192
- }
193
- }
194
  }
195
 
196
  return $itemsXmlObj->asNiceXml();
42
  {
43
  $itemsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<products></products>');
44
  $quote = Mage::getSingleton('checkout/session')->getQuote();
 
45
 
46
  /* @var $item Mage_Sales_Model_Quote_Item */
47
  foreach ($this->getItems() as $item) {
57
  $itemXml->addChild('item_id', $item->getId());
58
  $itemXml->addChild('name', $itemsXmlObj->escapeXml($renderer->getProductName()));
59
  $itemXml->addChild('qty', $renderer->getQty());
60
+ $icon = $renderer->getProductThumbnail()->resize(
61
+ Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small')
62
+ );
63
 
64
  $iconXml = $itemXml->addChild('icon', $icon);
65
+
66
+ $file = Mage::helper('xmlconnect')->urlToPath($icon);
67
+ $iconXml->addAttribute('modification_time', filemtime($file));
68
 
69
  /**
70
  * Price
81
  }
82
 
83
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
84
+ $_incl = $this->helper('checkout')->getPriceInclTax($item);
85
  $typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales');
86
  if ($typeOfDisplay && $item->getWeeeTaxAppliedAmount()) {
87
+ $inclPrice = $_incl + $item->getWeeeTaxAppliedAmount();
88
  } else {
89
+ $inclPrice = $_incl - $item->getWeeeTaxDisposition();
90
  }
91
  }
92
 
130
  }
131
  }
132
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
133
+ $_incl = $this->helper('checkout')->getSubtotalInclTax($item);
134
  if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
135
  && $item->getWeeeTaxAppliedAmount()
136
  ) {
137
+ $inclPrice = $_incl + $item->getWeeeTaxAppliedRowAmount();
138
  } else {
139
+ $inclPrice = $_incl - $item->getWeeeTaxRowDisposition();
140
  }
141
  }
142
 
169
  /**
170
  * Options list
171
  */
172
+ $_options = $renderer->getOptionList();
173
+ if ($_options) {
174
  $itemOptionsXml = $itemXml->addChild('options');
175
+ foreach ($_options as $_option) {
176
+ $_formattedOptionValue = $renderer->getFormatedOptionValue($_option);
177
  $optionXml = $itemOptionsXml->addChild('option');
178
+ $labelValue = $itemsXmlObj->escapeXml($_option['label']);
179
  $optionXml->addAttribute('label', $labelValue);
180
+ $textValue = $itemsXmlObj->escapeXml($_formattedOptionValue['value']);
181
  $optionXml->addAttribute('text', $textValue);
182
  }
183
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  }
185
 
186
  return $itemsXmlObj->asNiceXml();
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Ccsave.php CHANGED
@@ -80,8 +80,8 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_Ccsave extends Mage_Payment_
80
 
81
  $ccTypes = $helper->getArrayAsXmlItemValues($this->getCcAvailableTypes(), $this->getInfoData('cc_type'));
82
 
83
- $ccMonthArray = $this->getCcMonths();
84
- $ccMonths = $helper->getArrayAsXmlItemValues($ccMonthArray, $this->getInfoData('cc_exp_month'));
85
 
86
  $ccYears = $helper->getArrayAsXmlItemValues($this->getCcYears(), $this->getInfoData('cc_exp_year'));
87
 
@@ -100,7 +100,7 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_Ccsave extends Mage_Payment_
100
  $solo = '';
101
  if ($this->hasSsCardType()) {
102
  $ssCcMonths = $helper->getArrayAsXmlItemValues(
103
- $ccMonthArray, $this->getInfoData('cc_ss_start_month')
104
  );
105
  $ssCcYears = $helper->getArrayAsXmlItemValues(
106
  $this->getSsStartYears(), $this->getInfoData('cc_ss_start_year')
80
 
81
  $ccTypes = $helper->getArrayAsXmlItemValues($this->getCcAvailableTypes(), $this->getInfoData('cc_type'));
82
 
83
+ $_ccMonthArray = $this->getCcMonths();
84
+ $ccMonths = $helper->getArrayAsXmlItemValues($_ccMonthArray, $this->getInfoData('cc_exp_month'));
85
 
86
  $ccYears = $helper->getArrayAsXmlItemValues($this->getCcYears(), $this->getInfoData('cc_exp_year'));
87
 
100
  $solo = '';
101
  if ($this->hasSsCardType()) {
102
  $ssCcMonths = $helper->getArrayAsXmlItemValues(
103
+ $_ccMonthArray, $this->getInfoData('cc_ss_start_month')
104
  );
105
  $ssCcYears = $helper->getArrayAsXmlItemValues(
106
  $this->getSsStartYears(), $this->getInfoData('cc_ss_start_year')
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Ccsave.php CHANGED
@@ -44,8 +44,8 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Ccsave extends Mage_Pay
44
  $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
45
  $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
46
 
47
- if ($specificInfo = $this->getSpecificInformation()) {
48
- foreach ($specificInfo as $label => $value) {
49
  $orderItemXmlObj->addCustomChild('item', implode($this->getValueAsArray($value, true), '\n'), array(
50
  'label' => $label
51
  ));
44
  $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
45
  $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
46
 
47
+ if ($_specificInfo = $this->getSpecificInformation()) {
48
+ foreach ($_specificInfo as $label => $value) {
49
  $orderItemXmlObj->addCustomChild('item', implode($this->getValueAsArray($value, true), '\n'), array(
50
  'label' => $label
51
  ));
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Checkmo.php CHANGED
@@ -42,7 +42,9 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Checkmo extends Mage_Pa
42
  public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
43
  {
44
  $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
45
- $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
 
 
46
 
47
  if ($this->getInfo()->getAdditionalData()) {
48
  if ($this->getPayableTo()) {
42
  public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
43
  {
44
  $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
45
+ $orderItemXmlObj->addAttribute(
46
+ 'title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle())
47
+ );
48
 
49
  if ($this->getInfo()->getAdditionalData()) {
50
  if ($this->getPayableTo()) {
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Paypal/Abstract.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- abstract class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Paypal_Abstract extends Mage_Paypal_Block_Payment_Info
 
35
  {
36
  /**
37
  * Add CC Save Payment info to order XML object
@@ -42,10 +43,12 @@ abstract class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Paypal_Abstrac
42
  public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
43
  {
44
  $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
45
- $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
 
 
46
 
47
- if ($specificInfo = $this->getSpecificInformation()) {
48
- foreach ($specificInfo as $label => $value) {
49
  $orderItemXmlObj->addCustomChild('item', implode($this->getValueAsArray($value, true), '\n'), array(
50
  'label' => $label
51
  ));
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ abstract class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Paypal_Abstract
35
+ extends Mage_Paypal_Block_Payment_Info
36
  {
37
  /**
38
  * Add CC Save Payment info to order XML object
43
  public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
44
  {
45
  $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
46
+ $orderItemXmlObj->addAttribute(
47
+ 'title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle())
48
+ );
49
 
50
+ if ($_specificInfo = $this->getSpecificInformation()) {
51
+ foreach ($_specificInfo as $label => $value) {
52
  $orderItemXmlObj->addCustomChild('item', implode($this->getValueAsArray($value, true), '\n'), array(
53
  'label' => $label
54
  ));
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Pbridge/Verisign.php CHANGED
@@ -42,10 +42,12 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Pbridge_Verisign extend
42
  public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
43
  {
44
  $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
45
- $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
 
 
46
 
47
- if ($specificInfo = $this->getSpecificInformation()) {
48
- foreach ($specificInfo as $label => $value) {
49
  $orderItemXmlObj->addCustomChild('item', implode($this->getValueAsArray($value, true), '\n'), array(
50
  'label' => $label
51
  ));
42
  public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
43
  {
44
  $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
45
+ $orderItemXmlObj->addAttribute(
46
+ 'title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle())
47
+ );
48
 
49
+ if ($_specificInfo = $this->getSpecificInformation()) {
50
+ foreach ($_specificInfo as $label => $value) {
51
  $orderItemXmlObj->addCustomChild('item', implode($this->getValueAsArray($value, true), '\n'), array(
52
  'label' => $label
53
  ));
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/List.php CHANGED
@@ -41,7 +41,7 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_List extends Mage_Payment_Bl
41
  protected $_methodArray = array(
42
  'payment_ccsave' => 'Mage_Payment_Model_Method_Cc',
43
  'payment_checkmo' => 'Mage_Payment_Model_Method_Checkmo',
44
- 'payment_purchaseorder' => 'Mage_Payment_Model_Method_Purchaseorder'
45
  );
46
 
47
  /**
@@ -79,6 +79,29 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_List extends Mage_Payment_Bl
79
  return Mage::getSingleton('checkout/session')->getQuote();
80
  }
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  /**
83
  * Add gift card details to XML object
84
  *
@@ -96,6 +119,15 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_List extends Mage_Payment_Bl
96
 
97
  $methodsXmlObj->addCustomChild('information', null, array('label' => $amount, 'disabled' => '1'));
98
 
 
 
 
 
 
 
 
 
 
99
  $this->setIsUsedGiftCard(true);
100
  }
101
  }
@@ -143,109 +175,24 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_List extends Mage_Payment_Bl
143
  * Render payment methods xml
144
  *
145
  * @return string
 
146
  */
147
  protected function _toHtml()
148
  {
149
  /** @var $methodsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
150
  $methodsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<payment_methods></payment_methods>');
151
 
152
- if ($this->_addGiftCard($methodsXmlObj)) {
153
- return $methodsXmlObj->asNiceXml();
154
- }
155
-
156
- $this->addCustomerBalanceToXmlObj($methodsXmlObj)->_buildPaymentMethods($methodsXmlObj);
157
- return $methodsXmlObj->asNiceXml();
158
- }
159
-
160
- /**
161
- * Add free payment method xml to payment method list
162
- *
163
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
164
- * @return Mage_XmlConnect_Block_Checkout_Payment_Method_List
165
- */
166
- protected function _addFreePaymentToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj)
167
- {
168
- $methodsXmlObj->addCustomChild('method', null, array(
169
- 'id' => 'free',
170
- 'code' => 'free',
171
- 'post_name' => 'payment[method]',
172
- 'label' => $this->__('No Payment Information Required'),
173
- 'selected' => '1',
174
- 'disabled' => '1'
175
- ));
176
- return $this;
177
- }
178
-
179
- /**
180
- * Check and prepare payment method model
181
- *
182
- * @param mixed $method
183
- * @return bool
184
- */
185
- protected function _canUseMethod($method)
186
- {
187
- if (!($method instanceof Mage_Payment_Model_Method_Abstract) || !$method->canUseCheckout()
188
- || !$method->isAvailable($this->getQuote())
189
- ) {
190
- return false;
191
- }
192
- return parent::_canUseMethod($method);
193
- }
194
-
195
- /**
196
- * Add gift card info to xml and check is covered a quote
197
- *
198
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
199
- * @return bool
200
- */
201
- protected function _addGiftCard(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj)
202
- {
203
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_GiftCardAccount'))) {
204
  $this->addGiftcardToXmlObj($methodsXmlObj);
205
  if ($this->getIsUsedGiftCard() && $this->_isPaymentRequired()) {
206
- $this->_addFreePaymentToXmlObj($methodsXmlObj);
207
- return true;
208
  }
209
  }
210
- return false;
211
- }
212
 
213
- /**
214
- * Add customer balance details to XML object
215
- *
216
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
217
- * @return Mage_XmlConnect_Block_Checkout_Payment_Method_List
218
- */
219
- public function addCustomerBalanceToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj)
220
- {
221
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_CustomerBalance'))) {
222
- /** @var $customerBalanceBlock Enterprise_CustomerBalance_Block_Checkout_Onepage_Payment_Additional */
223
- $customerBalanceBlock = $this->getLayout()
224
- ->addBlock('enterprise_customerbalance/checkout_onepage_payment_additional', 'customer_balance');
225
- $storeCreditFlag = (int) Mage::getStoreConfig(Enterprise_CustomerBalance_Helper_Data::XML_PATH_ENABLED);
226
- if ($storeCreditFlag && $customerBalanceBlock->isDisplayContainer()) {
227
- $balance = $this->getQuote()->getStore()->formatPrice($customerBalanceBlock->getBalance(), false);
228
- $methodsXmlObj->addCustomChild('customer_balance', null, array(
229
- 'post_name' => 'payment[use_customer_balance]',
230
- 'code' => 1,
231
- 'label' => $this->__('Use Store Credit (%s available)', $balance),
232
- 'is_cover_a_quote' => intval($customerBalanceBlock->isFullyPaidAfterApplication()),
233
- 'selected' => intval($customerBalanceBlock->isCustomerBalanceUsed())
234
- ));
235
- }
236
  }
237
- return $this;
238
- }
239
 
240
- /**
241
- * Add payment methods info to xml object
242
- *
243
- * @throw Mage_Core_Exception
244
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
245
- * @return Mage_XmlConnect_Block_Checkout_Payment_Method_List
246
- */
247
- protected function _buildPaymentMethods(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj)
248
- {
249
  $methodArray = $this->_getPaymentMethodArray();
250
  $usedMethods = $sortedAvailableMethodCodes = $usedCodes = array();
251
 
@@ -256,17 +203,6 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_List extends Mage_Payment_Bl
256
  Mage::app()->getStore(), $this->getQuote()
257
  );
258
 
259
- $total = $this->getQuote()->getGrandTotal();
260
- foreach ($allAvailableMethods as $key => $method) {
261
- if ($this->_canUseMethod($method) && ($total != 0 || $method->getCode() == 'free'
262
- || ($this->getQuote()->hasRecurringItems() && $method->canManageRecurringProfiles()))
263
- ) {
264
- $this->_assignMethod($method);
265
- } else {
266
- unset($allAvailableMethods[$key]);
267
- }
268
- }
269
-
270
  /**
271
  * Get sorted codes of available methods
272
  */
@@ -287,6 +223,7 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_List extends Mage_Payment_Bl
287
  if (!$block) {
288
  continue;
289
  }
 
290
  $method = $block->getMethod();
291
  if (!$this->_canUseMethod($method) || in_array($method->getCode(), $usedCodes)) {
292
  continue;
@@ -345,32 +282,36 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_List extends Mage_Payment_Bl
345
  $renderer->setData('method', $method);
346
  }
347
 
348
- $options = array(
349
- 'id' => $method->getCode(),
350
- 'code' => $method->getCode(),
351
- 'post_name' => 'payment[method]',
352
- 'label' => $methodsXmlObj->escapeXml($method->getTitle()),
353
- );
354
-
355
  if ($this->getQuote()->getPayment()->getMethod() == $method->getCode()) {
356
- $options['selected'] = 1;
357
  }
358
-
359
- $methodItemXmlObj = $methodsXmlObj->addCustomChild('method', null, $options);
360
  $renderer->addPaymentFormToXmlObj($methodItemXmlObj);
361
  }
362
-
363
- if (count($allAvailableMethods) == 1 && isset($sortedAvailableMethodCodes[0])
364
- && $sortedAvailableMethodCodes[0] == 'free') {
365
- if ($this->_isPaymentRequired()) {
366
- $this->_addFreePaymentToXmlObj($methodsXmlObj);
367
- }
368
  }
 
 
369
 
370
- if (!count($allAvailableMethods)) {
371
- Mage::throwException($this->__('Your order cannot be completed at this time as there is no payment methods available for it.'));
 
 
 
 
 
 
 
 
 
 
 
372
  }
373
- return $this;
374
  }
375
 
376
  /**
41
  protected $_methodArray = array(
42
  'payment_ccsave' => 'Mage_Payment_Model_Method_Cc',
43
  'payment_checkmo' => 'Mage_Payment_Model_Method_Checkmo',
44
+ 'payment_purchaseorder' => 'Mage_Payment_Model_Method_Purchaseorder',
45
  );
46
 
47
  /**
79
  return Mage::getSingleton('checkout/session')->getQuote();
80
  }
81
 
82
+ /**
83
+ * Add customer balance details to XML object
84
+ *
85
+ * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
86
+ */
87
+ public function addCustomerBalanceToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj)
88
+ {
89
+ /** @var $customerBalanceBlock Enterprise_CustomerBalance_Block_Checkout_Onepage_Payment_Additional */
90
+ $customerBalanceBlock = $this->getLayout()
91
+ ->addBlock('enterprise_customerbalance/checkout_onepage_payment_additional', 'customer_balance');
92
+ $storeCreditFlag = (int) Mage::getStoreConfig(Enterprise_CustomerBalance_Helper_Data::XML_PATH_ENABLED);
93
+ if ($storeCreditFlag && $customerBalanceBlock->isDisplayContainer()) {
94
+ $balance = $this->getQuote()->getStore()->formatPrice($customerBalanceBlock->getBalance(), false);
95
+ $methodsXmlObj->addCustomChild('customer_balance', null, array(
96
+ 'post_name' => 'payment[use_customer_balance]',
97
+ 'code' => 1,
98
+ 'label' => $this->__('Use Store Credit (%s available)', $balance),
99
+ 'is_cover_a_quote' => intval($customerBalanceBlock->isFullyPaidAfterApplication()),
100
+ 'selected' => intval($customerBalanceBlock->isCustomerBalanceUsed())
101
+ ));
102
+ }
103
+ }
104
+
105
  /**
106
  * Add gift card details to XML object
107
  *
119
 
120
  $methodsXmlObj->addCustomChild('information', null, array('label' => $amount, 'disabled' => '1'));
121
 
122
+ if ($this->_isPaymentRequired()) {
123
+ $methodsXmlObj->addCustomChild('method', null, array(
124
+ 'post_name' => 'payment[method]',
125
+ 'code' => 'free',
126
+ 'label' => $this->__('No Payment Information Required'),
127
+ 'selected' => '1',
128
+ 'disabled' => '1'
129
+ ));
130
+ }
131
  $this->setIsUsedGiftCard(true);
132
  }
133
  }
175
  * Render payment methods xml
176
  *
177
  * @return string
178
+ * @throw Mage_Core_Exception
179
  */
180
  protected function _toHtml()
181
  {
182
  /** @var $methodsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
183
  $methodsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<payment_methods></payment_methods>');
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_GiftCardAccount'))) {
186
  $this->addGiftcardToXmlObj($methodsXmlObj);
187
  if ($this->getIsUsedGiftCard() && $this->_isPaymentRequired()) {
188
+ return $methodsXmlObj->asNiceXml();
 
189
  }
190
  }
 
 
191
 
 
 
 
 
 
 
 
 
192
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_CustomerBalance'))) {
193
+ $this->addCustomerBalanceToXmlObj($methodsXmlObj);
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
 
 
195
 
 
 
 
 
 
 
 
 
 
196
  $methodArray = $this->_getPaymentMethodArray();
197
  $usedMethods = $sortedAvailableMethodCodes = $usedCodes = array();
198
 
203
  Mage::app()->getStore(), $this->getQuote()
204
  );
205
 
 
 
 
 
 
 
 
 
 
 
 
206
  /**
207
  * Get sorted codes of available methods
208
  */
223
  if (!$block) {
224
  continue;
225
  }
226
+
227
  $method = $block->getMethod();
228
  if (!$this->_canUseMethod($method) || in_array($method->getCode(), $usedCodes)) {
229
  continue;
282
  $renderer->setData('method', $method);
283
  }
284
 
285
+ $methodItemXmlObj = $methodsXmlObj->addChild('method');
286
+ $methodItemXmlObj->addAttribute('post_name', 'payment[method]');
287
+ $methodItemXmlObj->addAttribute('code', $method->getCode());
288
+ $methodItemXmlObj->addAttribute('label', $methodsXmlObj->escapeXml($method->getTitle()));
 
 
 
289
  if ($this->getQuote()->getPayment()->getMethod() == $method->getCode()) {
290
+ $methodItemXmlObj->addAttribute('selected', 1);
291
  }
 
 
292
  $renderer->addPaymentFormToXmlObj($methodItemXmlObj);
293
  }
294
+ if (!count($usedMethods)) {
295
+ Mage::throwException($this->__('Sorry, no payment options are available for this order at this time.'));
 
 
 
 
296
  }
297
+ return $methodsXmlObj->asNiceXml();
298
+ }
299
 
300
+ /**
301
+ * Check and prepare payment method model
302
+ *
303
+ * @param mixed $method
304
+ * @return bool
305
+ */
306
+ protected function _canUseMethod($method)
307
+ {
308
+ if (!($method instanceof Mage_Payment_Model_Method_Abstract)
309
+ || !$method->canUseCheckout()
310
+ || !$method->isAvailable($this->getQuote())
311
+ ) {
312
+ return false;
313
  }
314
+ return parent::_canUseMethod($method);
315
  }
316
 
317
  /**
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/ListApi23.php DELETED
@@ -1,133 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * One page checkout payment methods xml renderer. API version 23
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Checkout_Payment_Method_ListApi23 extends Mage_XmlConnect_Block_Checkout_Payment_Method_List
35
- {
36
- /**
37
- * Method list xml object
38
- *
39
- * @var Mage_XmlConnect_Model_Simplexml_Element
40
- */
41
- protected $_methodList;
42
-
43
- /**
44
- * Add gift card info to xml and check is covered a quote. API version 23
45
- *
46
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
47
- * @return bool
48
- */
49
- protected function _addGiftCard(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj) {
50
- if (is_object(Mage::getConfig()->getNode('modules/Enterprise_GiftCardAccount'))) {
51
- $this->addGiftCardToXmlObj($methodsXmlObj);
52
- if ($this->getIsUsedGiftCard() && $this->_isPaymentRequired()) {
53
- $this->_addFreePaymentToXmlObj($this->getMethodList($methodsXmlObj));
54
- return true;
55
- }
56
- }
57
- return false;
58
- }
59
-
60
- /**
61
- * Add gift card details to XML object
62
- *
63
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
64
- * @return null
65
- */
66
- public function addGiftCardToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj)
67
- {
68
- $giftCardInfoBlock = $this->getLayout()->addBlock(
69
- 'enterprise_giftcardaccount/checkout_onepage_payment_additional', 'giftcard_info'
70
- );
71
-
72
- if (intval($giftCardInfoBlock->getAppliedGiftCardAmount())) {
73
- $amount = $this->getQuote()->getStore()->formatPrice($giftCardInfoBlock->getAppliedGiftCardAmount(), false);
74
- $amount = $this->__('Gift Card amount applied to order: %s', $amount);
75
- $methodsXmlObj->addCustomChild('information', null, array('label' => $amount));
76
- $this->setIsUsedGiftCard(true);
77
- }
78
- }
79
-
80
- /**
81
- * Add customer balance details to XML object. API version 23
82
- *
83
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
84
- * @return Mage_XmlConnect_Block_Checkout_Payment_Method_ListApi23
85
- */
86
- public function addCustomerBalanceToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj)
87
- {
88
- $methodsXmlObj = $this->getMethodList($methodsXmlObj);
89
- if (is_object(Mage::getConfig()->getNode('modules/Enterprise_CustomerBalance'))) {
90
- /** @var $customerBalanceBlock Enterprise_CustomerBalance_Block_Checkout_Onepage_Payment_Additional */
91
- $customerBalanceBlock = $this->getLayout()
92
- ->addBlock('enterprise_customerbalance/checkout_onepage_payment_additional', 'customer_balance');
93
- $storeCreditFlag = (int) Mage::getStoreConfig(Enterprise_CustomerBalance_Helper_Data::XML_PATH_ENABLED);
94
- if ($storeCreditFlag && $customerBalanceBlock->isDisplayContainer()) {
95
- $balance = $this->getQuote()->getStore()->formatPrice($customerBalanceBlock->getBalance(), false);
96
- $methodsXmlObj->addCustomChild('method', null, array(
97
- 'id' => 'customer_balance',
98
- 'post_name' => 'payment[use_customer_balance]',
99
- 'code' => 1,
100
- 'label' => $this->__('Use Store Credit (%s available)', $balance),
101
- 'is_cover_a_quote' => intval($customerBalanceBlock->isFullyPaidAfterApplication()),
102
- 'selected' => intval($customerBalanceBlock->isCustomerBalanceUsed())
103
- ));
104
- }
105
- }
106
- return $this;
107
- }
108
-
109
- /**
110
- * Get method list object
111
- *
112
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
113
- * @return Mage_XmlConnect_Model_Simplexml_Element
114
- */
115
- public function getMethodList($methodsXmlObj)
116
- {
117
- if (null === $this->_methodList) {
118
- $this->_methodList = $methodsXmlObj->addCustomChild('method_list');
119
- }
120
- return $this->_methodList;
121
- }
122
-
123
- /**
124
- * Add payment methods info to xml object
125
- *
126
- * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
127
- * @return Mage_XmlConnect_Block_Checkout_Payment_Method_List
128
- */
129
- protected function _buildPaymentMethods(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj)
130
- {
131
- return parent::_buildPaymentMethods($this->getMethodList($methodsXmlObj));
132
- }
133
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Paypal/Payflow.php CHANGED
@@ -75,29 +75,29 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_Paypal_Payflow extends Mage_
75
  $formXmlObj->addAttribute('name', 'payment_form_' . $method->getCode());
76
  $formXmlObj->addAttribute('method', 'post');
77
 
78
- $ccType = $this->getInfoData('cc_type');
79
  $ccTypes = '';
80
 
81
- foreach ($this->getCcAvailableTypes() as $typeCode => $_typeName) {
82
- if (!$typeCode) {
83
  continue;
84
  }
85
  $ccTypes .= '
86
- <item' . ($typeCode == $ccType ? ' selected="1"' : '') . '>
87
  <label>' . $_typeName . '</label>
88
- <value>' . $typeCode . '</value>
89
  </item>';
90
  }
91
 
92
  $ccMonthes = '';
93
 
94
- $ccExpMonth = $this->getInfoData('cc_exp_month');
95
  foreach ($this->getCcMonths() as $k => $v) {
96
  if (!$k) {
97
  continue;
98
  }
99
  $ccMonthes .= '
100
- <item' . ($k == $ccExpMonth ? ' selected="1"' : '') . '>
101
  <label>' . $v . '</label>
102
  <value>' . ($k ? $k : '') . '</value>
103
  </item>';
@@ -105,13 +105,13 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_Paypal_Payflow extends Mage_
105
 
106
  $ccYears = '';
107
 
108
- $ccExpYear = $this->getInfoData('cc_exp_year');
109
  foreach ($this->getCcYears() as $k => $v) {
110
  if (!$k) {
111
  continue;
112
  }
113
  $ccYears .= '
114
- <item' . ($k == $ccExpYear ? ' selected="1"' : '') . '>
115
  <label>' . $v . '</label>
116
  <value>' . ($k ? $k : '') . '</value>
117
  </item>';
75
  $formXmlObj->addAttribute('name', 'payment_form_' . $method->getCode());
76
  $formXmlObj->addAttribute('method', 'post');
77
 
78
+ $_ccType = $this->getInfoData('cc_type');
79
  $ccTypes = '';
80
 
81
+ foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName) {
82
+ if (!$_typeCode) {
83
  continue;
84
  }
85
  $ccTypes .= '
86
+ <item' . ($_typeCode == $_ccType ? ' selected="1"' : '') . '>
87
  <label>' . $_typeName . '</label>
88
+ <value>' . $_typeCode . '</value>
89
  </item>';
90
  }
91
 
92
  $ccMonthes = '';
93
 
94
+ $_ccExpMonth = $this->getInfoData('cc_exp_month');
95
  foreach ($this->getCcMonths() as $k => $v) {
96
  if (!$k) {
97
  continue;
98
  }
99
  $ccMonthes .= '
100
+ <item' . ($k == $_ccExpMonth ? ' selected="1"' : '') . '>
101
  <label>' . $v . '</label>
102
  <value>' . ($k ? $k : '') . '</value>
103
  </item>';
105
 
106
  $ccYears = '';
107
 
108
+ $_ccExpYear = $this->getInfoData('cc_exp_year');
109
  foreach ($this->getCcYears() as $k => $v) {
110
  if (!$k) {
111
  continue;
112
  }
113
  $ccYears .= '
114
+ <item' . ($k == $_ccExpYear ? ' selected="1"' : '') . '>
115
  <label>' . $v . '</label>
116
  <value>' . ($k ? $k : '') . '</value>
117
  </item>';
app/code/core/Mage/XmlConnect/Block/Checkout/Pbridge/Result.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Checkout_Pbridge_Result extends Mage_Core_Block_Abstract
35
  {
36
  /**
37
  * Return url for redirect with params of Payment Bridge incoming data
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Checkout_Pbridge_Result extends Mage_Core_Block_Template
35
  {
36
  /**
37
  * Return url for redirect with params of Payment Bridge incoming data
app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Available.php CHANGED
@@ -43,34 +43,33 @@ class Mage_XmlConnect_Block_Checkout_Shipping_Method_Available
43
  {
44
  /** @var $methodsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
45
  $methodsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<shipping_methods></shipping_methods>');
46
- $shippingRateGroups = $this->getShippingRates();
47
- if ($shippingRateGroups) {
48
  $store = $this->getQuote()->getStore();
49
- $sole = count($shippingRateGroups) == 1;
50
- foreach ($shippingRateGroups as $code => $rates) {
51
  $methodXmlObj = $methodsXmlObj->addChild('method');
52
  $methodXmlObj->addAttribute('label', $methodsXmlObj->escapeXml($this->getCarrierName($code)));
53
  $ratesXmlObj = $methodXmlObj->addChild('rates');
54
 
55
- $sole = $sole && count($rates) == 1;
56
- foreach ($rates as $rate) {
57
- $rateOptions = array();
58
- $rateOptions['label'] = $rate->getMethodTitle();
59
- $rateOptions['code'] = $rate->getCode();
60
- if ($rate->getErrorMessage()) {
61
- $rateXmlObj = $ratesXmlObj->addCustomChild('rate', null, $rateOptions);
62
- $rateXmlObj->addChild('error_message', $methodsXmlObj->escapeXml($rate->getErrorMessage()));
63
  } else {
64
  $price = Mage::helper('tax')->getShippingPrice(
65
- $rate->getPrice(),
66
  Mage::helper('tax')->displayShippingPriceIncludingTax(),
67
  $this->getAddress()
68
  );
69
- $rateOptions['price'] = Mage::helper('xmlconnect')->formatPriceForXml(
 
70
  $store->convertPrice($price, false, false)
71
- );
72
- $rateOptions['formated_price'] = $store->convertPrice($price, true, false);
73
- $ratesXmlObj->addCustomChild('rate', null, $rateOptions);
74
  }
75
  }
76
  }
43
  {
44
  /** @var $methodsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
45
  $methodsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<shipping_methods></shipping_methods>');
46
+ $_shippingRateGroups = $this->getShippingRates();
47
+ if ($_shippingRateGroups) {
48
  $store = $this->getQuote()->getStore();
49
+ $_sole = count($_shippingRateGroups) == 1;
50
+ foreach ($_shippingRateGroups as $code => $_rates) {
51
  $methodXmlObj = $methodsXmlObj->addChild('method');
52
  $methodXmlObj->addAttribute('label', $methodsXmlObj->escapeXml($this->getCarrierName($code)));
53
  $ratesXmlObj = $methodXmlObj->addChild('rates');
54
 
55
+ $_sole = $_sole && count($_rates) == 1;
56
+ foreach ($_rates as $_rate) {
57
+ $rateXmlObj = $ratesXmlObj->addChild('rate');
58
+ $rateXmlObj->addAttribute('label', $methodsXmlObj->escapeXml($_rate->getMethodTitle()));
59
+ $rateXmlObj->addAttribute('code', $_rate->getCode());
60
+ if ($_rate->getErrorMessage()) {
61
+ $rateXmlObj->addChild('error_message', $methodsXmlObj->escapeXml($_rate->getErrorMessage()));
 
62
  } else {
63
  $price = Mage::helper('tax')->getShippingPrice(
64
+ $_rate->getPrice(),
65
  Mage::helper('tax')->displayShippingPriceIncludingTax(),
66
  $this->getAddress()
67
  );
68
+ $formattedPrice = $store->convertPrice($price, true, false);
69
+ $rateXmlObj->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml(
70
  $store->convertPrice($price, false, false)
71
+ ));
72
+ $rateXmlObj->addAttribute('formated_price', $formattedPrice);
 
73
  }
74
  }
75
  }
app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/AvailableList.php DELETED
@@ -1,82 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * One page checkout shipping methods xml renderer. API version 23
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Checkout_Shipping_Method_AvailableList
35
- extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
36
- {
37
- /**
38
- * Render shipping methods xml
39
- *
40
- * @return string
41
- */
42
- protected function _toHtml()
43
- {
44
- /** @var $methodsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
45
- $methodsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<shipping_methods></shipping_methods>');
46
- $shippingRateGroups = $this->getShippingRates();
47
- if ($shippingRateGroups) {
48
- $store = $this->getQuote()->getStore();
49
- $sole = count($shippingRateGroups) == 1;
50
- foreach ($shippingRateGroups as $code => $rates) {
51
- $methodXmlObj = $methodsXmlObj->addChild('method');
52
- $methodXmlObj->addAttribute('label', $methodsXmlObj->escapeXml($this->getCarrierName($code)));
53
- $ratesXmlObj = $methodXmlObj->addChild('rates');
54
-
55
- $sole = $sole && count($rates) == 1;
56
- foreach ($rates as $rate) {
57
- $rateOptions = array();
58
- $rateOptions['label'] = $rate->getMethodTitle();
59
- $rateOptions['code'] = $rate->getCode();
60
- if ($rate->getErrorMessage()) {
61
- $rateXmlObj = $ratesXmlObj->addCustomChild('rate', null, $rateOptions);
62
- $rateXmlObj->addChild('error_message', $methodsXmlObj->escapeXml($rate->getErrorMessage()));
63
- } else {
64
- $price = Mage::helper('tax')->getShippingPrice(
65
- $rate->getPrice(),
66
- Mage::helper('tax')->displayShippingPriceIncludingTax(),
67
- $this->getAddress()
68
- );
69
- $rateOptions['price'] = Mage::helper('xmlconnect')->formatPriceForXml(
70
- $store->convertPrice($price, false, false)
71
- );
72
- $rateOptions['formatted_price'] = $store->convertPrice($price, true, false);
73
- $ratesXmlObj->addCustomChild('rate', null, $rateOptions);
74
- }
75
- }
76
- }
77
- } else {
78
- Mage::throwException($this->__('Shipping to this address is not possible.'));
79
- }
80
- return $methodsXmlObj->asNiceXml();
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Configuration.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Configuration extends Mage_Core_Block_Abstract
35
  {
36
  /**
37
  * Current application model
@@ -61,40 +61,40 @@ class Mage_XmlConnect_Block_Configuration extends Mage_Core_Block_Abstract
61
  * Recursively build XML configuration tree
62
  *
63
  * @param Mage_XmlConnect_Model_Simplexml_Element $section
64
- * @param array $subTree
65
- * @return Mage_XmlConnect_Block_Configuration
66
  */
67
- protected function _buildRecursive($section, $subTree)
68
  {
69
- Mage::helper('xmlconnect')->getDeviceHelper()->checkRequiredConfigFields($subTree);
70
 
71
- foreach ($subTree as $key => $value) {
72
  if (is_array($value)) {
73
  if ($key == 'fonts') {
74
- $subSection = $section->addChild('fonts');
75
- foreach ($value as $label => $val) {
76
- if (empty($val['name']) || empty($val['size']) || empty($val['color'])) {
77
  continue;
78
  }
79
- $font = $subSection->addChild('font');
80
  $font->addAttribute('label', $label);
81
- $font->addAttribute('name', $val['name']);
82
- $font->addAttribute('size', $val['size']);
83
- $font->addAttribute('color', $val['color']);
84
  }
85
  } elseif ($key == 'pages') {
86
- $subSection = $section->addChild('content');
87
  foreach ($value as $page) {
88
- $this->_buildRecursive($subSection->addChild('page'), $page);
89
  }
90
  } else {
91
- $subSection = $section->addChild($key);
92
- $this->_buildRecursive($subSection, $value);
93
  }
94
  } elseif ($value instanceof Mage_XmlConnect_Model_Tabs) {
95
  foreach ($value->getRenderTabs() as $tab) {
96
- $subSection = $section->addChild('tab');
97
- $this->_buildRecursive($subSection, $tab);
98
  }
99
  } else {
100
  $value = (string)$value;
@@ -103,7 +103,6 @@ class Mage_XmlConnect_Block_Configuration extends Mage_Core_Block_Abstract
103
  }
104
  }
105
  }
106
- return $this;
107
  }
108
 
109
  /**
@@ -113,26 +112,8 @@ class Mage_XmlConnect_Block_Configuration extends Mage_Core_Block_Abstract
113
  */
114
  protected function _toHtml()
115
  {
116
- /** @var $xml Mage_XmlConnect_Model_Simplexml_Element */
117
  $xml = Mage::getModel('xmlconnect/simplexml_element', '<configuration></configuration>');
118
- $this->_buildRecursive($xml, Mage::helper('xmlconnect')->excludeXmlConfigKeys($this->_app->getRenderConf()))
119
- ->_addLocalization($xml);
120
  return $xml->asNiceXml();
121
  }
122
-
123
- /**
124
- * Add localization data to xml object
125
- *
126
- * @param Mage_XmlConnect_Model_Simplexml_Element $xml
127
- * @return Mage_XmlConnect_Block_Configuration
128
- */
129
- protected function _addLocalization(Mage_XmlConnect_Model_Simplexml_Element $xml)
130
- {
131
- /** @var $translateHelper Mage_XmlConnect_Helper_Translate */
132
- $translateHelper = Mage::helper('xmlconnect/translate');
133
- $xml->addCustomChild('localization', Mage::helper('xmlconnect')->getActionUrl('xmlconnect/localization'), array(
134
- 'hash' => $translateHelper->getHash()
135
- ));
136
- return $this;
137
- }
138
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Configuration extends Mage_Core_Block_Template
35
  {
36
  /**
37
  * Current application model
61
  * Recursively build XML configuration tree
62
  *
63
  * @param Mage_XmlConnect_Model_Simplexml_Element $section
64
+ * @param array $subtree
65
+ * @return Mage_XmlConnect_Model_Simplexml_Element
66
  */
67
+ protected function _buildRecursive($section, $subtree)
68
  {
69
+ Mage::helper('xmlconnect')->getDeviceHelper()->checkRequiredConfigFields($subtree);
70
 
71
+ foreach ($subtree as $key => $value) {
72
  if (is_array($value)) {
73
  if ($key == 'fonts') {
74
+ $subsection = $section->addChild('fonts');
75
+ foreach ($value as $label=>$v) {
76
+ if (empty($v['name']) || empty($v['size']) || empty($v['color'])) {
77
  continue;
78
  }
79
+ $font = $subsection->addChild('font');
80
  $font->addAttribute('label', $label);
81
+ $font->addAttribute('name', $v['name']);
82
+ $font->addAttribute('size', $v['size']);
83
+ $font->addAttribute('color', $v['color']);
84
  }
85
  } elseif ($key == 'pages') {
86
+ $subsection = $section->addChild('content');
87
  foreach ($value as $page) {
88
+ $this->_buildRecursive($subsection->addChild('page'), $page);
89
  }
90
  } else {
91
+ $subsection = $section->addChild($key);
92
+ $this->_buildRecursive($subsection, $value);
93
  }
94
  } elseif ($value instanceof Mage_XmlConnect_Model_Tabs) {
95
  foreach ($value->getRenderTabs() as $tab) {
96
+ $subsection = $section->addChild('tab');
97
+ $this->_buildRecursive($subsection, $tab);
98
  }
99
  } else {
100
  $value = (string)$value;
103
  }
104
  }
105
  }
 
106
  }
107
 
108
  /**
112
  */
113
  protected function _toHtml()
114
  {
 
115
  $xml = Mage::getModel('xmlconnect/simplexml_element', '<configuration></configuration>');
116
+ $this->_buildRecursive($xml, Mage::helper('xmlconnect')->excludeXmlConfigKeys($this->_app->getRenderConf()));
 
117
  return $xml->asNiceXml();
118
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
app/code/core/Mage/XmlConnect/Block/Customer/Address/Form.php CHANGED
@@ -40,6 +40,35 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
40
  */
41
  protected $_nameWidgetBlock;
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  /**
44
  * Render customer address form xml
45
  *
@@ -48,6 +77,7 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
48
  protected function _toHtml()
49
  {
50
  $address = $this->getAddress();
 
51
  /**
52
  * Init address object and save its data to variables
53
  */
@@ -55,10 +85,8 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
55
  $billingChecked = $shippingChecked = false;
56
 
57
  if ($addressId && $address && $address->getId()) {
58
- /** @var $customerSession Mage_Customer_Model_Session */
59
- $customerSession = Mage::getSingleton('customer/session');
60
- $defaultBillingAddressId = $customerSession->getCustomer()->getDefaultBilling();
61
- $defaultShippingAddressId = $customerSession->getCustomer()->getDefaultShipping();
62
 
63
  $billingChecked = (int)$addressId == $defaultBillingAddressId;
64
  $shippingChecked = (int)$addressId == $defaultShippingAddressId;
@@ -79,7 +107,9 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
79
 
80
  /** @var Mage_XmlConnect_Model_Simplexml_Form $fromXmlObj */
81
  $fromXmlObj = Mage::getModel('xmlconnect/simplexml_form', array(
82
- 'xml_id' => 'address_form', 'action' => $action, 'use_container' => true
 
 
83
  ));
84
 
85
  $contactInfoFieldset = $fromXmlObj->addFieldset('contact_info', array(
@@ -94,7 +124,7 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
94
  ));
95
  $contactInfoFieldset->addField('telephone', 'text', array(
96
  'label' => $this->__('Telephone'),
97
- 'required' => $this->getNewCountryList() ? '1' : 'true',
98
  'value' => isset($telephone) ? $telephone : ''
99
  ));
100
  $contactInfoFieldset->addField('fax', 'text', array(
@@ -102,14 +132,13 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
102
  'value' => isset($fax) ? $fax : ''
103
  ));
104
 
105
- $addressFieldset = $fromXmlObj->addFieldset('address_info', array(
106
- 'legend' => $this->__('Address')
107
- ))->setCustomAttributes(array('legend'));
108
 
109
  $addressFieldset->addField('street', 'text', array(
110
  'name' => 'street[]',
111
  'label' => $this->__('Street Address'),
112
- 'required' => $this->getNewCountryList() ? '1' : 'true',
113
  'value' => isset($street1) ? $street1 : ''
114
  ));
115
  $addressFieldset->addField('street_2', 'text', array(
@@ -119,7 +148,7 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
119
  ));
120
  $addressFieldset->addField('city', 'text', array(
121
  'label' => $this->__('City'),
122
- 'required' => $this->getNewCountryList() ? '1' : 'true',
123
  'value' => isset($city) ? $city : ''
124
  ));
125
 
@@ -128,28 +157,26 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
128
  $region = isset($region) ? $region : null;
129
 
130
  $addressFieldset->addField('country_id', 'countryListSelect', array(
131
- 'label' => $this->__('Country'),
132
- 'required' => $this->getNewCountryList() ? '1' : 'true',
133
- 'value' => array(
134
  'country_id' => $countryId,
135
  'region_id' => $regionId,
136
  'region' => $region
137
  ),
138
- 'old_format' => !$this->getNewCountryList()
 
 
 
 
 
 
 
 
139
  ));
140
- if (!$this->getNewCountryList()) {
141
- $addressFieldset->addField('region', 'text', array(
142
- 'label' => $this->__('State/Province'),
143
- 'value' => isset($region) ? $region : ''
144
- ));
145
- $addressFieldset->addField('region_id', 'select', array(
146
- 'label' => $this->__('State/Province'),
147
- 'required' => $this->getNewCountryList() ? '1' : 'true'
148
- ));
149
- }
150
  $addressFieldset->addField('postcode', 'text', array(
151
  'label' => $this->__('Zip/Postal Code'),
152
- 'required' => $this->getNewCountryList() ? '1' : 'true',
153
  'value' => isset($postcode) ? $postcode : ''
154
  ));
155
  $addressFieldset->addField('default_billing', 'checkbox', array(
@@ -162,10 +189,7 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
162
  'value' => $shippingChecked ? $shippingChecked : 0
163
  ));
164
 
165
- /** Get custom attributes */
166
- Mage::helper('xmlconnect/customer_form_renderer')->setAttributesBlockName('customer_address_attr')
167
- ->setFormCode('customer_address_edit')->setBlockEntity($this->getAddress())
168
- ->addCustomAttributes($addressFieldset, $this->getLayout());
169
 
170
  return $fromXmlObj->getXml();
171
  }
@@ -180,8 +204,10 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
180
  Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
181
  ) {
182
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_Customer'))) {
183
- $this->setNameWidgetBlock($this->getLayout()->createBlock('customer/widget_name')
184
- ->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getCustomer()));
 
 
185
 
186
  if ($this->getNameWidgetBlock()->showPrefix()) {
187
  $this->_addPrefix($contactInfoFieldset);
@@ -224,12 +250,12 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
224
 
225
  if ($this->getNameWidgetBlock()->getPrefixOptions() === false) {
226
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('prefix'), 'text', array(
227
- 'label' => $this->getNameWidgetBlock()->__('Prefix'),
228
  'name' => $this->getNameWidgetBlock()->getFieldName('prefix')
229
  ) + $attributes);
230
  } else {
231
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('prefix'), 'select', array(
232
- 'label' => $this->getNameWidgetBlock()->__('Prefix'),
233
  'name' => $this->getNameWidgetBlock()->getFieldName('prefix'),
234
  'options' => $this->getNameWidgetBlock()->getPrefixOptions()
235
  ) + $attributes);
@@ -243,7 +269,9 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
243
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
244
  * @return Mage_XmlConnect_Block_Customer_Address_Form
245
  */
246
- protected function _addSuffix(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset)
 
 
247
  {
248
  $attributes = array();
249
  $attributes += $contactInfoFieldset->checkAttribute(
@@ -256,12 +284,12 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
256
 
257
  if ($this->getNameWidgetBlock()->getSuffixOptions() === false) {
258
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('suffix'), 'text', array(
259
- 'label' => $this->getNameWidgetBlock()->__('Suffix'),
260
  'name' => $this->getNameWidgetBlock()->getFieldName('suffix')
261
  ) + $attributes);
262
  } else {
263
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('suffix'), 'select', array(
264
- 'label' => $this->getNameWidgetBlock()->__('Suffix'),
265
  'name' => $this->getNameWidgetBlock()->getFieldName('suffix'),
266
  'options' => $this->getNameWidgetBlock()->getSuffixOptions()
267
  ) + $attributes);
@@ -275,17 +303,21 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
275
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
276
  * @return Mage_XmlConnect_Block_Customer_Address_Form
277
  */
278
- protected function _addMiddleName(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset)
 
 
279
  {
280
  $attributes = array();
281
  $attributes += $contactInfoFieldset->checkAttribute(
282
- 'value', $this->getNameWidgetBlock()->getObject()->getMiddlename()
 
283
  );
284
 
285
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('middlename'), 'text', array(
286
- 'label' => $this->getNameWidgetBlock()->__('M.I.'),
287
  'name' => $this->getNameWidgetBlock()->getFieldName('middlename')
288
  ) + $attributes);
 
289
  return $this;
290
  }
291
 
@@ -295,8 +327,9 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
295
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
296
  * @return Mage_XmlConnect_Block_Customer_Address_Form
297
  */
298
- protected function _addFirstName(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset)
299
- {
 
300
  $firstName = $this->getAddress()->getFirstname();
301
  $contactInfoFieldset->addField('firstname', 'text', array(
302
  'label' => $this->__('First Name'),
@@ -312,8 +345,9 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
312
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
313
  * @return Mage_XmlConnect_Block_Customer_Address_Form
314
  */
315
- protected function _addLastName(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset)
316
- {
 
317
  $lastName = $this->getAddress()->getLastname();
318
  $contactInfoFieldset->addField('lastname', 'text', array(
319
  'label' => $this->__('Last Name'),
@@ -326,7 +360,6 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Customer_Block_Ad
326
  /**
327
  * Add custom customer attributes
328
  *
329
- * @deprecated will delete in the next version
330
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $addressFieldset
331
  * @return Mage_XmlConnect_Block_Customer_Address_Form
332
  */
40
  */
41
  protected $_nameWidgetBlock;
42
 
43
+ /**
44
+ * Enterprise customer field renderer list as type => renderer block
45
+ *
46
+ * Original block relations:
47
+ * - 'text' => 'enterprise_customer/form_renderer_text',
48
+ * - 'textarea' => 'enterprise_customer/form_renderer_textarea',
49
+ * - 'multiline' => 'enterprise_customer/form_renderer_multiline',
50
+ * - 'date' => 'enterprise_customer/form_renderer_date',
51
+ * - 'select' => 'enterprise_customer/form_renderer_select',
52
+ * - 'multiselect' => 'enterprise_customer/form_renderer_multiselect',
53
+ * - 'boolean' => 'enterprise_customer/form_renderer_boolean',
54
+ * - 'file' => 'enterprise_customer/form_renderer_file'
55
+ * - 'image' => 'enterprise_customer/form_renderer_image'
56
+ *
57
+ * @see customer.xml layout customer_form_template_handle node
58
+ * @var array
59
+ */
60
+ protected $_customerFiledRenderer = array(
61
+ 'text' => 'xmlconnect/customer_form_renderer_text',
62
+ 'textarea' => 'xmlconnect/customer_form_renderer_textarea',
63
+ 'multiline' => 'xmlconnect/customer_form_renderer_multiline',
64
+ 'date' => 'xmlconnect/customer_form_renderer_date',
65
+ 'select' => 'xmlconnect/customer_form_renderer_select',
66
+ 'multiselect' => 'xmlconnect/customer_form_renderer_multiselect',
67
+ 'boolean' => 'xmlconnect/customer_form_renderer_boolean',
68
+ 'file' => 'xmlconnect/customer_form_renderer_file',
69
+ 'image' => 'xmlconnect/customer_form_renderer_image'
70
+ );
71
+
72
  /**
73
  * Render customer address form xml
74
  *
77
  protected function _toHtml()
78
  {
79
  $address = $this->getAddress();
80
+
81
  /**
82
  * Init address object and save its data to variables
83
  */
85
  $billingChecked = $shippingChecked = false;
86
 
87
  if ($addressId && $address && $address->getId()) {
88
+ $defaultBillingAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling();
89
+ $defaultShippingAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
 
 
90
 
91
  $billingChecked = (int)$addressId == $defaultBillingAddressId;
92
  $shippingChecked = (int)$addressId == $defaultShippingAddressId;
107
 
108
  /** @var Mage_XmlConnect_Model_Simplexml_Form $fromXmlObj */
109
  $fromXmlObj = Mage::getModel('xmlconnect/simplexml_form', array(
110
+ 'xml_id' => 'address_form',
111
+ 'action' => $action,
112
+ 'use_container' => true
113
  ));
114
 
115
  $contactInfoFieldset = $fromXmlObj->addFieldset('contact_info', array(
124
  ));
125
  $contactInfoFieldset->addField('telephone', 'text', array(
126
  'label' => $this->__('Telephone'),
127
+ 'required' => 'true',
128
  'value' => isset($telephone) ? $telephone : ''
129
  ));
130
  $contactInfoFieldset->addField('fax', 'text', array(
132
  'value' => isset($fax) ? $fax : ''
133
  ));
134
 
135
+ $addressFieldset = $fromXmlObj->addFieldset('address_info', array('legend' => $this->__('Address')))
136
+ ->setCustomAttributes(array('legend'));
 
137
 
138
  $addressFieldset->addField('street', 'text', array(
139
  'name' => 'street[]',
140
  'label' => $this->__('Street Address'),
141
+ 'required' => 'true',
142
  'value' => isset($street1) ? $street1 : ''
143
  ));
144
  $addressFieldset->addField('street_2', 'text', array(
148
  ));
149
  $addressFieldset->addField('city', 'text', array(
150
  'label' => $this->__('City'),
151
+ 'required' => 'true',
152
  'value' => isset($city) ? $city : ''
153
  ));
154
 
157
  $region = isset($region) ? $region : null;
158
 
159
  $addressFieldset->addField('country_id', 'countryListSelect', array(
160
+ 'label' => $this->__('Country'),
161
+ 'required' => 'true',
162
+ 'value' => array(
163
  'country_id' => $countryId,
164
  'region_id' => $regionId,
165
  'region' => $region
166
  ),
167
+ 'old_format' => true
168
+ ));
169
+ $addressFieldset->addField('region', 'text', array(
170
+ 'label' => $this->__('State/Province'),
171
+ 'value' => isset($region) ? $region : ''
172
+ ));
173
+ $addressFieldset->addField('region_id', 'select', array(
174
+ 'label' => $this->__('State/Province'),
175
+ 'required' => 'true',
176
  ));
 
 
 
 
 
 
 
 
 
 
177
  $addressFieldset->addField('postcode', 'text', array(
178
  'label' => $this->__('Zip/Postal Code'),
179
+ 'required' => 'true',
180
  'value' => isset($postcode) ? $postcode : ''
181
  ));
182
  $addressFieldset->addField('default_billing', 'checkbox', array(
189
  'value' => $shippingChecked ? $shippingChecked : 0
190
  ));
191
 
192
+ $this->_addCustomAddressAttributes($addressFieldset);
 
 
 
193
 
194
  return $fromXmlObj->getXml();
195
  }
204
  Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
205
  ) {
206
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_Customer'))) {
207
+ $this->setNameWidgetBlock(
208
+ $this->getLayout()->createBlock('customer/widget_name')->setObject(
209
+ $this->getAddress()->getFirstname() ? $this->getAddress() : $this->getCustomer()
210
+ ));
211
 
212
  if ($this->getNameWidgetBlock()->showPrefix()) {
213
  $this->_addPrefix($contactInfoFieldset);
250
 
251
  if ($this->getNameWidgetBlock()->getPrefixOptions() === false) {
252
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('prefix'), 'text', array(
253
+ 'label' => $this->__('Prefix'),
254
  'name' => $this->getNameWidgetBlock()->getFieldName('prefix')
255
  ) + $attributes);
256
  } else {
257
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('prefix'), 'select', array(
258
+ 'label' => $this->__('Prefix'),
259
  'name' => $this->getNameWidgetBlock()->getFieldName('prefix'),
260
  'options' => $this->getNameWidgetBlock()->getPrefixOptions()
261
  ) + $attributes);
269
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
270
  * @return Mage_XmlConnect_Block_Customer_Address_Form
271
  */
272
+ protected function _addSuffix(
273
+ Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
274
+ )
275
  {
276
  $attributes = array();
277
  $attributes += $contactInfoFieldset->checkAttribute(
284
 
285
  if ($this->getNameWidgetBlock()->getSuffixOptions() === false) {
286
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('suffix'), 'text', array(
287
+ 'label' => $this->__('Suffix'),
288
  'name' => $this->getNameWidgetBlock()->getFieldName('suffix')
289
  ) + $attributes);
290
  } else {
291
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('suffix'), 'select', array(
292
+ 'label' => $this->__('Suffix'),
293
  'name' => $this->getNameWidgetBlock()->getFieldName('suffix'),
294
  'options' => $this->getNameWidgetBlock()->getSuffixOptions()
295
  ) + $attributes);
303
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
304
  * @return Mage_XmlConnect_Block_Customer_Address_Form
305
  */
306
+ protected function _addMiddleName(
307
+ Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
308
+ )
309
  {
310
  $attributes = array();
311
  $attributes += $contactInfoFieldset->checkAttribute(
312
+ 'value',
313
+ $this->getNameWidgetBlock()->getObject()->getMiddlename()
314
  );
315
 
316
  $contactInfoFieldset->addField($this->getNameWidgetBlock()->getFieldId('middlename'), 'text', array(
317
+ 'label' => $this->__('M.I.'),
318
  'name' => $this->getNameWidgetBlock()->getFieldName('middlename')
319
  ) + $attributes);
320
+
321
  return $this;
322
  }
323
 
327
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
328
  * @return Mage_XmlConnect_Block_Customer_Address_Form
329
  */
330
+ protected function _addFirstName(
331
+ Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
332
+ ) {
333
  $firstName = $this->getAddress()->getFirstname();
334
  $contactInfoFieldset->addField('firstname', 'text', array(
335
  'label' => $this->__('First Name'),
345
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
346
  * @return Mage_XmlConnect_Block_Customer_Address_Form
347
  */
348
+ protected function _addLastName(
349
+ Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $contactInfoFieldset
350
+ ) {
351
  $lastName = $this->getAddress()->getLastname();
352
  $contactInfoFieldset->addField('lastname', 'text', array(
353
  'label' => $this->__('Last Name'),
360
  /**
361
  * Add custom customer attributes
362
  *
 
363
  * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $addressFieldset
364
  * @return Mage_XmlConnect_Block_Customer_Address_Form
365
  */
app/code/core/Mage/XmlConnect/Block/Customer/Address/List.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Customer_Address_List extends Mage_Core_Block_Abstract
35
  {
36
  /**
37
  * Render customer address list xml
@@ -43,10 +43,10 @@ class Mage_XmlConnect_Block_Customer_Address_List extends Mage_Core_Block_Abstra
43
  $addressXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<address></address>');
44
  $customer = Mage::getSingleton('customer/session')->getCustomer();
45
 
46
- $billingAddssesId = $customer->getDefaultBilling();
47
- $shippingAddssesId = $customer->getDefaultShipping();
48
- $billingAddress = $customer->getAddressById($billingAddssesId);
49
- $shippingAddress = $customer->getAddressById($shippingAddssesId);
50
 
51
  if ($billingAddress && $billingAddress->getId()) {
52
  $item = $addressXmlObj->addChild('item');
@@ -60,13 +60,13 @@ class Mage_XmlConnect_Block_Customer_Address_List extends Mage_Core_Block_Abstra
60
  $item->addAttribute('default_shipping', 1);
61
  $this->prepareAddressData($shippingAddress, $item);
62
  }
63
- $additionalAddresses = $customer->getAdditionalAddresses();
64
- if ($additionalAddresses) {
65
- foreach ($additionalAddresses as $address) {
66
  $item = $addressXmlObj->addChild('item');
67
  $item->addAttribute('label', $this->__('Additional Address'));
68
  $item->addAttribute('additional', 1);
69
- $this->prepareAddressData($address, $item);
70
  }
71
  }
72
 
@@ -81,9 +81,9 @@ class Mage_XmlConnect_Block_Customer_Address_List extends Mage_Core_Block_Abstra
81
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
82
  * @return array
83
  */
84
- public function prepareAddressData(Mage_Customer_Model_Address $address,
85
- Mage_XmlConnect_Model_Simplexml_Element $item)
86
- {
87
  if (!$address) {
88
  return array();
89
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Customer_Address_List extends Mage_Core_Block_Template
35
  {
36
  /**
37
  * Render customer address list xml
43
  $addressXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<address></address>');
44
  $customer = Mage::getSingleton('customer/session')->getCustomer();
45
 
46
+ $_billingAddssesId = $customer->getDefaultBilling();
47
+ $_shippingAddssesId = $customer->getDefaultShipping();
48
+ $billingAddress = $customer->getAddressById($_billingAddssesId);
49
+ $shippingAddress = $customer->getAddressById($_shippingAddssesId);
50
 
51
  if ($billingAddress && $billingAddress->getId()) {
52
  $item = $addressXmlObj->addChild('item');
60
  $item->addAttribute('default_shipping', 1);
61
  $this->prepareAddressData($shippingAddress, $item);
62
  }
63
+ $_additionalAddresses = $customer->getAdditionalAddresses();
64
+ if ($_additionalAddresses) {
65
+ foreach ($_additionalAddresses as $_address) {
66
  $item = $addressXmlObj->addChild('item');
67
  $item->addAttribute('label', $this->__('Additional Address'));
68
  $item->addAttribute('additional', 1);
69
+ $this->prepareAddressData($_address, $item);
70
  }
71
  }
72
 
81
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
82
  * @return array
83
  */
84
+ public function prepareAddressData(
85
+ Mage_Customer_Model_Address $address, Mage_XmlConnect_Model_Simplexml_Element $item
86
+ ) {
87
  if (!$address) {
88
  return array();
89
  }
app/code/core/Mage/XmlConnect/Block/Customer/Downloads.php DELETED
@@ -1,80 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Customer Downloadable Products list xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Customer_Downloads extends Mage_Downloadable_Block_Customer_Products_List
35
- {
36
- /**
37
- * Render downloadable products list xml
38
- *
39
- * @return string
40
- */
41
- protected function _toHtml()
42
- {
43
- $items = $this->getItems();
44
-
45
- if (count($items)) {
46
- /** @var $xmlModel Mage_XmlConnect_Model_Simplexml_Element */
47
- $xmlModel = Mage::getModel('xmlconnect/simplexml_element', '<downloads></downloads>');
48
-
49
- foreach ($items as $item) {
50
- $itemXmlObj = $xmlModel->addCustomChild('item');
51
- $itemXmlObj->addCustomChild('title', $item->getPurchased()->getProductName());
52
- $itemXmlObj->addCustomChild('link', $this->getDownloadUrl($item), array(
53
- 'label' => $item->getLinkTitle()
54
- ));
55
- $itemXmlObj->addCustomChild('status', Mage::helper('downloadable')->__(ucfirst($item->getStatus())));
56
- $itemXmlObj->addCustomChild('downloads_limit', $this->getRemainingDownloads($item));
57
- $itemXmlObj->addCustomChild('date', $this->formatDate($item->getPurchased()->getCreatedAt()));
58
- $itemXmlObj->addCustomChild('order_id', $item->getPurchased()->getOrderId());
59
- $itemXmlObj->addCustomChild('real_order_id', $item->getPurchased()->getOrderIncrementId());
60
- }
61
- } else {
62
- Mage::throwException(
63
- Mage::helper('downloadable')->__('You have not purchased any downloadable products yet.')
64
- );
65
- }
66
-
67
- return $xmlModel->asNiceXml();
68
- }
69
-
70
- /**
71
- * Return url to download link
72
- *
73
- * @param Mage_Downloadable_Model_Link_Purchased_Item $item
74
- * @return string
75
- */
76
- public function getDownloadUrl($item)
77
- {
78
- return $this->getUrl('downloadable/download/link', array('id' => $item->getLinkHash(), '_secure' => true));
79
- }
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Customer/Form.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Customer_Form extends Mage_Core_Block_Abstract
35
  {
36
  /**
37
  * Render customer form xml
@@ -40,160 +40,57 @@ class Mage_XmlConnect_Block_Customer_Form extends Mage_Core_Block_Abstract
40
  */
41
  protected function _toHtml()
42
  {
43
- $this->_setCustomerFields();
44
- $this->_prepareFormData();
45
-
46
- $action = Mage::helper('xmlconnect')->getActionUrl($this->getFormAction());
47
-
48
- /** @var Mage_XmlConnect_Model_Simplexml_Form $fromXmlObj */
49
- $fromXmlObj = Mage::getModel('xmlconnect/simplexml_form', array(
50
- 'xml_id' => 'account_form',
51
- 'action' => $action,
52
- 'use_container' => true
53
- ));
54
-
55
- $customerFieldset = $fromXmlObj->addFieldset('account_info', array(
56
- 'legend' => $this->__('Account Information')
57
- ))->setCustomAttributes(array('legend'));
58
-
59
- if ($this->getIsCheckoutRegistrationPage()) {
60
- $customerFieldset->addField('checkout_page_registration', 'text', array(
61
- 'label' => $this->__('Checkout Page Registration'),
62
- 'value' => true,
63
- 'visible' => 0
64
- ));
65
- }
66
-
67
- $this->_addCustomerData($customerFieldset);
68
-
69
- /** Add custom attributes for customer */
70
- Mage::helper('xmlconnect/customer_form_renderer')->setAttributesBlockName($this->getAttributesBlockName())
71
- ->setFormCode($this->getCustomerFormCode())->setBlockEntity($this->getCustomer())
72
- ->addCustomAttributes($customerFieldset, $this->getLayout());
73
-
74
- if ($this->getIsEditPage()) {
75
- $customerFieldset->addField('change_password', 'checkbox', array('label' => $this->__('Change Password')));
76
-
77
- $customerPasswordFieldset = $fromXmlObj->addFieldset('password_edit', array(
78
- 'legend' => $this->__('Change Password')
79
- ))->setCustomAttributes(array('legend'));
80
-
81
- $this->_addPasswordFields($customerPasswordFieldset);
82
  } else {
83
- $this->_addPasswordFields($customerFieldset);
84
  }
85
 
86
- return $fromXmlObj->getXml();
87
- }
88
-
89
- /**
90
- * Set customers fields for edit form
91
- *
92
- * @return Mage_XmlConnect_Block_Customer_Form
93
- */
94
- protected function _setCustomerFields()
95
- {
96
- $customer = $this->getCustomer();
97
- if ($this->getIsEditPage() && $customer && $customer->getId()) {
98
- $this->setFirstname($customer->getFirstname());
99
- $this->setLastname($customer->getLastname());
100
- $this->setEmail($customer->getEmail());
101
- }
102
- return $this;
103
- }
104
-
105
- /**
106
- * Set form data
107
- *
108
- * @return Mage_XmlConnect_Block_Customer_Form
109
- */
110
- protected function _prepareFormData()
111
- {
112
- if ($this->getIsEditPage()) {
113
- $this->setFormAction('xmlconnect/customer/edit');
114
- $this->setPasswordLabel($this->__('New Password'));
115
- $this->setConfirmLabel($this->__('Confirm New Password'));
116
  } else {
117
- $this->setFormAction('xmlconnect/customer/save');
118
- $this->setPasswordLabel($this->__('Password'));
119
- $this->setConfirmLabel($this->__('Confirm Password'));
120
- $this->setIsPasswordRequired(true);
 
 
 
 
121
  }
122
 
123
- return $this;
124
- }
125
-
126
-
127
- /**
128
- * Add customer fields - first name, last name and email
129
- *
130
- * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $customerFieldset
131
- * @return Mage_XmlConnect_Block_Customer_Form
132
- */
133
- protected function _addCustomerData(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $customerFieldset)
134
- {
135
- $customerFieldset->addField('firstname', 'text', array(
136
- 'label' => $this->__('First Name'),
137
- 'required' => 'true',
138
- 'value' => $this->getFirstname()
139
- ));
140
- $customerFieldset->addField('lastname', 'text', array(
141
- 'label' => $this->__('Last Name'),
142
- 'required' => 'true',
143
- 'value' => $this->getLastname()
144
- ));
145
- $customerFieldset->addField('email', 'text', array(
146
- 'label' => $this->__('Email'), 'required' => 'true', 'value' => $this->getEmail()
147
- ))->addValidator()->addRule(array('type' => 'email', 'message' => $this->__('Wrong email format')));
148
-
149
- return $this;
150
- }
151
-
152
- /**
153
- * Add password fields
154
- *
155
- * Add to form current password, password and password confirmation fields
156
- *
157
- * @param Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $formFieldset
158
- * @return Mage_XmlConnect_Block_Customer_Form
159
- */
160
- protected function _addPasswordFields(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $formFieldset)
161
- {
162
- /**
163
- * Return password confirmation validator in old format
164
- */
165
- if ($this->getIsEditPage()) {
166
- $formFieldset->addField('current_password', 'password', array(
167
- 'label' => $this->__('Current Password'),
168
- 'required' => 'true'
169
- ));
170
- }
171
- $formFieldset->addField('password', 'password', array(
172
- 'label' => $this->getPasswordLabel()
173
- ) + $this->_getRequiredParam());
174
-
175
- $field = $formFieldset->addField('confirmation', 'password', array(
176
- 'label' => $this->getConfirmLabel()
177
- ) + $this->_getRequiredParam())->addValidator();
178
-
179
- $field->getXmlObject()->addCustomChild('validator', 'password', array(
180
- 'type' => 'confirmation',
181
- 'message' => $this->__('Regular and confirmation passwords must be equal')
182
- ));
183
-
184
- return $this;
185
- }
186
-
187
- /**
188
- * Get is password required param
189
- *
190
- * @return array
191
- */
192
- protected function _getRequiredParam()
193
- {
194
- if ($this->getIsPasswordRequired()) {
195
- return array('required' => 'true');
196
- }
197
- return array();
198
  }
199
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Customer_Form extends Mage_Core_Block_Template
35
  {
36
  /**
37
  * Render customer form xml
40
  */
41
  protected function _toHtml()
42
  {
43
+ $editFlag = (int)$this->getRequest()->getParam('edit');
44
+ $customer = $this->getCustomer();
45
+ /** @var $xmlModel Mage_XmlConnect_Model_Simplexml_Element */
46
+ $xmlModel = Mage::getModel('xmlconnect/simplexml_element', '<node></node>');
47
+ //Enterprise_Customer
48
+ if ($editFlag == 1 && $customer && $customer->getId()) {
49
+ $firstname = $xmlModel->escapeXml($customer->getFirstname());
50
+ $lastname = $xmlModel->escapeXml($customer->getLastname());
51
+ $email = $xmlModel->escapeXml($customer->getEmail());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  } else {
53
+ $firstname = $lastname = $email = '';
54
  }
55
 
56
+ if ($editFlag) {
57
+ $passwordManageXml = '
58
+ <field name="change_password" type="checkbox" label="' . $xmlModel->escapeXml($this->__('Change Password')) . '"/>
59
+ </fieldset>
60
+ <fieldset>
61
+ <field name="current_password" type="password" label="' . $xmlModel->escapeXml($this->__('Current Password')) . '"/>
62
+ <field name="password" type="password" label="' . $xmlModel->escapeXml($this->__('New Password')) . '"/>
63
+ <field name="confirmation" type="password" label="' . $xmlModel->escapeXml($this->__('Confirm New Password')) . '">
64
+ <validators>
65
+ <validator type="confirmation" message="' . $xmlModel->escapeXml($this->__('Regular and confirmation passwords must be equal')) . '">password</validator>
66
+ </validators>
67
+ </field>
68
+ </fieldset>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  } else {
70
+ $passwordManageXml = '
71
+ <field name="password" type="password" label="' . $xmlModel->escapeXml($this->__('Password')) . '" required="true"/>
72
+ <field name="confirmation" type="password" label="' . $xmlModel->escapeXml($this->__('Confirm Password')) . '" required="true">
73
+ <validators>
74
+ <validator type="confirmation" message="' . $xmlModel->escapeXml($this->__('Regular and confirmation passwords must be equal')) . '">password</validator>
75
+ </validators>
76
+ </field>
77
+ </fieldset>';
78
  }
79
 
80
+ $xml = <<<EOT
81
+ <form name="account_form" method="post">
82
+ <fieldset>
83
+ <field name="firstname" type="text" label="{$xmlModel->escapeXml($this->__('First Name'))}" required="true" value="$firstname" />
84
+ <field name="lastname" type="text" label="{$xmlModel->escapeXml($this->__('Last Name'))}" required="true" value="$lastname" />
85
+ <field name="email" type="text" label="{$xmlModel->escapeXml($this->__('Email'))}" required="true" value="$email">
86
+ <validators>
87
+ <validator type="email" message="{$xmlModel->escapeXml($this->__('Wrong email format'))}"/>
88
+ </validators>
89
+ </field>
90
+ $passwordManageXml
91
+ </form>
92
+ EOT;
93
+
94
+ return $xml;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
96
  }
app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Date.php CHANGED
@@ -48,20 +48,20 @@ class Mage_XmlConnect_Block_Customer_Form_Renderer_Date extends Enterprise_Custo
48
  protected function _prepareValues()
49
  {
50
  return array('day' => array(
51
- 'id' => $this->getHtmlId('day'),
52
- 'title' => $this->__('Day'),
53
- 'label' => $this->__('DD'),
54
- 'value' => $this->getDay()
55
- ), 'month' => array(
56
- 'id' => $this->getHtmlId('month'),
57
- 'title' => $this->__('Month'),
58
- 'label' => $this->__('MM'),
59
- 'value' => $this->getMonth()
60
- ), 'year' => array(
61
- 'id' => $this->getHtmlId('year'),
62
- 'title' => $this->__('Year'),
63
- 'label' => $this->__('YYYY'),
64
- 'value' => $this->getYear()
65
  ));
66
  }
67
 
@@ -82,9 +82,7 @@ class Mage_XmlConnect_Block_Customer_Form_Renderer_Date extends Enterprise_Custo
82
 
83
  $attributes += Mage::helper('xmlconnect/customer_form_renderer')
84
  ->addTitleAndRequiredAttr($fieldsetXmlObj, $this);
85
-
86
  $fieldXmlObj = $fieldsetXmlObj->addField($this->getHtmlId('full'), $this->_filedType, $attributes);
87
-
88
  $validateRules = $this->getAttributeObject()->getValidateRules();
89
 
90
  if (!empty($validateRules)) {
48
  protected function _prepareValues()
49
  {
50
  return array('day' => array(
51
+ 'id' => $this->getHtmlId('day'),
52
+ 'title' => $this->__('Day'),
53
+ 'label' => $this->__('DD'),
54
+ 'value' => $this->getDay()
55
+ ), 'month' => array(
56
+ 'id' => $this->getHtmlId('month'),
57
+ 'title' => $this->__('Month'),
58
+ 'label' => $this->__('MM'),
59
+ 'value' => $this->getMonth()
60
+ ), 'year' => array(
61
+ 'id' => $this->getHtmlId('year'),
62
+ 'title' => $this->__('Year'),
63
+ 'label' => $this->__('YYYY'),
64
+ 'value' => $this->getYear()
65
  ));
66
  }
67
 
82
 
83
  $attributes += Mage::helper('xmlconnect/customer_form_renderer')
84
  ->addTitleAndRequiredAttr($fieldsetXmlObj, $this);
 
85
  $fieldXmlObj = $fieldsetXmlObj->addField($this->getHtmlId('full'), $this->_filedType, $attributes);
 
86
  $validateRules = $this->getAttributeObject()->getValidateRules();
87
 
88
  if (!empty($validateRules)) {
app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Text.php CHANGED
@@ -49,16 +49,15 @@ class Mage_XmlConnect_Block_Customer_Form_Renderer_Text extends Enterprise_Custo
49
  public function addFieldToXmlObj(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $fieldsetXmlObj)
50
  {
51
  $attributes = array(
52
- 'label' => $this->getLabel(),
53
- 'name' => $this->getFieldName(),
54
- 'value' => $this->getEscapedValue()
55
  );
56
 
57
  $attributes += Mage::helper('xmlconnect/customer_form_renderer')
58
  ->addTitleAndRequiredAttr($fieldsetXmlObj, $this);
59
 
60
- $fieldXmlObj = $fieldsetXmlObj->addField($this->getHtmlId(), $this->_filedType, $attributes);
61
- $validateRules = $this->getAttributeObject()->getValidateRules();
 
62
 
63
  if (!empty($validateRules)) {
64
  $validatorXmlObj = $fieldXmlObj->addValidator();
49
  public function addFieldToXmlObj(Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset $fieldsetXmlObj)
50
  {
51
  $attributes = array(
52
+ 'label' => $this->getLabel(), 'name' => $this->getFieldName(), 'value' => $this->getEscapedValue()
 
 
53
  );
54
 
55
  $attributes += Mage::helper('xmlconnect/customer_form_renderer')
56
  ->addTitleAndRequiredAttr($fieldsetXmlObj, $this);
57
 
58
+ $fieldXmlObj = $fieldsetXmlObj->addField($this->getHtmlId(), $this->_filedType, $attributes);
59
+
60
+ $validateRules = $this->getAttributeObject()->getValidateRules();
61
 
62
  if (!empty($validateRules)) {
63
  $validatorXmlObj = $fieldXmlObj->addValidator();
app/code/core/Mage/XmlConnect/Block/Customer/Order/Details.php CHANGED
@@ -71,13 +71,12 @@ class Mage_XmlConnect_Block_Customer_Order_Details extends Mage_Payment_Block_In
71
  'label' => $this->__('Order #%s - %s', $order->getRealOrderId(), $order->getStatusLabel()),
72
  'order_date' => $this->__('Order Date: %s', $orderDate)
73
  ));
74
-
75
- $billing = Mage::helper('xmlconnect')->trimLineBreaks($order->getBillingAddress()->format('text'));
76
- $orderXmlObj->addCustomChild('billing_address', $billing);
77
-
78
  if (!$order->getIsVirtual()) {
79
  $shipping = Mage::helper('xmlconnect')->trimLineBreaks($order->getShippingAddress()->format('text'));
 
 
80
  $orderXmlObj->addCustomChild('shipping_address', $shipping);
 
81
 
82
  if ($order->getShippingDescription()) {
83
  $shippingMethodDescription = $order->getShippingDescription();
@@ -89,12 +88,12 @@ class Mage_XmlConnect_Block_Customer_Order_Details extends Mage_Payment_Block_In
89
 
90
  $this->_addPaymentMethodInfoToXmlObj($orderXmlObj);
91
 
92
- $itemsBlock = $this->getLayout()->getBlock('order.items');
93
  if ($itemsBlock) {
94
  /** @var $itemsBlock Mage_XmlConnect_Block_Customer_Order_Items */
95
  $itemsBlock->setItems($order->getItemsCollection());
96
  $itemsBlock->addItemsToXmlObject($orderXmlObj);
97
- $totalsBlock = $this->getLayout()->getBlock('order.totals');
98
  if ($totalsBlock) {
99
  $totalsBlock->setOrder($order);
100
  $totalsBlock->addTotalsToXmlObject($orderXmlObj);
@@ -142,9 +141,9 @@ class Mage_XmlConnect_Block_Customer_Order_Details extends Mage_Payment_Block_In
142
  if (!empty($specificInfo)) {
143
  foreach ($specificInfo as $label => $value) {
144
  if ($value) {
145
- $paymentNode->addCustomChild('item',implode($this->getValueAsArray($value, true), '\n'), array(
146
- 'label' => $label
147
- ));
148
  }
149
  }
150
  }
@@ -177,6 +176,10 @@ class Mage_XmlConnect_Block_Customer_Order_Details extends Mage_Payment_Block_In
177
  */
178
  protected function _formatAddress($address)
179
  {
180
- return preg_replace(array('@\r@', '@\n+@'), array('', '\n'), $address);
 
 
 
 
181
  }
182
  }
71
  'label' => $this->__('Order #%s - %s', $order->getRealOrderId(), $order->getStatusLabel()),
72
  'order_date' => $this->__('Order Date: %s', $orderDate)
73
  ));
 
 
 
 
74
  if (!$order->getIsVirtual()) {
75
  $shipping = Mage::helper('xmlconnect')->trimLineBreaks($order->getShippingAddress()->format('text'));
76
+ $billing = Mage::helper('xmlconnect')->trimLineBreaks($order->getBillingAddress()->format('text'));
77
+
78
  $orderXmlObj->addCustomChild('shipping_address', $shipping);
79
+ $orderXmlObj->addCustomChild('billing_address', $billing);
80
 
81
  if ($order->getShippingDescription()) {
82
  $shippingMethodDescription = $order->getShippingDescription();
88
 
89
  $this->_addPaymentMethodInfoToXmlObj($orderXmlObj);
90
 
91
+ $itemsBlock = $this->getLayout()->getBlock('xmlconnect.customer.order.items');
92
  if ($itemsBlock) {
93
  /** @var $itemsBlock Mage_XmlConnect_Block_Customer_Order_Items */
94
  $itemsBlock->setItems($order->getItemsCollection());
95
  $itemsBlock->addItemsToXmlObject($orderXmlObj);
96
+ $totalsBlock = $this->getLayout()->getBlock('xmlconnect.customer.order.totals');
97
  if ($totalsBlock) {
98
  $totalsBlock->setOrder($order);
99
  $totalsBlock->addTotalsToXmlObject($orderXmlObj);
141
  if (!empty($specificInfo)) {
142
  foreach ($specificInfo as $label => $value) {
143
  if ($value) {
144
+ $paymentNode->addCustomChild('item', implode($this->getValueAsArray($value, true), '\n'),
145
+ array('label' => $label)
146
+ );
147
  }
148
  }
149
  }
176
  */
177
  protected function _formatAddress($address)
178
  {
179
+ return preg_replace(
180
+ array('@\r@', '@\n+@'),
181
+ array('', '\n'),
182
+ $address
183
+ );
184
  }
185
  }
app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Bundle.php CHANGED
@@ -42,14 +42,10 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Bundle extends Mage_Bun
42
  */
43
  public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
44
  {
45
- if ($this->getNewApi()) {
46
- $this->addItemToXmlObjectApi23($orderItemXmlObj);
47
- return;
48
- }
49
  /** @var $parentItem Mage_Sales_Model_Order_Item */
50
  $parentItem = $this->getItem();
51
  $items = array_merge(array($parentItem), $parentItem->getChildrenItems());
52
- $prevOptionId = '';
53
 
54
  /** @var $weeeHelper Mage_Weee_Helper_Data */
55
  $weeeHelper = $this->helper('weee');
@@ -77,7 +73,7 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Bundle extends Mage_Bun
77
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_1 => $typeOfDisplay1,
78
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_2 => $typeOfDisplay2,
79
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_4 => $typeOfDisplay4,
80
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_14 => $typeOfDisplay014
81
  ));
82
  $this->setWeeeTaxes($weeeHelper->getApplied($parentItem));
83
 
@@ -96,9 +92,9 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Bundle extends Mage_Bun
96
 
97
  if ($isOption) {
98
  $attributes = $this->getSelectionAttributes($item);
99
- if ($prevOptionId != $attributes['option_id']) {
100
  $objectXml->addAttribute('label', $objectXml->xmlAttribute($attributes['option_label']));
101
- $prevOptionId = $attributes['option_id'];
102
  }
103
  }
104
 
@@ -121,7 +117,10 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Bundle extends Mage_Bun
121
  // Price excluding tax
122
  if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
123
  Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml(
124
- $this, $parentItem, $priceXml, $subtotalXml
 
 
 
125
  );
126
  }
127
 
@@ -135,7 +134,9 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Bundle extends Mage_Bun
135
 
136
  // set quantities
137
  /** @var $qtyXml Mage_XmlConnect_Model_Simplexml_Element */
138
- if (($isOption && $this->isChildCalculated()) || (!$isOption && !$this->isChildCalculated())) {
 
 
139
  $qtyXml = $objectXml->addChild('qty');
140
  if ($item->getQtyOrdered() > 0) {
141
  $qtyXml->addCustomChild('value', $item->getQtyOrdered() * 1, array(
@@ -172,138 +173,6 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Bundle extends Mage_Bun
172
  Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
173
  }
174
 
175
- /**
176
- * Add item to XML object. Api version 23
177
- *
178
- * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
179
- * @return null
180
- */
181
- public function addItemToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
182
- {
183
- /** @var $parentItem Mage_Sales_Model_Order_Item */
184
- $parentItem = $this->getItem();
185
- $items = array_merge(array($parentItem), $parentItem->getChildrenItems());
186
- $prevOptionId = '';
187
-
188
- /** @var $weeeHelper Mage_Weee_Helper_Data */
189
- $weeeHelper = $this->helper('weee');
190
- /** @var $taxHelper Mage_Tax_Helper_Data */
191
- $taxHelper = $this->helper('tax');
192
-
193
- /** @var $itemXml Mage_XmlConnect_Model_Simplexml_Element */
194
- $itemXml = $orderItemXmlObj->addChild('item');
195
- /** @var $optionsXml Mage_XmlConnect_Model_Simplexml_Element */
196
- $optionsXml = $itemXml->addChild('related_products');
197
-
198
- $this->setWeeeTaxAppliedAmount($parentItem->getWeeeTaxAppliedAmount());
199
- $this->setWeeeTaxDisposition($parentItem->getWeeeTaxDisposition());
200
-
201
- $typeOfDisplay1 = $weeeHelper->typeOfDisplay($parentItem, 1, 'sales')
202
- && $this->getWeeeTaxAppliedAmount();
203
- $typeOfDisplay2 = $weeeHelper->typeOfDisplay($parentItem, 2, 'sales')
204
- && $this->getWeeeTaxAppliedAmount();
205
- $typeOfDisplay4 = $weeeHelper->typeOfDisplay($parentItem, 4, 'sales')
206
- && $this->getWeeeTaxAppliedAmount();
207
- $typeOfDisplay014 = $weeeHelper->typeOfDisplay($parentItem, array(0, 1, 4), 'sales')
208
- && $this->getWeeeTaxAppliedAmount();
209
-
210
- $this->setTypesOfDisplay(array(
211
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_1 => $typeOfDisplay1,
212
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_2 => $typeOfDisplay2,
213
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_4 => $typeOfDisplay4,
214
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_14 => $typeOfDisplay014
215
- ));
216
- $this->setWeeeTaxes($weeeHelper->getApplied($parentItem));
217
-
218
- /** @var $item Mage_Sales_Model_Order_Item */
219
- foreach ($items as $item) {
220
- $isOption = $item->getParentItem() ? true : false;
221
-
222
- /** @var $objectXml Mage_XmlConnect_Model_Simplexml_Element */
223
- if ($isOption) {
224
- $objectXml = $optionsXml->addChild('item');
225
- } else {
226
- $objectXml = $itemXml;
227
- }
228
- $objectXml->addAttribute('product_id', $item->getProductId());
229
- $objectXml->addCustomChild('entity_type', $item->getProductType());
230
-
231
- if ($isOption) {
232
- $attributes = $this->getSelectionAttributes($item);
233
- if ($prevOptionId != $attributes['option_id']) {
234
- $objectXml->addAttribute('label', $objectXml->xmlAttribute($attributes['option_label']));
235
- $prevOptionId = $attributes['option_id'];
236
- }
237
- }
238
-
239
- $objectXml->addCustomChild('sku', Mage::helper('core/string')->splitInjection($item->getSku()));
240
-
241
- if ($isOption) {
242
- $name = $this->getValueHtml($item);
243
- } else {
244
- $name = $item->getName();
245
- }
246
- $objectXml->addCustomChild('name', $name);
247
-
248
- // set prices exactly for the Bundle product, but not for related products
249
- if (!$isOption) {
250
- $priceXml = $itemXml->addCustomChild('price_list');
251
- $priceInfoXml = $priceXml->addCustomChild('prices', null, array('id' => 'price'));
252
- $subtotalInfoXml = $priceXml->addCustomChild('prices', null, array('id' => 'subtotal'));
253
- // Price excluding tax
254
- if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
255
- Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXmlApi23(
256
- $this, $parentItem, $priceInfoXml, $subtotalInfoXml
257
- );
258
- }
259
-
260
- // Price including tax
261
- if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) {
262
- Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXmlApi23(
263
- $this, $parentItem, $priceInfoXml, $subtotalInfoXml, true
264
- );
265
- }
266
- }
267
-
268
- // set quantities
269
- /** @var $qtyXml Mage_XmlConnect_Model_Simplexml_Element */
270
- if (($isOption && $this->isChildCalculated()) || (!$isOption && !$this->isChildCalculated())) {
271
- $qtyXml = $objectXml->addChild('quantity');
272
- if ($item->getQtyOrdered() > 0) {
273
- $qtyXml->addCustomChild('value', $item->getQtyOrdered() * 1, array(
274
- 'label' => Mage::helper('sales')->__('Ordered')
275
- ));
276
- }
277
- if ($item->getQtyShipped() > 0 && !$this->isShipmentSeparately()) {
278
- $qtyXml->addCustomChild('value', $item->getQtyShipped() * 1, array(
279
- 'label' => Mage::helper('sales')->__('Shipped')
280
- ));
281
- }
282
- if ($item->getQtyCanceled() > 0) {
283
- $qtyXml->addCustomChild('value', $item->getQtyCanceled() * 1, array(
284
- 'label' => Mage::helper('sales')->__('Canceled')
285
- ));
286
- }
287
- if ($item->getQtyRefunded() > 0) {
288
- $qtyXml->addCustomChild('value', $item->getQtyRefunded() * 1, array(
289
- 'label' => Mage::helper('sales')->__('Refunded')
290
- ));
291
- }
292
- } elseif ($item->getQtyShipped() > 0 && $isOption && $this->isShipmentSeparately()) {
293
- $qtyXml = $objectXml->addChild('quantity');
294
- $qtyXml->addCustomChild('value', $item->getQtyShipped() * 1, array(
295
- 'label' => Mage::helper('sales')->__('Shipped')
296
- ));
297
- }
298
- }
299
-
300
- if ($parentItem->getDescription()) {
301
- $itemXml->addCustomChild('description', $parentItem->getDescription());
302
- }
303
-
304
- Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
305
- }
306
-
307
  /**
308
  * Prepare option data for output
309
  *
42
  */
43
  public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
44
  {
 
 
 
 
45
  /** @var $parentItem Mage_Sales_Model_Order_Item */
46
  $parentItem = $this->getItem();
47
  $items = array_merge(array($parentItem), $parentItem->getChildrenItems());
48
+ $_prevOptionId = '';
49
 
50
  /** @var $weeeHelper Mage_Weee_Helper_Data */
51
  $weeeHelper = $this->helper('weee');
73
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_1 => $typeOfDisplay1,
74
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_2 => $typeOfDisplay2,
75
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_4 => $typeOfDisplay4,
76
+ Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_14 => $typeOfDisplay014,
77
  ));
78
  $this->setWeeeTaxes($weeeHelper->getApplied($parentItem));
79
 
92
 
93
  if ($isOption) {
94
  $attributes = $this->getSelectionAttributes($item);
95
+ if ($_prevOptionId != $attributes['option_id']) {
96
  $objectXml->addAttribute('label', $objectXml->xmlAttribute($attributes['option_label']));
97
+ $_prevOptionId = $attributes['option_id'];
98
  }
99
  }
100
 
117
  // Price excluding tax
118
  if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
119
  Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml(
120
+ $this,
121
+ $parentItem,
122
+ $priceXml,
123
+ $subtotalXml
124
  );
125
  }
126
 
134
 
135
  // set quantities
136
  /** @var $qtyXml Mage_XmlConnect_Model_Simplexml_Element */
137
+ if (($isOption && $this->isChildCalculated())
138
+ || (!$isOption && !$this->isChildCalculated())
139
+ ) {
140
  $qtyXml = $objectXml->addChild('qty');
141
  if ($item->getQtyOrdered() > 0) {
142
  $qtyXml->addCustomChild('value', $item->getQtyOrdered() * 1, array(
173
  Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
174
  }
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  /**
177
  * Prepare option data for output
178
  *
app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Default.php CHANGED
@@ -42,10 +42,6 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Default extends Mage_Sa
42
  */
43
  public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
44
  {
45
- if ($this->getNewApi()) {
46
- $this->addItemToXmlObjectApi23($orderItemXmlObj);
47
- return;
48
- }
49
  /** @var $item Mage_Sales_Model_Order_Item */
50
  $item = $this->getItem();
51
 
@@ -113,73 +109,4 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Default extends Mage_Sa
113
  );
114
  }
115
  }
116
-
117
- /**
118
- * Add item to XML object. Api version 23
119
- *
120
- * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
121
- * @return null
122
- */
123
- public function addItemToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
124
- {
125
- /** @var $item Mage_Sales_Model_Order_Item */
126
- $item = $this->getItem();
127
-
128
- /** @var $itemXml Mage_XmlConnect_Model_Simplexml_Element */
129
- $itemXml = $orderItemXmlObj->addCustomChild('item', null, array(
130
- 'product_id' => $item->getProductId()
131
- ));
132
- $itemXml->addCustomChild('name', $item->getName());
133
-
134
- /** @var $weeeHelper Mage_Weee_Helper_Data */
135
- $weeeHelper = $this->helper('weee');
136
- /** @var $taxHelper Mage_Tax_Helper_Data */
137
- $taxHelper = $this->helper('tax');
138
-
139
- Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
140
-
141
- $itemXml->addCustomChild('entity_type', $item->getProductType());
142
- $itemXml->addCustomChild('description', $item->getDescription());
143
- $itemXml->addCustomChild('sku', Mage::helper('core/string')->splitInjection($this->getSku()));
144
-
145
- $this->setWeeeTaxAppliedAmount($item->getWeeeTaxAppliedAmount());
146
- $this->setWeeeTaxDisposition($item->getWeeeTaxDisposition());
147
-
148
- $typeOfDisplay1 = $weeeHelper->typeOfDisplay($item, 1, 'sales')
149
- && $this->getWeeeTaxAppliedAmount();
150
- $typeOfDisplay2 = $weeeHelper->typeOfDisplay($item, 2, 'sales')
151
- && $this->getWeeeTaxAppliedAmount();
152
- $typeOfDisplay4 = $weeeHelper->typeOfDisplay($item, 4, 'sales')
153
- && $this->getWeeeTaxAppliedAmount();
154
- $typeOfDisplay014 = $weeeHelper->typeOfDisplay($item, array(0, 1, 4), 'sales')
155
- && $this->getWeeeTaxAppliedAmount();
156
-
157
- $this->setTypesOfDisplay(array(
158
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_1 => $typeOfDisplay1,
159
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_2 => $typeOfDisplay2,
160
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_4 => $typeOfDisplay4,
161
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_14 => $typeOfDisplay014,
162
- ));
163
- $this->setWeeeTaxes($weeeHelper->getApplied($item));
164
-
165
- // Quantity: Ordered, Shipped, Cancelled, Refunded
166
- Mage::helper('xmlconnect/customer_order')->addQuantityToXml($this, $itemXml->addChild('quantity'), $item);
167
-
168
- $priceXml = $itemXml->addCustomChild('price_list');
169
- $priceInfoXml = $priceXml->addCustomChild('prices', null, array('id' => 'price'));
170
- $subtotalInfoXml = $priceXml->addCustomChild('prices', null, array('id' => 'subtotal'));
171
- // Price & subtotal - excluding tax
172
- if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
173
- Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXmlApi23(
174
- $this, $item, $priceInfoXml, $subtotalInfoXml
175
- );
176
- }
177
-
178
- // Price & subtotal - including tax
179
- if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) {
180
- Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXmlApi23(
181
- $this, $item, $priceInfoXml, $subtotalInfoXml, true
182
- );
183
- }
184
- }
185
  }
42
  */
43
  public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
44
  {
 
 
 
 
45
  /** @var $item Mage_Sales_Model_Order_Item */
46
  $item = $this->getItem();
47
 
109
  );
110
  }
111
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Downloadable.php CHANGED
@@ -43,10 +43,6 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Downloadable
43
  */
44
  public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
45
  {
46
- if ($this->getNewApi()) {
47
- $this->addItemToXmlObjectApi23($orderItemXmlObj);
48
- return;
49
- }
50
  /** @var $item Mage_Sales_Model_Order_Item */
51
  $item = $this->getItem();
52
 
@@ -63,6 +59,12 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Downloadable
63
 
64
  Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
65
 
 
 
 
 
 
 
66
  $links = $this->getLinks();
67
  if ($links) {
68
  $linksXml = $itemXml->addCustomChild('links', null, array('label' => $this->getLinksTitle()));
@@ -100,97 +102,24 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Downloadable
100
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_1 => $typeOfDisplay1,
101
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_2 => $typeOfDisplay2,
102
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_4 => $typeOfDisplay4,
103
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_14 => $typeOfDisplay014
104
  ));
105
  $this->setWeeeTaxes($weeeHelper->getApplied($item));
106
 
107
  // Price & subtotal - excluding tax
108
  if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
109
- Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml($this, $item, $priceXml, $subtotalXml);
110
- }
111
-
112
- // Price & subtotal - including tax
113
- if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) {
114
  Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml(
115
- $this, $item, $priceXml, $subtotalXml, true
116
- );
117
- }
118
- }
119
-
120
- /**
121
- * Add item to XML object. Api version 23
122
- *
123
- * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
124
- * @return null
125
- */
126
- public function addItemToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
127
- {
128
- /** @var $item Mage_Sales_Model_Order_Item */
129
- $item = $this->getItem();
130
-
131
- /** @var $itemXml Mage_XmlConnect_Model_Simplexml_Element */
132
- $itemXml = $orderItemXmlObj->addCustomChild('item', null, array(
133
- 'product_id' => $item->getProductId()
134
- ));
135
- $itemXml->addCustomChild('name', $item->getName());
136
-
137
- /** @var $weeeHelper Mage_Weee_Helper_Data */
138
- $weeeHelper = $this->helper('weee');
139
- /** @var $taxHelper Mage_Tax_Helper_Data */
140
- $taxHelper = $this->helper('tax');
141
-
142
- Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
143
-
144
- $links = $this->getLinks();
145
- if ($links) {
146
- $linksXml = $itemXml->addCustomChild('links', null, array('label' => $this->getLinksTitle()));
147
- foreach ($links->getPurchasedItems() as $link) {
148
- $linksXml->addCustomChild('link', $link->getLinkTitle());
149
- }
150
- }
151
-
152
- $itemXml->addCustomChild('entity_type', $item->getProductType());
153
- $itemXml->addCustomChild('description', $item->getDescription());
154
- $itemXml->addCustomChild('sku', Mage::helper('core/string')->splitInjection($this->getSku()));
155
-
156
- // Quantity: Ordered, Shipped, Cancelled, Refunded
157
- Mage::helper('xmlconnect/customer_order')->addQuantityToXml($this, $itemXml->addChild('quantity'), $item);
158
-
159
- $this->setWeeeTaxAppliedAmount($item->getWeeeTaxAppliedAmount());
160
- $this->setWeeeTaxDisposition($item->getWeeeTaxDisposition());
161
-
162
- $typeOfDisplay1 = $weeeHelper->typeOfDisplay($item, 1, 'sales')
163
- && $this->getWeeeTaxAppliedAmount();
164
- $typeOfDisplay2 = $weeeHelper->typeOfDisplay($item, 2, 'sales')
165
- && $this->getWeeeTaxAppliedAmount();
166
- $typeOfDisplay4 = $weeeHelper->typeOfDisplay($item, 4, 'sales')
167
- && $this->getWeeeTaxAppliedAmount();
168
- $typeOfDisplay014 = $weeeHelper->typeOfDisplay($item, array(0, 1, 4), 'sales')
169
- && $this->getWeeeTaxAppliedAmount();
170
-
171
- $this->setTypesOfDisplay(array(
172
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_1 => $typeOfDisplay1,
173
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_2 => $typeOfDisplay2,
174
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_4 => $typeOfDisplay4,
175
- Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_14 => $typeOfDisplay014
176
- ));
177
- $this->setWeeeTaxes($weeeHelper->getApplied($item));
178
-
179
- $priceXml = $itemXml->addCustomChild('price_list');
180
- $priceInfoXml = $priceXml->addCustomChild('prices', null, array('id' => 'price'));
181
- $subtotalInfoXml = $priceXml->addCustomChild('prices', null, array('id' => 'subtotal'));
182
-
183
- // Price & subtotal - excluding tax
184
- if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
185
- Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXmlApi23(
186
- $this, $item, $priceInfoXml, $subtotalInfoXml
187
  );
188
  }
189
 
190
  // Price & subtotal - including tax
191
  if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) {
192
- Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXmlApi23(
193
- $this, $item, $priceInfoXml,$subtotalInfoXml, true
194
  );
195
  }
196
  }
43
  */
44
  public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
45
  {
 
 
 
 
46
  /** @var $item Mage_Sales_Model_Order_Item */
47
  $item = $this->getItem();
48
 
59
 
60
  Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
61
 
62
+ $addtInfoBlock = $this->getProductAdditionalInformationBlock();
63
+ if ($addtInfoBlock) {
64
+ // TODO: find how to set additional info block
65
+ // $addtInfoBlock->setItem($item)->toHtml();
66
+ }
67
+
68
  $links = $this->getLinks();
69
  if ($links) {
70
  $linksXml = $itemXml->addCustomChild('links', null, array('label' => $this->getLinksTitle()));
102
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_1 => $typeOfDisplay1,
103
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_2 => $typeOfDisplay2,
104
  Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_4 => $typeOfDisplay4,
105
+ Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_14 => $typeOfDisplay014,
106
  ));
107
  $this->setWeeeTaxes($weeeHelper->getApplied($item));
108
 
109
  // Price & subtotal - excluding tax
110
  if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
 
 
 
 
 
111
  Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml(
112
+ $this,
113
+ $item,
114
+ $priceXml,
115
+ $subtotalXml
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  );
117
  }
118
 
119
  // Price & subtotal - including tax
120
  if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) {
121
+ Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml(
122
+ $this, $item, $priceXml, $subtotalXml, true
123
  );
124
  }
125
  }
app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Giftcard.php CHANGED
@@ -72,8 +72,8 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Giftcard
72
  $item = $this->getOrderItem();
73
  $item->setProductOptions(array('additional_options' => $this->getItemOptions()));
74
 
75
- $defaultRenderer = $this->getLayout()->getBlock('order.items')->getItemRenderer(null);
76
- $defaultRenderer->setItem($item)->setNewApi($this->getNewApi());
77
  $defaultRenderer->addItemToXmlObject($orderItemXmlObj);
78
  }
79
  }
72
  $item = $this->getOrderItem();
73
  $item->setProductOptions(array('additional_options' => $this->getItemOptions()));
74
 
75
+ $defaultRenderer = $this->getLayout()->getBlock('xmlconnect.customer.order.items')->getItemRenderer(null);
76
+ $defaultRenderer->setItem($item);
77
  $defaultRenderer->addItemToXmlObject($orderItemXmlObj);
78
  }
79
  }
app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Grouped.php CHANGED
@@ -47,16 +47,14 @@ class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Grouped extends Mage_Sa
47
  */
48
  public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
49
  {
50
- $item = $this->getItem()->getOrderItem();
51
- if (!$item) {
52
  $item = $this->getItem();
53
  }
54
- $productType = $item->getRealProductType();
55
- if (!$productType) {
56
  $productType = self::DEFAULT_PRODUCT_TYPE;
57
  }
58
  $renderer = $this->getRenderedBlock()->getItemRenderer($productType);
59
- $renderer->setItem($this->getItem())->setNewApi($this->getNewApi());
60
  $renderer->addItemToXmlObject($orderItemXmlObj);
61
  }
62
  }
47
  */
48
  public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
49
  {
50
+ if (!($item = $this->getItem()->getOrderItem())) {
 
51
  $item = $this->getItem();
52
  }
53
+ if (!($productType = $item->getRealProductType())) {
 
54
  $productType = self::DEFAULT_PRODUCT_TYPE;
55
  }
56
  $renderer = $this->getRenderedBlock()->getItemRenderer($productType);
57
+ $renderer->setItem($this->getItem());
58
  $renderer->addItemToXmlObject($orderItemXmlObj);
59
  }
60
  }
app/code/core/Mage/XmlConnect/Block/Customer/Order/Items.php CHANGED
@@ -71,6 +71,7 @@ class Mage_XmlConnect_Block_Customer_Order_Items extends Mage_Sales_Block_Order_
71
  public function addItemsToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj)
72
  {
73
  $itemsXml = $orderXmlObj->addChild('ordered_items');
 
74
  foreach ($this->getItems() as $item) {
75
  if ($item->getParentItem()) {
76
  // if Item is option of grouped product - do not render it
@@ -83,7 +84,7 @@ class Mage_XmlConnect_Block_Customer_Order_Items extends Mage_Sales_Block_Order_
83
  if ($type == 'giftcard' && !is_object(Mage::getConfig()->getNode('modules/Enterprise_GiftCard'))) {
84
  continue;
85
  }
86
- $renderer = $this->getItemRenderer($type)->setNewApi($this->getNewApi())->setItem($item);
87
  if (method_exists($renderer, 'addItemToXmlObject')) {
88
  $renderer->addItemToXmlObject($itemsXml);
89
  }
71
  public function addItemsToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj)
72
  {
73
  $itemsXml = $orderXmlObj->addChild('ordered_items');
74
+
75
  foreach ($this->getItems() as $item) {
76
  if ($item->getParentItem()) {
77
  // if Item is option of grouped product - do not render it
84
  if ($type == 'giftcard' && !is_object(Mage::getConfig()->getNode('modules/Enterprise_GiftCard'))) {
85
  continue;
86
  }
87
+ $renderer = $this->getItemRenderer($type)->setItem($item);
88
  if (method_exists($renderer, 'addItemToXmlObject')) {
89
  $renderer->addItemToXmlObject($itemsXml);
90
  }
app/code/core/Mage/XmlConnect/Block/Customer/Order/List.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Customer_Order_List extends Mage_Core_Block_Abstract
35
  {
36
  /**
37
  * Orders count limit
@@ -49,26 +49,28 @@ class Mage_XmlConnect_Block_Customer_Order_List extends Mage_Core_Block_Abstract
49
 
50
  $orders = Mage::getResourceModel('sales/order_collection')->addFieldToSelect('*')->addFieldToFilter(
51
  'customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()
52
- )->addFieldToFilter('state', array(
53
- 'in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()
54
- ))->setOrder('created_at', 'desc');
 
 
55
 
56
  $orders->getSelect()->limit(self::ORDERS_LIST_LIMIT, 0);
57
  $orders->load();
58
 
59
  if (sizeof($orders->getItems())) {
60
- foreach ($orders as $order) {
61
  $item = $ordersXmlObj->addChild('item');
62
- $item->addChild('entity_id', $order->getId());
63
- $item->addChild('number', $order->getRealOrderId());
64
- $item->addChild('date', $this->formatDate($order->getCreatedAtStoreDate()));
65
- if ($order->getShippingAddress()) {
66
- $item->addChild('ship_to', $ordersXmlObj->escapeXml($order->getShippingAddress()->getName()));
67
  }
68
- $item->addChild('total', $order->getOrderCurrency()->formatPrecision(
69
- $order->getGrandTotal(), 2, array(), false, false
70
  ));
71
- $item->addChild('status', $order->getStatusLabel());
72
  }
73
  }
74
  return $ordersXmlObj->asNiceXml();
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Customer_Order_List extends Mage_Core_Block_Template
35
  {
36
  /**
37
  * Orders count limit
49
 
50
  $orders = Mage::getResourceModel('sales/order_collection')->addFieldToSelect('*')->addFieldToFilter(
51
  'customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()
52
+ )
53
+ ->addFieldToFilter(
54
+ 'state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())
55
+ )
56
+ ->setOrder('created_at', 'desc');
57
 
58
  $orders->getSelect()->limit(self::ORDERS_LIST_LIMIT, 0);
59
  $orders->load();
60
 
61
  if (sizeof($orders->getItems())) {
62
+ foreach ($orders as $_order) {
63
  $item = $ordersXmlObj->addChild('item');
64
+ $item->addChild('entity_id', $_order->getId());
65
+ $item->addChild('number', $_order->getRealOrderId());
66
+ $item->addChild('date', $this->formatDate($_order->getCreatedAtStoreDate()));
67
+ if ($_order->getShippingAddress()) {
68
+ $item->addChild('ship_to', $ordersXmlObj->escapeXml($_order->getShippingAddress()->getName()));
69
  }
70
+ $item->addChild('total', $_order->getOrderCurrency()->formatPrecision(
71
+ $_order->getGrandTotal(), 2, array(), false, false
72
  ));
73
+ $item->addChild('status', $_order->getStatusLabel());
74
  }
75
  }
76
  return $ordersXmlObj->asNiceXml();
app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals.php CHANGED
@@ -61,7 +61,8 @@ class Mage_XmlConnect_Block_Customer_Order_Totals extends Mage_Sales_Block_Order
61
  'action' => array(
62
  'method' => 'setAfterTotal',
63
  'value' => 'grand_total'
64
- )),
 
65
  'giftwrapping' => array(
66
  'module' => 'Enterprise_GiftWrapping',
67
  'block' => 'enterprise_giftwrapping/sales_totals'
@@ -70,10 +71,11 @@ class Mage_XmlConnect_Block_Customer_Order_Totals extends Mage_Sales_Block_Order
70
  'module' => 'Enterprise_GiftCardAccount',
71
  'block' => 'xmlconnect/customer_order_totals_giftcards',
72
  'template' => 'giftcardaccount/order/giftcards.phtml'
73
- ));
 
74
 
75
  foreach ($enterpriseBlocks as $name => $block) {
76
- // create blocks only for Enterprise/Pro modules which are in system
77
  if (is_object(Mage::getConfig()->getNode('modules/' . $block['module']))) {
78
  $blockInstance = $this->getLayout()->createBlock($block['block'], $name);
79
  $this->setChild($name, $blockInstance);
@@ -85,16 +87,11 @@ class Mage_XmlConnect_Block_Customer_Order_Totals extends Mage_Sales_Block_Order
85
  }
86
 
87
  $this->_beforeToHtml();
88
- $totalsXml = $orderXmlObj->addCustomChild('totals');
89
-
90
- if ($this->getNewApi()) {
91
- $this->_prepareTotalsApi23($totalsXml);
92
- return;
93
- }
94
 
 
95
  foreach ($this->getTotals() as $total) {
96
  if ($total->getValue()) {
97
- $total->setValue($totalsXml->escapeXml($total->getValue()));
98
  }
99
  if ($total->getBlockName()) {
100
  $block = $this->getLayout()->getBlock($total->getBlockName());
@@ -111,34 +108,6 @@ class Mage_XmlConnect_Block_Customer_Order_Totals extends Mage_Sales_Block_Order
111
  }
112
  }
113
 
114
- /**
115
- * Prepare totals using for response api version 23
116
- *
117
- * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml
118
- * @return null
119
- */
120
- protected function _prepareTotalsApi23(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
121
- {
122
- $totalsXml = $totalsXml->addCustomChild('total', null, array('id' => 'totals_full_list'));
123
- foreach ($this->getTotals() as $total) {
124
- if ($total->getValue()) {
125
- $total->setValue($totalsXml->escapeXml($total->getValue()));
126
- }
127
- if ($total->getBlockName()) {
128
- $block = $this->getLayout()->getBlock($total->getBlockName());
129
- if (is_object($block)) {
130
- if (method_exists($block, 'addToXmlObject')) {
131
- $block->setTotal($total)->setNewApi($this->getNewApi())->addToXmlObject($totalsXml);
132
- } else {
133
- $this->_addTotalToXmlApi23($total, $totalsXml);
134
- }
135
- }
136
- } else {
137
- $this->_addTotalToXmlApi23($total, $totalsXml);
138
- }
139
- }
140
- }
141
-
142
  /**
143
  * Add total to totals XML
144
  *
@@ -146,34 +115,15 @@ class Mage_XmlConnect_Block_Customer_Order_Totals extends Mage_Sales_Block_Order
146
  * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml
147
  * @return null
148
  */
149
- protected function _addTotalToXml($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
150
  {
151
  if ($total instanceof Varien_Object && $total->getCode() && $total->getLabel() && $total->hasData('value')) {
152
- $totalsXml->addCustomChild(
153
- preg_replace('@[\W]+@', '_', trim($total->getCode())),
154
- $this->_formatPrice($total),
155
- array('label' => $totalsXml->escapeXml($total->getLabel()))
156
  );
157
  }
158
  }
159
 
160
- /**
161
- * Add total to totals XML. Api version 23.
162
- *
163
- * @param Varien_Object $total
164
- * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml
165
- * @return null
166
- */
167
- protected function _addTotalToXmlApi23($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
168
- {
169
- if ($total instanceof Varien_Object && $total->getCode() && $total->getLabel() && $total->hasData('value')) {
170
- $totalsXml->addCustomChild('item', $this->_formatPrice($total), array(
171
- 'id' => preg_replace('@[\W]+@', '_', trim($total->getCode())),
172
- 'label' => $totalsXml->escapeXml($total->getLabel()),
173
- ));
174
- }
175
- }
176
-
177
  /**
178
  * Format price using order currency
179
  *
61
  'action' => array(
62
  'method' => 'setAfterTotal',
63
  'value' => 'grand_total'
64
+ )
65
+ ),
66
  'giftwrapping' => array(
67
  'module' => 'Enterprise_GiftWrapping',
68
  'block' => 'enterprise_giftwrapping/sales_totals'
71
  'module' => 'Enterprise_GiftCardAccount',
72
  'block' => 'xmlconnect/customer_order_totals_giftcards',
73
  'template' => 'giftcardaccount/order/giftcards.phtml'
74
+ ),
75
+ );
76
 
77
  foreach ($enterpriseBlocks as $name => $block) {
78
+ // create blocks only for Enterprise/Pro modules which is in system
79
  if (is_object(Mage::getConfig()->getNode('modules/' . $block['module']))) {
80
  $blockInstance = $this->getLayout()->createBlock($block['block'], $name);
81
  $this->setChild($name, $blockInstance);
87
  }
88
 
89
  $this->_beforeToHtml();
 
 
 
 
 
 
90
 
91
+ $totalsXml = $orderXmlObj->addChild('totals');
92
  foreach ($this->getTotals() as $total) {
93
  if ($total->getValue()) {
94
+ $total->setValue(strip_tags($total->getValue()));
95
  }
96
  if ($total->getBlockName()) {
97
  $block = $this->getLayout()->getBlock($total->getBlockName());
108
  }
109
  }
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  /**
112
  * Add total to totals XML
113
  *
115
  * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml
116
  * @return null
117
  */
118
+ private function _addTotalToXml($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
119
  {
120
  if ($total instanceof Varien_Object && $total->getCode() && $total->getLabel() && $total->hasData('value')) {
121
+ $totalsXml->addCustomChild(preg_replace('@[\W]+@', '_', trim($total->getCode())),
122
+ $this->_formatPrice($total), array('label' => strip_tags($total->getLabel()))
 
 
123
  );
124
  }
125
  }
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  /**
128
  * Format price using order currency
129
  *
app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance.php CHANGED
@@ -42,38 +42,14 @@ class Mage_XmlConnect_Block_Customer_Order_Totals_Customerbalance
42
  */
43
  public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
44
  {
45
- if ($this->getNewApi()) {
46
- $this->addToXmlObjectApi23($totalsXml);
47
- return;
48
- }
49
-
50
  $balance = $this->getSource()->getCustomerBalanceAmount();
51
  if ($balance) {
52
- $totalsXml->addCustomChild(
53
- $this->getTotal()->getCode(),
54
- '-' . $this->_formatPrice($balance),
55
  array('label' => Mage::helper('enterprise_giftcardaccount')->__('Store Credit'))
56
  );
57
  }
58
  }
59
 
60
- /**
61
- * Add order total rendered to XML object. Api version 23
62
- *
63
- * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element
64
- * @return null
65
- */
66
- public function addToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
67
- {
68
- $balance = $this->getSource()->getCustomerBalanceAmount();
69
- if ($balance) {
70
- $totalsXml->addCustomChild('item', '-' . $this->_formatPrice($balance), array(
71
- 'id' => $this->getTotal()->getCode(),
72
- 'label' => Mage::helper('enterprise_giftcardaccount')->__('Store Credit')
73
- ));
74
- }
75
- }
76
-
77
  /**
78
  * Format price using order currency
79
  *
42
  */
43
  public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
44
  {
 
 
 
 
 
45
  $balance = $this->getSource()->getCustomerBalanceAmount();
46
  if ($balance) {
47
+ $totalsXml->addCustomChild($this->getTotal()->getCode(), '-' . $this->_formatPrice($balance),
 
 
48
  array('label' => Mage::helper('enterprise_giftcardaccount')->__('Store Credit'))
49
  );
50
  }
51
  }
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  /**
54
  * Format price using order currency
55
  *
app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance/Refunded.php CHANGED
@@ -41,34 +41,12 @@ class Mage_XmlConnect_Block_Customer_Order_Totals_Customerbalance_Refunded
41
  * @return null
42
  */
43
  public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
44
- {
45
- if ($this->getNewApi()) {
46
- $this->addToXmlObjectApi23($totalsXml);
47
- return;
48
- }
49
-
50
- $balance = $this->getSource()->getCustomerBalanceTotalRefunded();
51
- if ($balance) {
52
- $totalsXml->addCustomChild($this->getTotal()->getCode(), $this->_formatPrice($balance), array(
53
- 'label' => Mage::helper('enterprise_giftcardaccount')->__('Refunded to Store Credit')
54
- ));
55
- }
56
- }
57
-
58
- /**
59
- * Add order total rendered to XML object. Api version 23
60
- *
61
- * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element
62
- * @return null
63
- */
64
- public function addToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
65
  {
66
  $balance = $this->getSource()->getCustomerBalanceTotalRefunded();
67
  if ($balance) {
68
- $totalsXml->addCustomChild('item', $this->_formatPrice($balance), array(
69
- 'id' => $this->getTotal()->getCode(),
70
- 'label' => Mage::helper('enterprise_giftcardaccount')->__('Refunded to Store Credit')
71
- ));
72
  }
73
  }
74
 
41
  * @return null
42
  */
43
  public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  {
45
  $balance = $this->getSource()->getCustomerBalanceTotalRefunded();
46
  if ($balance) {
47
+ $totalsXml->addCustomChild($this->getTotal()->getCode(), $this->_formatPrice($balance),
48
+ array('label' => Mage::helper('enterprise_giftcardaccount')->__('Refunded to Store Credit'))
49
+ );
 
50
  }
51
  }
52
 
app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Giftcards.php CHANGED
@@ -42,54 +42,20 @@ class Mage_XmlConnect_Block_Customer_Order_Totals_Giftcards
42
  */
43
  public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
44
  {
45
- if ($this->getNewApi()) {
46
- $this->addToXmlObjectApi23($totalsXml);
47
- return;
48
- }
49
-
50
- $cards = $this->getGiftCards();
51
  if ($cards) {
52
  foreach ($cards as $card) {
53
  $label = Mage::helper('enterprise_giftcardaccount')->__('Gift Card (%s)', $card->getCode());
54
- $totalsXml->addCustomChild(
55
- $this->getTotal()->getCode(),
56
- '-' . $this->_formatPrice($card->getAmount()),
57
  array('label' => $label)
58
  );
59
  }
60
  } else {
61
  $cardsAmount = $this->getSource()->getGiftCardsAmount();
62
  if ($cardsAmount > 0) {
63
- $totalsXml->addCustomChild($this->getTotal()->getCode(), '-' . $this->_formatPrice($cardsAmount), array(
64
- 'label' => Mage::helper('enterprise_giftcardaccount')->__('Gift Card')
65
- ));
66
- }
67
- }
68
- }
69
-
70
- /**
71
- * Add order total rendered to XML object. Api version 23
72
- *
73
- * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element
74
- * @return null
75
- */
76
- public function addToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
77
- {
78
- $cards = $this->getGiftCards();
79
- if ($cards) {
80
- foreach ($cards as $card) {
81
- $label = Mage::helper('enterprise_giftcardaccount')->__('Gift Card (%s)', $card->getCode());
82
- $totalsXml->addCustomChild('item', '-' . $this->_formatPrice($card->getAmount()), array(
83
- 'id' => $this->getTotal()->getCode(),
84
- 'label' => $label
85
- ));
86
- }
87
- } else {
88
- $cardsAmount = $this->getSource()->getGiftCardsAmount();
89
- if ($cardsAmount > 0) {
90
- $totalsXml->addCustomChild($this->getTotal()->getCode(), '-' . $this->_formatPrice($cardsAmount), array(
91
- 'label' => Mage::helper('enterprise_giftcardaccount')->__('Gift Card')
92
- ));
93
  }
94
  }
95
  }
42
  */
43
  public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
44
  {
45
+ $cards = $this->getGiftCards();
 
 
 
 
 
46
  if ($cards) {
47
  foreach ($cards as $card) {
48
  $label = Mage::helper('enterprise_giftcardaccount')->__('Gift Card (%s)', $card->getCode());
49
+ $totalsXml->addCustomChild($this->getTotal()->getCode(), '-' . $this->_formatPrice($card->getAmount()),
 
 
50
  array('label' => $label)
51
  );
52
  }
53
  } else {
54
  $cardsAmount = $this->getSource()->getGiftCardsAmount();
55
  if ($cardsAmount > 0) {
56
+ $totalsXml->addCustomChild($this->getTotal()->getCode(), '-' . $this->_formatPrice($cardsAmount),
57
+ array('label' => Mage::helper('enterprise_giftcardaccount')->__('Gift Card'))
58
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
  }
61
  }
app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Tax.php CHANGED
@@ -41,11 +41,6 @@ class Mage_XmlConnect_Block_Customer_Order_Totals_Tax extends Mage_Tax_Block_Sal
41
  */
42
  public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXmlObj)
43
  {
44
- if ($this->getNewApi()) {
45
- $this->addToXmlObjectApi23($totalsXmlObj);
46
- return;
47
- }
48
-
49
  /** @var $taxesXmlObj Mage_XmlConnect_Model_Simplexml_Element */
50
  $taxesXmlObj = $totalsXmlObj->addChild('tax');
51
 
@@ -71,45 +66,9 @@ class Mage_XmlConnect_Block_Customer_Order_Totals_Tax extends Mage_Tax_Block_Sal
71
  }
72
  }
73
 
74
- $taxesXmlObj->addCustomChild('summary', $this->_formatPrice($this->getSource()->getTaxAmount()), array(
75
- 'label' => $this->__('Tax')
76
- ));
77
- }
78
-
79
- /**
80
- * Add order taxes rendered to XML object. Api version 23
81
- *
82
- * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXmlObj
83
- * @return null
84
- */
85
- public function addToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $totalsXmlObj)
86
- {
87
- $fullInfo = $this->getOrder()->getFullTaxInfo();
88
-
89
- if ($this->displayFullSummary() && !empty($fullInfo)) {
90
- foreach ((array)$fullInfo as $info) {
91
- if (isset($info['hidden']) && $info['hidden']) {
92
- continue;
93
- }
94
- $i = 0;
95
- foreach ((array)$info['rates'] as $rate) {
96
- if (isset($info['amount'])) {
97
- $config = array('id' => 'tax_rate_' . $i, 'label' => $rate['title']);
98
- if (!is_null($rate['percent'])) {
99
- $config['percent'] = sprintf('(%0.2f%%)', $rate['percent']);
100
- }
101
- $totalsXmlObj->addCustomChild(
102
- 'item', is_null($rate['percent']) ? '' : $this->_formatPrice($info['amount']), $config
103
- );
104
- ++$i;
105
- }
106
- }
107
- }
108
- }
109
-
110
- $totalsXmlObj->addCustomChild('item', $this->_formatPrice($this->getSource()->getTaxAmount()), array(
111
- 'id' => 'tax_summary', 'label' => $this->__('Tax')
112
- ));
113
  }
114
 
115
  /**
41
  */
42
  public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXmlObj)
43
  {
 
 
 
 
 
44
  /** @var $taxesXmlObj Mage_XmlConnect_Model_Simplexml_Element */
45
  $taxesXmlObj = $totalsXmlObj->addChild('tax');
46
 
66
  }
67
  }
68
 
69
+ $taxesXmlObj->addCustomChild(
70
+ 'summary', $this->_formatPrice($this->getSource()->getTaxAmount()), array('label' => $this->__('Tax'))
71
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
 
74
  /**
app/code/core/Mage/XmlConnect/Block/Customer/Storecredit.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Customer_Storecredit extends Mage_Core_Block_Abstract
35
  {
36
  /**
37
  * Render customer store credits xml
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Customer_Storecredit extends Mage_Core_Block_Template
35
  {
36
  /**
37
  * Render customer store credits xml
app/code/core/Mage/XmlConnect/Block/Home.php CHANGED
@@ -68,18 +68,16 @@ class Mage_XmlConnect_Block_Home extends Mage_XmlConnect_Block_Catalog
68
  foreach ($categoryCollection as $item) {
69
  /** @var $item Mage_Catalog_Model_Category */
70
  $item = Mage::getModel('catalog/category')->load($item->getId());
71
- if (!$item->getIncludeInMenu()) {
72
- continue;
73
- }
74
  $itemXmlObj = $itemsXmlObj->addChild('item');
75
  $itemXmlObj->addChild('label', $homeXmlObj->escapeXml($item->getName()));
76
  $itemXmlObj->addChild('entity_id', $item->getId());
77
  $itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products');
78
  $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail')
79
- ->resize(Mage::getModel('xmlconnect/images')->getImageLimitParam('content/category'));
80
 
81
  $iconXml = $itemXmlObj->addChild('icon', $icon);
82
- $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
 
83
  }
84
  $homeXmlObj->addChild('home_banner', '/current/media/catalog/category/banner_home.png');
85
 
68
  foreach ($categoryCollection as $item) {
69
  /** @var $item Mage_Catalog_Model_Category */
70
  $item = Mage::getModel('catalog/category')->load($item->getId());
 
 
 
71
  $itemXmlObj = $itemsXmlObj->addChild('item');
72
  $itemXmlObj->addChild('label', $homeXmlObj->escapeXml($item->getName()));
73
  $itemXmlObj->addChild('entity_id', $item->getId());
74
  $itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products');
75
  $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail')
76
+ ->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('category'));
77
 
78
  $iconXml = $itemXmlObj->addChild('icon', $icon);
79
+ $file = Mage::helper('xmlconnect')->urlToPath($icon);
80
+ $iconXml->addAttribute('modification_time', filemtime($file));
81
  }
82
  $homeXmlObj->addChild('home_banner', '/current/media/catalog/category/banner_home.png');
83
 
app/code/core/Mage/XmlConnect/Block/Homebanners.php DELETED
@@ -1,156 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Home banners list renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Homebanners extends Mage_Core_Block_Abstract
35
- {
36
- /**
37
- * List of images separated by device those have to be shown on home banners page
38
- *
39
- * @return array
40
- */
41
- private function getBannerTypeArray()
42
- {
43
- return array(
44
- Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID => array(
45
- Mage_XmlConnect_Model_Device_Android::IMAGE_TYPE_PORTRAIT_BANNER
46
- ),
47
- Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPHONE => array(
48
- Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_PORTRAIT_BANNER,
49
- ),
50
- Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD => array(
51
- Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_LANDSCAPE_BANNER,
52
- Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_PORTRAIT_BANNER,
53
- ));
54
- }
55
-
56
- /**
57
- * Render home banners list xml
58
- *
59
- * @return string
60
- */
61
- protected function _toHtml()
62
- {
63
- /** @var $homeBannersXmlObj Mage_XmlConnect_Model_Simplexml_Element */
64
- $homeBannersXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<home_banners></home_banners>');
65
-
66
- /** @var $deviceHelper Mage_XmlConnect_Helper_Data */
67
- $deviceHelper = Mage::helper('xmlconnect');
68
- /** @var $imagesModel Mage_XmlConnect_Model_Images */
69
- $imagesModel = Mage::getModel('xmlconnect/images');
70
-
71
- $bannerTypeCollection = $this->getBannerTypeArray();
72
- $deviceType = $deviceHelper->getDeviceType();
73
- foreach ($bannerTypeCollection[$deviceType] as $bannerType) {
74
-
75
- $bannerImageCollection = $imagesModel->getDeviceImagesByType($bannerType);
76
-
77
- foreach ($bannerImageCollection as $bannerImage) {
78
- $itemXmlObj = $homeBannersXmlObj->addCustomChild('item', null, array(
79
- 'entity_id' => $bannerImage['image_id'],
80
- 'type' => $bannerType
81
- ));
82
-
83
- $originalFile = Mage_XmlConnect_Model_Images::getBasePath($bannerImage['image_file']);
84
- $bannerUrl = $imagesModel->getScreenSizeImageUrlByType($bannerImage['image_file'], $bannerType);
85
-
86
- $itemXmlObj->addCustomChild('image', $bannerUrl, array(
87
- 'modification_time' => filemtime($originalFile)
88
- ));
89
- $this->_addImageAction($itemXmlObj, $bannerImage['image_id']);
90
- }
91
- }
92
-
93
- return $homeBannersXmlObj->asNiceXml();
94
- }
95
-
96
- /**
97
- * Add action info to xml
98
- *
99
- * @param Mage_XmlConnect_Model_Simplexml_Element $imageXml
100
- * @param int $imageId
101
- * @return Mage_XmlConnect_Block_Homebanners
102
- */
103
- protected function _addImageAction(Mage_XmlConnect_Model_Simplexml_Element $imageXml, $imageId)
104
- {
105
- $imageActionData = Mage::helper('xmlconnect')->getApplication()->getImageActionModel()
106
- ->getImageActionData($imageId);
107
-
108
- if (empty($imageActionData)) {
109
- return $this;
110
- }
111
-
112
- switch ($imageActionData['action_type']) {
113
- case Mage_XmlConnect_Model_ImageAction::ACTION_TYPE_CMS:
114
- $page = Mage::getModel('cms/page')->setStoreId(Mage::app()->getStore()->getId())
115
- ->load($imageActionData['entity_action'], 'identifier');
116
- if ($page->getId()) {
117
- $actionXml = $imageXml->addCustomChild('action', null, array(
118
- 'type' => $imageActionData['action_type']
119
- ));
120
- $actionXml->addCustomChild('attribute', $imageActionData['entity_action'], array(
121
- 'name' => 'id',
122
- ));
123
- $actionXml->addCustomChild('attribute', $page->getTitle(), array(
124
- 'name' => 'title'
125
- ));
126
- }
127
- break;
128
- case Mage_XmlConnect_Model_ImageAction::ACTION_TYPE_PRODUCT:
129
- $product = Mage::getModel('catalog/product')->load($imageActionData['entity_action']);
130
- if ($product->getId()) {
131
- $actionXml = $imageXml->addCustomChild('action', null, array(
132
- 'type' => $imageActionData['action_type']
133
- ));
134
- $actionXml->addCustomChild('attribute', $imageActionData['entity_action'], array(
135
- 'name' => 'id',
136
- ));
137
- }
138
- break;
139
- case Mage_XmlConnect_Model_ImageAction::ACTION_TYPE_CATEGORY:
140
- $category = Mage::getModel('catalog/category')->load($imageActionData['entity_action']);
141
- if ($category->getEntityId()) {
142
- $actionXml = $imageXml->addCustomChild('action', null, array(
143
- 'type' => $imageActionData['action_type']
144
- ));
145
- $actionXml->addCustomChild('attribute', $imageActionData['entity_action'], array(
146
- 'name' => 'id',
147
- ));
148
- }
149
- break;
150
- default:
151
- Mage::throwException($this->__('Action type doesn\'t recognized.'));
152
- break;
153
- }
154
- return $this;
155
- }
156
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Localization.php DELETED
@@ -1,55 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Localization list renderer
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_Localization extends Mage_Core_Block_Abstract
35
- {
36
- /**
37
- * Render home category list xml
38
- *
39
- * @return string
40
- */
41
- protected function _toHtml()
42
- {
43
- /** @var $l10nXmlObj Mage_XmlConnect_Model_Simplexml_Element */
44
- $l10nXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<localization></localization>');
45
-
46
- /** @var $translateHelper Mage_XmlConnect_Helper_Translate */
47
- $translateHelper = Mage::helper('xmlconnect/translate');
48
-
49
- foreach ($translateHelper->getLocalizationArray() as $key => $string) {
50
- $l10nXmlObj->addCustomChild($key, $string);
51
- }
52
-
53
- return $l10nXmlObj->asNiceXml();
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Review/Form.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Block_Review_Form extends Mage_Core_Block_Abstract
35
  {
36
  /**
37
  * Collection of ratings
@@ -68,7 +68,6 @@ class Mage_XmlConnect_Block_Review_Form extends Mage_Core_Block_Abstract
68
  'label' => $rating->getRatingCode(),
69
  'required' => 'true'
70
  ));
71
-
72
  foreach ($rating->getOptions() as $option) {
73
  $ratingField->addCustomChild('value', $option->getId());
74
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Block_Review_Form extends Mage_Core_Block_Template
35
  {
36
  /**
37
  * Collection of ratings
68
  'label' => $rating->getRatingCode(),
69
  'required' => 'true'
70
  ));
 
71
  foreach ($rating->getOptions() as $option) {
72
  $ratingField->addCustomChild('value', $option->getId());
73
  }
app/code/core/Mage/XmlConnect/Block/ShoppingCart.php DELETED
@@ -1,108 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *s
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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Shopping cart xml renderer
29
- *
30
- * @category Mage
31
- * @package Mage_Xmlconnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Block_ShoppingCart extends Mage_Checkout_Block_Cart_Abstract
35
- {
36
- /**
37
- * Render shopping cart xml
38
- *
39
- * @return string
40
- */
41
- protected function _toHtml()
42
- {
43
- /** @var $xmlObject Mage_XmlConnect_Model_Simplexml_Element */
44
- $xmlObject = Mage::getModel('xmlconnect/simplexml_element', '<cart></cart>');
45
- $cartMessages = $this->getMessages();
46
- $quote = $this->getQuote();
47
-
48
- $this->_cartSummary($xmlObject, $quote);
49
- /**
50
- * Cart items
51
- */
52
- $this->getChild('items')->addCartProductsToXmlObj($xmlObject, $quote);
53
-
54
- /**
55
- * Cart messages
56
- */
57
- if ($cartMessages) {
58
- $messagesXml = $xmlObject->addCustomChild('messages');
59
- foreach ($cartMessages as $status => $messages) {
60
- foreach ($messages as $message) {
61
- $messageXml = $messagesXml->addCustomChild('message');
62
- $messageXml->addCustomChild('status', $status);
63
- $messageXml->addCustomChild('text', strip_tags($message));
64
- }
65
- }
66
- }
67
-
68
- /**
69
- * Cross Sell Products
70
- */
71
- if (count($this->getItems())) {
72
- $crossellXml = $this->getChildHtml('crosssell');
73
- $crossSellXmlObj = Mage::getModel('xmlconnect/simplexml_element', $crossellXml);
74
- $xmlObject->appendChild($crossSellXmlObj);
75
- }
76
-
77
- /**
78
- * Cart Totals
79
- */
80
- $this->getChild('totals')->setCartXmlObject($xmlObject)->toHtml();
81
-
82
- return $xmlObject->asNiceXml();
83
- }
84
-
85
- /**
86
- * Add summary block to cart
87
- *
88
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObject
89
- * @param Mage_Sales_Model_Quote $quote
90
- * @return Mage_XmlConnect_Block_Cart
91
- */
92
- protected function _cartSummary($xmlObject, $quote)
93
- {
94
- $cartSummary = $xmlObject->addCustomChild('summary');
95
-
96
- $cartSummary->addCustomChild(
97
- 'item', (int)$this->helper('checkout/cart')->getIsVirtualQuote(), array('label' => 'virtual')
98
- );
99
- $cartSummary->addCustomChild(
100
- 'item', (int)$this->helper('checkout/cart')->getSummaryCount(), array('label' => 'total_qty')
101
- );
102
-
103
- if (strlen($quote->getCouponCode())) {
104
- $cartSummary->addCustomChild('item', 1, array('label' => 'has_coupon_code'));
105
- }
106
- return $this;
107
- }
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Block/Wishlist.php CHANGED
@@ -59,9 +59,6 @@ class Mage_XmlConnect_Block_Wishlist extends Mage_Wishlist_Block_Customer_Wishli
59
  $wishlistXmlObj->addAttribute('items_count', $this->getWishlistItemsCount());
60
  $wishlistXmlObj->addAttribute('has_more_items', $hasMoreItems);
61
 
62
- $productSmallImageSize = Mage::getModel('xmlconnect/images')->getImageLimitParam('content/product_small');
63
- /** @var $categoryImageHelper Mage_XmlConnect_Helper_Catalog_Product_Image */
64
- $categoryImageHelper = $this->helper('xmlconnect/catalog_product_image');
65
  if ($this->hasWishlistItems()) {
66
  /**
67
  * @var Mage_Wishlist_Model_Mysql4_Product_Collection
@@ -85,11 +82,13 @@ class Mage_XmlConnect_Block_Wishlist extends Mage_Wishlist_Block_Customer_Wishli
85
  }
86
  $itemXmlObj->addChild('has_options', (int)$item->getProduct()->getHasOptions());
87
 
88
- $icon = $categoryImageHelper->init($item->getProduct(), 'small_image')
89
- ->resize($productSmallImageSize);
90
 
91
  $iconXml = $itemXmlObj->addChild('icon', $icon);
92
- $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
 
 
93
 
94
  $description = $wishlistXmlObj->escapeXml($item->getDescription());
95
  $itemXmlObj->addChild('description', $description);
59
  $wishlistXmlObj->addAttribute('items_count', $this->getWishlistItemsCount());
60
  $wishlistXmlObj->addAttribute('has_more_items', $hasMoreItems);
61
 
 
 
 
62
  if ($this->hasWishlistItems()) {
63
  /**
64
  * @var Mage_Wishlist_Model_Mysql4_Product_Collection
82
  }
83
  $itemXmlObj->addChild('has_options', (int)$item->getProduct()->getHasOptions());
84
 
85
+ $icon = $this->helper('catalog/image')->init($item->getProduct(), 'small_image')
86
+ ->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small'));
87
 
88
  $iconXml = $itemXmlObj->addChild('icon', $icon);
89
+
90
+ $file = Mage::helper('xmlconnect')->urlToPath($icon);
91
+ $iconXml->addAttribute('modification_time', filemtime($file));
92
 
93
  $description = $wishlistXmlObj->escapeXml($item->getDescription());
94
  $itemXmlObj->addChild('description', $description);
app/code/core/Mage/XmlConnect/Controller/Action.php CHANGED
@@ -77,7 +77,9 @@ abstract class Mage_XmlConnect_Controller_Action extends Mage_Core_Controller_Fr
77
  $screenSizeCookieName = Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_NAME;
78
  $screenSize = isset($_COOKIE[$screenSizeCookieName]) ? (string) $_COOKIE[$screenSizeCookieName] : '';
79
  if (!$appCode) {
80
- $this->_message(Mage::helper('xmlconnect')->__('Specified invalid app code.'), self::MESSAGE_STATUS_ERROR);
 
 
81
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
82
  return;
83
  }
@@ -97,11 +99,15 @@ abstract class Mage_XmlConnect_Controller_Action extends Mage_Core_Controller_Fr
97
  $appModel = Mage::getModel('xmlconnect/application')->loadByCode($appCode);
98
  $appModel->setScreenSize($screenSize);
99
  if ($appModel && $appModel->getId()) {
100
- Mage::app()->setCurrentStore(Mage::app()->getStore($appModel->getStoreId())->getCode());
 
 
101
  Mage::getSingleton('core/locale')->emulate($appModel->getStoreId());
102
- Mage::register('current_app', $appModel, true);
103
  } else {
104
- $this->_message(Mage::helper('xmlconnect')->__('Specified invalid app code.'), self::MESSAGE_STATUS_ERROR);
 
 
105
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
106
  return;
107
  }
@@ -116,7 +122,7 @@ abstract class Mage_XmlConnect_Controller_Action extends Mage_Core_Controller_Fr
116
  {
117
  parent::postDispatch();
118
  $body = $this->getResponse()->getBody();
119
- if (empty($body) && !$this->getFlag('forwarded')) {
120
  $this->_message(
121
  Mage::helper('xmlconnect')->__('An error occurred while processing your request.'),
122
  self::MESSAGE_STATUS_ERROR
@@ -145,35 +151,4 @@ abstract class Mage_XmlConnect_Controller_Action extends Mage_Core_Controller_Fr
145
 
146
  $this->getResponse()->setBody($message->asNiceXml());
147
  }
148
-
149
- /**
150
- * Throw control to different action (control and module if was specified).
151
- *
152
- * @param string $action
153
- * @param string|null $controller
154
- * @param string|null $module
155
- * @param array|null $params
156
- * @return null
157
- */
158
- protected function _forward($action, $controller = null, $module = null, array $params = null)
159
- {
160
- $this->setFlag('', 'forwarded', true);
161
- return parent::_forward($action, $controller, $module, $params);
162
- }
163
-
164
- /**
165
- * Check api version and forward if equal
166
- *
167
- * @param string $action
168
- * @param string $apiVersion
169
- * @return bool
170
- */
171
- protected function _checkApiForward($action, $apiVersion)
172
- {
173
- if (Mage::helper('xmlconnect')->checkApiVersion($apiVersion)) {
174
- $this->_forward($action);
175
- return true;
176
- }
177
- return false;
178
- }
179
  }
77
  $screenSizeCookieName = Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_NAME;
78
  $screenSize = isset($_COOKIE[$screenSizeCookieName]) ? (string) $_COOKIE[$screenSizeCookieName] : '';
79
  if (!$appCode) {
80
+ $this->_message(
81
+ Mage::helper('xmlconnect')->__('Specified invalid app code.'), self::MESSAGE_STATUS_ERROR
82
+ );
83
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
84
  return;
85
  }
99
  $appModel = Mage::getModel('xmlconnect/application')->loadByCode($appCode);
100
  $appModel->setScreenSize($screenSize);
101
  if ($appModel && $appModel->getId()) {
102
+ Mage::app()->setCurrentStore(
103
+ Mage::app()->getStore($appModel->getStoreId())->getCode()
104
+ );
105
  Mage::getSingleton('core/locale')->emulate($appModel->getStoreId());
106
+ Mage::register('current_app', $appModel);
107
  } else {
108
+ $this->_message(
109
+ Mage::helper('xmlconnect')->__('Specified invalid app code.'), self::MESSAGE_STATUS_ERROR
110
+ );
111
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
112
  return;
113
  }
122
  {
123
  parent::postDispatch();
124
  $body = $this->getResponse()->getBody();
125
+ if (empty($body)) {
126
  $this->_message(
127
  Mage::helper('xmlconnect')->__('An error occurred while processing your request.'),
128
  self::MESSAGE_STATUS_ERROR
151
 
152
  $this->getResponse()->setBody($message->asNiceXml());
153
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  }
app/code/core/Mage/XmlConnect/Controller/AdminAction.php DELETED
@@ -1,192 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect admin application controller abstract
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- abstract class Mage_XmlConnect_Controller_AdminAction extends Mage_Adminhtml_Controller_Action
35
- {
36
- /**
37
- * Admin application device type cookie
38
- */
39
- const DEVICE_TYPE_COOKIE_NAME = 'device_type';
40
-
41
- /**
42
- * Controller pre-dispatch method
43
- *
44
- * @return Mage_XmlConnect_Controller_AdminAction
45
- */
46
- public function preDispatch()
47
- {
48
- Mage::getSingleton('adminhtml/url')->turnOffSecretKey();
49
- // override admin store design settings via stores section
50
- Mage::getDesign()->setArea($this->_currentArea)
51
- ->setPackageName((string)Mage::getConfig()->getNode('stores/admin/design/package/name'))
52
- ->setTheme((string)Mage::getConfig()->getNode('stores/admin/design/theme/default'));
53
- foreach (array('layout', 'template', 'skin', 'locale') as $type) {
54
- $value = (string)Mage::getConfig()->getNode("stores/admin/design/theme/{$type}");
55
- if ($value) {
56
- Mage::getDesign()->setTheme($type, $value);
57
- }
58
- }
59
-
60
- $this->getLayout()->setArea($this->_currentArea);
61
-
62
- Mage::dispatchEvent('adminhtml_controller_action_predispatch_start', array());
63
- Mage_Core_Controller_Varien_Action::preDispatch();
64
-
65
- if ($this->getRequest()->isDispatched() && $this->getRequest()->getActionName() !== 'denied'
66
- && !$this->_isAllowed()
67
- ) {
68
- $this->_forward('denied');
69
- $this->setFlag('', self::FLAG_NO_DISPATCH, true);
70
- return $this;
71
- }
72
-
73
- if (is_null(Mage::getSingleton('adminhtml/session')->getLocale())) {
74
- Mage::getSingleton('adminhtml/session')->setLocale(Mage::app()->getLocale()->getLocaleCode());
75
- }
76
-
77
- $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
78
- if ($this->_isCheckCookieRequired()) {
79
- $this->_checkCookie();
80
- }
81
-
82
- return $this;
83
- }
84
-
85
- /**
86
- * Check device cookies
87
- *
88
- * @return null
89
- */
90
- public function _checkCookie()
91
- {
92
- $AdminDeviceCookie = self::DEVICE_TYPE_COOKIE_NAME;
93
- $currentDevice = isset($_COOKIE[$AdminDeviceCookie]) ? (string) $_COOKIE[$AdminDeviceCookie] : '';
94
- if (!array_key_exists($currentDevice, Mage_XmlConnect_Helper_Data::getSupportedDevices())) {
95
- $this->_message(
96
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_CLIENT_SP_CONFIG_RELOAD_REQUIRED,
97
- $this->__('Device type doesn\'t recognized.')
98
- );
99
- $this->setFlag('', self::FLAG_NO_DISPATCH, true);
100
- return;
101
- }
102
- $screenSizeCookieName = Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_NAME;
103
- $screenSize = isset($_COOKIE[$screenSizeCookieName]) ? (string) $_COOKIE[$screenSizeCookieName] : '';
104
- if (!$screenSize) {
105
- $deviceClassName = 'Mage_XmlConnect_Model_Device_' . ucfirst($currentDevice);
106
- $_COOKIE[$screenSizeCookieName] = constant($deviceClassName . '::SCREEN_SIZE_DEFAULT');
107
- }
108
- }
109
-
110
- /**
111
- * Is check cookie required flag
112
- *
113
- * @return bool
114
- */
115
- protected function _isCheckCookieRequired()
116
- {
117
- return true;
118
- }
119
-
120
- /**
121
- * Validate response body
122
- *
123
- * @return null
124
- */
125
- public function postDispatch()
126
- {
127
- parent::postDispatch();
128
- $body = $this->getResponse()->getBody();
129
- if (empty($body)) {
130
- $this->_message(
131
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_SERVER_SP_DEFAULT,
132
- $this->__('An error occurred while processing your request.')
133
- );
134
- }
135
- }
136
-
137
- /**
138
- * Access denied action
139
- *
140
- * @return Mage_XmlConnect_Controller_AdminAction|null
141
- */
142
- public function deniedAction()
143
- {
144
- $this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
145
- if (Mage::getSingleton('xmlconnect/configuration')->isActiveAdminApp()) {
146
- $this->_message(Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_USER_SP_ACCESS_FORBIDDEN);
147
- } else {
148
- $this->_message(
149
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_USER_SP_ACCESS_FORBIDDEN,
150
- $this->__('Admin application has not been enabled')
151
- );
152
- }
153
- return $this;
154
- }
155
-
156
- /**
157
- * Generate message xml and set it to response body
158
- *
159
- * @param string $messageCode
160
- * @param string $messageText
161
- * @param array $children
162
- * @return null
163
- */
164
- protected function _message($messageCode, $messageText = null, $children = array())
165
- {
166
- /** @var $messageXmlObj Mage_XmlConnect_Model_Simplexml_Message */
167
- $messageXmlObj = Mage::getModel('xmlconnect/simplexml_message', $messageCode);
168
- $messageXmlObj->setMessageText($messageText)->setChildren($children);
169
- $this->getResponse()->setBody($messageXmlObj);
170
- }
171
-
172
- /**
173
- * Check the permission to run it
174
- *
175
- * @return boolean
176
- */
177
- protected function _isAllowed()
178
- {
179
- return Mage::getSingleton('admin/session')->isAllowed('xmlconnect/admin_connect')
180
- && Mage::getSingleton('xmlconnect/configuration')->isActiveAdminApp();
181
- }
182
-
183
- /**
184
- * Allowed controller actions w/o authorization
185
- *
186
- * @return array
187
- */
188
- public function getAllowedControllerActions()
189
- {
190
- return array('connect_user' => array('loginform', 'login', 'logout', 'denied'));
191
- }
192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Helper/AdminApplication.php DELETED
@@ -1,134 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect device helper for Android
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Helper_AdminApplication extends Mage_Core_Helper_Abstract
35
- {
36
- /**
37
- * All store views param for a store switcher
38
- */
39
- const ALL_STORE_VIEWS = 'all_store_views';
40
-
41
- /**
42
- * Store id list
43
- *
44
- * @var array
45
- */
46
- protected $_storeIdList;
47
-
48
- /**
49
- * View id list
50
- *
51
- * @var array
52
- */
53
- protected $_viewIdList;
54
-
55
- /**
56
- * Get store list ids
57
- *
58
- * @throws Mage_Core_Exception
59
- * @param bool $storeList
60
- * @return array
61
- */
62
- public function getSwitcherList($storeList = false)
63
- {
64
- $result = array(null);
65
- $storeSwitcher = Mage::registry('store_switcher');
66
-
67
- if (null === $storeSwitcher) {
68
- Mage::throwException($this->__('Store switcher hasn\'t been defined'));
69
- }
70
-
71
- if (empty($storeSwitcher)) {
72
- return $result;
73
- }
74
-
75
- if ($storeList) {
76
- return array_merge($result, $this->_getStoreIdList($storeSwitcher));
77
- } else {
78
- return array_merge($result, $this->_getViewIdList($storeSwitcher));
79
- }
80
- }
81
-
82
- /**
83
- * Get store id list
84
- *
85
- * @param array $storeSwitcher
86
- * @return array
87
- */
88
- protected function _getStoreIdList($storeSwitcher)
89
- {
90
- if (null === $this->_storeIdList) {
91
- $this->_storeIdList = array();
92
- foreach ($storeSwitcher as $params) {
93
- if (empty($params['store_list'])) {
94
- continue;
95
- }
96
- $storeIds = array_keys($params['store_list']);
97
- foreach ($storeIds as $storeId) {
98
- $this->_storeIdList[] = $storeId;
99
- }
100
- }
101
- sort($this->_storeIdList);
102
- }
103
- return $this->_storeIdList;
104
- }
105
-
106
- /**
107
- * Get view id list
108
- *
109
- * @param array $storeSwitcher
110
- * @return array
111
- */
112
- protected function _getViewIdList($storeSwitcher)
113
- {
114
- if (null === $this->_viewIdList) {
115
- $this->_viewIdList = array();
116
- foreach ($storeSwitcher as $params) {
117
- if (empty($params['store_list'])) {
118
- continue;
119
- }
120
- foreach ($params['store_list'] as $storeData) {
121
- if (empty($storeData['view_list'])) {
122
- continue;
123
- }
124
- $viewIds = array_keys($storeData['view_list']);
125
- foreach ($viewIds as $viewId) {
126
- $this->_viewIdList[] = $viewId;
127
- }
128
- }
129
- }
130
- sort($this->_viewIdList);
131
- }
132
- return $this->_viewIdList;
133
- }
134
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Helper/Adminhtml/Dashboard/Order.php DELETED
@@ -1,68 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Dashboard order graph helper
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Helper_Adminhtml_Dashboard_Order extends Mage_Adminhtml_Helper_Dashboard_Order
35
- {
36
- /**
37
- * Re-init product collection
38
- *
39
- * @return null
40
- */
41
- public function initCollection()
42
- {
43
- $this->_collection = Mage::getResourceModel('reports/order_collection')
44
- ->prepareSummary($this->getParam('period'), 0, 0, (bool)$this->getParam('store'));
45
-
46
- if ($this->getParam('store')) {
47
- $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
48
- } elseif (!$this->_collection->isLive()) {
49
- $this->_collection->addFieldToFilter('store_id', array(
50
- 'eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId()
51
- ));
52
- }
53
- $this->_collection->load();
54
- }
55
-
56
- /**
57
- * Prepare price to display
58
- *
59
- * @param null|string $price
60
- * @param null|string $storeId
61
- * @return string
62
- */
63
- public function preparePrice($price, $storeId)
64
- {
65
- $baseCurrencyCode = (string)Mage::app()->getStore($storeId)->getBaseCurrencyCode();
66
- return Mage::app()->getLocale()->currency($baseCurrencyCode)->toCurrency($price);
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Helper/Android.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstract
35
  {
36
  /**
37
  * Submission title length
@@ -44,14 +44,12 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
44
  const SUBMISSION_DESCRIPTION_LENGTH = 4000;
45
 
46
  /**
47
- * Android preview banner width
48
- * @deprecated
49
  */
50
  const PREVIEW_BANNER_WIDTH = 320;
51
 
52
  /**
53
  * Android preview banner image height
54
- * @deprecated
55
  */
56
  const PREVIEW_BANNER_HEIGHT = 258;
57
 
@@ -67,26 +65,14 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
67
 
68
  /**
69
  * Country renderer for submission
70
- *
71
- * @deprecated
72
  */
73
  const SUBMISSION_COUNTRY_RENDERER = 'androidmarket';
74
 
75
  /**
76
  * Country columns for submission
77
- *
78
- * @deprecated
79
  */
80
  const SUBMISSION_COUNTRY_COLUMNS = 2;
81
 
82
- /**
83
- * Submission columns count
84
- *
85
- * @var int
86
- */
87
- protected $_countryColumnsCount = 2;
88
-
89
-
90
  /**
91
  * Submit images that are stored in "params" field of history table
92
  *
@@ -95,14 +81,14 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
95
  protected $_imageIds = array('icon', 'android_loader_image', 'android_logo', 'big_logo');
96
 
97
  /**
98
- * Country renderer block
99
  *
100
- * @var string
101
  */
102
- protected $_countryRendererBlock = 'xmlconnect/adminhtml_mobile_submission_renderer_country_androidmarket';
103
 
104
  /**
105
- * List of countries that allowed in Androidmarket by Google
106
  *
107
  * array(
108
  * 'country name' => 'country id at directory model'
@@ -143,25 +129,13 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
143
  );
144
 
145
  /**
146
- * Default images list
147
  *
148
  * @return array
149
  */
150
- public function getImagesTypesList()
151
  {
152
- return array(
153
- Mage_XmlConnect_Model_Device_Android::IMAGE_TYPE_ICON => array(
154
- 'count' => Mage_XmlConnect_Model_Device_Android::IMAGE_TYPE_ICON_COUNT,
155
- 'label' => $this->__('Logo in Header'),
156
- 'sortable' => false,
157
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 35, 35)
158
- ),
159
- Mage_XmlConnect_Model_Device_Android::IMAGE_TYPE_PORTRAIT_BANNER => array(
160
- 'count' => Mage_XmlConnect_Model_Device_Android::IMAGE_TYPE_BANNER_COUNT,
161
- 'label' => $this->__('Banners on Home Screen'),
162
- 'sortable' => true,
163
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 320, 258) . $this->__('Note: Image size affects the performance of your app.') . $this->__('Keep your image size below %s KB for optimal performance.', 50)
164
- ));
165
  }
166
 
167
  /**
@@ -506,7 +480,25 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
506
  array(
507
  'value' => 'STHeitiK-Light',
508
  'label' => 'STHeitiK-Light',
509
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  }
511
 
512
  /**
@@ -584,7 +576,6 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
584
  /**
585
  * Check config for valid values
586
  *
587
- * @deprecated we don't use it since 1.11.1.0
588
  * @param array $native
589
  * @return array
590
  */
@@ -604,6 +595,21 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
604
  return $errors;
605
  }
606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  /**
608
  * Get label for submission country
609
  *
@@ -614,6 +620,16 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
614
  return Mage::helper('xmlconnect')->__('Locations');
615
  }
616
 
 
 
 
 
 
 
 
 
 
 
617
  /**
618
  * Get placement of Country Names for submission country
619
  *
@@ -631,14 +647,12 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
631
  */
632
  public function getCountryClass()
633
  {
634
- return 'androidmarket';
635
  }
636
 
637
  /**
638
  * Get list of countries that allowed by Magento Inc. for Android
639
  *
640
- * @deprecated
641
- * @see $this->getAllowedCountriesArray()
642
  * @return array
643
  */
644
  public function getAndroidMarketCountriesArray()
@@ -651,7 +665,6 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
651
  *
652
  * We set empty value for image field if file was missed in some reason
653
  *
654
- * @deprecated will delete in the next version
655
  * @param array $data
656
  * @return array
657
  */
@@ -676,7 +689,6 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
676
  /**
677
  * Check required fields of a config for a front-end
678
  *
679
- * @deprecated will delete in the next version
680
  * @throws Mage_Core_Exception
681
  * @param array $data
682
  * @return null
@@ -695,4 +707,14 @@ class Mage_XmlConnect_Helper_Android extends Mage_XmlConnect_Helper_Device_Abstr
695
  Mage::throwException(Mage::helper('xmlconnect')->__('Banner on Home Screen image missing.'));
696
  }
697
  }
 
 
 
 
 
 
 
 
 
 
698
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Helper_Android extends Mage_Core_Helper_Abstract
35
  {
36
  /**
37
  * Submission title length
44
  const SUBMISSION_DESCRIPTION_LENGTH = 4000;
45
 
46
  /**
47
+ * Android preview banner widht
 
48
  */
49
  const PREVIEW_BANNER_WIDTH = 320;
50
 
51
  /**
52
  * Android preview banner image height
 
53
  */
54
  const PREVIEW_BANNER_HEIGHT = 258;
55
 
65
 
66
  /**
67
  * Country renderer for submission
 
 
68
  */
69
  const SUBMISSION_COUNTRY_RENDERER = 'androidmarket';
70
 
71
  /**
72
  * Country columns for submission
 
 
73
  */
74
  const SUBMISSION_COUNTRY_COLUMNS = 2;
75
 
 
 
 
 
 
 
 
 
76
  /**
77
  * Submit images that are stored in "params" field of history table
78
  *
81
  protected $_imageIds = array('icon', 'android_loader_image', 'android_logo', 'big_logo');
82
 
83
  /**
84
+ * Country field renderer
85
  *
86
+ * @var Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Androidmarket
87
  */
88
+ protected $_countryRenderer = null;
89
 
90
  /**
91
+ * List of coutries that allowed in Ituens by Apple Store
92
  *
93
  * array(
94
  * 'country name' => 'country id at directory model'
129
  );
130
 
131
  /**
132
+ * Get submit images that are required for application submit
133
  *
134
  * @return array
135
  */
136
+ public function getSubmitImages()
137
  {
138
+ return $this->_imageIds;
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
 
141
  /**
480
  array(
481
  'value' => 'STHeitiK-Light',
482
  'label' => 'STHeitiK-Light',
483
+ ),
484
+ );
485
+ }
486
+
487
+ /**
488
+ * List of allowed font sizes for Android application
489
+ *
490
+ * @return array
491
+ */
492
+ public function getFontSizes()
493
+ {
494
+ $result = array();
495
+ for ($i = 6; $i < 32; $i++) {
496
+ $result[] = array(
497
+ 'value' => $i,
498
+ 'label' => $i . ' pt',
499
+ );
500
+ }
501
+ return $result;
502
  }
503
 
504
  /**
576
  /**
577
  * Check config for valid values
578
  *
 
579
  * @param array $native
580
  * @return array
581
  */
595
  return $errors;
596
  }
597
 
598
+ /**
599
+ * Get renderer for submission country
600
+ *
601
+ * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Androidmarket
602
+ */
603
+ public function getCountryRenderer()
604
+ {
605
+ if (empty($this->_countryRenderer)) {
606
+ $renderer = 'xmlconnect/adminhtml_mobile_submission_renderer_country_'
607
+ . self::SUBMISSION_COUNTRY_RENDERER;
608
+ $this->_countryRenderer = Mage::app()->getLayout()->createBlock($renderer);
609
+ }
610
+ return $this->_countryRenderer;
611
+ }
612
+
613
  /**
614
  * Get label for submission country
615
  *
620
  return Mage::helper('xmlconnect')->__('Locations');
621
  }
622
 
623
+ /**
624
+ * Get columns for submission country
625
+ *
626
+ * @return int
627
+ */
628
+ public function getCountryColumns()
629
+ {
630
+ return self::SUBMISSION_COUNTRY_COLUMNS;
631
+ }
632
+
633
  /**
634
  * Get placement of Country Names for submission country
635
  *
647
  */
648
  public function getCountryClass()
649
  {
650
+ return self::SUBMISSION_COUNTRY_RENDERER;
651
  }
652
 
653
  /**
654
  * Get list of countries that allowed by Magento Inc. for Android
655
  *
 
 
656
  * @return array
657
  */
658
  public function getAndroidMarketCountriesArray()
665
  *
666
  * We set empty value for image field if file was missed in some reason
667
  *
 
668
  * @param array $data
669
  * @return array
670
  */
689
  /**
690
  * Check required fields of a config for a front-end
691
  *
 
692
  * @throws Mage_Core_Exception
693
  * @param array $data
694
  * @return null
707
  Mage::throwException(Mage::helper('xmlconnect')->__('Banner on Home Screen image missing.'));
708
  }
709
  }
710
+
711
+ /**
712
+ * Check the notifications are allowed for current type of application
713
+ *
714
+ * @return bool
715
+ */
716
+ public function isNotificationsAllowed()
717
+ {
718
+ return true;
719
+ }
720
  }
app/code/core/Mage/XmlConnect/Helper/Catalog/Category/Image.php CHANGED
@@ -27,9 +27,6 @@
27
  /**
28
  * Catalog image helper
29
  *
30
- * Helper used to display thumbnail image for category
31
- * Prepare category image for cache and resize for mobile devices
32
- *
33
  * @category Mage
34
  * @package Mage_XmlConnect
35
  * @author Magento Core Team <core@magentocommerce.com>
@@ -43,6 +40,7 @@ class Mage_XmlConnect_Helper_Catalog_Category_Image extends Mage_Catalog_Helper_
43
  * @param string $attributeName
44
  * @param string $imageFile
45
  * @return Mage_XmlConnect_Helper_Catalog_Category_Image
 
46
  */
47
  public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile = null)
48
  {
@@ -83,65 +81,13 @@ class Mage_XmlConnect_Helper_Catalog_Category_Image extends Mage_Catalog_Helper_
83
  /*
84
  * add for work original size
85
  */
86
- $this->_getModel()->setBaseFile($this->getProduct()->getData($this->_getModel()->getDestinationSubdir()));
 
 
87
  }
88
  return $this;
89
  }
90
 
91
- /**
92
- * Re-write parent to handle an exception if any
93
- *
94
- * @return string
95
- */
96
- public function __toString()
97
- {
98
- try {
99
- if ($this->getImageFile()) {
100
- $this->_getModel()->setBaseFile($this->getImageFile());
101
- } else {
102
- $this->_getModel()->setBaseFile(
103
- $this->getProduct()->getData($this->_getModel()->getDestinationSubdir())
104
- );
105
- }
106
-
107
- if ($this->_getModel()->isCached()) {
108
- return $this->_getModel()->getUrl();
109
- } else {
110
- if ($this->_scheduleRotate) {
111
- $this->_getModel()->rotate($this->getAngle());
112
- }
113
-
114
- if ($this->_scheduleResize) {
115
- $this->_getModel()->resize();
116
- }
117
-
118
- if ($this->getWatermark()) {
119
- $this->_getModel()->setWatermark($this->getWatermark());
120
- }
121
-
122
- $url = $this->_getModel()->saveFile()->getUrl();
123
- }
124
- } catch(Exception $e) {
125
- Mage::logException($e);
126
- $url = Mage::getDesign()->getSkinUrl($this->getPlaceholder());
127
- $params = array('_package' => Mage_Core_Model_Design_Package::DEFAULT_PACKAGE,
128
- '_theme' => Mage_Core_Model_Design_Package::DEFAULT_THEME);
129
- $filePath = Mage::getDesign()->getSkinBaseDir($params) . DS . str_replace('/', DS, $this->getPlaceholder());
130
- $this->_getModel()->setNewFile($filePath);
131
- }
132
- return $url;
133
- }
134
-
135
- /**
136
- * Get new file path
137
- *
138
- * @return string
139
- */
140
- public function getNewFile()
141
- {
142
- return $this->_getModel()->getNewFile();
143
- }
144
-
145
  /**
146
  * Return placeholder image file path
147
  *
27
  /**
28
  * Catalog image helper
29
  *
 
 
 
30
  * @category Mage
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
40
  * @param string $attributeName
41
  * @param string $imageFile
42
  * @return Mage_XmlConnect_Helper_Catalog_Category_Image
43
+ *
44
  */
45
  public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile = null)
46
  {
81
  /*
82
  * add for work original size
83
  */
84
+ $this->_getModel()->setBaseFile(
85
+ $this->getProduct()->getData($this->_getModel()->getDestinationSubdir())
86
+ );
87
  }
88
  return $this;
89
  }
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  /**
92
  * Return placeholder image file path
93
  *
app/code/core/Mage/XmlConnect/Helper/Catalog/Product/Image.php DELETED
@@ -1,46 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Product image helper
29
- * Helper used to get path to new modified product image
30
- *
31
- * @category Mage
32
- * @package Mage_XmlConnect
33
- * @author Magento Core Team <core@magentocommerce.com>
34
- */
35
- class Mage_XmlConnect_Helper_Catalog_Product_Image extends Mage_Catalog_Helper_Image
36
- {
37
- /**
38
- * Get new file path
39
- *
40
- * @return string
41
- */
42
- public function getNewFile()
43
- {
44
- return $this->_getModel()->getNewFile();
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Helper/Customer/Form/Renderer.php CHANGED
@@ -33,162 +33,6 @@
33
  */
34
  class Mage_XmlConnect_Helper_Customer_Form_Renderer extends Mage_Core_Helper_Abstract
35
  {
36
- /**
37
- * Attributes block name
38
- *
39
- * @var string
40
- */
41
- protected $_attributesBlockName;
42
-
43
- /**
44
- * Form code
45
- *
46
- * @var string
47
- */
48
- protected $_formCode;
49
-
50
- /**
51
- * Set block entity
52
- *
53
- * @var object
54
- */
55
- protected $_blockEntity;
56
-
57
- /**
58
- * Block entity type
59
- *
60
- * @var null|string
61
- */
62
- protected $_blockEntityType;
63
-
64
- /**
65
- * Enterprise field renderer list as type => renderer block
66
- *
67
- * Original block relations:
68
- * - 'text' => 'enterprise_customer/form_renderer_text',
69
- * - 'textarea' => 'enterprise_customer/form_renderer_textarea',
70
- * - 'multiline' => 'enterprise_customer/form_renderer_multiline',
71
- * - 'date' => 'enterprise_customer/form_renderer_date',
72
- * - 'select' => 'enterprise_customer/form_renderer_select',
73
- * - 'multiselect' => 'enterprise_customer/form_renderer_multiselect',
74
- * - 'boolean' => 'enterprise_customer/form_renderer_boolean',
75
- * - 'file' => 'enterprise_customer/form_renderer_file'
76
- * - 'image' => 'enterprise_customer/form_renderer_image'
77
- *
78
- * @see customer.xml layout customer_form_template_handle node
79
- * @var array
80
- */
81
- protected $_customerFiledRenderer = array(
82
- 'text' => 'xmlconnect/customer_form_renderer_text',
83
- 'textarea' => 'xmlconnect/customer_form_renderer_textarea',
84
- 'multiline' => 'xmlconnect/customer_form_renderer_multiline',
85
- 'date' => 'xmlconnect/customer_form_renderer_date',
86
- 'select' => 'xmlconnect/customer_form_renderer_select',
87
- 'multiselect' => 'xmlconnect/customer_form_renderer_multiselect',
88
- 'boolean' => 'xmlconnect/customer_form_renderer_boolean',
89
- 'file' => 'xmlconnect/customer_form_renderer_file',
90
- 'image' => 'xmlconnect/customer_form_renderer_image'
91
- );
92
-
93
- /**
94
- * Add custom attributes
95
- *
96
- * @param Mage_XmlConnect_Model_Simplexml_Form_Abstract $fieldset
97
- * @param Mage_Core_Model_Layout $layout
98
- * @return Mage_XmlConnect_Helper_Customer_Form_Renderer
99
- */
100
- public function addCustomAttributes(Mage_XmlConnect_Model_Simplexml_Form_Abstract $fieldset, $layout)
101
- {
102
- if (is_object(Mage::getConfig()->getNode('modules/Enterprise_Customer'))) {
103
- $attrBlock = $layout->addBlock('enterprise_customer/form', $this->getAttributesBlockName());
104
- $attrBlock->setFormCode($this->getFormCode());
105
- $attrBlock->setEntity($this->getBlockEntity());
106
- if ($this->getBlockEntityType()) {
107
- $attrBlock->setEntityType($this->getBlockEntityType());
108
- }
109
- foreach ($this->_customerFiledRenderer as $type => $rendererBlock) {
110
- $attrBlock->addRenderer($type, $rendererBlock, '');
111
- }
112
- if ($attrBlock->hasUserDefinedAttributes()) {
113
- foreach ($attrBlock->getUserDefinedAttributes() as $attribute) {
114
- $type = $attribute->getFrontendInput();
115
- $block = $attrBlock->getRenderer($type);
116
- if ($block) {
117
- $block->setAttributeObject($attribute)->setEntity($attrBlock->getEntity())
118
- ->addFieldToXmlObj($fieldset);
119
- }
120
- }
121
- }
122
- }
123
- return $this;
124
- }
125
-
126
- /**
127
- * Set attributes block name
128
- *
129
- * @param string $attributesBlockName
130
- * @return Mage_XmlConnect_Helper_Form
131
- */
132
- public function setAttributesBlockName($attributesBlockName)
133
- {
134
- $this->_attributesBlockName = $attributesBlockName;
135
- return $this;
136
- }
137
-
138
- /**
139
- * Get attributes block name
140
- *
141
- * @return string
142
- */
143
- public function getAttributesBlockName()
144
- {
145
- return $this->_attributesBlockName;
146
- }
147
-
148
- /**
149
- * Set form code
150
- *
151
- * @param string $customerFormCode
152
- * @return Mage_XmlConnect_Helper_Form
153
- */
154
- public function setFormCode($customerFormCode)
155
- {
156
- $this->_formCode = $customerFormCode;
157
- return $this;
158
- }
159
-
160
- /**
161
- * Get form code
162
- *
163
- * @return string
164
- */
165
- public function getFormCode()
166
- {
167
- return $this->_formCode;
168
- }
169
-
170
- /**
171
- * Set block entity
172
- *
173
- * @param object $blockEntity
174
- * @return Mage_XmlConnect_Helper_Form
175
- */
176
- public function setBlockEntity($blockEntity)
177
- {
178
- $this->_blockEntity = $blockEntity;
179
- return $this;
180
- }
181
-
182
- /**
183
- * Get block entity
184
- *
185
- * @return object
186
- */
187
- public function getBlockEntity()
188
- {
189
- return $this->_blockEntity;
190
- }
191
-
192
  /**
193
  * Get title and required attributes for a field
194
  *
@@ -211,26 +55,4 @@ class Mage_XmlConnect_Helper_Customer_Form_Renderer extends Mage_Core_Helper_Abs
211
 
212
  return $attributes;
213
  }
214
-
215
- /**
216
- * Set block entity type
217
- *
218
- * @param string $setBlockEntity
219
- * @return Mage_XmlConnect_Helper_Customer_Form_Renderer
220
- */
221
- public function setBlockEntityType($setBlockEntity)
222
- {
223
- $this->_blockEntityType = $setBlockEntity;
224
- return $this;
225
- }
226
-
227
- /**
228
- * Get block entity type
229
- *
230
- * @return null|string
231
- */
232
- public function getBlockEntityType()
233
- {
234
- return $this->_blockEntityType;
235
- }
236
  }
33
  */
34
  class Mage_XmlConnect_Helper_Customer_Form_Renderer extends Mage_Core_Helper_Abstract
35
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * Get title and required attributes for a field
38
  *
55
 
56
  return $attributes;
57
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
app/code/core/Mage/XmlConnect/Helper/Customer/Order.php CHANGED
@@ -35,7 +35,6 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
35
  {
36
  /**#@+
37
  * Price display type
38
- *
39
  * @see Mage_Weee_Helper_Data::typeOfDisplay(...);
40
  */
41
  const PRICE_DISPLAY_TYPE_1 = 1;
@@ -44,16 +43,6 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
44
  const PRICE_DISPLAY_TYPE_14 = 14;
45
  /**#@-*/
46
 
47
- /**
48
- * Including tax id
49
- */
50
- const INCLUDING_TAX_ID = 'including_tax';
51
-
52
- /**
53
- * Excluding tax id
54
- */
55
- const EXCLUDING_TAX_ID = 'excluding_tax';
56
-
57
  /**
58
  * Add Weee taxes child to the XML
59
  *
@@ -66,14 +55,14 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
66
  */
67
  public function addPriceAndSubtotalToXml(Mage_Core_Block_Template $renderer, Mage_Sales_Model_Order_Item $item,
68
  Mage_XmlConnect_Model_Simplexml_Element $priceXml, Mage_XmlConnect_Model_Simplexml_Element $subtotalXml,
69
- $isIncludeTax = false)
70
- {
71
  $weeeParams = array();
72
 
73
  $typesOfDisplay = $renderer->getTypesOfDisplay();
74
  if ($isIncludeTax) {
75
- $nodeName = self::INCLUDING_TAX_ID;
76
- $nodeLabel = $this->__('Incl. Tax');
77
 
78
  $inclPrice = $renderer->helper('checkout')->getPriceInclTax($item);
79
  $inclSubtotal = $renderer->helper('checkout')->getSubtotalInclTax($item);
@@ -87,8 +76,8 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
87
  }
88
  $weeeParams['include'] = $inclPrice;
89
  } else {
90
- $nodeName = self::EXCLUDING_TAX_ID;
91
- $nodeLabel = $this->__('Excl. Tax');
92
 
93
  if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_14]) {
94
  $price = $item->getPrice() + $renderer->getWeeeTaxAppliedAmount()
@@ -101,8 +90,9 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
101
  }
102
  }
103
 
104
- $configNode = array('value' => $this->formatPrice($renderer, $price));
105
-
 
106
  if ($renderer->helper('tax')->displaySalesBothPrices()) {
107
  $configNode['label'] = $nodeLabel;
108
  }
@@ -114,88 +104,11 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
114
  $configNode['value'] = $this->formatPrice($renderer, $subtotal);
115
  $weeeParams['include'] = $isIncludeTax ? $inclSubtotal : null;
116
  $weeeParams['is_subtotal'] = true;
117
-
118
  $this->addWeeeTaxesToPriceXml(
119
  $renderer, $item, $subtotalXml->addCustomChild($nodeName, null, $configNode), $weeeParams
120
  );
121
  }
122
 
123
- /**
124
- * Add Weee taxes child to the XML. Api version 23
125
- *
126
- * @param Mage_Core_Block_Template $renderer Product renderer
127
- * @param Mage_Sales_Model_Order_Item $item
128
- * @param Mage_XmlConnect_Model_Simplexml_Element $priceXml
129
- * @param Mage_XmlConnect_Model_Simplexml_Element $subtotalXml
130
- * @param bool $isIncludeTax
131
- * @return null
132
- */
133
- public function addPriceAndSubtotalToXmlApi23(Mage_Core_Block_Template $renderer, Mage_Sales_Model_Order_Item $item,
134
- Mage_XmlConnect_Model_Simplexml_Element $priceXml,
135
- Mage_XmlConnect_Model_Simplexml_Element $subtotalXml,
136
- $isIncludeTax = false
137
- ) {
138
- $weeeParams = array();
139
-
140
- $typesOfDisplay = $renderer->getTypesOfDisplay();
141
- if ($isIncludeTax) {
142
- $nodeId = self::INCLUDING_TAX_ID;
143
- $nodeLabel = $this->__('Incl. Tax');
144
-
145
- $inclPrice = $renderer->helper('checkout')->getPriceInclTax($item);
146
- $inclSubtotal = $renderer->helper('checkout')->getSubtotalInclTax($item);
147
-
148
- if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_14]) {
149
- $price = $inclPrice + $renderer->getWeeeTaxAppliedAmount();
150
- $subtotal = $inclSubtotal + $item->getWeeeTaxAppliedRowAmount();
151
- } else {
152
- $price = $inclPrice - $renderer->getWeeeTaxDisposition();
153
- $subtotal = $inclSubtotal - $item->getWeeeTaxRowDisposition();
154
- }
155
- $weeeParams['include'] = $inclPrice;
156
- } else {
157
- $nodeId = self::EXCLUDING_TAX_ID;
158
- $nodeLabel = $this->__('Excl. Tax');
159
-
160
- if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_14]) {
161
- $price = $item->getPrice() + $renderer->getWeeeTaxAppliedAmount()
162
- + $renderer->getWeeeTaxDisposition();
163
- $subtotal = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
164
- + $item->getWeeeTaxRowDisposition();
165
- } else {
166
- $price = $item->getPrice();
167
- $subtotal = $item->getRowTotal();
168
- }
169
- }
170
-
171
- $configNode = array('id' => $nodeId);
172
- $priceValue = $this->formatPrice($renderer, $price);
173
-
174
- if ($renderer->helper('tax')->displaySalesBothPrices()) {
175
- $configNode['label'] = $nodeLabel;
176
- }
177
-
178
- $priceConfig = $configNode;
179
- $idPrefix = 'price_';
180
- $priceConfig['id'] = $idPrefix . $priceConfig['id'];
181
- $priceConfig['formatted_price'] = $priceValue;
182
- $price = Mage::helper('xmlconnect')->formatPriceForXml($price);
183
- $priceXml->addCustomChild('price', $price, $priceConfig);
184
- $this->addWeeeTaxesToPriceXmlApi23($renderer, $item, $priceXml, $weeeParams, $idPrefix, $isIncludeTax);
185
-
186
- $priceValue = $this->formatPrice($renderer, $subtotal);
187
- $weeeParams['include'] = $isIncludeTax ? $inclSubtotal : null;
188
- $weeeParams['is_subtotal'] = true;
189
-
190
- $subtotalConfig = $configNode;
191
- $idPrefix = 'subtotal_';
192
- $subtotalConfig['id'] = $idPrefix . $subtotalConfig['id'];
193
- $subtotalConfig['formatted_price'] = $priceValue;
194
- $subtotal = Mage::helper('xmlconnect')->formatPriceForXml($subtotal);
195
- $subtotalXml->addCustomChild('price', $subtotal, $subtotalConfig);
196
- $this->addWeeeTaxesToPriceXmlApi23($renderer, $item, $subtotalXml, $weeeParams, $idPrefix, $isIncludeTax);
197
- }
198
-
199
  /**
200
  * Add Product options to XML
201
  *
@@ -208,22 +121,20 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
208
  ) {
209
  $options = $renderer->getItemOptions();
210
  if (!empty($options)) {
211
- $optionsXml = $itemXml->addCustomChild('options');
212
 
213
  foreach ($options as $option) {
214
  $value = false;
215
- $formattedOptionValue = $renderer->getFormatedOptionValue($option);
216
- if (isset($formattedOptionValue['full_view']) && isset($formattedOptionValue['value'])) {
217
- $value = $formattedOptionValue['value'];
218
  } elseif (isset($option['print_value'])) {
219
  $value = $option['print_value'];
220
  } elseif (isset($option['value'])) {
221
  $value = $option['value'];
222
  }
223
  if ($value) {
224
- $optionsXml->addCustomChild('option', $optionsXml->escapeXml($value), array(
225
- 'label' => $option['label']
226
- ));
227
  }
228
  }
229
  }
@@ -254,21 +165,21 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
254
  if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_1]) {
255
  $weeeXml = $parentXml->addChild('weee');
256
  foreach ($weeTaxes as $tax) {
257
- $weeeXml->addCustomChild('tax', $this->formatPrice($renderer, $tax[$row . 'amount']), array(
258
- 'label' => $tax['title']
259
- ));
260
  }
261
  } elseif ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_2] || $typesOfDisplay[self::PRICE_DISPLAY_TYPE_4]) {
262
  $weeeXml = $parentXml->addChild('weee');
263
  foreach ($weeTaxes as $tax) {
264
- $weeeXml->addCustomChild('tax', $this->formatPrice($renderer, $tax[$row . 'amount_incl_tax']), array(
265
- 'label' => $tax['title']
266
- ));
267
  }
268
  }
269
 
270
  if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_2]) {
271
- if (!empty($params['include'])) {
272
  // including tax
273
  if (isset($params['is_subtotal'])) {
274
  $total = $params['include'] + $item->getWeeeTaxAppliedRowAmount();
@@ -277,7 +188,7 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
277
  }
278
  } else {
279
  // excluding tax
280
- if (isset($params['is_subtotal'])) {
281
  $total = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
282
  + $item->getWeeeTaxRowDisposition();
283
  } else {
@@ -289,84 +200,11 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
289
  if (!isset($weeeXml)) {
290
  $weeeXml = $parentXml->addChild('weee');
291
  }
292
-
293
- $weeeXml->addCustomChild('total', $this->formatPrice($renderer, $total), array(
294
- 'label' => $renderer->helper('weee')->__('Total')
295
- ));
296
- }
297
- }
298
-
299
- /**
300
- * Add Weee taxes child to the XML. Api version 23
301
- *
302
- * @param Mage_Core_Block_Template $renderer Product renderer
303
- * @param Mage_Sales_Model_Order_Item $item
304
- * @param Mage_XmlConnect_Model_Simplexml_Element $parentXml
305
- * @param array $params Params for Weee taxes: 'include' - Price including tax, 'is_subtotal' - Flag of subtotal
306
- * @param string $idPrefix
307
- * @param bool $isIncludeTax
308
- * @return null
309
- */
310
- public function addWeeeTaxesToPriceXmlApi23(Mage_Core_Block_Template $renderer, Mage_Sales_Model_Order_Item $item,
311
- Mage_XmlConnect_Model_Simplexml_Element $parentXml, $params = array(), $idPrefix, $isIncludeTax
312
- ) {
313
- $weeTaxes = $renderer->getWeeeTaxes();
314
- if (empty($weeTaxes)) {
315
- return;
316
- }
317
-
318
- $typesOfDisplay = $renderer->getTypesOfDisplay();
319
-
320
- $row = isset($params['is_subtotal']) && $params['is_subtotal'] ? 'row_' : '';
321
-
322
- if ($isIncludeTax) {
323
- $weeeXml = $parentXml->addCustomChild('price', null, array('id' => 'weee'));
324
- /** @var $weeeXml Mage_XmlConnect_Model_Simplexml_Element */
325
- if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_1]) {
326
- foreach ($weeTaxes as $tax) {
327
- $taxAmount = Mage::helper('xmlconnect')->formatPriceForXml($tax[$row . 'amount']);
328
- $weeeXml->addCustomChild('item', $taxAmount, array(
329
- 'label' => $tax['title'],
330
- 'formatted_price' => $this->formatPrice($renderer, $tax[$row . 'amount'])
331
- ));
332
- }
333
- } elseif ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_2] || $typesOfDisplay[self::PRICE_DISPLAY_TYPE_4]) {
334
- foreach ($weeTaxes as $tax) {
335
- $taxAmount = Mage::helper('xmlconnect')->formatPriceForXml($tax[$row . 'amount_incl_tax']);
336
- $weeeXml->addCustomChild('item', $taxAmount, array(
337
- 'label' => $tax['title'],
338
- 'formatted_price' => $this->formatPrice($renderer, $tax[$row . 'amount_incl_tax'])
339
- ));
340
- }
341
- }
342
- }
343
-
344
- if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_2]) {
345
- if (!empty($params['include'])) {
346
- // including tax
347
- if (isset($params['is_subtotal'])) {
348
- $total = $params['include'] + $item->getWeeeTaxAppliedRowAmount();
349
- } else {
350
- $total = $params['include'] + $renderer->getWeeeTaxAppliedAmount();
351
- }
352
- } else {
353
- // excluding tax
354
- if (isset($params['is_subtotal'])) {
355
- $total = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
356
- + $item->getWeeeTaxRowDisposition();
357
- } else {
358
- $total = $item->getPrice() + $renderer->getWeeeTaxAppliedAmount()
359
- + $renderer->getWeeeTaxDisposition();
360
- }
361
- }
362
-
363
- $totalNodeId = $idPrefix . 'fpt_total_' . ($isIncludeTax ? self::INCLUDING_TAX_ID : self::EXCLUDING_TAX_ID);
364
- $parentXml->addCustomChild('price', Mage::helper('xmlconnect')->formatPriceForXml($total), array(
365
- 'id' => $totalNodeId,
366
- 'label' => $isIncludeTax ? $renderer->helper('weee')->__('Total incl. tax')
367
- : $renderer->helper('weee')->__('Total excl. tax'),
368
- 'formatted_price' => $this->formatPrice($renderer, $total)
369
- ));
370
  }
371
  }
372
 
@@ -383,19 +221,19 @@ class Mage_XmlConnect_Helper_Customer_Order extends Mage_Core_Helper_Abstract
383
  ) {
384
  $qty = 1 * $item->getQtyOrdered();
385
  if ($qty > 0) {
386
- $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Ordered')));
387
  }
388
  $qty = 1 * $item->getQtyShipped();
389
  if ($qty > 0) {
390
- $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Shipped')));
391
  }
392
  $qty = 1 * $item->getQtyCanceled();
393
  if ($qty > 0) {
394
- $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Canceled')));
395
  }
396
  $qty = 1 * $item->getQtyRefunded();
397
  if ($qty > 0) {
398
- $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Refunded')));
399
  }
400
  }
401
 
35
  {
36
  /**#@+
37
  * Price display type
 
38
  * @see Mage_Weee_Helper_Data::typeOfDisplay(...);
39
  */
40
  const PRICE_DISPLAY_TYPE_1 = 1;
43
  const PRICE_DISPLAY_TYPE_14 = 14;
44
  /**#@-*/
45
 
 
 
 
 
 
 
 
 
 
 
46
  /**
47
  * Add Weee taxes child to the XML
48
  *
55
  */
56
  public function addPriceAndSubtotalToXml(Mage_Core_Block_Template $renderer, Mage_Sales_Model_Order_Item $item,
57
  Mage_XmlConnect_Model_Simplexml_Element $priceXml, Mage_XmlConnect_Model_Simplexml_Element $subtotalXml,
58
+ $isIncludeTax = false
59
+ ) {
60
  $weeeParams = array();
61
 
62
  $typesOfDisplay = $renderer->getTypesOfDisplay();
63
  if ($isIncludeTax) {
64
+ $nodeName = 'including_tax';
65
+ $nodeLabel = Mage::helper('tax')->__('Incl. Tax');
66
 
67
  $inclPrice = $renderer->helper('checkout')->getPriceInclTax($item);
68
  $inclSubtotal = $renderer->helper('checkout')->getSubtotalInclTax($item);
76
  }
77
  $weeeParams['include'] = $inclPrice;
78
  } else {
79
+ $nodeName = 'excluding_tax';
80
+ $nodeLabel = Mage::helper('tax')->__('Excl. Tax');
81
 
82
  if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_14]) {
83
  $price = $item->getPrice() + $renderer->getWeeeTaxAppliedAmount()
90
  }
91
  }
92
 
93
+ $configNode = array(
94
+ 'value' => $this->formatPrice($renderer, $price)
95
+ );
96
  if ($renderer->helper('tax')->displaySalesBothPrices()) {
97
  $configNode['label'] = $nodeLabel;
98
  }
104
  $configNode['value'] = $this->formatPrice($renderer, $subtotal);
105
  $weeeParams['include'] = $isIncludeTax ? $inclSubtotal : null;
106
  $weeeParams['is_subtotal'] = true;
 
107
  $this->addWeeeTaxesToPriceXml(
108
  $renderer, $item, $subtotalXml->addCustomChild($nodeName, null, $configNode), $weeeParams
109
  );
110
  }
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  /**
113
  * Add Product options to XML
114
  *
121
  ) {
122
  $options = $renderer->getItemOptions();
123
  if (!empty($options)) {
124
+ $optionsXml = $itemXml->addChild('options');
125
 
126
  foreach ($options as $option) {
127
  $value = false;
128
+ $formatedOptionValue = $renderer->getFormatedOptionValue($option);
129
+ if (isset($formatedOptionValue['full_view']) && isset($formatedOptionValue['value'])) {
130
+ $value = $formatedOptionValue['value'];
131
  } elseif (isset($option['print_value'])) {
132
  $value = $option['print_value'];
133
  } elseif (isset($option['value'])) {
134
  $value = $option['value'];
135
  }
136
  if ($value) {
137
+ $optionsXml->addCustomChild('option', strip_tags($value), array('label' => $option['label']));
 
 
138
  }
139
  }
140
  }
165
  if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_1]) {
166
  $weeeXml = $parentXml->addChild('weee');
167
  foreach ($weeTaxes as $tax) {
168
+ $weeeXml->addCustomChild('tax', $this->formatPrice($renderer, $tax[$row . 'amount']),
169
+ array('label' => $tax['title'])
170
+ );
171
  }
172
  } elseif ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_2] || $typesOfDisplay[self::PRICE_DISPLAY_TYPE_4]) {
173
  $weeeXml = $parentXml->addChild('weee');
174
  foreach ($weeTaxes as $tax) {
175
+ $weeeXml->addCustomChild('tax', $this->formatPrice($renderer, $tax[$row . 'amount_incl_tax']),
176
+ array('label' => $tax['title'])
177
+ );
178
  }
179
  }
180
 
181
  if ($typesOfDisplay[self::PRICE_DISPLAY_TYPE_2]) {
182
+ if (!is_null($params['include'])) {
183
  // including tax
184
  if (isset($params['is_subtotal'])) {
185
  $total = $params['include'] + $item->getWeeeTaxAppliedRowAmount();
188
  }
189
  } else {
190
  // excluding tax
191
+ if ($params['is_subtotal']) {
192
  $total = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount()
193
  + $item->getWeeeTaxRowDisposition();
194
  } else {
200
  if (!isset($weeeXml)) {
201
  $weeeXml = $parentXml->addChild('weee');
202
  }
203
+ $weeeXml->addCustomChild(
204
+ 'total',
205
+ $this->formatPrice($renderer, $total),
206
+ array('label' => $renderer->helper('weee')->__('Total'))
207
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
209
  }
210
 
221
  ) {
222
  $qty = 1 * $item->getQtyOrdered();
223
  if ($qty > 0) {
224
+ $quantityXml->addCustomChild('value', $qty, array('label' => Mage::helper('xmlconnect')->__('Ordered')));
225
  }
226
  $qty = 1 * $item->getQtyShipped();
227
  if ($qty > 0) {
228
+ $quantityXml->addCustomChild('value', $qty, array('label' => Mage::helper('xmlconnect')->__('Shipped')));
229
  }
230
  $qty = 1 * $item->getQtyCanceled();
231
  if ($qty > 0) {
232
+ $quantityXml->addCustomChild('value', $qty, array('label' => Mage::helper('xmlconnect')->__('Canceled')));
233
  }
234
  $qty = 1 * $item->getQtyRefunded();
235
  if ($qty > 0) {
236
+ $quantityXml->addCustomChild('value', $qty, array('label' => Mage::helper('xmlconnect')->__('Refunded')));
237
  }
238
  }
239
 
app/code/core/Mage/XmlConnect/Helper/Data.php CHANGED
@@ -33,16 +33,6 @@
33
  */
34
  class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract
35
  {
36
- /**
37
- * Thumbnail image width
38
- */
39
- const THUMBNAIL_IMAGE_WIDTH = 160;
40
-
41
- /**
42
- * Thumbnail image height
43
- */
44
- const THUMBNAIL_IMAGE_HEIGHT = 115;
45
-
46
  /**
47
  * Push title length
48
  */
@@ -53,6 +43,11 @@ class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract
53
  */
54
  const MESSAGE_TITLE_LENGTH = 255;
55
 
 
 
 
 
 
56
  /**
57
  * List of the keys for xml config that have to be excluded form application config
58
  *
@@ -114,16 +109,6 @@ class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract
114
  */
115
  const SOCIAL_NETWORK_LINKEDIN = 'linkedin';
116
 
117
- /**
118
- * Api changes for version 23
119
- */
120
- const DEVICE_API_V_23 = '23';
121
-
122
- /**
123
- * API version request param
124
- */
125
- const API_VERSION_REQUEST_PARAM = 'api_version';
126
-
127
  /**
128
  * Get device preview model
129
  *
@@ -211,16 +196,6 @@ class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract
211
  return $model;
212
  }
213
 
214
- /**
215
- * Get application id from model in registry
216
- *
217
- * @return int
218
- */
219
- public function getApplicationId()
220
- {
221
- return $this->getApplication()->getId();
222
- }
223
-
224
  /**
225
  * Create array with filter model and filter block by key
226
  *
@@ -273,14 +248,15 @@ class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract
273
  {
274
  Varien_Profiler::start('TEST: ' . __METHOD__);
275
  $deviceType = $this->getDeviceType();
276
- $deviceCountries = $this->getDeviceHelper()->getAllowedCountriesArray();
277
  switch ($deviceType) {
278
  case self::DEVICE_TYPE_IPHONE:
279
  case self::DEVICE_TYPE_IPAD:
280
  $cacheKey = 'XMLCONNECT_COUNTRY_ITUNES_SELECT_STORE_' . Mage::app()->getStore()->getCode();
 
281
  break;
282
  case self::DEVICE_TYPE_ANDROID:
283
  $cacheKey = 'XMLCONNECT_COUNTRY_ANDROID_SELECT_STORE_' . Mage::app()->getStore()->getCode();
 
284
  break;
285
  default:
286
  Mage::throwException(
@@ -649,17 +625,13 @@ EOT;
649
  }
650
 
651
  try {
 
652
  /** @var $app Mage_XmlConnect_Model_Application */
653
- $templateModel = Mage::getModel('xmlconnect/template')->load($queue->getTemplateId());
654
- if (!$templateModel->getId()) {
655
- Mage::throwException(
656
- Mage::helper('xmlconnect')->__('Can\'t load template with id "%s"', $templateModel->getId())
657
- );
658
- }
659
- $app = Mage::getModel('xmlconnect/application')->load($templateModel->getApplicationId());
660
  if (!$app->getId()) {
661
  Mage::throwException(
662
- Mage::helper('xmlconnect')->__('Can\'t load application with id "%s"', $templateModel->getApplicationId())
663
  );
664
  }
665
 
@@ -669,7 +641,6 @@ EOT;
669
  }
670
 
671
  $sendType = $queue->getData('type');
672
-
673
  switch ($sendType) {
674
  case Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_AIRMAIL:
675
  $configPath = 'xmlconnect/' . Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_AIRMAIL . '/broadcast_url';
@@ -683,30 +654,19 @@ EOT;
683
  break;
684
  }
685
 
686
- $curlHandler = curl_init(Mage::getStoreConfig($configPath));
 
687
 
688
- $httpHeaders = $this->getHttpHeaders();
 
 
 
689
 
690
- curl_setopt($curlHandler, CURLOPT_POST, 1);
691
- curl_setopt($curlHandler, CURLOPT_HTTPHEADER, $httpHeaders);
692
- curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $params);
693
- curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1);
694
- curl_setopt($curlHandler, CURLOPT_USERPWD, $app->getUserpwd());
695
- curl_setopt($curlHandler, CURLOPT_TIMEOUT, 60);
696
-
697
- // Execute the request.
698
- $result = curl_exec($curlHandler);
699
- $succeeded = curl_errno($curlHandler) == 0;
700
- $responseCode = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);
701
- // close cURL resource, and free up system resources
702
- curl_close($curlHandler);
703
-
704
- if ($succeeded && $responseCode == 200) {
705
  $queue->setStatus(Mage_XmlConnect_Model_Queue::STATUS_COMPLETED);
706
- } else {
707
- Mage::log($result);
708
- $queue->setStatus(Mage_XmlConnect_Model_Queue::STATUS_CANCELED);
709
  }
 
 
710
  $queue->setIsSent(true);
711
  $queue->save();
712
  return;
@@ -726,6 +686,18 @@ EOT;
726
  return array('Content-Type: application/json');
727
  }
728
 
 
 
 
 
 
 
 
 
 
 
 
 
729
  /**
730
  * Remove from array the unnecessary parameters by given keys
731
  *
@@ -841,7 +813,6 @@ EOT;
841
  /**
842
  * Convert Url link to file path for images
843
  *
844
- * @deprecated will remove in new release
845
  * @param string $icon
846
  * @return string
847
  */
@@ -910,70 +881,4 @@ EOT;
910
  {
911
  return preg_replace(array('@\r@', '@\n+@'), array('', PHP_EOL), $string);
912
  }
913
-
914
- /**
915
- * Add item to total node
916
- *
917
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
918
- * @param string $code
919
- * @param string $label
920
- * @param float $value
921
- * @param string $formattedValue
922
- * @return Mage_XmlConnect_Helper_Data
923
- */
924
- public function addTotalItemToXmlObj($xmlObj, $code, $label, $value, $formattedValue)
925
- {
926
- $xmlObj->addCustomChild('item', Mage::helper('xmlconnect')->formatPriceForXml($value), array(
927
- 'id' => $code,
928
- 'label' => $label,
929
- 'formatted_value' => $formattedValue
930
- ));
931
- return $this;
932
- }
933
-
934
- /**
935
- * Check if current api version equal to device api version
936
- *
937
- * @param string $apiVersion
938
- * @param string $operator
939
- * @return bool
940
- */
941
- public function checkApiVersion($apiVersion, $operator = '>=')
942
- {
943
- if (version_compare($this->getApiVersion(), $apiVersion, $operator) === true) {
944
- return true;
945
- }
946
- return false;
947
- }
948
-
949
- /**
950
- * Get api version param
951
- *
952
- * @return string
953
- */
954
- public function getApiVersion()
955
- {
956
- return Mage::app()->getRequest()->getParam(self::API_VERSION_REQUEST_PARAM, false);
957
- }
958
-
959
- /**
960
- * Check is localization has been changed
961
- *
962
- * @return bool
963
- */
964
- public function isChangeLocalization()
965
- {
966
- /** @var $translateHelper Mage_XmlConnect_Helper_Translate */
967
- $translateHelper = Mage::helper('xmlconnect/translate');
968
- $localizationHash = $translateHelper->getHash();
969
-
970
- /** @var $configuration Mage_XmlConnect_Model_Configuration */
971
- $configuration = Mage::getSingleton('xmlconnect/configuration');
972
- if ($configuration->getPreviousLocalizationHash() !== $localizationHash) {
973
- $configuration->setPreviousLocalizationHash($localizationHash);
974
- $configuration->getApplicationModel()->updateAllAppsUpdatedAtParameter();
975
- return true;
976
- }
977
- return false;
978
- }
979
  }
33
  */
34
  class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract
35
  {
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * Push title length
38
  */
43
  */
44
  const MESSAGE_TITLE_LENGTH = 255;
45
 
46
+ /**
47
+ * Curl default timeout
48
+ */
49
+ const CURLOPT_DEFAULT_TIMEOUT = 60;
50
+
51
  /**
52
  * List of the keys for xml config that have to be excluded form application config
53
  *
109
  */
110
  const SOCIAL_NETWORK_LINKEDIN = 'linkedin';
111
 
 
 
 
 
 
 
 
 
 
 
112
  /**
113
  * Get device preview model
114
  *
196
  return $model;
197
  }
198
 
 
 
 
 
 
 
 
 
 
 
199
  /**
200
  * Create array with filter model and filter block by key
201
  *
248
  {
249
  Varien_Profiler::start('TEST: ' . __METHOD__);
250
  $deviceType = $this->getDeviceType();
 
251
  switch ($deviceType) {
252
  case self::DEVICE_TYPE_IPHONE:
253
  case self::DEVICE_TYPE_IPAD:
254
  $cacheKey = 'XMLCONNECT_COUNTRY_ITUNES_SELECT_STORE_' . Mage::app()->getStore()->getCode();
255
+ $deviceCountries = $this->getDeviceHelper()->getItunesCountriesArray();
256
  break;
257
  case self::DEVICE_TYPE_ANDROID:
258
  $cacheKey = 'XMLCONNECT_COUNTRY_ANDROID_SELECT_STORE_' . Mage::app()->getStore()->getCode();
259
+ $deviceCountries = $this->getDeviceHelper()->getAndroidMarketCountriesArray();
260
  break;
261
  default:
262
  Mage::throwException(
625
  }
626
 
627
  try {
628
+ $applicationId = Mage::getModel('xmlconnect/template')->load($queue->getTemplateId())->getApplicationId();
629
  /** @var $app Mage_XmlConnect_Model_Application */
630
+ $app = Mage::getModel('xmlconnect/application')->load($applicationId);
631
+
 
 
 
 
 
632
  if (!$app->getId()) {
633
  Mage::throwException(
634
+ Mage::helper('xmlconnect')->__('Can\'t load application with id "%s"', $applicationId)
635
  );
636
  }
637
 
641
  }
642
 
643
  $sendType = $queue->getData('type');
 
644
  switch ($sendType) {
645
  case Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_AIRMAIL:
646
  $configPath = 'xmlconnect/' . Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_AIRMAIL . '/broadcast_url';
654
  break;
655
  }
656
 
657
+ $curl = new Varien_Http_Adapter_Curl();
658
+ $curl->setConfig($this->_getCurlConfig($app->getUserpwd()));
659
 
660
+ $urbanUrl = Mage::getStoreConfig($configPath);
661
+ $curl->write(
662
+ Zend_Http_Client::POST, $urbanUrl, HTTP_REQUEST_HTTP_VER_1_1, $this->getHttpHeaders(), $params
663
+ );
664
 
665
+ if ($curl->read() && $curl->getInfo(CURLINFO_HTTP_CODE) == 200) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
666
  $queue->setStatus(Mage_XmlConnect_Model_Queue::STATUS_COMPLETED);
 
 
 
667
  }
668
+ $curl->close();
669
+
670
  $queue->setIsSent(true);
671
  $queue->save();
672
  return;
686
  return array('Content-Type: application/json');
687
  }
688
 
689
+ /**
690
+ * Get urban airship curl request configuration
691
+ *
692
+ * @param string $userPwd
693
+ * @param int $timeout
694
+ * @return array
695
+ */
696
+ protected function _getCurlConfig($userPwd, $timeout = self::CURLOPT_DEFAULT_TIMEOUT)
697
+ {
698
+ return array ('timeout' => $timeout, 'userpwd' => $userPwd);
699
+ }
700
+
701
  /**
702
  * Remove from array the unnecessary parameters by given keys
703
  *
813
  /**
814
  * Convert Url link to file path for images
815
  *
 
816
  * @param string $icon
817
  * @return string
818
  */
881
  {
882
  return preg_replace(array('@\r@', '@\n+@'), array('', PHP_EOL), $string);
883
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
884
  }
app/code/core/Mage/XmlConnect/Helper/Device/Abstract.php DELETED
@@ -1,309 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect device helper abstract
28
- *
29
- * @category Mage
30
- * @package Mage_XmlConnect
31
- * @author Magento Core Team <core@magentocommerce.com>
32
- */
33
- abstract class Mage_XmlConnect_Helper_Device_Abstract extends Mage_Core_Helper_Abstract
34
- {
35
- /**
36
- * Country renderer block
37
- *
38
- * @var string
39
- */
40
- protected $_countryRendererBlock = 'xmlconnect/adminhtml_mobile_submission_renderer_country_istore';
41
-
42
- /**
43
- * Country field renderer
44
- *
45
- * @var Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
46
- */
47
- protected $_countryRenderer;
48
-
49
- /**
50
- * Submission columns count
51
- *
52
- * @var int
53
- */
54
- protected $_countryColumnsCount = 4;
55
-
56
- /**
57
- * List of coutries that allowed in Ituens by Apple Store
58
- *
59
- * array(
60
- * 'country name' => 'country id at directory model'
61
- * )
62
- *
63
- * @var array
64
- */
65
- protected $_allowedCountries = array(
66
- 'Argentina' => 'AR',
67
- 'Armenia' => 'AM',
68
- 'Australia' => 'AU',
69
- 'Austria' => 'AT',
70
- 'Belgium' => 'BE',
71
- 'Botswana' => 'BW',
72
- 'Brazil' => 'BR',
73
- 'Bulgaria' => 'BG',
74
- 'Canada' => 'CA',
75
- 'Chile' => 'CL',
76
- 'China' => 'CN',
77
- 'Colombia' => 'CO',
78
- 'Costa Rica' => 'CR',
79
- 'Croatia' => 'HR',
80
- 'Czech Republic' => 'CZ',
81
- 'Denmark' => 'DK',
82
- 'Dominican Republic' => 'DO',
83
- 'Ecuador' => 'EC',
84
- 'Egypt' => 'EG',
85
- 'El Salvador' => 'SV',
86
- 'Estonia' => 'EE',
87
- 'Finland' => 'FI',
88
- 'France' => 'FR',
89
- 'Germany' => 'DE',
90
- 'Greece' => 'GR',
91
- 'Guatemala' => 'GT',
92
- 'Honduras' => 'HN',
93
- 'Hong Kong SAR China' => 'HK',
94
- 'Hungary' => 'HU',
95
- 'India' => 'IN',
96
- 'Indonesia' => 'ID',
97
- 'Ireland' => 'IE',
98
- 'Israel' => 'IL',
99
- 'Italy' => 'IT',
100
- 'Jamaica' => 'JM',
101
- 'Japan' => 'JP',
102
- 'Jordan' => 'JO',
103
- 'Kazakstan' => 'KZ',
104
- 'Kenya' => 'KE',
105
- 'South Korea' => 'KR',
106
- 'Kuwait' => 'KW',
107
- 'Latvia' => 'LV',
108
- 'Lebanon' => 'LB',
109
- 'Lithuania' => 'LT',
110
- 'Luxembourg' => 'LU',
111
- 'Macau SAR China' => 'MO',
112
- 'Macedonia' => 'MK',
113
- 'Madagascar' => 'MG',
114
- 'Malaysia' => 'MY',
115
- 'Mali' => 'ML',
116
- 'Malta' => 'MT',
117
- 'Mauritius' => 'MU',
118
- 'Mexico' => 'MX',
119
- 'Moldova' => 'MD',
120
- 'Netherlands' => 'NL',
121
- 'New Zealand' => 'NZ',
122
- 'Nicaragua' => 'NI',
123
- 'Niger' => 'NE',
124
- 'Norway' => 'NO',
125
- 'Pakistan' => 'PK',
126
- 'Panama' => 'PA',
127
- 'Paraguay' => 'PY',
128
- 'Peru' => 'PE',
129
- 'Philippines' => 'PH',
130
- 'Poland' => 'PL',
131
- 'Portugal' => 'PT',
132
- 'Qatar' => 'QA',
133
- 'Romania' => 'RO',
134
- 'Russia' => 'RU',
135
- 'Saudi Arabia' => 'SA',
136
- 'Senegal' => 'SN',
137
- 'Singapore' => 'SG',
138
- 'Slovakia' => 'SK',
139
- 'Slovenia' => 'SI',
140
- 'South Africa' => 'ZA',
141
- 'Spain' => 'ES',
142
- 'Sri Lanka' => 'LK',
143
- 'Sweden' => 'SE',
144
- 'Switzerland' => 'CH',
145
- 'Taiwan' => 'TW',
146
- 'Thailand' => 'TH',
147
- 'Tunisia' => 'TN',
148
- 'Turkey' => 'TR',
149
- 'Uganda' => 'UG',
150
- 'United Arab Emirates' => 'AE',
151
- 'United Kingdom' => 'GB',
152
- 'United States' => 'US',
153
- 'Uruguay' => 'UY',
154
- 'Venezuela' => 'VE',
155
- 'Vietnam' => 'VN',
156
- );
157
-
158
- /**
159
- * Get submit images that are required for application submit
160
- *
161
- * @return array
162
- */
163
- public function getSubmitImages()
164
- {
165
- return $this->_imageIds;
166
- }
167
-
168
- /**
169
- * Default images list
170
- *
171
- * @return array
172
- */
173
- abstract function getImagesTypesList();
174
-
175
- /**
176
- * Get default application tabs
177
- *
178
- * @return array
179
- */
180
- abstract function getDefaultDesignTabs();
181
-
182
- /**
183
- * Default application configuration: font and color
184
- *
185
- * @return array
186
- */
187
- abstract function getDefaultConfiguration();
188
-
189
- /**
190
- * List of allowed fonts for application
191
- *
192
- * @return array
193
- */
194
- abstract function getFontList();
195
-
196
- /**
197
- * List of allowed font sizes for application
198
- *
199
- * @return array
200
- */
201
- public function getFontSizes()
202
- {
203
- $result = array();
204
- for ($i = 6; $i < 32; $i++) {
205
- $result[] = array(
206
- 'value' => $i,
207
- 'label' => $i . ' pt',
208
- );
209
- }
210
- return $result;
211
- }
212
-
213
- /**
214
- * Get list of countries that allowed by Magento Inc. for iOS
215
- *
216
- *
217
- * @return array
218
- */
219
- public function getAllowedCountriesArray()
220
- {
221
- return $this->_allowedCountries;
222
- }
223
-
224
- /**
225
- * Validate submit application data
226
- *
227
- * @param array $params
228
- * @return array
229
- */
230
- abstract function validateSubmit($params);
231
-
232
- /**
233
- * Get renderer for submission country
234
- *
235
- * @return Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
236
- */
237
- public function getCountryRenderer()
238
- {
239
- if (empty($this->_countryRenderer)) {
240
- $this->_countryRenderer = Mage::app()->getLayout()->createBlock($this->_countryRendererBlock);
241
- }
242
- return $this->_countryRenderer;
243
- }
244
-
245
- /**
246
- * Get label for submission country
247
- *
248
- * @return string
249
- */
250
- public function getCountryLabel()
251
- {
252
- return Mage::helper('xmlconnect')->__('App Stores');
253
- }
254
-
255
- /**
256
- * Get count of columns for submission country
257
- *
258
- * @return int
259
- */
260
- public function getCountryColumns()
261
- {
262
- return $this->_countryColumnsCount;
263
- }
264
-
265
- /**
266
- * Get placement of Country Names for submission country
267
- *
268
- * @return bool
269
- */
270
- public function isCountryNamePlaceLeft()
271
- {
272
- return true;
273
- }
274
-
275
- /**
276
- * Get class name for submission country
277
- *
278
- * @return string
279
- */
280
- public function getCountryClass()
281
- {
282
- return 'istore stripy';
283
- }
284
-
285
- /**
286
- * Check the notifications are allowed for current type of application
287
- *
288
- * @return bool
289
- */
290
- public function isNotificationsAllowed()
291
- {
292
- return true;
293
- }
294
-
295
- /**
296
- * Get image count for image type
297
- *
298
- * @param string $imageType
299
- * @return int
300
- */
301
- public function getImageCount($imageType)
302
- {
303
- $imagesTypesList = $this->getImagesTypesList();
304
- if (!array_key_exists($imageType, $imagesTypesList)) {
305
- Mage::throwException(Mage::helper('xmlconnect')->__('Image type doesn\'t recognized: "%s".', $imageType));
306
- }
307
- return !empty($imagesTypesList[$imageType]['count']) ? $imagesTypesList[$imageType]['count'] : 0;
308
- }
309
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Helper/Image.php CHANGED
@@ -35,15 +35,12 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
35
  {
36
  /**
37
  * Xml connect glue
38
- *
39
- * @deprecated will delete in the next version
40
  */
41
- const XMLCONNECT_GLUE = Mage_XmlConnect_Model_ImageLimits::SCREEN_SIZE_UPDATE_TYPE_GLUE;
42
 
43
  /**
44
  * Image limits for content
45
  *
46
- * @deprecated will delete in the next version
47
  * @var array|null
48
  */
49
  protected $_content = null;
@@ -51,7 +48,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
51
  /**
52
  * Image limits for interface
53
  *
54
- * @deprecated will delete in the next version
55
  * @var array|null
56
  */
57
  protected $_interface = null;
@@ -59,7 +55,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
59
  /**
60
  * Array of interface image paths in xmlConfig
61
  *
62
- * @deprecated will delete in the next version
63
  * @var array
64
  */
65
  protected $_interfacePath = array();
@@ -67,7 +62,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
67
  /**
68
  * Image limits array
69
  *
70
- * @deprecated will delete in the next version
71
  * @var array
72
  */
73
  protected $_imageLimits = array();
@@ -75,7 +69,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
75
  /**
76
  * Images paths in the config
77
  *
78
- * @deprecated will delete in the next version
79
  * @var array|null
80
  */
81
  protected $_confPaths = null;
@@ -84,9 +77,8 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
84
  * Process uploaded file
85
  * setup file names to the configuration
86
  *
87
- * @deprecated will delete in the next version
88
  * @param string $field
89
- * @return string
90
  */
91
  public function handleUpload($field)
92
  {
@@ -124,18 +116,16 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
124
  /**
125
  * Return current screen_size parameter
126
  *
127
- * @deprecated will delete in the next version
128
  * @return string
129
  */
130
  protected function _getScreenSize()
131
  {
132
- return $this->filterScreenSize(Mage::helper('xmlconnect')->getApplication()->getScreenSize());
133
  }
134
 
135
  /**
136
  * Return correct system filename for current screenSize
137
  *
138
- * @deprecated will delete in the next version
139
  * @throws Mage_Core_Exception
140
  * @param string $fieldPath
141
  * @param string $fileName
@@ -159,8 +149,8 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
159
  if (!file_exists($originalSizeFileName)) {
160
  $oldFileName = $this->getOldUploadDir() . DS . $fileName;
161
  if (file_exists($oldFileName)) {
162
- if (!(copy($oldFileName, $originalSizeFileName) && (is_readable($customSizeFileName)
163
- || chmod($customSizeFileName, 0644))
164
  )) {
165
  Mage::throwException(
166
  Mage::helper('xmlconnect')->__('Error while processing file "%s".', $fileName)
@@ -188,7 +178,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
188
  /**
189
  * Resize uploaded file
190
  *
191
- * @deprecated will delete in the next version
192
  * @param string $fieldPath
193
  * @param string $file
194
  * @return null
@@ -239,7 +228,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
239
  /**
240
  * Convert uploaded file to PNG
241
  *
242
- * @deprecated will delete in the next version
243
  * @param string $field
244
  */
245
  protected function _forcedConvertPng($field)
@@ -295,7 +283,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
295
  /**
296
  * Return CustomSizeDirPrefix
297
  *
298
- * @deprecated will delete in the next version
299
  * @return string
300
  */
301
  public function getCustomSizeDirPrefix()
@@ -306,8 +293,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
306
  /**
307
  * Return FileDefaultSizeSuffixAsUrl
308
  *
309
- * @todo get rid of this method
310
- * @deprecated will delete in the next version
311
  * @param string $fileName
312
  * @return string
313
  */
@@ -319,21 +304,22 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
319
  /**
320
  * Return getFileCustomDirSuffixAsUrl
321
  *
322
- * @deprecated will delete in the next version
323
  * @param string $confPath
324
  * @param string $fileName
325
  * @return string
326
  */
327
  public function getFileCustomDirSuffixAsUrl($confPath, $fileName)
328
  {
329
- return 'custom' . '/' . $this->_getScreenSize() . '/'
 
 
 
330
  . basename($this->_getResizedFilename($confPath, $fileName));
331
  }
332
 
333
  /**
334
  * Return correct size for given $imageName and device screen_size
335
  *
336
- * @deprecated will delete in the next version
337
  * @param string $imageName
338
  * @return int
339
  */
@@ -354,7 +340,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
354
  /**
355
  * Return setting for interface images (image size limits)
356
  *
357
- * @deprecated will delete in the next version
358
  * @return array
359
  */
360
  public function getInterfaceImageLimits()
@@ -369,7 +354,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
369
  /**
370
  * Return correct size for given $imageName and device screen_size
371
  *
372
- * @deprecated will delete in the next version
373
  * @param string $imagePath
374
  * @return int
375
  */
@@ -401,11 +385,11 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
401
  $path = trim($path);
402
  $result = Mage::getBaseDir('media') . DS . 'xmlconnect';
403
 
404
- if ($path) {
405
- if (strpos($path, DS) !== 0) {
406
- $path = DS . $path;
407
  }
408
- $result .= $path;
409
  }
410
  return $result;
411
  }
@@ -421,11 +405,11 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
421
  $image = trim($image);
422
  $result = Mage::getBaseUrl('media') . 'xmlconnect';
423
 
424
- if ($image) {
425
- if (strpos($image, '/') !== 0) {
426
- $image = '/' . $image;
427
  }
428
- $result .= $image;
429
  }
430
  return $result;
431
  }
@@ -453,8 +437,7 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
453
  }
454
 
455
  /**
456
- * Retrieve custom size image url
457
- *
458
  *
459
  * @param string $imageUrl
460
  * @param int $width
@@ -467,8 +450,8 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
467
  $customDir = $this->getMediaPath('custom' . DS . $screenSize);
468
  $this->_verifyDirExist($customDir);
469
  $imageUrl = explode('/', $imageUrl);
470
- $file = array_pop($imageUrl);
471
- $filePath = Mage_XmlConnect_Model_Images::getBasePath() . DS . $file;
472
  if (!file_exists($customDir . DS . $file)) {
473
  $image = new Varien_Image($filePath);
474
  $widthOriginal = $image->getOriginalWidth();
@@ -498,7 +481,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
498
  /**
499
  * Ensure correct $screenSize value
500
  *
501
- * @deprecated will delete in the next version
502
  * @param string $screenSize
503
  * @return string
504
  */
@@ -536,7 +518,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
536
  /**
537
  * Return correct size array for given device screen_size(320x480/640x960_a)
538
  *
539
- * @deprecated will delete in the next version
540
  * @param string $screenSize
541
  * @return array
542
  */
@@ -633,7 +614,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
633
  /**
634
  * Return reference to the $path in $array
635
  *
636
- * @deprecated will delete in the next version
637
  * @param array &$array
638
  * @param string $path
639
  * @return mixed reference
@@ -647,7 +627,8 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
647
  if (is_array($target) && isset($target[$node])) {
648
  $target =& $target[$node];
649
  } else {
650
- return null;
 
651
  }
652
  }
653
  }
@@ -657,7 +638,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
657
  /**
658
  * Multiply given $item by $value if non array
659
  *
660
- * @deprecated will delete in the next version
661
  * @param mixed $item (argument to change)
662
  * @param mixed $key (used with array_walk_recursive function as a key of given array)
663
  * @param string $value (contains float)
@@ -689,7 +669,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
689
  /**
690
  * Return customSizeUploadDir path
691
  *
692
- * @deprecated will delete in the next version
693
  * @param string $screenSize
694
  * @return string
695
  */
@@ -704,7 +683,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
704
  /**
705
  * Return originalSizeUploadDir path
706
  *
707
- * @deprecated will delete in the next version
708
  * @return string
709
  */
710
  public function getOriginalSizeUploadDir()
@@ -717,7 +695,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
717
  /**
718
  * Return oldUpload dir path (media/xmlconnect)
719
  *
720
- * @deprecated from 1.6.1.0
721
  * @return string
722
  */
723
  public function getOldUploadDir()
@@ -730,7 +707,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
730
  /**
731
  * Return default size upload dir path
732
  *
733
- * @deprecated will delete in the next version
734
  * @return string
735
  */
736
  public function getDefaultSizeUploadDir()
@@ -741,7 +717,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
741
  /**
742
  * Return array for interface images paths in the config
743
  *
744
- * @deprecated will delete in the next version
745
  * @return array
746
  */
747
  public function getInterfaceImagesPathsConf()
@@ -764,7 +739,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
764
  * - default interface image path for specified $imagePath
765
  * - array of image paths
766
  *
767
- * @deprecated will delete in the next version
768
  * @param string $imagePath
769
  * @return array|string
770
  */
@@ -794,7 +768,6 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
794
  /**
795
  * Check image and get full file path
796
  *
797
- * @deprecated will delete in the next version
798
  * @param string &$icon
799
  * @return bool
800
  */
35
  {
36
  /**
37
  * Xml connect glue
 
 
38
  */
39
+ const XMLCONNECT_GLUE = '_';
40
 
41
  /**
42
  * Image limits for content
43
  *
 
44
  * @var array|null
45
  */
46
  protected $_content = null;
48
  /**
49
  * Image limits for interface
50
  *
 
51
  * @var array|null
52
  */
53
  protected $_interface = null;
55
  /**
56
  * Array of interface image paths in xmlConfig
57
  *
 
58
  * @var array
59
  */
60
  protected $_interfacePath = array();
62
  /**
63
  * Image limits array
64
  *
 
65
  * @var array
66
  */
67
  protected $_imageLimits = array();
69
  /**
70
  * Images paths in the config
71
  *
 
72
  * @var array|null
73
  */
74
  protected $_confPaths = null;
77
  * Process uploaded file
78
  * setup file names to the configuration
79
  *
 
80
  * @param string $field
81
+ * @retun string
82
  */
83
  public function handleUpload($field)
84
  {
116
  /**
117
  * Return current screen_size parameter
118
  *
 
119
  * @return string
120
  */
121
  protected function _getScreenSize()
122
  {
123
+ return Mage::helper('xmlconnect')->getApplication()->getScreenSize();
124
  }
125
 
126
  /**
127
  * Return correct system filename for current screenSize
128
  *
 
129
  * @throws Mage_Core_Exception
130
  * @param string $fieldPath
131
  * @param string $fileName
149
  if (!file_exists($originalSizeFileName)) {
150
  $oldFileName = $this->getOldUploadDir() . DS . $fileName;
151
  if (file_exists($oldFileName)) {
152
+ if (!(copy($oldFileName, $originalSizeFileName)
153
+ && (is_readable($customSizeFileName) || chmod($customSizeFileName, 0644))
154
  )) {
155
  Mage::throwException(
156
  Mage::helper('xmlconnect')->__('Error while processing file "%s".', $fileName)
178
  /**
179
  * Resize uploaded file
180
  *
 
181
  * @param string $fieldPath
182
  * @param string $file
183
  * @return null
228
  /**
229
  * Convert uploaded file to PNG
230
  *
 
231
  * @param string $field
232
  */
233
  protected function _forcedConvertPng($field)
283
  /**
284
  * Return CustomSizeDirPrefix
285
  *
 
286
  * @return string
287
  */
288
  public function getCustomSizeDirPrefix()
293
  /**
294
  * Return FileDefaultSizeSuffixAsUrl
295
  *
 
 
296
  * @param string $fileName
297
  * @return string
298
  */
304
  /**
305
  * Return getFileCustomDirSuffixAsUrl
306
  *
 
307
  * @param string $confPath
308
  * @param string $fileName
309
  * @return string
310
  */
311
  public function getFileCustomDirSuffixAsUrl($confPath, $fileName)
312
  {
313
+ return 'custom'
314
+ . '/'
315
+ . $this->_getScreenSize()
316
+ . '/'
317
  . basename($this->_getResizedFilename($confPath, $fileName));
318
  }
319
 
320
  /**
321
  * Return correct size for given $imageName and device screen_size
322
  *
 
323
  * @param string $imageName
324
  * @return int
325
  */
340
  /**
341
  * Return setting for interface images (image size limits)
342
  *
 
343
  * @return array
344
  */
345
  public function getInterfaceImageLimits()
354
  /**
355
  * Return correct size for given $imageName and device screen_size
356
  *
 
357
  * @param string $imagePath
358
  * @return int
359
  */
385
  $path = trim($path);
386
  $result = Mage::getBaseDir('media') . DS . 'xmlconnect';
387
 
388
+ if (!empty($path)) {
389
+ if (strpos($path, DS) === 0) {
390
+ $path = substr($path, 1);
391
  }
392
+ $result .= DS . $path;
393
  }
394
  return $result;
395
  }
405
  $image = trim($image);
406
  $result = Mage::getBaseUrl('media') . 'xmlconnect';
407
 
408
+ if (!empty($image)) {
409
+ if (strpos($image, '/') === 0) {
410
+ $image = substr($image, 1);
411
  }
412
+ $result .= '/' . $image;
413
  }
414
  return $result;
415
  }
437
  }
438
 
439
  /**
440
+ * Retrieve thumbnail image url
 
441
  *
442
  * @param string $imageUrl
443
  * @param int $width
450
  $customDir = $this->getMediaPath('custom' . DS . $screenSize);
451
  $this->_verifyDirExist($customDir);
452
  $imageUrl = explode('/', $imageUrl);
453
+ $file = $imageUrl[count($imageUrl)-1];
454
+ $filePath = $this->getDefaultSizeUploadDir() . DS . $file;
455
  if (!file_exists($customDir . DS . $file)) {
456
  $image = new Varien_Image($filePath);
457
  $widthOriginal = $image->getOriginalWidth();
481
  /**
482
  * Ensure correct $screenSize value
483
  *
 
484
  * @param string $screenSize
485
  * @return string
486
  */
518
  /**
519
  * Return correct size array for given device screen_size(320x480/640x960_a)
520
  *
 
521
  * @param string $screenSize
522
  * @return array
523
  */
614
  /**
615
  * Return reference to the $path in $array
616
  *
 
617
  * @param array &$array
618
  * @param string $path
619
  * @return mixed reference
627
  if (is_array($target) && isset($target[$node])) {
628
  $target =& $target[$node];
629
  } else {
630
+ $targetNull = null;
631
+ return $targetNull;
632
  }
633
  }
634
  }
638
  /**
639
  * Multiply given $item by $value if non array
640
  *
 
641
  * @param mixed $item (argument to change)
642
  * @param mixed $key (used with array_walk_recursive function as a key of given array)
643
  * @param string $value (contains float)
669
  /**
670
  * Return customSizeUploadDir path
671
  *
 
672
  * @param string $screenSize
673
  * @return string
674
  */
683
  /**
684
  * Return originalSizeUploadDir path
685
  *
 
686
  * @return string
687
  */
688
  public function getOriginalSizeUploadDir()
695
  /**
696
  * Return oldUpload dir path (media/xmlconnect)
697
  *
 
698
  * @return string
699
  */
700
  public function getOldUploadDir()
707
  /**
708
  * Return default size upload dir path
709
  *
 
710
  * @return string
711
  */
712
  public function getDefaultSizeUploadDir()
717
  /**
718
  * Return array for interface images paths in the config
719
  *
 
720
  * @return array
721
  */
722
  public function getInterfaceImagesPathsConf()
739
  * - default interface image path for specified $imagePath
740
  * - array of image paths
741
  *
 
742
  * @param string $imagePath
743
  * @return array|string
744
  */
768
  /**
769
  * Check image and get full file path
770
  *
 
771
  * @param string &$icon
772
  * @return bool
773
  */
app/code/core/Mage/XmlConnect/Helper/Ipad.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
35
  {
36
  /**
37
  * Submission title length
@@ -44,62 +44,52 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
44
  const SUBMISSION_DESCRIPTION_LENGTH = 500;
45
 
46
  /**
47
- * Ipad landscape orientation identifier
48
- * @deprecated
49
  */
50
  const ORIENTATION_LANDSCAPE = 'landscape';
51
 
52
  /**
53
- * Ipad portrait orientation identifier
54
- * @deprecated
55
  */
56
  const ORIENTATION_PORTRAIT = 'portrait';
57
 
58
  /**
59
- * Ipad portrait preview banner width
60
- * @deprecated
61
  */
62
  const PREVIEW_PORTRAIT_BANNER_WIDTH = 350;
63
 
64
  /**
65
  * Ipad portrait preview banner image height
66
- * @deprecated
67
  */
68
  const PREVIEW_PORTRAIT_BANNER_HEIGHT = 135;
69
 
70
  /**
71
- * Ipad landscape preview banner width
72
- * @deprecated
73
  */
74
  const PREVIEW_LANDSCAPE_BANNER_WIDTH = 467;
75
 
76
  /**
77
  * Ipad landscape preview banner image height
78
- * @deprecated
79
  */
80
  const PREVIEW_LANDSCAPE_BANNER_HEIGHT = 157;
81
 
82
  /**
83
- * Ipad landscape orientation preview image width
84
- * @deprecated
85
  */
86
  const PREVIEW_LANDSCAPE_BACKGROUND_WIDTH = 467;
87
 
88
  /**
89
  * Ipad landscape orientation preview image height
90
- * @deprecated
91
  */
92
  const PREVIEW_LANDSCAPE_BACKGROUND_HEIGHT = 321;
93
 
94
  /**
95
- * Ipad portrait orientation preview image width
96
- * @deprecated
97
  */
98
  const PREVIEW_PORTRAIT_BACKGROUND_WIDTH = 350;
99
 
100
  /**
101
  * Ipad portrait orientation preview image height
102
- * @deprecated
103
  */
104
  const PREVIEW_PORTRAIT_BACKGROUND_HEIGHT = 438;
105
 
@@ -112,6 +102,23 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
112
  'icon', 'ipad_loader_portrait_image', 'ipad_loader_landscape_image', 'ipad_logo', 'big_logo'
113
  );
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  /**
116
  * Get default application tabs
117
  *
@@ -146,46 +153,6 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
146
  return $this->_tabs;
147
  }
148
 
149
- /**
150
- * Default images list
151
- *
152
- * @return array
153
- */
154
- public function getImagesTypesList()
155
- {
156
- return array(
157
- Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_ICON => array(
158
- 'count' => Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_ICON_COUNT,
159
- 'label' => $this->__('Logo in Header'),
160
- 'sortable' => false,
161
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 35, 35)
162
- ),
163
- Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_PORTRAIT_BACKGROUND => array(
164
- 'count' => Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_BACKGROUND_COUNT,
165
- 'label' => $this->__('Portrait app Background'),
166
- 'sortable' => false,
167
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 768, 960) . $this->__('Note: Image size affects the performance of your app.')
168
- ),
169
- Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_LANDSCAPE_BACKGROUND => array(
170
- 'count' => Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_BACKGROUND_COUNT,
171
- 'label' => $this->__('Landscape app Background'),
172
- 'sortable' => false,
173
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 1024, 704) . $this->__('Note: Image size affects the performance of your app.')
174
- ),
175
- Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_PORTRAIT_BANNER => array(
176
- 'count' => Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_BANNER_COUNT,
177
- 'label' => $this->__('Portrait banners on Home Screen'),
178
- 'sortable' => true,
179
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 768, 294) . $this->__('Note: Image size affects the performance of your app.')
180
- ),
181
- Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_LANDSCAPE_BANNER => array(
182
- 'count' => Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_BANNER_COUNT,
183
- 'label' => $this->__('Landscape banners on Home Screen'),
184
- 'sortable' => true,
185
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 1024, 344) . $this->__('Note: Image size affects the performance of your app.')
186
- ));
187
- }
188
-
189
  /**
190
  * Default application configuration
191
  *
@@ -257,7 +224,10 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
257
  'name' => 'HelveticaNeue',
258
  'size' => '12',
259
  'color' => '#222222',
260
- ))));
 
 
 
261
  }
262
 
263
  /**
@@ -475,21 +445,36 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
475
  array(
476
  'value' => 'STHeitiK-Light',
477
  'label' => 'STHeitiK-Light',
478
- ));
 
479
  }
480
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
 
482
  /**
483
  * Get list of countries that allowed in Itunes by Apple Store for Ipad
484
  * (we get info from Iphone helper)
485
  *
486
- * @deprecated
487
- * @see $this->getAllowedCountriesArray()
488
  * @return array
489
  */
490
  public function getItunesCountriesArray()
491
  {
492
- return $this->_allowedCountries;
493
  }
494
 
495
  /**
@@ -566,7 +551,6 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
566
  /**
567
  * Check config for valid values
568
  *
569
- * @deprecated we don't use it since 1.11.1.0
570
  * @param array $native
571
  * @return array
572
  */
@@ -600,12 +584,66 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
600
  return $errors;
601
  }
602
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
  /**
604
  * Check image fields
605
  *
606
  * We set empty value for image field if file was missed in some reason
607
  *
608
- * @deprecated will delete in the next version
609
  * @param array $data
610
  * @return array
611
  */
@@ -650,7 +688,6 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
650
  /**
651
  * Check required fields of a config for a front-end
652
  *
653
- * @deprecated will delete in the next version
654
  * @throws Mage_Core_Exception
655
  * @param array $data
656
  * @return null
@@ -691,4 +728,14 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_XmlConnect_Helper_Device_Abstract
691
  );
692
  }
693
  }
 
 
 
 
 
 
 
 
 
 
694
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Helper_Ipad extends Mage_Core_Helper_Abstract
35
  {
36
  /**
37
  * Submission title length
44
  const SUBMISSION_DESCRIPTION_LENGTH = 500;
45
 
46
  /**
47
+ * Ipad landscape orientation identificator
 
48
  */
49
  const ORIENTATION_LANDSCAPE = 'landscape';
50
 
51
  /**
52
+ * Ipad portrait orientation identificator
 
53
  */
54
  const ORIENTATION_PORTRAIT = 'portrait';
55
 
56
  /**
57
+ * Ipad portrait preview banner widht
 
58
  */
59
  const PREVIEW_PORTRAIT_BANNER_WIDTH = 350;
60
 
61
  /**
62
  * Ipad portrait preview banner image height
 
63
  */
64
  const PREVIEW_PORTRAIT_BANNER_HEIGHT = 135;
65
 
66
  /**
67
+ * Ipad landscape preview banner widht
 
68
  */
69
  const PREVIEW_LANDSCAPE_BANNER_WIDTH = 467;
70
 
71
  /**
72
  * Ipad landscape preview banner image height
 
73
  */
74
  const PREVIEW_LANDSCAPE_BANNER_HEIGHT = 157;
75
 
76
  /**
77
+ * Ipad landscape orientation preview image widht
 
78
  */
79
  const PREVIEW_LANDSCAPE_BACKGROUND_WIDTH = 467;
80
 
81
  /**
82
  * Ipad landscape orientation preview image height
 
83
  */
84
  const PREVIEW_LANDSCAPE_BACKGROUND_HEIGHT = 321;
85
 
86
  /**
87
+ * Ipad portrait orientation preview image widht
 
88
  */
89
  const PREVIEW_PORTRAIT_BACKGROUND_WIDTH = 350;
90
 
91
  /**
92
  * Ipad portrait orientation preview image height
 
93
  */
94
  const PREVIEW_PORTRAIT_BACKGROUND_HEIGHT = 438;
95
 
102
  'icon', 'ipad_loader_portrait_image', 'ipad_loader_landscape_image', 'ipad_logo', 'big_logo'
103
  );
104
 
105
+ /**
106
+ * Country field renderer
107
+ *
108
+ * @var Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Istore
109
+ */
110
+ protected $_countryRenderer = null;
111
+
112
+ /**
113
+ * Get submit images that are required for application submit
114
+ *
115
+ * @return array
116
+ */
117
+ public function getSubmitImages()
118
+ {
119
+ return $this->_imageIds;
120
+ }
121
+
122
  /**
123
  * Get default application tabs
124
  *
153
  return $this->_tabs;
154
  }
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  /**
157
  * Default application configuration
158
  *
224
  'name' => 'HelveticaNeue',
225
  'size' => '12',
226
  'color' => '#222222',
227
+ ),
228
+ ),
229
+ ),
230
+ );
231
  }
232
 
233
  /**
445
  array(
446
  'value' => 'STHeitiK-Light',
447
  'label' => 'STHeitiK-Light',
448
+ ),
449
+ );
450
  }
451
 
452
+ /**
453
+ * List of allowed font sizes for iPad application
454
+ *
455
+ * @return array
456
+ */
457
+ public function getFontSizes()
458
+ {
459
+ $result = array();
460
+ for ($i = 6; $i < 32; $i++) {
461
+ $result[] = array(
462
+ 'value' => $i,
463
+ 'label' => $i . ' pt',
464
+ );
465
+ }
466
+ return $result;
467
+ }
468
 
469
  /**
470
  * Get list of countries that allowed in Itunes by Apple Store for Ipad
471
  * (we get info from Iphone helper)
472
  *
 
 
473
  * @return array
474
  */
475
  public function getItunesCountriesArray()
476
  {
477
+ return Mage::helper('xmlconnect/iphone')->getItunesCountriesArray();
478
  }
479
 
480
  /**
551
  /**
552
  * Check config for valid values
553
  *
 
554
  * @param array $native
555
  * @return array
556
  */
584
  return $errors;
585
  }
586
 
587
+ /**
588
+ * Get renderer for submission country
589
+ *
590
+ * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Istore
591
+ */
592
+ public function getCountryRenderer()
593
+ {
594
+ if (empty($this->_countryRenderer)) {
595
+ $renderer = 'xmlconnect/adminhtml_mobile_submission_renderer_country_'
596
+ . Mage_XmlConnect_Helper_Iphone::SUBMISSION_COUNTRY_RENDERER;
597
+ $this->_countryRenderer = Mage::app()->getLayout()->createBlock($renderer);
598
+ }
599
+ return $this->_countryRenderer;
600
+ }
601
+
602
+ /**
603
+ * Get label for submission country
604
+ *
605
+ * @return string
606
+ */
607
+ public function getCountryLabel()
608
+ {
609
+ return Mage::helper('xmlconnect')->__('App Stores');
610
+ }
611
+
612
+ /**
613
+ * Get columns for submission country
614
+ *
615
+ * @return int
616
+ */
617
+ public function getCountryColumns()
618
+ {
619
+ return Mage_XmlConnect_Helper_Iphone::SUBMISSION_COUNTRY_COLUMNS;
620
+ }
621
+
622
+ /**
623
+ * Get placement of Country Names for submission country
624
+ *
625
+ * @return bool
626
+ */
627
+ public function isCountryNamePlaceLeft()
628
+ {
629
+ return true;
630
+ }
631
+
632
+ /**
633
+ * Get class name for submission country
634
+ *
635
+ * @return string
636
+ */
637
+ public function getCountryClass()
638
+ {
639
+ return Mage_XmlConnect_Helper_Iphone::SUBMISSION_COUNTRY_RENDERER . ' stripy';
640
+ }
641
+
642
  /**
643
  * Check image fields
644
  *
645
  * We set empty value for image field if file was missed in some reason
646
  *
 
647
  * @param array $data
648
  * @return array
649
  */
688
  /**
689
  * Check required fields of a config for a front-end
690
  *
 
691
  * @throws Mage_Core_Exception
692
  * @param array $data
693
  * @return null
728
  );
729
  }
730
  }
731
+
732
+ /**
733
+ * Check the notifications are allowed for current type of application
734
+ *
735
+ * @return bool
736
+ */
737
+ public function isNotificationsAllowed()
738
+ {
739
+ return true;
740
+ }
741
  }
app/code/core/Mage/XmlConnect/Helper/Iphone.php CHANGED
@@ -31,7 +31,7 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Helper_Iphone extends Mage_XmlConnect_Helper_Device_Abstract
35
  {
36
  /**
37
  * Submission title length
@@ -45,14 +45,11 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_XmlConnect_Helper_Device_Abstra
45
 
46
  /**
47
  * Country renderer for submission page
48
- *
49
- * @deprecated
50
  */
51
  const SUBMISSION_COUNTRY_RENDERER = 'istore';
52
 
53
  /**
54
  * Country columns for submission page
55
- * @deprecated
56
  */
57
  const SUBMISSION_COUNTRY_COLUMNS = 4;
58
 
@@ -65,6 +62,125 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_XmlConnect_Helper_Device_Abstra
65
  'icon', 'loader_image', 'loader_image_i4', 'logo', 'logo_i4', 'big_logo', 'big_logo_i4'
66
  );
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  /**
69
  * Get default application tabs
70
  *
@@ -114,34 +230,6 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_XmlConnect_Helper_Device_Abstra
114
  return $this->_tabs;
115
  }
116
 
117
- /**
118
- * Default images list
119
- *
120
- * @return array
121
- */
122
- public function getImagesTypesList()
123
- {
124
- return array(
125
- Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_ICON => array(
126
- 'count' => Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_ICON_COUNT,
127
- 'label' => $this->__('Logo in Header'),
128
- 'sortable' => false,
129
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 35, 35)
130
- ),
131
- Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_PORTRAIT_BACKGROUND => array(
132
- 'count' => Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_BACKGROUND_COUNT,
133
- 'label' => $this->__('App Background'),
134
- 'sortable' => false,
135
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 320, 367) . $this->__('Note: Image size affects the performance of your app.') . $this->__('Keep your image size below %s KB for optimal performance.', 75)
136
- ),
137
- Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_PORTRAIT_BANNER => array(
138
- 'count' => Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_BANNER_COUNT,
139
- 'label' => $this->__('Banners on Home Screen'),
140
- 'sortable' => true,
141
- 'sizeTip' => $this->__('Recommended size %spx x %spx.', 320, 230) . $this->__('Note: Image size affects the performance of your app.') . $this->__('Keep your image size below %s KB for optimal performance.', 50)
142
- ));
143
- }
144
-
145
  /**
146
  * Default application configuration
147
  *
@@ -434,15 +522,30 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_XmlConnect_Helper_Device_Abstra
434
  array(
435
  'value' => 'STHeitiK-Light',
436
  'label' => 'STHeitiK-Light',
437
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  }
439
 
440
  /**
441
  * Get list of countries that allowed in Itunes by Apple Store for Iphone
442
- * (we get info from Iphone helper)
443
  *
444
- * @deprecated
445
- * @see $this->getAllowedCountriesArray()
446
  * @return array
447
  */
448
  public function getItunesCountriesArray()
@@ -525,7 +628,6 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_XmlConnect_Helper_Device_Abstra
525
  /**
526
  * Check config for valid values
527
  *
528
- * @deprecated we don't use it since 1.11.1.0
529
  * @param array $native
530
  * @return array
531
  */
@@ -550,12 +652,66 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_XmlConnect_Helper_Device_Abstra
550
  return $errors;
551
  }
552
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
553
  /**
554
  * Check image fields
555
  *
556
  * We set empty value for image field if file was missed in some reason
557
  *
558
- * @deprecated will delete in the next version
559
  * @param array $data
560
  * @return array
561
  */
@@ -588,7 +744,6 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_XmlConnect_Helper_Device_Abstra
588
  /**
589
  * Check required fields of a config for a front-end
590
  *
591
- * @deprecated will delete in the next version
592
  * @throws Mage_Core_Exception
593
  * @param array $data
594
  * @return null
@@ -609,4 +764,14 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_XmlConnect_Helper_Device_Abstra
609
  Mage::throwException(Mage::helper('xmlconnect')->__('App Background image missing.'));
610
  }
611
  }
 
 
 
 
 
 
 
 
 
 
612
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Helper_Iphone extends Mage_Core_Helper_Abstract
35
  {
36
  /**
37
  * Submission title length
45
 
46
  /**
47
  * Country renderer for submission page
 
 
48
  */
49
  const SUBMISSION_COUNTRY_RENDERER = 'istore';
50
 
51
  /**
52
  * Country columns for submission page
 
53
  */
54
  const SUBMISSION_COUNTRY_COLUMNS = 4;
55
 
62
  'icon', 'loader_image', 'loader_image_i4', 'logo', 'logo_i4', 'big_logo', 'big_logo_i4'
63
  );
64
 
65
+ /**
66
+ * List of coutries that allowed in Ituens by Apple Store
67
+ *
68
+ * array(
69
+ * 'country name' => 'country id at directory model'
70
+ * )
71
+ *
72
+ * @var array
73
+ */
74
+ protected $_allowedCountries = array(
75
+ 'Argentina' => 'AR',
76
+ 'Armenia' => 'AM',
77
+ 'Australia' => 'AU',
78
+ 'Austria' => 'AT',
79
+ 'Belgium' => 'BE',
80
+ 'Botswana' => 'BW',
81
+ 'Brazil' => 'BR',
82
+ 'Bulgaria' => 'BG',
83
+ 'Canada' => 'CA',
84
+ 'Chile' => 'CL',
85
+ 'China' => 'CN',
86
+ 'Colombia' => 'CO',
87
+ 'Costa Rica' => 'CR',
88
+ 'Croatia' => 'HR',
89
+ 'Czech Republic' => 'CZ',
90
+ 'Denmark' => 'DK',
91
+ 'Dominican Republic' => 'DO',
92
+ 'Ecuador' => 'EC',
93
+ 'Egypt' => 'EG',
94
+ 'El Salvador' => 'SV',
95
+ 'Estonia' => 'EE',
96
+ 'Finland' => 'FI',
97
+ 'France' => 'FR',
98
+ 'Germany' => 'DE',
99
+ 'Greece' => 'GR',
100
+ 'Guatemala' => 'GT',
101
+ 'Honduras' => 'HN',
102
+ 'Hong Kong SAR China' => 'HK',
103
+ 'Hungary' => 'HU',
104
+ 'India' => 'IN',
105
+ 'Indonesia' => 'ID',
106
+ 'Ireland' => 'IE',
107
+ 'Israel' => 'IL',
108
+ 'Italy' => 'IT',
109
+ 'Jamaica' => 'JM',
110
+ 'Japan' => 'JP',
111
+ 'Jordan' => 'JO',
112
+ 'Kazakstan' => 'KZ',
113
+ 'Kenya' => 'KE',
114
+ 'South Korea' => 'KR',
115
+ 'Kuwait' => 'KW',
116
+ 'Latvia' => 'LV',
117
+ 'Lebanon' => 'LB',
118
+ 'Lithuania' => 'LT',
119
+ 'Luxembourg' => 'LU',
120
+ 'Macau SAR China' => 'MO',
121
+ 'Macedonia' => 'MK',
122
+ 'Madagascar' => 'MG',
123
+ 'Malaysia' => 'MY',
124
+ 'Mali' => 'ML',
125
+ 'Malta' => 'MT',
126
+ 'Mauritius' => 'MU',
127
+ 'Mexico' => 'MX',
128
+ 'Moldova' => 'MD',
129
+ 'Netherlands' => 'NL',
130
+ 'New Zealand' => 'NZ',
131
+ 'Nicaragua' => 'NI',
132
+ 'Niger' => 'NE',
133
+ 'Norway' => 'NO',
134
+ 'Pakistan' => 'PK',
135
+ 'Panama' => 'PA',
136
+ 'Paraguay' => 'PY',
137
+ 'Peru' => 'PE',
138
+ 'Philippines' => 'PH',
139
+ 'Poland' => 'PL',
140
+ 'Portugal' => 'PT',
141
+ 'Qatar' => 'QA',
142
+ 'Romania' => 'RO',
143
+ 'Russia' => 'RU',
144
+ 'Saudi Arabia' => 'SA',
145
+ 'Senegal' => 'SN',
146
+ 'Singapore' => 'SG',
147
+ 'Slovakia' => 'SK',
148
+ 'Slovenia' => 'SI',
149
+ 'South Africa' => 'ZA',
150
+ 'Spain' => 'ES',
151
+ 'Sri Lanka' => 'LK',
152
+ 'Sweden' => 'SE',
153
+ 'Switzerland' => 'CH',
154
+ 'Taiwan' => 'TW',
155
+ 'Thailand' => 'TH',
156
+ 'Tunisia' => 'TN',
157
+ 'Turkey' => 'TR',
158
+ 'Uganda' => 'UG',
159
+ 'United Arab Emirates' => 'AE',
160
+ 'United Kingdom' => 'GB',
161
+ 'United States' => 'US',
162
+ 'Uruguay' => 'UY',
163
+ 'Venezuela' => 'VE',
164
+ 'Vietnam' => 'VN',
165
+ );
166
+
167
+ /**
168
+ * Country field renderer
169
+ *
170
+ * @var Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Istore
171
+ */
172
+ protected $_countryRenderer = null;
173
+
174
+ /**
175
+ * Get submit images that are required for application submit
176
+ *
177
+ * @return array
178
+ */
179
+ public function getSubmitImages()
180
+ {
181
+ return $this->_imageIds;
182
+ }
183
+
184
  /**
185
  * Get default application tabs
186
  *
230
  return $this->_tabs;
231
  }
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  /**
234
  * Default application configuration
235
  *
522
  array(
523
  'value' => 'STHeitiK-Light',
524
  'label' => 'STHeitiK-Light',
525
+ ),
526
+ );
527
+ }
528
+
529
+ /**
530
+ * List of allowed font sizes for iPhone application
531
+ *
532
+ * @return array
533
+ */
534
+ public function getFontSizes()
535
+ {
536
+ $result = array();
537
+ for ($i = 6; $i < 32; $i++) {
538
+ $result[] = array(
539
+ 'value' => $i,
540
+ 'label' => $i . ' pt',
541
+ );
542
+ }
543
+ return $result;
544
  }
545
 
546
  /**
547
  * Get list of countries that allowed in Itunes by Apple Store for Iphone
 
548
  *
 
 
549
  * @return array
550
  */
551
  public function getItunesCountriesArray()
628
  /**
629
  * Check config for valid values
630
  *
 
631
  * @param array $native
632
  * @return array
633
  */
652
  return $errors;
653
  }
654
 
655
+ /**
656
+ * Get renderer for submission country
657
+ *
658
+ * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Istore
659
+ */
660
+ public function getCountryRenderer()
661
+ {
662
+ if (empty($this->_countryRenderer)) {
663
+ $renderer = 'xmlconnect/adminhtml_mobile_submission_renderer_country_'
664
+ . self::SUBMISSION_COUNTRY_RENDERER;
665
+ $this->_countryRenderer = Mage::app()->getLayout()->createBlock($renderer);
666
+ }
667
+ return $this->_countryRenderer;
668
+ }
669
+
670
+ /**
671
+ * Get label for submission country
672
+ *
673
+ * @return string
674
+ */
675
+ public function getCountryLabel()
676
+ {
677
+ return Mage::helper('xmlconnect')->__('App Stores');
678
+ }
679
+
680
+ /**
681
+ * Get columns for submission country
682
+ *
683
+ * @return int
684
+ */
685
+ public function getCountryColumns()
686
+ {
687
+ return self::SUBMISSION_COUNTRY_COLUMNS;
688
+ }
689
+
690
+ /**
691
+ * Get placement of Country Names for submission country
692
+ *
693
+ * @return bool
694
+ */
695
+ public function isCountryNamePlaceLeft()
696
+ {
697
+ return true;
698
+ }
699
+
700
+ /**
701
+ * Get class name for submission country
702
+ *
703
+ * @return string
704
+ */
705
+ public function getCountryClass()
706
+ {
707
+ return self::SUBMISSION_COUNTRY_RENDERER . ' stripy';
708
+ }
709
+
710
  /**
711
  * Check image fields
712
  *
713
  * We set empty value for image field if file was missed in some reason
714
  *
 
715
  * @param array $data
716
  * @return array
717
  */
744
  /**
745
  * Check required fields of a config for a front-end
746
  *
 
747
  * @throws Mage_Core_Exception
748
  * @param array $data
749
  * @return null
764
  Mage::throwException(Mage::helper('xmlconnect')->__('App Background image missing.'));
765
  }
766
  }
767
+
768
+ /**
769
+ * Check the notifications are allowed for current type of application
770
+ *
771
+ * @return bool
772
+ */
773
+ public function isNotificationsAllowed()
774
+ {
775
+ return true;
776
+ }
777
  }
app/code/core/Mage/XmlConnect/Helper/OfflineCatalog.php DELETED
@@ -1,307 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect offline catalog helper
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Helper_OfflineCatalog extends Mage_Core_Helper_Abstract
35
- {
36
- /**
37
- * Result folder
38
- */
39
- const RESULT_FOLDER = 'offline_catalog';
40
-
41
- /**
42
- * Map file
43
- */
44
- const MAP_FILE = '_storage.dict';
45
-
46
- /**
47
- * Export url
48
- */
49
- const EXPORT_URL = 'xmlconnect/offlineCatalog/index/key/';
50
-
51
- /**
52
- * Varien file IO
53
- *
54
- * @var null|Varien_Io_File
55
- */
56
- protected $_fileIo;
57
-
58
- /**
59
- * Xml object
60
- *
61
- * @var null|Mage_XmlConnect_Model_Simplexml_Element
62
- */
63
- protected $_xmlObject;
64
-
65
- /**
66
- * Layout model
67
- *
68
- * @var null|Mage_Core_Model_Layout
69
- */
70
- protected $_layout;
71
-
72
- /**
73
- * Result dir
74
- *
75
- * @var null|string
76
- */
77
- protected $_resultDir;
78
-
79
- /**
80
- * Application model
81
- *
82
- * @var null|Mage_XmlConnect_Model_Application
83
- */
84
- protected $_appModel;
85
-
86
- /**
87
- * Prepare result directory
88
- *
89
- * @return Mage_XmlConnect_Helper_OfflineCatalog
90
- */
91
- public function prepareResultDirectory()
92
- {
93
- $fileModel = $this->_getFileIo();
94
- $resultDir = $this->_getResultDir();
95
- $fileModel->rmdirRecursive($resultDir);
96
- $fileModel->mkdir($resultDir);
97
- return $this;
98
- }
99
-
100
- /**
101
- * Get file IO
102
- *
103
- * @return Varien_Io_File
104
- */
105
- protected function _getFileIo()
106
- {
107
- if ($this->_fileIo === null) {
108
- $this->_fileIo = new Varien_Io_File();
109
- }
110
- return $this->_fileIo;
111
- }
112
-
113
- /**
114
- * Get handles
115
- *
116
- * @return array
117
- */
118
- protected function _getHandles()
119
- {
120
- return array('xmlconnect_configuration_index', 'xmlconnect_catalog_categorydetails',
121
- 'xmlconnect_catalog_productview', 'xmlconnect_homebanners_index', 'xmlconnect_index_index',
122
- 'xmlconnect_catalog_productgallery', 'xmlconnect_catalog_productreviews'
123
- );
124
- }
125
-
126
- /**
127
- * Add offline catalog data
128
- *
129
- * @param string $urlPath
130
- * @param string $output
131
- * @return Mage_XmlConnect_Helper_OfflineCatalog
132
- */
133
- public function addOfflineCatalogData($urlPath, $output)
134
- {
135
- $xmlObj = $this->_getXmlObject();
136
- $fileName = uniqid() . '-' . sha1($output) . '.cache';
137
-
138
- $this->saveCacheFile($fileName, $output);
139
- $xmlObj->addCustomChild('key', $urlPath);
140
- $xmlObj->addCustomChild('string', $fileName);
141
- return $this;
142
- }
143
-
144
- /**
145
- * Save cache file
146
- *
147
- * @param string $fileName
148
- * @param string $output
149
- * @return Mage_XmlConnect_Helper_OfflineCatalog
150
- */
151
- public function saveCacheFile($fileName, $output)
152
- {
153
- $filePath = $this->_getResultDir() . DS . $fileName;
154
- $this->_getFileIo()->open(array('path' => $this->_getResultDir()));
155
- $this->_getFileIo()->write($filePath, $output);
156
- return $this;
157
- }
158
-
159
- /**
160
- * Get result directory path
161
- *
162
- * @return string
163
- */
164
- protected function _getResultDir()
165
- {
166
- if ($this->_resultDir === null) {
167
- $this->_resultDir = Mage::getBaseDir('var') . DS . self::RESULT_FOLDER;
168
- }
169
- return $this->_resultDir;
170
- }
171
-
172
- /**
173
- * Get xml object
174
- *
175
- * @return Mage_XmlConnect_Model_Simplexml_Element
176
- */
177
- protected function _getXmlObject()
178
- {
179
- if ($this->_xmlObject === null) {
180
- $this->_xmlObject = Mage::getModel('xmlconnect/simplexml_element', '<dict></dict>');
181
- }
182
- return $this->_xmlObject;
183
- }
184
-
185
- /**
186
- * Get block
187
- *
188
- * @param string $blockName
189
- * @return Mage_Core_Block_Abstract
190
- */
191
- public function getBlock($blockName)
192
- {
193
- /** @var $layout Mage_Core_Model_Layouts */
194
- $this->_prepareLayout();
195
- $this->_layout->getUpdate()->load($this->_getHandles());
196
- $this->_layout->generateXml()->generateBlocks();
197
- $block = $this->_layout->getBlock($blockName);
198
- $this->unsetLayout();
199
- return $block;
200
- }
201
-
202
- /**
203
- * Prepare layout
204
- *
205
- * @return Mage_XmlConnect_Helper_OfflineCatalog
206
- */
207
- protected function _prepareLayout()
208
- {
209
- $this->_layout = Mage::getModel('core/layout');
210
- return $this;
211
- }
212
-
213
- /**
214
- * Unset layout
215
- *
216
- * Only for PHP 5 >= 5.3.0
217
- *
218
- * @return Mage_XmlConnect_Helper_OfflineCatalog
219
- */
220
- protected function unsetLayout()
221
- {
222
- /** @TODO Add support for previous PHP version */
223
- unset($this->_layout);
224
- gc_collect_cycles();
225
- return $this;
226
- }
227
-
228
- /**
229
- * Get current device model
230
- *
231
- * @return Mage_XmlConnect_Model_Application|null
232
- */
233
- public function getCurrentDeviceModel()
234
- {
235
- return $this->_appModel;
236
- }
237
-
238
- /**
239
- * Set current device model
240
- *
241
- * @param string $key
242
- * @return bool
243
- */
244
- public function setCurrentDeviceModel($key)
245
- {
246
- $appCode = $this->base64UrlDecode($key);
247
- $appModel = Mage::getModel('xmlConnect/application')->loadByCode($appCode);
248
- if (!$appModel->getId()) {
249
- return false;
250
- }
251
- Mage::register('current_app', $appModel);
252
- $this->_appModel = $appModel;
253
- return true;
254
- }
255
-
256
- /**
257
- * Base64 url encode
258
- *
259
- * @param string $data
260
- * @return string
261
- */
262
- public function base64UrlEncode($data)
263
- {
264
- /** @var $decryptHelper Mage_Core_Helper_Data */
265
- $decryptHelper = Mage::helper('core/data');
266
- return strtr($decryptHelper->encrypt($data), '+/=', '-_,');
267
- }
268
-
269
- /**
270
- * Base64 url dencode
271
- *
272
- * @param string $data
273
- * @return string
274
- */
275
- public function base64UrlDecode($data)
276
- {
277
- /** @var $decryptHelper Mage_Core_Helper_Data */
278
- $decryptHelper = Mage::helper('core/data');
279
- return $decryptHelper->decrypt(strtr($data, '-_,', '+/='));
280
- }
281
-
282
- /**
283
- * Render xml object
284
- *
285
- * @return Mage_XmlConnect_Helper_OfflineCatalog
286
- */
287
- public function renderXmlObject()
288
- {
289
- /** @var $result Mage_XmlConnect_Model_Simplexml_Element */
290
- $result = Mage::getModel('xmlconnect/simplexml_element', '<plist version="1.0"></plist>');
291
- $result->appendChild($this->_getXmlObject())->asNiceXml($this->_getResultDir() . DS . self::MAP_FILE);
292
- return $this;
293
- }
294
-
295
- /**
296
- * Get export url
297
- *
298
- * @return string
299
- */
300
- public function getExportUrl()
301
- {
302
- $app = Mage::helper('xmlconnect')->getApplication();
303
- $secretKey = array('key' => $this->base64UrlEncode($app->getCode()));
304
- $storeUrl = Mage::getModel('core/store')->load($app->getStoreId())->getUrl(self::EXPORT_URL, $secretKey);
305
- return $storeUrl;
306
- }
307
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Helper/Theme.php CHANGED
@@ -171,16 +171,15 @@ EOT;
171
  public function getAllThemes($flushCache = false)
172
  {
173
  if (!$this->_themeArray || $flushCache) {
 
 
 
 
 
 
174
  try {
175
- $saveLibxmlErrors = libxml_use_internal_errors(true);
176
- $this->_themeArray = array();
177
- $themeDir = $this->getMediaThemePath();
178
-
179
- $ioFile = new Varien_Io_File();
180
- $ioFile->checkAndCreateFolder($themeDir);
181
- $ioFile->open(array('path' => $themeDir));
182
  $fileList = $ioFile->ls(Varien_Io_File::GREP_FILES);
183
- if (!count($fileList) || !$this->_checkDefaultThemes($fileList)) {
184
  $this->resetTheme();
185
  $this->getAllThemes(true);
186
  }
@@ -200,46 +199,6 @@ EOT;
200
  return $this->_themeArray;
201
  }
202
 
203
- /**
204
- * Check are default themes files present in media folder or not
205
- *
206
- * @param array $fileList
207
- * @return bool
208
- */
209
- protected function _checkDefaultThemes($fileList)
210
- {
211
- $cacheKey = 'MAGENTO_MOBILE_DEFAULT_THEMES_CACHE_KEY';
212
- $cache = Mage::app()->loadCache($cacheKey);
213
- if (Mage::app()->useCache('config') && $cache) {
214
- $defaultFiles = unserialize($cache);
215
- } else {
216
- $ioFile = new Varien_Io_File();
217
- $ioFile->open(array('path' => $this->_getDefaultThemePath()));
218
- $fileDefaultList = $ioFile->ls(Varien_Io_File::GREP_FILES);
219
- $defaultFiles = array();
220
- foreach ($fileDefaultList as $defaultFileData) {
221
- if ('xml' != $defaultFileData['filetype']) {
222
- continue;
223
- }
224
- $defaultFiles[] = $defaultFileData['text'];
225
- }
226
- if (Mage::app()->useCache('config')) {
227
- Mage::app()->saveCache(serialize($defaultFiles), $cacheKey, array('config'));
228
- }
229
- }
230
-
231
- if (empty($defaultFiles)) {
232
- Mage::throwException($this->__('Default themes are missed.'));
233
- }
234
- $matches = 0;
235
- foreach ($fileList as $fileData) {
236
- if (in_array($fileData['text'], $defaultFiles)) {
237
- ++$matches;
238
- }
239
- }
240
- return $matches == count($defaultFiles);
241
- }
242
-
243
  /**
244
  * Reads default theme directory
245
  *
@@ -423,7 +382,7 @@ EOT;
423
  $result = false;
424
  $ioFile = new Varien_Io_File();
425
  $ioFile->cd($this->getMediaThemePath());
426
- $themeFile = basename($themeId . '.xml');
427
  if ($ioFile->fileExists($themeFile)) {
428
  $result = $ioFile->rm($themeFile);
429
  }
171
  public function getAllThemes($flushCache = false)
172
  {
173
  if (!$this->_themeArray || $flushCache) {
174
+ $saveLibxmlErrors = libxml_use_internal_errors(true);
175
+ $this->_themeArray = array();
176
+ $themeDir = $this->getMediaThemePath();
177
+ $ioFile = new Varien_Io_File();
178
+ $ioFile->checkAndCreateFolder($themeDir);
179
+ $ioFile->open(array('path' => $themeDir));
180
  try {
 
 
 
 
 
 
 
181
  $fileList = $ioFile->ls(Varien_Io_File::GREP_FILES);
182
+ if (!count($fileList)) {
183
  $this->resetTheme();
184
  $this->getAllThemes(true);
185
  }
199
  return $this->_themeArray;
200
  }
201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  /**
203
  * Reads default theme directory
204
  *
382
  $result = false;
383
  $ioFile = new Varien_Io_File();
384
  $ioFile->cd($this->getMediaThemePath());
385
+ $themeFile = $themeId . '.xml';
386
  if ($ioFile->fileExists($themeFile)) {
387
  $result = $ioFile->rm($themeFile);
388
  }
app/code/core/Mage/XmlConnect/Helper/Translate.php DELETED
@@ -1,514 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect application localization helper
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Helper_Translate extends Mage_Core_Helper_Abstract
35
- {
36
- /**
37
- * Hash of localization
38
- *
39
- * @var string
40
- */
41
- protected $_hash;
42
-
43
- /**
44
- * Get hash localization
45
- *
46
- * @return string
47
- */
48
- public function getHash()
49
- {
50
- if (!$this->_hash) {
51
- $this->_hash = sha1(serialize($this->getLocalizationArray()));
52
- }
53
- return $this->_hash;
54
- }
55
-
56
- /**
57
- * Get application localization strings array
58
- *
59
- * @return array
60
- */
61
- public function getLocalizationArray()
62
- {
63
- return array(
64
- 'About' => $this->__('About'),
65
- 'Account' => $this->__('Account'),
66
- 'AccountInfo' => $this->__('Account Information'),
67
- 'AccountMyDownloadableProducts' => $this->__('My Downloadable Products'),
68
- 'AccountMyDownloadableProductsDate' => $this->__('Date'),
69
- 'AccountMyDownloadableProductsOpen' => $this->__('Open'),
70
- 'AccountMyDownloadableProductsOrder' => $this->__('Order'),
71
- 'AccountMyDownloadableProductsRemainingDownloads' => $this->__('Remaining downloads'),
72
- 'AccountMyDownloadableProductsStatus' => $this->__('Status'),
73
- 'AccountSettings' => $this->__('Account Settings'),
74
- 'AccountSettingsCancel' => $this->__('Home'),
75
- 'Add' => $this->__('Add'),
76
- 'AddAddressFromContacts' => $this->__('Add Address from Contacts'),
77
- 'AddBillingAddressText' => $this->__('Add a billing address'),
78
- 'AddCustomText' => $this->__('Add Custom'),
79
- 'AddFilterTitle' => $this->__('Filter'),
80
- 'AddNewAddress' => $this->__('Add New Address'),
81
- 'AddNewEntry' => $this->__('Add'),
82
- 'AddShippingAddressText' => $this->__('Add a shipping address'),
83
- 'AddToCart' => $this->__('Add to Cart'),
84
- 'AddToCartTitle' => $this->__('Add to Cart'),
85
- 'AddToWishlistTitle' => $this->__('Add to Wishlist'),
86
- 'AddingProductToCartProgressTitle' => $this->__('Adding Product to Cart...'),
87
- 'AddingProductToWishListProgressTitle' => $this->__('Adding Product to WishList...'),
88
- 'AdditionalInfo' => $this->__('Additional Info'),
89
- 'AddressBook' => $this->__('Address Book'),
90
- 'AddressBookIsEmpty' => $this->__('Address book is empty'),
91
- 'AddressBookUpdatedMessage' => $this->__('Address Book Updated'),
92
- 'AddressInfo' => $this->__('Address Info'),
93
- 'AgreementsButtonTitle' => $this->__('Read the Terms and Conditions'),
94
- 'AgreementsCheckboxTitle' => $this->__('I agree to the Terms and Conditions'),
95
- 'AgreementsDescription' => $this->__('You must read and agree to the Terms and Conditions before placing your order.'),
96
- 'AllImages' => $this->__('All Images'),
97
- 'AlsoLikeLbl' => $this->__('You may also like'),
98
- 'Amount' => $this->__('Amount'),
99
- 'AmountIn' => $this->__('Amount in %@'),
100
- 'Amounts' => $this->__('Amounts'),
101
- 'AppIdNotActivated' => $this->__('The application is currently inactive.\nPlease try again later.'),
102
- 'ApplicationCode' => $this->__('App code'),
103
- 'AppliedFiltersLabel' => $this->__('FILTERS APPLIED'),
104
- 'Apply' => $this->__('Apply'),
105
- 'ApplyingCouponProgressTitle' => $this->__('Applying Coupon Code'),
106
- 'ApplyingGiftCartProgressTitle' => $this->__('Applying Gift Card %@'),
107
- 'AsGuestText' => $this->__('as Guest'),
108
- 'AsLowAsExcludingTaxLabel' => $this->__('As low as excl. tax'),
109
- 'AsLowAsIncludingTaxLabel' => $this->__('As low as incl. tax'),
110
- 'AsLowAsLabel' => $this->__('As low as'),
111
- 'AuthenticationToSocialClientFailedAlertMessage' => $this->__('Authentication to %@ did failed...'),
112
- 'AverageRating' => $this->__('Average Rating'),
113
- 'Back' => $this->__('Back'),
114
- 'BackFromInfo' => $this->__('Back'),
115
- 'BiggerThanMaxMessage' => $this->__('The value should not be greater than %.2f!'),
116
- 'BillingAddressTitle' => $this->__('Billing address'),
117
- 'BillingCheckout' => $this->__('Billing'),
118
- 'BundleProductsSectionTitle' => $this->__('Bundle Products'),
119
- 'BuyMoreAndSave' => $this->__('Buy More & Save'),
120
- 'Cancel' => $this->__('Cancel'),
121
- 'CancelButtonTitle' => $this->__('Cancel'),
122
- 'CancelingPayPalMECLProgressTitle' => $this->__('Canceling PayPal ...'),
123
- 'Cart' => $this->__('Shopping Cart'),
124
- 'CartBtn' => $this->__('Cart'),
125
- 'CartIsEmpty' => $this->__('The cart is empty'),
126
- 'CartRegisteredMessage' => $this->__('Offline cart stored on server'),
127
- 'CartRegisteredTitle' => $this->__(''),
128
- 'CartRegistrationFailedMessage' => $this->__('Storage of offline cart on server failed. Please retry later'),
129
- 'CartRegistrationFailedTitle' => $this->__('Error'),
130
- 'CartUpdatedMessageTitle' => $this->__('Cart Updated'),
131
- 'CheckGiftCardLabel' => $this->__('Check Gift Card'),
132
- 'CheckingCartProgressTitle' => $this->__('Checking Gift Card %@'),
133
- 'CheckoutAsGuestButtonTitle' => $this->__('Checkout as Guest'),
134
- 'CheckoutButtonFullTitle' => $this->__('Proceed to Checkout'),
135
- 'CheckoutButtonTitle' => $this->__('Checkout'),
136
- 'CheckoutInitializationProgressTitle' => $this->__('Checkout initialization...'),
137
- 'CheckoutInitializedText' => $this->__('Checkout initialized!'),
138
- 'CheckoutTitle' => $this->__('Checkout'),
139
- 'ChooseAmount' => $this->__('Choose amount'),
140
- 'City' => $this->__('City'),
141
- 'Clear' => $this->__('Clear'),
142
- 'Close' => $this->__('Close'),
143
- 'CommitCartChangesAlertText' => $this->__('You have uncommitted actions. Commit?'),
144
- 'CommittingUpdatesProgressTitle' => $this->__('Commiting updates...'),
145
- 'ConfigurationLoadingError' => $this->__('There is an error in loading an app\'s configuration'),
146
- 'ConfigureTitle' => $this->__('Select Options'),
147
- 'Connecting' => $this->__('Connecting'),
148
- 'ConnectionErrorMessage' => $this->__('Connection Error\nWe\'re sorry. The app is experiencing connection problems. The app requires a network connection to operate.'),
149
- 'ConnectionLostMessage' => $this->__('Connection Error\nWe\'re sorry. The app is experiencing connection problems. The app requires a network connection to operate.'),
150
- 'ContactsAreEmpty' => $this->__('ContactsAreEmpty'),
151
- 'Continue' => $this->__('Continue'),
152
- 'Copyright' => $this->__('Copyright: Magento (c) 2010'),
153
- 'Country' => $this->__('Country'),
154
- 'CountrySelect' => $this->__('Countries'),
155
- 'CreateAccount' => $this->__('Create an Account'),
156
- 'CreateAccountButtonTitle' => $this->__('Create Account'),
157
- 'CreateAccountLabel' => $this->__('Create Account'),
158
- 'CreateAccountSectionHeader' => $this->__('New to Our Store?'),
159
- 'CreateAnAccountLabel' => $this->__('Create an Account'),
160
- 'CrossSellsText' => $this->__('Cross Sells'),
161
- 'CrossellTitle' => $this->__('You may also like'),
162
- 'CustomAmount' => $this->__('Custom amount'),
163
- 'DateText' => $this->__('Date'),
164
- 'DateTitle' => $this->__('Date:'),
165
- 'Delete' => $this->__('Delete'),
166
- 'DeleteItemMessage' => $this->__('Are you sure you want to remove this item?'),
167
- 'DeleteRecordButtonTitle' => $this->__('Delete'),
168
- 'Description' => $this->__('Description'),
169
- 'DiscountButtonTitle' => $this->__('Apply'),
170
- 'DiscountLabel' => $this->__('Discount:'),
171
- 'DiscountTextFieldPlaceholder' => $this->__('Enter discount code if any'),
172
- 'DiscoutnButtonTitle' => $this->__('Apply'),
173
- 'DoneTitle' => $this->__('Done'),
174
- 'DownloadableProductLinkSample' => $this->__('Sample'),
175
- 'DownloadableProductsUpdatedMessage' => $this->__('Downloadable Products Updated'),
176
- 'DownloadsLimitTitle' => $this->__('Downloads limit:'),
177
- 'Edit' => $this->__('Edit'),
178
- 'EditAccountButtonTitle' => $this->__('Save'),
179
- 'EditAddressBookRecord' => $this->__('Edit Address'),
180
- 'EditFilterTitle' => $this->__('Edit filter'),
181
- 'EditMailList' => $this->__('Edit Mail List'),
182
- 'EditNote' => $this->__('Edit note'),
183
- 'Email' => $this->__('E-mail'),
184
- 'EmailCopyLabel' => $this->__('Cc:'),
185
- 'EmailCountMaxExceed' => $this->__('Too many recipients have been set. Max amount of recipients is:'),
186
- 'EmailLabel' => $this->__('To:'),
187
- 'EmailThemeLabel' => $this->__('Subject:'),
188
- 'EmptyCategoryMessage' => $this->__('Sorry, there are no items in this category.'),
189
- 'EmptyDiscount' => $this->__('Enter discount code first.'),
190
- 'EmptyDiscountCodeAlertMessage' => $this->__('Discount code is empty'),
191
- 'EmptyEmails' => $this->__('Please enter at least one email recipient'),
192
- 'EmptyGalleryMessage' => $this->__('This product has no images.'),
193
- 'EmptyGiftCardValueMessage' => $this->__('Please, specify gift card amount!'),
194
- 'EmptyMyDownloadableViewMessage' => $this->__('List of downloadable products is empty'),
195
- 'EmptyStoreCreditHistoryMessage' => $this->__('There is no store credit history!'),
196
- 'EmptyViewMessage' => $this->__('There are no items here'),
197
- 'EmptyWishlistViewMessage' => $this->__('Wishlist is empty.'),
198
- 'EnterEmailText' => $this->__('Enter e-mail'),
199
- 'EnterGiftCardPromo' => $this->__('Enter giftcard promo code here'),
200
- 'EnterNameText' => $this->__('Enter Name'),
201
- 'EnterText' => $this->__('Enter text'),
202
- 'Error' => $this->__('Error'),
203
- 'ErrorEmailMessage1' => $this->__('Email is not specified'),
204
- 'ErrorEmailMessage2' => $this->__('Email is not correct'),
205
- 'ErrorLoadingConfigurationFormat' => $this->__('Error Loading Configuration Format'),
206
- 'ErrorPasswordMessage1' => $this->__('Password is not specified'),
207
- 'ErrorRetrievingData' => $this->__('There is an error in retrieving the data. Please try again later'),
208
- 'ExcludingTaxLabel' => $this->__(''),
209
- 'Facebook' => $this->__('Facebook'),
210
- 'FacebookPostFailedMessage' => $this->__('Facebook post failed...'),
211
- 'FacebookPostSuccess' => $this->__('Successfully posted to Facebook'),
212
- 'FieldRequiredToBeFilledDialogMessage' => $this->__('The %s field should be filled.'),
213
- 'Filters' => $this->__('Filters'),
214
- 'FixedAmounts' => $this->__('Fixed amounts'),
215
- 'ForgotPassword' => $this->__('Forgot Password'),
216
- 'ForgotPasswordButtonTitle' => $this->__('Forgot Password?'),
217
- 'ForgotPasswordSectionHeader' => $this->__('Forgot your password?'),
218
- 'Form' => $this->__('Form'),
219
- 'FormCellTitle' => $this->__('Form'),
220
- 'FromExcludingTaxLabel' => $this->__('From excl. tax'),
221
- 'FromIncludingTaxLabel' => $this->__('From incl. tax'),
222
- 'FullDescription' => $this->__('Full Description'),
223
- 'FunctionalityIsDisabledInOfflineModeAlertMessage' => $this->__('This functionality disabled in offline mode'),
224
- 'Gallery' => $this->__('Gallery'),
225
- 'GetMoreElements' => $this->__('Load more items'),
226
- 'GettingMoreElements' => $this->__('Loading more items...'),
227
- 'GiftCardCodeCheck' => $this->__('Check'),
228
- 'GiftCardCodeRedeem' => $this->__('Redeem'),
229
- 'GiftCardPromo' => $this->__('Giftcard promo code'),
230
- 'GiftCartRedeemedMessageText' => $this->__('Check Gift Card Promo Redeemed'),
231
- 'Giftcards' => $this->__('Enter the gift card code'),
232
- 'GuestLogInMessage' => $this->__('Checkout as Guest or Register'),
233
- 'Home' => $this->__('Home'),
234
- 'IAgree' => $this->__('I Agree'),
235
- 'InStock' => $this->__('In Stock'),
236
- 'IncludingTaxLabel' => $this->__('Incl. tax'),
237
- 'IncorrectDecimalValueDialogMessage' => $this->__('You have entered an incorrect decimal value in the custom amount field. Provide a valid value.'),
238
- 'InitializationPayPalMECLFailedMessage' => $this->__('Initialization of the PayPal checkout failed!'),
239
- 'InitializationPayPalMECLProgressTitle' => $this->__('Initialization PayPal ...'),
240
- 'InvalidEmailDialogMessage' => $this->__('Email address you provided is not valid. Please provide a valid one.'),
241
- 'InvalidResponse' => $this->__('The server responded with invalid data.'),
242
- 'Item' => $this->__('Item'),
243
- 'ItemOptionsSectionTitle' => $this->__('Item Options'),
244
- 'LastOrders' => $this->__('My Orders'),
245
- 'LastUpdatePullDownText' => $this->__('Last update: %@'),
246
- 'LessThatMinMessage' => $this->__('The value should not be less than %.2f!'),
247
- 'LindedIn' => $this->__('LindedIn'),
248
- 'LinkTitle' => $this->__('Link:'),
249
- 'LinkedIn' => $this->__('LinkedIn'),
250
- 'LinkedInAuthorization' => $this->__('LinkedIn Authorization'),
251
- 'LinkedInAutorization' => $this->__('LinkedIn Autorization'),
252
- 'LinkedInPostSuccess' => $this->__('Successfully posted to Linkedin'),
253
- 'LinkedInTitle' => $this->__('LinkedIn'),
254
- 'LinkedinPostFailedMessage' => $this->__('Linkedin post failed...'),
255
- 'LoadingAccountFormProgressTitle' => $this->__('Loading Account Form...'),
256
- 'LoadingAddressBookProgressTitle' => $this->__('Loading Address Book...'),
257
- 'LoadingAddressFormProgressTitle' => $this->__('Loading Address Form...'),
258
- 'LoadingCMSPageProgtessTitle' => $this->__('Loading CMS page ...'),
259
- 'LoadingCartProgressTitle' => $this->__('Loading Cart...'),
260
- 'LoadingCategoryProgressTitle' => $this->__('Loading category ...'),
261
- 'LoadingDownloadableProductsProgressTitle' => $this->__('Loading My Downloadable Products...'),
262
- 'LoadingGalleryProgressTitle' => $this->__('Loading Gallery...'),
263
- 'LoadingLoginFormProgressTitle' => $this->__('Loading Login Form...'),
264
- 'LoadingMoreItems' => $this->__(''),
265
- 'LoadingOrderDetailsProgressTitle' => $this->__('Loading Order Details'),
266
- 'LoadingOrdersListProgressTitle' => $this->__('Loading Orders List...'),
267
- 'LoadingProductOptionsProgressTitle' => $this->__('Loading Product Options...'),
268
- 'LoadingProductProgressTitle' => $this->__('Loading product ...'),
269
- 'LoadingProductsProgressTitle' => $this->__('Loading Products...'),
270
- 'LoadingProgressTitle' => $this->__('Loading %@...'),
271
- 'LoadingRegistrationFormProgressTitle' => $this->__('Loading Registration Form...'),
272
- 'LoadingRestorePasswordFormProgressTitle' => $this->__('Loading Restore Password Form...'),
273
- 'LoadingShippindPayPalMECLProgressTitle' => $this->__('Loading shipping methods ...'),
274
- 'LoadingStoreCreditProgressTitle' => $this->__('Loading Store Credit...'),
275
- 'LoadingText' => $this->__('Loading...'),
276
- 'LoadingWishListProgressTitle' => $this->__('Loading WishList...'),
277
- 'LoadingWriteReviewFormProgressTitle' => $this->__('Loading Write Review Form...'),
278
- 'LogIn' => $this->__('Log In'),
279
- 'LogInButtonTitle' => $this->__('Log into Account'),
280
- 'LogInEmailLabel' => $this->__('Email'),
281
- 'LogInMessage' => $this->__('You must login first'),
282
- 'LogInMessageTitle' => $this->__('LogInMessageTitle'),
283
- 'LogInPasswordLabel' => $this->__('Password'),
284
- 'LogInSectionHeader' => $this->__('Log into your account'),
285
- 'LogOut' => $this->__('Log Out'),
286
- 'LogOutButtonTitle' => $this->__('Log out Account'),
287
- 'MailToText' => $this->__('To:'),
288
- 'MaxLengthMessage' => $this->__('The max length of the field "%@" is %d!'),
289
- 'Maximum' => $this->__('Maximum: %.2f'),
290
- 'MergeButtonTitle' => $this->__('Merge'),
291
- 'MessageText' => $this->__('Message'),
292
- 'MessageTwitterTooLong' => $this->__('Message too long, please use 140 symbols'),
293
- 'Minimize' => $this->__('Minimize'),
294
- 'Minimum' => $this->__('Minimum: %.2f'),
295
- 'MoreInfo' => $this->__('More Info'),
296
- 'MyAccount' => $this->__('My Account'),
297
- 'NameText' => $this->__('Name'),
298
- 'NewAddressBookRecord' => $this->__('Add New Address'),
299
- 'No' => $this->__('No'),
300
- 'NoInternetConnectionAlertTitle' => $this->__('No internet connection. Retry later ...'),
301
- 'NoLastOrders' => $this->__('You have placed no orders.'),
302
- 'NoProductsFoundAlertTitle' => $this->__('No products found. Please retry with other term'),
303
- 'NoProductsMatchingSelection' => $this->__(''),
304
- 'NoSupportForOrderDetails' => $this->__('Currently, the system does not support the viewing of the order detail.'),
305
- 'NotCorrectField' => $this->__('%@ is not correct'),
306
- 'NotEmail' => $this->__('The following email(s) are either mistyped or have incorrect format. Check them and try again:\n'),
307
- 'NotLoggedInAlertMessage' => $this->__('You are not logged in'),
308
- 'NotZeroCustomValueDialogMessage' => $this->__('The custom amount value should be higher than 0.'),
309
- 'NothingSelected' => $this->__('At least one option should be selected'),
310
- 'Notice' => $this->__('Notice'),
311
- 'OK' => $this->__('OK'),
312
- 'OpenAmountPriceBoundariesText' => $this->__('Minimum %@, maximum %@'),
313
- 'Options' => $this->__('Options'),
314
- 'OptionsTitle' => $this->__('Options'),
315
- 'OrderCanceledAlertMessage' => $this->__('You canceled your order. Touch "Pay with PayPal" to try again.'),
316
- 'OrderCanceledPayPalMECLMessage' => $this->__('Order canceled'),
317
- 'OrderDetailsUpdatedMessage' => $this->__('Order Details Updated'),
318
- 'OrderFailedAlertMessage' => $this->__('Your order failed. Touch "Pay with PayPal" to try again.'),
319
- 'OrderFailedMessage' => $this->__('Order failed'),
320
- 'OrderHeader' => $this->__('Order #'),
321
- 'OrderIDTitle' => $this->__('Order ID:'),
322
- 'OrderInfoTitle' => $this->__('Order Info'),
323
- 'OrderListUpdatedMessage' => $this->__('Order List Updated'),
324
- 'OrderNumberText' => $this->__('Order Number'),
325
- 'OrderReviewCheckout' => $this->__('Order Review'),
326
- 'OrderReviewScreenTitle' => $this->__('Order Review'),
327
- 'OrderedItemsText' => $this->__('Ordered Items'),
328
- 'OtherAmount' => $this->__('Other amount'),
329
- 'OutOfStock' => $this->__('Out of Stock'),
330
- 'ParsingError' => $this->__('Error while reading remote data'),
331
- 'PasswordLength' => $this->__('The minimum password length is 6'),
332
- 'PayPalCheckout' => $this->__('PayPal Checkout'),
333
- 'PayPalText' => $this->__('PayPal'),
334
- 'PaymentBridgeServiceErrorMessage' => $this->__('Unknown Payment Bridge Error'),
335
- 'PaymentMethodSectionTitle' => $this->__('Payment Method'),
336
- 'PaymentMethodSelectionWarning' => $this->__('Please select payment method to cover a quote'),
337
- 'PaymentMethodTitle' => $this->__('Payment method'),
338
- 'PaymentMethodsCheckout' => $this->__('Payment Information'),
339
- 'PlaceOrder' => $this->__('Place Order'),
340
- 'PlacingOrderProgressTitle' => $this->__('Placing order ...'),
341
- 'PostToLinkedIn' => $this->__('Share on LinkedIn'),
342
- 'PostToTwitter' => $this->__('Share on Twitter'),
343
- 'PostToWallProduct' => $this->__('Post this product to your wall'),
344
- 'PostingEmailProgressTitle' => $this->__('Posting to e-mails'),
345
- 'Price' => $this->__('Price'),
346
- 'PriceExcludingTax' => $this->__('Price excluding tax'),
347
- 'PriceIncludingTax' => $this->__('Price including tax'),
348
- 'Product' => $this->__('Product'),
349
- 'ProductAddedAlertMessage' => $this->__('Product succesfully added to cart'),
350
- 'ProductAddedAlertTitle' => $this->__('Product added'),
351
- 'ProductAddedToCartLabelTitle' => $this->__('Product Added to Cart'),
352
- 'ProductAddedToWishlistLabelTitle' => $this->__('Product Added to Wishlist'),
353
- 'ProductGalleryUpdatedMessage' => $this->__('Product Gallery Updated'),
354
- 'ProductOptionsUpdatedMessage' => $this->__('Product Options Updated'),
355
- 'ProductOutOfStockAlertMessage' => $this->__('Product is out of stock'),
356
- 'ProductOutOfStockAlertTitle' => $this->__(''),
357
- 'ProductPaymentCompleteLabelTitle' => $this->__('Success'),
358
- 'ProductPaymentCompleteleLabelTitle' => $this->__('Success'),
359
- 'ProductRemovedFromWishlistLabelTitle' => $this->__('Product Removed From Wishlist'),
360
- 'ProductReviewsUpdatedMessage' => $this->__('Product Reviews Updated'),
361
- 'ProductUpdatedMessage' => $this->__('Product Updated'),
362
- 'ProductsText' => $this->__('Products'),
363
- 'PullDownToUpdatePullDownText' => $this->__('Pull Down To Update..'),
364
- 'Qty' => $this->__('Qty'),
365
- 'Quantity' => $this->__('Quantity'),
366
- 'QuantityTitle' => $this->__('Qty:'),
367
- 'RatingReviewsNone' => $this->__('No Ratings'),
368
- 'RatingReviewsTitle' => $this->__('Ratings and Reviews'),
369
- 'RecoverPasswordButtonTitle' => $this->__('Recover'),
370
- 'RedemingGiftCartProgressTitle' => $this->__('Redeeming Gift Card %@'),
371
- 'RegionFieldLabel' => $this->__('State/Province'),
372
- 'RegionSelect' => $this->__('Regions'),
373
- 'RegisterText' => $this->__('Register'),
374
- 'RegisteringOfflineCartProgressTitle' => $this->__('Registering cart ...'),
375
- 'RegisteringUserProgressTitle' => $this->__('Registering user ...'),
376
- 'RegularLabel' => $this->__('Regular'),
377
- 'RegularPriceLabel' => $this->__('Unit Price:'),
378
- 'RelatedProductLabel' => $this->__('You may also like'),
379
- 'ReleaseToUpdatePullDownText' => $this->__('Release To Update...'),
380
- 'RemoveFromWishlistTitle' => $this->__('Remove'),
381
- 'RemoveGiftCardLabel' => $this->__('Remove'),
382
- 'RemoveText' => $this->__('Remove'),
383
- 'RemovingAddressProgressTitle' => $this->__('Remove Address...'),
384
- 'RemovingCouponProgressTitle' => $this->__('Removing Coupon...'),
385
- 'RemovingGiftCartProgressTitle' => $this->__('Removing Gift Card...'),
386
- 'RemovingProductFromWishListProgressTitle' => $this->__('Removing Product from WishList...'),
387
- 'RemovingProgressTitle' => $this->__('Removing %@...'),
388
- 'RemovingStoreCreditProgressTitle' => $this->__('Removing Store Credit...'),
389
- 'RequiredFieldMessage' => $this->__('field is required'),
390
- 'RequiredFieldTitle' => $this->__('required'),
391
- 'RequiredLabel' => $this->__('* - field is required'),
392
- 'Revert' => $this->__('Revert'),
393
- 'RevertDiscountButtonTitle' => $this->__('Revert Discount'),
394
- 'SamplesButtonTitle' => $this->__('Samples'),
395
- 'Save' => $this->__('Save'),
396
- 'SavingAddressProgressTitle' => $this->__('Saving Address...'),
397
- 'SavingChangesProgressTitle' => $this->__('Saving changes ...'),
398
- 'SavingMethodsProgressTitle' => $this->__('Saving shipping methods ...'),
399
- 'SavingShippingAddressProgressTitle' => $this->__('Saving shipping address ...'),
400
- 'Search' => $this->__('Search'),
401
- 'SearchUpdatedMessage' => $this->__('Search Updated'),
402
- 'SearchingProgressTitle' => $this->__('Searching for %@...'),
403
- 'SeeAllText' => $this->__('See all'),
404
- 'SelectA' => $this->__('Select a'),
405
- 'SelectBillingAddressTitle' => $this->__('Select a Billing Address'),
406
- 'SelectBillingMethodTitle' => $this->__('Select a Billing Address'),
407
- 'SelectBillingMethodTitleNoAddress' => $this->__(''),
408
- 'SelectBoxFormat' => $this->__('Select %@'),
409
- 'SelectFromAddressBook' => $this->__('Select from Address Book'),
410
- 'SelectLinks' => $this->__('Select Links'),
411
- 'SelectOptions' => $this->__('Select Options'),
412
- 'SelectPaymentMethod' => $this->__('Select Payment Method'),
413
- 'SelectShippingAddressTitle' => $this->__('Select a Shipping Address'),
414
- 'SelectShippingMethod' => $this->__('Select shipping method'),
415
- 'SelectShippingMethodTitle' => $this->__('Select a Shipping Address'),
416
- 'Send' => $this->__('Send'),
417
- 'SendEmail' => $this->__('Send'),
418
- 'SendEmailTitle' => $this->__('Tell a Friend'),
419
- 'SendTitle' => $this->__('Send'),
420
- 'SendingEmailFailedMessage' => $this->__('Sending e-mail failed...'),
421
- 'SetEmailMessage' => $this->__('Please set email'),
422
- 'SettedText' => $this->__('Set'),
423
- 'ShakeToResetFilters' => $this->__('Shake device to reset the filter'),
424
- 'Share' => $this->__('Share'),
425
- 'ShareTitle' => $this->__('Share'),
426
- 'ShippingAddressTitle' => $this->__('Shipping address'),
427
- 'ShippingCheckout' => $this->__('Shipping'),
428
- 'ShippingMethodTitle' => $this->__('Shipping method'),
429
- 'ShippingMethodsCheckout' => $this->__('Ship method'),
430
- 'Shop' => $this->__('Shop'),
431
- 'ShopAll' => $this->__('Shop All'),
432
- 'ShopUpdatedMessageTitle' => $this->__('Shop Updated'),
433
- 'ShorteningUrlClientSideError' => $this->__('The shortening service returned status code %d indicating a client side error.'),
434
- 'ShorteningUrlError' => $this->__('Error during shortening url'),
435
- 'ShorteningUrlServerSideError' => $this->__('The shortening service returned status code %d indicating a server side error.'),
436
- 'ShowPasswordLabelTitle' => $this->__('Show Password'),
437
- 'SignIn' => $this->__('Sign In'),
438
- 'SignOutProgressTitle' => $this->__('Signing Out ...'),
439
- 'SigningInProgressTitle' => $this->__('Signing In...'),
440
- 'Sku' => $this->__('Product SKU'),
441
- 'SortByLabel' => $this->__('SORT BY:'),
442
- 'SpecialExcludingTaxLabel' => $this->__('Special'),
443
- 'SpecialIncludingTaxLabel' => $this->__('Incl. tax'),
444
- 'SpecifyPaymentMethod' => $this->__('Please specify payment method'),
445
- 'SpecifyShippingMethod' => $this->__('Please specify shipping method'),
446
- 'StandardCheckout' => $this->__('Standard Checkout'),
447
- 'StartingAtExcludingTaxLabel' => $this->__('Starting at excl. tax'),
448
- 'StartingAtIncludingTaxLabel' => $this->__('Starting at incl. tax'),
449
- 'StatusText' => $this->__('Status'),
450
- 'StoreCredit' => $this->__('Store credit'),
451
- 'StoreCreditBalanceHeader' => $this->__('Balance'),
452
- 'StoreCreditInfoUpdatedMessage' => $this->__('Store Credit Info Updated'),
453
- 'StrAddress' => $this->__('Address'),
454
- 'SubmitReview' => $this->__('Submit Review'),
455
- 'SubmittingReviewProgressTitle' => $this->__('Submitting Review...'),
456
- 'Subtotal' => $this->__('Subtotal'),
457
- 'SubtotalExcludingTax' => $this->__('Subtotal excluding tax'),
458
- 'SubtotalExcludingTaxLabel' => $this->__('Subtotal:'),
459
- 'SubtotalIncludingTax' => $this->__('Subtotal including tax'),
460
- 'SubtotalIncludingTaxLabel' => $this->__('Subtotal incl. tax:'),
461
- 'SubtotalRegularPriceLabel' => $this->__('Subtotal:'),
462
- 'SuccessOrderID' => $this->__('Order ID'),
463
- 'SwipeToRevealOptions' => $this->__('Swipe a product to reveal more options'),
464
- 'Telephone' => $this->__('Telephone'),
465
- 'TellAFriendButtonTitle' => $this->__('Tell a Friend'),
466
- 'TellAFriendTitle' => $this->__('Tell a Friend'),
467
- 'TermsAndConditions' => $this->__('Terms And Conditions'),
468
- 'ThereAreNoItemsInYourCart' => $this->__('There are no items in your cart'),
469
- 'ThereIsNoAddressesForThisContact' => $this->__('There is no addresses for this contact'),
470
- 'ToExcludingTaxLabel' => $this->__('To excl. tax'),
471
- 'ToHighCustomValueDialogMessage' => $this->__('The custom amount value should not be higher than %s.'),
472
- 'ToIncludingTaxLabel' => $this->__('To incl. tax'),
473
- 'ToLowCustomValueDialogMessage' => $this->__('The custom amount value should not be lower than %s.'),
474
- 'TooBigValueMessage' => $this->__('The value is too big!'),
475
- 'TooLongTextDialogMessage' => $this->__('The length of the text in the %s field is too big. Please shorten the text.'),
476
- 'TotalsText' => $this->__('Totals'),
477
- 'TouchAndHoldToDeleteProduct' => $this->__('Touch and hold a product to delete from shopping cart'),
478
- 'TouchAndHoldToRevealOptions' => $this->__('Touch and hold a product to reveal more options'),
479
- 'TryAgain' => $this->__('Try Again'),
480
- 'Twitter' => $this->__('Twitter'),
481
- 'TwitterAuthorization' => $this->__('Twitter Authorization'),
482
- 'TwitterAutorization' => $this->__('Twitter Autorization'),
483
- 'TwitterPostFailedMessage' => $this->__('Twitter post failed...'),
484
- 'TwitterPostSuccess' => $this->__('Your tweet has been sent. Thanks for sharing this product on Twitter'),
485
- 'TypeTitle' => $this->__('Type'),
486
- 'URLOrCodeNotSet' => $this->__('Either remote URL or application code was not set. Please make sure you filled all the values and try again.'),
487
- 'UnknownException' => $this->__('Unknown error ocured. Please retry later'),
488
- 'UpdateCommentErrorMessage' => $this->__('Update Comment Error'),
489
- 'UpdatingCartProgressTitle' => $this->__('Updating Cart...'),
490
- 'UpdatingPullDownText' => $this->__('Updating ...'),
491
- 'UseBillingAddress' => $this->__('Use Billing Address'),
492
- 'UseBillingAddressForShipping' => $this->__('Use billing address for shipping'),
493
- 'Version' => $this->__('Version'),
494
- 'ViewCartButtonTitle' => $this->__('View Cart'),
495
- 'ViewDetailsTitle' => $this->__('View Details'),
496
- 'ViewGalleryTitle' => $this->__('View Gallery'),
497
- 'ViewWishlistButtonTitle' => $this->__('View Wishlist'),
498
- 'WaitTitle' => $this->__('Please wait...'),
499
- 'WebStoreAvailableOnly' => $this->__('Product only available on the website.'),
500
- 'WebsiteRestrictionEnabledMessage' => $this->__('Website is offline'),
501
- 'WishListUpdatedMessage' => $this->__('WishList Updated'),
502
- 'Wishlist' => $this->__('My Wishlist'),
503
- 'WishlistPopupTitle' => $this->__('Add To Wishlist'),
504
- 'WriteAReview' => $this->__('Write a review'),
505
- 'WriteReviewTitle' => $this->__('Write a Review'),
506
- 'WrongEmailFormat' => $this->__('Wrong email format'),
507
- 'XMLConnectURL' => $this->__('URL'),
508
- 'Yes' => $this->__('Yes'),
509
- 'iPhoneAddressBookNavigationBarTitle' => $this->__('Address Book'),
510
- 'labelPayWithCheckoutTitle' => $this->__('OR, Pay with Standard Checkout'),
511
- 'qtyLabelTitle' => $this->__('Quantity:')
512
- );
513
- }
514
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Adminhtml/Search/Catalog.php DELETED
@@ -1,71 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Search Catalog Model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Adminhtml_Search_Catalog extends Varien_Object
35
- {
36
- /**
37
- * Load search results
38
- *
39
- * @return Mage_XmlConnect_Model_Adminhtml_Search_Catalog
40
- */
41
- public function load()
42
- {
43
- $arr = array();
44
-
45
- if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
46
- $this->setResults($arr);
47
- return $this;
48
- }
49
-
50
- $collection = Mage::helper('catalogsearch')->getQuery()->getSearchCollection()
51
- ->addAttributeToSelect('product_id')->addAttributeToSelect('name')->addAttributeToSelect('description')
52
- ->addAttributeToSelect('image')->addSearchFilter($this->getQuery())->setCurPage($this->getStart())
53
- ->setPageSize($this->getLimit())->load();
54
-
55
- foreach ($collection as $product) {
56
- $description = Mage::helper('core')->stripTags($product->getDescription());
57
- $arr[] = array(
58
- 'id' => 'product/1/' . $product->getId(),
59
- 'item_id' => $product->getId(),
60
- 'type' => Mage_XmlConnect_Model_ImageAction::ACTION_TYPE_PRODUCT,
61
- 'label' => Mage::helper('adminhtml')->__('Product'),
62
- 'name' => $product->getName(),
63
- 'image' => $product->getImage(),
64
- 'description' => Mage::helper('core/string')->substr($description, 0, 30),
65
- 'url' => Mage::helper('adminhtml')->getUrl('*/catalog_product/edit', array('id' => $product->getId())),
66
- );
67
- }
68
- $this->setResults($arr);
69
- return $this;
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Adminhtml/Search/Category.php DELETED
@@ -1,70 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Search Category Model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Adminhtml_Search_Category extends Varien_Object
35
- {
36
- /**
37
- * Load search results
38
- *
39
- * @return Mage_XmlConnect_Model_Adminhtml_Search_Category
40
- */
41
- public function load()
42
- {
43
- $arr = array();
44
-
45
- if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
46
- $this->setResults($arr);
47
- return $this;
48
- }
49
- /** @var $collection Mage_XmlConnect_Model_Resource_CategorySearch_Collection */
50
- $collection = Mage::getResourceModel('xmlconnect/categorySearch_collection');
51
- $collection->addAttributeToSelect('name')->addAttributeToSelect('description')
52
- ->addSearchFilter($this->getQuery())->setCurPage($this->getStart())->setPageSize($this->getLimit())->load();
53
-
54
- foreach ($collection as $category) {
55
- $description = Mage::helper('core')->stripTags($category->getDescription());
56
- $arr[] = array(
57
- 'id' => 'category/1' . $category->getEntityId(),
58
- 'item_id' => $category->getId(),
59
- 'type' => Mage_XmlConnect_Model_ImageAction::ACTION_TYPE_CATEGORY,
60
- 'label' => Mage::helper('adminhtml')->__('Category'),
61
- 'name' => $category->getName(),
62
- 'image' => null,
63
- 'description' => Mage::helper('core/string')->substr($description, 0, 30),
64
- 'url' => Mage::helper('adminhtml')->getUrl('*/catalog_category/index'),
65
- );
66
- }
67
- $this->setResults($arr);
68
- return $this;
69
- }
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Adminhtml/System/Config/Backend/Currency/Default.php CHANGED
@@ -37,7 +37,7 @@ class Mage_XmlConnect_Model_Adminhtml_System_Config_Backend_Currency_Default
37
  /**
38
  * Update all applications "updated at" parameter with current date
39
  *
40
- * @return Mage_XmlConnect_Model_Adminhtml_System_Config_Backend_Currency_Default
41
  */
42
  protected function _afterSave()
43
  {
37
  /**
38
  * Update all applications "updated at" parameter with current date
39
  *
40
+ * @return this
41
  */
42
  protected function _afterSave()
43
  {
app/code/core/Mage/XmlConnect/Model/Application.php CHANGED
@@ -65,8 +65,6 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
65
 
66
  /**
67
  * Device screen size name
68
- *
69
- * @deprecated will delete in the next version
70
  */
71
  const APP_SCREEN_SIZE_DEFAULT = '320x480';
72
 
@@ -247,38 +245,14 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
247
  */
248
  const DEPRECATED_CONFIG_FLAG = 'deprecated';
249
 
250
- /**
251
- * Pages config flag value
252
- */
253
- const STATIC_PAGE_CATEGORY = 'pages';
254
-
255
  /**
256
  * Delete on update paths for config data
257
  *
258
  * @var array
259
  */
260
- protected $_deleteOnUpdateConfig = array(self::STATIC_PAGE_CATEGORY => 'staticpage');
261
-
262
- /**
263
- * Current device model
264
- *
265
- * @var Mage_XmlConnect_Model_Device_Abstract
266
- */
267
- protected $_deviceModel;
268
-
269
- /**
270
- * Image limits model
271
- *
272
- * @var Mage_XmlConnect_Model_ImageLimits
273
- */
274
- protected $_imageLimitsModel;
275
-
276
- /**
277
- * Image action model
278
- *
279
- * @var Mage_XmlConnect_Model_ImageAction
280
- */
281
- protected $_imageActionModel;
282
 
283
  /**
284
  * Initialize application
@@ -311,20 +285,21 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
311
  public function getFormData()
312
  {
313
  $data = $this->getData();
 
314
  return $this->_flatArray($data);
315
  }
316
 
317
  /**
318
  * Load data (flat array) for Varien_Data_Form
319
  *
320
- * @param array $subTree
321
  * @param string $prefix
322
  * @return array
323
  */
324
- protected function _flatArray($subTree, $prefix=null)
325
  {
326
  $result = array();
327
- foreach ($subTree as $key => $value) {
328
  if (is_null($prefix)) {
329
  $name = $key;
330
  } else {
@@ -453,7 +428,26 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
453
  }
454
  }
455
 
456
- Mage::getModel('xmlconnect/images')->loadOldImageNodes($result);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
 
458
  /**
459
  * General configuration
@@ -463,59 +457,60 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
463
  $result['general']['currencyCode'] = Mage::app()->getStore($this->getStoreId())->getDefaultCurrencyCode();
464
  $result['general']['secureBaseUrl'] = $this->getSecureBaseUrl();
465
 
466
- $allowGuest = $maxRecipients = 0;
 
467
  if (Mage::getStoreConfig(Mage_Sendfriend_Helper_Data::XML_PATH_ENABLED)) {
468
- $maxRecipients = (int)Mage::getStoreConfig(Mage_Sendfriend_Helper_Data::XML_PATH_MAX_RECIPIENTS);
469
- $maxRecipients = $maxRecipients > 0 ? $maxRecipients: 1;
470
  $allowGuest = Mage::getStoreConfig(Mage_Sendfriend_Helper_Data::XML_PATH_ALLOW_FOR_GUEST);
471
  }
472
  $result['general']['emailToFriendMaxRecepients'] = $maxRecipients;
473
  $result['general']['emailAllowGuest'] = $allowGuest;
474
- $result['general']['primaryStoreLang'] = Mage::app()->getStore($this->getStoreId())
475
- ->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE);
476
  $result['general']['magentoVersion'] = Mage::getVersion();
477
- $result['general']['copyright'] = Mage::helper('core')->stripTags(
478
- Mage::getStoreConfig(self::XML_PATH_DESIGN_FOOTER_COPYRIGHT, $this->getStoreId())
479
  );
480
  $result['general']['xmlconnectVersion'] = Mage::getConfig()->getNode(self::XML_PATH_MODULE_VERSION);
481
 
482
- $result['general']['isAllowedGuestCheckout'] = (int)Mage::getSingleton('checkout/session')->getQuote()
483
- ->isAllowedGuestCheckout();
484
 
485
  /**
486
  * Check is guest can post product reviews
487
  */
488
- $result['general']['isAllowedGuestReview'] = Mage::helper('review')->getIsGuestAllowToWrite() ? '1' : '0';
 
 
 
 
489
 
490
  /**
491
  * Check is wishlist enabled in a config
492
  */
493
- $result['general']['wishlistEnable'] = Mage::getStoreConfigFlag('wishlist/general/active') ? '1' : '0';
 
 
 
 
494
 
495
  /**
496
  * "Use Secure URLs in Frontend" flag
497
  */
498
  $result['general']['useSecureURLInFrontend'] = $this->getUseSecureURLInFrontend();
499
 
500
- /**
501
- * Set flag is allowed guest checkout if quote contain downloadable product(s)
502
- */
503
- if ($this->isGuestBuyDownloadableProduct()) {
504
- $result['general']['isAllowedGuestCheckoutForDownloadableProducts'] = '0';
505
- } else {
506
- $result['general']['isAllowedGuestCheckoutForDownloadableProducts'] = '1';
507
- }
508
-
509
  /**
510
  * Is enabled Store credit functionality
511
  */
512
- $isStoreCreditEnable = $canShowHistoryFlag = 0;
513
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_CustomerBalance'))) {
514
  $storeCreditFlag = Mage::getStoreConfig(Enterprise_CustomerBalance_Helper_Data::XML_PATH_ENABLED);
515
  $isStoreCreditEnable = (int)$storeCreditFlag;
516
- $canShowHistoryFlag = (int)Mage::getStoreConfigFlag('customer/enterprise_customerbalance/show_history');
 
 
 
 
517
  }
518
-
519
  $result['general']['isStoreCreditEnabled'] = $isStoreCreditEnable;
520
  $result['general']['isStoreCreditHistoryEnabled'] = $canShowHistoryFlag;
521
 
@@ -541,15 +536,6 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
541
 
542
  $paypalMeclIsAvailable = Mage::getModel('xmlconnect/payment_method_paypal_mecl')->isAvailable(null);
543
 
544
- /**
545
- * Pages configuration
546
- */
547
- $pages = Mage::getSingleton('xmlconnect/configuration')->getDeviceStaticPages();
548
-
549
- if (!empty($pages)) {
550
- $result['pages'] = $pages;
551
- }
552
-
553
  /**
554
  * PayPal Mobile Express Library Checkout
555
  */
@@ -578,18 +564,6 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
578
  return Mage::getStoreConfig(self::XML_PATH_SECURE_BASE_LINK_URL, $this->getStoreId());
579
  }
580
 
581
- /**
582
- * Check is allowed guest checkout if quote contain downloadable product(s)
583
- *
584
- * @return bool
585
- */
586
- public function isGuestBuyDownloadableProduct()
587
- {
588
- return (bool)Mage::getStoreConfigFlag(
589
- Mage_Downloadable_Model_Observer::XML_PATH_DISABLE_GUEST_CHECKOUT, $this->getStoreId()
590
- );
591
- }
592
-
593
  /**
594
  * Is forced front secure url
595
  *
@@ -608,20 +582,21 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
608
  public function getScreenSize()
609
  {
610
  if (!isset($this->_data['screen_size'])) {
611
- $this->_data['screen_size'] = $this->getDeviceModel()->getDefaultScreenSize();
612
  }
613
  return $this->_data['screen_size'];
614
  }
615
 
616
  /**
617
- * Setter for current screen_size parameter
 
618
  *
619
  * @param string $screenSize
620
- * @return Mage_XmlConnect_Model_Application
621
  */
622
  public function setScreenSize($screenSize)
623
  {
624
- $this->_data['screen_size'] = $screenSize;
625
  return $this;
626
  }
627
 
@@ -641,21 +616,21 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
641
  /**
642
  * Change URLs to absolute
643
  *
644
- * @param array $subTree
645
  * @return array
646
  */
647
- protected function _absPath($subTree)
648
  {
649
- foreach ($subTree as $key => $value) {
650
  if (!empty($value)) {
651
  if (is_array($value)) {
652
- $subTree[$key] = $this->_absPath($value);
653
  } elseif (strtolower(substr($key, -4)) == 'icon' || strtolower(substr($key, -5)) == 'image') {
654
- $subTree[$key] = Mage::getBaseUrl('media') . 'xmlconnect/' . $value;
655
  }
656
  }
657
  }
658
- return $subTree;
659
  }
660
 
661
  /**
@@ -665,8 +640,8 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
665
  */
666
  public function getPages()
667
  {
668
- if (isset($this->_data['conf']['pages'])) {
669
- return $this->_data['conf']['pages'];
670
  }
671
  return array();
672
  }
@@ -681,17 +656,6 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
681
  return $this->_configModel;
682
  }
683
 
684
- /**
685
- * Set last updated datetime string
686
- *
687
- * @return Mage_XmlConnect_Model_Application
688
- */
689
- protected function _renewUpdatedAtTime()
690
- {
691
- $this->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate());
692
- return $this;
693
- }
694
-
695
  /**
696
  * Processing object before save data
697
  *
@@ -699,7 +663,7 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
699
  */
700
  protected function _beforeSave()
701
  {
702
- $this->_renewUpdatedAtTime();
703
  return $this;
704
  }
705
 
@@ -797,6 +761,7 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
797
  'application_id' => $this->getId(),
798
  'category' => 'payment'
799
  ))->toOptionArray();
 
800
  $this->setData('config_data', $configuration);
801
  return $this;
802
  }
@@ -823,7 +788,6 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
823
  * Convert old config data array
824
  *
825
  * @deprecated Serialized config storage has been removed
826
- * @throws Mage_Core_Exception
827
  * @param $config
828
  * @return array
829
  */
@@ -833,7 +797,9 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
833
  foreach ($config as $values) {
834
  foreach ($values as $path => $value) {
835
  if (preg_match('@[^\w\/]@', $path)) {
836
- Mage::throwException(Mage::helper('xmlconnect')->__('Unsupported character in path: "%s"', $path));
 
 
837
  }
838
  $keyArray = explode('/', $path);
839
  $keys = '$result["' . implode('"]["', $keyArray) . '"]';
@@ -899,7 +865,9 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
899
  {
900
  $images = array();
901
  $params = $this->getLastParams();
902
- $deviceImages = Mage::helper('xmlconnect')->getDeviceHelper()->getSubmitImages();
 
 
903
 
904
  foreach ($deviceImages as $id) {
905
  $path = $this->getData('conf/submit/'.$id);
@@ -995,9 +963,9 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
995
  */
996
  protected function _validateConf()
997
  {
998
- $config = $this->getConf();
999
- $native = isset($config['native']) && is_array($config['native']) ? $config['native'] : false;
1000
- $errors = array();
1001
 
1002
  foreach ($this->_socialNetValidationArray as $networkKey) {
1003
  if (isset($native['socialNetworking'][$networkKey]['isActive'])
@@ -1130,7 +1098,7 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
1130
  */
1131
  public function updateAllAppsUpdatedAtParameter()
1132
  {
1133
- $this->_renewUpdatedAtTime()->_getResource()->updateUpdatedAtParameter($this);
1134
  return $this;
1135
  }
1136
 
@@ -1216,90 +1184,4 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract
1216
  $this->_deleteOnUpdateConfig = array_merge($this->_deleteOnUpdateConfig, $pathsToDelete);
1217
  return $this;
1218
  }
1219
-
1220
- /**
1221
- * Get current device model
1222
- *
1223
- * @return Mage_XmlConnect_Model_Device_Abstract
1224
- */
1225
- public function getDeviceModel()
1226
- {
1227
- if (null === $this->_deviceModel) {
1228
- $this->setDeviceModel();
1229
- }
1230
- return $this->_deviceModel;
1231
- }
1232
-
1233
- /**
1234
- * Set current device model
1235
- *
1236
- * @throws Mage_Core_Exception
1237
- * @param Mage_XmlConnect_Model_Device_Abstract|null $deviceModel
1238
- * @return Mage_XmlConnect_Model_Application
1239
- */
1240
- public function setDeviceModel($deviceModel = null)
1241
- {
1242
- if ($deviceModel instanceof Mage_XmlConnect_Model_Device_Abstract) {
1243
- $this->_deviceModel = $deviceModel;
1244
- } elseif ($this->getType()) {
1245
- $this->_deviceModel = Mage::getModel('xmlconnect/device_' . $this->getType(), $this);
1246
- } else {
1247
- Mage::throwException(Mage::helper('xmlconnect')->__('Device doesn\'t recognized'));
1248
- }
1249
- return $this;
1250
- }
1251
-
1252
- /**
1253
- * Get current image limit model
1254
- *
1255
- * @return Mage_XmlConnect_Model_ImageLimits
1256
- */
1257
- public function getImageLimitsModel()
1258
- {
1259
- if ($this->_imageLimitsModel === null) {
1260
- $this->setImageLimitsModel();
1261
- }
1262
- return $this->_imageLimitsModel;
1263
- }
1264
-
1265
- /**
1266
- * Set current image limit model
1267
- *
1268
- * @param null|Mage_XmlConnect_Model_ImageLimits $imageLimitsModel
1269
- * @return Mage_XmlConnect_Model_Application
1270
- */
1271
- public function setImageLimitsModel($imageLimitsModel = null)
1272
- {
1273
- if (null === $imageLimitsModel) {
1274
- $this->_imageLimitsModel = Mage::getModel('xmlconnect/imageLimits', $this);
1275
- } else {
1276
- $this->_imageLimitsModel = $imageLimitsModel;
1277
- }
1278
- return $this;
1279
- }
1280
-
1281
- /**
1282
- * Get image action model
1283
- *
1284
- * @return Mage_XmlConnect_Model_ImageAction
1285
- */
1286
- public function getImageActionModel()
1287
- {
1288
- if (null === $this->_imageActionModel) {
1289
- $this->_imageActionModel = Mage::getModel('xmlconnect/imageAction', $this);
1290
- }
1291
- return $this->_imageActionModel;
1292
- }
1293
-
1294
- /**
1295
- * Set image action model
1296
- *
1297
- * @param Mage_XmlConnect_Model_ImageAction $imageActionModel
1298
- * @return Mage_XmlConnect_Model_Application
1299
- */
1300
- public function setImageActionModel($imageActionModel)
1301
- {
1302
- $this->_imageActionModel = $imageActionModel;
1303
- return $this;
1304
- }
1305
  }
65
 
66
  /**
67
  * Device screen size name
 
 
68
  */
69
  const APP_SCREEN_SIZE_DEFAULT = '320x480';
70
 
245
  */
246
  const DEPRECATED_CONFIG_FLAG = 'deprecated';
247
 
 
 
 
 
 
248
  /**
249
  * Delete on update paths for config data
250
  *
251
  * @var array
252
  */
253
+ protected $_deleteOnUpdateConfig = array(
254
+ self::DEPRECATED_CONFIG_FLAG => 'native/pages'
255
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
 
257
  /**
258
  * Initialize application
285
  public function getFormData()
286
  {
287
  $data = $this->getData();
288
+ $data = Mage::helper('xmlconnect')->getDeviceHelper()->checkImages($data);
289
  return $this->_flatArray($data);
290
  }
291
 
292
  /**
293
  * Load data (flat array) for Varien_Data_Form
294
  *
295
+ * @param array $subtree
296
  * @param string $prefix
297
  * @return array
298
  */
299
+ protected function _flatArray($subtree, $prefix=null)
300
  {
301
  $result = array();
302
+ foreach ($subtree as $key => $value) {
303
  if (is_null($prefix)) {
304
  $name = $key;
305
  } else {
428
  }
429
  }
430
 
431
+ /** @var $helperImage Mage_XmlConnect_Helper_Image */
432
+ $helperImage = Mage::helper('xmlconnect/image');
433
+ $paths = $helperImage->getInterfaceImagesPathsConf();
434
+
435
+ foreach ($paths as $confPath => $dataPath) {
436
+ $imageNodeValue =& $helperImage->findPath($result, $dataPath);
437
+
438
+ if (!$helperImage->checkAndGetImagePath($imageNodeValue)) {
439
+ /**
440
+ * We set empty string to get default image if original was missing in some reason
441
+ */
442
+ $imageNodeValue = '';
443
+ } else {
444
+ /**
445
+ * Creating file ending (some_inner/some_dir/filename.png) For url
446
+ */
447
+ $imageNodeValue = $helperImage->getFileCustomDirSuffixAsUrl($confPath, $imageNodeValue);
448
+ }
449
+ }
450
+ $result = $this->_absPath($result);
451
 
452
  /**
453
  * General configuration
457
  $result['general']['currencyCode'] = Mage::app()->getStore($this->getStoreId())->getDefaultCurrencyCode();
458
  $result['general']['secureBaseUrl'] = $this->getSecureBaseUrl();
459
 
460
+ $maxRecipients = 0;
461
+ $allowGuest = 0;
462
  if (Mage::getStoreConfig(Mage_Sendfriend_Helper_Data::XML_PATH_ENABLED)) {
463
+ $maxRecipients = Mage::getStoreConfig(Mage_Sendfriend_Helper_Data::XML_PATH_MAX_RECIPIENTS);
 
464
  $allowGuest = Mage::getStoreConfig(Mage_Sendfriend_Helper_Data::XML_PATH_ALLOW_FOR_GUEST);
465
  }
466
  $result['general']['emailToFriendMaxRecepients'] = $maxRecipients;
467
  $result['general']['emailAllowGuest'] = $allowGuest;
468
+ $result['general']['primaryStoreLang'] = Mage::app()
469
+ ->getStore($this->getStoreId())->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE);
470
  $result['general']['magentoVersion'] = Mage::getVersion();
471
+ $result['general']['copyright'] = Mage::getStoreConfig(
472
+ self::XML_PATH_DESIGN_FOOTER_COPYRIGHT, $this->getStoreId()
473
  );
474
  $result['general']['xmlconnectVersion'] = Mage::getConfig()->getNode(self::XML_PATH_MODULE_VERSION);
475
 
476
+ $result['general']['isAllowedGuestCheckout'] = (int)Mage::getSingleton('checkout/session')
477
+ ->getQuote()->isAllowedGuestCheckout();
478
 
479
  /**
480
  * Check is guest can post product reviews
481
  */
482
+ if (Mage::helper('review')->getIsGuestAllowToWrite()) {
483
+ $result['general']['isAllowedGuestReview'] = '1';
484
+ } else {
485
+ $result['general']['isAllowedGuestReview'] = '0';
486
+ }
487
 
488
  /**
489
  * Check is wishlist enabled in a config
490
  */
491
+ if (Mage::getStoreConfigFlag('wishlist/general/active')) {
492
+ $result['general']['wishlistEnable'] = '1';
493
+ } else {
494
+ $result['general']['wishlistEnable'] = '0';
495
+ }
496
 
497
  /**
498
  * "Use Secure URLs in Frontend" flag
499
  */
500
  $result['general']['useSecureURLInFrontend'] = $this->getUseSecureURLInFrontend();
501
 
 
 
 
 
 
 
 
 
 
502
  /**
503
  * Is enabled Store credit functionality
504
  */
 
505
  if (is_object(Mage::getConfig()->getNode('modules/Enterprise_CustomerBalance'))) {
506
  $storeCreditFlag = Mage::getStoreConfig(Enterprise_CustomerBalance_Helper_Data::XML_PATH_ENABLED);
507
  $isStoreCreditEnable = (int)$storeCreditFlag;
508
+ $canShowHistoryFlag = (int) Mage::getStoreConfigFlag(
509
+ 'customer/enterprise_customerbalance/show_history'
510
+ );
511
+ } else {
512
+ $isStoreCreditEnable = $canShowHistoryFlag = 0;
513
  }
 
514
  $result['general']['isStoreCreditEnabled'] = $isStoreCreditEnable;
515
  $result['general']['isStoreCreditHistoryEnabled'] = $canShowHistoryFlag;
516
 
536
 
537
  $paypalMeclIsAvailable = Mage::getModel('xmlconnect/payment_method_paypal_mecl')->isAvailable(null);
538
 
 
 
 
 
 
 
 
 
 
539
  /**
540
  * PayPal Mobile Express Library Checkout
541
  */
564
  return Mage::getStoreConfig(self::XML_PATH_SECURE_BASE_LINK_URL, $this->getStoreId());
565
  }
566
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  /**
568
  * Is forced front secure url
569
  *
582
  public function getScreenSize()
583
  {
584
  if (!isset($this->_data['screen_size'])) {
585
+ $this->_data['screen_size'] = self::APP_SCREEN_SIZE_DEFAULT;
586
  }
587
  return $this->_data['screen_size'];
588
  }
589
 
590
  /**
591
+ * Setter
592
+ * for current screen_size parameter
593
  *
594
  * @param string $screenSize
595
+ * @return this
596
  */
597
  public function setScreenSize($screenSize)
598
  {
599
+ $this->_data['screen_size'] = Mage::helper('xmlconnect/image')->filterScreenSize((string) $screenSize);
600
  return $this;
601
  }
602
 
616
  /**
617
  * Change URLs to absolute
618
  *
619
+ * @param array $subtree
620
  * @return array
621
  */
622
+ protected function _absPath($subtree)
623
  {
624
+ foreach ($subtree as $key => $value) {
625
  if (!empty($value)) {
626
  if (is_array($value)) {
627
+ $subtree[$key] = $this->_absPath($value);
628
  } elseif (strtolower(substr($key, -4)) == 'icon' || strtolower(substr($key, -5)) == 'image') {
629
+ $subtree[$key] = Mage::getBaseUrl('media') . 'xmlconnect/' . $value;
630
  }
631
  }
632
  }
633
+ return $subtree;
634
  }
635
 
636
  /**
640
  */
641
  public function getPages()
642
  {
643
+ if (isset($this->_data['conf']['native']['pages'])) {
644
+ return $this->_data['conf']['native']['pages'];
645
  }
646
  return array();
647
  }
656
  return $this->_configModel;
657
  }
658
 
 
 
 
 
 
 
 
 
 
 
 
659
  /**
660
  * Processing object before save data
661
  *
663
  */
664
  protected function _beforeSave()
665
  {
666
+ $this->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate());
667
  return $this;
668
  }
669
 
761
  'application_id' => $this->getId(),
762
  'category' => 'payment'
763
  ))->toOptionArray();
764
+
765
  $this->setData('config_data', $configuration);
766
  return $this;
767
  }
788
  * Convert old config data array
789
  *
790
  * @deprecated Serialized config storage has been removed
 
791
  * @param $config
792
  * @return array
793
  */
797
  foreach ($config as $values) {
798
  foreach ($values as $path => $value) {
799
  if (preg_match('@[^\w\/]@', $path)) {
800
+ Mage::throwException(
801
+ Mage::helper('xmlconnect')->__('Unsupported character in path: "%s"', $path)
802
+ );
803
  }
804
  $keyArray = explode('/', $path);
805
  $keys = '$result["' . implode('"]["', $keyArray) . '"]';
865
  {
866
  $images = array();
867
  $params = $this->getLastParams();
868
+ $deviceImages = Mage::helper('xmlconnect')
869
+ ->getDeviceHelper()
870
+ ->getSubmitImages();
871
 
872
  foreach ($deviceImages as $id) {
873
  $path = $this->getData('conf/submit/'.$id);
963
  */
964
  protected function _validateConf()
965
  {
966
+ $conf = $this->getConf();
967
+ $native = isset($conf['native']) && is_array($conf['native']) ? $conf['native'] : false;
968
+ $errors = Mage::helper('xmlconnect')->getDeviceHelper($this)->validateConfig($native);
969
 
970
  foreach ($this->_socialNetValidationArray as $networkKey) {
971
  if (isset($native['socialNetworking'][$networkKey]['isActive'])
1098
  */
1099
  public function updateAllAppsUpdatedAtParameter()
1100
  {
1101
+ $this->_getResource()->updateAllAppsUpdatedAtParameter();
1102
  return $this;
1103
  }
1104
 
1184
  $this->_deleteOnUpdateConfig = array_merge($this->_deleteOnUpdateConfig, $pathsToDelete);
1185
  return $this;
1186
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1187
  }
app/code/core/Mage/XmlConnect/Model/Catalog/Category/Image.php CHANGED
@@ -34,7 +34,7 @@
34
  class Mage_XmlConnect_Model_Catalog_Category_Image extends Mage_Catalog_Model_Product_Image
35
  {
36
  /**
37
- * Set file names for base file and new file
38
  *
39
  * @param string $file
40
  * @return Mage_Catalog_Model_Product_Image
@@ -76,9 +76,8 @@ class Mage_XmlConnect_Model_Catalog_Category_Image extends Mage_Catalog_Model_Pr
76
  } else {
77
  $baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default'));
78
  if (!file_exists($baseDir . $file)) {
79
- $baseDir = Mage::getDesign()->getSkinBaseDir(
80
- array('_theme' => 'default', '_package' => 'base')
81
- );
82
  }
83
  }
84
  }
@@ -94,22 +93,18 @@ class Mage_XmlConnect_Model_Catalog_Category_Image extends Mage_Catalog_Model_Pr
94
  $this->_baseFile = $baseFile;
95
 
96
  // build new filename (most important params)
97
- $path = array(Mage::getSingleton('xmlconnect/catalog_category_media_config')->getBaseMediaPath(),
98
- 'cache', Mage::app()->getStore()->getId(), $path[] = $this->getDestinationSubdir());
99
-
100
  if ((!empty($this->_width)) || (!empty($this->_height))) {
101
  $path[] = "{$this->_width}x{$this->_height}";
102
  }
103
 
104
  // add misk params as a hash
105
- $miscParams = array(
106
- ($this->_keepAspectRatio ? '' : 'non') . 'proportional',
107
- ($this->_keepFrame ? '' : 'no') . 'frame',
108
- ($this->_keepTransparency ? '' : 'no') . 'transparency',
109
- ($this->_constrainOnly ? 'do' : 'not') . 'constrainonly',
110
- $this->_rgbToString($this->_backgroundColor),
111
- 'angle' . $this->_angle,
112
- 'quality' . $this->_quality
113
  );
114
 
115
  // if has watermark add watermark params to hash
@@ -129,23 +124,11 @@ class Mage_XmlConnect_Model_Catalog_Category_Image extends Mage_Catalog_Model_Pr
129
  return $this;
130
  }
131
 
132
- /**
133
- * Set new file
134
- *
135
- * @param string $filePath
136
- * @return Mage_XmlConnect_Model_Catalog_Category_Image
137
- */
138
- public function setNewFile($filePath)
139
- {
140
- $this->_newFile = $filePath;
141
- return $this;
142
- }
143
-
144
  /**
145
  * Get relative watermark file path
146
  * or false if file not found
147
  *
148
- * @return string|bool
149
  */
150
  protected function _getWatermarkFilePath()
151
  {
34
  class Mage_XmlConnect_Model_Catalog_Category_Image extends Mage_Catalog_Model_Product_Image
35
  {
36
  /**
37
+ * Set filenames for base file and new file
38
  *
39
  * @param string $file
40
  * @return Mage_Catalog_Model_Product_Image
76
  } else {
77
  $baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default'));
78
  if (!file_exists($baseDir . $file)) {
79
+ $baseDir = Mage::getDesign()
80
+ ->getSkinBaseDir(array('_theme' => 'default', '_package' => 'base'));
 
81
  }
82
  }
83
  }
93
  $this->_baseFile = $baseFile;
94
 
95
  // build new filename (most important params)
96
+ $path = array(Mage::getSingleton('xmlconnect/catalog_category_media_config')->getBaseMediaPath(), 'cache',
97
+ Mage::app()->getStore()->getId(), $path[] = $this->getDestinationSubdir()
98
+ );
99
  if ((!empty($this->_width)) || (!empty($this->_height))) {
100
  $path[] = "{$this->_width}x{$this->_height}";
101
  }
102
 
103
  // add misk params as a hash
104
+ $miscParams = array(($this->_keepAspectRatio ? '' : 'non') . 'proportional',
105
+ ($this->_keepFrame ? '' : 'no') . 'frame', ($this->_keepTransparency ? '' : 'no') . 'transparency',
106
+ ($this->_constrainOnly ? 'do' : 'not') . 'constrainonly', $this->_rgbToString($this->_backgroundColor),
107
+ 'angle' . $this->_angle, 'quality' . $this->_quality
 
 
 
 
108
  );
109
 
110
  // if has watermark add watermark params to hash
124
  return $this;
125
  }
126
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  /**
128
  * Get relative watermark file path
129
  * or false if file not found
130
  *
131
+ * @return string | bool
132
  */
133
  protected function _getWatermarkFilePath()
134
  {
app/code/core/Mage/XmlConnect/Model/ConfigData.php CHANGED
@@ -73,8 +73,8 @@ class Mage_XmlConnect_Model_ConfigData extends Mage_Core_Model_Abstract
73
  * Create an array: application id with a prefix as key and
74
  * configuration data as value
75
  *
76
- * @param int $applicationId
77
- * @param array $configData
78
  * @return array
79
  */
80
  protected function _assignConfig($applicationId, $configData)
@@ -91,7 +91,7 @@ class Mage_XmlConnect_Model_ConfigData extends Mage_Core_Model_Abstract
91
  * - array('config/path/param' => 'value')
92
  * if key doesn't have a separator category will be set as default
93
  *
94
- * @param array $configuration posted data array
95
  * @return array configuration data array
96
  */
97
  protected function _prepareData($configuration)
@@ -112,7 +112,7 @@ class Mage_XmlConnect_Model_ConfigData extends Mage_Core_Model_Abstract
112
  /**
113
  * Prepare and set configuration data
114
  *
115
- * @param int $applicationId
116
  * @param array $configData
117
  * @param bool $replace
118
  * @return Mage_XmlConnect_Model_ConfigData
@@ -132,10 +132,10 @@ class Mage_XmlConnect_Model_ConfigData extends Mage_Core_Model_Abstract
132
  /**
133
  * Get configuration data
134
  *
135
- * @param int $applicationId
136
  * @return array
137
  */
138
- public function getConfigData($applicationId = 0)
139
  {
140
  if ($applicationId && isset($this->_configuration[self::CONFIG_PREFIX . $applicationId])) {
141
  return $this->_configuration[self::CONFIG_PREFIX . $applicationId];
@@ -163,7 +163,7 @@ class Mage_XmlConnect_Model_ConfigData extends Mage_Core_Model_Abstract
163
  /**
164
  * Save configuration data by given params
165
  *
166
- * @param int $applicationId
167
  * @param array $configData
168
  * @param string $category
169
  * @return Mage_XmlConnect_Model_ConfigData
@@ -202,126 +202,14 @@ class Mage_XmlConnect_Model_ConfigData extends Mage_Core_Model_Abstract
202
  }
203
 
204
  /**
205
- * Delete group of records those have to be deleted with update process
206
- *
207
- * @param int $applicationId
208
  * @return Mage_XmlConnect_Model_ConfigData
209
  */
210
  protected function _deleteOnUpdate($applicationId)
211
  {
212
  foreach ($this->_deleteOnUpdate as $category => $path) {
213
- $this->deleteConfig($applicationId, $category, $path, true);
214
  }
215
  return $this;
216
  }
217
-
218
- /**
219
- * Delete config record
220
- *
221
- * @param int $applicationId
222
- * @param string $category
223
- * @param string $path
224
- * @param bool $pathLike
225
- * @return Mage_XmlConnect_Model_ConfigData
226
- */
227
- public function deleteConfig($applicationId, $category = '', $path = '', $pathLike = false)
228
- {
229
- $this->getResource()->deleteConfig($applicationId, $category, $path, $pathLike);
230
- return $this;
231
- }
232
-
233
- /**
234
- * Load Configuration data by filter params
235
- *
236
- * @param int $applicationId
237
- * @param string $category
238
- * @param string $path
239
- * @param bool $pathLike
240
- * @return array
241
- */
242
- public function loadApplicationData($applicationId, $category = '', $path = '', $pathLike = true)
243
- {
244
- /** @var $collection Mage_XmlConnect_Model_Resource_ConfigData_Collection */
245
- $collection = $this->getCollection();
246
- $collection->addApplicationIdFilter($applicationId);
247
-
248
- if ($category) {
249
- $collection->addCategoryFilter($category);
250
- }
251
-
252
- if ($path) {
253
- $collection->addPathFilter($path, $pathLike);
254
- }
255
-
256
- return $collection->toOptionArray();
257
- }
258
-
259
- /**
260
- * Load configuration node value
261
- *
262
- * @param int $applicationId
263
- * @param string $category
264
- * @param string $path
265
- * @return mixed
266
- */
267
- public function loadScalarValue($applicationId, $category, $path)
268
- {
269
- /** @var $collection Mage_XmlConnect_Model_Resource_ConfigData_Collection */
270
- $collection = $this->getCollection();
271
- $collection->addApplicationIdFilter($applicationId);
272
-
273
- if ($category) {
274
- $collection->addCategoryFilter($category);
275
- }
276
-
277
- if ($path) {
278
- $collection->addPathFilter($path, false);
279
- }
280
-
281
- return ($result = $collection->fetchItem()) ? $result->getValue() : null;
282
- }
283
-
284
- /**
285
- * Update old pages records in database
286
- * For data upgrade usage only
287
- *
288
- * @see data upgrade file: mysql4-data-upgrade-1.6.0.0-1.6.0.0.1.php
289
- * @param array $records
290
- * @return null
291
- */
292
- public function pagesUpgradeOldConfig($records)
293
- {
294
- $newConfig = array();
295
- /** @var $applicationModel Mage_XmlConnect_Model_Application */
296
- $applicationModel = Mage::getModel('xmlconnect/application');
297
- $deprecatedFlag = Mage_XmlConnect_Model_Application::DEPRECATED_CONFIG_FLAG;
298
-
299
- foreach ($records as $applicationId) {
300
- /** @var $applicationModel Mage_XmlConnect_Model_Application */
301
- $applicationModel->load($applicationId);
302
- $configData = $this->loadApplicationData($applicationId);
303
-
304
- foreach ($configData[$deprecatedFlag] as $deprecatedConfigKey => $deprecatedConfigValue) {
305
- $pagesConfigPath = 'native/pages/';
306
- if (strpos($deprecatedConfigKey, $pagesConfigPath) !== false) {
307
- $pagePath = substr($deprecatedConfigKey, strlen($pagesConfigPath));
308
- list($id, $type) = explode('/', $pagePath);
309
- $newConfig[$id][$type] = $deprecatedConfigValue;
310
-
311
- $this->deleteConfig($applicationId, $deprecatedFlag, $deprecatedConfigKey);
312
- }
313
- }
314
-
315
- foreach ($newConfig as $id => $page) {
316
- if (empty($page['label']) || empty($page['id'])) {
317
- continue;
318
- }
319
- $path = 'staticpage/' . $id;
320
-
321
- $this->getResource()->saveConfig(
322
- $applicationId, Mage_XmlConnect_Model_Application::STATIC_PAGE_CATEGORY, $path, serialize($page)
323
- );
324
- }
325
- }
326
- }
327
  }
73
  * Create an array: application id with a prefix as key and
74
  * configuration data as value
75
  *
76
+ * @param $applicationId
77
+ * @param $configData
78
  * @return array
79
  */
80
  protected function _assignConfig($applicationId, $configData)
91
  * - array('config/path/param' => 'value')
92
  * if key doesn't have a separator category will be set as default
93
  *
94
+ * @param $configuration posted data array
95
  * @return array configuration data array
96
  */
97
  protected function _prepareData($configuration)
112
  /**
113
  * Prepare and set configuration data
114
  *
115
+ * @param $applicationId
116
  * @param array $configData
117
  * @param bool $replace
118
  * @return Mage_XmlConnect_Model_ConfigData
132
  /**
133
  * Get configuration data
134
  *
135
+ * @param bool $applicationId
136
  * @return array
137
  */
138
+ public function getConfigData($applicationId = false)
139
  {
140
  if ($applicationId && isset($this->_configuration[self::CONFIG_PREFIX . $applicationId])) {
141
  return $this->_configuration[self::CONFIG_PREFIX . $applicationId];
163
  /**
164
  * Save configuration data by given params
165
  *
166
+ * @param $applicationId
167
  * @param array $configData
168
  * @param string $category
169
  * @return Mage_XmlConnect_Model_ConfigData
202
  }
203
 
204
  /**
205
+ * @param $applicationId
 
 
206
  * @return Mage_XmlConnect_Model_ConfigData
207
  */
208
  protected function _deleteOnUpdate($applicationId)
209
  {
210
  foreach ($this->_deleteOnUpdate as $category => $path) {
211
+ $this->getResource()->deleteConfig($applicationId, $category, $path);
212
  }
213
  return $this;
214
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  }
app/code/core/Mage/XmlConnect/Model/Configuration.php DELETED
@@ -1,271 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Application configuration model
29
- *
30
- * @category Mage
31
- * @package Mage_Xmlconnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Configuration extends Mage_Core_Model_Abstract
35
- {
36
- /**
37
- * Admin application config flag for is active param
38
- */
39
- const CONFIG_PATH_AA_SETTINGS = 'xmlconnect/admin_app/settings';
40
-
41
- /**
42
- * Core config data collection
43
- *
44
- * @var Mage_Core_Model_Resource_Config_Data_Collection
45
- */
46
- protected $_configDataCollection;
47
-
48
- /**
49
- * XmlConnect data collection
50
- *
51
- * @var Mage_XmlConnect_Model_Resource_ConfigData_Collection
52
- */
53
- protected $_configConnectDataCollection;
54
-
55
- /**
56
- * Core config model
57
- *
58
- * @var Mage_Core_Model_Config
59
- */
60
- protected $_configDataModel;
61
-
62
- /**
63
- * Admin application settings
64
- *
65
- * @var array
66
- */
67
- protected $_adminApplicationSettings;
68
-
69
- /**
70
- * Application model
71
- *
72
- * @var Mage_XmlConnect_Model_Application
73
- */
74
- protected $_applicationModel;
75
-
76
- /**
77
- * Get is active admin application flag
78
- *
79
- * @return bool
80
- */
81
- public function isActiveAdminApp()
82
- {
83
- $isActiveSetting = $this->_getAdminApplicationSettings(
84
- Mage_XmlConnect_Model_Configuration::CONFIG_PATH_AA_SETTINGS . '/is_active'
85
- );
86
- return $isActiveSetting ? (bool)$isActiveSetting['value'] : false;
87
- }
88
-
89
- /**
90
- * Save is active admin application param
91
- *
92
- * @param int $isActive
93
- * @return Mage_XmlConnect_Model_Configuration
94
- */
95
- public function saveIsActiveAdminApp($isActive)
96
- {
97
- $this->_getConfigDataModel()->saveConfig(
98
- Mage_XmlConnect_Model_Configuration::CONFIG_PATH_AA_SETTINGS . '/is_active', (int)$isActive
99
- );
100
- return $this;
101
- }
102
-
103
- /**
104
- * Get admin application settings data
105
- *
106
- * @param null|string $path to config node
107
- * @return array
108
- */
109
- protected function _getAdminApplicationSettings($path = null)
110
- {
111
- if (null === $this->_adminApplicationSettings) {
112
- $adminApplicationSettings = $this->_getConfigDataCollection()
113
- ->addPathFilter(self::CONFIG_PATH_AA_SETTINGS)
114
- ->getData();
115
-
116
- foreach ($adminApplicationSettings as $setting) {
117
- $this->_adminApplicationSettings[$setting['path']] = $setting;
118
- }
119
- }
120
-
121
- if ($path !== null && isset($this->_adminApplicationSettings[$path])) {
122
- return $this->_adminApplicationSettings[$path];
123
- } else {
124
- return $this->_adminApplicationSettings;
125
- }
126
- }
127
-
128
- /**
129
- * Get core config data collection
130
- *
131
- * @return Mage_Core_Model_Resource_Config_Data_Collection
132
- */
133
- protected function _getConfigDataCollection()
134
- {
135
- if (null === $this->_configDataCollection) {
136
- $this->_configDataCollection = Mage::getModel('core/resource_config_data_collection');
137
- } else {
138
- $this->_configDataCollection->clear()->getSelect()->reset();
139
- }
140
- return $this->_configDataCollection;
141
- }
142
-
143
- /**
144
- * Get core config data model
145
- *
146
- * @return Mage_Core_Model_Config
147
- */
148
- protected function _getConfigDataModel()
149
- {
150
- if (null === $this->_configDataModel) {
151
- $this->_configDataModel = Mage::getModel('core/config');
152
- }
153
- return $this->_configDataModel;
154
- }
155
-
156
- /**
157
- * Get device static pages
158
- *
159
- * @return array
160
- */
161
- public function getDeviceStaticPages()
162
- {
163
- return $this->_getConfigDataByCategory(Mage_XmlConnect_Model_Application::STATIC_PAGE_CATEGORY, true);
164
- }
165
-
166
- /**
167
- * Get previous localization hash from storage
168
- *
169
- * @return string|null
170
- */
171
- public function getPreviousLocalizationHash()
172
- {
173
- $localizationHashSetting = $this->_getAdminApplicationSettings(
174
- Mage_XmlConnect_Model_Configuration::CONFIG_PATH_AA_SETTINGS . '/localization_hash'
175
- );
176
- return $localizationHashSetting ? $localizationHashSetting['value'] : null;
177
-
178
- }
179
-
180
- /**
181
- * Save localization hash in configuration storage
182
- *
183
- * @param string $hash
184
- * @return Mage_XmlConnect_Model_Configuration
185
- */
186
- public function setPreviousLocalizationHash($hash)
187
- {
188
- $this->_getConfigDataModel()->saveConfig(
189
- Mage_XmlConnect_Model_Configuration::CONFIG_PATH_AA_SETTINGS . '/localization_hash', $hash
190
- );
191
- return $this;
192
- }
193
-
194
- /**
195
- * Get xmlconnect saved config data by category
196
- *
197
- * @param string $category
198
- * @param bool $unSerialize
199
- * @return array
200
- */
201
- protected function _getConfigDataByCategory($category = null, $unSerialize = false)
202
- {
203
- $configuration = $this->_getConnectConfigDataCollection()->addArrayFilter(array(
204
- 'application_id' => $this->getApplicationModel()->getId(),
205
- 'category' => $category,
206
- ))->toOptionArray();
207
- if (!empty($configuration)) {
208
- return $this->_formatConfigData($configuration[$category], $unSerialize, $category);
209
- } else {
210
- return array();
211
- }
212
- }
213
-
214
- /**
215
- * Format config data
216
- *
217
- * @param array $configuration
218
- * @param bool $unSerialize
219
- * @return array
220
- */
221
- protected function _formatConfigData($configuration, $unSerialize = false)
222
- {
223
- $result = array();
224
- foreach ($configuration as $node => $values) {
225
- if ($unSerialize) {
226
- $values = unserialize($values);
227
- }
228
- $result[$node] = $values;
229
- }
230
- return $result;
231
- }
232
-
233
- /**
234
- * Get xmlconnect config data collection
235
- *
236
- * @return Mage_Core_Model_Resource_Config_Data_Collection
237
- */
238
- protected function _getConnectConfigDataCollection()
239
- {
240
- if (null === $this->_configConnectDataCollection) {
241
- $this->_configConnectDataCollection = Mage::getModel('xmlconnect/resource_configData_collection');
242
- } else {
243
- $this->_configConnectDataCollection->clear()->getSelect()->reset(Zend_Db_Select::WHERE);
244
- }
245
- return $this->_configConnectDataCollection;
246
- }
247
-
248
- /**
249
- * Get application model
250
- *
251
- * @return Mage_XmlConnect_Model_Application
252
- */
253
- public function getApplicationModel()
254
- {
255
- if (null === $this->_applicationModel) {
256
- $this->setApplicationModel();
257
- }
258
- return $this->_applicationModel;
259
- }
260
-
261
- /**
262
- * Set application model
263
- *
264
- * @return Mage_XmlConnect_Model_Configuration
265
- */
266
- public function setApplicationModel()
267
- {
268
- $this->_applicationModel = Mage::helper('xmlconnect')->getApplication();
269
- return $this;
270
- }
271
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Device/Abstract.php DELETED
@@ -1,179 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Abstract device model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- abstract class Mage_XmlConnect_Model_Device_Abstract extends Mage_Core_Model_Abstract
35
- {
36
- /**
37
- * Icon image type
38
- */
39
- const IMAGE_TYPE_ICON = 'icon';
40
-
41
- /**
42
- * Icon image type count
43
- */
44
- const IMAGE_TYPE_ICON_COUNT = 1;
45
-
46
- /**
47
- * Banner image type count
48
- */
49
- const IMAGE_TYPE_BANNER_COUNT = 5;
50
-
51
- /**
52
- * Background image count
53
- */
54
- const IMAGE_TYPE_BACKGROUND_COUNT = 1;
55
-
56
- /**
57
- * Application model
58
- *
59
- * @var Mage_XmlConnect_Model_Application
60
- */
61
- protected $_applicationModel;
62
-
63
- /**
64
- * Image size configuration that is the same for all devices
65
- *
66
- * @var array
67
- */
68
- protected $_defaultSizeConfiguration = array(
69
- 'content' => array(
70
- 'product_small' => 70,
71
- 'product_big' => 130,
72
- 'category' => 80,
73
- 'product_gallery_small' => 40
74
- ),
75
- 'tabBar' => array(
76
- 'home' => array('icon' => array('width' => 35, 'height' => 35)),
77
- 'shop' => array('icon' => array('width' => 35, 'height' => 35)),
78
- 'search' => array('icon' => array('width' => 35, 'height' => 35)),
79
- 'cart' => array('icon' => array('width' => 35, 'height' => 35)),
80
- 'more' => array('icon' => array('width' => 35, 'height' => 35))
81
- )
82
- );
83
-
84
- /**
85
- * Initialize model
86
- *
87
- * @param null|Mage_XmlConnect_Model_Application $applicationModel
88
- */
89
- public function __construct($applicationModel = null)
90
- {
91
- $this->_setApplicationModel($applicationModel);
92
- }
93
-
94
- /**
95
- * Return image size configuration for device
96
- *
97
- * @return array
98
- */
99
- abstract protected function _getImageSizeConfiguration();
100
-
101
- /**
102
- * Get application model
103
- *
104
- * @return Mage_XmlConnect_Model_Application
105
- */
106
- protected function _getApplicationModel()
107
- {
108
- if (null !== $this->_applicationModel) {
109
- $this->setApplicationModel(Mage::helper('xmlconnect')->getApplication());
110
- }
111
- return $this->_applicationModel;
112
- }
113
-
114
- /**
115
- * Set application model
116
- *
117
- * @param null|Mage_XmlConnect_Model_Application $applicationModel
118
- * @return Mage_XmlConnect_Model_Device_Abstract
119
- */
120
- protected function _setApplicationModel($applicationModel = null)
121
- {
122
- if ($applicationModel instanceof Mage_XmlConnect_Model_Application) {
123
- $this->_applicationModel = $applicationModel;
124
- } else {
125
- $this->_applicationModel = Mage::helper('xmlconnect')->getApplication();
126
- }
127
- return $this;
128
- }
129
-
130
- /**
131
- * Return default configuration
132
- *
133
- * @return array
134
- */
135
- protected function _getDefaultSizeConfiguration()
136
- {
137
- return $this->_defaultSizeConfiguration;
138
- }
139
-
140
- /**
141
- * Get image size configuration for current device
142
- *
143
- * @return array
144
- */
145
- public function getImageSizeConfig()
146
- {
147
- if (function_exists('array_replace_recursive')) {
148
- return array_replace_recursive($this->_getDefaultSizeConfiguration(), $this->_getImageSizeConfiguration());
149
- } else {
150
- return $this->_arrayReplaceRecursive(
151
- $this->_getDefaultSizeConfiguration(), $this->_getImageSizeConfiguration()
152
- );
153
- }
154
- }
155
-
156
- /**
157
- * Replaces elements from passed arrays into the first array recursively
158
- * Analog of array_replace_recursive()
159
- *
160
- * @param array $base
161
- * @param array $replacements
162
- * @return array
163
- */
164
- protected function _arrayReplaceRecursive(array $base, array $replacements)
165
- {
166
- foreach ($replacements as $key => $value) {
167
- if (!isset($base[$key]) || (isset($base[$key]) && !is_array($base[$key]))) {
168
- $base[$key] = array();
169
- }
170
-
171
- // overwrite the value in the base array
172
- if (is_array($value)) {
173
- $value = $this->_arrayReplaceRecursive($base[$key], $value);
174
- }
175
- $base[$key] = $value;
176
- }
177
- return $base;
178
- }
179
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Device/Android.php DELETED
@@ -1,111 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Android device model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Device_Android extends Mage_XmlConnect_Model_Device_Abstract
35
- {
36
- /**
37
- * Banner image type
38
- */
39
- const IMAGE_TYPE_PORTRAIT_BANNER = 'android_portrait_banner';
40
-
41
- /**
42
- * Android default screen size
43
- */
44
- const SCREEN_SIZE_DEFAULT = '480x800';
45
-
46
- /**
47
- * Android default scale used for calculation rate
48
- */
49
- const DEFAULT_SCALE = 480;
50
-
51
- /**
52
- * Android preview banner width
53
- */
54
- const PREVIEW_BANNER_WIDTH = 320;
55
-
56
- /**
57
- * Android preview banner image height
58
- */
59
- const PREVIEW_BANNER_HEIGHT = 258;
60
-
61
- /**
62
- * Device specific image size configuration
63
- *
64
- * @var array
65
- */
66
- protected $_imageSizeConfiguration = array(
67
- self::IMAGE_TYPE_ICON => array('width' => 53, 'height' => 53),
68
- self::IMAGE_TYPE_PORTRAIT_BANNER => array('width' => 480, 'height' => 387),
69
- 'content' => array('product_gallery_big' => 840),
70
- );
71
-
72
- /**
73
- * Initialize model
74
- *
75
- * @param null|Mage_XmlConnect_Model_Application $applicationModel
76
- */
77
- public function __construct($applicationModel = null)
78
- {
79
- parent::__construct($applicationModel);
80
- }
81
-
82
- /**
83
- * Get Android default screen size
84
- *
85
- * @return string
86
- */
87
- public function getDefaultScreenSize()
88
- {
89
- return self::SCREEN_SIZE_DEFAULT;
90
- }
91
-
92
- /**
93
- * Get Android default scale
94
- *
95
- * @return int
96
- */
97
- public function getDefaultScaleValue()
98
- {
99
- return self::DEFAULT_SCALE;
100
- }
101
-
102
- /**
103
- * Return image size configuration for device
104
- *
105
- * @return array
106
- */
107
- protected function _getImageSizeConfiguration()
108
- {
109
- return $this->_imageSizeConfiguration;
110
- }
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Device/Ipad.php DELETED
@@ -1,174 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect iPad device model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Device_Ipad extends Mage_XmlConnect_Model_Device_Abstract
35
- {
36
- /**
37
- * Portrait banner image type
38
- */
39
- const IMAGE_TYPE_PORTRAIT_BANNER = 'ipad_portrait_banner';
40
-
41
- /**
42
- * Landscape banner image type
43
- */
44
- const IMAGE_TYPE_LANDSCAPE_BANNER = 'ipad_landscape_banner';
45
-
46
- /**
47
- * Portrait background image type
48
- */
49
- const IMAGE_TYPE_PORTRAIT_BACKGROUND = 'ipad_portrait_background';
50
-
51
- /**
52
- * Landscape background image type
53
- */
54
- const IMAGE_TYPE_LANDSCAPE_BACKGROUND = 'ipad_landscape_background';
55
-
56
- /**
57
- * Ipad landscape orientation identificator
58
- */
59
- const ORIENTATION_LANDSCAPE = 'landscape';
60
-
61
- /**
62
- * Ipad portrait orientation identificator
63
- */
64
- const ORIENTATION_PORTRAIT = 'portrait';
65
-
66
- /**
67
- * Ipad portrait preview banner widht
68
- */
69
- const PREVIEW_PORTRAIT_BANNER_WIDTH = 350;
70
-
71
- /**
72
- * Ipad portrait preview banner image height
73
- */
74
- const PREVIEW_PORTRAIT_BANNER_HEIGHT = 135;
75
-
76
- /**
77
- * Ipad landscape preview banner width
78
- */
79
- const PREVIEW_LANDSCAPE_BANNER_WIDTH = 467;
80
-
81
- /**
82
- * Ipad landscape preview banner image height
83
- */
84
- const PREVIEW_LANDSCAPE_BANNER_HEIGHT = 157;
85
-
86
- /**
87
- * Ipad landscape orientation preview image width
88
- */
89
- const PREVIEW_LANDSCAPE_BACKGROUND_WIDTH = 467;
90
-
91
- /**
92
- * Ipad landscape orientation preview image height
93
- */
94
- const PREVIEW_LANDSCAPE_BACKGROUND_HEIGHT = 321;
95
-
96
- /**
97
- * Ipad portrait orientation preview image width
98
- */
99
- const PREVIEW_PORTRAIT_BACKGROUND_WIDTH = 350;
100
-
101
- /**
102
- * Ipad portrait orientation preview image height
103
- */
104
- const PREVIEW_PORTRAIT_BACKGROUND_HEIGHT = 438;
105
-
106
- /**
107
- * Ipad default scale used for calculation rate
108
- */
109
- const DEFAULT_SCALE = 768;
110
-
111
- /**
112
- * Ipad default screen size
113
- */
114
- const SCREEN_SIZE_DEFAULT = '768x1024';
115
-
116
- /**
117
- * Device specific image size configuration
118
- *
119
- * @var array
120
- */
121
- protected $_imageSizeConfiguration = array(
122
- self::IMAGE_TYPE_ICON => array('width' => 35, 'height' => 35),
123
- self::IMAGE_TYPE_PORTRAIT_BANNER => array('width' => 768, 'height' => 294),
124
- self::IMAGE_TYPE_LANDSCAPE_BANNER => array('width' => 1024, 'height' => 344),
125
- self::IMAGE_TYPE_PORTRAIT_BACKGROUND => array('width' => 768, 'height' => 960),
126
- self::IMAGE_TYPE_LANDSCAPE_BACKGROUND => array('width' => 1024, 'height' => 704),
127
- 'content' => array(
128
- 'product_small' => 210,
129
- 'product_big' => 400,
130
- 'category' => 243,
131
- 'product_gallery_big' => 1288,
132
- ),
133
- );
134
-
135
- /**
136
- * Initialize model
137
- *
138
- * @param null|Mage_XmlConnect_Model_Application $applicationModel
139
- */
140
- public function __construct($applicationModel = null)
141
- {
142
- parent::__construct($applicationModel);
143
- }
144
-
145
- /**
146
- * Get iPad default screen size
147
- *
148
- * @return string
149
- */
150
- public function getDefaultScreenSize()
151
- {
152
- return self::SCREEN_SIZE_DEFAULT;
153
- }
154
-
155
- /**
156
- * Get iPad default scale
157
- *
158
- * @return int
159
- */
160
- public function getDefaultScaleValue()
161
- {
162
- return self::DEFAULT_SCALE;
163
- }
164
-
165
- /**
166
- * Return image size configuration for device
167
- *
168
- * @return array
169
- */
170
- protected function _getImageSizeConfiguration()
171
- {
172
- return $this->_imageSizeConfiguration;
173
- }
174
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Device/Iphone.php DELETED
@@ -1,117 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect iPhone device model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Device_Iphone extends Mage_XmlConnect_Model_Device_Abstract
35
- {
36
- /**
37
- * Portrait banner image type
38
- */
39
- const IMAGE_TYPE_PORTRAIT_BANNER = 'iphone_portrait_banner';
40
-
41
- /**
42
- * Portrait background image type
43
- */
44
- const IMAGE_TYPE_PORTRAIT_BACKGROUND = 'iphone_portrait_background';
45
-
46
- /**
47
- * iPhone default scale used for calculation rate
48
- */
49
- const DEFAULT_SCALE = 320;
50
-
51
- /**
52
- * iPhone default screen size
53
- */
54
- const SCREEN_SIZE_DEFAULT = '320x480';
55
-
56
- /**
57
- * Portrait preview banner width
58
- */
59
- const PREVIEW_PORTRAIT_BANNER_WIDTH = '320';
60
-
61
- /**
62
- * Portrait preview banner height
63
- */
64
- const PREVIEW_PORTRAIT_BANNER_HEIGHT = '230';
65
-
66
- /**
67
- * Device specific image size configuration
68
- *
69
- * @var array
70
- */
71
- protected $_imageSizeConfiguration = array(
72
- self::IMAGE_TYPE_ICON => array('width' => 35, 'height' => 35),
73
- self::IMAGE_TYPE_PORTRAIT_BANNER => array('width' => 320, 'height' => 230),
74
- self::IMAGE_TYPE_PORTRAIT_BACKGROUND => array('width' => 320, 'height' => 367),
75
- 'content' => array('product_gallery_big' => 560),
76
- );
77
-
78
- /**
79
- * Initialize model
80
- *
81
- * @param null|Mage_XmlConnect_Model_Application $applicationModel
82
- */
83
- public function __construct($applicationModel = null)
84
- {
85
- parent::__construct($applicationModel);
86
- }
87
-
88
- /**
89
- * Get iPhone default screen size
90
- *
91
- * @return string
92
- */
93
- public function getDefaultScreenSize()
94
- {
95
- return self::SCREEN_SIZE_DEFAULT;
96
- }
97
-
98
- /**
99
- * Get iPhone default scale
100
- *
101
- * @return int
102
- */
103
- public function getDefaultScaleValue()
104
- {
105
- return self::DEFAULT_SCALE;
106
- }
107
-
108
- /**
109
- * Return image size configuration for device
110
- *
111
- * @return array
112
- */
113
- protected function _getImageSizeConfiguration()
114
- {
115
- return $this->_imageSizeConfiguration;
116
- }
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/ImageAction.php DELETED
@@ -1,321 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Images model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_ImageAction extends Mage_Core_Model_Abstract
35
- {
36
-
37
- /**
38
- * Default image action configuration category
39
- */
40
- const IMAGE_ACTION_CATEGORY_DEFAULT = 'image_action';
41
-
42
- /**
43
- * CMS action type
44
- */
45
- const ACTION_TYPE_CMS = 'cms';
46
-
47
- /**
48
- * Product action type
49
- */
50
- const ACTION_TYPE_PRODUCT = 'product';
51
-
52
- /**
53
- * Category action type
54
- */
55
- const ACTION_TYPE_CATEGORY = 'category';
56
-
57
- /**
58
- * Image action types
59
- *
60
- * @var array
61
- */
62
- protected $_imageActionTypes = array(self::ACTION_TYPE_CMS, self::ACTION_TYPE_PRODUCT, self::ACTION_TYPE_CATEGORY);
63
-
64
- /**
65
- * Required image action fields separated by action type
66
- *
67
- * @var array
68
- */
69
- protected $_requiredImageActionFields = array(
70
- self::ACTION_TYPE_CMS => array('action_type','image_id', 'entity_action', 'entity_name'),
71
- self::ACTION_TYPE_PRODUCT => array('action_type', 'image_id', 'entity_action', 'entity_name'),
72
- self::ACTION_TYPE_CATEGORY => array('action_type', 'image_id', 'entity_action', 'entity_name')
73
- );
74
-
75
- /**
76
- * Image action config path template
77
- *
78
- * @var string
79
- */
80
- protected $_imageActionConfigPathTemplate = 'image_id/%d/app_id/%d';
81
-
82
- /**
83
- * Image action data to save
84
- *
85
- * @var array
86
- */
87
- protected $_currentImageActionData;
88
-
89
- /**
90
- * Application model
91
- *
92
- * @var Mage_XmlConnect_Model_Application
93
- */
94
- protected $_applicationModel;
95
-
96
- /**
97
- * Initialize model
98
- *
99
- * @param null|Mage_XmlConnect_Model_Application $applicationModel
100
- */
101
- public function __construct($applicationModel = null)
102
- {
103
- $this->_setApplicationModel($applicationModel);
104
- }
105
-
106
- /**
107
- * Set application model
108
- *
109
- * @param Mage_XmlConnect_Model_Application $applicationModel
110
- * @return Mage_XmlConnect_Model_Device_Abstract
111
- */
112
- protected function _setApplicationModel($applicationModel = null)
113
- {
114
- if ($applicationModel instanceof Mage_XmlConnect_Model_Application) {
115
- $this->_applicationModel = $applicationModel;
116
- } else {
117
- $this->_applicationModel = Mage::helper('xmlconnect')->getApplication();
118
- }
119
- return $this;
120
- }
121
-
122
- /**
123
- * Get application model
124
- *
125
- * @return Mage_XmlConnect_Model_Application
126
- */
127
- protected function _getApplicationModel()
128
- {
129
- if (null === $this->_applicationModel) {
130
- $this->setApplicationModel(Mage::helper('xmlconnect')->getApplication());
131
- }
132
- return $this->_applicationModel;
133
- }
134
-
135
-
136
- /**
137
- * Save image action info
138
- *
139
- * @param array $imageData
140
- * @param string $category
141
- * @return Mage_XmlConnect_Model_Device_Abstract
142
- */
143
- public function saveImageAction($imageData, $category = self::IMAGE_ACTION_CATEGORY_DEFAULT)
144
- {
145
- $this->_setCurrentImageActionData(null)->_validateImagePrepareActionData($imageData);
146
- $actionData = $this->getCurrentImageActionData();
147
- $configPath = $this->_createImageActionConfigPath($actionData['image_id']);
148
- $this->_getApplicationModel()->getConfigModel()->saveConfig($this->_getApplicationModel()->getId(),
149
- array($configPath => serialize($actionData)), $category);
150
- return $this;
151
- }
152
-
153
- /**
154
- * Validate image action by action type and prepare data for save
155
- *
156
- * @throws Mage_Core_Exception
157
- * @param array $imageData
158
- * @return bool
159
- */
160
- protected function _validateImagePrepareActionData($imageData)
161
- {
162
- if (isset($imageData['action_type']) && in_array($imageData['action_type'], $this->_imageActionTypes)) {
163
- if ($imageData['action_type'] == self::ACTION_TYPE_CMS) {
164
- $imageData['entity_name'] = Mage::getModel('cms/page')->load($imageData['entity_action'])->getTitle();
165
- }
166
- $result = array();
167
- foreach ($this->_requiredImageActionFields[$imageData['action_type']] as $requiredField) {
168
- if (empty($imageData[$requiredField])) {
169
- Mage::throwException(Mage::helper('xmlconnect')->__('%s fields is required', $requiredField));
170
- }
171
- $result[$requiredField] = $imageData[$requiredField];
172
- }
173
- $this->_setCurrentImageActionData($result);
174
- return true;
175
- } else {
176
- Mage::throwException(Mage::helper('xmlconnect')->__('Action type does\'t recognized'));
177
- return false;
178
- }
179
- }
180
-
181
- /**
182
- * Create image action config path
183
- *
184
- * @param int $imageId
185
- * @return string
186
- */
187
- protected function _createImageActionConfigPath($imageId)
188
- {
189
- return sprintf($this->_imageActionConfigPathTemplate, $imageId, $this->_getApplicationModel()->getId());
190
- }
191
-
192
- /**
193
- * Set image action data
194
- *
195
- * @param mixed $data
196
- * @return Mage_XmlConnect_Model_Device_Abstract
197
- */
198
- protected function _setCurrentImageActionData($data)
199
- {
200
- $this->_currentImageActionData = $data;
201
- return $this;
202
- }
203
-
204
- /**
205
- * Action data for currently saved image
206
- *
207
- * @return array
208
- */
209
- public function getCurrentImageActionData()
210
- {
211
- return $this->_currentImageActionData;
212
- }
213
-
214
- /**
215
- * Get image action data
216
- *
217
- * @param int $imageId
218
- * @return mixed
219
- */
220
- public function getImageActionData($imageId)
221
- {
222
- $imageActionConfigData = $this->_getApplicationModel()->getConfigModel()->loadScalarValue(
223
- $this->_getApplicationModel()->getId(),
224
- self::IMAGE_ACTION_CATEGORY_DEFAULT,
225
- $this->_createImageActionConfigPath($imageId)
226
- );
227
- $imageActionData = $imageActionConfigData ? unserialize($imageActionConfigData) : $imageActionConfigData;
228
- return $this->_checkImageActionData($imageActionData);
229
- }
230
-
231
- /**
232
- * Check image action data
233
- *
234
- * @throws Mage_Core_Exception
235
- * @param array $imageActionData
236
- * @return mixed
237
- */
238
- protected function _checkImageActionData($imageActionData)
239
- {
240
- if (empty($imageActionData)) {
241
- return;
242
- }
243
- $storeId = Mage::app()->getStore()->getId();
244
- switch ($imageActionData['action_type']) {
245
- case self::ACTION_TYPE_CMS:
246
- $page = Mage::getModel('cms/page')->setStoreId($storeId)
247
- ->load($imageActionData['entity_action'], 'identifier');
248
- if (!$page->getId() && $storeId == Mage_Core_Model_App::ADMIN_STORE_ID) {
249
- $this->deleteAction($imageActionData['image_id']);
250
- return;
251
- } elseif ($page->getId()) {
252
- $imageActionData['entity_name'] = $page->getTitle();
253
- }
254
- break;
255
- case self::ACTION_TYPE_CATEGORY:
256
- $category = Mage::getModel('catalog/category')->load($imageActionData['entity_action']);
257
- if (!$category->getId()) {
258
- $this->deleteAction($imageActionData['image_id']);
259
- return;
260
- } elseif ($category->getIsActive() == 0 && Mage_Core_Model_App::ADMIN_STORE_ID != $storeId) {
261
- return;
262
- } else {
263
- $imageActionData['entity_name'] = $category->getName();
264
- }
265
- break;
266
- case self::ACTION_TYPE_PRODUCT:
267
- $product = Mage::getModel('catalog/product')->load($imageActionData['entity_action']);
268
- if (!$product->getId()) {
269
- $this->deleteAction($imageActionData['image_id']);
270
- return;
271
- } elseif ($product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED
272
- && Mage_Core_Model_App::ADMIN_STORE_ID != $storeId
273
- ) {
274
- return;
275
- } else {
276
- $imageActionData['entity_name'] = $product->getName();
277
- }
278
- break;
279
- default:
280
- Mage::throwException($this->__('Action type doesn\'t recognized.'));
281
- break;
282
- }
283
- return $imageActionData;
284
- }
285
-
286
- /**
287
- * Delete Image action
288
- *
289
- * @param int $imageId
290
- * @return Mage_XmlConnect_Model_ImageAction
291
- */
292
- public function deleteAction($imageId)
293
- {
294
- $this->_getApplicationModel()->getConfigModel()->deleteConfig($this->_getApplicationModel()->getId(),
295
- self::IMAGE_ACTION_CATEGORY_DEFAULT, $this->_createImageActionConfigPath($imageId));
296
- return $this;
297
- }
298
-
299
- /**
300
- * Save images new order
301
- *
302
- * @param array $imagesOrderData
303
- * @param string $type
304
- * @return Mage_XmlConnect_Model_ImageAction
305
- */
306
- public function saveImageOrder($imagesOrderData, $type)
307
- {
308
- if (empty($imagesOrderData)) {
309
- return $this;
310
- }
311
- /** @var $imagesModel Mage_XmlConnect_Model_Images */
312
- $imagesModel = Mage::getModel('xmlconnect/images');
313
- foreach ($imagesOrderData as $imageId => $imageOrder) {
314
- $imagesModel->load($imageId);
315
- if ($imagesModel->getImageId()) {
316
- $imagesModel->setOrder($imageOrder)->save();
317
- }
318
- }
319
- return $this;
320
- }
321
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/ImageLimits.php DELETED
@@ -1,366 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Image Limits model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_ImageLimits extends Mage_Core_Model_Abstract
35
- {
36
- /**
37
- * Screen size update type glue
38
- */
39
- const SCREEN_SIZE_UPDATE_TYPE_GLUE = '_';
40
-
41
- /**
42
- * Screen size glue
43
- */
44
- const SCREEN_SIZE_GLUE = 'x';
45
-
46
- /**
47
- * Maximum allowed screen sizes
48
- */
49
- const MAX_ALLOWED_SCREEN_SIZES = 2560;
50
-
51
- /**
52
- * Current screen size
53
- *
54
- * @var string
55
- */
56
- protected $_screenSize;
57
-
58
- /**
59
- * Current screen rate
60
- *
61
- * @var float
62
- */
63
- protected $_screenRate;
64
-
65
- /**
66
- * Update type
67
- *
68
- * @var string
69
- */
70
- protected $_updateType;
71
-
72
- /**
73
- * Screen size image limits array
74
- *
75
- * @var array
76
- */
77
- protected $_imageLimits = array();
78
-
79
- /**
80
- * Screen size config update model
81
- *
82
- * @var Mage_XmlConnect_Model_ImageLimits_Abstract
83
- */
84
- protected $_sizeModel;
85
-
86
- /**
87
- * Application model
88
- *
89
- * @var Mage_XmlConnect_Model_Application
90
- */
91
- protected $_applicationModel;
92
-
93
- /**
94
- * Initialize model
95
- *
96
- * @param null|Mage_XmlConnect_Model_Application $applicationModel
97
- */
98
- public function __construct($applicationModel = null)
99
- {
100
- parent::_construct();
101
- $this->_setApplicationModel($applicationModel)->_setScreenSize()->_initSizeModel();
102
- }
103
-
104
- /**
105
- * Set application model
106
- *
107
- * @param Mage_XmlConnect_Model_Application $applicationModel
108
- * @return Mage_XmlConnect_Model_Device_Abstract
109
- */
110
- protected function _setApplicationModel($applicationModel = null)
111
- {
112
- if ($applicationModel instanceof Mage_XmlConnect_Model_Application) {
113
- $this->_applicationModel = $applicationModel;
114
- } else {
115
- $this->_applicationModel = Mage::helper('xmlconnect')->getApplication();
116
- }
117
- return $this;
118
- }
119
-
120
- /**
121
- * Get application model
122
- *
123
- * @return Mage_XmlConnect_Model_Application
124
- */
125
- protected function _getApplicationModel()
126
- {
127
- if (null === $this->_applicationModel) {
128
- $this->setApplicationModel(Mage::helper('xmlconnect')->getApplication());
129
- }
130
- return $this->_applicationModel;
131
- }
132
-
133
- /**
134
- * Do steps to set current screen size and image limits configuration
135
- *
136
- * @param string $screenSize
137
- * @return Mage_XmlConnect_Model_ImageLimits
138
- */
139
- protected function _doUpdateConfig($screenSize = '')
140
- {
141
- $this->_setScreenSize($screenSize)->_initSizeModel()->_afterCalculate();
142
- return $this;
143
- }
144
-
145
- /**
146
- * Set screen current screen siz
147
- *
148
- * @param string $screenSize
149
- * @return Mage_XmlConnect_Model_ImageLimits
150
- */
151
- protected function _setScreenSize($screenSize = '')
152
- {
153
- /** @var $applicationModel Mage_XmlConnect_Model_Application */
154
- $applicationModel = Mage::helper('xmlconnect')->getApplication();
155
- if (!$screenSize) {
156
- $screenSize = $applicationModel->getScreenSize();
157
- }
158
-
159
- if (isset($this->_imageLimits[$screenSize])) {
160
- return $this;
161
- }
162
-
163
- $screenSizeExplodeArray = explode(self::SCREEN_SIZE_UPDATE_TYPE_GLUE, $screenSize);
164
- switch (count($screenSizeExplodeArray)) {
165
- case 2:
166
- $this->_updateType = $screenSizeExplodeArray[1];
167
- case 1:
168
- $this->_screenSize = $screenSizeExplodeArray[0];
169
- break;
170
- default:
171
- $this->_screenSize = $applicationModel->getScreenSize();
172
- break;
173
- }
174
- $this->_checkMaximumAllowedSize();
175
- return $this;
176
- }
177
-
178
- /**
179
- * Check maximum allowed screen size for devices
180
- *
181
- * @throws Mage_Core_Exception
182
- * @return Mage_XmlConnect_Model_ImageLimits
183
- */
184
- protected function _checkMaximumAllowedSize()
185
- {
186
- $screenSizeArray = explode(self::SCREEN_SIZE_GLUE, $this->_screenSize);
187
- if (count($screenSizeArray) != 2 || $screenSizeArray[0] > self::MAX_ALLOWED_SCREEN_SIZES
188
- || $screenSizeArray[1] > self::MAX_ALLOWED_SCREEN_SIZES
189
- ) {
190
- Mage::throwException(Mage::helper('xmlconnect')->__('Screen resolution is not supported'));
191
- }
192
- return $this;
193
- }
194
-
195
- /**
196
- * Init image limit configuration model
197
- *
198
- * @throws Mage_Core_Exception
199
- * @return Mage_XmlConnect_Model_ImageLimits
200
- */
201
- protected function _initSizeModel()
202
- {
203
- $defaultScreenSize = $this->_getApplicationModel()->getDeviceModel()->getDefaultScreenSize();
204
-
205
- if ($this->_screenSize && $this->_screenSize != $defaultScreenSize) {
206
- if (!$this->getSizeModel()) {
207
- $modelClass = Mage::getConfig()->getModelClassName('xmlconnect/imageLimits_' . $this->_screenSize);
208
- if (class_exists($modelClass, false) || mageFindClassFile($modelClass)) {
209
- $sizeModel = Mage::getModel('xmlconnect/imageLimits_' . $this->_screenSize, $this->_updateType);
210
- $this->setSizeModel($sizeModel);
211
- }
212
- }
213
- $this->_calculateImageLimits()->_afterCalculate();
214
- } else {
215
- $this->_setScreenSize($defaultScreenSize)->_setDefaultSizeModel();
216
- }
217
- return $this;
218
- }
219
-
220
- /**
221
- * Set default image size model
222
- *
223
- * @return Mage_XmlConnect_Model_ImageLimits
224
- */
225
- protected function _setDefaultSizeModel()
226
- {
227
- $defaultSizeModel = $this->_getApplicationModel()->getDeviceModel();
228
- $this->_imageLimits[$this->_screenSize] = $defaultSizeModel->getImageSizeConfig();
229
- return $this;
230
- }
231
-
232
- /**
233
- * After calculate image limits screen size update
234
- *
235
- * @return Mage_XmlConnect_Model_ImageLimits
236
- */
237
- protected function _afterCalculate()
238
- {
239
- if (isset($this->_imageLimits[$this->_screenSize])) {
240
- return $this;
241
- }
242
- $this->_imageLimits[$this->_screenSize] = $this->getSizeModel()->getScreenSizeConfig();
243
- return $this;
244
- }
245
-
246
- /**
247
- * Calculate image limits for current screen size
248
- *
249
- * @return Mage_XmlConnect_Model_ImageLimits
250
- */
251
- protected function _calculateImageLimits()
252
- {
253
- $defaultSizeModel = $this->_getApplicationModel()->getDeviceModel();
254
- $sizeModel = $this->getSizeModel();
255
-
256
- $updatedConfiguration = $this->_calculateImageRate()->_updateConfigByRate(
257
- $defaultSizeModel->getImageSizeConfig()
258
- );
259
-
260
- if (!$sizeModel) {
261
- $this->_imageLimits[$this->_screenSize] = $updatedConfiguration;
262
- } else {
263
- $sizeModel->setConfig($updatedConfiguration);
264
- }
265
- return $this;
266
- }
267
-
268
- /**
269
- * Calculate image rate
270
- *
271
- * @return Mage_XmlConnect_Model_ImageLimits
272
- */
273
- protected function _calculateImageRate()
274
- {
275
- $defaultScaleValue = $this->_getApplicationModel()->getDeviceModel()->getDefaultScaleValue();
276
-
277
- list($width, $height) = explode(self::SCREEN_SIZE_GLUE, $this->_screenSize);
278
- // Calculate rate for current resolution
279
- $this->_screenRate = min($width, $height) / $defaultScaleValue;
280
-
281
- return $this;
282
- }
283
-
284
- /**
285
- * Update image limits based on device default screen size
286
- *
287
- * @param array $defaultValues
288
- * @return array
289
- */
290
- protected function _updateConfigByRate($defaultValues)
291
- {
292
- foreach ($defaultValues as $key => $value) {
293
- if (is_array($value)) {
294
- $defaultValues[$key] = $this->_updateConfigByRate($value);
295
- } else {
296
- $defaultValues[$key] = round($value * $this->_screenRate);
297
- }
298
- }
299
- return $defaultValues;
300
- }
301
-
302
- /**
303
- * Get screen size config update model
304
- *
305
- * @return Mage_XmlConnect_Model_ImageLimits_Abstract
306
- */
307
- public function getSizeModel()
308
- {
309
- return $this->_sizeModel;
310
- }
311
-
312
- /**
313
- * Set screen size config update model
314
- *
315
- * @param object $sizeModel
316
- * @return Mage_XmlConnect_Model_ImageLimits
317
- */
318
- public function setSizeModel($sizeModel)
319
- {
320
- $this->_sizeModel = $sizeModel;
321
- return $this;
322
- }
323
-
324
- /**
325
- * Get image limits config
326
- *
327
- * @return array
328
- */
329
- public function getImageLimits()
330
- {
331
- return $this->_imageLimits;
332
- }
333
-
334
- /**
335
- * Set image limits config
336
- *
337
- * @param array $imageLimits
338
- * @return Mage_XmlConnect_Model_ImageLimits
339
- */
340
- public function setImageLimits($imageLimits)
341
- {
342
- $this->_imageLimits = $imageLimits;
343
- return $this;
344
- }
345
-
346
- /**
347
- * Get image limits by type
348
- *
349
- * @param string $key
350
- * @param null|string $index
351
- * @param string $screenSize
352
- * @return mixed
353
- */
354
- public function getImageLimitsByType($key = '', $index = null, $screenSize = '')
355
- {
356
- if ($screenSize && !isset($this->_imageLimits[$screenSize])) {
357
- $this->_doUpdateConfig($screenSize);
358
- }
359
-
360
- $this->setData($this->_imageLimits[$this->_screenSize]);
361
- $result = $this->getData($key, $index);
362
- $this->unsetData();
363
-
364
- return $result;
365
- }
366
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/ImageLimits/Abstract.php DELETED
@@ -1,295 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Abstract Image Limit model for screen size resolution config
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- abstract class Mage_XmlConnect_Model_ImageLimits_Abstract extends Mage_Core_Model_Abstract
35
- {
36
- /**
37
- * Default update type
38
- *
39
- * @var array
40
- */
41
- protected $_defaultUpdateType = array();
42
-
43
- /**
44
- * Current update params (based on a current screen size)
45
- *
46
- * @var array
47
- */
48
- protected $_currentUpdate = array();
49
-
50
- /**
51
- * Current configuration
52
- *
53
- * @var array
54
- */
55
- protected $_configuration = array();
56
-
57
- /**
58
- * Config updated flag
59
- *
60
- * @var bool
61
- */
62
- protected $_configUpdatedFlag = false;
63
-
64
- /**
65
- * Initialize resource model
66
- *
67
- * @param string $updateType
68
- */
69
- public function __construct($updateType)
70
- {
71
- $this->_setCurrentUpdate($updateType)->_setDefaultConfig();
72
- }
73
-
74
- /**
75
- * Set default configuration params for current device
76
- *
77
- * @return Mage_XmlConnect_Model_ImageLimits_Abstract
78
- */
79
- protected function _setDefaultConfig()
80
- {
81
- $deviceModel = Mage::helper('xmlconnect')->getApplication()->getDeviceModel();
82
- $this->_configuration = $deviceModel->getImageSizeConfig();
83
- return $this;
84
- }
85
-
86
- /**
87
- * Set configuration for current device
88
- *
89
- * @param array $data
90
- * @return Mage_XmlConnect_Model_ImageLimits_Abstract
91
- */
92
- public function setConfig($data)
93
- {
94
- $this->_configuration = $data;
95
- return $this;
96
- }
97
-
98
- /**
99
- * Set update type
100
- *
101
- * @param string $updateType
102
- * @return Mage_XmlConnect_Model_ImageLimits_Abstract
103
- */
104
- protected function _setCurrentUpdate($updateType)
105
- {
106
- if (isset($this->{'_' . $updateType . 'UpdateType'})) {
107
- $this->_currentUpdate = $this->{'_' . $updateType . 'UpdateType'};
108
- } else {
109
- $this->_currentUpdate = $this->_defaultUpdateType;
110
- }
111
- return $this;
112
- }
113
-
114
- /**
115
- * Get config for current screen size
116
- *
117
- * @return array
118
- */
119
- public function getScreenSizeConfig()
120
- {
121
- if (!$this->_isConfigUpdated()) {
122
- $this->_doUpdateConfig();
123
- $this->_configUpdatedFlag = true;
124
- }
125
- return $this->_configuration;
126
- }
127
-
128
- /**
129
- * Update config for current screen size
130
- *
131
- * @return array
132
- */
133
- protected function _doUpdateConfig()
134
- {
135
- if (!$this->_currentUpdate) {
136
- return $this->_configuration;
137
- }
138
-
139
- foreach ($this->_currentUpdate as $function => $params) {
140
- $this->_doFunctionUpdate($function, $params);
141
- }
142
-
143
- return $this->_configuration;
144
- }
145
-
146
- /**
147
- * Update config using custom update function
148
- *
149
- * @param string $function
150
- * @param array $params
151
- * @return Mage_XmlConnect_Model_ImageLimits_Abstract
152
- */
153
- protected function _doFunctionUpdate($function, $params)
154
- {
155
- foreach ($params as $param) {
156
- $data = $param['data'];
157
- $path = $param['path'];
158
-
159
- $target =& $this->findPath($this->_configuration, $path);
160
- switch ($function) {
161
- case 'zoom':
162
- if (is_array($target)) {
163
- array_walk_recursive($target, array($this, '_zoom'), $data);
164
- } else {
165
- $this->_zoom($target, null, $data);
166
- }
167
- break;
168
- case 'update':
169
- $this->_update($target, $data);
170
- break;
171
- case 'insert':
172
- $this->_insert($target, $data, false);
173
- break;
174
- case 'insert_force':
175
- $this->_insert($target, $data);
176
- break;
177
- case 'delete':
178
- $this->_delete($target, $data);
179
- break;
180
- default:
181
- break;
182
- }
183
- }
184
- return $this;
185
- }
186
-
187
- /**
188
- * Get config updated flag state
189
- *
190
- * @return bool
191
- */
192
- protected function _isConfigUpdated()
193
- {
194
- return $this->_configUpdatedFlag;
195
- }
196
-
197
- /**
198
- * Return reference to the $path in $array
199
- *
200
- * @param array &$array
201
- * @param string $path
202
- * @return mixed reference
203
- */
204
- public function &findPath(&$array, $path)
205
- {
206
- $target =& $array;
207
- if ($path !== '/') {
208
- $pathArray = explode('/', $path);
209
- foreach ($pathArray as $node) {
210
- if (is_array($target) && isset($target[$node])) {
211
- $target =& $target[$node];
212
- } else {
213
- return null;
214
- }
215
- }
216
- }
217
- return $target;
218
- }
219
-
220
- /**
221
- * Insert value(s) in array
222
- *
223
- * @param mixed &$target old value(s)
224
- * @param mixed $data new value(s)
225
- * @param bool $force
226
- * @return null
227
- */
228
- protected function _insert(&$target, $data, $force = true)
229
- {
230
- if (is_array($target) && is_array($data)) {
231
- foreach ($data as $key => $val) {
232
- if (!$force && isset($target[$key])) {
233
- continue;
234
- }
235
- $target[$key] = $val;
236
- }
237
- }
238
- }
239
-
240
- /**
241
- * Update array value(s) by reference
242
- *
243
- * @param mixed &$target old value(s)
244
- * @param mixed $data new value(s)
245
- * @return null
246
- */
247
- protected function _update(&$target, $data)
248
- {
249
- if (is_array($target) && is_array($data)) {
250
- $data = array_intersect_key($data, $target);
251
- foreach ($data as $key => $val) {
252
- $target[$key] = $val;
253
- }
254
- } elseif (is_array($target)) {
255
- foreach ($target as $key => $val) {
256
- $target[$key] = $data;
257
- }
258
- } elseif ($target) {
259
- $target = $data;
260
- }
261
- }
262
-
263
- /**
264
- * Delete given key(s) from array
265
- *
266
- * @param array &$item
267
- * @param string|array $value items to delete
268
- * @return null
269
- */
270
- protected function _delete(&$item, $value)
271
- {
272
- if (is_array($value)) {
273
- foreach ($value as $keyToDelete) {
274
- unset($item[$keyToDelete]);
275
- }
276
- return;
277
- }
278
- unset($item[$value]);
279
- }
280
-
281
- /**
282
- * Multiply given $item by $value if it's a string
283
- *
284
- * @param mixed &$item (argument to change)
285
- * @param mixed $key (used with array_walk_recursive function as a key of given array)
286
- * @param string $value (contains float)
287
- * @return null
288
- */
289
- protected function _zoom(&$item, $key, $value)
290
- {
291
- if (is_scalar($item)) {
292
- $item = (int) round($item * $value);
293
- }
294
- }
295
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Images.php DELETED
@@ -1,551 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Images model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Images extends Mage_Core_Model_Abstract
35
- {
36
- /**
37
- * Array of required submit data
38
- *
39
- * @var array
40
- */
41
- protected $_requiredSubmitData = array('application_id', 'image_type', 'order');
42
-
43
- /**
44
- * Initialize resource model
45
- */
46
- protected function _construct()
47
- {
48
- $this->_init('xmlconnect/images');
49
- parent::_construct();
50
- }
51
-
52
- /**
53
- * Delete item and repair order of images
54
- *
55
- * @return Mage_XmlConnect_Model_Images
56
- */
57
- public function deleteAndRepairOrder()
58
- {
59
- Mage::helper('xmlconnect')->getApplication()->getImageActionModel()->deleteAction($this->getId());
60
- $this->delete()->_deleteImageFiles($this->getImageFile())->getResource()->repairOrder($this);
61
- return $this;
62
- }
63
-
64
- /**
65
- * Delete image action
66
- *
67
- * @return Mage_XmlConnect_Model_Images
68
- */
69
- public function deleteImageAction()
70
- {
71
- Mage::helper('xmlconnect')->getApplication()->getImageActionModel()->deleteAction($this->getId());
72
- return $this;
73
- }
74
-
75
- /**
76
- * Remove all image files
77
- *
78
- * @param string $imageFile
79
- * @param bool $deleteOriginal
80
- * @return Mage_XmlConnect_Model_Images
81
- */
82
- protected function _deleteImageFiles($imageFile, $deleteOriginal = true)
83
- {
84
- $convertedImageFile = $this->_convertFileExtensionToPng($imageFile);
85
- $ioAdapter = new Varien_Io_File();
86
- $baseImageDir = Mage::helper('xmlconnect/image')->getMediaPath('custom');
87
- if (is_dir($baseImageDir)) {
88
- $dirArray = array_diff(scandir($baseImageDir), array('.', '..'));
89
- foreach ($dirArray as $item) {
90
- if (!is_dir($baseImageDir . DS . $item)) {
91
- continue;
92
- }
93
- $ioAdapter->rm($baseImageDir . DS . $item . DS . basename($convertedImageFile));
94
- }
95
- }
96
- if ($deleteOriginal) {
97
- $ioAdapter->rm(self::getBasePath() . DS . basename($imageFile));
98
- }
99
- return $this;
100
- }
101
-
102
- /**
103
- * Check image type
104
- *
105
- * @param string $type
106
- * @return Mage_XmlConnect_Model_Images
107
- */
108
- public function checkType($type = '')
109
- {
110
- if ($type) {
111
- $this->setImageType($type);
112
- }
113
-
114
- if (!$this->getImageType()) {
115
- Mage::throwException(Mage::helper('xmlconnect')->__('Image type is required.'));
116
- }
117
- return $this;
118
- }
119
-
120
- /**
121
- * Get image count for image type
122
- *
123
- * @param string $type
124
- * @return int
125
- */
126
- public function getImageCount($type = '')
127
- {
128
- if (!$type) {
129
- $type = $this->getImageType();
130
- }
131
- return Mage::helper('xmlconnect')->getDeviceHelper()->getImageCount($type);
132
- }
133
-
134
- /**
135
- * Check is application record exists
136
- *
137
- * @param int $appId
138
- * @return Mage_XmlConnect_Model_Images
139
- */
140
- public function checkApplication($appId = 0)
141
- {
142
- if (!$appId) {
143
- $appId = $this->getApplicationId();
144
- }
145
-
146
- $appModel = Mage::getModel('xmlconnect/application')->load($appId);
147
- if (!$appModel->getId()) {
148
- Mage::throwException(Mage::helper('xmlconnect')->__('Application doesn\'t exist.'));
149
- }
150
- return $this;
151
- }
152
-
153
- /**
154
- * Validate submit data
155
- *
156
- * @param array $data
157
- * @return Mage_XmlConnect_Model_Images
158
- */
159
- public function validateAndSetSubmitData($data)
160
- {
161
- foreach ($this->_requiredSubmitData as $submitValue) {
162
- if (empty($data[$submitValue])) {
163
- Mage::throwException(Mage::helper('xmlconnect')->__('Image %s is required.', $submitValue));
164
- } else {
165
- $this->setData($submitValue, $data[$submitValue]);
166
- }
167
- }
168
- return $this;
169
- }
170
-
171
- /**
172
- * Retrieve Base files path
173
- *
174
- * @param string $filePath
175
- * @return string
176
- */
177
- public static function getBasePath($filePath = '')
178
- {
179
- if ($filePath && strpos($filePath, DS) !== 0) {
180
- $filePath = DS . $filePath;
181
- }
182
- return Mage::getBaseDir('media') . DS . 'xmlconnect' . DS . 'original' . $filePath;
183
- }
184
-
185
- /**
186
- * Get original image url
187
- *
188
- * @param string $image
189
- * @return string
190
- */
191
- public function getImageUrl($image = '')
192
- {
193
- if ($image && strpos($image, '/') !== 0) {
194
- $image = '/' . $image;
195
- }
196
-
197
- return Mage::getBaseUrl('media') . 'xmlconnect/original' . $image;
198
- }
199
-
200
- /**
201
- * Get device image array by type
202
- *
203
- * @param string $type
204
- * @param int $limit
205
- * @param int $offset
206
- * @return array
207
- */
208
- public function getDeviceImagesByType($type, $limit = null, $offset = null)
209
- {
210
- if (!$this->getApplicationId()) {
211
- $this->setApplicationId(Mage::helper('xmlconnect')->getApplicationId());
212
- }
213
- return $this->getCollection()->addApplicationToFilter($this->getApplicationId())->addImageTypeToFilter($type)
214
- ->setPositionOrder()->setLimit($limit, $offset)->getData();
215
- }
216
-
217
- /**
218
- * Get device image by type
219
- *
220
- * @param string $type
221
- * @return array|bool
222
- */
223
- public function getImageItemByType($type)
224
- {
225
- if (!$this->getApplicationId()) {
226
- $this->setApplicationId(Mage::helper('xmlconnect')->getApplicationId());
227
- }
228
- return $this->getCollection()->addApplicationToFilter($this->getApplicationId())->addImageTypeToFilter($type)
229
- ->setPositionOrder()->fetchItem();
230
- }
231
-
232
- /**
233
- * Check is image exists in original folder
234
- *
235
- * @param string $imagePath
236
- * @return bool
237
- */
238
- protected function _checkImageExists($imagePath)
239
- {
240
- $image = new Varien_Io_File();
241
- return $image->fileExists(self::getBasePath() . $imagePath);
242
- }
243
-
244
- /**
245
- * Retrieve custom size image url
246
- *
247
- * @param string $imageFile
248
- * @param int $width
249
- * @param int $height
250
- * @return string|bool
251
- */
252
- public function getCustomSizeImageUrl($imageFile, $width = 100, $height = 100)
253
- {
254
- /** @var $imageHelper Mage_XmlConnect_Helper_Image */
255
- $imageHelper = Mage::helper('xmlconnect/image');
256
- $screenSize = $width . 'x' . $height;
257
- $customDir = $imageHelper->getMediaPath('custom' . DS . $screenSize);
258
- $ioFile = new Varien_Io_File();
259
- $ioFile->checkAndCreateFolder($customDir);
260
- $filePath = self::getBasePath() . DS . $imageFile;
261
- $isImagePng = true;
262
-
263
- if (!$ioFile->fileExists($filePath)) {
264
- return false;
265
- }
266
-
267
- $originalImageType = $this->_getImageType($filePath);
268
- if ($originalImageType !== IMAGETYPE_PNG) {
269
- $imageFile = $this->_convertFileExtensionToPng($imageFile);
270
- $isImagePng = false;
271
- }
272
-
273
- $customSizeFile = $customDir . DS . $imageFile;
274
- if (!file_exists($customSizeFile)) {
275
- if (!$isImagePng) {
276
- $filePath = $this->_forcedConvertPng($filePath, $customSizeFile, $originalImageType);
277
- }
278
-
279
- $image = new Varien_Image($filePath);
280
- $widthOriginal = $image->getOriginalWidth();
281
- $heightOriginal = $image->getOriginalHeight();
282
-
283
- if ($width != $widthOriginal) {
284
- $widthOriginal = $width;
285
- }
286
-
287
- if ($height != $heightOriginal) {
288
- $heightOriginal = $height;
289
- }
290
-
291
- if (($widthOriginal != $image->getOriginalWidth()) || ($heightOriginal != $image->getOriginalHeight()) ) {
292
- $image->keepTransparency(true);
293
- $image->keepFrame(true);
294
- $image->keepAspectRatio(true);
295
- $image->backgroundColor(array(0, 0, 0));
296
- $image->resize($widthOriginal, $heightOriginal);
297
- $image->save($customDir, basename($imageFile));
298
- } else {
299
- $ioFile->cp($filePath, $customSizeFile);
300
- }
301
- }
302
- return $imageHelper->getMediaUrl("custom/{$screenSize}/" . basename($imageFile));
303
- }
304
-
305
- /**
306
- * Save image data
307
- *
308
- * @param int $applicationId
309
- * @param string $imageFile
310
- * @param string $imageType
311
- * @param int $order
312
- * @return Mage_XmlConnect_Model_Images
313
- */
314
- public function saveImage($applicationId, $imageFile, $imageType, $order)
315
- {
316
- $this->getResource()->saveImage($applicationId, $imageFile, $imageType, $order);
317
- return $this;
318
- }
319
-
320
- /**
321
- * Add image node to the config
322
- * Used for backward compatibility only
323
- *
324
- * @param array $config
325
- * @return Mage_XmlConnect_Model_Images
326
- */
327
- public function loadOldImageNodes(&$config)
328
- {
329
- $iconImageFile = $this->getImageItemByType(Mage_XmlConnect_Model_Device_Abstract::IMAGE_TYPE_ICON);
330
-
331
- if (is_object($iconImageFile) && $iconImageFile->getImageFile()) {
332
- $iconImageType = Mage_XmlConnect_Model_Device_Abstract::IMAGE_TYPE_ICON;
333
- $config['navigationBar']['icon'] = $this->getCustomSizeImageUrl(
334
- $iconImageFile->getImageFile(),
335
- $this->getImageLimitParam($iconImageType, 'width'),
336
- $this->getImageLimitParam($iconImageType, 'height')
337
- );
338
- }
339
-
340
- $imageArray = $this->_getOldConfigImageNodeArray();
341
- $imageArray = $imageArray[Mage::helper('xmlconnect')->getDeviceType()];
342
- foreach ($imageArray as $node => $imageType) {
343
- $imageFile = $this->getImageItemByType($imageType);
344
- if (!is_object($imageFile) || !$imageFile->getImageFile()) {
345
- continue;
346
- }
347
- $config['body'][$node] = $this->getCustomSizeImageUrl(
348
- $imageFile->getImageFile(),
349
- $this->getImageLimitParam($imageType, 'width'),
350
- $this->getImageLimitParam($imageType, 'height')
351
- );
352
- }
353
- return $this;
354
- }
355
-
356
- /**
357
- * Get image url for current screen size
358
- *
359
- * @param $imageFile
360
- * @param $imageType
361
- * @return bool|string
362
- */
363
- public function getScreenSizeImageUrlByType($imageFile, $imageType)
364
- {
365
- if (is_numeric($this->getImageLimitParam($imageType))) {
366
- $width = $height = $this->getImageLimitParam($imageType);
367
- } else {
368
- $width = $this->getImageLimitParam($imageType, 'width');
369
- $height = $this->getImageLimitParam($imageType, 'height');
370
- }
371
- if (!is_numeric($width) || !is_numeric($height)) {
372
- Mage::throwException(Mage::helper('xmlconnect')->__('Image limits don\'t recognized for "%s" image type', $imageType));
373
- }
374
-
375
- return $this->getCustomSizeImageUrl($imageFile, $width, $height);
376
- }
377
-
378
- /**
379
- * Get image limit param value
380
- *
381
- * @param string $imageType
382
- * @param string|null $key
383
- * @param string $screenSize
384
- * @return mixed
385
- */
386
- public function getImageLimitParam($imageType = '', $key = null, $screenSize = '')
387
- {
388
- return $this->getImageLimitsModel()->getImageLimitsByType($imageType, $key, $screenSize);
389
- }
390
-
391
- /**
392
- * Get Image Limits model
393
- *
394
- * @return Mage_XmlConnect_Model_ImageLimits
395
- */
396
- public function getImageLimitsModel()
397
- {
398
- return Mage::helper('xmlconnect')->getApplication()->getImageLimitsModel();
399
- }
400
-
401
- /**
402
- * Get old config image node for devices
403
- *
404
- * @return array
405
- */
406
- protected function _getOldConfigImageNodeArray()
407
- {
408
- // array as old config node => new image type (separated by device types)
409
- return array(
410
- Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID => array(
411
- 'bannerAndroidImage' => Mage_XmlConnect_Model_Device_Android::IMAGE_TYPE_PORTRAIT_BANNER
412
- ),
413
- Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPHONE => array(
414
- 'bannerImage' => Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_PORTRAIT_BANNER,
415
- 'backgroundImage' => Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_PORTRAIT_BACKGROUND
416
- ),
417
- Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD => array(
418
- 'bannerIpadLandscapeImage' => Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_LANDSCAPE_BANNER,
419
- 'bannerIpadImage' => Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_PORTRAIT_BANNER,
420
- 'backgroundIpadLandscapeImage' => Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_LANDSCAPE_BACKGROUND,
421
- 'backgroundIpadPortraitImage' => Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_PORTRAIT_BACKGROUND
422
- )
423
- );
424
- }
425
-
426
- /**
427
- * Update old image records in database
428
- * For data upgrade usage only
429
- *
430
- * @see data upgrade file: mysql4-data-upgrade-1.6.0.0-1.6.0.0.1.php
431
- * @param array $records
432
- * @return null
433
- */
434
- public function dataUpgradeOldConfig($records)
435
- {
436
- // array as old config node => new image type (separated by device types)
437
- $oldConfigPathByDeviceType = $this->_getOldConfigImageNodeArray();
438
-
439
- /** @var $applicationModel Mage_XmlConnect_Model_Application */
440
- $applicationModel = Mage::getModel('xmlconnect/application');
441
-
442
- /** @var $configModel Mage_XmlConnect_Model_ConfigData */
443
- $configModel = $applicationModel->getConfigModel();
444
- $deprecatedFlag = Mage_XmlConnect_Model_Application::DEPRECATED_CONFIG_FLAG;
445
-
446
- foreach ($records as $application_id) {
447
- /** @var $applicationModel Mage_XmlConnect_Model_Application */
448
- $applicationModel->load($application_id);
449
- $configPathList = $oldConfigPathByDeviceType[$applicationModel->getType()];
450
- $configData = $configModel->loadApplicationData($application_id);
451
-
452
- // old icon config path
453
- $iconConfigPath = 'native/navigationBar/icon';
454
- if (!empty($configData[$deprecatedFlag][$iconConfigPath])) {
455
- // Add icon to image table
456
- $iconFile = basename($configData[$deprecatedFlag][$iconConfigPath]);
457
- $this->saveImage(
458
- $application_id, $iconFile, Mage_XmlConnect_Model_Device_Abstract::IMAGE_TYPE_ICON, 1
459
- );
460
-
461
- // delete old icon record from config_data table
462
- $configModel->deleteConfig($application_id, $deprecatedFlag, $iconConfigPath);
463
-
464
- // delete all icon files from file system
465
- $this->_deleteImageFiles($iconFile, false);
466
- }
467
-
468
- $i = 0;
469
- // old config path prefix native/body/
470
- $configPrefix = 'native/body/';
471
- foreach ($configPathList as $configPath => $imageType) {
472
- if (empty($configData[$deprecatedFlag][$configPrefix . $configPath])) {
473
- continue;
474
- }
475
- $fileName = basename($configData[$deprecatedFlag][$configPrefix . $configPath]);
476
- // add new record to image table
477
- $this->saveImage($application_id, $fileName, $imageType, ++$i);
478
-
479
- // delete all image files from file system
480
- $this->_deleteImageFiles($fileName, false);
481
-
482
- // remove old record from config_data table
483
- $configModel->deleteConfig($application_id, $deprecatedFlag, $configPrefix . $configPath);
484
- }
485
- }
486
- return $this;
487
- }
488
-
489
- /**
490
- * Convert uploaded file to PNG
491
- *
492
- * @param string $originalFile
493
- * @param string $destinationFile
494
- * @param int|null $originalImageType
495
- * @return string
496
- */
497
- protected function _forcedConvertPng($originalFile, $destinationFile, $originalImageType = null)
498
- {
499
- switch ($originalImageType) {
500
- case IMAGETYPE_GIF:
501
- $img = imagecreatefromgif($originalFile);
502
- imagealphablending($img, false);
503
- imagesavealpha($img, true);
504
- break;
505
- case IMAGETYPE_JPEG:
506
- $img = imagecreatefromjpeg($originalFile);
507
- break;
508
- case IMAGETYPE_WBMP:
509
- $img = imagecreatefromwbmp($originalFile);
510
- break;
511
- case IMAGETYPE_XBM:
512
- $img = imagecreatefromxbm($originalFile);
513
- break;
514
- default:
515
- return '';
516
- }
517
- imagepng($img, $destinationFile);
518
- imagedestroy($img);
519
-
520
- return $destinationFile;
521
- }
522
-
523
- /**
524
- * Convert image file extension to PNG
525
- *
526
- * @param string $fileName
527
- * @return string
528
- */
529
- protected function _convertFileExtensionToPng($fileName)
530
- {
531
- $dotPosition = strrpos($fileName, '.');
532
- if ($dotPosition !== false) {
533
- $fileName = substr($fileName, 0 , $dotPosition);
534
- }
535
- $fileName .= '.png';
536
-
537
- return $fileName;
538
- }
539
-
540
- /**
541
- * Get image type
542
- *
543
- * @param string $filePath
544
- * @return int
545
- */
546
- protected function _getImageType($filePath)
547
- {
548
- list(,, $originalImageType) = getimagesize($filePath);
549
- return $originalImageType;
550
- }
551
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Observer.php CHANGED
@@ -40,7 +40,6 @@ class Mage_XmlConnect_Model_Observer
40
  */
41
  protected $_appDependOnConfigFieldPathes = array(
42
  Mage_XmlConnect_Model_Application::XML_PATH_PAYPAL_BUSINESS_ACCOUNT,
43
- Mage_Checkout_Helper_Data::XML_PATH_GUEST_CHECKOUT,
44
  'sendfriend/email/max_recipients',
45
  'sendfriend/email/allow_guest',
46
  'general/locale/code',
@@ -58,11 +57,7 @@ class Mage_XmlConnect_Model_Observer
58
  */
59
  public function restrictWebsite($observer)
60
  {
61
- $controller = $observer->getEvent()->getController();
62
- if ($controller instanceof Mage_XmlConnect_Controller_AdminAction
63
- || $controller instanceof Mage_XmlConnect_Controller_Action
64
- || Mage::app()->getRequest()->getModuleName() == 'xmlconnect'
65
- ) {
66
  $observer->getEvent()->getResult()->setShouldProceed(false);
67
  }
68
  }
@@ -90,18 +85,15 @@ class Mage_XmlConnect_Model_Observer
90
  */
91
  public function sendMessageImmediately($observer)
92
  {
93
- /** @var $message Mage_XmlConnect_Model_Queue */
94
  $message = $observer->getEvent()->getData('queueMessage');
95
- $execTime = strtotime($message->getExecTime());
96
- $isPastTime = false;
97
- if (false !== $execTime) {
98
- $isPastTime = strtotime(Mage::getSingleton('core/date')->gmtDate()) - strtotime($message->getExecTime());
99
- }
100
- if ($isPastTime === false || $isPastTime > 0) {
101
  $message->setExecTime(Mage::getSingleton('core/date')->gmtDate());
102
  Mage::helper('xmlconnect')->sendBroadcastMessage($message);
103
  return true;
104
  }
 
105
  return false;
106
  }
107
 
@@ -113,76 +105,14 @@ class Mage_XmlConnect_Model_Observer
113
  public function scheduledSend()
114
  {
115
  $countOfQueue = Mage::getStoreConfig(Mage_XmlConnect_Model_Queue::XML_PATH_CRON_MESSAGES_COUNT);
 
116
  $collection = Mage::getModel('xmlconnect/queue')->getCollection()->addOnlyForSendingFilter()
117
  ->setPageSize($countOfQueue)->setCurPage(1)->load();
 
118
  foreach ($collection as $message) {
119
  if ($message->getId()) {
120
  Mage::helper('xmlconnect')->sendBroadcastMessage($message);
121
  }
122
  }
123
  }
124
-
125
- /**
126
- * Clear category images cache
127
- *
128
- * @return null
129
- */
130
- public function clearCategoryImagesCache()
131
- {
132
- Mage::getModel('xmlconnect/catalog_category_image')->clearCache();
133
- }
134
-
135
- /**
136
- * Handle xmlconnect admin actions
137
- *
138
- * @param Varien_Event_Observer $event
139
- * @return null
140
- */
141
- public function actionFrontPreDispatchXmlAdmin($event)
142
- {
143
- /** @var $request Mage_Core_Controller_Request_Http */
144
- $request = Mage::app()->getRequest();
145
- if (true === $this->_checkAdminController($request, $event->getControllerAction())) {
146
- $request->setParam('forwarded', true)->setDispatched(true);
147
- }
148
- }
149
-
150
- /**
151
- * Forward unauthorized users for xmlconnect admin actions
152
- *
153
- * @param Varien_Event_Observer $event
154
- * @return null
155
- */
156
- public function actionPreDispatchXmlAdmin($event)
157
- {
158
- /** @var $request Mage_Core_Controller_Request_Http */
159
- $request = Mage::app()->getRequest();
160
- if (false === $this->_checkAdminController($request, $event->getControllerAction())
161
- && !Mage::getSingleton('admin/session')->isLoggedIn()
162
- ) {
163
- $request->setParam('forwarded', true)->setRouteName('adminhtml')->setControllerName('connect_user')
164
- ->setActionName('loginform')->setDispatched(false);
165
- }
166
- }
167
-
168
- /**
169
- * Check is controller action is allowed w/o authorization
170
- *
171
- * @param Mage_Core_Controller_Request_Http $request
172
- * @param Mage_XmlConnect_Controller_AdminAction $controllerAction
173
- * @return bool|null
174
- */
175
- protected function _checkAdminController($request, $controllerAction)
176
- {
177
- if ($controllerAction instanceof Mage_XmlConnect_Controller_AdminAction) {
178
- foreach ($controllerAction->getAllowedControllerActions() as $controller => $allowedActions) {
179
- if ($request->getControllerName() == $controller
180
- && in_array(strtolower($request->getActionName()), $allowedActions)
181
- ) {
182
- return true;
183
- }
184
- }
185
- return false;
186
- }
187
- }
188
  }
40
  */
41
  protected $_appDependOnConfigFieldPathes = array(
42
  Mage_XmlConnect_Model_Application::XML_PATH_PAYPAL_BUSINESS_ACCOUNT,
 
43
  'sendfriend/email/max_recipients',
44
  'sendfriend/email/allow_guest',
45
  'general/locale/code',
57
  */
58
  public function restrictWebsite($observer)
59
  {
60
+ if (Mage::app()->getRequest()->getModuleName() == 'xmlconnect') {
 
 
 
 
61
  $observer->getEvent()->getResult()->setShouldProceed(false);
62
  }
63
  }
85
  */
86
  public function sendMessageImmediately($observer)
87
  {
 
88
  $message = $observer->getEvent()->getData('queueMessage');
89
+ if ($message instanceof Mage_XmlConnect_Model_Queue && (strtolower($message->getExecTime()) == 'null'
90
+ || !$message->getExecTime())
91
+ ) {
 
 
 
92
  $message->setExecTime(Mage::getSingleton('core/date')->gmtDate());
93
  Mage::helper('xmlconnect')->sendBroadcastMessage($message);
94
  return true;
95
  }
96
+
97
  return false;
98
  }
99
 
105
  public function scheduledSend()
106
  {
107
  $countOfQueue = Mage::getStoreConfig(Mage_XmlConnect_Model_Queue::XML_PATH_CRON_MESSAGES_COUNT);
108
+
109
  $collection = Mage::getModel('xmlconnect/queue')->getCollection()->addOnlyForSendingFilter()
110
  ->setPageSize($countOfQueue)->setCurPage(1)->load();
111
+
112
  foreach ($collection as $message) {
113
  if ($message->getId()) {
114
  Mage::helper('xmlconnect')->sendBroadcastMessage($message);
115
  }
116
  }
117
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
app/code/core/Mage/XmlConnect/Model/OfflineCatalog.php DELETED
@@ -1,117 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect offline catalog model
29
- *
30
- * @category Mage
31
- * @package Mage_Xmlconnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog
35
- {
36
- /**
37
- * Category type
38
- */
39
- const CATEGORY_TYPE = 'category';
40
-
41
- /**
42
- * Product type
43
- */
44
- const PRODUCT_TYPE = 'product';
45
-
46
- /**
47
- * Home banners type
48
- */
49
- const HOMEBANNERS_TYPE = 'homebanners';
50
-
51
- /**
52
- * Home page type
53
- */
54
- const HOME_TYPE = 'home';
55
-
56
- /**
57
- * Config type
58
- */
59
- const CONFIG_TYPE = 'config';
60
-
61
- /**
62
- * Run export by type
63
- *
64
- * @param string $type
65
- * @return Mage_XmlConnect_Model_OfflineCatalog
66
- */
67
- protected function _runExport($type)
68
- {
69
- $exportModel = $this->_getExportModel($type);
70
- if (null !== $exportModel) {
71
- $exportModel->exportData();
72
- }
73
- return $this;
74
- }
75
-
76
- /**
77
- * Export offline catalog data
78
- *
79
- * @return Mage_XmlConnect_Model_OfflineCatalog
80
- */
81
- public function exportData()
82
- {
83
- Mage::helper('xmlconnect/offlineCatalog')->prepareResultDirectory();
84
- $this->_runExport(self::CATEGORY_TYPE)->_runExport(self::PRODUCT_TYPE)->_runExport(self::HOMEBANNERS_TYPE)
85
- ->_runExport(self::HOME_TYPE)->_runExport(self::CONFIG_TYPE);
86
- return $this;
87
- }
88
-
89
- /**
90
- * Get export model by type
91
- *
92
- * @param string $type
93
- * @return Mage_Core_Model_Abstract|null
94
- */
95
- protected function _getExportModel($type)
96
- {
97
- switch ($type) {
98
- case self::CATEGORY_TYPE:
99
- return Mage::getModel('xmlconnect/offlineCatalog_category');
100
- break;
101
- case self::PRODUCT_TYPE:
102
- return Mage::getModel('xmlconnect/offlineCatalog_product');
103
- break;
104
- case self::HOMEBANNERS_TYPE:
105
- return Mage::getModel('xmlconnect/offlineCatalog_homebanners');
106
- break;
107
- case self::HOME_TYPE:
108
- return Mage::getModel('xmlconnect/offlineCatalog_home');
109
- break;
110
- case self::CONFIG_TYPE:
111
- return Mage::getModel('xmlconnect/offlineCatalog_config');
112
- break;
113
- default:
114
- return null;
115
- }
116
- }
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Abstract.php DELETED
@@ -1,66 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog abstract model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- abstract class Mage_XmlConnect_Model_OfflineCatalog_Abstract extends Mage_Core_Model_Abstract
35
- {
36
- /**
37
- * Return layout block
38
- *
39
- * @abstract
40
- * @param Mage_XmlConnect_Helper_OfflineCatalog $exportHelper
41
- * @return Mage_Core_Block_Abstract
42
- */
43
- abstract public function getLayoutBlock($exportHelper);
44
-
45
- /**
46
- * Return action url
47
- *
48
- * @abstract
49
- * @return string
50
- */
51
- abstract protected function _getActionUrl();
52
-
53
- /**
54
- * Export offline catalog data
55
- *
56
- * @return Mage_XmlConnect_Model_OfflineCatalog_Home
57
- */
58
- public function exportData()
59
- {
60
- /** @var $exportHelper Mage_XmlConnect_Helper_OfflineCatalog */
61
- $exportHelper = Mage::helper('xmlconnect/offlineCatalog');
62
- $currentBlock = $this->getLayoutBlock($exportHelper);
63
- $exportHelper->addOfflineCatalogData($this->_getActionUrl(), $currentBlock->toHtml());
64
- return $this;
65
- }
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Category.php DELETED
@@ -1,120 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog category model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Category extends Mage_XmlConnect_Block_Catalog_Category
35
- {
36
- /**
37
- * Category url
38
- */
39
- const URL_CATEGORY_DETAILS = 'xmlconnect/catalog/category/id/%1$s/';
40
-
41
- /**
42
- * Product count in category
43
- */
44
- const PRODUCT_IN_CATEGORY = 10;
45
-
46
- /**
47
- * Request controller
48
- *
49
- * @var null|Mage_Core_Controller_Request_Http
50
- */
51
- protected $_request;
52
-
53
- /**
54
- * @var array
55
- */
56
- protected $_productIds = array();
57
-
58
- /**
59
- * Initialize category model
60
- */
61
- protected function _construct()
62
- {
63
- $this->setCategoryModel(Mage::getModel('xmlconnect/offlineCatalog_category_category'));
64
- $this->setIndexCategoryModel(Mage::getModel('xmlconnect/offlineCatalog_category_indexCategory'));
65
- $this->_request = Mage::app()->getRequest();
66
- parent::_construct();
67
- }
68
-
69
- /**
70
- * Get request
71
- *
72
- * @return Mage_Core_Controller_Request_Http
73
- */
74
- protected function _getRequest()
75
- {
76
- if (null === $this->_request) {
77
- $this->_request = Mage::app()->getRequest();
78
- }
79
- return $this->_request;
80
- }
81
-
82
- /**
83
- * Export category data
84
- *
85
- * @return Mage_XmlConnect_Model_OfflineCatalog_Category
86
- */
87
- public function exportData()
88
- {
89
- $this->_getRequest()->setParam('id', null)->setParam('count', self::PRODUCT_IN_CATEGORY);
90
- $this->getIndexCategoryModel()->exportData();
91
- /** @var $helper Mage_Catalog_Helper_Category */
92
- $helper = Mage::helper('catalog/category');
93
- foreach ($helper->getStoreCategories() as $category) {
94
- if (!$category->getIsActive()) {
95
- continue;
96
- }
97
- $this->_exportCategory($category);
98
- }
99
- return $this;
100
- }
101
-
102
- /**
103
- * Export category data
104
- *
105
- * @param Mage_Catalog_Model_Category $category
106
- * @return Mage_XmlConnect_Model_OfflineCatalog_Category
107
- */
108
- protected function _exportCategory($category)
109
- {
110
- /** @var $exportHelper Mage_XmlConnect_Helper_OfflineCatalog */
111
- $exportHelper = Mage::helper('xmlconnect/offlineCatalog');
112
- $this->_getRequest()->setParam('app_code', $exportHelper->getCurrentDeviceModel()->getCode());
113
-
114
- $categoryId = $category->getId();
115
- $this->getCategoryModel()->setCategoryId($categoryId);
116
- $this->_getRequest()->setParam('id', $categoryId);
117
- $this->getCategoryModel()->exportData();
118
- return $this;
119
- }
120
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Category/Category.php DELETED
@@ -1,61 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog category model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Category_Category extends Mage_XmlConnect_Model_OfflineCatalog_Abstract
35
- {
36
- /**
37
- * Category url
38
- */
39
- const CATEGORY_URL = 'xmlconnect/catalog/category/id/%1$s/';
40
-
41
- /**
42
- * Return category block
43
- *
44
- * @param Mage_XmlConnect_Helper_OfflineCatalog $exportHelper
45
- * @return Mage_Core_Block_Abstract
46
- */
47
- public function getLayoutBlock($exportHelper)
48
- {
49
- return $exportHelper->getBlock('xmlconnect.catalog.category');
50
- }
51
-
52
- /**
53
- * Return category url
54
- *
55
- * @return string
56
- */
57
- protected function _getActionUrl()
58
- {
59
- return sprintf(Mage::getBaseUrl() . self::CATEGORY_URL, $this->getCategoryId());
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Category/IndexCategory.php DELETED
@@ -1,61 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog index category model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Category_IndexCategory extends Mage_XmlConnect_Model_OfflineCatalog_Abstract
35
- {
36
- /**
37
- * Index category url
38
- */
39
- const CATEGORY_INDEX_URL = 'xmlconnect/catalog/category/';
40
-
41
- /**
42
- * Return category block
43
- *
44
- * @param Mage_XmlConnect_Helper_OfflineCatalog $exportHelper
45
- * @return Mage_Core_Block_Abstract
46
- */
47
- public function getLayoutBlock($exportHelper)
48
- {
49
- return $exportHelper->getBlock('xmlconnect.catalog.category');
50
- }
51
-
52
- /**
53
- * Return index category url
54
- *
55
- * @return string
56
- */
57
- protected function _getActionUrl()
58
- {
59
- return Mage::getBaseUrl() . self::CATEGORY_INDEX_URL;
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Config.php DELETED
@@ -1,77 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog config model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Config extends Mage_XmlConnect_Model_OfflineCatalog_Abstract
35
- {
36
- /**
37
- * Config url
38
- */
39
- const CONFIG_URL = 'Configuration';
40
-
41
- /**
42
- * Export config data
43
- *
44
- * @return Mage_XmlConnect_Model_OfflineCatalog_Config
45
- */
46
- public function exportData()
47
- {
48
- /** @var $exportHelper Mage_XmlConnect_Helper_OfflineCatalog */
49
- $exportHelper = Mage::helper('xmlconnect/offlineCatalog');
50
- Mage::app()->getRequest()->setParam('app_code', $exportHelper->getCurrentDeviceModel()->getCode());
51
- $exportHelper->addOfflineCatalogData(
52
- $this->_getActionUrl(), $this->getLayoutBlock($exportHelper)->toHtml()
53
- );
54
- return $this;
55
- }
56
-
57
- /**
58
- * Return config block
59
- *
60
- * @param Mage_XmlConnect_Helper_OfflineCatalog $exportHelper
61
- * @return Mage_Core_Block_Abstract
62
- */
63
- public function getLayoutBlock($exportHelper)
64
- {
65
- return $exportHelper->getBlock('xmlconnect.configuration');
66
- }
67
-
68
- /**
69
- * Return action url
70
- *
71
- * @return string
72
- */
73
- protected function _getActionUrl()
74
- {
75
- return self::CONFIG_URL;
76
- }
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Home.php DELETED
@@ -1,61 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog home model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Home extends Mage_XmlConnect_Model_OfflineCatalog_Abstract
35
- {
36
- /**
37
- * Home url
38
- */
39
- const HOME_URL = 'xmlconnect/index/index/';
40
-
41
- /**
42
- * Return home block
43
- *
44
- * @param Mage_XmlConnect_Helper_OfflineCatalog $exportHelper
45
- * @return Mage_Core_Block_Abstract
46
- */
47
- public function getLayoutBlock($exportHelper)
48
- {
49
- return $exportHelper->getBlock('xmlconnect.home');
50
- }
51
-
52
- /**
53
- * Return home url
54
- *
55
- * @return string
56
- */
57
- protected function _getActionUrl()
58
- {
59
- return Mage::getBaseUrl() . self::HOME_URL;
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Homebanners.php DELETED
@@ -1,61 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog homebanners model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Homebanners extends Mage_XmlConnect_Model_OfflineCatalog_Abstract
35
- {
36
- /**
37
- * Home banners url
38
- */
39
- const HOMEBANNES_URL = 'xmlconnect/homebanners';
40
-
41
- /**
42
- * Return home banners block
43
- *
44
- * @param Mage_XmlConnect_Helper_OfflineCatalog $exportHelper
45
- * @return Mage_Core_Block_Abstract
46
- */
47
- public function getLayoutBlock($exportHelper)
48
- {
49
- return $exportHelper->getBlock('xmlconnect.homebanners');
50
- }
51
-
52
- /**
53
- * Return home banners url
54
- *
55
- * @return string
56
- */
57
- protected function _getActionUrl()
58
- {
59
- return Mage::getBaseUrl() . self::HOMEBANNES_URL;
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Product.php DELETED
@@ -1,111 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog product model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Product extends Mage_XmlConnect_Block_Catalog_Product_List
35
- {
36
- /**
37
- * Type product
38
- */
39
- const TYPE_PRODUCT = 'product';
40
-
41
- /**
42
- * Type review
43
- */
44
- const TYPE_REVIEW = 'review';
45
-
46
- /**
47
- * Type gallery
48
- */
49
- const TYPE_GALLERY = 'gallery';
50
-
51
- /**
52
- * Export product data
53
- *
54
- * @return Mage_XmlConnect_Model_OfflineCatalog_Product
55
- */
56
- public function exportData()
57
- {
58
- /** @var $helper Mage_Catalog_Helper_Category */
59
- $helper = Mage::helper('catalog/category');
60
- Mage::app()->getRequest()->setParam(
61
- 'count', Mage_XmlConnect_Model_OfflineCatalog_Category::PRODUCT_IN_CATEGORY
62
- );
63
- foreach ($helper->getStoreCategories() as $category) {
64
- if (!$category->getIsActive()) {
65
- continue;
66
- }
67
- $this->_exportProductCollection($category);
68
- }
69
- }
70
-
71
- /**
72
- * Export product collection
73
- *
74
- * @param Varien_Data_Tree_Node $category
75
- */
76
- protected function _exportProductCollection($category)
77
- {
78
- $categoryModel = Mage::getModel('catalog/category')->load($category->getId());
79
- $this->setCategory($categoryModel)->setLayer(Mage::getSingleton('catalog/layer'));
80
- foreach ($this->_getProductCollection() as $product) {
81
- $product->load($product->getEntityId());
82
- Mage::app()->getRequest()->setParam('id', $product->getId());
83
- $this->_getExportModel(self::TYPE_PRODUCT)->setProduct($product)->exportData();
84
- $this->_getExportModel(self::TYPE_GALLERY)->setProduct($product)->exportData();
85
- $this->_getExportModel(self::TYPE_REVIEW)->setProduct($product)->exportData();
86
- }
87
- }
88
-
89
- /**
90
- * Get export model by type
91
- *
92
- * @param string $type
93
- * @return Mage_Core_Model_Abstract|null
94
- */
95
- protected function _getExportModel($type)
96
- {
97
- switch ($type) {
98
- case self::TYPE_PRODUCT:
99
- return Mage::getSingleton('xmlconnect/offlineCatalog_product_product');
100
- break;
101
- case self::TYPE_GALLERY:
102
- return Mage::getSingleton('xmlconnect/offlineCatalog_product_gallery');
103
- break;
104
- case self::TYPE_REVIEW:
105
- return Mage::getSingleton('xmlconnect/offlineCatalog_product_review');
106
- break;
107
- default:
108
- return null;
109
- }
110
- }
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Product/Gallery.php DELETED
@@ -1,61 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog gallery model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Product_Gallery extends Mage_XmlConnect_Model_OfflineCatalog_Abstract
35
- {
36
- /**
37
- * Gallery url
38
- */
39
- const GALLERY_URL = 'xmlconnect/catalog/productgallery/id/%1$s/';
40
-
41
- /**
42
- * Return gallery block
43
- *
44
- * @param Mage_XmlConnect_Helper_OfflineCatalog $exportHelper
45
- * @return Mage_Core_Block_Abstract
46
- */
47
- public function getLayoutBlock($exportHelper)
48
- {
49
- return $exportHelper->getBlock('xmlconnect.catalog.product.gallery');
50
- }
51
-
52
- /**
53
- * Return gallery url
54
- *
55
- * @return string
56
- */
57
- protected function _getActionUrl()
58
- {
59
- return sprintf(Mage::getBaseUrl() . self::GALLERY_URL, $this->getProduct()->getId());
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Product/Product.php DELETED
@@ -1,61 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog product model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Product_Product extends Mage_XmlConnect_Model_OfflineCatalog_Abstract
35
- {
36
- /**
37
- * Product url
38
- */
39
- const PRODUCT_URL = 'xmlconnect/catalog/product/id/%1$s/';
40
-
41
- /**
42
- * Return product block
43
- *
44
- * @param Mage_XmlConnect_Helper_OfflineCatalog $exportHelper
45
- * @return Mage_Core_Block_Abstract
46
- */
47
- public function getLayoutBlock($exportHelper)
48
- {
49
- return $exportHelper->getBlock('xmlconnect.catalog.product');
50
- }
51
-
52
- /**
53
- * Return product url
54
- *
55
- * @return string
56
- */
57
- protected function _getActionUrl()
58
- {
59
- return sprintf(Mage::getBaseUrl() . self::PRODUCT_URL, $this->getProduct()->getId());
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/OfflineCatalog/Product/Review.php DELETED
@@ -1,61 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect offline catalog review model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_OfflineCatalog_Product_Review extends Mage_XmlConnect_Model_OfflineCatalog_Abstract
35
- {
36
- /**
37
- * Review url
38
- */
39
- const REVIEW_URL = 'xmlconnect/catalog/productreviews/id/%1$s/';
40
-
41
- /**
42
- * Return review block
43
- *
44
- * @param Mage_XmlConnect_Helper_OfflineCatalog $exportHelper
45
- * @return Mage_Core_Block_Abstract
46
- */
47
- public function getLayoutBlock($exportHelper)
48
- {
49
- return $exportHelper->getBlock('xmlconnect.catalog.product.reviews');
50
- }
51
-
52
- /**
53
- * Return review url
54
- *
55
- * @return mixed
56
- */
57
- protected function _getActionUrl()
58
- {
59
- return sprintf(Mage::getBaseUrl() . self::REVIEW_URL, $this->getProduct()->getId());
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Config.php CHANGED
@@ -48,19 +48,4 @@ class Mage_XmlConnect_Model_Payment_Method_Paypal_Config extends Mage_Paypal_Mod
48
  {
49
  return $this->getPaypalUrl(array('cmd' => '_express-checkout-mobile', 'token' => $token));
50
  }
51
-
52
- /**
53
- * Map any supported payment method into a config path by specified field name
54
- *
55
- * @param string $fieldName
56
- * @return string|null
57
- */
58
- protected function _getSpecificConfigPath($fieldName)
59
- {
60
- $path = parent::_getSpecificConfigPath($fieldName);
61
- if ($path === null && $this->_methodCode == self::METHOD_WPP_MECL) {
62
- $path = $this->_mapExpressFieldset($fieldName);
63
- }
64
- return $path;
65
- }
66
  }
48
  {
49
  return $this->getPaypalUrl(array('cmd' => '_express-checkout-mobile', 'token' => $token));
50
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
app/code/core/Mage/XmlConnect/Model/Paypal/Mecl/Checkout.php CHANGED
@@ -39,28 +39,4 @@ class Mage_XmlConnect_Model_Paypal_Mecl_Checkout extends Mage_Paypal_Model_Expre
39
  * @var string
40
  */
41
  protected $_methodType = Mage_XmlConnect_Model_Payment_Method_Paypal_Config::METHOD_WPP_MECL;
42
-
43
- /**
44
- * Set sandbox flag and get api
45
- *
46
- * @return Mage_Paypal_Model_Api_Nvp
47
- */
48
- protected function _getApi()
49
- {
50
- $this->_setSandboxFlag();
51
- return parent::_getApi();
52
- }
53
-
54
- /**
55
- * Set sandbox flag
56
- *
57
- * @return Mage_XmlConnect_Model_Paypal_Mecl_Checkout
58
- */
59
- protected function _setSandboxFlag()
60
- {
61
- $this->_config->sandboxFlag = Mage::helper('payment')
62
- ->getMethodInstance(Mage_XmlConnect_Model_Payment_Method_Paypal_Config::METHOD_WPP_EXPRESS)
63
- ->getConfigData('sandbox_flag');
64
- return $this;
65
- }
66
  }
39
  * @var string
40
  */
41
  protected $_methodType = Mage_XmlConnect_Model_Payment_Method_Paypal_Config::METHOD_WPP_MECL;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
app/code/core/Mage/XmlConnect/Model/Preview/Abstract.php CHANGED
@@ -33,13 +33,6 @@
33
  */
34
  abstract class Mage_XmlConnect_Model_Preview_Abstract extends Varien_Object
35
  {
36
- /**
37
- * XmlConnect image model
38
- *
39
- * @var Mage_XmlConnect_Model_Images
40
- */
41
- protected $_imageModel;
42
-
43
  /**
44
  * Current active tab according preview action
45
  *
@@ -212,19 +205,12 @@ abstract class Mage_XmlConnect_Model_Preview_Abstract extends Varien_Object
212
  */
213
  public function getLogoUrl()
214
  {
215
- $imageArray = $this->_getDeviceImageByType('icon');
216
- $iconImage = false;
217
- if (count($imageArray)) {
218
- $iconImage = $this->getImageModel()->getCustomSizeImageUrl(
219
- $imageArray[0]['image_file'], 35, 35
220
- );
221
- }
222
-
223
- if (!$iconImage) {
224
- $iconImage = $this->getPreviewImagesUrl('smallIcon.png');
225
  }
226
-
227
- return $iconImage;
228
  }
229
 
230
  /**
@@ -277,42 +263,4 @@ abstract class Mage_XmlConnect_Model_Preview_Abstract extends Varien_Object
277
  }
278
  return $this->_categoryItemTintColor;
279
  }
280
-
281
- /**
282
- * Get device image by type
283
- *
284
- * @param string $type
285
- * @param int $limit
286
- * @param int $offset
287
- * @return array
288
- */
289
- protected function _getDeviceImageByType($type, $limit = 1, $offset = 0)
290
- {
291
- return $this->getImageModel()->getDeviceImagesByType($type, $limit, $offset);
292
- }
293
-
294
- /**
295
- * Get XmlConnect Image Model
296
- *
297
- * @return Mage_XmlConnect_Model_Images
298
- */
299
- public function getImageModel()
300
- {
301
- if ($this->_imageModel === null) {
302
- $this->setImageModel(Mage::getModel('xmlconnect/images'));
303
- }
304
- return $this->_imageModel;
305
- }
306
-
307
- /**
308
- * Set XmlConnect image model
309
- *
310
- * @param Mage_XmlConnect_Model_Images $imageModel
311
- * @return Mage_XmlConnect_Model_Preview_Abstract
312
- */
313
- public function setImageModel($imageModel)
314
- {
315
- $this->_imageModel = $imageModel;
316
- return $this;
317
- }
318
  }
33
  */
34
  abstract class Mage_XmlConnect_Model_Preview_Abstract extends Varien_Object
35
  {
 
 
 
 
 
 
 
36
  /**
37
  * Current active tab according preview action
38
  *
205
  */
206
  public function getLogoUrl()
207
  {
208
+ $configPath = 'conf/navigationBar/icon';
209
+ if ($this->getData($configPath)) {
210
+ return $this->getData($configPath);
211
+ } else {
212
+ return $this->getPreviewImagesUrl('smallIcon.png');
 
 
 
 
 
213
  }
 
 
214
  }
215
 
216
  /**
263
  }
264
  return $this->_categoryItemTintColor;
265
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  }
app/code/core/Mage/XmlConnect/Model/Preview/Android.php CHANGED
@@ -69,20 +69,13 @@ class Mage_XmlConnect_Model_Preview_Android extends Mage_XmlConnect_Model_Previe
69
  */
70
  public function getBannerImage()
71
  {
72
- $result = array();
73
- $bannerImages = $this->getImageModel()
74
- ->getDeviceImagesByType(Mage_XmlConnect_Model_Device_Android::IMAGE_TYPE_PORTRAIT_BANNER);
75
- if (!empty($bannerImages)) {
76
- $width = Mage_XmlConnect_Model_Device_Android::PREVIEW_BANNER_WIDTH;
77
- $height = Mage_XmlConnect_Model_Device_Android::PREVIEW_BANNER_HEIGHT;
78
- foreach ($bannerImages as $banner) {
79
- if (!isset($banner['image_file'])) {
80
- continue;
81
- }
82
- $result[] = $this->getImageModel()->getCustomSizeImageUrl($banner['image_file'], $width, $height);
83
- }
84
  }
85
- return $result;
86
  }
87
 
88
  /**
69
  */
70
  public function getBannerImage()
71
  {
72
+ $configPath = 'conf/body/bannerAndroidImage';
73
+ if ($this->getData($configPath)) {
74
+ $bannerImage = $this->getData($configPath);
75
+ } else {
76
+ $bannerImage = $this->getPreviewImagesUrl('android/bg_logo.png');
 
 
 
 
 
 
 
77
  }
78
+ return $bannerImage;
79
  }
80
 
81
  /**
app/code/core/Mage/XmlConnect/Model/Preview/Ipad.php CHANGED
@@ -69,42 +69,34 @@ class Mage_XmlConnect_Model_Preview_Ipad extends Mage_XmlConnect_Model_Preview_A
69
  */
70
  public function getBannerImage()
71
  {
72
- $result = array();
73
- switch ($this->getOrientation()) {
74
- case Mage_XmlConnect_Model_Device_Ipad::ORIENTATION_LANDSCAPE:
75
- $bannerImages = $this->getImageModel()
76
- ->getDeviceImagesByType(Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_LANDSCAPE_BANNER);
77
- if (!empty($bannerImages)) {
78
- $width = Mage_XmlConnect_Model_Device_Ipad::PREVIEW_LANDSCAPE_BANNER_WIDTH;
79
- $height = Mage_XmlConnect_Model_Device_Ipad::PREVIEW_LANDSCAPE_BANNER_HEIGHT;
80
- foreach ($bannerImages as $banner) {
81
- if (!isset($banner['image_file'])) {
82
- continue;
83
- }
84
- $result[] = $this->getImageModel()->getCustomSizeImageUrl(
85
- $banner['image_file'], $width, $height
86
- );
87
- }
88
  }
89
  break;
90
- case Mage_XmlConnect_Model_Device_Ipad::ORIENTATION_PORTRAIT:
91
- $bannerImages = $this->getImageModel()
92
- ->getDeviceImagesByType(Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_PORTRAIT_BANNER);
93
- if (!empty($bannerImages)) {
94
- $width = Mage_XmlConnect_Model_Device_Ipad::PREVIEW_PORTRAIT_BANNER_WIDTH;
95
- $height = Mage_XmlConnect_Model_Device_Ipad::PREVIEW_PORTRAIT_BANNER_HEIGHT;
96
- foreach ($bannerImages as $banner) {
97
- if (!isset($banner['image_file'])) {
98
- continue;
99
- }
100
- $result[] = $this->getImageModel()->getCustomSizeImageUrl(
101
- $banner['image_file'], $width, $height
102
- );
103
- }
104
  }
105
  break;
106
  }
107
- return $result;
108
  }
109
 
110
  /**
@@ -115,34 +107,37 @@ class Mage_XmlConnect_Model_Preview_Ipad extends Mage_XmlConnect_Model_Preview_A
115
  */
116
  public function getBackgroundImage()
117
  {
118
- switch ($this->getOrientation()) {
119
- case Mage_XmlConnect_Model_Device_Ipad::ORIENTATION_LANDSCAPE:
120
- $backgroundImage = $this->getImageModel()
121
- ->getImageItemByType(Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_LANDSCAPE_BACKGROUND);
122
- if (is_object($backgroundImage) && $backgroundImage->getImageFile()) {
123
- $width = Mage_XmlConnect_Model_Device_Ipad::PREVIEW_LANDSCAPE_BACKGROUND_WIDTH;
124
- $height = Mage_XmlConnect_Model_Device_Ipad::PREVIEW_LANDSCAPE_BACKGROUND_HEIGHT;
125
- $backgroundImage = $this->getImageModel()
126
- ->getCustomSizeImageUrl($backgroundImage->getImageFile(), $width, $height);
 
 
 
 
127
  } else {
128
  $backgroundImage = $this->getPreviewImagesUrl('ipad/background_home_landscape.jpg');
129
  }
130
  break;
131
- case Mage_XmlConnect_Model_Device_Ipad::ORIENTATION_PORTRAIT:
132
- $backgroundImage = $this->getImageModel()
133
- ->getImageItemByType(Mage_XmlConnect_Model_Device_Ipad::IMAGE_TYPE_PORTRAIT_BACKGROUND);
134
- if (is_object($backgroundImage) && $backgroundImage->getImageFile()) {
135
- $width = Mage_XmlConnect_Model_Device_Ipad::PREVIEW_PORTRAIT_BACKGROUND_WIDTH;
136
- $height = Mage_XmlConnect_Model_Device_Ipad::PREVIEW_PORTRAIT_BACKGROUND_HEIGHT;
137
- $backgroundImage = $this->getImageModel()
138
- ->getCustomSizeImageUrl($backgroundImage->getImageFile(), $width, $height);
139
  } else {
140
  $backgroundImage = $this->getPreviewImagesUrl('ipad/background_portrait.jpg');
141
  }
142
  break;
143
  default:
144
  Mage::throwException(
145
- Mage::helper('xmlconnect')->__('Wrong Ipad background image orientation has been specified: "%s".', $this->getOrientation())
146
  );
147
  break;
148
  }
69
  */
70
  public function getBannerImage()
71
  {
72
+ $orientation = $this->getOrientation();
73
+ switch ($orientation) {
74
+ case Mage_XmlConnect_Helper_Ipad::ORIENTATION_LANDSCAPE:
75
+ $configPath = 'conf/body/bannerIpadLandscapeImage';
76
+ $imageUrlOrig = $this->getData($configPath);
77
+ if ($imageUrlOrig) {
78
+ $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BANNER_WIDTH;
79
+ $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BANNER_HEIGHT;
80
+ $bannerImage = Mage::helper('xmlconnect/image')
81
+ ->getCustomSizeImageUrl($imageUrlOrig, $width, $height);
82
+ } else {
83
+ $bannerImage = $this->getPreviewImagesUrl('ipad/banner_image_l.png');
 
 
 
 
84
  }
85
  break;
86
+ case Mage_XmlConnect_Helper_Ipad::ORIENTATION_PORTRAIT:
87
+ $configPath = 'conf/body/bannerIpadImage';
88
+ $imageUrlOrig = $this->getData($configPath);
89
+ if ($imageUrlOrig) {
90
+ $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BANNER_WIDTH;
91
+ $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BANNER_HEIGHT;
92
+ $bannerImage = Mage::helper('xmlconnect/image')
93
+ ->getCustomSizeImageUrl($imageUrlOrig, $width, $height);
94
+ } else {
95
+ $bannerImage = $this->getPreviewImagesUrl('ipad/banner_image.png');
 
 
 
 
96
  }
97
  break;
98
  }
99
+ return $bannerImage;
100
  }
101
 
102
  /**
107
  */
108
  public function getBackgroundImage()
109
  {
110
+ $orientation = $this->getOrientation();
111
+ $backgroundImage = '';
112
+ /** @var $helperImage Mage_XmlConnect_Helper_Image */
113
+ $helperImage = Mage::helper('xmlconnect/image');
114
+
115
+ switch ($orientation) {
116
+ case Mage_XmlConnect_Helper_Ipad::ORIENTATION_LANDSCAPE:
117
+ $configPath = 'conf/body/backgroundIpadLandscapeImage';
118
+ $imageUrlOrig = $this->getData($configPath);
119
+ if ($imageUrlOrig) {
120
+ $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BACKGROUND_WIDTH;
121
+ $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BACKGROUND_HEIGHT;
122
+ $backgroundImage = $helperImage->getCustomSizeImageUrl($imageUrlOrig, $width, $height);
123
  } else {
124
  $backgroundImage = $this->getPreviewImagesUrl('ipad/background_home_landscape.jpg');
125
  }
126
  break;
127
+ case Mage_XmlConnect_Helper_Ipad::ORIENTATION_PORTRAIT:
128
+ $configPath = 'conf/body/backgroundIpadPortraitImage';
129
+ $imageUrlOrig = $this->getData($configPath);
130
+ if ($imageUrlOrig) {
131
+ $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BACKGROUND_WIDTH;
132
+ $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BACKGROUND_HEIGHT;
133
+ $backgroundImage = $helperImage->getCustomSizeImageUrl($imageUrlOrig, $width, $height);
 
134
  } else {
135
  $backgroundImage = $this->getPreviewImagesUrl('ipad/background_portrait.jpg');
136
  }
137
  break;
138
  default:
139
  Mage::throwException(
140
+ Mage::helper('xmlconnect')->__('Wrong Ipad background image orientation has been specified: "%s".', $orientation)
141
  );
142
  break;
143
  }
app/code/core/Mage/XmlConnect/Model/Preview/Iphone.php CHANGED
@@ -41,22 +41,13 @@ class Mage_XmlConnect_Model_Preview_Iphone extends Mage_XmlConnect_Model_Preview
41
  */
42
  public function getBannerImage()
43
  {
44
- $result = array();
45
- $bannerImages = $this->getImageModel()
46
- ->getDeviceImagesByType(Mage_XmlConnect_Model_Device_Iphone::IMAGE_TYPE_PORTRAIT_BANNER);
47
- if (!empty($bannerImages)) {
48
- $width = Mage_XmlConnect_Model_Device_Iphone::PREVIEW_PORTRAIT_BANNER_WIDTH;
49
- $height = Mage_XmlConnect_Model_Device_Iphone::PREVIEW_PORTRAIT_BANNER_HEIGHT;
50
- foreach ($bannerImages as $banner) {
51
- if (!isset($banner['image_file'])) {
52
- continue;
53
- }
54
- $result[] = $this->getImageModel()->getCustomSizeImageUrl($banner['image_file'], $width, $height);
55
- }
56
  } else {
57
- $result[] = $this->getPreviewImagesUrl('banner.png');
58
  }
59
- return $result;
60
  }
61
 
62
  /**
41
  */
42
  public function getBannerImage()
43
  {
44
+ $configPath = 'conf/body/bannerImage';
45
+ if ($this->getData($configPath)) {
46
+ $bannerImage = $this->getData($configPath);
 
 
 
 
 
 
 
 
 
47
  } else {
48
+ $bannerImage = $this->getPreviewImagesUrl('banner.png');
49
  }
50
+ return $bannerImage;
51
  }
52
 
53
  /**
app/code/core/Mage/XmlConnect/Model/Queue.php CHANGED
@@ -79,14 +79,7 @@ class Mage_XmlConnect_Model_Queue extends Mage_Core_Model_Template
79
  *
80
  * @var null|string
81
  */
82
- protected $_appType;
83
-
84
- /**
85
- * Application code
86
- *
87
- * @var string
88
- */
89
- protected $_appCode;
90
 
91
  /**
92
  * Initialize queue message
@@ -109,14 +102,8 @@ class Mage_XmlConnect_Model_Queue extends Mage_Core_Model_Template
109
  {
110
  parent::load($id, $field);
111
 
112
- if (!$this->getTemplateId() && Mage::app()->getRequest()->getParam('template_id', false)) {
113
- $this->setTemplateId(Mage::app()->getRequest()->getParam('template_id'));
114
- }
115
-
116
  if ($this->getTemplateId()) {
117
- $template = Mage::getModel('xmlconnect/template')->load($this->getTemplateId());
118
- $this->setName($template->getName());
119
- $this->setApplicationId($template->getApplicationId());
120
  }
121
  return $this;
122
  }
@@ -309,20 +296,4 @@ EOT;
309
  }
310
  return parent::save();
311
  }
312
-
313
- /**
314
- * Get application code
315
- *
316
- * @return string
317
- */
318
- public function getAppCode()
319
- {
320
- if (null === $this->_appCode) {
321
- if ($this->getApplicationId()) {
322
- $application = Mage::getModel('xmlconnect/application')->load($this->getApplicationId());
323
- $this->_appCode = $application->getCode();
324
- }
325
- }
326
- return $this->_appCode;
327
- }
328
  }
79
  *
80
  * @var null|string
81
  */
82
+ protected $_appType = null;
 
 
 
 
 
 
 
83
 
84
  /**
85
  * Initialize queue message
102
  {
103
  parent::load($id, $field);
104
 
 
 
 
 
105
  if ($this->getTemplateId()) {
106
+ $this->setName(Mage::getModel('xmlconnect/template')->load($this->getTemplateId())->getName());
 
 
107
  }
108
  return $this;
109
  }
296
  }
297
  return parent::save();
298
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  }
app/code/core/Mage/XmlConnect/Model/Resource/Application.php CHANGED
@@ -111,27 +111,11 @@ class Mage_XmlConnect_Model_Resource_Application extends Mage_Core_Model_Resourc
111
  /**
112
  * Update all applications "updated at" parameter with current date
113
  *
114
- * @deprecated will remove in new release
115
  * @return Mage_XmlConnect_Model_Resource_Application
116
  */
117
  public function updateAllAppsUpdatedAtParameter()
118
  {
119
- $this->_getWriteAdapter()->update(
120
- $this->getMainTable(),
121
- array('updated_at' => date('Y-m-d H:i:s'))
122
- );
123
- return $this;
124
- }
125
-
126
- /**
127
- * Update all applications "updated at" parameter with current date
128
- *
129
- * @param Mage_XmlConnect_Model_Application $model
130
- * @return Mage_XmlConnect_Model_Resource_Application
131
- */
132
- public function updateUpdatedAtParameter($model)
133
- {
134
- $this->_getWriteAdapter()->update($this->getMainTable(), array('updated_at' => $model->getUpdatedAt()));
135
  return $this;
136
  }
137
  }
111
  /**
112
  * Update all applications "updated at" parameter with current date
113
  *
 
114
  * @return Mage_XmlConnect_Model_Resource_Application
115
  */
116
  public function updateAllAppsUpdatedAtParameter()
117
  {
118
+ $this->_getWriteAdapter()->update($this->getMainTable(), array('updated_at' => date('Y-m-d H:i:s')));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  return $this;
120
  }
121
  }
app/code/core/Mage/XmlConnect/Model/Resource/CategorySearch/Collection.php DELETED
@@ -1,120 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Category search collection
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Resource_CategorySearch_Collection extends Mage_Catalog_Model_Resource_Category_Collection
35
- {
36
- /**
37
- * Filter for category collection
38
- *
39
- * @var array
40
- */
41
- protected $_collectionFilter = array();
42
-
43
- /**
44
- * Add search query filter
45
- *
46
- * @param string $query
47
- * @return Mage_XmlConnect_Model_Resource_CategorySearch_Collection
48
- */
49
- public function addSearchFilter($query)
50
- {
51
- $this->_addNameFilter($query)->_addDescriptionFilter($query)
52
- ->_addUrlKeyFilter($query)->addFieldToFilter($this->getCollectionFilter());
53
-
54
- return $this;
55
- }
56
-
57
- /**
58
- * Add name filter
59
- *
60
- * @param string $query
61
- * @return Mage_XmlConnect_Model_Resource_CategorySearch_Collection
62
- */
63
- protected function _addNameFilter($query)
64
- {
65
- $collectionFilter = $this->getCollectionFilter();
66
- $collectionFilter[] = array('attribute' => 'name', 'like' => $query . '%');
67
- $this->setCollectionFilter($collectionFilter);
68
- return $this;
69
- }
70
-
71
- /**
72
- * Add description filter
73
- *
74
- * @param string $query
75
- * @return Mage_XmlConnect_Model_Resource_CategorySearch_Collection
76
- */
77
- protected function _addDescriptionFilter($query)
78
- {
79
- $collectionFilter = $this->getCollectionFilter();
80
- $collectionFilter[] = array('attribute' => 'description', 'like' => $query . '%');
81
- $this->setCollectionFilter($collectionFilter);
82
- return $this;
83
- }
84
-
85
- /**
86
- * Add url key filter
87
- *
88
- * @param string $query
89
- * @return Mage_XmlConnect_Model_Resource_CategorySearch_Collection
90
- */
91
- protected function _addUrlKeyFilter($query)
92
- {
93
- $collectionFilter = $this->getCollectionFilter();
94
- $collectionFilter[] = array('attribute' => 'url_key', 'like' => $query . '%');
95
- $this->setCollectionFilter($collectionFilter);
96
- return $this;
97
- }
98
-
99
- /**
100
- * Set collection filter
101
- *
102
- * @param array $collectionFilter
103
- * @return Mage_XmlConnect_Model_Resource_CategorySearch_Collection
104
- */
105
- public function setCollectionFilter($collectionFilter)
106
- {
107
- $this->_collectionFilter = $collectionFilter;
108
- return $this;
109
- }
110
-
111
- /**
112
- * Get collection filter
113
- *
114
- * @return array
115
- */
116
- public function getCollectionFilter()
117
- {
118
- return $this->_collectionFilter;
119
- }
120
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Resource/ConfigData.php CHANGED
@@ -69,12 +69,12 @@ class Mage_XmlConnect_Model_Resource_ConfigData extends Mage_Core_Model_Mysql4_A
69
  * Delete config value
70
  *
71
  * @param int $applicationId
72
- * @param string $category
73
- * @param string $path
74
  * @param bool $pathLike
75
  * @return Mage_XmlConnect_Model_Mysql4_ConfigData
76
  */
77
- public function deleteConfig($applicationId, $category = '', $path = '', $pathLike = true)
78
  {
79
  try {
80
  $this->_getWriteAdapter()->beginTransaction();
69
  * Delete config value
70
  *
71
  * @param int $applicationId
72
+ * @param bool $category
73
+ * @param bool $path
74
  * @param bool $pathLike
75
  * @return Mage_XmlConnect_Model_Mysql4_ConfigData
76
  */
77
+ public function deleteConfig($applicationId, $category = false, $path = false, $pathLike = true)
78
  {
79
  try {
80
  $this->_getWriteAdapter()->beginTransaction();
app/code/core/Mage/XmlConnect/Model/Resource/ConfigData/Collection.php CHANGED
@@ -125,7 +125,9 @@ class Mage_XmlConnect_Model_Resource_ConfigData_Collection extends Mage_Core_Mod
125
  * return items array
126
  * array(
127
  * application_id => array(
128
- * category => array(path)
 
 
129
  * )
130
  * )
131
  *
125
  * return items array
126
  * array(
127
  * application_id => array(
128
+ * category => array(
129
+ * path
130
+ * )
131
  * )
132
  * )
133
  *
app/code/core/Mage/XmlConnect/Model/Resource/Filter/Collection.php CHANGED
@@ -65,6 +65,7 @@ class Mage_XmlConnect_Model_Resource_Filter_Collection extends Varien_Data_Colle
65
  }
66
  if ($layer->getCurrentCategory()->getIsAnchor()) {
67
  foreach ($layer->getFilterableAttributes() as $attributeItem) {
 
68
  switch ($attributeItem->getAttributeCode()) {
69
  case 'price':
70
  $filterModelName = 'catalog/layer_filter_price';
65
  }
66
  if ($layer->getCurrentCategory()->getIsAnchor()) {
67
  foreach ($layer->getFilterableAttributes() as $attributeItem) {
68
+ $filterModelName = 'catalog/layer_filter_attribute';
69
  switch ($attributeItem->getAttributeCode()) {
70
  case 'price':
71
  $filterModelName = 'catalog/layer_filter_price';
app/code/core/Mage/XmlConnect/Model/Resource/Images.php DELETED
@@ -1,89 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Images resource model
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Resource_Images extends Mage_Core_Model_Resource_Db_Abstract
35
- {
36
- /**
37
- * Initialize connection and define resource
38
- *
39
- */
40
- protected function _construct()
41
- {
42
- $this->_init('xmlconnect/images', 'image_id');
43
- }
44
-
45
- /**
46
- * Repair image order for application by type
47
- *
48
- * @param Mage_Core_Model_Abstract $image
49
- * @return Mage_XmlConnect_Model_Resource_Images
50
- */
51
- public function repairOrder(Mage_Core_Model_Abstract $image)
52
- {
53
- $bind = array(':application_id' => (int)$image->getApplicationId(), ':image_type' => $image->getImageType());
54
-
55
- $select = $this->_getWriteAdapter()->select()->from($this->getMainTable(), array('image_id'))
56
- ->where('application_id=:application_id AND image_type=:image_type')
57
- ->order('order', Varien_Data_Collection::SORT_ORDER_ASC);
58
-
59
- $result = $this->_getWriteAdapter()->fetchCol($select, $bind);
60
- $imageModel = Mage::getModel('xmlconnect/images');
61
- $i = 0;
62
- foreach ($result as $image_id) {
63
- $imageModel->load($image_id)->setOrder(++$i)->save();
64
- }
65
- return $this;
66
- }
67
-
68
- /**
69
- * Save image data
70
- *
71
- * @param int $applicationId
72
- * @param string $imageFile
73
- * @param string $imageType
74
- * @param string $order
75
- * @return Mage_XmlConnect_Model_Resource_Images
76
- */
77
- public function saveImage($applicationId, $imageFile, $imageType, $order)
78
- {
79
- $newData = array(
80
- 'application_id' => $applicationId,
81
- 'image_file' => $imageFile,
82
- 'image_type' => $imageType,
83
- 'order' => $order
84
- );
85
-
86
- $this->_getWriteAdapter()->insert($this->getMainTable(), $newData);
87
- return $this;
88
- }
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Resource/Images/Collection.php DELETED
@@ -1,91 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Images resource collection
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_Xmlconnect_Model_Resource_Images_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
35
- {
36
- /**
37
- * Init resource model
38
- */
39
- protected function _construct()
40
- {
41
- $this->_init('xmlconnect/images');
42
- }
43
-
44
- /**
45
- * Add application filter
46
- *
47
- * @param integer $appId
48
- * @return Mage_Xmlconnect_Model_Images_Collection
49
- */
50
- public function addApplicationToFilter($appId)
51
- {
52
- $this->addFieldToFilter('application_id', $appId);
53
- return $this;
54
- }
55
-
56
- /**
57
- * Add image type filter
58
- *
59
- * @param integer $type
60
- * @return Mage_Xmlconnect_Model_Images_Collection
61
- */
62
- public function addImageTypeToFilter($type)
63
- {
64
- $this->addFieldToFilter('image_type', $type);
65
- return $this;
66
- }
67
-
68
- /**
69
- * Set Order by position
70
- *
71
- * @return Mage_Xmlconnect_Model_Images_Collection
72
- */
73
- public function setPositionOrder()
74
- {
75
- $this->setOrder('main_table.order', self::SORT_ORDER_ASC);
76
- return $this;
77
- }
78
-
79
- /**
80
- * Sets a limit count and offset to the query.
81
- *
82
- * @param int $count OPTIONAL The number of rows to return.
83
- * @param int $offset OPTIONAL Start returning after this many rows.
84
- * @return Mage_Xmlconnect_Model_Resource_Images_Collection
85
- */
86
- public function setLimit($count = null, $offset = null)
87
- {
88
- $this->getSelect()->limit($count, $offset);
89
- return $this;
90
- }
91
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Simplexml/Element.php CHANGED
@@ -42,7 +42,7 @@ class Mage_XmlConnect_Model_Simplexml_Element extends Varien_Simplexml_Element
42
  public function appendChild($source)
43
  {
44
  if (sizeof($source->children())) {
45
- $name = $source->getName();
46
  $child = $this->addChild($name);
47
  } else {
48
  $child = $this->addChild($source->getName(), $this->xmlentities($source));
@@ -97,7 +97,7 @@ class Mage_XmlConnect_Model_Simplexml_Element extends Varien_Simplexml_Element
97
  *
98
  * @param string $value
99
  * @param bool $stripTags
100
- * @return string|Mage_XmlConnect_Model_Simplexml_Element|null
101
  */
102
  public function xmlAttribute($value = null, $stripTags = true)
103
  {
42
  public function appendChild($source)
43
  {
44
  if (sizeof($source->children())) {
45
+ $name = $source->getName();
46
  $child = $this->addChild($name);
47
  } else {
48
  $child = $this->addChild($source->getName(), $this->xmlentities($source));
97
  *
98
  * @param string $value
99
  * @param bool $stripTags
100
+ * @return string|this
101
  */
102
  public function xmlAttribute($value = null, $stripTags = true)
103
  {
app/code/core/Mage/XmlConnect/Model/Simplexml/Form.php CHANGED
@@ -352,8 +352,7 @@ class Mage_XmlConnect_Model_Simplexml_Form extends Mage_XmlConnect_Model_Simplex
352
  public function toXmlObject()
353
  {
354
  $xmlObj = $this->getXmlObject();
355
- $useContainer = $this->getUseContainer();
356
- if ($useContainer) {
357
  $this->_addRequiredAttributes($xmlObj);
358
  foreach ($this->getAttributes() as $key => $val) {
359
  $xmlObj->addAttribute($key, $xmlObj->xmlAttribute($val));
@@ -386,27 +385,4 @@ class Mage_XmlConnect_Model_Simplexml_Form extends Mage_XmlConnect_Model_Simplex
386
  }
387
  Mage::throwException(Mage::helper('xmlconnect')->__('Container is not defined.'));
388
  }
389
-
390
- /**
391
- * Add suffix to form element name
392
- *
393
- * @param string $name
394
- * @param string $suffix
395
- * @return string
396
- */
397
- public function addSuffixToName($name, $suffix)
398
- {
399
- if (!$name) {
400
- return $suffix;
401
- }
402
- $vars = explode('[', $name);
403
- $newName = $suffix;
404
- foreach ($vars as $index => $value) {
405
- $newName .= '[' . $value;
406
- if ($index == 0) {
407
- $newName .= ']';
408
- }
409
- }
410
- return $newName;
411
- }
412
  }
352
  public function toXmlObject()
353
  {
354
  $xmlObj = $this->getXmlObject();
355
+ if ($useContainer = $this->getUseContainer()) {
 
356
  $this->_addRequiredAttributes($xmlObj);
357
  foreach ($this->getAttributes() as $key => $val) {
358
  $xmlObj->addAttribute($key, $xmlObj->xmlAttribute($val));
385
  }
386
  Mage::throwException(Mage::helper('xmlconnect')->__('Container is not defined.'));
387
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  }
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Abstract.php CHANGED
@@ -386,7 +386,7 @@ class Mage_XmlConnect_Model_Simplexml_Form_Abstract extends Varien_Object
386
 
387
  foreach ($this->getRequiredXmlAttributes() as $attribute => $defValue) {
388
  $data = $this->getData($this->_underscore($attribute));
389
- if (null !== $data) {
390
  $xmlObj->addAttribute($attribute, $xmlObj->xmlAttribute($data));
391
  } elseif(null !== $defValue){
392
  $xmlObj->addAttribute($attribute, $xmlObj->xmlAttribute($defValue));
386
 
387
  foreach ($this->getRequiredXmlAttributes() as $attribute => $defValue) {
388
  $data = $this->getData($this->_underscore($attribute));
389
+ if ($data) {
390
  $xmlObj->addAttribute($attribute, $xmlObj->xmlAttribute($data));
391
  } elseif(null !== $defValue){
392
  $xmlObj->addAttribute($attribute, $xmlObj->xmlAttribute($defValue));
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Abstract.php CHANGED
@@ -118,9 +118,6 @@ abstract class Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
118
  */
119
  public function getXmlId()
120
  {
121
- if (!$this->getForm()) {
122
- return parent::getXmlId();
123
- }
124
  return $this->getForm()->getXmlIdPrefix() . $this->getData('xml_id') . $this->getForm()->getXmlIdSuffix();
125
  }
126
 
@@ -132,11 +129,7 @@ abstract class Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
132
  public function getName()
133
  {
134
  $name = $this->getData('name');
135
- $suffix = null;
136
- if ($this->getForm()) {
137
- $suffix = $this->getForm()->getFieldNameSuffix();
138
- }
139
- if ($name && $suffix) {
140
  $name = $this->getForm()->addSuffixToName($name, $suffix);
141
  }
142
  return $name;
@@ -220,6 +213,7 @@ abstract class Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
220
  }
221
 
222
  $this->addAfterXmlElementToObj($xmlObj);
 
223
  return $xmlObj;
224
  }
225
 
@@ -297,7 +291,7 @@ abstract class Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
297
  */
298
  public function getXml()
299
  {
300
- return $this->toXmlObject()->asNiceXml();
301
  }
302
 
303
  /**
118
  */
119
  public function getXmlId()
120
  {
 
 
 
121
  return $this->getForm()->getXmlIdPrefix() . $this->getData('xml_id') . $this->getForm()->getXmlIdSuffix();
122
  }
123
 
129
  public function getName()
130
  {
131
  $name = $this->getData('name');
132
+ if ($suffix = $this->getForm()->getFieldNameSuffix()) {
 
 
 
 
133
  $name = $this->getForm()->addSuffixToName($name, $suffix);
134
  }
135
  return $name;
213
  }
214
 
215
  $this->addAfterXmlElementToObj($xmlObj);
216
+
217
  return $xmlObj;
218
  }
219
 
291
  */
292
  public function getXml()
293
  {
294
+ return $this->toXmlObject->asNiceXml();
295
  }
296
 
297
  /**
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/CountryListSelect.php CHANGED
@@ -61,10 +61,9 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_CountryListSelect
61
  $value = $this->getValue();
62
 
63
  foreach ($this->_countryListValues as $param) {
64
- if (!isset($value[$param])) {
65
- continue;
66
  }
67
- $this->setData($param, $value[$param]);
68
  }
69
 
70
  return $this;
@@ -97,9 +96,9 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_CountryListSelect
97
  $selectedCountry = array('selected' => 1);
98
  }
99
 
100
- $item = $valuesXmlObj->addCustomChild('item', null, array(
101
- 'relation' => $relationType
102
- ) + $selectedCountry);
103
 
104
  $item->addCustomChild('label', (string)$data['label']);
105
  $item->addCustomChild('value', $data['value']);
@@ -133,7 +132,6 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_CountryListSelect
133
  protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
134
  {
135
  $this->_setValues();
136
- $form = $this->getForm();
137
 
138
  if ($this->getOldFormat()) {
139
  $this->_addOldStandardValue($xmlObj);
@@ -149,28 +147,20 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_CountryListSelect
149
  $values = $xmlObj->addCustomChild('values');
150
  foreach ($countries as $data) {
151
  $regions = array();
152
- $countryValueAttribute = '';
153
  if ($data['value']) {
154
  $regions = $this->_getRegionOptions($data['value']);
155
  }
156
 
157
  if (is_array($regions) && !empty($regions)) {
158
  $relationType = 'region_id';
159
- $countryValueAttribute = $data['value'];
160
  } else {
161
  $relationType = 'region';
162
  }
163
 
164
- $countryData = array(
165
- 'relation' => $relationType,
166
- 'label' => (string)$data['label']
167
- );
168
-
169
- if ($countryValueAttribute) {
170
- $countryData['value'] = $countryValueAttribute;
171
- }
172
-
173
- $item = $values->addCustomChild('item', $data['value'], $countryData);
174
 
175
  if ($relationType !== 'region') {
176
 
@@ -179,41 +169,24 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_CountryListSelect
179
  $selectedRegion = array('value' => $this->getRegionId());
180
  }
181
 
182
- $suffix = $form->getFieldNameSuffix();
183
- $regionFieldName = 'region_id';
184
- if ($suffix) {
185
- $regionFieldName = $form->addSuffixToName($regionFieldName, $suffix);
186
- }
187
-
188
  $regionsXmlObj = $item->addCustomChild('field', null, array(
189
- 'id' => 'region_id_' . $data['value'],
190
- 'name' => $regionFieldName,
191
- 'label' => Mage::helper('xmlconnect')->__('State/Province'),
192
- 'type' => 'select',
193
- 'required' => 1
194
- ) + $selectedRegion
195
- );
196
 
197
  $regionValues = $regionsXmlObj->addCustomChild('values');
198
 
199
  foreach ($regions as $regionData) {
200
- // Skip "Please select" item
201
- if ($regionData['value'] == 0) {
202
- continue;
203
- }
204
- $regionValues->addCustomChild('item', (string)$regionData['value'], array(
205
- 'label' => (string)$regionData['label']
206
  ));
207
  }
208
  } elseif ($this->getCountryId() == $data['value']) {
209
- $item->addAttribute('value', $data['value']);
210
  $item->addCustomChild('field', null, array(
211
- 'id' => 'region_' . $data['value'],
212
- 'name' => 'region',
213
- 'label' => Mage::helper('xmlconnect')->__('State/Province'),
214
- 'type' => 'text',
215
- 'value' => $this->getRegion(),
216
- 'required' => 1
217
  ));
218
  }
219
  }
61
  $value = $this->getValue();
62
 
63
  foreach ($this->_countryListValues as $param) {
64
+ if (isset($value[$param])) {
65
+ $this->setData($param, $value[$param]);
66
  }
 
67
  }
68
 
69
  return $this;
96
  $selectedCountry = array('selected' => 1);
97
  }
98
 
99
+ $item = $valuesXmlObj->addCustomChild('item', null,
100
+ array('relation' => $relationType) + $selectedCountry
101
+ );
102
 
103
  $item->addCustomChild('label', (string)$data['label']);
104
  $item->addCustomChild('value', $data['value']);
132
  protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
133
  {
134
  $this->_setValues();
 
135
 
136
  if ($this->getOldFormat()) {
137
  $this->_addOldStandardValue($xmlObj);
147
  $values = $xmlObj->addCustomChild('values');
148
  foreach ($countries as $data) {
149
  $regions = array();
150
+
151
  if ($data['value']) {
152
  $regions = $this->_getRegionOptions($data['value']);
153
  }
154
 
155
  if (is_array($regions) && !empty($regions)) {
156
  $relationType = 'region_id';
 
157
  } else {
158
  $relationType = 'region';
159
  }
160
 
161
+ $item = $values->addCustomChild('item', null, array(
162
+ 'relation' => $relationType, 'label' => (string)$data['label'], 'value' => $data['value']
163
+ ));
 
 
 
 
 
 
 
164
 
165
  if ($relationType !== 'region') {
166
 
169
  $selectedRegion = array('value' => $this->getRegionId());
170
  }
171
 
 
 
 
 
 
 
172
  $regionsXmlObj = $item->addCustomChild('field', null, array(
173
+ 'id' => 'region_list_' . $data['value'], 'name' => 'region_id',
174
+ 'label' => Mage::helper('xmlconnect')->__('State/Province'), 'type' => 'select',
175
+ 'required' => 1
176
+ ) + $selectedRegion);
 
 
 
177
 
178
  $regionValues = $regionsXmlObj->addCustomChild('values');
179
 
180
  foreach ($regions as $regionData) {
181
+ $regionValues->addCustomChild('item', null, array(
182
+ 'label' => (string)$regionData['label'], 'value' => (string)$regionData['value']
 
 
 
 
183
  ));
184
  }
185
  } elseif ($this->getCountryId() == $data['value']) {
 
186
  $item->addCustomChild('field', null, array(
187
+ 'id' => 'region_' . $data['value'], 'name' => 'region',
188
+ 'label' => Mage::helper('xmlconnect')->__('State/Province'), 'type' => 'text',
189
+ 'value' => $this->getRegion(), 'required' => 1
 
 
 
190
  ));
191
  }
192
  }
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Custom.php DELETED
@@ -1,71 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect form custom element
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Simplexml_Form_Element_Custom extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
35
- {
36
- /**
37
- * Init custom element
38
- *
39
- * @param array $attributes
40
- */
41
- public function __construct($attributes = array())
42
- {
43
- parent::__construct($attributes);
44
- $this->setType('custom');
45
- }
46
-
47
- /**
48
- * Add required attributes to validator rule
49
- *
50
- * @throws Mage_Core_Exception
51
- * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
52
- * @return Mage_XmlConnect_Model_Simplexml_Form_Element_Custom
53
- */
54
- protected function _addRequiredAttributes(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
55
- {
56
- $this->_addId($xmlObj);
57
-
58
- foreach ($this->getRequiredXmlAttributes() as $attribute => $defValue) {
59
- $data = $this->getData($this->_underscore($attribute));
60
-
61
- if (null !== $data) {
62
- $xmlObj->addAttribute($attribute, $xmlObj->xmlAttribute($data));
63
- } elseif(null !== $defValue){
64
- $xmlObj->addAttribute($attribute, $xmlObj->xmlAttribute($defValue));
65
- } else {
66
- Mage::throwException(Mage::helper('xmlconnect')->__('%s attribute is required.', $attribute));
67
- }
68
- }
69
- return $this;
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Date.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Model_Simplexml_Form_Element_Date extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
 
35
  {
36
  /**
37
  * Init multiline element
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Model_Simplexml_Form_Element_Date
35
+ extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
36
  {
37
  /**
38
  * Init multiline element
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Email.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Model_Simplexml_Form_Element_Email extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
 
35
  {
36
  /**
37
  * Init email element
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Model_Simplexml_Form_Element_Email
35
+ extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
36
  {
37
  /**
38
  * Init email element
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Fieldset.php CHANGED
@@ -86,11 +86,9 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset
86
  foreach ($this->getAttributes() as $key => $val) {
87
  $xmlObj->addAttribute($key, $xmlObj->xmlAttribute($val));
88
  }
89
-
90
  foreach ($this->getChildrenXml(false) as $element) {
91
  $xmlObj->appendChild($element);
92
  }
93
-
94
  foreach ($this->getChildrenXml(true) as $fieldset) {
95
  $xmlObj->appendChild($fieldset);
96
  }
86
  foreach ($this->getAttributes() as $key => $val) {
87
  $xmlObj->addAttribute($key, $xmlObj->xmlAttribute($val));
88
  }
 
89
  foreach ($this->getChildrenXml(false) as $element) {
90
  $xmlObj->appendChild($element);
91
  }
 
92
  foreach ($this->getChildrenXml(true) as $fieldset) {
93
  $xmlObj->appendChild($fieldset);
94
  }
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/File.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Model_Simplexml_Form_Element_File extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
 
35
  {
36
  /**
37
  * Init text element
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Model_Simplexml_Form_Element_File
35
+ extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
36
  {
37
  /**
38
  * Init text element
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Image.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Model_Simplexml_Form_Element_Image extends Mage_XmlConnect_Model_Simplexml_Form_Element_File
 
35
  {
36
  /**
37
  * Init text element
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Model_Simplexml_Form_Element_Image
35
+ extends Mage_XmlConnect_Model_Simplexml_Form_Element_File
36
  {
37
  /**
38
  * Init text element
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Multiline.php CHANGED
@@ -71,7 +71,10 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_Multiline
71
  */
72
  public function getRequiredXmlAttributes()
73
  {
74
- return array('label' => null, 'type' => null);
 
 
 
75
  }
76
 
77
  /**
71
  */
72
  public function getRequiredXmlAttributes()
73
  {
74
+ return array(
75
+ 'label' => null,
76
+ 'type' => null
77
+ );
78
  }
79
 
80
  /**
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Multiselect.php CHANGED
@@ -60,6 +60,7 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_Multiselect
60
 
61
  $valuesXmlObj = $xmlObj->addCustomChild('values');
62
  foreach ($this->getOptions() as $option) {
 
63
  if (empty($option['value'])) {
64
  continue;
65
  }
@@ -69,7 +70,10 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_Multiselect
69
  $selected = array('selected' => 1);
70
  }
71
 
72
- $valuesXmlObj->addCustomChild('item', $option['value'], array('label' => $option['label']) + $selected);
 
 
 
73
  }
74
 
75
  return $this;
60
 
61
  $valuesXmlObj = $xmlObj->addCustomChild('values');
62
  foreach ($this->getOptions() as $option) {
63
+
64
  if (empty($option['value'])) {
65
  continue;
66
  }
70
  $selected = array('selected' => 1);
71
  }
72
 
73
+ $valuesXmlObj->addCustomChild('item', null, array(
74
+ 'label' => $option['label'],
75
+ 'value' => $option['value']
76
+ ) + $selected);
77
  }
78
 
79
  return $this;
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Password.php DELETED
@@ -1,47 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * Xmlconnect form password element
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Simplexml_Form_Element_Password
35
- extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
36
- {
37
- /**
38
- * Init password element
39
- *
40
- * @param array $attributes
41
- */
42
- public function __construct($attributes = array())
43
- {
44
- parent::__construct($attributes);
45
- $this->setType('password');
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Select.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Model_Simplexml_Form_Element_Select extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
 
35
  {
36
  /**
37
  * Init text element
@@ -54,7 +55,10 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_Select extends Mage_XmlConnec
54
  {
55
  $value = $this->getEscapedValue();
56
  if ($value !== null) {
57
- $xmlObj->addAttribute('value', $xmlObj->xmlAttribute($value));
 
 
 
58
  }
59
  $this->_addOptions($xmlObj);
60
 
@@ -72,10 +76,15 @@ class Mage_XmlConnect_Model_Simplexml_Form_Element_Select extends Mage_XmlConnec
72
  if ($this->getOptions() && is_array($this->getOptions())) {
73
  $valuesXmlObj = $xmlObj->addCustomChild('values');
74
  foreach ($this->getOptions() as $option) {
75
- if (empty($option['value'])) {
 
76
  continue;
77
  }
78
- $valuesXmlObj->addCustomChild('item', $option['value'], array('label' => $option['label']));
 
 
 
 
79
  }
80
  }
81
  }
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Model_Simplexml_Form_Element_Select
35
+ extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
36
  {
37
  /**
38
  * Init text element
55
  {
56
  $value = $this->getEscapedValue();
57
  if ($value !== null) {
58
+ $xmlObj->addAttribute(
59
+ 'value',
60
+ $xmlObj->xmlAttribute($value)
61
+ );
62
  }
63
  $this->_addOptions($xmlObj);
64
 
76
  if ($this->getOptions() && is_array($this->getOptions())) {
77
  $valuesXmlObj = $xmlObj->addCustomChild('values');
78
  foreach ($this->getOptions() as $option) {
79
+
80
+ if (!isset($option['value']) || $option['value'] == '') {
81
  continue;
82
  }
83
+
84
+ $valuesXmlObj->addCustomChild('item', null, array(
85
+ 'label' => $option['label'],
86
+ 'value' => $option['value']
87
+ ));
88
  }
89
  }
90
  }
app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Text.php CHANGED
@@ -31,7 +31,8 @@
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Mage_XmlConnect_Model_Simplexml_Form_Element_Text extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
 
35
  {
36
  /**
37
  * Init text element
31
  * @package Mage_XmlConnect
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Mage_XmlConnect_Model_Simplexml_Form_Element_Text
35
+ extends Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
36
  {
37
  /**
38
  * Init text element
app/code/core/Mage/XmlConnect/Model/Simplexml/Message.php DELETED
@@ -1,267 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect simple message class
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Simplexml_Message extends Varien_Object
35
- {
36
- /**
37
- * Message status `error`
38
- */
39
- const MESSAGE_STATUS_ERROR = 'error';
40
-
41
- /**
42
- * Message status `warning`
43
- */
44
- const MESSAGE_STATUS_WARNING = 'warning';
45
-
46
- /**
47
- * Message status `success`
48
- */
49
- const MESSAGE_STATUS_SUCCESS = 'success';
50
-
51
- /**
52
- * Error message decorator
53
- *
54
- * @var Mage_XmlConnect_Model_Simplexml_Message_Abstract
55
- */
56
- protected $_messageRenderer;
57
-
58
- /**
59
- * Message status
60
- *
61
- * @var string
62
- */
63
- protected $_messageStatus;
64
-
65
- /**
66
- * Message code
67
- *
68
- * @var string
69
- */
70
- protected $_messageCode;
71
-
72
- /**
73
- * Message text
74
- *
75
- * @var string|null
76
- */
77
- protected $_messageText;
78
-
79
- /**
80
- * Children message params
81
- *
82
- * @var array
83
- */
84
- protected $_children = array();
85
-
86
- /**
87
- * Flag error in processing the message
88
- *
89
- * @var bool
90
- */
91
- protected $_flagError = false;
92
-
93
- /**
94
- * Init simple xml message
95
- *
96
- * @param string $messageCode
97
- */
98
- public function __construct($messageCode)
99
- {
100
- $this->setMessageCode($messageCode)->_setMessageStatus();
101
-
102
- switch ($this->getMessageStatus()) {
103
- case self::MESSAGE_STATUS_SUCCESS:
104
- case self::MESSAGE_STATUS_WARNING:
105
- $renderer = self::MESSAGE_STATUS_SUCCESS;
106
- break;
107
- case self::MESSAGE_STATUS_ERROR:
108
- $renderer = self::MESSAGE_STATUS_ERROR;
109
- break;
110
- default:
111
- $this->setMessageCode(Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_SERVER_SP_DEFAULT)
112
- ->setMessageText(Mage::helper('xmlconnect')->__('Message type doesn\'t recognized'))
113
- ->_setMessageStatus()->_setFlagError(true);
114
- $renderer = self::MESSAGE_STATUS_ERROR;
115
- break;
116
- }
117
- $this->_setMessageRenderer(Mage::getModel('xmlconnect/simplexml_message_' . $renderer, $this));
118
- }
119
-
120
- /**
121
- * Get message type
122
- *
123
- * @return Mage_XmlConnect_Model_Simplexml_Message
124
- */
125
- protected function _setMessageStatus()
126
- {
127
- list($messageType) = explode('_', $this->_messageCode);
128
- $this->_messageStatus = $messageType;
129
- return $this;
130
- }
131
-
132
- /**
133
- * Get message status
134
- *
135
- * @return string
136
- */
137
- public function getMessageStatus()
138
- {
139
- return $this->_messageStatus;
140
- }
141
-
142
- /**
143
- * Get message text
144
- *
145
- * @return string|null
146
- */
147
- public function getMessageText()
148
- {
149
- return $this->_messageText;
150
- }
151
-
152
- /**
153
- * set message text
154
- *
155
- * @param string $text
156
- * @return Mage_XmlConnect_Model_Simplexml_Message
157
- */
158
- public function setMessageText($text)
159
- {
160
- if (!$this->_getFlagError()) {
161
- $this->_messageText = $text;
162
- }
163
- return $this;
164
- }
165
-
166
- /**
167
- * Get message code
168
- *
169
- * @return string
170
- */
171
- public function getMessageCode()
172
- {
173
- return $this->_messageCode;
174
- }
175
-
176
- /**
177
- * Set message code
178
- *
179
- * @param string $messageCode
180
- * @return Mage_XmlConnect_Model_Simplexml_Message
181
- */
182
- public function setMessageCode($messageCode)
183
- {
184
- if (!$this->_getFlagError()) {
185
- $this->_messageCode = $messageCode;
186
- }
187
- return $this;
188
- }
189
-
190
- /**
191
- * Convert object attributes to string
192
- *
193
- * @return string
194
- */
195
- public function __toString()
196
- {
197
- return $this->_getMessageRenderer()->getMessage();
198
- }
199
-
200
- /**
201
- * Set children message params
202
- *
203
- * @param array $children
204
- * @return Mage_XmlConnect_Model_Simplexml_Message
205
- */
206
- public function setChildren($children)
207
- {
208
- if (!$this->_getFlagError()) {
209
- $this->_children = $children;
210
- }
211
- return $this;
212
- }
213
-
214
- /**
215
- * Set children message params
216
- *
217
- * @return array
218
- */
219
- public function getChildren()
220
- {
221
- return $this->_children;
222
- }
223
-
224
- /**
225
- * Get message renderer
226
- *
227
- * @return Mage_XmlConnect_Model_Simplexml_Message_Abstract
228
- */
229
- protected function _getMessageRenderer()
230
- {
231
- return $this->_messageRenderer;
232
- }
233
-
234
- /**
235
- * Set message renderer
236
- *
237
- * @param Mage_XmlConnect_Model_Simplexml_Message_Abstract $messageRenderer
238
- * @return Mage_XmlConnect_Model_Simplexml_Message
239
- */
240
- protected function _setMessageRenderer($messageRenderer)
241
- {
242
- $this->_messageRenderer = $messageRenderer;
243
- return $this;
244
- }
245
-
246
- /**
247
- * Get flag error in processing
248
- *
249
- * @return boolean
250
- */
251
- public function _getFlagError()
252
- {
253
- return $this->_flagError;
254
- }
255
-
256
- /**
257
- * Set flag error in processing
258
- *
259
- * @param boolean $flagError
260
- * @return Mage_XmlConnect_Model_Simplexml_Message
261
- */
262
- public function _setFlagError($flagError)
263
- {
264
- $this->_flagError = $flagError;
265
- return $this;
266
- }
267
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Simplexml/Message/Abstract.php DELETED
@@ -1,142 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect message abstract class
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- abstract class Mage_XmlConnect_Model_Simplexml_Message_Abstract extends Varien_Object
35
- {
36
- /**
37
- * Simple Xml object
38
- *
39
- * @var Mage_XmlConnect_Model_Simplexml
40
- */
41
- protected $_xmlObject;
42
-
43
- /**
44
- * Message model
45
- *
46
- * @var Mage_XmlConnect_Model_Simplexml_Message
47
- */
48
- protected $_messageModel;
49
-
50
- /**
51
- * Init simple xml message
52
- *
53
- * @param Mage_XmlConnect_Model_Simplexml_Message $messageModel
54
- */
55
- public function __construct($messageModel)
56
- {
57
- $this->_xmlObject = Mage::getModel('xmlconnect/simplexml_element', '<message></message>');
58
- $this->_messageModel = $messageModel;
59
- }
60
-
61
- /**
62
- * Get message xml
63
- *
64
- * @abstract
65
- * @return string
66
- */
67
- abstract public function getMessage();
68
-
69
- /**
70
- * Get simple xml message object
71
- *
72
- * @return Mage_XmlConnect_Model_Simplexml_Element
73
- */
74
- protected function _getXmlObject()
75
- {
76
- return $this->_xmlObject;
77
- }
78
-
79
- /**
80
- * Get message code
81
- *
82
- * @return string
83
- */
84
- protected function _getMessageCode()
85
- {
86
- return $this->_messageModel->getMessageCode();
87
- }
88
-
89
- /**
90
- * Set message code
91
- *
92
- * @param string $messageCode
93
- * @return Mage_XmlConnect_Model_Simplexml_Message_Abstract
94
- */
95
- protected function _setMessageCode($messageCode)
96
- {
97
- $this->_messageModel->setMessageCode($messageCode);
98
- return $this;
99
- }
100
-
101
- /**
102
- * Get message text
103
- *
104
- * @return null|string
105
- */
106
- protected function _getMessageText()
107
- {
108
- return $this->_messageModel->getMessageText();
109
- }
110
-
111
- /**
112
- * Set message text
113
- *
114
- * @param string $text
115
- * @return Mage_XmlConnect_Model_Simplexml_Message_Abstract
116
- */
117
- protected function _setMessageText($text)
118
- {
119
- $this->_messageModel->setMessageText($text);
120
- return $this;
121
- }
122
-
123
- /**
124
- * Get message status
125
- *
126
- * @return string
127
- */
128
- protected function _getMessageStatus()
129
- {
130
- return $this->_messageModel->getMessageStatus();
131
- }
132
-
133
- /**
134
- * Get message children
135
- *
136
- * @return array
137
- */
138
- protected function _getChildren()
139
- {
140
- return $this->_messageModel->getChildren();
141
- }
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Simplexml/Message/Error.php DELETED
@@ -1,125 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect error message class
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Simplexml_Message_Error extends Mage_XmlConnect_Model_Simplexml_Message_Abstract
35
- {
36
- /**
37
- * User space default error type
38
- */
39
- const ERROR_USER_SPACE_DEFAULT = 'error_1000';
40
-
41
- /**
42
- * User space account confirmation required
43
- */
44
- const ERROR_USER_SP_ACCOUNT_CONFIRMATION = 'error_1001';
45
-
46
- /**
47
- * User data validation error
48
- */
49
- const ERROR_USER_SP_DATA_VALIDATION = 'error_1002';
50
-
51
- /**
52
- * User data validation error
53
- */
54
- const ERROR_USER_SP_ACCESS_FORBIDDEN = 'error_1003';
55
-
56
- /**
57
- * Client space error default
58
- */
59
- const ERROR_CLIENT_SP_DEFAULT = 'error_2000';
60
-
61
- /**
62
- * User session is expired
63
- */
64
- const ERROR_CLIENT_SP_SESSION_EXPIRED = 'error_2001';
65
-
66
- /**
67
- * Configuration reload required
68
- */
69
- const ERROR_CLIENT_SP_CONFIG_RELOAD_REQUIRED = 'error_2002';
70
-
71
- /**
72
- * Server space default error type
73
- */
74
- const ERROR_SERVER_SP_DEFAULT = 'error_3000';
75
-
76
- /**
77
- * Undefined error type
78
- */
79
- const ERROR_UNDEFINED = 'error_0';
80
-
81
- /**
82
- * Get custom error message list
83
- *
84
- * @return array
85
- */
86
- protected function _getCustomMessageList()
87
- {
88
- return array(
89
- self::ERROR_CLIENT_SP_SESSION_EXPIRED => Mage::helper('xmlconnect')->__('User session is expired'),
90
- self::ERROR_USER_SP_ACCESS_FORBIDDEN => Mage::helper('xmlconnect')->__('Access forbidden')
91
- );
92
- }
93
-
94
- /**
95
- * Get message xml
96
- *
97
- * @return string
98
- */
99
- public function getMessage()
100
- {
101
- $this->_getXmlObject()->addCustomChild('status', $this->_getMessageStatus());
102
- if (!$this->_getMessageText()) {
103
- $this->_setMessageText($this->_getCustomMessageByCode());
104
- }
105
- $this->_getXmlObject()->addCustomChild('text', $this->_getMessageText());
106
- $this->_getXmlObject()->addCustomChild('error_level', substr($this->_getMessageCode(), 6));
107
- return $this->_getXmlObject()->asNiceXml();
108
- }
109
-
110
- /**
111
- * Get custom message by error code
112
- *
113
- * @return string
114
- */
115
- protected function _getCustomMessageByCode()
116
- {
117
- $messages = $this->_getCustomMessageList();
118
- if (!array_key_exists($this->_getMessageCode(), $messages)){
119
- $this->_setMessageCode(self::ERROR_SERVER_SP_DEFAULT);
120
- return Mage::helper('xmlconnect')->__('Error message text is missed.');
121
- } else {
122
- return $messages[$this->_getMessageCode()];
123
- }
124
- }
125
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Simplexml/Message/Success.php DELETED
@@ -1,56 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect success message class
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Model_Simplexml_Message_Success extends Mage_XmlConnect_Model_Simplexml_Message_Abstract
35
- {
36
- /**
37
- * Get message xml
38
- *
39
- * @return string
40
- */
41
- public function getMessage()
42
- {
43
- $this->_getXmlObject()->addCustomChild('status', $this->_getMessageStatus());
44
- if (!$this->_getMessageText()) {
45
- $this->_setMessageText(Mage::helper('xmlconnect')->__('Message text is missed.'));
46
- }
47
- $this->_getXmlObject()->addCustomChild('text', $this->_getMessageText());
48
- if ($this->_getChildren()) {
49
- $extDataXmlObj = $this->_getXmlObject()->addCustomChild('extended_data');
50
- foreach($this->_getChildren() as $key => $val) {
51
- $extDataXmlObj->addCustomChild('item', $val, array('name' => $key));
52
- }
53
- }
54
- return $this->_getXmlObject()->asNiceXml();
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/Model/Theme.php CHANGED
@@ -233,14 +233,14 @@ class Mage_XmlConnect_Model_Theme
233
  /**
234
  * Load data (flat array) for Varien_Data_Form
235
  *
236
- * @param array $subTree
237
  * @param string $prefix
238
  * @return array
239
  */
240
- protected function _flatArray($subTree, $prefix = null)
241
  {
242
  $result = array();
243
- foreach ($subTree as $key => $value) {
244
  if (is_null($prefix)) {
245
  $name = $key;
246
  } else {
@@ -296,7 +296,7 @@ class Mage_XmlConnect_Model_Theme
296
  */
297
  protected function _buildRecursive($parent, $data)
298
  {
299
- foreach ($data as $key => $value) {
300
  if (is_array($value)) {
301
  $this->_buildRecursive($parent->addChild($key), $value);
302
  } else {
@@ -308,13 +308,12 @@ class Mage_XmlConnect_Model_Theme
308
  /**
309
  * Import data into theme form $data array, and save XML to file
310
  *
311
- * @throws Mage_Core_Exception
312
  * @param array $data
313
  * @return null
314
  */
315
  public function importAndSaveData($data)
316
  {
317
- $xml = new SimpleXMLElement('<theme>' . $this->_xml->manifest->asXML() . '</theme>');
318
  $this->_buildRecursive($xml->addChild('configuration'), $this->_validateFormInput($data));
319
  clearstatcache();
320
  if (is_writeable($this->_file)) {
233
  /**
234
  * Load data (flat array) for Varien_Data_Form
235
  *
236
+ * @param array $subtree
237
  * @param string $prefix
238
  * @return array
239
  */
240
+ protected function _flatArray($subtree, $prefix = null)
241
  {
242
  $result = array();
243
+ foreach ($subtree as $key => $value) {
244
  if (is_null($prefix)) {
245
  $name = $key;
246
  } else {
296
  */
297
  protected function _buildRecursive($parent, $data)
298
  {
299
+ foreach ($data as $key=>$value) {
300
  if (is_array($value)) {
301
  $this->_buildRecursive($parent->addChild($key), $value);
302
  } else {
308
  /**
309
  * Import data into theme form $data array, and save XML to file
310
  *
 
311
  * @param array $data
312
  * @return null
313
  */
314
  public function importAndSaveData($data)
315
  {
316
+ $xml = new SimpleXMLElement('<theme>'.$this->_xml->manifest->asXML().'</theme>');
317
  $this->_buildRecursive($xml->addChild('configuration'), $this->_validateFormInput($data));
318
  clearstatcache();
319
  if (is_writeable($this->_file)) {
app/code/core/Mage/XmlConnect/controllers/Adminhtml/Admin/ApplicationController.php DELETED
@@ -1,69 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Adminhtml mobile controller
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Adminhtml_Admin_ApplicationController extends Mage_Adminhtml_Controller_Action
35
- {
36
- /**
37
- * Admin application settings action
38
- */
39
- public function indexAction()
40
- {
41
- try {
42
- $isActive = $this->getRequest()->getParam('is_active', false);
43
- if (false !== $isActive) {
44
- Mage::getSingleton('xmlconnect/configuration')->saveIsActiveAdminApp($isActive);
45
- $this->_getSession()->addSuccess($this->__('Configuration data have been saved'));
46
- }
47
- $this->loadLayout();
48
- $this->_setActiveMenu('xmlconnect/mobile_admin_app');
49
- $this->renderLayout();
50
- } catch (Mage_Core_Exception $e) {
51
- $this->_getSession()->addError($e->getMessage());
52
- $this->_redirect('*/*/');
53
- } catch (Exception $e) {
54
- Mage::logException($e);
55
- $this->_getSession()->addException($e, $this->__('Can\'t load admin application settings.'));
56
- $this->_redirect('*/*/');
57
- }
58
- }
59
-
60
- /**
61
- * Check the permission to run it
62
- *
63
- * @return boolean
64
- */
65
- protected function _isAllowed()
66
- {
67
- return Mage::getSingleton('admin/session')->isAllowed('xmlconnect/admin_connect');
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/controllers/Adminhtml/Connect/ConfigController.php DELETED
@@ -1,126 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Adminhtml mobile configuration controller
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Adminhtml_Connect_ConfigController extends Mage_XmlConnect_Controller_AdminAction
35
- {
36
- /**
37
- * Configuration action
38
- */
39
- public function indexAction()
40
- {
41
- try {
42
- if (!$this->_initCookies()) {
43
- return;
44
- }
45
- $this->loadLayout(false);
46
- $this->renderLayout();
47
- } catch (Mage_Core_Exception $e) {
48
- Mage::logException($e);
49
- $this->_message(Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_USER_SPACE_DEFAULT, $e->getMessage());
50
- } catch (Exception $e) {
51
- Mage::logException($e);
52
- $this->_message(
53
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_SERVER_SP_DEFAULT,
54
- $this->__('An error occurred while loading configuration.')
55
- );
56
- }
57
- }
58
-
59
- /**
60
- * Localization action
61
- */
62
- public function localizationAction()
63
- {
64
- try {
65
- $this->loadLayout(false);
66
- $this->renderLayout();
67
- } catch (Mage_Core_Exception $e) {
68
- Mage::logException($e);
69
- $this->_message(Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_USER_SPACE_DEFAULT, $e->getMessage());
70
- } catch (Exception $e) {
71
- Mage::logException($e);
72
- $this->_message(
73
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_SERVER_SP_DEFAULT,
74
- $this->__('An error occurred while loading localization.')
75
- );
76
- }
77
- }
78
-
79
- /**
80
- * Set admin application cookies
81
- *
82
- * Set application cookies: application code and device screen size.
83
- *
84
- * @return bool
85
- */
86
- protected function _initCookies()
87
- {
88
- $cookieToSetArray = array(
89
- array(
90
- 'cookieName' => self::DEVICE_TYPE_COOKIE_NAME,
91
- 'paramName' => self::DEVICE_TYPE_COOKIE_NAME,
92
- ),
93
- array(
94
- 'cookieName' => Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_NAME,
95
- 'paramName' => Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_NAME,
96
- ));
97
-
98
- $cookieExpireOffset = 3600 * 24 * 30;
99
- foreach ($cookieToSetArray as $item) {
100
- if ($this->getRequest()->getParam($item['paramName'], false)) {
101
- Mage::getSingleton('core/cookie')->set(
102
- $item['cookieName'],
103
- $this->getRequest()->getParam($item['paramName']),
104
- $cookieExpireOffset, '/', null, null, true
105
- );
106
- } else {
107
- $this->_message(
108
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_CLIENT_SP_DEFAULT,
109
- $this->__('Request param %s is missed', $item['paramName'])
110
- );
111
- return false;
112
- }
113
- }
114
- return true;
115
- }
116
-
117
- /**
118
- * Is check cookie required flag
119
- *
120
- * @return bool
121
- */
122
- protected function _isCheckCookieRequired()
123
- {
124
- return false;
125
- }
126
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/controllers/Adminhtml/Connect/DashboardController.php DELETED
@@ -1,55 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Adminhtml mobile dashboard controller
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Adminhtml_Connect_DashboardController extends Mage_XmlConnect_Controller_AdminAction
35
- {
36
- /**
37
- * Dashboard index action
38
- */
39
- public function indexAction()
40
- {
41
- try {
42
- $this->loadLayout(false);
43
- $this->renderLayout();
44
- } catch (Mage_Core_Exception $e) {
45
- Mage::logException($e);
46
- $this->_message(Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_USER_SPACE_DEFAULT, $e->getMessage());
47
- } catch (Exception $e) {
48
- Mage::logException($e);
49
- $this->_message(
50
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_SERVER_SP_DEFAULT,
51
- $this->__('An error occurred while loading configuration.')
52
- );
53
- }
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/controllers/Adminhtml/Connect/UserController.php DELETED
@@ -1,165 +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_XmlConnect
23
- * @copyright Copyright (c) 2010 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
- * XmlConnect Adminhtml mobile user controller
29
- *
30
- * @category Mage
31
- * @package Mage_XmlConnect
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Mage_XmlConnect_Adminhtml_Connect_UserController extends Mage_XmlConnect_Controller_AdminAction
35
- {
36
- /**
37
- * Get admin user session
38
- *
39
- * @return Mage_Admin_Model_Session
40
- */
41
- protected function _getSession()
42
- {
43
- return Mage::getSingleton('admin/session');
44
- }
45
-
46
- /**
47
- * Login form action
48
- */
49
- public function loginFormAction()
50
- {
51
- try {
52
- $result = $this->loadLayout(false)->getLayout()
53
- ->addBlock('xmlconnect/adminhtml_connect_loginform', 'login_form')->toHtml();
54
- $this->getResponse()->setBody($result);
55
- } catch (Mage_Core_Exception $e) {
56
- Mage::logException($e);
57
- $this->_message(Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_USER_SPACE_DEFAULT, $e->getMessage());
58
- } catch (Exception $e) {
59
- Mage::logException($e);
60
- $this->_message(
61
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_SERVER_SP_DEFAULT,
62
- $this->__('An error occurred while loading login form.')
63
- );
64
- }
65
- }
66
-
67
- /**
68
- * User login action
69
- */
70
- public function loginAction()
71
- {
72
- try {
73
- $session = $this->_getSession();
74
- $request = $this->getRequest();
75
-
76
- if ($session->isLoggedIn()) {
77
- $this->_message(
78
- Mage_XmlConnect_Model_Simplexml_Message::MESSAGE_STATUS_SUCCESS,
79
- $this->__('Authentication complete.')
80
- );
81
- return;
82
- }
83
-
84
- $postLogin = $request->getPost('login_info');
85
- $request->setPost('login_info', null);
86
- if ($postLogin) {
87
- $username = isset($postLogin['username']) ? $postLogin['username'] : '';
88
- $password = isset($postLogin['password']) ? $postLogin['password'] : '';
89
- $user = $session->login($username, $password);
90
- $request->setPost('login', null);
91
- if ($user && $session->isLoggedIn()) {
92
- $this->_message(
93
- Mage_XmlConnect_Model_Simplexml_Message::MESSAGE_STATUS_SUCCESS,
94
- $this->__('Authentication complete.')
95
- );
96
- return;
97
- } else {
98
- $this->_message(
99
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_USER_SPACE_DEFAULT,
100
- $this->__('Invalid login or password.')
101
- );
102
- return;
103
- }
104
- }
105
- $this->_message(
106
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_CLIENT_SP_DEFAULT,
107
- $this->__('Post data is empty.')
108
- );
109
- } catch (Mage_Core_Exception $e) {
110
- $this->_message(Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_USER_SPACE_DEFAULT, $e->getMessage());
111
- } catch (Exception $e) {
112
- Mage::logException($e);
113
- $this->_message(
114
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_SERVER_SP_DEFAULT,
115
- $this->__('An error occurred while loading login form.')
116
- );
117
- }
118
- }
119
-
120
- /**
121
- * User logout action
122
- */
123
- public function logoutAction()
124
- {
125
- try {
126
- $this->_getSession()->unsetAll();
127
- $this->_getSession()->getCookie()->delete($this->_getSession()->getSessionName());
128
- $this->_message(
129
- Mage_XmlConnect_Model_Simplexml_Message::MESSAGE_STATUS_SUCCESS,
130
- Mage::helper('adminhtml')->__('You have logged out.')
131
- );
132
- } catch (Mage_Core_Exception $e) {
133
- $this->_message(Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_USER_SPACE_DEFAULT, $e->getMessage());
134
- } catch (Exception $e) {
135
- Mage::logException($e);
136
- $this->_message(
137
- Mage_XmlConnect_Model_Simplexml_Message_Error::ERROR_SERVER_SP_DEFAULT,
138
- $this->__('An error occurred while loading login form.')
139
- );
140
- }
141
- }
142
-
143
- /**
144
- * Check the permission to run actions
145
- *
146
- * @return boolean
147
- */
148
- protected function _isAllowed()
149
- {
150
- if (!Mage::getSingleton('xmlconnect/configuration')->isActiveAdminApp()) {
151
- $this->_forward('denied');
152
- }
153
- return true;
154
- }
155
-
156
- /**
157
- * Is check cookie required flag
158
- *
159
- * @return bool
160
- */
161
- protected function _isCheckCookieRequired()
162
- {
163
- return false;
164
- }
165
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php CHANGED
@@ -37,10 +37,10 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
37
  * Initialize application
38
  *
39
  * @param string $paramName
40
- * @param bool|string $deviceType
41
  * @return Mage_XmlConnect_Model_Application
42
  */
43
- protected function _initApp($paramName = 'application_id', $deviceType = false)
44
  {
45
  $id = (int) $this->getRequest()->getParam($paramName);
46
  $app = Mage::getModel('xmlconnect/application');
@@ -50,7 +50,7 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
50
  $app->loadConfiguration();
51
  }
52
  } else {
53
- $app->setType($deviceType);
54
  Mage::register('current_app', $app);
55
  $app->loadDefaultConfiguration();
56
  Mage::unregister('current_app');
@@ -62,7 +62,6 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
62
  /**
63
  * Restore data from session $_POST and $_FILES (processed)
64
  *
65
- * @todo remove this method from controller
66
  * @param array $data
67
  * @return array|null
68
  */
@@ -196,7 +195,6 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
196
  } catch (Mage_Core_Exception $e) {
197
  $this->_getSession()->addError($e->getMessage());
198
  $redirectBack = true;
199
- Mage::logException($e);
200
  } catch (Exception $e) {
201
  $this->_getSession()->addError($this->__('Unable to load application form.'));
202
  $redirectBack = true;
@@ -228,10 +226,8 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
228
  if (!empty($newAppData)) {
229
  $app->setData(Mage::helper('xmlconnect')->arrayMergeRecursive($app->getData(), $newAppData));
230
  }
231
-
232
  $params = $app->prepareSubmitParams($data);
233
  $errors = $app->validateSubmit($params);
234
-
235
  if ($errors !== true) {
236
  foreach ($errors as $err) {
237
  $this->_getSession()->addError($err);
@@ -242,14 +238,10 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
242
  $this->_processPostRequest();
243
  $history = Mage::getModel('xmlconnect/history');
244
  $history->setData(array(
245
- 'params' => $params,
246
- 'application_id' => $app->getId(),
247
- 'created_at' => Mage::getModel('core/date')->date(),
248
- 'store_id' => $app->getStoreId(),
249
- 'title' => isset($params['title']) ? $params['title'] : '',
250
- 'name' => $app->getName(),
251
- 'code' => $app->getCode(),
252
- 'activation_key' => isset($params['resubmission_activation_key'])
253
  ? $params['resubmission_activation_key'] : $params['key'],
254
  ));
255
  $history->save();
@@ -307,7 +299,7 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
307
  * Clear session data
308
  * Used after successful save/submit action
309
  *
310
- * @return Mage_XmlConnect_Adminhtml_MobileController
311
  */
312
  protected function _clearSessionData()
313
  {
@@ -330,26 +322,24 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
330
  $params = $app->getSubmitParams();
331
 
332
  $appConnectorUrl = Mage::getStoreConfig('xmlconnect/mobile_application/magentocommerce_url');
333
- $curlHandler = curl_init($appConnectorUrl . $params['key']);
334
-
335
- // set URL and other appropriate options
336
- curl_setopt($curlHandler, CURLOPT_POST, 1);
337
- curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $params);
338
- curl_setopt($curlHandler, CURLOPT_SSL_VERIFYHOST, 2);
339
- curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1);
340
- curl_setopt($curlHandler, CURLOPT_SSL_VERIFYPEER, 0);
341
- curl_setopt($curlHandler, CURLOPT_TIMEOUT, 60);
342
-
343
- // Execute the request.
344
- $result = curl_exec($curlHandler);
345
-
346
- if (curl_exec($curlHandler) === false) {
347
- Mage::log('Curl error: ' . curl_error($curlHandler));
348
- Mage::log(curl_getinfo($curlHandler));
349
- }
350
 
351
- // close cURL resource, and free up system resources
352
- curl_close($curlHandler);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
  // Assert that we received an expected message in reponse.
355
  $resultArray = json_decode($result, true);
@@ -363,14 +353,7 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
363
  if (is_array($message)) {
364
  $message = implode(' ,', $message);
365
  }
366
-
367
- if (isset($params['resubmission_activation_key'])) {
368
- $message = $this->__('Resubmit App failure. %s', $message);
369
- } else {
370
- $message = $this->__('Submit App failure. %s', $message);
371
- }
372
-
373
- Mage::throwException($message);
374
  }
375
  } catch (Exception $e) {
376
  throw $e;
@@ -400,7 +383,7 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
400
  $isError = true;
401
  }
402
  }
403
- /** @var $app Mage_XmlConnect_Model_Application */
404
  $app = $this->_initApp('application_id', $data['devtype']);
405
  if (!$app->getId() && $id) {
406
  $this->_getSession()->addError($this->__('App does not exist.'));
@@ -541,17 +524,6 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
541
  return $conf;
542
  }
543
 
544
- /**
545
- * Save Theme action
546
- *
547
- * @return null
548
- */
549
- public function saveThemeAction()
550
- {
551
- $data = $this->getRequest()->getPost();
552
- $this->_saveThemeAction($data);
553
- }
554
-
555
  /**
556
  * Delete theme action
557
  *
@@ -579,7 +551,7 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
579
  );
580
  }
581
  } catch (Mage_Core_Exception $e) {
582
- $response = array('error' => true, 'message' => $e->getMessage());
583
  } catch (Exception $e) {
584
  $response = array(
585
  'error' => true,
@@ -596,7 +568,18 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
596
  }
597
 
598
  /**
599
- * Reset Theme action
 
 
 
 
 
 
 
 
 
 
 
600
  *
601
  * @return null
602
  */
@@ -823,7 +806,6 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
823
  * Process all uploaded files
824
  * setup file names to the configuration return array
825
  *
826
- * @todo remove this method from controller
827
  * @param array $data
828
  * @param bool $restore
829
  * @return array
@@ -862,36 +844,41 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
862
  * Prepare post data
863
  * Retains previous data in the object.
864
  *
865
- * @todo remove this method from controller
866
  * @param array $arr
867
  * @return array
868
  */
869
  public function _preparePostData(array $arr)
870
  {
871
  unset($arr['code']);
872
-
873
- $pageId = 0;
874
- if (!empty($arr['config_data'])) {
875
- foreach ($arr['config_data'] as $path => $data) {
876
- if (!preg_match('/^pages:staticpage\/(\d+)$/', $path, $pageData)
877
- || empty($data['label']) || empty($data['id'])
878
- ) {
879
- continue;
880
  }
881
- list($savedPath, $pageId) = $pageData;
882
- $arr['config_data']['pages:staticpage/' . $pageId] = serialize($data);
883
  }
 
884
  }
885
- if (isset($arr['config_data']['new_pages'])) {
886
- $pageId++;
887
- foreach ($arr['config_data']['new_pages'] as $page) {
888
- if (empty($page['label']) || empty($page['id'])) {
889
- continue;
 
 
 
890
  }
891
- $arr['config_data']['pages:staticpage/' . $pageId] = serialize($page);
892
- $pageId++;
893
  }
894
- unset($arr['config_data']['new_pages']);
 
 
 
 
 
 
895
  }
896
 
897
  /**
@@ -1178,8 +1165,9 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
1178
  break;
1179
  }
1180
  if ($temporaryObject->getExecTime()) {
1181
- $execTime = Mage::getSingleton('core/date')->gmtDate(null, $temporaryObject->getExecTime());
1182
- $message->setExecTime($execTime ? $execTime : Mage::getSingleton('core/date')->gmtDate());
 
1183
  } else {
1184
  $message->setExecTime(new Zend_Db_Expr('NULL'));
1185
  }
@@ -1329,13 +1317,13 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
1329
  }
1330
 
1331
  if (isset($template)) {
1332
- $appId = $template->getApplicationId();
1333
  } else {
1334
- $appId = Mage::getModel('xmlconnect/template')->load($message->getTemplateId())->getApplicationId();
1335
  }
1336
 
1337
  /** @var $app Mage_XmlConnect_Model_Application */
1338
- $app = Mage::getModel('xmlconnect/application')->load($appId);
1339
 
1340
  if(!$app->isNotificationsActive()) {
1341
  $this->_getSession()->addError(
@@ -1352,8 +1340,8 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
1352
  } else {
1353
  $title = $this->__('New AirMail Message');
1354
  }
1355
- $this->_addBreadcrumb(
1356
- $this->__('AirMail Message Queue'), $this->__('AirMail Message Queue'), $this->getUrl('*/*/queue')
1357
  );
1358
  $this->_addBreadcrumb($title, $title);
1359
 
@@ -1370,202 +1358,4 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll
1370
  {
1371
  $this->_forward('queueMessage');
1372
  }
1373
-
1374
- /**
1375
- * Upload file controller action
1376
- */
1377
- public function uploadImagesAction()
1378
- {
1379
- $data = $this->getRequest()->getParams();
1380
- if (isset($data['Filename'])) {
1381
- // Add random string to uploaded file new
1382
- $newFileName = Mage::helper('core')->getRandomString(5) . '_' . $data['Filename'];
1383
- }
1384
- try {
1385
- $this->_initApp();
1386
- /** @var $imageModel Mage_XmlConnect_Model_Images */
1387
- $imageModel = Mage::getModel('xmlconnect/images');
1388
- if (isset($data['image_id']) && $data['image_id'] > 0) {
1389
- $imageModel->load($data['image_id']);
1390
- }
1391
- $imageModel->validateAndSetSubmitData($data)->checkType()->checkApplication();
1392
-
1393
- /** @var $uploader Mage_Core_Model_File_Uploader */
1394
- $uploader = Mage::getModel('core/file_uploader', $imageModel->getImageType());
1395
- $uploader->setAllowRenameFiles(true)->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
1396
- $result = $uploader->save(Mage_XmlConnect_Model_Images::getBasePath(), $newFileName);
1397
- $result['thumbnail'] = Mage::getModel('xmlconnect/images')->getCustomSizeImageUrl(
1398
- $result['file'],
1399
- Mage_XmlConnect_Helper_Data::THUMBNAIL_IMAGE_WIDTH,
1400
- Mage_XmlConnect_Helper_Data::THUMBNAIL_IMAGE_HEIGHT
1401
- );
1402
-
1403
- $imageModel->setImageFile($result['file']);
1404
- $imageModel->save();
1405
-
1406
- $result['cookie'] = array(
1407
- 'name' => session_name(),
1408
- 'value' => $this->_getSession()->getSessionId(),
1409
- 'lifetime' => $this->_getSession()->getCookieLifetime(),
1410
- 'path' => $this->_getSession()->getCookiePath(),
1411
- 'domain' => $this->_getSession()->getCookieDomain(),
1412
- 'order' => $imageModel->getOrder(),
1413
- 'image_id' => $imageModel->getId(),
1414
- 'file_field' => $imageModel->getImageType()
1415
- );
1416
-
1417
- $result['image_list'] = $this->getLayout()
1418
- ->addBlock('xmlconnect/adminhtml_mobile_edit_tab_design_images', 'design_images')
1419
- ->getImageList($imageModel->getImageType(), $imageModel->getImageCount());
1420
-
1421
- } catch (Exception $e) {
1422
- $result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
1423
- }
1424
-
1425
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
1426
- }
1427
-
1428
- /**
1429
- * Get image list by type
1430
- */
1431
- public function imageListAction()
1432
- {
1433
- $data = $this->getRequest()->getParams();
1434
- $result = array();
1435
- try {
1436
- $this->_initApp();
1437
- /** @var $imageModel Mage_XmlConnect_Model_Images */
1438
- $imageModel = Mage::getModel('xmlconnect/images');
1439
- if (!empty($data['image_type'])) {
1440
- $result['image_list'] = $this->getLayout()
1441
- ->addBlock('xmlconnect/adminhtml_mobile_edit_tab_design_images', 'design_images')
1442
- ->getImageList($data['image_type'], $imageModel->getImageCount($data['image_type']));
1443
- }
1444
- } catch (Exception $e) {
1445
- $result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
1446
- }
1447
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
1448
- }
1449
-
1450
- /**
1451
- * Delete device image action
1452
- */
1453
- public function deleteImageAction()
1454
- {
1455
- $imageId = $this->getRequest()->getParam('image_id', false);
1456
- /** @var $imageModel Mage_XmlConnect_Model_Images */
1457
- $imageModel = Mage::getModel('xmlconnect/images');
1458
- try {
1459
- $imageModel->load($imageId);
1460
- if ($imageModel->getId()) {
1461
- $this->_initApp();
1462
- $imageModel->deleteAndRepairOrder();
1463
- $result = array('success' => $this->__('Image has been deleted.'));
1464
- $result['image_list'] = $this->getLayout()
1465
- ->addBlock('xmlconnect/adminhtml_mobile_edit_tab_design_images', 'design_images')
1466
- ->getImageList($imageModel->getImageType(), $imageModel->getImageCount());
1467
- } else {
1468
- $result = array('error' => $this->__('Image does not exist. Please reload this page.'));
1469
- }
1470
- } catch (Exception $e) {
1471
- $result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
1472
- }
1473
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
1474
- }
1475
-
1476
- /**
1477
- * Delete device image action
1478
- */
1479
- public function deleteImageDataAction()
1480
- {
1481
- $imageId = $this->getRequest()->getParam('image_id', false);
1482
- try {
1483
- $this->_initApp();
1484
- if ($imageId) {
1485
- $image = Mage::getModel('xmlconnect/images')->load($imageId)->deleteImageAction();
1486
- $result = array('success' => $this->__('Image has been deleted.'));
1487
- $result['image_list'] = $this->getLayout()
1488
- ->addBlock('xmlconnect/adminhtml_mobile_edit_tab_design_images', 'design_images')
1489
- ->getImageList($image->getImageType(), $image->getImageCount());
1490
- } else {
1491
- $result = array('error' => $this->__('Image id is required.'));
1492
- }
1493
- } catch (Exception $e) {
1494
- $result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
1495
- }
1496
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
1497
- }
1498
-
1499
- /**
1500
- * Save image action
1501
- */
1502
- public function saveImageDataAction()
1503
- {
1504
- $result = array();
1505
- try {
1506
- $imageId = $this->getRequest()->getParam('image_id', false);
1507
- if (!$imageId) {
1508
- Mage::throwException($this->__('image_id is required'));
1509
- }
1510
- $imageConfig = $this->_initApp()->getImageActionModel()->saveImageAction($this->getRequest()->getParams())
1511
- ->getCurrentImageActionData();
1512
- $result['success'] = $this->__('Image action has been saved.');
1513
- $result['image_action_data'] = $imageConfig;
1514
- } catch (Exception $e) {
1515
- Mage::logException($e);
1516
- $result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
1517
- }
1518
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
1519
- }
1520
-
1521
- /**
1522
- * Global Search Action
1523
- */
1524
- public function globalSearchAction()
1525
- {
1526
- $start = $this->getRequest()->getParam('start', 1);
1527
- $limit = $this->getRequest()->getParam('limit', 10);
1528
- $query = $this->getRequest()->getParam('query', '');
1529
- $type = $this->getRequest()->getParam('type', 'product');
1530
-
1531
- if ($type == 'product') {
1532
- $searchModel = Mage::getModel('xmlconnect/adminhtml_search_catalog');
1533
- } else {
1534
- $searchModel = Mage::getModel('xmlconnect/adminhtml_search_category');
1535
- }
1536
- $results = $searchModel->setStart($start)->setLimit($limit)->setQuery($query)->load()->getResults();
1537
-
1538
- $block = $this->getLayout()->createBlock('adminhtml/template')
1539
- ->setTemplate('xmlconnect/edit/tab/design/autocomplete.phtml')->assign('items', $results);
1540
-
1541
- $this->getResponse()->setBody($block->toHtml());
1542
- }
1543
-
1544
- /**
1545
- * Save image order
1546
- */
1547
- public function saveImageOrderAction()
1548
- {
1549
- /** @var $imagesModel Mage_XmlConnect_Model_Images */
1550
- $imagesModel = Mage::getModel('xmlconnect/images');
1551
- $imageData = $this->getRequest()->getParam('data', false);
1552
- $imageType = $this->getRequest()->getParam('type', false);
1553
- try {
1554
-
1555
- if (!$imageType || !$imageData) {
1556
- Mage::throwException($this->__('Type and data is required'));
1557
- }
1558
- $actionModel = $this->_initApp()->getImageActionModel();
1559
-
1560
- $actionModel->saveImageOrder($imageData, $imageType);
1561
- $result = array('success' => $this->__('Images order has been updated.'));
1562
- $result['image_list'] = $this->getL
37
  * Initialize application
38
  *
39
  * @param string $paramName
40
+ * @param bool|string $type
41
  * @return Mage_XmlConnect_Model_Application
42
  */
43
+ protected function _initApp($paramName = 'application_id', $type = false)
44
  {
45
  $id = (int) $this->getRequest()->getParam($paramName);
46
  $app = Mage::getModel('xmlconnect/application');
50
  $app->loadConfiguration();
51
  }
52
  } else {
53
+ $app->setType($type);
54
  Mage::register('current_app', $app);
55
  $app->loadDefaultConfiguration();
56
  Mage::unregister('current_app');
62
  /**
63
  * Restore data from session $_POST and $_FILES (processed)
64
  *
 
65
  * @param array $data
66
  * @return array|null
67
  */
195
  } catch (Mage_Core_Exception $e) {
196
  $this->_getSession()->addError($e->getMessage());
197
  $redirectBack = true;
 
198
  } catch (Exception $e) {
199
  $this->_getSession()->addError($this->__('Unable to load application form.'));
200
  $redirectBack = true;
226
  if (!empty($newAppData)) {
227
  $app->setData(Mage::helper('xmlconnect')->arrayMergeRecursive($app->getData(), $newAppData));
228
  }
 
229
  $params = $app->prepareSubmitParams($data);
230
  $errors = $app->validateSubmit($params);
 
231
  if ($errors !== true) {
232
  foreach ($errors as $err) {
233
  $this->_getSession()->addError($err);
238
  $this->_processPostRequest();
239
  $history = Mage::getModel('xmlconnect/history');
240
  $history->setData(array(
241
+ 'params' => $params, 'application_id' => $app->getId(),
242
+ 'created_at' => Mage::getModel('core/date')->date(), 'store_id' => $app->getStoreId(),
243
+ 'title' => isset($params['title']) ? $params['title'] : '', 'name' => $app->getName(),
244
+ 'code' => $app->getCode(), 'activation_key' => isset($params['resubmission_activation_key'])
 
 
 
 
245
  ? $params['resubmission_activation_key'] : $params['key'],
246
  ));
247
  $history->save();
299
  * Clear session data
300
  * Used after successful save/submit action
301
  *
302
+ * @return this
303
  */
304
  protected function _clearSessionData()
305
  {
322
  $params = $app->getSubmitParams();
323
 
324
  $appConnectorUrl = Mage::getStoreConfig('xmlconnect/mobile_application/magentocommerce_url');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
 
326
+ $curl = new Varien_Http_Adapter_Curl();
327
+ $verifyPeerValue = Mage::getStoreConfig('xmlconnect/mobile_application/curl_ssl_verifypeer');
328
+ $curl->setConfig(array(
329
+ 'timeout' => Mage_XmlConnect_Helper_Data::CURLOPT_DEFAULT_TIMEOUT,
330
+ 'verifypeer' => $verifyPeerValue, 'verifyhost' => 2, 'header' => false
331
+ ));
332
+
333
+ $mCommerceUrl = $appConnectorUrl . $params['key'];
334
+ $curl->write(Zend_Http_Client::POST, $mCommerceUrl, CURL_HTTP_VERSION_1_1, array(), $params);
335
+
336
+ $result = $curl->read();
337
+ if(false === $result) {
338
+ Mage::log('Curl error: ' . $curl->getError());
339
+ $curl->close();
340
+ Mage::throwException($this->__('Request internal error.'));
341
+ }
342
+ $curl->close();
343
 
344
  // Assert that we received an expected message in reponse.
345
  $resultArray = json_decode($result, true);
353
  if (is_array($message)) {
354
  $message = implode(' ,', $message);
355
  }
356
+ Mage::throwException($this->__('Submit App failure. %s', $message));
 
 
 
 
 
 
 
357
  }
358
  } catch (Exception $e) {
359
  throw $e;
383
  $isError = true;
384
  }
385
  }
386
+
387
  $app = $this->_initApp('application_id', $data['devtype']);
388
  if (!$app->getId() && $id) {
389
  $this->_getSession()->addError($this->__('App does not exist.'));
524
  return $conf;
525
  }
526
 
 
 
 
 
 
 
 
 
 
 
 
527
  /**
528
  * Delete theme action
529
  *
551
  );
552
  }
553
  } catch (Mage_Core_Exception $e) {
554
+ $response = array('error' => true, 'message' => $e->getMessage());
555
  } catch (Exception $e) {
556
  $response = array(
557
  'error' => true,
568
  }
569
 
570
  /**
571
+ * Save Theme action
572
+ *
573
+ * @return null
574
+ */
575
+ public function saveThemeAction()
576
+ {
577
+ $data = $this->getRequest()->getPost();
578
+ $this->_saveThemeAction($data);
579
+ }
580
+
581
+ /**
582
+ * Save Theme action
583
  *
584
  * @return null
585
  */
806
  * Process all uploaded files
807
  * setup file names to the configuration return array
808
  *
 
809
  * @param array $data
810
  * @param bool $restore
811
  * @return array
844
  * Prepare post data
845
  * Retains previous data in the object.
846
  *
 
847
  * @param array $arr
848
  * @return array
849
  */
850
  public function _preparePostData(array $arr)
851
  {
852
  unset($arr['code']);
853
+ if (!empty($arr['conf']['native']['pages'])) {
854
+ /**
855
+ * Remove emptied pages
856
+ */
857
+ $pages = array();
858
+ foreach ($arr['conf']['native']['pages'] as $_page) {
859
+ if (!empty($_page['id']) && !empty($_page['label'])) {
860
+ $pages[] = $_page;
861
  }
 
 
862
  }
863
+ $arr['conf']['native']['pages'] = $pages;
864
  }
865
+ if (isset($arr['conf']['new_pages']['ids']) && isset($arr['conf']['new_pages']['labels'])) {
866
+ $newPages = array();
867
+ $cmsPages = &$arr['conf']['new_pages'];
868
+ $idx = 0;
869
+ foreach ($cmsPages['ids'] as $key => $value) {
870
+ if (!empty($value) && !empty($cmsPages['labels'][$key])) {
871
+ $newPages[$idx]['id'] = trim($value);
872
+ $newPages[$idx++]['label'] = trim($cmsPages['labels'][$key]);
873
  }
 
 
874
  }
875
+ if (!isset($arr['conf']['native']['pages'])) {
876
+ $arr['conf']['native']['pages'] = array();
877
+ }
878
+ if (!empty($newPages)) {
879
+ $arr['conf']['native']['pages'] = array_merge($arr['conf']['native']['pages'], $newPages);
880
+ }
881
+ unset($arr['conf']['new_pages']);
882
  }
883
 
884
  /**
1165
  break;
1166
  }
1167
  if ($temporaryObject->getExecTime()) {
1168
+ $message->setExecTime(
1169
+ Mage::getSingleton('core/date')->gmtDate(null, $temporaryObject->getExecTime())
1170
+ );
1171
  } else {
1172
  $message->setExecTime(new Zend_Db_Expr('NULL'));
1173
  }
1317
  }
1318
 
1319
  if (isset($template)) {
1320
+ $applicationId = $template->getApplicationId();
1321
  } else {
1322
+ $applicationId = Mage::getModel('xmlconnect/template')->load($message->getTemplateId())->getApplicationId();
1323
  }
1324
 
1325
  /** @var $app Mage_XmlConnect_Model_Application */
1326
+ $app = Mage::getModel('xmlconnect/application')->load($applicationId);
1327
 
1328
  if(!$app->isNotificationsActive()) {
1329
  $this->_getSession()->addError(
1340
  } else {
1341
  $title = $this->__('New AirMail Message');
1342
  }
1343
+ $this->_addBreadcrumb($this->__('AirMail Message Queue'), $this->__('AirMail Message Queue'),
1344
+ $this->getUrl('*/*/queue')
1345
  );
1346
  $this->_addBreadcrumb($title, $title);
1347
 
1358
  {
1359
  $this->_forward('queueMessage');
1360
  }