Magento_Mobile - Version 1.4.0.1.23.0

Version Notes

1.4.0.1.23.0 version of package
internal svn revision #3cd616975d5927903d4f34bde0d9e5e2e727e9ba

Download this release

Release Info

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


Code changes from version 1.6.0.0.22.1 to 1.4.0.1.23.0

Files changed (248) hide show
  1. app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit.php +71 -0
  2. app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit/Form.php +55 -0
  3. app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit/Tab/Settings.php +108 -0
  4. app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit/Tabs.php +62 -0
  5. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Config.php +68 -0
  6. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard.php +249 -0
  7. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/BestSellers.php +113 -0
  8. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/Customers.php +129 -0
  9. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphAmountsData.php +71 -0
  10. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphDataAbstract.php +350 -0
  11. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphInfo.php +160 -0
  12. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphOrderData.php +71 -0
  13. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/GraphTotalsData.php +119 -0
  14. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/LastOrders.php +94 -0
  15. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/LastSearchTerms.php +118 -0
  16. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/MostViewedProducts.php +117 -0
  17. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/NewCustomers.php +132 -0
  18. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/SalesInfo.php +119 -0
  19. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/StoreSwitcher.php +198 -0
  20. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/TopSearchTerms.php +114 -0
  21. app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Loginform.php +70 -0
  22. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile.php +2 -6
  23. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit.php +1 -2
  24. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Submission.php +1 -2
  25. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Content.php +54 -34
  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 +23 -8
  28. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Images.php +192 -0
  29. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Preview.php +3 -6
  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/Payment.php +2 -14
  32. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Settings.php +10 -14
  33. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Social.php +11 -26
  34. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Submission/History.php +1 -1
  35. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tabs.php +2 -5
  36. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Addrow.php +8 -18
  37. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Color.php +1 -2
  38. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Country.php +1 -2
  39. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Datetime.php +1 -2
  40. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Font.php +2 -5
  41. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Image.php +1 -2
  42. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Page.php +3 -6
  43. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Tabs.php +3 -6
  44. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Theme.php +3 -5
  45. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Grid/Renderer/Bool.php +2 -6
  46. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Form.php +1 -2
  47. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Tab/Container/Submission.php +17 -17
  48. app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Tabs.php +1 -2
  49. app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Edit.php +2 -4
  50. app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Edit/Form.php +7 -10
  51. app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Grid.php +4 -5
  52. app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Grid/Renderer/Action.php +2 -2
  53. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Edit.php +5 -4
  54. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Edit/Form.php +3 -8
  55. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Grid.php +2 -3
  56. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Grid/Renderer/Application.php +1 -1
  57. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Preview.php +0 -2
  58. app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Preview/Form.php +1 -2
  59. app/code/core/Mage/XmlConnect/Block/Cart.php +31 -21
  60. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals.php +95 -0
  61. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Default.php +93 -0
  62. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Grandtotal.php +107 -0
  63. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Nodes/Default.php +63 -0
  64. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Nodes/Giftcardaccount.php +69 -0
  65. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Shipping.php +113 -0
  66. app/code/core/Mage/XmlConnect/Block/Cart/CartTotals/Subtotal.php +108 -0
  67. app/code/core/Mage/XmlConnect/Block/Cart/Crosssell.php +6 -6
  68. app/code/core/Mage/XmlConnect/Block/Cart/Item/Renderer.php +259 -64
  69. app/code/core/Mage/XmlConnect/Block/Cart/Item/Renderer/Configurable.php +75 -3
  70. app/code/core/Mage/XmlConnect/Block/Cart/Items.php +254 -0
  71. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Details.php +5 -9
  72. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/OrderDetails.php +83 -0
  73. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Review.php +35 -13
  74. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Shippingmethods.php +188 -28
  75. app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php +20 -9
  76. app/code/core/Mage/XmlConnect/Block/Cart/Totals.php +6 -8
  77. app/code/core/Mage/XmlConnect/Block/Catalog.php +59 -5
  78. app/code/core/Mage/XmlConnect/Block/Catalog/Category.php +6 -7
  79. app/code/core/Mage/XmlConnect/Block/Catalog/Filters.php +2 -1
  80. app/code/core/Mage/XmlConnect/Block/Catalog/Product.php +35 -25
  81. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Attributes.php +1 -1
  82. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Gallery.php +13 -14
  83. app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice.php +98 -0
  84. app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice/Bundle.php +426 -0
  85. app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice/Default.php +740 -0
  86. app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice/Giftcard.php +98 -0
  87. app/code/core/Mage/XmlConnect/Block/Catalog/Product/List.php +17 -9
  88. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options.php +85 -2
  89. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Bundle.php +33 -17
  90. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Configurable.php +36 -27
  91. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Downloadable.php +113 -0
  92. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Giftcard.php +107 -68
  93. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Grouped.php +11 -11
  94. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Simple.php +1 -1
  95. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Virtual.php +1 -1
  96. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Bundle.php +140 -158
  97. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Default.php +265 -267
  98. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Giftcard.php +8 -7
  99. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Related.php +2 -2
  100. app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review.php +1 -0
  101. app/code/core/Mage/XmlConnect/Block/Catalog/Search.php +4 -4
  102. app/code/core/Mage/XmlConnect/Block/Catalog/Search/Suggest.php +1 -0
  103. app/code/core/Mage/XmlConnect/Block/Checkout/Address/Billing.php +2 -3
  104. app/code/core/Mage/XmlConnect/Block/Checkout/Address/Form.php +43 -94
  105. app/code/core/Mage/XmlConnect/Block/Checkout/Address/Shipping.php +1 -0
  106. app/code/core/Mage/XmlConnect/Block/Checkout/Agreements.php +1 -1
  107. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer.php +48 -0
  108. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Bundle.php +49 -0
  109. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Configurable.php +53 -0
  110. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Downloadable.php +49 -0
  111. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Giftcard.php +49 -0
  112. app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Grouped.php +52 -0
  113. app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Address.php +69 -0
  114. app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Address/Form.php +114 -0
  115. app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Address/List.php +119 -0
  116. app/code/core/Mage/XmlConnect/Block/Checkout/Onepage/Review.php +64 -0
  117. app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review/Info.php +28 -18
  118. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Ccsave.php +3 -3
  119. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Ccsave.php +2 -2
  120. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Checkmo.php +1 -3
  121. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Paypal/Abstract.php +4 -7
  122. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Pbridge/Verisign.php +3 -5
  123. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/List.php +119 -60
  124. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/ListApi23.php +133 -0
  125. app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Paypal/Payflow.php +10 -10
  126. app/code/core/Mage/XmlConnect/Block/Checkout/Pbridge/Result.php +1 -1
  127. app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Available.php +20 -19
  128. app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/AvailableList.php +82 -0
  129. app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Avaliable.php +39 -0
  130. app/code/core/Mage/XmlConnect/Block/Configuration.php +40 -21
  131. app/code/core/Mage/XmlConnect/Block/Customer/Address/Form.php +45 -78
  132. app/code/core/Mage/XmlConnect/Block/Customer/Address/List.php +34 -27
  133. app/code/core/Mage/XmlConnect/Block/Customer/Downloads.php +80 -0
  134. app/code/core/Mage/XmlConnect/Block/Customer/Form.php +150 -47
  135. app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Date.php +16 -14
  136. app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Text.php +5 -4
  137. app/code/core/Mage/XmlConnect/Block/Customer/Order/Details.php +10 -13
  138. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Bundle.php +142 -11
  139. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Default.php +73 -0
  140. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Downloadable.php +84 -13
  141. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Giftcard.php +2 -2
  142. app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Grouped.php +5 -3
  143. app/code/core/Mage/XmlConnect/Block/Customer/Order/Items.php +1 -2
  144. app/code/core/Mage/XmlConnect/Block/Customer/Order/List.php +14 -16
  145. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals.php +60 -10
  146. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance.php +25 -1
  147. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance/Refunded.php +25 -3
  148. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Giftcards.php +39 -5
  149. app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Tax.php +44 -3
  150. app/code/core/Mage/XmlConnect/Block/Customer/Storecredit.php +1 -1
  151. app/code/core/Mage/XmlConnect/Block/Home.php +3 -3
  152. app/code/core/Mage/XmlConnect/Block/Homebanners.php +156 -0
  153. app/code/core/Mage/XmlConnect/Block/Localization.php +55 -0
  154. app/code/core/Mage/XmlConnect/Block/Review/Form.php +2 -1
  155. app/code/core/Mage/XmlConnect/Block/ShoppingCart.php +108 -0
  156. app/code/core/Mage/XmlConnect/Block/Wishlist.php +19 -19
  157. app/code/core/Mage/XmlConnect/Controller/Action.php +36 -11
  158. app/code/core/Mage/XmlConnect/Controller/AdminAction.php +192 -0
  159. app/code/core/Mage/XmlConnect/Helper/AdminApplication.php +134 -0
  160. app/code/core/Mage/XmlConnect/Helper/Adminhtml/Dashboard/Order.php +64 -0
  161. app/code/core/Mage/XmlConnect/Helper/Android.php +42 -64
  162. app/code/core/Mage/XmlConnect/Helper/Catalog/Category/Image.php +58 -4
  163. app/code/core/Mage/XmlConnect/Helper/Catalog/Product/Image.php +46 -0
  164. app/code/core/Mage/XmlConnect/Helper/Customer/Form/Renderer.php +178 -0
  165. app/code/core/Mage/XmlConnect/Helper/Customer/Order.php +193 -31
  166. app/code/core/Mage/XmlConnect/Helper/Data.php +127 -32
  167. app/code/core/Mage/XmlConnect/Helper/Device/Abstract.php +309 -0
  168. app/code/core/Mage/XmlConnect/Helper/Image.php +50 -24
  169. app/code/core/Mage/XmlConnect/Helper/Ipad.php +65 -112
  170. app/code/core/Mage/XmlConnect/Helper/Iphone.php +39 -204
  171. app/code/core/Mage/XmlConnect/Helper/Paypal/Data.php +51 -0
  172. app/code/core/Mage/XmlConnect/Helper/Theme.php +49 -8
  173. app/code/core/Mage/XmlConnect/Helper/Translate.php +514 -0
  174. app/code/core/Mage/XmlConnect/Model/Adminhtml/Search/Catalog.php +71 -0
  175. app/code/core/Mage/XmlConnect/Model/Adminhtml/Search/Category.php +70 -0
  176. app/code/core/Mage/XmlConnect/Model/Adminhtml/System/Config/Backend/Currency/Default.php +1 -1
  177. app/code/core/Mage/XmlConnect/Model/Application.php +199 -81
  178. app/code/core/Mage/XmlConnect/Model/Catalog/Category/Image.php +28 -11
  179. app/code/core/Mage/XmlConnect/Model/ConfigData.php +121 -9
  180. app/code/core/Mage/XmlConnect/Model/Configuration.php +270 -0
  181. app/code/core/Mage/XmlConnect/Model/Device/Abstract.php +179 -0
  182. app/code/core/Mage/XmlConnect/Model/Device/Android.php +111 -0
  183. app/code/core/Mage/XmlConnect/Model/Device/Ipad.php +174 -0
  184. app/code/core/Mage/XmlConnect/Model/Device/Iphone.php +117 -0
  185. app/code/core/Mage/XmlConnect/Model/History.php +3 -3
  186. app/code/core/Mage/XmlConnect/Model/ImageAction.php +321 -0
  187. app/code/core/Mage/XmlConnect/Model/ImageLimits.php +366 -0
  188. app/code/core/Mage/XmlConnect/Model/ImageLimits/Abstract.php +295 -0
  189. app/code/core/Mage/XmlConnect/Model/Images.php +551 -0
  190. app/code/core/Mage/XmlConnect/Model/Input/Filter/MaliciousCode.php +100 -0
  191. app/code/core/Mage/XmlConnect/{Block/Adminhtml/Template/Grid/Renderer/Name.php → Model/Mysql4/CategorySearch/Collection.php} +3 -14
  192. app/code/core/Mage/XmlConnect/Model/Mysql4/Cms/Page/Collection.php +3 -3
  193. app/code/core/Mage/XmlConnect/Model/Mysql4/History/Collection.php +3 -3
  194. app/code/core/Mage/XmlConnect/Model/Mysql4/Images.php +36 -0
  195. app/code/core/Mage/XmlConnect/Model/Mysql4/Images/Collection.php +36 -0
  196. app/code/core/Mage/XmlConnect/Model/Observer.php +77 -7
  197. app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Config.php +21 -0
  198. app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Mecl.php +6 -2
  199. app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Mep.php +6 -2
  200. app/code/core/Mage/XmlConnect/Model/Preview/Abstract.php +57 -5
  201. app/code/core/Mage/XmlConnect/Model/Preview/Android.php +13 -6
  202. app/code/core/Mage/XmlConnect/Model/Preview/Ipad.php +49 -44
  203. app/code/core/Mage/XmlConnect/Model/Preview/Iphone.php +14 -5
  204. app/code/core/Mage/XmlConnect/Model/Queue.php +39 -4
  205. app/code/core/Mage/XmlConnect/Model/Resource/Application.php +23 -7
  206. app/code/core/Mage/XmlConnect/Model/Resource/Application/Collection.php +1 -1
  207. app/code/core/Mage/XmlConnect/Model/Resource/CategorySearch/Collection.php +121 -0
  208. app/code/core/Mage/XmlConnect/Model/Resource/Cms/Page/Collection.php +4 -4
  209. app/code/core/Mage/XmlConnect/Model/Resource/ConfigData.php +3 -3
  210. app/code/core/Mage/XmlConnect/Model/Resource/ConfigData/Collection.php +1 -3
  211. app/code/core/Mage/XmlConnect/Model/Resource/Filter/Collection.php +0 -1
  212. app/code/core/Mage/XmlConnect/Model/Resource/History.php +1 -1
  213. app/code/core/Mage/XmlConnect/Model/Resource/History/Collection.php +4 -4
  214. app/code/core/Mage/XmlConnect/Model/Resource/Images.php +89 -0
  215. app/code/core/Mage/XmlConnect/Model/Resource/Images/Collection.php +91 -0
  216. app/code/core/Mage/XmlConnect/Model/Resource/Queue.php +1 -1
  217. app/code/core/Mage/XmlConnect/Model/Resource/Queue/Collection.php +6 -17
  218. app/code/core/Mage/XmlConnect/Model/Resource/Setup.php +1 -1
  219. app/code/core/Mage/XmlConnect/Model/Resource/Template.php +1 -1
  220. app/code/core/Mage/XmlConnect/Model/Resource/Template/Collection.php +1 -1
  221. app/code/core/Mage/XmlConnect/Model/Simplexml/Element.php +5 -5
  222. app/code/core/Mage/XmlConnect/Model/Simplexml/Form.php +25 -1
  223. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Abstract.php +1 -1
  224. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Abstract.php +9 -3
  225. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/CountryListSelect.php +45 -19
  226. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Custom.php +71 -0
  227. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Date.php +1 -2
  228. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Email.php +1 -2
  229. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Fieldset.php +2 -0
  230. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/File.php +1 -2
  231. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Image.php +1 -2
  232. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Multiline.php +1 -4
  233. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Multiselect.php +1 -5
  234. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Password.php +47 -0
  235. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Select.php +4 -13
  236. app/code/core/Mage/XmlConnect/Model/Simplexml/Form/Element/Text.php +1 -2
  237. app/code/core/Mage/XmlConnect/Model/Simplexml/Message.php +267 -0
  238. app/code/core/Mage/XmlConnect/Model/Simplexml/Message/Abstract.php +142 -0
  239. app/code/core/Mage/XmlConnect/Model/Simplexml/Message/Error.php +125 -0
  240. app/code/core/Mage/XmlConnect/Model/Simplexml/Message/Success.php +56 -0
  241. app/code/core/Mage/XmlConnect/Model/Tabs.php +0 -1
  242. app/code/core/Mage/XmlConnect/Model/Template.php +7 -1
  243. app/code/core/Mage/XmlConnect/Model/Theme.php +6 -5
  244. app/code/core/Mage/XmlConnect/controllers/Adminhtml/Admin/ApplicationController.php +69 -0
  245. app/code/core/Mage/XmlConnect/controllers/Adminhtml/Connect/ConfigController.php +126 -0
  246. app/code/core/Mage/XmlConnect/controllers/Adminhtml/Connect/DashboardController.php +55 -0
  247. app/code/core/Mage/XmlConnect/controllers/Adminhtml/Connect/UserController.php +165 -0
  248. app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php +155 -74
app/code/core/Mage/XmlConnect/Block/Adminhtml/Admin/Application/Edit.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (!is_object(Mage::getConfig()->getNode('modules/' . '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
+ }
66
+
67
+ $collection->load();
68
+ $totals = $collection->getFirstItem();
69
+
70
+ $this->addTotal($this->__('Revenue'), $totals->getRevenue());
71
+ $this->addTotal($this->__('Tax'), $totals->getTax());
72
+ $this->addTotal($this->__('Shipping'), $totals->getShipping());
73
+ $this->addTotal($this->__('Quantity'), $totals->getQuantity() * 1, true);
74
+ return $this;
75
+ }
76
+
77
+ /**
78
+ * Add cart totals data to xml object
79
+ *
80
+ * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
81
+ * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphTotalsData
82
+ */
83
+ public function addTotalsDataToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
84
+ {
85
+ $dataValuesXml = $xmlObj->addCustomChild('chart_totals');
86
+
87
+ foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeFilter) {
88
+ $storeId = $storeFilter ? $storeFilter : null;
89
+
90
+ $totalsXml = $dataValuesXml->addCustomChild('totals', null, array(
91
+ 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
92
+ ));
93
+
94
+ foreach ($this->getRangeOptions() as $rangeFilter) {
95
+ $this->_initCollection($storeId, $rangeFilter['value']);
96
+ $valuesXml = $totalsXml->addCustomChild('values', null, array(
97
+ 'range_id' => $rangeFilter['value']
98
+ ));
99
+ foreach ($this->getTotals() as $total) {
100
+ $totalValue = $valuesXml->escapeXml($total['value'] . $total['decimals']);
101
+ $valuesXml->addCustomChild('item', $totalValue, array('label' => $total['label']));
102
+ }
103
+ $this->_clearTotals();
104
+ }
105
+ }
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Clear totals values array
111
+ *
112
+ * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphTotalsData
113
+ */
114
+ protected function _clearTotals()
115
+ {
116
+ $this->_totals = array();
117
+ return $this;
118
+ }
119
+ }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/LastOrders.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (!is_object(Mage::getConfig()->getNode('modules/' . 'Mage_Reports'))) {
50
+ return $this;
51
+ }
52
+
53
+ /** @var $collection Mage_Reports_Model_Mysql4_Order_Collection */
54
+ $collection = Mage::getResourceModel('reports/order_collection')->addItemCountExpr()
55
+ ->addExpressionAttributeToSelect(
56
+ 'customer',
57
+ "IFNULL(CONCAT({{customer_firstname}},' ',{{customer_lastname}}), '{$this->__('Guest')}')",
58
+ array('customer_firstname','customer_lastname')
59
+ )
60
+ ->setOrder('created_at')
61
+ ->setPageSize(self::LAST_ORDER_COUNT_LIMIT);
62
+
63
+ foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
64
+ if ($storeId) {
65
+ $collection->addAttributeToFilter('store_id', $storeId);
66
+ } else {
67
+ $collection->addExpressionAttributeToSelect(
68
+ 'revenue',
69
+ '({{base_grand_total}}*{{base_to_global_rate}})',
70
+ array('base_grand_total', 'base_to_global_rate')
71
+ );
72
+ }
73
+
74
+ $this->setCollection($collection);
75
+ $orderList = $this->_prepareColumns()->getCollection()->load();
76
+ $valuesXmlObj = $xmlObj->addCustomChild('values', null, array(
77
+ 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
78
+ ));
79
+
80
+ foreach ($orderList as $order) {
81
+ $itemXmlObj = $valuesXmlObj->addCustomChild('item');
82
+ $itemXmlObj->addCustomChild('customer', $order->getCustomer(), array('label' => $this->__('Customer')));
83
+ $itemXmlObj->addCustomChild('items_count', $order->getItemsCount(), array(
84
+ 'label' => $this->__('Items')
85
+ ));
86
+ $currency_code = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
87
+ $itemXmlObj->addCustomChild('currency', Mage::app()->getLocale()->currency($currency_code)
88
+ ->toCurrency($order->getRevenue()), array('label' => $this->__('Grand Total')));
89
+ }
90
+ $collection->clear();
91
+ }
92
+ return $this;
93
+ }
94
+ }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/LastSearchTerms.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (!is_object(Mage::getConfig()->getNode('modules/' . '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 ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Mysql4_Customer_Collection */
61
+ $collection = Mage::getResourceModel('reports/customer_collection')
62
+ ->addCustomerName()
63
+ ->joinOrders()
64
+ ->addOrdersCount()
65
+ ->setPageSize(self::CUSTOMERS_COUNT_LIMIT);
66
+
67
+ $storeFilter = 0;
68
+ if ($storeId) {
69
+ $collection->addAttributeToFilter('store_id', $storeId);
70
+ $storeFilter = 1;
71
+ }
72
+
73
+ $collection->addSumAvgTotals($storeFilter)->orderByCustomerRegistration();
74
+ $this->setCollection($collection);
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * Clear collection
80
+ *
81
+ * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_NewCustomers
82
+ */
83
+ protected function _clearCollection()
84
+ {
85
+ $this->_collection = null;
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * Add new customers statistic to xml object
91
+ *
92
+ * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
93
+ * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_NewCustomers
94
+ */
95
+ public function addNewCustomersToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
96
+ {
97
+ foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
98
+ $this->_clearCollection()->_initCollection($storeId);
99
+ $valuesXml = $xmlObj->addCustomChild('values', null, array(
100
+ 'store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS
101
+ ));
102
+
103
+ if(!count($this->getCollection()->getItems()) > 0) {
104
+ continue;
105
+ }
106
+
107
+ /** @var $orderHelper Mage_XmlConnect_Helper_Adminhtml_Dashboard_Order */
108
+ $orderHelper = Mage::helper('xmlconnect/adminhtml_dashboard_order');
109
+
110
+ foreach ($this->getCollection()->getItems() as $item) {
111
+ $itemListXml = $valuesXml->addCustomChild('item');
112
+ $itemListXml->addCustomChild('name', $item->getName(), array(
113
+ 'label' => $this->__('Customer Name')
114
+ ));
115
+ $itemListXml->addCustomChild('orders_count', $item->getOrdersCount(), array(
116
+ 'label' => $this->__('Number of Orders')
117
+ ));
118
+ $itemListXml->addCustomChild(
119
+ 'orders_avg_amount',
120
+ $orderHelper->preparePrice($item->getOrdersAvgAmount(), $storeId),
121
+ array('label' => $this->__('Average Order Amount'))
122
+ );
123
+ $itemListXml->addCustomChild(
124
+ 'orders_sum_amount',
125
+ $orderHelper->preparePrice($item->getOrdersSumAmount(), $storeId),
126
+ array('label' => $this->__('Total Order Amount'))
127
+ );
128
+ }
129
+ }
130
+ return $this;
131
+ }
132
+ }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Connect/Dashboard/SalesInfo.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (!is_object(Mage::getConfig()->getNode('modules/' . '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 ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (!is_object(Mage::getConfig()->getNode('modules/' . '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 ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,12 +40,8 @@ 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(
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();
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();
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit.php CHANGED
@@ -31,8 +31,7 @@
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
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
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Submission.php CHANGED
@@ -31,8 +31,7 @@
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
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
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Content.php CHANGED
@@ -35,6 +35,11 @@ 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
  protected $_pages;
39
 
40
  /**
@@ -45,63 +50,58 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Content
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,4 +143,24 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Content
143
  {
144
  return false;
145
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  }
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
  {
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
  {
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
  }
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 xml renderer
29
  *
30
  * @category Mage
31
  * @package Mage_Xmlconnect
25
  */
26
 
27
  /**
28
+ * Tab design accordion block 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,6 +27,7 @@
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,6 +38,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
37
  /**
38
  * Getter for accordion item title
39
  *
 
40
  * @return string
41
  */
42
  public function getTitle()
@@ -47,6 +49,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
47
  /**
48
  * Getter for accordion item is open flag
49
  *
 
50
  * @return bool
51
  */
52
  public function getIsOpen()
@@ -57,6 +60,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
57
  /**
58
  * Prepare form
59
  *
 
60
  * @throws Mage_Core_Exception
61
  * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
62
  */
@@ -69,7 +73,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
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,14 +84,18 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
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,28 +104,32 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
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,7 +138,9 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
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,6 +160,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
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
  */
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
  /**
39
  * Getter for accordion item title
40
  *
41
+ * @deprecated will delete in the next version
42
  * @return string
43
  */
44
  public function getTitle()
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
  /**
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
  $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
  $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
  $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
  $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
  /**
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
  */
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Images.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,14 +25,13 @@
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,9 +44,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Preview
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);
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
  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);
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/Payment.php CHANGED
@@ -80,7 +80,6 @@ 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_IPHONE:
84
  case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD:
85
  /**
86
  * PayPal MEP management
@@ -192,13 +191,13 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Payment
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,17 +223,6 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Payment
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(
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
  )
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
  'value' => $paypalMeclActive,
224
  'disabled' => !$paypalMeclIsAvailable
225
  ));
 
 
 
 
 
 
 
 
 
 
 
226
  break;
227
  default:
228
  Mage::throwException(
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Settings.php CHANGED
@@ -37,15 +37,11 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Settings
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,11 +59,11 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Settings
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(
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
  $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(
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Social.php CHANGED
@@ -60,9 +60,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Social
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,16 +111,11 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Social
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,23 +156,15 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Social
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]'];
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
  )
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
  )
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]'];
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) !Mage::getSingleton('adminhtml/session')->getNewApplication();
83
  }
84
 
85
  /**
79
  */
80
  public function canShowTab()
81
  {
82
+ return (bool)$this->_getApplication()->getId();
83
  }
84
 
85
  /**
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tabs.php CHANGED
@@ -31,11 +31,9 @@
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,8 +54,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tabs
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
  ));
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
  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
  ));
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
  * @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,17 +41,9 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Addrow
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,10 +66,8 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Addrow
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,7 +83,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Addrow
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();
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
  */
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
  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
  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();
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Color.php CHANGED
@@ -31,8 +31,7 @@
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
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
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Country.php CHANGED
@@ -31,8 +31,7 @@
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
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
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Datetime.php CHANGED
@@ -31,8 +31,7 @@
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
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
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Font.php CHANGED
@@ -31,8 +31,7 @@
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,9 +96,7 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Font
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
  }
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
  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
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Image.php CHANGED
@@ -31,8 +31,7 @@
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
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
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Page.php CHANGED
@@ -31,8 +31,7 @@
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,10 +97,8 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Page
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
  }
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
  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
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Tabs.php CHANGED
@@ -31,8 +31,7 @@
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,14 +45,12 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Tabs
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);
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
  }
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);
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Form/Element/Theme.php CHANGED
@@ -31,8 +31,7 @@
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,9 +40,8 @@ class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Theme
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());
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
  */
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());
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Grid/Renderer/Bool.php CHANGED
@@ -46,14 +46,10 @@ 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="'
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;
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;
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Form.php CHANGED
@@ -31,8 +31,7 @@
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
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
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' => '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). 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
 
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
  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
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Submission/Tabs.php CHANGED
@@ -31,8 +31,7 @@
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
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
app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Edit.php CHANGED
@@ -31,8 +31,7 @@
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,8 +65,7 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Edit
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
 
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
  {
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
 
app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Edit/Form.php CHANGED
@@ -31,8 +31,7 @@
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,15 +58,11 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Edit_Form
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,12 +150,14 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Edit_Form
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
  }
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
  }
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
  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
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Queue/Grid.php CHANGED
@@ -55,8 +55,7 @@ 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',
59
- array('neq' => Mage_XmlConnect_Model_Queue::STATUS_DELETED)
60
  );
61
  $this->setCollection($collection);
62
  return parent::_prepareCollection();
@@ -88,7 +87,7 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Grid extends Mage_Adminhtml_Block_Wi
88
  $this->addColumn('app_code', array(
89
  'header' => $this->__('Application Name'),
90
  'align' => 'left',
91
- 'index' => 'app.code',
92
  'type' => 'options',
93
  'options' => Mage::helper('xmlconnect')->getApplications(),
94
  'renderer' => 'xmlconnect/adminhtml_queue_grid_renderer_application'
@@ -159,13 +158,13 @@ class Mage_XmlConnect_Block_Adminhtml_Queue_Grid extends Mage_Adminhtml_Block_Wi
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
  }
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();
87
  $this->addColumn('app_code', array(
88
  'header' => $this->__('Application Name'),
89
  'align' => 'left',
90
+ 'index' => 'main_table.app_code',
91
  'type' => 'options',
92
  'options' => Mage::helper('xmlconnect')->getApplications(),
93
  'renderer' => 'xmlconnect/adminhtml_queue_grid_renderer_application'
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
  }
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 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);
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);
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Edit.php CHANGED
@@ -43,9 +43,8 @@ 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(\''
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,7 +58,9 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Edit extends Mage_Adminhtml_Block
59
  */
60
  public function getDeleteUrl()
61
  {
62
- return $this->getUrl('*/*/deletetemplate', array($this->_objectId => $this->getRequest()->getParam($this->_objectId)));
 
 
63
  }
64
 
65
  /**
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
  */
59
  public function getDeleteUrl()
60
  {
61
+ return $this->getUrl('*/*/deletetemplate', array(
62
+ $this->_objectId => $this->getRequest()->getParam($this->_objectId)
63
+ ));
64
  }
65
 
66
  /**
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Edit/Form.php CHANGED
@@ -31,8 +31,7 @@
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,12 +85,8 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Edit_Form
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(
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
  $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(
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Grid.php CHANGED
@@ -74,8 +74,7 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Grid extends Mage_Adminhtml_Block
74
  $this->addColumn('name', array(
75
  'header' => $this->__('Template Name'),
76
  'align' => 'left',
77
- 'index' => 'main_table.name',
78
- 'renderer' => 'xmlconnect/adminhtml_template_grid_renderer_name',
79
  'escape' => true
80
  ));
81
 
@@ -95,7 +94,7 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Grid extends Mage_Adminhtml_Block
95
 
96
  $this->addColumn('app_code', array(
97
  'header' => $this->__('Application'),
98
- 'index' => 'app.code',
99
  'type' => 'options',
100
  'align' => 'left',
101
  'options' => Mage::helper('xmlconnect')->getApplications(),
74
  $this->addColumn('name', array(
75
  'header' => $this->__('Template Name'),
76
  'align' => 'left',
77
+ 'index' => 'name',
 
78
  'escape' => true
79
  ));
80
 
94
 
95
  $this->addColumn('app_code', array(
96
  'header' => $this->__('Application'),
97
+ 'index' => 'app_code',
98
  'type' => 'options',
99
  'align' => 'left',
100
  'options' => Mage::helper('xmlconnect')->getApplications(),
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Grid/Renderer/Application.php CHANGED
@@ -42,7 +42,7 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Grid_Renderer_Application
42
  */
43
  public function render(Varien_Object $row)
44
  {
45
- $str = $this->escapeHtml($row->getAppName());
46
  if ($str == '') {
47
  $str = ' --- ';
48
  }
42
  */
43
  public function render(Varien_Object $row)
44
  {
45
+ $str = $this->htmlEscape($row->getAppName());
46
  if ($str == '') {
47
  $str = ' --- ';
48
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Preview.php CHANGED
@@ -60,9 +60,7 @@ class Mage_XmlConnect_Block_Adminhtml_Template_Preview extends Mage_Adminhtml_Bl
60
  $storeId = Mage::app()->getDefaultStoreView()->getId();
61
  }
62
 
63
- $template->emulateDesign($storeId);
64
  $templateProcessed = $template->getProcessedTemplate(array(), true);
65
- $template->revertDesign();
66
 
67
  return $templateProcessed;
68
  }
60
  $storeId = Mage::app()->getDefaultStoreView()->getId();
61
  }
62
 
 
63
  $templateProcessed = $template->getProcessedTemplate(array(), true);
 
64
 
65
  return $templateProcessed;
66
  }
app/code/core/Mage/XmlConnect/Block/Adminhtml/Template/Preview/Form.php CHANGED
@@ -31,8 +31,7 @@
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
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
app/code/core/Mage/XmlConnect/Block/Cart.php CHANGED
@@ -49,8 +49,10 @@ 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
  $products = $xmlObject->addChild('products');
53
- /* @var $item Mage_Sales_Model_Quote_Item */
54
  foreach ($this->getItems() as $item) {
55
  $type = $item->getProductType();
56
  $renderer = $this->getItemRenderer($type)->setItem($item);
@@ -64,12 +66,9 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
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,19 +78,19 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
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);
@@ -99,7 +98,6 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
99
  $formattedExclPrice = $quote->getStore()->formatPrice($exclPrice, false);
100
  $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice);
101
  $formattedInclPrice = $quote->getStore()->formatPrice($inclPrice, false);
102
-
103
  $priceXmlObj = $itemXml->addChild('price');
104
  $formattedPriceXmlObj = $itemXml->addChild('formated_price');
105
 
@@ -151,13 +149,13 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
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
 
@@ -173,7 +171,6 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
173
  if ($this->helper('tax')->displayCartBothPrices()) {
174
  $subtotalPriceXmlObj->addAttribute('excluding_tax', $exclPrice);
175
  $subtotalPriceXmlObj->addAttribute('including_tax', $inclPrice);
176
-
177
  $subtotalFormattedPriceXmlObj->addAttribute('excluding_tax', $formattedExclPrice);
178
  $subtotalFormattedPriceXmlObj->addAttribute('including_tax', $formattedInclPrice);
179
  } else {
@@ -190,14 +187,27 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
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
 
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) {
57
  $type = $item->getProductType();
58
  $renderer = $this->getItemRenderer($type)->setItem($item);
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
  && $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);
98
  $formattedExclPrice = $quote->getStore()->formatPrice($exclPrice, false);
99
  $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice);
100
  $formattedInclPrice = $quote->getStore()->formatPrice($inclPrice, false);
 
101
  $priceXmlObj = $itemXml->addChild('price');
102
  $formattedPriceXmlObj = $itemXml->addChild('formated_price');
103
 
149
  }
150
  }
151
  if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
152
+ $incl = $this->helper('checkout')->getSubtotalInclTax($item);
153
  if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales')
154
  && $item->getWeeeTaxAppliedAmount()
155
  ) {
156
+ $inclPrice = $incl + $item->getWeeeTaxAppliedRowAmount();
157
  } else {
158
+ $inclPrice = $incl - $item->getWeeeTaxRowDisposition();
159
  }
160
  }
161
 
171
  if ($this->helper('tax')->displayCartBothPrices()) {
172
  $subtotalPriceXmlObj->addAttribute('excluding_tax', $exclPrice);
173
  $subtotalPriceXmlObj->addAttribute('including_tax', $inclPrice);
 
174
  $subtotalFormattedPriceXmlObj->addAttribute('excluding_tax', $formattedExclPrice);
175
  $subtotalFormattedPriceXmlObj->addAttribute('including_tax', $formattedInclPrice);
176
  } else {
187
  /**
188
  * Options list
189
  */
190
+ $options = $renderer->getOptionList();
191
+ if ($options) {
192
  $itemOptionsXml = $itemXml->addChild('options');
193
+ foreach ($options as $option) {
194
+ $formattedOptionValue = $renderer->getFormatedOptionValue($option);
195
  $optionXml = $itemOptionsXml->addChild('option');
196
+ $optionXml->addAttribute('label', $xmlObject->xmlAttribute($option['label']));
197
+ $optionXml->addAttribute('text', $xmlObject->xmlAttribute($formattedOptionValue['value']));
198
+ }
199
+ }
200
+
201
+ /**
202
+ * Downloadable products
203
+ */
204
+ $links = $renderer->getLinks();
205
+ if ($links) {
206
+ $itemOptionsXml = $itemXml->addCustomChild('options', null, array(
207
+ 'label' => $renderer->getLinksTitle()
208
+ ));
209
+ foreach ($links as $link) {
210
+ $itemOptionsXml->addCustomChild('option', null, array('label' => $link->getTitle()));
211
  }
212
  }
213
 
app/code/core/Mage/XmlConnect/Block/Cart/CartTotals.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
-
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());
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());
app/code/core/Mage/XmlConnect/Block/Cart/Item/Renderer.php CHANGED
@@ -40,36 +40,238 @@ 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
- $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,38 +280,38 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
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,43 +337,38 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
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,19 +384,19 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
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,14 +405,13 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
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,30 +419,29 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
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);
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
  */
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
  */
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
  */
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
  }
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
  }
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);
app/code/core/Mage/XmlConnect/Block/Cart/Item/Renderer/Configurable.php CHANGED
@@ -80,8 +80,80 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer_Configurable extends Mage_XmlConn
80
  */
81
  public function getOptionList()
82
  {
83
- /* @var $helper Mage_Catalog_Helper_Product_Configuration */
84
- $helper = Mage::helper('catalog/product_configuration');
85
- return $helper->getConfigurableOptions($this->getItem());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
  }
80
  */
81
  public function getOptionList()
82
  {
83
+ return $this->_getConfigurableOptions($this->getItem());
84
+ }
85
+
86
+ /**
87
+ * Retrieves configuration options for configurable product
88
+ *
89
+ * @param Mage_Sales_Model_Quote_Item $item
90
+ * @return array
91
+ */
92
+ protected function _getConfigurableOptions($item)
93
+ {
94
+ $product = $item->getProduct();
95
+ $typeId = $product->getTypeId();
96
+ if ($typeId != Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
97
+ Mage::throwException($this->__('Wrong product type to extract configurable options.'));
98
+ }
99
+ $attributes = $product->getTypeInstance(true)
100
+ ->getSelectedAttributesInfo($product);
101
+ return array_merge($attributes, $this->_getCustomOptions($item));
102
+ }
103
+
104
+ /**
105
+ * Retrieves product configuration options
106
+ *
107
+ * @param Mage_Sales_Model_Quote_Item $item
108
+ * @return array
109
+ */
110
+ protected function _getCustomOptions($item)
111
+ {
112
+ $product = $item->getProduct();
113
+ $options = array();
114
+ $optionIds = $item->getOptionByCode('option_ids');
115
+ if ($optionIds) {
116
+ $options = array();
117
+ foreach (explode(',', $optionIds->getValue()) as $optionId) {
118
+ $option = $product->getOptionById($optionId);
119
+ if ($option) {
120
+ $itemOption = $item->getOptionByCode('option_' . $option->getId());
121
+ $group = $option->groupFactory($option->getType())
122
+ ->setOption($option)
123
+ ->setConfigurationItem($item)
124
+ ->setConfigurationItemOption($itemOption);
125
+
126
+ if ('file' == $option->getType()) {
127
+ $downloadParams = $item->getFileDownloadParams();
128
+ if ($downloadParams) {
129
+ $url = $downloadParams->getUrl();
130
+ if ($url) {
131
+ $group->setCustomOptionDownloadUrl($url);
132
+ }
133
+ $urlParams = $downloadParams->getUrlParams();
134
+ if ($urlParams) {
135
+ $group->setCustomOptionUrlParams($urlParams);
136
+ }
137
+ }
138
+ }
139
+
140
+ $options[] = array(
141
+ 'label' => $option->getTitle(),
142
+ 'value' => $group->getFormattedOptionValue($itemOption->getValue()),
143
+ 'print_value' => $group->getPrintableOptionValue($itemOption->getValue()),
144
+ 'option_id' => $option->getId(),
145
+ 'option_type' => $option->getType(),
146
+ 'custom_view' => $group->isCustomizedView()
147
+ );
148
+ }
149
+ }
150
+ }
151
+
152
+ $addOptions = $item->getOptionByCode('additional_options');
153
+ if ($addOptions) {
154
+ $options = array_merge($options, unserialize($addOptions->getValue()));
155
+ }
156
+
157
+ return $options;
158
  }
159
  }
app/code/core/Mage/XmlConnect/Block/Cart/Items.php ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,10 +59,8 @@ 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,
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,9 +76,7 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Details extends Mage_Paypal_Block_E
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
  }
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, 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
  public function addItemRender($productType, $blockType, $template)
77
  {
78
  $this->_itemRenders[$productType] = array(
79
+ 'block' => $blockType, 'template' => $template, 'blockInstance' => null
 
 
80
  );
81
  return $this;
82
  }
app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/OrderDetails.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
@@ -33,6 +33,26 @@
33
  */
34
  class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Review extends Mage_Paypal_Block_Express_Review
35
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * Render PayPal MECL details xml
38
  *
@@ -44,15 +64,14 @@ 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(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,17 +97,20 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Review extends Mage_Paypal_Block_Ex
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
  }
33
  */
34
  class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Review extends Mage_Paypal_Block_Express_Review
35
  {
36
+ /**
37
+ * Get shipping rate code title and its price
38
+ *
39
+ * @param Varien_Object $rate
40
+ * @return string
41
+ */
42
+ protected function _renderShippingRateOption($rate)
43
+ {
44
+ $result = $rate->getMethodTitle();
45
+ $_excl = $this->getShippingPrice($rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax());
46
+ $_incl = $this->getShippingPrice($rate->getPrice(), true);
47
+
48
+ $result .= ' - ' . $_excl;
49
+
50
+ if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl) {
51
+ $result .= ' (' . $this->__('Incl. Tax') . ' ' . $_incl .')';
52
+ }
53
+ return $result;
54
+ }
55
+
56
  /**
57
  * Render PayPal MECL details xml
58
  *
64
  $reviewXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<mecl_cart_details></mecl_cart_details>');
65
 
66
  if ($this->getPaypalMessages()) {
67
+ $reviewXmlObj->addChild('paypal_message', implode('\n', $this->getPaypalMessages()));
68
  }
69
 
70
  if ($this->getShippingAddress()) {
71
+ $shipping = Mage::helper('xmlconnect')->trimLineBreaks($this->getShippingAddress()->format('text'));
72
+ $reviewXmlObj->addCustomChild('shipping_address', $shipping, array(
73
+ 'label' => $this->__('Shipping Address')
74
+ ));
 
75
  }
76
 
77
  if ($this->_quote->isVirtual()) {
97
  $reviewXmlObj->addCustomChild('payment_method', $this->escapeHtml($this->getPaymentMethodTitle()), array(
98
  'label' => $this->__('Payment Method')
99
  ));
100
+ $billing = Mage::helper('xmlconnect')->trimLineBreaks($this->getBillingAddress()->format('text'));
101
+ $reviewXmlObj->addCustomChild('billing_address', $billing, array(
102
+ 'label' => $this->__('Billing Address'),
103
+ 'payer_email' => $this->__('Payer Email: %s', $this->getBillingAddress()->getEmail())
 
 
 
104
  ));
105
 
106
  $this->getChild('details')->addDetailsToXmlObj($reviewXmlObj);
107
 
108
+ $agreements = $this->getChildHtml('agreements');
109
+ if ($agreements) {
110
+ $agreementsXmlObj = Mage::getModel('xmlconnect/simplexml_element', $agreements);
111
+ $reviewXmlObj->appendChild($agreementsXmlObj);
112
+ }
113
+
114
  return $reviewXmlObj->asNiceXml();
115
  }
116
  }
app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mecl/Shippingmethods.php CHANGED
@@ -31,9 +31,114 @@
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,45 +148,100 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
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,7 +249,7 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
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');
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
+ * Return shipping rates
38
+ *
39
+ * @return array
40
+ */
41
+ public function getShippingRateGroups()
42
+ {
43
+ return $this->getShippingRates();
44
+ }
45
+
46
+ /**
47
+ * Get either shipping rate code or empty value on error
48
+ *
49
+ * @param Varien_Object $rate
50
+ * @return string
51
+ */
52
+ public function renderShippingRateValue(Varien_Object $rate)
53
+ {
54
+ if ($rate->getErrorMessage()) {
55
+ return '';
56
+ }
57
+ return $rate->getCode();
58
+ }
59
+
60
+ /**
61
+ * Return formatted shipping price
62
+ *
63
+ * @param float $price
64
+ * @param bool $isInclTax
65
+ *
66
+ * @return bool
67
+ */
68
+ protected function _getShippingPrice($price, $isInclTax)
69
+ {
70
+ return $this->_formatPrice($this->helper('tax')->getShippingPrice($price, $isInclTax, $this->_address));
71
+ }
72
+
73
+ /**
74
+ * Format price base on store convert price method
75
+ *
76
+ * @param float $price
77
+ * @return string
78
+ */
79
+ protected function _formatPrice($price)
80
+ {
81
+ return $this->_quote->getStore()->convertPrice($price, true);
82
+ }
83
+
84
+ /**
85
+ * Get shipping rate code title and its price or error message
86
+ *
87
+ * @param Varien_Object $rate
88
+ * @param string $format
89
+ * @param string $inclTaxFormat
90
+ * @return string
91
+ */
92
+ public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
93
+ {
94
+ $renderedInclTax = '';
95
+ if ($rate->getErrorMessage()) {
96
+ $price = $rate->getErrorMessage();
97
+ } else {
98
+ $price = $this->_getShippingPrice($rate->getPrice(), $this->helper('tax')
99
+ ->displayShippingPriceIncludingTax());
100
+ $incl = $this->_getShippingPrice($rate->getPrice(), true);
101
+ if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
102
+ $renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
103
+ }
104
+ }
105
+ return sprintf($format, $rate->getMethodTitle(), $price, $renderedInclTax);
106
+ }
107
+
108
+ /**
109
+ * Get current shipping rate
110
+ *
111
+ * @return Mage_Sales_Model_Quote_Address_Rate|bool
112
+ */
113
+ public function getCurrentShippingRate()
114
+ {
115
+ /** @var $address Mage_Sales_Model_Quote_Address */
116
+ $address = $this->getAddress();
117
+ return $address->getShippingRateByCode($address->getShippingMethod());
118
+ }
119
+
120
+ /**
121
+ * Add price details to xml object
122
+ *
123
+ * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
124
+ * @param Mage_Sales_Model_Quote_Address_Rate $rate
125
+ * @return Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
126
+ */
127
+ protected function _addPriceToXmlObj($xmlObj, $rate)
128
+ {
129
+ $price = $this->_getShippingPrice($rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax());
130
+ $incl = $this->_getShippingPrice($rate->getPrice(), true);
131
+ $renderedInclTax = '';
132
+ if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
133
+ $inclTaxFormat = ' (%s %s)';
134
+ $renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
135
+ }
136
+ $price .= $renderedInclTax;
137
+ $xmlObj->addAttribute('price', $rate->getPrice() * 1);
138
+ $xmlObj->addAttribute('formatted_price', $xmlObj->escapeXml($price));
139
+ return $this;
140
+ }
141
+
142
  /**
143
  * Render PayPal MECL shipping method list xml
144
  *
148
  {
149
  /** @var $listXmlObj Mage_XmlConnect_Model_Simplexml_Element */
150
  $methodListXmlObj = Mage::getModel(
151
+ 'xmlconnect/simplexml_element', '<shipping_method_list></shipping_method_list>'
 
152
  );
 
153
  $methodListXmlObj->addAttribute('label', $this->__('Shipping Method'));
154
 
155
+ if (Mage::helper('xmlconnect')->checkApiVersion(Mage_XmlConnect_Helper_Data::DEVICE_API_V_23)) {
156
+ if (!$this->getCurrentShippingRate()) {
157
+ $groups = $this->getShippingRateGroups();
158
+ if ($groups) {
159
+ $currentRate = $this->getCurrentShippingRate();
160
+ foreach ($groups as $code => $rates) {
161
+ $rateListXmlObj = $this->_addRatesToXmlObj($methodListXmlObj, $code);
162
+ foreach ($rates as $rate) {
163
+ $rateAttributes = array(
164
+ 'label' => $rate->getMethodTitle(),
165
+ 'code' => $this->renderShippingRateValue($rate)
166
+ );
167
+ $rateXmlObj = $rateListXmlObj->addCustomChild('rate', null, $rateAttributes);
168
+ if ($rate->getErrorMessage()) {
169
+ $rateXmlObj->addChild('error_message', $rateXmlObj->escapeXml(
170
+ $rate->getErrorMessage()
171
+ ));
172
+ } else {
173
+ $this->_addPriceToXmlObj($rateXmlObj, $rate);
174
+ }
175
+ if ($currentRate === $rate) {
176
+ $rateXmlObj->addAttribute('selected', 1);
177
+ }
178
  }
 
179
  }
180
+ } else {
181
+ $this->_addNoShippingMessage($methodListXmlObj);
182
  }
183
  } else {
184
+ $rateListXmlObj = $this->_addRatesToXmlObj($methodListXmlObj);
185
+ $rate = $this->getCurrentShippingRate();
186
+ $rateXmlObj = $rateListXmlObj->addCustomChild('rate', null, array(
187
+ 'label' => $rate->getMethodTitle(),
188
+ 'code' => $this->renderShippingRateValue($rate),
189
+ 'selected' => 1
190
+ ));
191
+ $this->_addPriceToXmlObj($rateXmlObj, $rate);
192
  }
193
  } else {
194
+ if (!$this->getCurrentShippingRate()) {
195
+ $groups = $this->getShippingRateGroups();
196
+ if ($groups) {
197
+ $currentRate = $this->getCurrentShippingRate();
198
+ foreach ($groups as $code => $rates) {
199
+ $rateListXmlObj = $this->_addRatesToXmlObj($methodListXmlObj, $code);
200
+ foreach ($rates as $rate) {
201
+ if ($rate->getErrorMessage()) {
202
+ $title = $rate->getErrorMessage();
203
+ } else {
204
+ $title = $this->renderShippingRateOption($rate);
205
+ }
206
+ $rateAttributes = array(
207
+ 'label' => $rateListXmlObj->escapeXml($title),
208
+ 'code' => $this->renderShippingRateValue($rate)
209
+ );
210
+ if ($currentRate === $rate) {
211
+ $rateAttributes += array('selected' => 1);
212
+ }
213
+ $rateListXmlObj->addCustomChild('rate', null, $rateAttributes);
214
+ }
215
+ }
216
+ } else {
217
+ $this->_addNoShippingMessage($methodListXmlObj);
218
+ }
219
+ } else {
220
+ $rateXmlObj = $this->_addRatesToXmlObj($methodListXmlObj);
221
+ $rateXmlObj->addCustomChild('rate', null, array(
222
+ 'label' => $this->renderShippingRateOption($this->getCurrentShippingRate()),
223
+ 'selected' => 1
224
+ ));
225
+ }
226
  }
227
 
228
  return $methodListXmlObj->asNiceXml();
229
  }
230
 
231
+ /**
232
+ * Add message to describe that shipping is not required or not available
233
+ *
234
+ * @param Mage_XmlConnect_Model_Simplexml_Element $methodListXmlObj
235
+ * @return Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
236
+ */
237
+ protected function _addNoShippingMessage($methodListXmlObj)
238
+ {
239
+ $message = $this->_quote->isVirtual() ? $this->__('No shipping method required.')
240
+ : $this->__('Sorry, no quotes are available for this order at this time.');
241
+ $methodListXmlObj->addCustomChild('method', null, array('label' => $message));
242
+ return $this;
243
+ }
244
+
245
  /**
246
  * Add cart details to XML object
247
  *
249
  * @param string $code
250
  * @return Mage_XmlConnect_Model_Simplexml_Element
251
  */
252
+ protected function _addRatesToXmlObj($methodListXmlObj, $code = '')
253
  {
254
  $attributes = $code ? array('label' => $this->getCarrierName($code)) : array();
255
  return $methodListXmlObj->addCustomChild('method', null, $attributes)->addCustomChild('rates');
app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php CHANGED
@@ -40,13 +40,27 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mep_Totals extends Mage_Checkout_Block_C
40
  */
41
  protected function _toHtml()
42
  {
43
- /** @var $paypalCart Mage_Paypal_Model_Cart */
44
- $paypalCart = Mage::getModel('paypal/cart', array($this->getQuote()));
45
  /** @var $totalsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
46
  $totalsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<cart_totals></cart_totals>');
47
- foreach ($paypalCart->getTotals(true) as $code => $amount) {
48
- $currencyAmount = $this->helper('core')->currency($amount, false, false);
49
- $totalsXmlObj->addChild($code, sprintf('%01.2F', $currencyAmount));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
 
52
  $paypalTotals = $totalsXmlObj->addChild('paypal_totals');
@@ -59,10 +73,7 @@ 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(
63
- $code,
64
- Mage::helper('xmlconnect')->formatPriceForXml($subtotal)
65
- );
66
  break;
67
  case 'tax':
68
  $paypalTotals->addAttribute(
40
  */
41
  protected function _toHtml()
42
  {
43
+ $quote = $this->getQuote();
 
44
  /** @var $totalsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
45
  $totalsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<cart_totals></cart_totals>');
46
+
47
+ list($items, $totals) = Mage::helper('paypal')->prepareLineItems($quote);
48
+
49
+ $itemValidation = Mage::helper('xmlconnect/paypal_data')
50
+ ->areCartLineItemsValid($items, $totals, $quote->getBaseGrandTotal());
51
+ if ($itemValidation) {
52
+ foreach ($totals as $code => $amount) {
53
+ $currencyAmount = $this->helper('core')
54
+ ->currency($amount, false, false);
55
+ $totalsXmlObj->addChild(
56
+ $code,
57
+ Mage::helper('xmlconnect')->formatPriceForXml($currencyAmount)
58
+ );
59
+ }
60
+ } else {
61
+ Mage::throwException(
62
+ $this->__('Cart line items are not eligible for exporting to PayPal API')
63
+ );
64
  }
65
 
66
  $paypalTotals = $totalsXmlObj->addChild('paypal_totals');
73
  switch ($code) {
74
  case 'subtotal':
75
  $subtotal = intval($total->getValueExclTax()) ? $total->getValueExclTax() : $total->getValue();
76
+ $paypalTotals->addAttribute($code, Mage::helper('xmlconnect')->formatPriceForXml($subtotal));
 
 
 
77
  break;
78
  case 'tax':
79
  $paypalTotals->addAttribute(
app/code/core/Mage/XmlConnect/Block/Cart/Totals.php CHANGED
@@ -58,10 +58,7 @@ 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,
62
- $code . '_excl_tax',
63
- $title,
64
- $total->getValueExclTax()
65
  );
66
 
67
  $code = $code . '_incl_tax';
@@ -93,6 +90,7 @@ class Mage_XmlConnect_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Totals
93
  $this->_addTotalDataToXmlObj(
94
  $totalsXmlObj, $code . '_excl_tax', $title, $grandTotalExlTax
95
  );
 
96
  $code = $code . '_incl_tax';
97
  $title = $this->__('Grand Total (Incl. Tax)');
98
  }
@@ -103,12 +101,12 @@ class Mage_XmlConnect_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Totals
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);
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';
90
  $this->_addTotalDataToXmlObj(
91
  $totalsXmlObj, $code . '_excl_tax', $title, $grandTotalExlTax
92
  );
93
+
94
  $code = $code . '_incl_tax';
95
  $title = $this->__('Grand Total (Incl. Tax)');
96
  }
101
  }
102
  continue 2;
103
  case 'giftcardaccount':
104
+ $cards = $renderer->getTotal()->getGiftCards();
105
+ if (!$cards) {
106
+ $cards = $renderer->getQuoteGiftCards();
107
  }
108
  if ($renderer->getTotal()->getValue()) {
109
+ foreach ($cards as $cardCode) {
110
  $title = $this->__('Gift Card (%s)', $cardCode['c']);
111
  $value = $cardCode['c'];
112
  $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_Core_Block_Template
35
  {
36
  /**
37
  * Limit for product sorting fields to return
@@ -39,22 +39,48 @@ class Mage_XmlConnect_Block_Catalog extends Mage_Core_Block_Template
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,4 +98,32 @@ class Mage_XmlConnect_Block_Catalog extends Mage_Core_Block_Template
72
 
73
  return $ordersXmlObject;
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
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
  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
 
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
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Category.php CHANGED
@@ -43,8 +43,9 @@ 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
- if ($categoryId === null) {
47
- $categoryId = Mage::app()->getStore()->getRootCategoryId();
 
48
  }
49
 
50
  $productsXmlObj = $productListBlock = false;
@@ -73,10 +74,10 @@ class Mage_XmlConnect_Block_Catalog_Category extends Mage_XmlConnect_Block_Catal
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,12 +86,10 @@ class Mage_XmlConnect_Block_Catalog_Category extends Mage_XmlConnect_Block_Catal
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
 
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
  // 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
  $itemXmlObj = $itemsXmlObj->addChild('item');
82
  $itemXmlObj->addChild('label', $categoryXmlObj->escapeXml($item->getName()));
83
  $itemXmlObj->addChild('entity_id', $item->getId());
86
  $itemXmlObj->addChild('parent_id', $item->getParentId());
87
  }
88
  $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail')
89
+ ->resize($categoryImageSize);
90
 
91
  $iconXml = $itemXmlObj->addChild('icon', $icon);
92
+ $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
 
 
93
  }
94
  }
95
 
app/code/core/Mage/XmlConnect/Block/Catalog/Filters.php CHANGED
@@ -41,6 +41,7 @@ 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
  $categoryXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<category></category>');
45
  $filtersCollection = Mage::getResourceModel('xmlconnect/filter_collection')->setCategoryId($categoryId);
46
 
@@ -61,7 +62,7 @@ class Mage_XmlConnect_Block_Catalog_Filters extends Mage_XmlConnect_Block_Catalo
61
  $valueXmlObj->addChild('count', (int)$value->getProductsCount());
62
  }
63
  }
64
- $categoryXmlObj->appendChild($this->getProductSortFeildsXmlObject());
65
 
66
  return $categoryXmlObj->asNiceXml();
67
  }
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
  $valueXmlObj->addChild('count', (int)$value->getProductsCount());
63
  }
64
  }
65
+ $categoryXmlObj->appendChild($this->getProductSortFieldsXmlObject());
66
 
67
  return $categoryXmlObj->asNiceXml();
68
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product.php CHANGED
@@ -52,23 +52,24 @@ 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
 
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,8 +88,14 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
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,8 +106,7 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
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,24 +142,28 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
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
  }
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
  }
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
  $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
  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
  }
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', strip_tags($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', $attrXmlObject->escapeXml($attribute));
57
  }
58
  }
59
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Gallery.php CHANGED
@@ -40,43 +40,42 @@ class Mage_XmlConnect_Block_Catalog_Product_Gallery extends Mage_XmlConnect_Bloc
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
  }
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
  }
app/code/core/Mage/XmlConnect/Block/Catalog/Product/ItemPrice.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,426 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,740 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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