Mage_Core_Adminhtml - Version 1.6.1.0

Version Notes

1.6.1.0

Download this release

Release Info

Developer Magento Core Team
Extension Mage_Core_Adminhtml
Version 1.6.1.0
Comparing to
See all releases


Version 1.6.1.0

Files changed (262) hide show
  1. app/code/core/Mage/Adminhtml/Block/Abstract.php +47 -0
  2. app/code/core/Mage/Adminhtml/Block/Api/Buttons.php +102 -0
  3. app/code/core/Mage/Adminhtml/Block/Api/Editroles.php +64 -0
  4. app/code/core/Mage/Adminhtml/Block/Api/Edituser.php +57 -0
  5. app/code/core/Mage/Adminhtml/Block/Api/Grid/Role.php +81 -0
  6. app/code/core/Mage/Adminhtml/Block/Api/Role.php +46 -0
  7. app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php +182 -0
  8. app/code/core/Mage/Adminhtml/Block/Api/Roles.php +51 -0
  9. app/code/core/Mage/Adminhtml/Block/Api/Tab/Roleinfo.php +81 -0
  10. app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php +117 -0
  11. app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php +57 -0
  12. app/code/core/Mage/Adminhtml/Block/Api/Tab/Userroles.php +49 -0
  13. app/code/core/Mage/Adminhtml/Block/Api/User.php +45 -0
  14. app/code/core/Mage/Adminhtml/Block/Api/User/Edit.php +58 -0
  15. app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Form.php +45 -0
  16. app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php +153 -0
  17. app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.php +119 -0
  18. app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tabs.php +62 -0
  19. app/code/core/Mage/Adminhtml/Block/Api/User/Grid.php +106 -0
  20. app/code/core/Mage/Adminhtml/Block/Api/Users.php +54 -0
  21. app/code/core/Mage/Adminhtml/Block/Backup.php +68 -0
  22. app/code/core/Mage/Adminhtml/Block/Backup/Grid.php +108 -0
  23. app/code/core/Mage/Adminhtml/Block/Cache.php +67 -0
  24. app/code/core/Mage/Adminhtml/Block/Cache/Additional.php +38 -0
  25. app/code/core/Mage/Adminhtml/Block/Cache/Grid.php +182 -0
  26. app/code/core/Mage/Adminhtml/Block/Cache/Notifications.php +66 -0
  27. app/code/core/Mage/Adminhtml/Block/Catalog.php +41 -0
  28. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +209 -0
  29. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.php +98 -0
  30. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit.php +45 -0
  31. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php +234 -0
  32. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Image.php +44 -0
  33. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php +64 -0
  34. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php +67 -0
  35. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php +67 -0
  36. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php +179 -0
  37. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Design.php +58 -0
  38. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php +137 -0
  39. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php +162 -0
  40. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tabs.php +167 -0
  41. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php +352 -0
  42. app/code/core/Mage/Adminhtml/Block/Catalog/Category/Widget/Chooser.php +178 -0
  43. app/code/core/Mage/Adminhtml/Block/Catalog/Form.php +48 -0
  44. app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Attribute/Urlkey.php +65 -0
  45. app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php +61 -0
  46. app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php +54 -0
  47. app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php +183 -0
  48. app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php +72 -0
  49. app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php +65 -0
  50. app/code/core/Mage/Adminhtml/Block/Catalog/Product.php +94 -0
  51. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute.php +46 -0
  52. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php +101 -0
  53. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Form.php +46 -0
  54. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php +106 -0
  55. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php +261 -0
  56. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php +36 -0
  57. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/System.php +134 -0
  58. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php +73 -0
  59. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php +123 -0
  60. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Attributes.php +94 -0
  61. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php +89 -0
  62. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Grid.php +78 -0
  63. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php +409 -0
  64. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.php +70 -0
  65. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php +88 -0
  66. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php +87 -0
  67. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Attribute.php +39 -0
  68. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Group.php +39 -0
  69. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php +88 -0
  70. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php +71 -0
  71. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main/Filter.php +64 -0
  72. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Configure.php +74 -0
  73. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Error.php +47 -0
  74. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset.php +62 -0
  75. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Configurable.php +76 -0
  76. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Grouped.php +146 -0
  77. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Options.php +73 -0
  78. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Qty.php +75 -0
  79. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Update/Result.php +50 -0
  80. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Created.php +152 -0
  81. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php +249 -0
  82. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php +136 -0
  83. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Attributes.php +124 -0
  84. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Inventory.php +102 -0
  85. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Websites.php +75 -0
  86. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tabs.php +45 -0
  87. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Js.php +52 -0
  88. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.php +71 -0
  89. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php +77 -0
  90. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php +122 -0
  91. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php +114 -0
  92. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php +161 -0
  93. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php +103 -0
  94. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php +239 -0
  95. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php +260 -0
  96. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php +145 -0
  97. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php +72 -0
  98. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php +345 -0
  99. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.php +69 -0
  100. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Date.php +44 -0
  101. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/File.php +43 -0
  102. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php +90 -0
  103. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Text.php +44 -0
  104. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price.php +63 -0
  105. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Recurring.php +49 -0
  106. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php +382 -0
  107. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php +258 -0
  108. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Reviews.php +55 -0
  109. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Settings.php +90 -0
  110. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php +341 -0
  111. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid.php +312 -0
  112. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php +56 -0
  113. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php +72 -0
  114. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Inventory.php +51 -0
  115. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php +196 -0
  116. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php +236 -0
  117. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php +159 -0
  118. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag.php +108 -0
  119. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag/Customer.php +103 -0
  120. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php +257 -0
  121. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Websites.php +111 -0
  122. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php +238 -0
  123. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Configurable.php +59 -0
  124. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Grouped.php +46 -0
  125. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Frontend/Product/Watermark.php +107 -0
  126. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php +291 -0
  127. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Apply.php +71 -0
  128. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Boolean.php +50 -0
  129. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Config.php +70 -0
  130. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php +191 -0
  131. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php +170 -0
  132. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Image.php +64 -0
  133. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php +49 -0
  134. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php +49 -0
  135. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php +90 -0
  136. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Price.php +37 -0
  137. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser.php +294 -0
  138. app/code/core/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser/Container.php +46 -0
  139. app/code/core/Mage/Adminhtml/Block/Catalog/Search.php +46 -0
  140. app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit.php +59 -0
  141. app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php +157 -0
  142. app/code/core/Mage/Adminhtml/Block/Catalog/Search/Grid.php +178 -0
  143. app/code/core/Mage/Adminhtml/Block/Checkout/Agreement.php +44 -0
  144. app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Edit.php +66 -0
  145. app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Edit/Form.php +151 -0
  146. app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Grid.php +110 -0
  147. app/code/core/Mage/Adminhtml/Block/Cms/Block.php +45 -0
  148. app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php +83 -0
  149. app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php +140 -0
  150. app/code/core/Mage/Adminhtml/Block/Cms/Block/Grid.php +132 -0
  151. app/code/core/Mage/Adminhtml/Block/Cms/Block/Widget/Chooser.php +159 -0
  152. app/code/core/Mage/Adminhtml/Block/Cms/Page.php +67 -0
  153. app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php +142 -0
  154. app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Form.php +46 -0
  155. app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php +153 -0
  156. app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php +184 -0
  157. app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php +175 -0
  158. app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php +135 -0
  159. app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php +44 -0
  160. app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php +150 -0
  161. app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid/Renderer/Action.php +41 -0
  162. app/code/core/Mage/Adminhtml/Block/Cms/Page/Widget/Chooser.php +165 -0
  163. app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content.php +161 -0
  164. app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Files.php +155 -0
  165. app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Newfolder.php +37 -0
  166. app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Uploader.php +71 -0
  167. app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Tree.php +99 -0
  168. app/code/core/Mage/Adminhtml/Block/Customer.php +46 -0
  169. app/code/core/Mage/Adminhtml/Block/Customer/Edit.php +123 -0
  170. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Form.php +60 -0
  171. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php +56 -0
  172. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php +69 -0
  173. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php +244 -0
  174. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php +274 -0
  175. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Cart.php +158 -0
  176. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php +64 -0
  177. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php +99 -0
  178. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid.php +126 -0
  179. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Filter/Status.php +71 -0
  180. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php +73 -0
  181. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php +65 -0
  182. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Orders.php +136 -0
  183. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Reviews.php +55 -0
  184. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Tag.php +122 -0
  185. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Tags.php +122 -0
  186. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php +204 -0
  187. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php +88 -0
  188. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php +123 -0
  189. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php +136 -0
  190. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php +126 -0
  191. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php +139 -0
  192. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php +137 -0
  193. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php +279 -0
  194. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php +42 -0
  195. app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php +131 -0
  196. app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/Boolean.php +56 -0
  197. app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/File.php +212 -0
  198. app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/Image.php +104 -0
  199. app/code/core/Mage/Adminhtml/Block/Customer/Grid.php +221 -0
  200. app/code/core/Mage/Adminhtml/Block/Customer/Grid/Filter/Country.php +44 -0
  201. app/code/core/Mage/Adminhtml/Block/Customer/Grid/Renderer/Multiaction.php +92 -0
  202. app/code/core/Mage/Adminhtml/Block/Customer/Group.php +57 -0
  203. app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php +64 -0
  204. app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit/Form.php +98 -0
  205. app/code/core/Mage/Adminhtml/Block/Customer/Group/Grid.php +90 -0
  206. app/code/core/Mage/Adminhtml/Block/Customer/Online.php +60 -0
  207. app/code/core/Mage/Adminhtml/Block/Customer/Online/Filter.php +77 -0
  208. app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php +166 -0
  209. app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Ip.php +42 -0
  210. app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Type.php +42 -0
  211. app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Url.php +47 -0
  212. app/code/core/Mage/Adminhtml/Block/Dashboard.php +88 -0
  213. app/code/core/Mage/Adminhtml/Block/Dashboard/Abstract.php +80 -0
  214. app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php +116 -0
  215. app/code/core/Mage/Adminhtml/Block/Dashboard/Diagrams.php +59 -0
  216. app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php +560 -0
  217. app/code/core/Mage/Adminhtml/Block/Dashboard/Grid.php +50 -0
  218. app/code/core/Mage/Adminhtml/Block/Dashboard/Grids.php +89 -0
  219. app/code/core/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php +124 -0
  220. app/code/core/Mage/Adminhtml/Block/Dashboard/Sales.php +71 -0
  221. app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Last.php +102 -0
  222. app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php +47 -0
  223. app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Top.php +104 -0
  224. app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Amounts.php +69 -0
  225. app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Most.php +118 -0
  226. app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Newest.php +116 -0
  227. app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Orders.php +68 -0
  228. app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Products/Ordered.php +126 -0
  229. app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Products/Viewed.php +105 -0
  230. app/code/core/Mage/Adminhtml/Block/Dashboard/Totals.php +79 -0
  231. app/code/core/Mage/Adminhtml/Block/Denied.php +37 -0
  232. app/code/core/Mage/Adminhtml/Block/Html/Date.php +48 -0
  233. app/code/core/Mage/Adminhtml/Block/Html/Select.php +47 -0
  234. app/code/core/Mage/Adminhtml/Block/Media/Editor.php +152 -0
  235. app/code/core/Mage/Adminhtml/Block/Media/Uploader.php +218 -0
  236. app/code/core/Mage/Adminhtml/Block/Messages.php +48 -0
  237. app/code/core/Mage/Adminhtml/Block/Newsletter/Problem.php +90 -0
  238. app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid.php +102 -0
  239. app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Filter/Checkbox.php +46 -0
  240. app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Renderer/Checkbox.php +47 -0
  241. app/code/core/Mage/Adminhtml/Block/Newsletter/Queue.php +47 -0
  242. app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php +262 -0
  243. app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit/Form.php +202 -0
  244. app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Grid.php +130 -0
  245. app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Grid/Renderer/Action.php +79 -0
  246. app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php +79 -0
  247. app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview/Form.php +69 -0
  248. app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber.php +96 -0
  249. app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php +208 -0
  250. app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Checkbox.php +46 -0
  251. app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Website.php +71 -0
  252. app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Checkbox.php +52 -0
  253. app/code/core/Mage/Adminhtml/Block/Newsletter/Template.php +59 -0
  254. app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php +350 -0
  255. app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit/Form.php +155 -0
  256. app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid.php +121 -0
  257. app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php +62 -0
  258. app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Sender.php +51 -0
  259. app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview.php +76 -0
  260. app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview/Form.php +70 -0
  261. app/code/core/Mage/Adminhtml/Block/Notification/Baseurl.php +64 -0
  262. app/code/core/Mage/Adminhtml/Block/Notification/Grid.php +68 -0
app/code/core/Mage/Adminhtml/Block/Abstract.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml abstract block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Abstract extends Mage_Core_Block_Template
35
+ {
36
+
37
+ /**
38
+ * Enter description here...
39
+ *
40
+ * @return string
41
+ */
42
+ protected function _getUrlModelClass()
43
+ {
44
+ return 'adminhtml/url';
45
+ }
46
+
47
+ }
app/code/core/Mage/Adminhtml/Block/Api/Buttons.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Api_Buttons extends Mage_Adminhtml_Block_Template
28
+ {
29
+
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setTemplate('api/userinfo.phtml');
34
+ }
35
+
36
+ protected function _prepareLayout()
37
+ {
38
+ $this->setChild('backButton',
39
+ $this->getLayout()->createBlock('adminhtml/widget_button')
40
+ ->setData(array(
41
+ 'label' => Mage::helper('adminhtml')->__('Back'),
42
+ 'onclick' => 'window.location.href=\''.$this->getUrl('*/*/').'\'',
43
+ 'class' => 'back'
44
+ ))
45
+ );
46
+
47
+ $this->setChild('resetButton',
48
+ $this->getLayout()->createBlock('adminhtml/widget_button')
49
+ ->setData(array(
50
+ 'label' => Mage::helper('adminhtml')->__('Reset'),
51
+ 'onclick' => 'window.location.reload()'
52
+ ))
53
+ );
54
+
55
+ $this->setChild('saveButton',
56
+ $this->getLayout()->createBlock('adminhtml/widget_button')
57
+ ->setData(array(
58
+ 'label' => Mage::helper('adminhtml')->__('Save Role'),
59
+ 'onclick' => 'roleForm.submit();return false;',
60
+ 'class' => 'save'
61
+ ))
62
+ );
63
+
64
+ $this->setChild('deleteButton',
65
+ $this->getLayout()->createBlock('adminhtml/widget_button')
66
+ ->setData(array(
67
+ 'label' => Mage::helper('adminhtml')->__('Delete Role'),
68
+ 'onclick' => 'deleteConfirm(\'' . Mage::helper('adminhtml')->__('Are you sure you want to do this?') . '\', \'' . $this->getUrl('*/*/delete', array('rid' => $this->getRequest()->getParam('rid'))) . '\')',
69
+ 'class' => 'delete'
70
+ ))
71
+ );
72
+ return parent::_prepareLayout();
73
+ }
74
+
75
+ public function getBackButtonHtml()
76
+ {
77
+ return $this->getChildHtml('backButton');
78
+ }
79
+
80
+ public function getResetButtonHtml()
81
+ {
82
+ return $this->getChildHtml('resetButton');
83
+ }
84
+
85
+ public function getSaveButtonHtml()
86
+ {
87
+ return $this->getChildHtml('saveButton');
88
+ }
89
+
90
+ public function getDeleteButtonHtml()
91
+ {
92
+ if( intval($this->getRequest()->getParam('rid')) == 0 ) {
93
+ return;
94
+ }
95
+ return $this->getChildHtml('deleteButton');
96
+ }
97
+
98
+ public function getUser()
99
+ {
100
+ return Mage::registry('user_data');
101
+ }
102
+ }
app/code/core/Mage/Adminhtml/Block/Api/Editroles.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Api_Editroles extends Mage_Adminhtml_Block_Widget_Tabs {
28
+ public function __construct()
29
+ {
30
+ parent::__construct();
31
+ $this->setId('role_info_tabs');
32
+ $this->setDestElementId('role_edit_form');
33
+ $this->setTitle(Mage::helper('adminhtml')->__('Role Information'));
34
+ }
35
+
36
+ protected function _beforeToHtml()
37
+ {
38
+ $roleId = $this->getRequest()->getParam('rid', false);
39
+ $role = Mage::getModel("api/roles")
40
+ ->load($roleId);
41
+
42
+ $this->addTab('info', array(
43
+ 'label' => Mage::helper('adminhtml')->__('Role Info'),
44
+ 'title' => Mage::helper('adminhtml')->__('Role Info'),
45
+ 'content' => $this->getLayout()->createBlock('adminhtml/api_tab_roleinfo')->setRole($role)->toHtml(),
46
+ 'active' => true
47
+ ));
48
+
49
+ $this->addTab('account', array(
50
+ 'label' => Mage::helper('adminhtml')->__('Role Resources'),
51
+ 'title' => Mage::helper('adminhtml')->__('Role Resources'),
52
+ 'content' => $this->getLayout()->createBlock('adminhtml/api_tab_rolesedit')->toHtml(),
53
+ ));
54
+
55
+ if( intval($roleId) > 0 ) {
56
+ $this->addTab('roles', array(
57
+ 'label' => Mage::helper('adminhtml')->__('Role Users'),
58
+ 'title' => Mage::helper('adminhtml')->__('Role Users'),
59
+ 'content' => $this->getLayout()->createBlock('adminhtml/api_tab_rolesusers', 'role.users.grid')->toHtml(),
60
+ ));
61
+ }
62
+ return parent::_beforeToHtml();
63
+ }
64
+ }
app/code/core/Mage/Adminhtml/Block/Api/Edituser.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Api_Edituser extends Mage_Adminhtml_Block_Widget_Tabs {
28
+ public function __construct()
29
+ {
30
+ parent::__construct();
31
+ $this->setId('customer_info_tabs');
32
+ $this->setDestElementId('user_edit_form');
33
+ }
34
+
35
+ protected function _beforeToHtml()
36
+ {
37
+ $this->addTab('account', array(
38
+ 'label' => Mage::helper('adminhtml')->__('User Info'),
39
+ 'title' => Mage::helper('adminhtml')->__('User Info'),
40
+ 'content' => $this->getLayout()->createBlock('adminhtml/api_tab_useredit')->toHtml(),
41
+ 'active' => true
42
+ ));
43
+ if( $this->getUser()->getUserId() ) {
44
+ $this->addTab('roles', array(
45
+ 'label' => Mage::helper('adminhtml')->__('Roles'),
46
+ 'title' => Mage::helper('adminhtml')->__('Roles'),
47
+ 'content' => $this->getLayout()->createBlock('adminhtml/api_tab_userroles')->toHtml(),
48
+ ));
49
+ }
50
+ return parent::_beforeToHtml();
51
+ }
52
+
53
+ public function getUser()
54
+ {
55
+ return Mage::registry('user_data');
56
+ }
57
+ }
app/code/core/Mage/Adminhtml/Block/Api/Grid/Role.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * roles grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Api_Grid_Role extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setId('roleGrid');
40
+ $this->setSaveParametersInSession(true);
41
+ $this->setDefaultSort('role_id');
42
+ $this->setDefaultDir('asc');
43
+ $this->setUseAjax(true);
44
+ }
45
+
46
+ protected function _prepareCollection()
47
+ {
48
+ $collection = Mage::getModel("api/roles")->getCollection();
49
+ $this->setCollection($collection);
50
+
51
+ return parent::_prepareCollection();
52
+ }
53
+
54
+ protected function _prepareColumns()
55
+ {
56
+
57
+ $this->addColumn('role_id', array(
58
+ 'header' =>Mage::helper('adminhtml')->__('ID'),
59
+ 'index' =>'role_id',
60
+ 'align' => 'right',
61
+ 'width' => '50px'
62
+ ));
63
+
64
+ $this->addColumn('role_name', array(
65
+ 'header' =>Mage::helper('adminhtml')->__('Role Name'),
66
+ 'index' =>'role_name'
67
+ ));
68
+
69
+ return parent::_prepareColumns();
70
+ }
71
+
72
+ public function getGridUrl()
73
+ {
74
+ return $this->getUrl('*/*/roleGrid', array('_current'=>true));
75
+ }
76
+
77
+ public function getRowUrl($row)
78
+ {
79
+ return $this->getUrl('*/*/editrole', array('rid' => $row->getRoleId()));
80
+ }
81
+ }
app/code/core/Mage/Adminhtml/Block/Api/Role.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml permissioms role block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Api_Role extends Mage_Adminhtml_Block_Widget_Grid_Container
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ $this->_controller = 'api_role';
41
+ $this->_headerText = Mage::helper('adminhtml')->__('Roles');
42
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add New Role');
43
+ parent::__construct();
44
+ }
45
+
46
+ }
app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Acl role user grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Api_Role_Grid_User extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setDefaultSort('role_user_id');
41
+ $this->setDefaultDir('asc');
42
+ $this->setId('roleUserGrid');
43
+ $this->setDefaultFilter(array('in_role_users'=>1));
44
+ $this->setUseAjax(true);
45
+ }
46
+
47
+ protected function _addColumnFilterToCollection($column)
48
+ {
49
+ if ($column->getId() == 'in_role_users') {
50
+ $inRoleIds = $this->_getUsers();
51
+ if (empty($inRoleIds)) {
52
+ $inRoleIds = 0;
53
+ }
54
+ if ($column->getFilter()->getValue()) {
55
+ $this->getCollection()->addFieldToFilter('user_id', array('in'=>$inRoleIds));
56
+ }
57
+ else {
58
+ if($inRoleIds) {
59
+ $this->getCollection()->addFieldToFilter('user_id', array('nin'=>$inRoleIds));
60
+ }
61
+ }
62
+ }
63
+ else {
64
+ parent::_addColumnFilterToCollection($column);
65
+ }
66
+ return $this;
67
+ }
68
+
69
+ protected function _prepareCollection()
70
+ {
71
+ $roleId = $this->getRequest()->getParam('rid');
72
+ Mage::register('RID', $roleId);
73
+ $collection = Mage::getModel('api/roles')->getUsersCollection();
74
+ $this->setCollection($collection);
75
+ return parent::_prepareCollection();
76
+ }
77
+
78
+ protected function _prepareColumns()
79
+ {
80
+ $this->addColumn('in_role_users', array(
81
+ 'header_css_class' => 'a-center',
82
+ 'type' => 'checkbox',
83
+ 'name' => 'in_role_users',
84
+ 'values' => $this->_getUsers(),
85
+ 'align' => 'center',
86
+ 'index' => 'user_id'
87
+ ));
88
+
89
+ $this->addColumn('role_user_id', array(
90
+ 'header' =>Mage::helper('adminhtml')->__('User ID'),
91
+ 'width' =>5,
92
+ 'align' =>'left',
93
+ 'sortable' =>true,
94
+ 'index' =>'user_id'
95
+ ));
96
+
97
+ $this->addColumn('role_user_username', array(
98
+ 'header' =>Mage::helper('adminhtml')->__('User Name'),
99
+ 'align' =>'left',
100
+ 'index' =>'username'
101
+ ));
102
+
103
+ $this->addColumn('role_user_firstname', array(
104
+ 'header' =>Mage::helper('adminhtml')->__('First Name'),
105
+ 'align' =>'left',
106
+ 'index' =>'firstname'
107
+ ));
108
+
109
+ $this->addColumn('role_user_lastname', array(
110
+ 'header' =>Mage::helper('adminhtml')->__('Last Name'),
111
+ 'align' =>'left',
112
+ 'index' =>'lastname'
113
+ ));
114
+
115
+ $this->addColumn('role_user_email', array(
116
+ 'header' =>Mage::helper('adminhtml')->__('Email'),
117
+ 'width' =>40,
118
+ 'align' =>'left',
119
+ 'index' =>'email'
120
+ ));
121
+
122
+ $this->addColumn('role_user_is_active', array(
123
+ 'header' => Mage::helper('adminhtml')->__('Status'),
124
+ 'index' => 'is_active',
125
+ 'align' =>'left',
126
+ 'type' => 'options',
127
+ 'options' => array('1' => Mage::helper('adminhtml')->__('Active'), '0' => Mage::helper('adminhtml')->__('Inactive')),
128
+ ));
129
+
130
+ /*
131
+ $this->addColumn('grid_actions',
132
+ array(
133
+ 'header'=>Mage::helper('adminhtml')->__('Actions'),
134
+ 'width'=>5,
135
+ 'sortable'=>false,
136
+ 'filter' =>false,
137
+ 'type' => 'action',
138
+ 'actions' => array(
139
+ array(
140
+ 'caption' => Mage::helper('adminhtml')->__('Remove'),
141
+ 'onClick' => 'role.deleteFromRole($role_id);'
142
+ )
143
+ )
144
+ )
145
+ );
146
+ */
147
+
148
+ return parent::_prepareColumns();
149
+ }
150
+
151
+ public function getGridUrl()
152
+ {
153
+ $roleId = $this->getRequest()->getParam('rid');
154
+ return $this->getUrl('*/*/editrolegrid', array('rid' => $roleId));
155
+ }
156
+
157
+ protected function _getUsers($json=false)
158
+ {
159
+ if ( $this->getRequest()->getParam('in_role_user') != "" ) {
160
+ return $this->getRequest()->getParam('in_role_user');
161
+ }
162
+ $roleId = ( $this->getRequest()->getParam('rid') > 0 ) ? $this->getRequest()->getParam('rid') : Mage::registry('RID');
163
+ $users = Mage::getModel('api/roles')->setId($roleId)->getRoleUsers();
164
+ if (sizeof($users) > 0) {
165
+ if ( $json ) {
166
+ $jsonUsers = Array();
167
+ foreach($users as $usrid) $jsonUsers[$usrid] = 0;
168
+ return Mage::helper('core')->jsonEncode((object)$jsonUsers);
169
+ } else {
170
+ return array_values($users);
171
+ }
172
+ } else {
173
+ if ( $json ) {
174
+ return '{}';
175
+ } else {
176
+ return array();
177
+ }
178
+ }
179
+ }
180
+
181
+ }
182
+
app/code/core/Mage/Adminhtml/Block/Api/Roles.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * user roles block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Api_Roles extends Mage_Adminhtml_Block_Template
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setTemplate('api/roles.phtml');
40
+ }
41
+
42
+ public function getAddNewUrl()
43
+ {
44
+ return $this->getUrl('*/*/editrole');
45
+ }
46
+
47
+ public function getGridHtml()
48
+ {
49
+ return $this->getLayout()->createBlock('adminhtml/api_grid_role')->toHtml();
50
+ }
51
+ }
app/code/core/Mage/Adminhtml/Block/Api/Tab/Roleinfo.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * implementing now
29
+ *
30
+ */
31
+ class Mage_Adminhtml_Block_Api_Tab_Roleinfo extends Mage_Adminhtml_Block_Widget_Form
32
+ {
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+ }
37
+
38
+ public function _beforeToHtml() {
39
+ $this->_initForm();
40
+
41
+ return parent::_beforeToHtml();
42
+ }
43
+
44
+ protected function _initForm()
45
+ {
46
+ $roleId = $this->getRequest()->getParam('rid');
47
+
48
+ $form = new Varien_Data_Form();
49
+
50
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Role Information')));
51
+
52
+ $fieldset->addField('role_name', 'text',
53
+ array(
54
+ 'name' => 'rolename',
55
+ 'label' => Mage::helper('adminhtml')->__('Role Name'),
56
+ 'id' => 'role_name',
57
+ 'class' => 'required-entry',
58
+ 'required' => true,
59
+ )
60
+ );
61
+
62
+ $fieldset->addField('role_id', 'hidden',
63
+ array(
64
+ 'name' => 'role_id',
65
+ 'id' => 'role_id',
66
+ )
67
+ );
68
+
69
+ $fieldset->addField('in_role_user', 'hidden',
70
+ array(
71
+ 'name' => 'in_role_user',
72
+ 'id' => 'in_role_userz',
73
+ )
74
+ );
75
+
76
+ $fieldset->addField('in_role_user_old', 'hidden', array('name' => 'in_role_user_old'));
77
+
78
+ $form->setValues($this->getRole()->getData());
79
+ $this->setForm($form);
80
+ }
81
+ }
app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Api_Tab_Rolesedit extends Mage_Adminhtml_Block_Widget_Form {
28
+
29
+ public function __construct() {
30
+ parent::__construct();
31
+
32
+ $rid = Mage::app()->getRequest()->getParam('rid', false);
33
+
34
+ $resources = Mage::getModel('api/roles')->getResourcesList();
35
+
36
+ $rules_set = Mage::getResourceModel('api/rules_collection')->getByRoles($rid)->load();
37
+
38
+ $selrids = array();
39
+
40
+ foreach ($rules_set->getItems() as $item) {
41
+ if (array_key_exists(strtolower($item->getResource_id()), $resources) && $item->getPermission() == 'allow') {
42
+ $resources[$item->getResource_id()]['checked'] = true;
43
+ array_push($selrids, $item->getResource_id());
44
+ }
45
+ }
46
+
47
+ $this->setSelectedResources($selrids);
48
+
49
+ $this->setTemplate('api/rolesedit.phtml');
50
+ //->assign('resources', $resources);
51
+ //->assign('checkedResources', join(',', $selrids));
52
+ }
53
+
54
+ public function getEverythingAllowed()
55
+ {
56
+ return in_array('all', $this->getSelectedResources());
57
+ }
58
+
59
+ public function getResTreeJson()
60
+ {
61
+ $rid = Mage::app()->getRequest()->getParam('rid', false);
62
+ $resources = Mage::getModel('api/roles')->getResourcesTree();
63
+
64
+ $rootArray = $this->_getNodeJson($resources,1);
65
+
66
+ $json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());
67
+
68
+ return $json;
69
+ }
70
+
71
+ protected function _sortTree($a, $b)
72
+ {
73
+ return $a['sort_order']<$b['sort_order'] ? -1 : ($a['sort_order']>$b['sort_order'] ? 1 : 0);
74
+ }
75
+
76
+
77
+ protected function _getNodeJson($node, $level=0)
78
+ {
79
+ $item = array();
80
+ $selres = $this->getSelectedResources();
81
+
82
+ if ($level != 0) {
83
+ $item['text']= (string)$node->title;
84
+ $item['sort_order']= isset($node->sort_order) ? (string)$node->sort_order : 0;
85
+ $item['id'] = (string)$node->attributes()->aclpath;
86
+
87
+ if (in_array($item['id'], $selres))
88
+ $item['checked'] = true;
89
+ }
90
+ if (isset($node->children)) {
91
+ $children = $node->children->children();
92
+ } else {
93
+ $children = $node->children();
94
+ }
95
+ if (empty($children)) {
96
+ return $item;
97
+ }
98
+
99
+ if ($children) {
100
+ $item['children'] = array();
101
+ //$item['cls'] = 'fiche-node';
102
+ foreach ($children as $child) {
103
+ if ($child->getName()!='title' && $child->getName()!='sort_order' && $child->attributes()->module) {
104
+ if ($level != 0) {
105
+ $item['children'][] = $this->_getNodeJson($child, $level+1);
106
+ } else {
107
+ $item = $this->_getNodeJson($child, $level+1);
108
+ }
109
+ }
110
+ }
111
+ if (!empty($item['children'])) {
112
+ usort($item['children'], array($this, '_sortTree'));
113
+ }
114
+ }
115
+ return $item;
116
+ }
117
+ }
app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesusers.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Api_Tab_Rolesusers extends Mage_Adminhtml_Block_Widget_Tabs {
28
+
29
+ public function __construct()
30
+ {
31
+ parent::__construct();
32
+
33
+ $roleId = $this->getRequest()->getParam('rid', false);
34
+
35
+ $users = Mage::getModel("api/user")->getCollection()->load();
36
+ $this->setTemplate('api/rolesusers.phtml')
37
+ ->assign('users', $users->getItems())
38
+ ->assign('roleId', $roleId);
39
+ }
40
+
41
+ protected function _prepareLayout()
42
+ {
43
+ $this->setChild('userGrid', $this->getLayout()->createBlock('adminhtml/api_role_grid_user', 'roleUsersGrid'));
44
+ return parent::_prepareLayout();
45
+ }
46
+
47
+ protected function _getGridHtml()
48
+ {
49
+ return $this->getChildHtml('userGrid');
50
+ }
51
+
52
+ protected function _getJsObjectName()
53
+ {
54
+ return $this->getChild('userGrid')->getJsObjectName();
55
+ }
56
+
57
+ }
app/code/core/Mage/Adminhtml/Block/Api/Tab/Userroles.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Mage_Adminhtml_Block_Api_Tab_Userroles extends Mage_Adminhtml_Block_Widget_Tabs
27
+ {
28
+
29
+ public function __construct()
30
+ {
31
+ parent::__construct();
32
+
33
+ $uid = $this->getRequest()->getParam('id', false);
34
+ $uid = !empty($uid) ? $uid : 0;
35
+ $roles = Mage::getModel("api/roles")
36
+ ->getCollection()
37
+ ->load();
38
+
39
+ $user_roles = Mage::getModel("api/roles")
40
+ ->getUsersCollection()
41
+ ->setUserFilter($uid)
42
+ ->load();
43
+
44
+ $this->setTemplate('api/userroles.phtml')
45
+ ->assign('roles', $roles)
46
+ ->assign('user_roles', $user_roles);
47
+ }
48
+
49
+ }
app/code/core/Mage/Adminhtml/Block/Api/User.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml permissions user block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Api_User extends Mage_Adminhtml_Block_Widget_Grid_Container
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ $this->_controller = 'api_user';
40
+ $this->_headerText = Mage::helper('adminhtml')->__('Users');
41
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add New User');
42
+ parent::__construct();
43
+ }
44
+
45
+ }
app/code/core/Mage/Adminhtml/Block/Api/User/Edit.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml permissions user edit page
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Api_User_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ $this->_objectId = 'user_id';
40
+ $this->_controller = 'api_user';
41
+
42
+ parent::__construct();
43
+
44
+ $this->_updateButton('save', 'label', Mage::helper('adminhtml')->__('Save User'));
45
+ $this->_updateButton('delete', 'label', Mage::helper('adminhtml')->__('Delete User'));
46
+ }
47
+
48
+ public function getHeaderText()
49
+ {
50
+ if (Mage::registry('api_user')->getId()) {
51
+ return Mage::helper('adminhtml')->__("Edit User '%s'", $this->htmlEscape(Mage::registry('api_user')->getUsername()));
52
+ }
53
+ else {
54
+ return Mage::helper('adminhtml')->__('New User');
55
+ }
56
+ }
57
+
58
+ }
app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Form.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml permissions user edit form
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Api_User_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+
37
+ protected function _prepareForm()
38
+ {
39
+ $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
40
+ $form->setUseContainer(true);
41
+ $this->setForm($form);
42
+ return parent::_prepareForm();
43
+ }
44
+
45
+ }
app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Cms page edit form main tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Api_User_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+
38
+ protected function _prepareForm()
39
+ {
40
+ $model = Mage::registry('api_user');
41
+
42
+ $form = new Varien_Data_Form();
43
+
44
+ $form->setHtmlIdPrefix('user_');
45
+
46
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Account Information')));
47
+
48
+ if ($model->getUserId()) {
49
+ $fieldset->addField('user_id', 'hidden', array(
50
+ 'name' => 'user_id',
51
+ ));
52
+ } else {
53
+ if (! $model->hasData('is_active')) {
54
+ $model->setIsActive(1);
55
+ }
56
+ }
57
+
58
+ $fieldset->addField('username', 'text', array(
59
+ 'name' => 'username',
60
+ 'label' => Mage::helper('adminhtml')->__('User Name'),
61
+ 'id' => 'username',
62
+ 'title' => Mage::helper('adminhtml')->__('User Name'),
63
+ 'required' => true,
64
+ ));
65
+
66
+ $fieldset->addField('firstname', 'text', array(
67
+ 'name' => 'firstname',
68
+ 'label' => Mage::helper('adminhtml')->__('First Name'),
69
+ 'id' => 'firstname',
70
+ 'title' => Mage::helper('adminhtml')->__('First Name'),
71
+ 'required' => true,
72
+ ));
73
+
74
+ $fieldset->addField('lastname', 'text', array(
75
+ 'name' => 'lastname',
76
+ 'label' => Mage::helper('adminhtml')->__('Last Name'),
77
+ 'id' => 'lastname',
78
+ 'title' => Mage::helper('adminhtml')->__('Last Name'),
79
+ 'required' => true,
80
+ ));
81
+
82
+ $fieldset->addField('email', 'text', array(
83
+ 'name' => 'email',
84
+ 'label' => Mage::helper('adminhtml')->__('Email'),
85
+ 'id' => 'customer_email',
86
+ 'title' => Mage::helper('adminhtml')->__('User Email'),
87
+ 'class' => 'required-entry validate-email',
88
+ 'required' => true,
89
+ ));
90
+
91
+ if ($model->getUserId()) {
92
+ $fieldset->addField('password', 'password', array(
93
+ 'name' => 'new_api_key',
94
+ 'label' => Mage::helper('adminhtml')->__('New API Key'),
95
+ 'id' => 'new_pass',
96
+ 'title' => Mage::helper('adminhtml')->__('New API Key'),
97
+ 'class' => 'input-text validate-password',
98
+ ));
99
+
100
+ $fieldset->addField('confirmation', 'password', array(
101
+ 'name' => 'api_key_confirmation',
102
+ 'label' => Mage::helper('adminhtml')->__('API Key Confirmation'),
103
+ 'id' => 'confirmation',
104
+ 'class' => 'input-text validate-cpassword',
105
+ ));
106
+ }
107
+ else {
108
+ $fieldset->addField('password', 'password', array(
109
+ 'name' => 'api_key',
110
+ 'label' => Mage::helper('adminhtml')->__('API Key'),
111
+ 'id' => 'customer_pass',
112
+ 'title' => Mage::helper('adminhtml')->__('API Key'),
113
+ 'class' => 'input-text required-entry validate-password',
114
+ 'required' => true,
115
+ ));
116
+ $fieldset->addField('confirmation', 'password', array(
117
+ 'name' => 'api_key_confirmation',
118
+ 'label' => Mage::helper('adminhtml')->__('API Key Confirmation'),
119
+ 'id' => 'confirmation',
120
+ 'title' => Mage::helper('adminhtml')->__('API Key Confirmation'),
121
+ 'class' => 'input-text required-entry validate-cpassword',
122
+ 'required' => true,
123
+ ));
124
+ }
125
+
126
+ if (Mage::getSingleton('admin/session')->getUser()->getId() != $model->getUserId()) {
127
+ $fieldset->addField('is_active', 'select', array(
128
+ 'name' => 'is_active',
129
+ 'label' => Mage::helper('adminhtml')->__('This account is'),
130
+ 'id' => 'is_active',
131
+ 'title' => Mage::helper('adminhtml')->__('Account status'),
132
+ 'class' => 'input-select',
133
+ 'style' => 'width: 80px',
134
+ 'options' => array('1' => Mage::helper('adminhtml')->__('Active'), '0' => Mage::helper('adminhtml')->__('Inactive')),
135
+ ));
136
+ }
137
+
138
+ $fieldset->addField('user_roles', 'hidden', array(
139
+ 'name' => 'user_roles',
140
+ 'id' => '_user_roles',
141
+ ));
142
+
143
+ $data = $model->getData();
144
+
145
+ unset($data['password']);
146
+
147
+ $form->setValues($data);
148
+
149
+ $this->setForm($form);
150
+
151
+ return parent::_prepareForm();
152
+ }
153
+ }
app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Api_User_Edit_Tab_Roles extends Mage_Adminhtml_Block_Widget_Grid
28
+ {
29
+
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setId('permissionsUserRolesGrid');
34
+ $this->setDefaultSort('sort_order');
35
+ $this->setDefaultDir('asc');
36
+ //$this->setDefaultFilter(array('assigned_user_role'=>1));
37
+ $this->setTitle(Mage::helper('adminhtml')->__('User Roles Information'));
38
+ $this->setUseAjax(true);
39
+ }
40
+
41
+ protected function _addColumnFilterToCollection($column)
42
+ {
43
+ if ($column->getId() == 'assigned_user_role') {
44
+ $userRoles = $this->_getSelectedRoles();
45
+ if (empty($userRoles)) {
46
+ $userRoles = 0;
47
+ }
48
+ if ($column->getFilter()->getValue()) {
49
+ $this->getCollection()->addFieldToFilter('role_id', array('in'=>$userRoles));
50
+ }
51
+ else {
52
+ if($userRoles) {
53
+ $this->getCollection()->addFieldToFilter('role_id', array('nin'=>$userRoles));
54
+ }
55
+ }
56
+ }
57
+ else {
58
+ parent::_addColumnFilterToCollection($column);
59
+ }
60
+ return $this;
61
+ }
62
+
63
+ protected function _prepareCollection()
64
+ {
65
+ $collection = Mage::getResourceModel('api/role_collection');
66
+ $collection->setRolesFilter();
67
+ $this->setCollection($collection);
68
+ return parent::_prepareCollection();
69
+ }
70
+
71
+ protected function _prepareColumns()
72
+ {
73
+
74
+ $this->addColumn('assigned_user_role', array(
75
+ 'header_css_class' => 'a-center',
76
+ 'header' => Mage::helper('adminhtml')->__('Assigned'),
77
+ 'type' => 'radio',
78
+ 'html_name' => 'roles[]',
79
+ 'values' => $this->_getSelectedRoles(),
80
+ 'align' => 'center',
81
+ 'index' => 'role_id'
82
+ ));
83
+
84
+ /*$this->addColumn('role_id', array(
85
+ 'header' =>Mage::helper('adminhtml')->__('Role ID'),
86
+ 'index' =>'role_id',
87
+ 'align' => 'right',
88
+ 'width' => '50px'
89
+ ));*/
90
+
91
+ $this->addColumn('role_name', array(
92
+ 'header' =>Mage::helper('adminhtml')->__('Role Name'),
93
+ 'index' =>'role_name'
94
+ ));
95
+
96
+ return parent::_prepareColumns();
97
+ }
98
+
99
+ public function getGridUrl()
100
+ {
101
+ return $this->getUrl('*/*/rolesGrid', array('user_id' => Mage::registry('api_user')->getUserId()));
102
+ }
103
+
104
+ protected function _getSelectedRoles($json=false)
105
+ {
106
+ if ( $this->getRequest()->getParam('user_roles') != "" ) {
107
+ return $this->getRequest()->getParam('user_roles');
108
+ }
109
+ $uRoles = Mage::registry('api_user')->getRoles();
110
+ if ($json) {
111
+ $jsonRoles = Array();
112
+ foreach($uRoles as $urid) $jsonRoles[$urid] = 0;
113
+ return Mage::helper('core')->jsonEncode((object)$jsonRoles);
114
+ } else {
115
+ return $uRoles;
116
+ }
117
+ }
118
+
119
+ }
app/code/core/Mage/Adminhtml/Block/Api/User/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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Admin page left menu
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Api_User_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('page_tabs');
41
+ $this->setDestElementId('edit_form');
42
+ $this->setTitle(Mage::helper('adminhtml')->__('User Information'));
43
+ }
44
+
45
+ protected function _beforeToHtml()
46
+ {
47
+ $this->addTab('main_section', array(
48
+ 'label' => Mage::helper('adminhtml')->__('User Info'),
49
+ 'title' => Mage::helper('adminhtml')->__('User Info'),
50
+ 'content' => $this->getLayout()->createBlock('adminhtml/api_user_edit_tab_main')->toHtml(),
51
+ 'active' => true
52
+ ));
53
+
54
+ $this->addTab('roles_section', array(
55
+ 'label' => Mage::helper('adminhtml')->__('User Role'),
56
+ 'title' => Mage::helper('adminhtml')->__('User Role'),
57
+ 'content' => $this->getLayout()->createBlock('adminhtml/api_user_edit_tab_roles', 'user.roles.grid')->toHtml(),
58
+ ));
59
+ return parent::_beforeToHtml();
60
+ }
61
+
62
+ }
app/code/core/Mage/Adminhtml/Block/Api/User/Grid.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml permissions user grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Api_User_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('permissionsUserGrid');
41
+ $this->setDefaultSort('username');
42
+ $this->setDefaultDir('asc');
43
+ $this->setUseAjax(true);
44
+ }
45
+
46
+ protected function _prepareCollection()
47
+ {
48
+ $collection = Mage::getResourceModel('api/user_collection');
49
+ $this->setCollection($collection);
50
+ return parent::_prepareCollection();
51
+ }
52
+
53
+ protected function _prepareColumns()
54
+ {
55
+ $this->addColumn('user_id', array(
56
+ 'header' => Mage::helper('adminhtml')->__('ID'),
57
+ 'width' => 5,
58
+ 'align' => 'right',
59
+ 'sortable' => true,
60
+ 'index' => 'user_id'
61
+ ));
62
+
63
+ $this->addColumn('username', array(
64
+ 'header' => Mage::helper('adminhtml')->__('User Name'),
65
+ 'index' => 'username'
66
+ ));
67
+
68
+ $this->addColumn('firstname', array(
69
+ 'header' => Mage::helper('adminhtml')->__('First Name'),
70
+ 'index' => 'firstname'
71
+ ));
72
+
73
+ $this->addColumn('lastname', array(
74
+ 'header' => Mage::helper('adminhtml')->__('Last Name'),
75
+ 'index' => 'lastname'
76
+ ));
77
+
78
+ $this->addColumn('email', array(
79
+ 'header' => Mage::helper('adminhtml')->__('Email'),
80
+ 'width' => 40,
81
+ 'align' => 'left',
82
+ 'index' => 'email'
83
+ ));
84
+
85
+ $this->addColumn('is_active', array(
86
+ 'header' => Mage::helper('adminhtml')->__('Status'),
87
+ 'index' => 'is_active',
88
+ 'type' => 'options',
89
+ 'options' => array('1' => Mage::helper('adminhtml')->__('Active'), '0' => Mage::helper('adminhtml')->__('Inactive')),
90
+ ));
91
+
92
+ return parent::_prepareColumns();
93
+ }
94
+
95
+ public function getRowUrl($row)
96
+ {
97
+ return $this->getUrl('*/*/edit', array('user_id' => $row->getId()));
98
+ }
99
+
100
+ public function getGridUrl()
101
+ {
102
+ //$uid = $this->getRequest()->getParam('user_id');
103
+ return $this->getUrl('*/*/roleGrid', array());
104
+ }
105
+
106
+ }
app/code/core/Mage/Adminhtml/Block/Api/Users.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * users block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Api_Users extends Mage_Adminhtml_Block_Template
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setTemplate('api/users.phtml');
41
+ }
42
+
43
+ public function getAddNewUrl()
44
+ {
45
+ return $this->getUrl('*/*/edituser');
46
+ }
47
+
48
+ public function getGridHtml()
49
+ {
50
+ return $this->getLayout()->createBlock('adminhtml/api_grid_user')->toHtml();
51
+ }
52
+
53
+ }
54
+
app/code/core/Mage/Adminhtml/Block/Backup.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml backup page content block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Backup extends Mage_Adminhtml_Block_Template
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setTemplate('backup/list.phtml');
41
+ }
42
+
43
+ protected function _prepareLayout()
44
+ {
45
+ parent::_prepareLayout();
46
+ $this->setChild('createButton',
47
+ $this->getLayout()->createBlock('adminhtml/widget_button')
48
+ ->setData(array(
49
+ 'label' => Mage::helper('backup')->__('Create Backup'),
50
+ 'onclick' => "window.location.href='" . $this->getUrl('*/*/create') . "'",
51
+ 'class' => 'task'
52
+ ))
53
+ );
54
+ $this->setChild('backupsGrid',
55
+ $this->getLayout()->createBlock('adminhtml/backup_grid')
56
+ );
57
+ }
58
+
59
+ public function getCreateButtonHtml()
60
+ {
61
+ return $this->getChildHtml('createButton');
62
+ }
63
+
64
+ public function getGridHtml()
65
+ {
66
+ return $this->getChildHtml('backupsGrid');
67
+ }
68
+ }
app/code/core/Mage/Adminhtml/Block/Backup/Grid.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml backups grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Backup_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ protected function _construct()
38
+ {
39
+ $this->setSaveParametersInSession(true);
40
+ $this->setId('backupsGrid');
41
+ $this->setDefaultSort('time', 'desc');
42
+ }
43
+
44
+ /**
45
+ * Init backups collection
46
+ */
47
+ protected function _prepareCollection()
48
+ {
49
+ $collection = Mage::getSingleton('backup/fs_collection');
50
+ $this->setCollection($collection);
51
+ return parent::_prepareCollection();
52
+ }
53
+
54
+ /**
55
+ * Configuration of grid
56
+ */
57
+ protected function _prepareColumns()
58
+ {
59
+ $url7zip = Mage::helper('adminhtml')->__('The archive can be uncompressed with <a href="%s">%s</a> on Windows systems', 'http://www.7-zip.org/', '7-Zip');
60
+
61
+ $this->addColumn('time', array(
62
+ 'header' => Mage::helper('backup')->__('Time'),
63
+ 'index' => 'date_object',
64
+ 'type' => 'datetime',
65
+ ));
66
+
67
+ $this->addColumn('size', array(
68
+ 'header' => Mage::helper('backup')->__('Size, Bytes'),
69
+ 'index' => 'size',
70
+ 'type' => 'number',
71
+ 'sortable' => false,
72
+ 'filter' => false
73
+ ));
74
+
75
+ $this->addColumn('type', array(
76
+ 'header' => Mage::helper('backup')->__('Type'),
77
+ 'type' => 'options',
78
+ 'options' => array('db' => Mage::helper('backup')->__('DB')),
79
+ 'index' =>'type'
80
+ ));
81
+
82
+ $this->addColumn('download', array(
83
+ 'header' => Mage::helper('backup')->__('Download'),
84
+ 'format' => '<a href="' . $this->getUrl('*/*/download', array('time' => '$time', 'type' => '$type')) .'">gz</a> &nbsp; <small>('.$url7zip.')</small>',
85
+ 'index' => 'type',
86
+ 'sortable' => false,
87
+ 'filter' => false
88
+ ));
89
+
90
+ $this->addColumn('action', array(
91
+ 'header' => Mage::helper('backup')->__('Action'),
92
+ 'type' => 'action',
93
+ 'width' => '80px',
94
+ 'filter' => false,
95
+ 'sortable' => false,
96
+ 'actions' => array(array(
97
+ 'url' => $this->getUrl('*/*/delete', array('time' => '$time', 'type' => '$type')),
98
+ 'caption' => Mage::helper('adminhtml')->__('Delete'),
99
+ 'confirm' => Mage::helper('adminhtml')->__('Are you sure you want to do this?')
100
+ )),
101
+ 'index' => 'type',
102
+ 'sortable' => false
103
+ ));
104
+
105
+ return $this;
106
+ }
107
+
108
+ }
app/code/core/Mage/Adminhtml/Block/Cache.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Cache extends Mage_Adminhtml_Block_Widget_Grid_Container
28
+ {
29
+ /**
30
+ * Class constructor
31
+ */
32
+ public function __construct()
33
+ {
34
+ $this->_controller = 'cache';
35
+ $this->_headerText = Mage::helper('core')->__('Cache Storage Management');
36
+ parent::__construct();
37
+ $this->_removeButton('add');
38
+ $this->_addButton('flush_magento', array(
39
+ 'label' => Mage::helper('core')->__('Flush Magento Cache'),
40
+ 'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() .'\')',
41
+ 'class' => 'delete',
42
+ ));
43
+
44
+ $message = Mage::helper('core')->__('Cache storage may contain additional data. Are you sure that you want flush it?');
45
+ $this->_addButton('flush_system', array(
46
+ 'label' => Mage::helper('core')->__('Flush Cache Storage'),
47
+ 'onclick' => 'confirmSetLocation(\''.$message.'\', \'' . $this->getFlushStorageUrl() .'\')',
48
+ 'class' => 'delete',
49
+ ));
50
+ }
51
+
52
+ /**
53
+ * Get url for clean cache storage
54
+ */
55
+ public function getFlushStorageUrl()
56
+ {
57
+ return $this->getUrl('*/*/flushAll');
58
+ }
59
+
60
+ /**
61
+ * Get url for clean cache storage
62
+ */
63
+ public function getFlushSystemUrl()
64
+ {
65
+ return $this->getUrl('*/*/flushSystem');
66
+ }
67
+ }
app/code/core/Mage/Adminhtml/Block/Cache/Additional.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Cache_Additional extends Mage_Adminhtml_Block_Template
28
+ {
29
+ public function getCleanImagesUrl()
30
+ {
31
+ return $this->getUrl('*/*/cleanImages');
32
+ }
33
+
34
+ public function getCleanMediaUrl()
35
+ {
36
+ return $this->getUrl('*/*/cleanMedia');
37
+ }
38
+ }
app/code/core/Mage/Adminhtml/Block/Cache/Grid.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Cache_Grid extends Mage_Adminhtml_Block_Widget_Grid
28
+ {
29
+ protected $_invalidatedTypes = array();
30
+ /**
31
+ * Class constructor
32
+ */
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+ $this->setId('cache_grid');
37
+ $this->_filterVisibility = false;
38
+ $this->_pagerVisibility = false;
39
+ $this->_invalidatedTypes = Mage::app()->getCacheInstance()->getInvalidatedTypes();
40
+ }
41
+
42
+ /**
43
+ * Prepare grid collection
44
+ */
45
+ protected function _prepareCollection()
46
+ {
47
+ $collection = new Varien_Data_Collection();
48
+ foreach (Mage::app()->getCacheInstance()->getTypes() as $type) {
49
+ $collection->addItem($type);
50
+ }
51
+ $this->setCollection($collection);
52
+ return parent::_prepareCollection();
53
+ }
54
+
55
+ /**
56
+ * Add name and description to collection elements
57
+ */
58
+ protected function _afterLoadCollection()
59
+ {
60
+ foreach ($this->_collection as $item) {
61
+ }
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Prepare grid columns
67
+ */
68
+ protected function _prepareColumns()
69
+ {
70
+ $baseUrl = $this->getUrl();
71
+ $this->addColumn('cache_type', array(
72
+ 'header' => $this->__('Cache Type'),
73
+ 'width' => '180',
74
+ 'align' => 'left',
75
+ 'index' => 'cache_type',
76
+ 'sortable' => false,
77
+ ));
78
+
79
+ $this->addColumn('description', array(
80
+ 'header' => $this->__('Description'),
81
+ 'align' => 'left',
82
+ 'index' => 'description',
83
+ 'sortable' => false,
84
+ ));
85
+
86
+ $this->addColumn('tags', array(
87
+ 'header' => $this->__('Associated Tags'),
88
+ 'align' => 'left',
89
+ 'index' => 'tags',
90
+ 'width' => '180',
91
+ 'sortable' => false,
92
+ ));
93
+
94
+ $this->addColumn('status', array(
95
+ 'header' => $this->__('Status'),
96
+ 'width' => '120',
97
+ 'align' => 'left',
98
+ 'index' => 'status',
99
+ 'type' => 'options',
100
+ 'options' => array(0 => $this->__('Disabled'), 1 => $this->__('Enabled')),
101
+ 'frame_callback' => array($this, 'decorateStatus')
102
+ ));
103
+
104
+ // $this->addColumn('action',
105
+ // array(
106
+ // 'header' => $this->__('Action'),
107
+ // 'width' => '100',
108
+ // 'type' => 'action',
109
+ // 'getter' => 'getId',
110
+ // 'actions' => array(
111
+ // array(
112
+ // 'caption' => $this->__('Refresh'),
113
+ // 'url' => array('base'=> '*/*/refresh'),
114
+ // 'field' => 'type'
115
+ // ),
116
+ // ),
117
+ // 'filter' => false,
118
+ // 'sortable' => false,
119
+ // 'is_system' => true,
120
+ // ));
121
+
122
+ return parent::_prepareColumns();
123
+ }
124
+
125
+ /**
126
+ * Decorate status column values
127
+ *
128
+ * @return string
129
+ */
130
+ public function decorateStatus($value, $row, $column, $isExport)
131
+ {
132
+ $class = '';
133
+ if (isset($this->_invalidatedTypes[$row->getId()])) {
134
+ $cell = '<span class="grid-severity-minor"><span>'.$this->__('Invalidated').'</span></span>';
135
+ } else {
136
+ if ($row->getStatus()) {
137
+ $cell = '<span class="grid-severity-notice"><span>'.$value.'</span></span>';
138
+ } else {
139
+ $cell = '<span class="grid-severity-critical"><span>'.$value.'</span></span>';
140
+ }
141
+ }
142
+ return $cell;
143
+ }
144
+
145
+ /**
146
+ * Get row edit url
147
+ *
148
+ * @return string
149
+ */
150
+ public function getRowUrl($row)
151
+ {
152
+ return false;
153
+ //return $this->getUrl('*/*/edit', array('type'=>$row->getId()));
154
+ }
155
+
156
+ /**
157
+ * Add mass-actions to grid
158
+ */
159
+ protected function _prepareMassaction()
160
+ {
161
+ $this->setMassactionIdField('id');
162
+ $this->getMassactionBlock()->setFormFieldName('types');
163
+
164
+ $modeOptions = Mage::getModel('index/process')->getModesOptions();
165
+
166
+ $this->getMassactionBlock()->addItem('enable', array(
167
+ 'label' => Mage::helper('index')->__('Enable'),
168
+ 'url' => $this->getUrl('*/*/massEnable'),
169
+ ));
170
+ $this->getMassactionBlock()->addItem('disable', array(
171
+ 'label' => Mage::helper('index')->__('Disable'),
172
+ 'url' => $this->getUrl('*/*/massDisable'),
173
+ ));
174
+ $this->getMassactionBlock()->addItem('refresh', array(
175
+ 'label' => Mage::helper('index')->__('Refresh'),
176
+ 'url' => $this->getUrl('*/*/massRefresh'),
177
+ 'selected' => true,
178
+ ));
179
+
180
+ return $this;
181
+ }
182
+ }
app/code/core/Mage/Adminhtml/Block/Cache/Notifications.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Cache_Notifications extends Mage_Adminhtml_Block_Template
28
+ {
29
+ /**
30
+ * Get array of cache types which require data refresh
31
+ *
32
+ * @return array
33
+ */
34
+ public function getCacheTypesForRefresh()
35
+ {
36
+ $invalidatedTypes = Mage::app()->getCacheInstance()->getInvalidatedTypes();
37
+ $res = array();
38
+ foreach ($invalidatedTypes as $type) {
39
+ $res[] = $type->getCacheType();
40
+ }
41
+ return $res;
42
+ }
43
+
44
+ /**
45
+ * Get index management url
46
+ *
47
+ * @return string
48
+ */
49
+ public function getManageUrl()
50
+ {
51
+ return $this->getUrl('adminhtml/cache');
52
+ }
53
+
54
+ /**
55
+ * ACL validation before html generation
56
+ *
57
+ * @return string
58
+ */
59
+ protected function _toHtml()
60
+ {
61
+ if (Mage::getSingleton('admin/session')->isAllowed('system/cache')) {
62
+ return parent::_toHtml();
63
+ }
64
+ return '';
65
+ }
66
+ }
app/code/core/Mage/Adminhtml/Block/Catalog.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers page content block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog extends Mage_Adminhtml_Block_Template
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setTemplate('catalog/index.phtml');
40
+ }
41
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Category abstract block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Category_Abstract extends Mage_Adminhtml_Block_Template
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ }
41
+
42
+ /**
43
+ * Retrieve current category instance
44
+ *
45
+ * @return Mage_Catalog_Model_Category
46
+ */
47
+ public function getCategory()
48
+ {
49
+ return Mage::registry('category');
50
+ }
51
+
52
+ public function getCategoryId()
53
+ {
54
+ if ($this->getCategory()) {
55
+ return $this->getCategory()->getId();
56
+ }
57
+ return Mage_Catalog_Model_Category::TREE_ROOT_ID;
58
+ }
59
+
60
+ public function getCategoryName()
61
+ {
62
+ return $this->getCategory()->getName();
63
+ }
64
+
65
+ public function getCategoryPath()
66
+ {
67
+ if ($this->getCategory()) {
68
+ return $this->getCategory()->getPath();
69
+ }
70
+ return Mage_Catalog_Model_Category::TREE_ROOT_ID;
71
+ }
72
+
73
+ public function hasStoreRootCategory()
74
+ {
75
+ $root = $this->getRoot();
76
+ if ($root && $root->getId()) {
77
+ return true;
78
+ }
79
+ return false;
80
+ }
81
+
82
+ public function getStore()
83
+ {
84
+ $storeId = (int) $this->getRequest()->getParam('store');
85
+ return Mage::app()->getStore($storeId);
86
+ }
87
+
88
+ public function getRoot($parentNodeCategory=null, $recursionLevel=3)
89
+ {
90
+ if (!is_null($parentNodeCategory) && $parentNodeCategory->getId()) {
91
+ return $this->getNode($parentNodeCategory, $recursionLevel);
92
+ }
93
+ $root = Mage::registry('root');
94
+ if (is_null($root)) {
95
+ $storeId = (int) $this->getRequest()->getParam('store');
96
+
97
+ if ($storeId) {
98
+ $store = Mage::app()->getStore($storeId);
99
+ $rootId = $store->getRootCategoryId();
100
+ }
101
+ else {
102
+ $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID;
103
+ }
104
+
105
+ $tree = Mage::getResourceSingleton('catalog/category_tree')
106
+ ->load(null, $recursionLevel);
107
+
108
+ if ($this->getCategory()) {
109
+ $tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId));
110
+ }
111
+
112
+ $tree->addCollectionData($this->getCategoryCollection());
113
+
114
+ $root = $tree->getNodeById($rootId);
115
+
116
+ if ($root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID) {
117
+ $root->setIsVisible(true);
118
+ }
119
+ elseif($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) {
120
+ $root->setName(Mage::helper('catalog')->__('Root'));
121
+ }
122
+
123
+ Mage::register('root', $root);
124
+ }
125
+
126
+ return $root;
127
+ }
128
+
129
+ /**
130
+ * Get and register categories root by specified categories IDs
131
+ *
132
+ * IDs can be arbitrary set of any categories ids.
133
+ * Tree with minimal required nodes (all parents and neighbours) will be built.
134
+ * If ids are empty, default tree with depth = 2 will be returned.
135
+ *
136
+ * @param array $ids
137
+ */
138
+ public function getRootByIds($ids)
139
+ {
140
+ $root = Mage::registry('root');
141
+ if (null === $root) {
142
+ $categoryTreeResource = Mage::getResourceSingleton('catalog/category_tree');
143
+ $ids = $categoryTreeResource->getExistingCategoryIdsBySpecifiedIds($ids);
144
+ $tree = $categoryTreeResource->loadByIds($ids);
145
+ $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID;
146
+ $root = $tree->getNodeById($rootId);
147
+ if ($root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID) {
148
+ $root->setIsVisible(true);
149
+ } else if($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) {
150
+ $root->setName(Mage::helper('catalog')->__('Root'));
151
+ }
152
+
153
+ $tree->addCollectionData($this->getCategoryCollection());
154
+ Mage::register('root', $root);
155
+ }
156
+ return $root;
157
+ }
158
+
159
+ public function getNode($parentNodeCategory, $recursionLevel=2)
160
+ {
161
+ $tree = Mage::getResourceModel('catalog/category_tree');
162
+
163
+ $nodeId = $parentNodeCategory->getId();
164
+ $parentId = $parentNodeCategory->getParentId();
165
+
166
+ $node = $tree->loadNode($nodeId);
167
+ $node->loadChildren($recursionLevel);
168
+
169
+ if ($node && $nodeId != Mage_Catalog_Model_Category::TREE_ROOT_ID) {
170
+ $node->setIsVisible(true);
171
+ } elseif($node && $node->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) {
172
+ $node->setName(Mage::helper('catalog')->__('Root'));
173
+ }
174
+
175
+ $tree->addCollectionData($this->getCategoryCollection());
176
+
177
+ return $node;
178
+ }
179
+
180
+ public function getSaveUrl(array $args = array())
181
+ {
182
+ $params = array('_current'=>true);
183
+ $params = array_merge($params, $args);
184
+ return $this->getUrl('*/*/save', $params);
185
+ }
186
+
187
+ public function getEditUrl()
188
+ {
189
+ return $this->getUrl("*/catalog_category/edit", array('_current'=>true, 'store'=>null, '_query'=>false, 'id'=>null, 'parent'=>null));
190
+ }
191
+
192
+ /**
193
+ * Return ids of root categories as array
194
+ *
195
+ * @return array
196
+ */
197
+ public function getRootIds()
198
+ {
199
+ $ids = $this->getData('root_ids');
200
+ if (is_null($ids)) {
201
+ $ids = array();
202
+ foreach (Mage::app()->getGroups() as $store) {
203
+ $ids[] = $store->getRootCategoryId();
204
+ }
205
+ $this->setData('root_ids', $ids);
206
+ }
207
+ return $ids;
208
+ }
209
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Checkboxes/Tree.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Categories tree with checkboxes
29
+ *
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+ class Mage_Adminhtml_Block_Catalog_Category_Checkboxes_Tree extends Mage_Adminhtml_Block_Catalog_Category_Tree
33
+ {
34
+ protected $_selectedIds = array();
35
+
36
+ protected function _prepareLayout()
37
+ {
38
+ $this->setTemplate('catalog/category/checkboxes/tree.phtml');
39
+ }
40
+
41
+ public function getCategoryIds()
42
+ {
43
+ return $this->_selectedIds;
44
+ }
45
+
46
+ public function setCategoryIds($ids)
47
+ {
48
+ if (empty($ids)) {
49
+ $ids = array();
50
+ }
51
+ elseif (!is_array($ids)) {
52
+ $ids = array((int)$ids);
53
+ }
54
+ $this->_selectedIds = $ids;
55
+ return $this;
56
+ }
57
+
58
+ protected function _getNodeJson($node, $level = 1)
59
+ {
60
+ $item = array();
61
+ $item['text']= $this->htmlEscape($node->getName());
62
+
63
+ if ($this->_withProductCount) {
64
+ $item['text'].= ' ('.$node->getProductCount().')';
65
+ }
66
+ $item['id'] = $node->getId();
67
+ $item['path'] = $node->getData('path');
68
+ $item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
69
+ $item['allowDrop'] = false;
70
+ $item['allowDrag'] = false;
71
+
72
+ if ($node->hasChildren()) {
73
+ $item['children'] = array();
74
+ foreach ($node->getChildren() as $child) {
75
+ $item['children'][] = $this->_getNodeJson($child, $level + 1);
76
+ }
77
+ }
78
+
79
+ if (empty($item['children']) && (int)$node->getChildrenCount() > 0) {
80
+ $item['children'] = array();
81
+ }
82
+
83
+ if (!empty($item['children'])) {
84
+ $item['expanded'] = true;
85
+ }
86
+
87
+ if (in_array($node->getId(), $this->getCategoryIds())) {
88
+ $item['checked'] = true;
89
+ }
90
+
91
+ return $item;
92
+ }
93
+
94
+ public function getRoot($parentNodeCategory=null, $recursionLevel=3)
95
+ {
96
+ return $this->getRootByIds($this->getCategoryIds());
97
+ }
98
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Category container block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Category_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
35
+ {
36
+ public function __construct()
37
+ {
38
+ $this->_objectId = 'entity_id';
39
+ $this->_controller = 'catalog_category';
40
+ $this->_mode = 'edit';
41
+
42
+ parent::__construct();
43
+ $this->setTemplate('catalog/category/edit.phtml');
44
+ }
45
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Category edit block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Category_Edit_Form extends Mage_Adminhtml_Block_Catalog_Category_Abstract
35
+ {
36
+ /**
37
+ * Additional buttons on category page
38
+ *
39
+ * @var array
40
+ */
41
+ protected $_additionalButtons = array();
42
+
43
+ public function __construct()
44
+ {
45
+ parent::__construct();
46
+ $this->setTemplate('catalog/category/edit/form.phtml');
47
+ }
48
+
49
+ protected function _prepareLayout()
50
+ {
51
+ $category = $this->getCategory();
52
+ $categoryId = (int) $category->getId(); // 0 when we create category, otherwise some value for editing category
53
+
54
+ $this->setChild('tabs',
55
+ $this->getLayout()->createBlock('adminhtml/catalog_category_tabs', 'tabs')
56
+ );
57
+
58
+ // Save button
59
+ if (!$category->isReadonly()) {
60
+ $this->setChild('save_button',
61
+ $this->getLayout()->createBlock('adminhtml/widget_button')
62
+ ->setData(array(
63
+ 'label' => Mage::helper('catalog')->__('Save Category'),
64
+ 'onclick' => "categorySubmit('" . $this->getSaveUrl() . "', true)",
65
+ 'class' => 'save'
66
+ ))
67
+ );
68
+ }
69
+
70
+ // Delete button
71
+ if (!in_array($categoryId, $this->getRootIds()) && $category->isDeleteable()) {
72
+ $this->setChild('delete_button',
73
+ $this->getLayout()->createBlock('adminhtml/widget_button')
74
+ ->setData(array(
75
+ 'label' => Mage::helper('catalog')->__('Delete Category'),
76
+ 'onclick' => "categoryDelete('" . $this->getUrl('*/*/delete', array('_current' => true)) . "', true, {$categoryId})",
77
+ 'class' => 'delete'
78
+ ))
79
+ );
80
+ }
81
+
82
+ // Reset button
83
+ if (!$category->isReadonly()) {
84
+ $resetPath = $categoryId ? '*/*/edit' : '*/*/add';
85
+ $this->setChild('reset_button',
86
+ $this->getLayout()->createBlock('adminhtml/widget_button')
87
+ ->setData(array(
88
+ 'label' => Mage::helper('catalog')->__('Reset'),
89
+ 'onclick' => "categoryReset('".$this->getUrl($resetPath, array('_current'=>true))."',true)"
90
+ ))
91
+ );
92
+ }
93
+
94
+ return parent::_prepareLayout();
95
+ }
96
+
97
+ public function getStoreConfigurationUrl()
98
+ {
99
+ $storeId = (int) $this->getRequest()->getParam('store');
100
+ $params = array();
101
+ // $params = array('section'=>'catalog');
102
+ if ($storeId) {
103
+ $store = Mage::app()->getStore($storeId);
104
+ $params['website'] = $store->getWebsite()->getCode();
105
+ $params['store'] = $store->getCode();
106
+ }
107
+ return $this->getUrl('*/system_store', $params);
108
+ }
109
+
110
+ public function getDeleteButtonHtml()
111
+ {
112
+ return $this->getChildHtml('delete_button');
113
+ }
114
+
115
+ public function getSaveButtonHtml()
116
+ {
117
+ if ($this->hasStoreRootCategory()) {
118
+ return $this->getChildHtml('save_button');
119
+ }
120
+ return '';
121
+ }
122
+
123
+ public function getResetButtonHtml()
124
+ {
125
+ if ($this->hasStoreRootCategory()) {
126
+ return $this->getChildHtml('reset_button');
127
+ }
128
+ return '';
129
+ }
130
+
131
+ /**
132
+ * Retrieve additional buttons html
133
+ *
134
+ * @return string
135
+ */
136
+ public function getAdditionalButtonsHtml()
137
+ {
138
+ $html = '';
139
+ foreach ($this->_additionalButtons as $childName) {
140
+ $html .= $this->getChildHtml($childName);
141
+ }
142
+ return $html;
143
+ }
144
+
145
+ /**
146
+ * Add additional button
147
+ *
148
+ * @param string $alias
149
+ * @param array $config
150
+ * @return Mage_Adminhtml_Block_Catalog_Category_Edit_Form
151
+ */
152
+ public function addAdditionalButton($alias, $config)
153
+ {
154
+ if (isset($config['name'])) {
155
+ $config['element_name'] = $config['name'];
156
+ }
157
+ $this->setChild($alias . '_button',
158
+ $this->getLayout()->createBlock('adminhtml/widget_button')->addData($config));
159
+ $this->_additionalButtons[$alias] = $alias . '_button';
160
+ return $this;
161
+ }
162
+
163
+ /**
164
+ * Remove additional button
165
+ *
166
+ * @param string $alias
167
+ * @return Mage_Adminhtml_Block_Catalog_Category_Edit_Form
168
+ */
169
+ public function removeAdditionalButton($alias)
170
+ {
171
+ if (isset($this->_additionalButtons[$alias])) {
172
+ $this->unsetChild($this->_additionalButtons[$alias]);
173
+ unset($this->_additionalButtons[$alias]);
174
+ }
175
+
176
+ return $this;
177
+ }
178
+
179
+ public function getTabsHtml()
180
+ {
181
+ return $this->getChildHtml('tabs');
182
+ }
183
+
184
+ public function getHeader()
185
+ {
186
+ if ($this->hasStoreRootCategory()) {
187
+ if ($this->getCategoryId()) {
188
+ return $this->getCategoryName();
189
+ } else {
190
+ $parentId = (int) $this->getRequest()->getParam('parent');
191
+ if ($parentId && ($parentId != Mage_Catalog_Model_Category::TREE_ROOT_ID)) {
192
+ return Mage::helper('catalog')->__('New Subcategory');
193
+ } else {
194
+ return Mage::helper('catalog')->__('New Root Category');
195
+ }
196
+ }
197
+ }
198
+ return Mage::helper('catalog')->__('Set Root Category for Store');
199
+ }
200
+
201
+ public function getDeleteUrl(array $args = array())
202
+ {
203
+ $params = array('_current'=>true);
204
+ $params = array_merge($params, $args);
205
+ return $this->getUrl('*/*/delete', $params);
206
+ }
207
+
208
+ /**
209
+ * Return URL for refresh input element 'path' in form
210
+ *
211
+ * @param array $args
212
+ * @return string
213
+ */
214
+ public function getRefreshPathUrl(array $args = array())
215
+ {
216
+ $params = array('_current'=>true);
217
+ $params = array_merge($params, $args);
218
+ return $this->getUrl('*/*/refreshPath', $params);
219
+ }
220
+
221
+ public function getProductsJson()
222
+ {
223
+ $products = $this->getCategory()->getProductsPosition();
224
+ if (!empty($products)) {
225
+ return Mage::helper('core')->jsonEncode($products);
226
+ }
227
+ return '{}';
228
+ }
229
+
230
+ public function isAjax()
231
+ {
232
+ return Mage::app()->getRequest()->isXmlHttpRequest() || Mage::app()->getRequest()->getParam('isAjax');
233
+ }
234
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Image.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Category form image field helper
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Category_Helper_Image extends Varien_Data_Form_Element_Image
35
+ {
36
+ protected function _getUrl()
37
+ {
38
+ $url = false;
39
+ if ($this->getValue()) {
40
+ $url = Mage::getBaseUrl('media').'catalog/category/'. $this->getValue();
41
+ }
42
+ return $url;
43
+ }
44
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Pricestep.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml additional helper block for sort by
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Category_Helper_Pricestep extends Varien_Data_Form_Element_Text
36
+ {
37
+ /**
38
+ * Retrieve Element HTML fragment
39
+ *
40
+ * @return string
41
+ */
42
+ public function getElementHtml()
43
+ {
44
+ $disabled = false;
45
+ if (!$this->getValue()) {
46
+ $this->setData('disabled', 'disabled');
47
+ $disabled = true;
48
+ }
49
+ $html = parent::getElementHtml();
50
+ $htmlId = 'use_config_' . $this->getHtmlId();
51
+ $html .= '<br/><input id="'.$htmlId.'" name="use_config[]" value="' . $this->getId() . '"';
52
+ $html .= ($disabled ? ' checked="checked"' : '');
53
+ if ($this->getReadonly()) {
54
+ $html .= ' disabled="disabled"';
55
+ }
56
+ $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />';
57
+
58
+ $html .= ' <label for="'.$htmlId.'" class="normal">'
59
+ . Mage::helper('adminhtml')->__('Use Config Settings').'</label>';
60
+ $html .= '<script type="text/javascript">toggleValueElements($(\''.$htmlId.'\'), $(\''.$htmlId.'\').parentNode);</script>';
61
+
62
+ return $html;
63
+ }
64
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Available.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml additional helper block for sort by
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Category_Helper_Sortby_Available
36
+ extends Varien_Data_Form_Element_Multiselect
37
+ {
38
+ /**
39
+ * Retrieve Element HTML fragment
40
+ *
41
+ * @return string
42
+ */
43
+ public function getElementHtml()
44
+ {
45
+ $disabled = false;
46
+ if (!$this->getValue()) {
47
+ $this->setData('disabled', 'disabled');
48
+ $disabled = true;
49
+ }
50
+ $html = parent::getElementHtml();
51
+ $htmlId = 'use_config_' . $this->getHtmlId();
52
+ $html .= '<input id="'.$htmlId.'" name="use_config[]" value="' . $this->getId() . '"';
53
+ $html .= ($disabled ? ' checked="checked"' : '');
54
+
55
+ if ($this->getReadonly()) {
56
+ $html .= ' disabled="disabled"';
57
+ }
58
+
59
+ $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />';
60
+
61
+ $html .= ' <label for="'.$htmlId.'" class="normal">'
62
+ . Mage::helper('adminhtml')->__('Use All Available Attributes').'</label>';
63
+ $html .= '<script type="text/javascript">toggleValueElements($(\''.$htmlId.'\'), $(\''.$htmlId.'\').parentNode);</script>';
64
+
65
+ return $html;
66
+ }
67
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Helper/Sortby/Default.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml additional helper block for sort by
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Category_Helper_Sortby_Default
36
+ extends Varien_Data_Form_Element_Select
37
+ {
38
+ /**
39
+ * Retrieve Element HTML fragment
40
+ *
41
+ * @return string
42
+ */
43
+ public function getElementHtml()
44
+ {
45
+ $disabled = false;
46
+ if (!$this->getValue()) {
47
+ $this->setData('disabled', 'disabled');
48
+ $disabled = true;
49
+ }
50
+ $html = parent::getElementHtml();
51
+ $htmlId = 'use_config_' . $this->getHtmlId();
52
+ $html .= '<input id="'.$htmlId.'" name="use_config[]" value="' . $this->getId() . '"';
53
+ $html .= ($disabled ? ' checked="checked"' : '');
54
+ if ($this->getReadonly()) {
55
+ $html .= ' disabled="disabled"';
56
+ }
57
+ $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />';
58
+
59
+
60
+
61
+ $html .= ' <label for="'.$htmlId.'" class="normal">'
62
+ . Mage::helper('adminhtml')->__('Use Config Settings').'</label>';
63
+ $html .= '<script type="text/javascript">toggleValueElements($(\''.$htmlId.'\'), $(\''.$htmlId.'\').parentNode);</script>';
64
+
65
+ return $html;
66
+ }
67
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml Catalog Category Attributes per Group Tab block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes extends Mage_Adminhtml_Block_Catalog_Form
36
+ {
37
+ /**
38
+ * Retrieve Category object
39
+ *
40
+ * @return Mage_Catalog_Model_Category
41
+ */
42
+ public function getCategory()
43
+ {
44
+ return Mage::registry('current_category');
45
+ }
46
+
47
+ /**
48
+ * Initialize tab
49
+ *
50
+ */
51
+ public function __construct() {
52
+ parent::__construct();
53
+ $this->setShowGlobalIcon(true);
54
+ }
55
+
56
+ /**
57
+ * Load Wysiwyg on demand and Prepare layout
58
+ */
59
+ protected function _prepareLayout()
60
+ {
61
+ parent::_prepareLayout();
62
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
63
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Prepare form before rendering HTML
69
+ *
70
+ * @return Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes
71
+ */
72
+ protected function _prepareForm() {
73
+ $group = $this->getGroup();
74
+ $attributes = $this->getAttributes();
75
+
76
+ $form = new Varien_Data_Form();
77
+ $form->setHtmlIdPrefix('group_' . $group->getId());
78
+ $form->setDataObject($this->getCategory());
79
+
80
+ $fieldset = $form->addFieldset('fieldset_group_' . $group->getId(), array(
81
+ 'legend' => Mage::helper('catalog')->__($group->getAttributeGroupName()),
82
+ 'class' => 'fieldset-wide',
83
+ ));
84
+
85
+ if ($this->getAddHiddenFields()) {
86
+ if (!$this->getCategory()->getId()) {
87
+ // path
88
+ if ($this->getRequest()->getParam('parent')) {
89
+ $fieldset->addField('path', 'hidden', array(
90
+ 'name' => 'path',
91
+ 'value' => $this->getRequest()->getParam('parent')
92
+ ));
93
+ }
94
+ else {
95
+ $fieldset->addField('path', 'hidden', array(
96
+ 'name' => 'path',
97
+ 'value' => 1
98
+ ));
99
+ }
100
+ }
101
+ else {
102
+ $fieldset->addField('id', 'hidden', array(
103
+ 'name' => 'id',
104
+ 'value' => $this->getCategory()->getId()
105
+ ));
106
+ $fieldset->addField('path', 'hidden', array(
107
+ 'name' => 'path',
108
+ 'value' => $this->getCategory()->getPath()
109
+ ));
110
+ }
111
+ }
112
+
113
+ $this->_setFieldset($attributes, $fieldset);
114
+
115
+ foreach ($attributes as $attribute) {
116
+ /* @var $attribute Mage_Eav_Model_Entity_Attribute */
117
+ if ($attribute->getAttributeCode() == 'url_key') {
118
+ if ($this->getCategory()->getLevel() == 1) {
119
+ $fieldset->removeField('url_key');
120
+ $fieldset->addField('url_key', 'hidden', array(
121
+ 'name' => 'url_key',
122
+ 'value' => $this->getCategory()->getUrlKey()
123
+ ));
124
+ } else {
125
+ $form->getElement('url_key')->setRenderer(
126
+ $this->getLayout()->createBlock('adminhtml/catalog_form_renderer_attribute_urlkey')
127
+ );
128
+ }
129
+ }
130
+ }
131
+
132
+ if ($this->getCategory()->getLevel() == 1) {
133
+ $fieldset->removeField('custom_use_parent_settings');
134
+ } else {
135
+ if ($this->getCategory()->getCustomUseParentSettings()) {
136
+ foreach ($this->getCategory()->getDesignAttributes() as $attribute) {
137
+ if ($element = $form->getElement($attribute->getAttributeCode())) {
138
+ $element->setDisabled(true);
139
+ }
140
+ }
141
+ }
142
+ if ($element = $form->getElement('custom_use_parent_settings')) {
143
+ $element->setData('onchange', 'onCustomUseParentChanged(this)');
144
+ }
145
+ }
146
+
147
+ if ($this->getCategory()->hasLockedAttributes()) {
148
+ foreach ($this->getCategory()->getLockedAttributes() as $attribute) {
149
+ if ($element = $form->getElement($attribute)) {
150
+ $element->setReadonly(true, true);
151
+ }
152
+ }
153
+ }
154
+
155
+ if (!$this->getCategory()->getId()){
156
+ $this->getCategory()->setIncludeInMenu(1);
157
+ }
158
+
159
+ $form->addValues($this->getCategory()->getData());
160
+
161
+ $form->setFieldNameSuffix('general');
162
+ $this->setForm($form);
163
+
164
+ return parent::_prepareForm();
165
+ }
166
+
167
+ /**
168
+ * Retrieve Additional Element Types
169
+ *
170
+ * @return array
171
+ */
172
+ protected function _getAdditionalElementTypes()
173
+ {
174
+ return array(
175
+ 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_category_helper_image'),
176
+ 'textarea' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_helper_form_wysiwyg')
177
+ );
178
+ }
179
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Design.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Mage_Adminhtml_Block_Catalog_Category_Tab_Design extends Mage_Adminhtml_Block_Catalog_Form
27
+ {
28
+ public function __construct()
29
+ {
30
+ parent::__construct();
31
+ $this->setShowGlobalIcon(true);
32
+ }
33
+
34
+ public function getCategory()
35
+ {
36
+ if (!$this->_category) {
37
+ $this->_category = Mage::registry('category');
38
+ }
39
+ return $this->_category;
40
+ }
41
+
42
+ public function _prepareLayout()
43
+ {
44
+ parent::_prepareLayout();
45
+ $form = new Varien_Data_Form();
46
+ $form->setDataObject($this->getCategory());
47
+
48
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('catalog')->__('Custom Design')));
49
+
50
+
51
+ $this->_setFieldset($this->getCategory()->getDesignAttributes(), $fieldset);
52
+
53
+ $form->addValues($this->getCategory()->getData());
54
+ $form->setFieldNameSuffix('general');
55
+ $this->setForm($form);
56
+ }
57
+
58
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/General.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Category edit general tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Category_Tab_General extends Mage_Adminhtml_Block_Catalog_Form
35
+ {
36
+
37
+ protected $_category;
38
+
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setShowGlobalIcon(true);
43
+ }
44
+
45
+ public function getCategory()
46
+ {
47
+ if (!$this->_category) {
48
+ $this->_category = Mage::registry('category');
49
+ }
50
+ return $this->_category;
51
+ }
52
+
53
+ public function _prepareLayout()
54
+ {
55
+ parent::_prepareLayout();
56
+ $form = new Varien_Data_Form();
57
+ $form->setHtmlIdPrefix('_general');
58
+ $form->setDataObject($this->getCategory());
59
+
60
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('catalog')->__('General Information')));
61
+
62
+ if (!$this->getCategory()->getId()) {
63
+ // $fieldset->addField('path', 'select', array(
64
+ // 'name' => 'path',
65
+ // 'label' => Mage::helper('catalog')->__('Parent Category'),
66
+ // 'value' => base64_decode($this->getRequest()->getParam('parent')),
67
+ // 'values'=> $this->_getParentCategoryOptions(),
68
+ // //'required' => true,
69
+ // //'class' => 'required-entry'
70
+ // ),
71
+ // 'name'
72
+ // );
73
+ $parentId = $this->getRequest()->getParam('parent');
74
+ if (!$parentId) {
75
+ $parentId = Mage_Catalog_Model_Category::TREE_ROOT_ID;
76
+ }
77
+ $fieldset->addField('path', 'hidden', array(
78
+ 'name' => 'path',
79
+ 'value' => $parentId
80
+ ));
81
+ } else {
82
+ $fieldset->addField('id', 'hidden', array(
83
+ 'name' => 'id',
84
+ 'value' => $this->getCategory()->getId()
85
+ ));
86
+ $fieldset->addField('path', 'hidden', array(
87
+ 'name' => 'path',
88
+ 'value' => $this->getCategory()->getPath()
89
+ ));
90
+ }
91
+
92
+ $this->_setFieldset($this->getCategory()->getAttributes(true), $fieldset);
93
+
94
+ if ($this->getCategory()->getId()) {
95
+ if ($this->getCategory()->getLevel() == 1) {
96
+ $fieldset->removeField('url_key');
97
+ $fieldset->addField('url_key', 'hidden', array(
98
+ 'name' => 'url_key',
99
+ 'value' => $this->getCategory()->getUrlKey()
100
+ ));
101
+ }
102
+ }
103
+
104
+ $form->addValues($this->getCategory()->getData());
105
+
106
+ $form->setFieldNameSuffix('general');
107
+ $this->setForm($form);
108
+ }
109
+
110
+ protected function _getAdditionalElementTypes()
111
+ {
112
+ return array(
113
+ 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_category_helper_image')
114
+ );
115
+ }
116
+
117
+ protected function _getParentCategoryOptions($node=null, &$options=array())
118
+ {
119
+ if (is_null($node)) {
120
+ $node = $this->getRoot();
121
+ }
122
+
123
+ if ($node) {
124
+ $options[] = array(
125
+ 'value' => $node->getPathId(),
126
+ 'label' => str_repeat('&nbsp;', max(0, 3*($node->getLevel()))) . $this->htmlEscape($node->getName()),
127
+ );
128
+
129
+ foreach ($node->getChildren() as $child) {
130
+ $this->_getParentCategoryOptions($child, $options);
131
+ }
132
+ }
133
+ return $options;
134
+ }
135
+
136
+ }
137
+
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product in category grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Category_Tab_Product extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('catalog_category_products');
41
+ $this->setDefaultSort('entity_id');
42
+ $this->setUseAjax(true);
43
+ }
44
+
45
+ public function getCategory()
46
+ {
47
+ return Mage::registry('category');
48
+ }
49
+
50
+ protected function _addColumnFilterToCollection($column)
51
+ {
52
+ // Set custom filter for in category flag
53
+ if ($column->getId() == 'in_category') {
54
+ $productIds = $this->_getSelectedProducts();
55
+ if (empty($productIds)) {
56
+ $productIds = 0;
57
+ }
58
+ if ($column->getFilter()->getValue()) {
59
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
60
+ }
61
+ elseif(!empty($productIds)) {
62
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
63
+ }
64
+ }
65
+ else {
66
+ parent::_addColumnFilterToCollection($column);
67
+ }
68
+ return $this;
69
+ }
70
+
71
+ protected function _prepareCollection()
72
+ {
73
+ if ($this->getCategory()->getId()) {
74
+ $this->setDefaultFilter(array('in_category'=>1));
75
+ }
76
+ $collection = Mage::getModel('catalog/product')->getCollection()
77
+ ->addAttributeToSelect('name')
78
+ ->addAttributeToSelect('sku')
79
+ ->addAttributeToSelect('price')
80
+ ->addStoreFilter($this->getRequest()->getParam('store'))
81
+ ->joinField('position',
82
+ 'catalog/category_product',
83
+ 'position',
84
+ 'product_id=entity_id',
85
+ 'category_id='.(int) $this->getRequest()->getParam('id', 0),
86
+ 'left');
87
+ $this->setCollection($collection);
88
+
89
+ if ($this->getCategory()->getProductsReadonly()) {
90
+ $productIds = $this->_getSelectedProducts();
91
+ if (empty($productIds)) {
92
+ $productIds = 0;
93
+ }
94
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
95
+ }
96
+
97
+ return parent::_prepareCollection();
98
+ }
99
+
100
+ protected function _prepareColumns()
101
+ {
102
+ if (!$this->getCategory()->getProductsReadonly()) {
103
+ $this->addColumn('in_category', array(
104
+ 'header_css_class' => 'a-center',
105
+ 'type' => 'checkbox',
106
+ 'name' => 'in_category',
107
+ 'values' => $this->_getSelectedProducts(),
108
+ 'align' => 'center',
109
+ 'index' => 'entity_id'
110
+ ));
111
+ }
112
+ $this->addColumn('entity_id', array(
113
+ 'header' => Mage::helper('catalog')->__('ID'),
114
+ 'sortable' => true,
115
+ 'width' => '60',
116
+ 'index' => 'entity_id'
117
+ ));
118
+ $this->addColumn('name', array(
119
+ 'header' => Mage::helper('catalog')->__('Name'),
120
+ 'index' => 'name'
121
+ ));
122
+ $this->addColumn('sku', array(
123
+ 'header' => Mage::helper('catalog')->__('SKU'),
124
+ 'width' => '80',
125
+ 'index' => 'sku'
126
+ ));
127
+ $this->addColumn('price', array(
128
+ 'header' => Mage::helper('catalog')->__('Price'),
129
+ 'type' => 'currency',
130
+ 'width' => '1',
131
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
132
+ 'index' => 'price'
133
+ ));
134
+ $this->addColumn('position', array(
135
+ 'header' => Mage::helper('catalog')->__('Position'),
136
+ 'width' => '1',
137
+ 'type' => 'number',
138
+ 'index' => 'position',
139
+ 'editable' => !$this->getCategory()->getProductsReadonly()
140
+ //'renderer' => 'adminhtml/widget_grid_column_renderer_input'
141
+ ));
142
+
143
+ return parent::_prepareColumns();
144
+ }
145
+
146
+ public function getGridUrl()
147
+ {
148
+ return $this->getUrl('*/*/grid', array('_current'=>true));
149
+ }
150
+
151
+ protected function _getSelectedProducts()
152
+ {
153
+ $products = $this->getRequest()->getPost('selected_products');
154
+ if (is_null($products)) {
155
+ $products = $this->getCategory()->getProductsPosition();
156
+ return array_keys($products);
157
+ }
158
+ return $products;
159
+ }
160
+
161
+ }
162
+
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tabs.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Category tabs
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Category_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35
+ {
36
+ /**
37
+ * Default Attribute Tab Block
38
+ *
39
+ * @var string
40
+ */
41
+ protected $_attributeTabBlock = 'adminhtml/catalog_category_tab_attributes';
42
+
43
+ /**
44
+ * Initialize Tabs
45
+ *
46
+ */
47
+ public function __construct()
48
+ {
49
+ parent::__construct();
50
+ $this->setId('category_info_tabs');
51
+ $this->setDestElementId('category_tab_content');
52
+ $this->setTitle(Mage::helper('catalog')->__('Category Data'));
53
+ $this->setTemplate('widget/tabshoriz.phtml');
54
+ }
55
+
56
+ /**
57
+ * Retrieve cattegory object
58
+ *
59
+ * @return Mage_Catalog_Model_Category
60
+ */
61
+ public function getCategory()
62
+ {
63
+ return Mage::registry('current_category');
64
+ }
65
+
66
+ /**
67
+ * Return Adminhtml Catalog Helper
68
+ *
69
+ * @return Mage_Adminhtml_Helper_Catalog
70
+ */
71
+ public function getCatalogHelper()
72
+ {
73
+ return Mage::helper('adminhtml/catalog');
74
+ }
75
+
76
+ /**
77
+ * Getting attribute block name for tabs
78
+ *
79
+ * @return string
80
+ */
81
+ public function getAttributeTabBlock()
82
+ {
83
+ if ($block = $this->getCatalogHelper()->getCategoryAttributeTabBlock()) {
84
+ return $block;
85
+ }
86
+ return $this->_attributeTabBlock;
87
+ }
88
+
89
+ /**
90
+ * Prepare Layout Content
91
+ *
92
+ * @return Mage_Adminhtml_Block_Catalog_Category_Tabs
93
+ */
94
+ protected function _prepareLayout()
95
+ {
96
+ $categoryAttributes = $this->getCategory()->getAttributes();
97
+ if (!$this->getCategory()->getId()) {
98
+ foreach ($categoryAttributes as $attribute) {
99
+ $default = $attribute->getDefaultValue();
100
+ if ($default != '') {
101
+ $this->getCategory()->setData($attribute->getAttributeCode(), $default);
102
+ }
103
+ }
104
+ }
105
+
106
+ $attributeSetId = $this->getCategory()->getDefaultAttributeSetId();
107
+ /** @var $groupCollection Mage_Eav_Model_Resource_Entity_Attribute_Group_Collection */
108
+ $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
109
+ ->setAttributeSetFilter($attributeSetId)
110
+ ->setSortOrder()
111
+ ->load();
112
+ $defaultGroupId = 0;
113
+ foreach ($groupCollection as $group) {
114
+ /* @var $group Mage_Eav_Model_Entity_Attribute_Group */
115
+ if ($defaultGroupId == 0 or $group->getIsDefault()) {
116
+ $defaultGroupId = $group->getId();
117
+ }
118
+ }
119
+
120
+ foreach ($groupCollection as $group) {
121
+ /* @var $group Mage_Eav_Model_Entity_Attribute_Group */
122
+ $attributes = array();
123
+ foreach ($categoryAttributes as $attribute) {
124
+ /* @var $attribute Mage_Eav_Model_Entity_Attribute */
125
+ if ($attribute->isInGroup($attributeSetId, $group->getId())) {
126
+ $attributes[] = $attribute;
127
+ }
128
+ }
129
+
130
+ // do not add grops without attributes
131
+ if (!$attributes) {
132
+ continue;
133
+ }
134
+
135
+ $active = $defaultGroupId == $group->getId();
136
+ $block = $this->getLayout()->createBlock($this->getAttributeTabBlock(), '')
137
+ ->setGroup($group)
138
+ ->setAttributes($attributes)
139
+ ->setAddHiddenFields($active)
140
+ ->toHtml();
141
+ $this->addTab('group_' . $group->getId(), array(
142
+ 'label' => Mage::helper('catalog')->__($group->getAttributeGroupName()),
143
+ 'content' => $block,
144
+ 'active' => $active
145
+ ));
146
+ }
147
+
148
+ $this->addTab('products', array(
149
+ 'label' => Mage::helper('catalog')->__('Category Products'),
150
+ 'content' => $this->getLayout()->createBlock(
151
+ 'adminhtml/catalog_category_tab_product',
152
+ 'category.product.grid'
153
+ )->toHtml(),
154
+ ));
155
+
156
+ // dispatch event add custom tabs
157
+ Mage::dispatchEvent('adminhtml_catalog_category_tabs', array(
158
+ 'tabs' => $this
159
+ ));
160
+
161
+ /*$this->addTab('features', array(
162
+ 'label' => Mage::helper('catalog')->__('Feature Products'),
163
+ 'content' => 'Feature Products'
164
+ )); */
165
+ return parent::_prepareLayout();
166
+ }
167
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Categories tree block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Category_Tree extends Mage_Adminhtml_Block_Catalog_Category_Abstract
36
+ {
37
+
38
+ protected $_withProductCount;
39
+
40
+ public function __construct()
41
+ {
42
+ parent::__construct();
43
+ $this->setTemplate('catalog/category/tree.phtml');
44
+ $this->setUseAjax(true);
45
+ $this->_withProductCount = true;
46
+ }
47
+
48
+ protected function _prepareLayout()
49
+ {
50
+ $addUrl = $this->getUrl("*/*/add", array(
51
+ '_current'=>true,
52
+ 'id'=>null,
53
+ '_query' => false
54
+ ));
55
+
56
+ $this->setChild('add_sub_button',
57
+ $this->getLayout()->createBlock('adminhtml/widget_button')
58
+ ->setData(array(
59
+ 'label' => Mage::helper('catalog')->__('Add Subcategory'),
60
+ 'onclick' => "addNew('".$addUrl."', false)",
61
+ 'class' => 'add',
62
+ 'id' => 'add_subcategory_button',
63
+ 'style' => $this->canAddSubCategory() ? '' : 'display: none;'
64
+ ))
65
+ );
66
+
67
+ if ($this->canAddRootCategory()) {
68
+ $this->setChild('add_root_button',
69
+ $this->getLayout()->createBlock('adminhtml/widget_button')
70
+ ->setData(array(
71
+ 'label' => Mage::helper('catalog')->__('Add Root Category'),
72
+ 'onclick' => "addNew('".$addUrl."', true)",
73
+ 'class' => 'add',
74
+ 'id' => 'add_root_category_button'
75
+ ))
76
+ );
77
+ }
78
+
79
+ $this->setChild('store_switcher',
80
+ $this->getLayout()->createBlock('adminhtml/store_switcher')
81
+ ->setSwitchUrl($this->getUrl('*/*/*', array('_current'=>true, '_query'=>false, 'store'=>null)))
82
+ ->setTemplate('store/switcher/enhanced.phtml')
83
+ );
84
+ return parent::_prepareLayout();
85
+ }
86
+
87
+ protected function _getDefaultStoreId()
88
+ {
89
+ return Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
90
+ }
91
+
92
+ public function getCategoryCollection()
93
+ {
94
+ $storeId = $this->getRequest()->getParam('store', $this->_getDefaultStoreId());
95
+ $collection = $this->getData('category_collection');
96
+ if (is_null($collection)) {
97
+ $collection = Mage::getModel('catalog/category')->getCollection();
98
+
99
+ /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
100
+ $collection->addAttributeToSelect('name')
101
+ ->addAttributeToSelect('is_active')
102
+ ->setProductStoreId($storeId)
103
+ ->setLoadProductCount($this->_withProductCount)
104
+ ->setStoreId($storeId);
105
+
106
+ $this->setData('category_collection', $collection);
107
+ }
108
+ return $collection;
109
+ }
110
+
111
+ public function getAddRootButtonHtml()
112
+ {
113
+ return $this->getChildHtml('add_root_button');
114
+ }
115
+
116
+ public function getAddSubButtonHtml()
117
+ {
118
+ return $this->getChildHtml('add_sub_button');
119
+ }
120
+
121
+ public function getExpandButtonHtml()
122
+ {
123
+ return $this->getChildHtml('expand_button');
124
+ }
125
+
126
+ public function getCollapseButtonHtml()
127
+ {
128
+ return $this->getChildHtml('collapse_button');
129
+ }
130
+
131
+ public function getStoreSwitcherHtml()
132
+ {
133
+ return $this->getChildHtml('store_switcher');
134
+ }
135
+
136
+ public function getLoadTreeUrl($expanded=null)
137
+ {
138
+ $params = array('_current'=>true, 'id'=>null,'store'=>null);
139
+ if (
140
+ (is_null($expanded) && Mage::getSingleton('admin/session')->getIsTreeWasExpanded())
141
+ || $expanded == true) {
142
+ $params['expand_all'] = true;
143
+ }
144
+ return $this->getUrl('*/*/categoriesJson', $params);
145
+ }
146
+
147
+ public function getNodesUrl()
148
+ {
149
+ return $this->getUrl('*/catalog_category/jsonTree');
150
+ }
151
+
152
+ public function getSwitchTreeUrl()
153
+ {
154
+ return $this->getUrl("*/catalog_category/tree", array('_current'=>true, 'store'=>null, '_query'=>false, 'id'=>null, 'parent'=>null));
155
+ }
156
+
157
+ public function getIsWasExpanded()
158
+ {
159
+ return Mage::getSingleton('admin/session')->getIsTreeWasExpanded();
160
+ }
161
+
162
+ public function getMoveUrl()
163
+ {
164
+ return $this->getUrl('*/catalog_category/move', array('store'=>$this->getRequest()->getParam('store')));
165
+ }
166
+
167
+ public function getTree($parenNodeCategory=null)
168
+ {
169
+ $rootArray = $this->_getNodeJson($this->getRoot($parenNodeCategory));
170
+ $tree = isset($rootArray['children']) ? $rootArray['children'] : array();
171
+ return $tree;
172
+ }
173
+
174
+ public function getTreeJson($parenNodeCategory=null)
175
+ {
176
+ $rootArray = $this->_getNodeJson($this->getRoot($parenNodeCategory));
177
+ $json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());
178
+ return $json;
179
+ }
180
+
181
+ /**
182
+ * Get JSON of array of categories, that are breadcrumbs for specified category path
183
+ *
184
+ * @param string $path
185
+ * @param string $javascriptVarName
186
+ * @return string
187
+ */
188
+ public function getBreadcrumbsJavascript($path, $javascriptVarName)
189
+ {
190
+ if (empty($path)) {
191
+ return '';
192
+ }
193
+
194
+ $categories = Mage::getResourceSingleton('catalog/category_tree')
195
+ ->setStoreId($this->getStore()->getId())->loadBreadcrumbsArray($path);
196
+ if (empty($categories)) {
197
+ return '';
198
+ }
199
+ foreach ($categories as $key => $category) {
200
+ $categories[$key] = $this->_getNodeJson($category);
201
+ }
202
+ return
203
+ '<script type="text/javascript">'
204
+ . $javascriptVarName . ' = ' . Mage::helper('core')->jsonEncode($categories) . ';'
205
+ . ($this->canAddSubCategory() ? '$("add_subcategory_button").show();' : '$("add_subcategory_button").hide();')
206
+ . '</script>';
207
+ }
208
+
209
+ /**
210
+ * Get JSON of a tree node or an associative array
211
+ *
212
+ * @param Varien_Data_Tree_Node|array $node
213
+ * @param int $level
214
+ * @return string
215
+ */
216
+ protected function _getNodeJson($node, $level = 0)
217
+ {
218
+ // create a node from data array
219
+ if (is_array($node)) {
220
+ $node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
221
+ }
222
+
223
+ $item = array();
224
+ $item['text'] = $this->buildNodeName($node);
225
+
226
+ //$rootForStores = Mage::getModel('core/store')->getCollection()->loadByCategoryIds(array($node->getEntityId()));
227
+ $rootForStores = in_array($node->getEntityId(), $this->getRootIds());
228
+
229
+ $item['id'] = $node->getId();
230
+ $item['store'] = (int) $this->getStore()->getId();
231
+ $item['path'] = $node->getData('path');
232
+
233
+ $item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
234
+ //$item['allowDrop'] = ($level<3) ? true : false;
235
+ $allowMove = $this->_isCategoryMoveable($node);
236
+ $item['allowDrop'] = $allowMove;
237
+ // disallow drag if it's first level and category is root of a store
238
+ $item['allowDrag'] = $allowMove && (($node->getLevel()==1 && $rootForStores) ? false : true);
239
+
240
+ if ((int)$node->getChildrenCount()>0) {
241
+ $item['children'] = array();
242
+ }
243
+
244
+ $isParent = $this->_isParentSelectedCategory($node);
245
+
246
+ if ($node->hasChildren()) {
247
+ $item['children'] = array();
248
+ if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) {
249
+ foreach ($node->getChildren() as $child) {
250
+ $item['children'][] = $this->_getNodeJson($child, $level+1);
251
+ }
252
+ }
253
+ }
254
+
255
+ if ($isParent || $node->getLevel() < 2) {
256
+ $item['expanded'] = true;
257
+ }
258
+
259
+ return $item;
260
+ }
261
+
262
+ /**
263
+ * Get category name
264
+ *
265
+ * @param Varien_Object $node
266
+ * @return string
267
+ */
268
+ public function buildNodeName($node)
269
+ {
270
+ $result = $this->htmlEscape($node->getName());
271
+ if ($this->_withProductCount) {
272
+ $result .= ' (' . $node->getProductCount() . ')';
273
+ }
274
+ return $result;
275
+ }
276
+
277
+ protected function _isCategoryMoveable($node)
278
+ {
279
+ $options = new Varien_Object(array(
280
+ 'is_moveable' => true,
281
+ 'category' => $node
282
+ ));
283
+
284
+ Mage::dispatchEvent('adminhtml_catalog_category_tree_is_moveable',
285
+ array('options'=>$options)
286
+ );
287
+
288
+ return $options->getIsMoveable();
289
+ }
290
+
291
+ protected function _isParentSelectedCategory($node)
292
+ {
293
+ if ($node && $this->getCategory()) {
294
+ $pathIds = $this->getCategory()->getPathIds();
295
+ if (in_array($node->getId(), $pathIds)) {
296
+ return true;
297
+ }
298
+ }
299
+
300
+ return false;
301
+ }
302
+
303
+ /**
304
+ * Check if page loaded by outside link to category edit
305
+ *
306
+ * @return boolean
307
+ */
308
+ public function isClearEdit()
309
+ {
310
+ return (bool) $this->getRequest()->getParam('clear');
311
+ }
312
+
313
+ /**
314
+ * Check availability of adding root category
315
+ *
316
+ * @return boolean
317
+ */
318
+ public function canAddRootCategory()
319
+ {
320
+ $options = new Varien_Object(array('is_allow'=>true));
321
+ Mage::dispatchEvent(
322
+ 'adminhtml_catalog_category_tree_can_add_root_category',
323
+ array(
324
+ 'category' => $this->getCategory(),
325
+ 'options' => $options,
326
+ 'store' => $this->getStore()->getId()
327
+ )
328
+ );
329
+
330
+ return $options->getIsAllow();
331
+ }
332
+
333
+ /**
334
+ * Check availability of adding sub category
335
+ *
336
+ * @return boolean
337
+ */
338
+ public function canAddSubCategory()
339
+ {
340
+ $options = new Varien_Object(array('is_allow'=>true));
341
+ Mage::dispatchEvent(
342
+ 'adminhtml_catalog_category_tree_can_add_sub_category',
343
+ array(
344
+ 'category' => $this->getCategory(),
345
+ 'options' => $options,
346
+ 'store' => $this->getStore()->getId()
347
+ )
348
+ );
349
+
350
+ return $options->getIsAllow();
351
+ }
352
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Category/Widget/Chooser.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Category chooser for Wysiwyg CMS widget
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Category_Widget_Chooser extends Mage_Adminhtml_Block_Catalog_Category_Tree
35
+ {
36
+ protected $_selectedCategories = array();
37
+
38
+ /**
39
+ * Block construction
40
+ * Defines tree template and init tree params
41
+ */
42
+ public function __construct()
43
+ {
44
+ parent::__construct();
45
+ $this->setTemplate('catalog/category/widget/tree.phtml');
46
+ $this->_withProductCount = false;
47
+ }
48
+
49
+ /**
50
+ * Setter
51
+ *
52
+ * @param array $selectedCategories
53
+ * @return Mage_Adminhtml_Block_Catalog_Category_Widget_Chooser
54
+ */
55
+ public function setSelectedCategories($selectedCategories)
56
+ {
57
+ $this->_selectedCategories = $selectedCategories;
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Getter
63
+ *
64
+ * @return array
65
+ */
66
+ public function getSelectedCategories()
67
+ {
68
+ return $this->_selectedCategories;
69
+ }
70
+
71
+ /**
72
+ * Prepare chooser element HTML
73
+ *
74
+ * @param Varien_Data_Form_Element_Abstract $element Form Element
75
+ * @return Varien_Data_Form_Element_Abstract
76
+ */
77
+ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
78
+ {
79
+ $uniqId = Mage::helper('core')->uniqHash($element->getId());
80
+ $sourceUrl = $this->getUrl('*/catalog_category_widget/chooser', array('uniq_id' => $uniqId, 'use_massaction' => false));
81
+
82
+ $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
83
+ ->setElement($element)
84
+ ->setTranslationHelper($this->getTranslationHelper())
85
+ ->setConfig($this->getConfig())
86
+ ->setFieldsetId($this->getFieldsetId())
87
+ ->setSourceUrl($sourceUrl)
88
+ ->setUniqId($uniqId);
89
+
90
+ if ($element->getValue()) {
91
+ $value = explode('/', $element->getValue());
92
+ $categoryId = false;
93
+ if (isset($value[0]) && isset($value[1]) && $value[0] == 'category') {
94
+ $categoryId = $value[1];
95
+ }
96
+ if ($categoryId) {
97
+ $label = Mage::getSingleton('catalog/category')->load($categoryId)->getName();
98
+ $chooser->setLabel($label);
99
+ }
100
+ }
101
+
102
+ $element->setData('after_element_html', $chooser->toHtml());
103
+ return $element;
104
+ }
105
+
106
+ /**
107
+ * Category Tree node onClick listener js function
108
+ *
109
+ * @return string
110
+ */
111
+ public function getNodeClickListener()
112
+ {
113
+ if ($this->getData('node_click_listener')) {
114
+ return $this->getData('node_click_listener');
115
+ }
116
+ if ($this->getUseMassaction()) {
117
+ $js = '
118
+ function (node, e) {
119
+ if (node.ui.toggleCheck) {
120
+ node.ui.toggleCheck(true);
121
+ }
122
+ }
123
+ ';
124
+ } else {
125
+ $chooserJsObject = $this->getId();
126
+ $js = '
127
+ function (node, e) {
128
+ '.$chooserJsObject.'.setElementValue("category/" + node.attributes.id);
129
+ '.$chooserJsObject.'.setElementLabel(node.text);
130
+ '.$chooserJsObject.'.close();
131
+ }
132
+ ';
133
+ }
134
+ return $js;
135
+ }
136
+
137
+ /**
138
+ * Get JSON of a tree node or an associative array
139
+ *
140
+ * @param Varien_Data_Tree_Node|array $node
141
+ * @param int $level
142
+ * @return string
143
+ */
144
+ protected function _getNodeJson($node, $level = 0)
145
+ {
146
+ $item = parent::_getNodeJson($node, $level);
147
+ if (in_array($node->getId(), $this->getSelectedCategories())) {
148
+ $item['checked'] = true;
149
+ }
150
+ $item['is_anchor'] = (int)$node->getIsAnchor();
151
+ $item['url_key'] = $node->getData('url_key');
152
+ return $item;
153
+ }
154
+
155
+ /**
156
+ * Adds some extra params to categories collection
157
+ *
158
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
159
+ */
160
+ public function getCategoryCollection()
161
+ {
162
+ return parent::getCategoryCollection()->addAttributeToSelect('url_key')->addAttributeToSelect('is_anchor');
163
+ }
164
+
165
+ /**
166
+ * Tree JSON source URL
167
+ *
168
+ * @return string
169
+ */
170
+ public function getLoadTreeUrl($expanded=null)
171
+ {
172
+ return $this->getUrl('*/catalog_category_widget/categoriesJson', array(
173
+ '_current'=>true,
174
+ 'uniq_id' => $this->getId(),
175
+ 'use_massaction' => $this->getUseMassaction()
176
+ ));
177
+ }
178
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Form.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Base block for rendering category and product forms
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Form extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+ protected function _prepareLayout()
37
+ {
38
+ Varien_Data_Form::setElementRenderer(
39
+ $this->getLayout()->createBlock('adminhtml/widget_form_renderer_element')
40
+ );
41
+ Varien_Data_Form::setFieldsetRenderer(
42
+ $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset')
43
+ );
44
+ Varien_Data_Form::setFieldsetElementRenderer(
45
+ $this->getLayout()->createBlock('adminhtml/catalog_form_renderer_fieldset_element')
46
+ );
47
+ }
48
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Attribute/Urlkey.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Renderer for URL key input
29
+ * Allows to manage and overwrite URL Rewrites History save settings
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+
36
+ class Mage_Adminhtml_Block_Catalog_Form_Renderer_Attribute_Urlkey
37
+ extends Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element
38
+ {
39
+ public function getElementHtml()
40
+ {
41
+ $element = $this->getElement();
42
+ if(!$element->getValue()) {
43
+ return parent::getElementHtml();
44
+ }
45
+ $element->setOnkeyup("onUrlkeyChanged('" . $element->getHtmlId() . "')");
46
+ $element->setOnchange("onUrlkeyChanged('" . $element->getHtmlId() . "')");
47
+
48
+ $data = array(
49
+ 'name' => $element->getData('name') . '_create_redirect',
50
+ 'disabled' => true,
51
+ );
52
+ $hidden = new Varien_Data_Form_Element_Hidden($data);
53
+ $hidden->setForm($element->getForm());
54
+
55
+ $storeId = $element->getForm()->getDataObject()->getStoreId();
56
+ $data['html_id'] = $element->getHtmlId() . '_create_redirect';
57
+ $data['label'] = Mage::helper('catalog')->__('Create Permanent Redirect for old URL');
58
+ $data['value'] = $element->getValue();
59
+ $data['checked'] = Mage::helper('catalog')->shouldSaveUrlRewritesHistory($storeId);
60
+ $checkbox = new Varien_Data_Form_Element_Checkbox($data);
61
+ $checkbox->setForm($element->getForm());
62
+
63
+ return parent::getElementHtml() . '<br/>' . $hidden->getElementHtml() . $checkbox->getElementHtml() . $checkbox->getLabelHtml();
64
+ }
65
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/DateFieldsOrder.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Catalog Custom Options Config Renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Form_Renderer_Config_DateFieldsOrder extends Mage_Adminhtml_Block_System_Config_Form_Field
35
+ {
36
+
37
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
38
+ {
39
+ $_options = array(
40
+ 'd' => Mage::helper('adminhtml')->__('Day'),
41
+ 'm' => Mage::helper('adminhtml')->__('Month'),
42
+ 'y' => Mage::helper('adminhtml')->__('Year')
43
+ );
44
+
45
+ $element->setValues($_options)
46
+ ->setStyle('width:70px;')
47
+ ->setName($element->getName() . '[]');
48
+ if ($element->getValue()) {
49
+ $values = explode(',', $element->getValue());
50
+ } else {
51
+ $values = array();
52
+ }
53
+
54
+ $_parts = array();
55
+ $_parts[] = $element->setValue(isset($values[0]) ? $values[0] : null)->getElementHtml();
56
+ $_parts[] = $element->setValue(isset($values[1]) ? $values[1] : null)->getElementHtml();
57
+ $_parts[] = $element->setValue(isset($values[2]) ? $values[2] : null)->getElementHtml();
58
+
59
+ return implode(' / ', $_parts);
60
+ }
61
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Config/YearRange.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Catalog Custom Options Config Renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Form_Renderer_Config_YearRange extends Mage_Adminhtml_Block_System_Config_Form_Field
35
+ {
36
+
37
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
38
+ {
39
+ $element->setStyle('width:70px;')
40
+ ->setName($element->getName() . '[]');
41
+
42
+ if ($element->getValue()) {
43
+ $values = explode(',', $element->getValue());
44
+ } else {
45
+ $values = array();
46
+ }
47
+
48
+ $from = $element->setValue(isset($values[0]) ? $values[0] : null)->getElementHtml();
49
+ $to = $element->setValue(isset($values[1]) ? $values[1] : null)->getElementHtml();
50
+ return Mage::helper('adminhtml')->__('from') . ' ' . $from
51
+ . ' '
52
+ . Mage::helper('adminhtml')->__('to') . ' ' . $to;
53
+ }
54
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Catalog fieldset element renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
35
+ {
36
+ /**
37
+ * Initialize block template
38
+ */
39
+ protected function _construct()
40
+ {
41
+ $this->setTemplate('catalog/form/renderer/fieldset/element.phtml');
42
+ }
43
+
44
+ /**
45
+ * Retrieve data object related with form
46
+ *
47
+ * @return Mage_Catalog_Model_Product || Mage_Catalog_Model_Category
48
+ */
49
+ public function getDataObject()
50
+ {
51
+ return $this->getElement()->getForm()->getDataObject();
52
+ }
53
+
54
+ /**
55
+ * Retireve associated with element attribute object
56
+ *
57
+ * @return Mage_Catalog_Model_Resource_Eav_Attribute
58
+ */
59
+ public function getAttribute()
60
+ {
61
+ return $this->getElement()->getEntityAttribute();
62
+ }
63
+
64
+ /**
65
+ * Retrieve associated attribute code
66
+ *
67
+ * @return string
68
+ */
69
+ public function getAttributeCode()
70
+ {
71
+ return $this->getAttribute()->getAttributeCode();
72
+ }
73
+
74
+ /**
75
+ * Check "Use default" checkbox display availability
76
+ *
77
+ * @return bool
78
+ */
79
+ public function canDisplayUseDefault()
80
+ {
81
+ if ($attribute = $this->getAttribute()) {
82
+ if (!$attribute->isScopeGlobal()
83
+ && $this->getDataObject()
84
+ && $this->getDataObject()->getId()
85
+ && $this->getDataObject()->getStoreId()) {
86
+ return true;
87
+ }
88
+ }
89
+ return false;
90
+ }
91
+
92
+ /**
93
+ * Check default value usage fact
94
+ *
95
+ * @return bool
96
+ */
97
+ public function usedDefault()
98
+ {
99
+ $attributeCode = $this->getAttribute()->getAttributeCode();
100
+ $defaultValue = $this->getDataObject()->getAttributeDefaultValue($attributeCode);
101
+
102
+ if (!$this->getDataObject()->getExistsStoreValueFlag($attributeCode)) {
103
+ return true;
104
+ } else if ($this->getElement()->getValue() == $defaultValue &&
105
+ $this->getDataObject()->getStoreId() != $this->_getDefaultStoreId()) {
106
+ return false;
107
+ }
108
+ if ($defaultValue === false && !$this->getAttribute()->getIsRequired() && $this->getElement()->getValue()) {
109
+ return false;
110
+ }
111
+ return $defaultValue === false;
112
+ }
113
+
114
+ /**
115
+ * Disable field in default value using case
116
+ *
117
+ * @return Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element
118
+ */
119
+ public function checkFieldDisable()
120
+ {
121
+ if ($this->canDisplayUseDefault() && $this->usedDefault()) {
122
+ $this->getElement()->setDisabled(true);
123
+ }
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * Retrieve label of attribute scope
129
+ *
130
+ * GLOBAL | WEBSITE | STORE
131
+ *
132
+ * @return string
133
+ */
134
+ public function getScopeLabel()
135
+ {
136
+ $html = '';
137
+ $attribute = $this->getElement()->getEntityAttribute();
138
+ if (!$attribute || Mage::app()->isSingleStoreMode() || $attribute->getFrontendInput()=='gallery') {
139
+ return $html;
140
+ }
141
+ if ($attribute->isScopeGlobal()) {
142
+ $html.= '[GLOBAL]';
143
+ }
144
+ elseif ($attribute->isScopeWebsite()) {
145
+ $html.= '[WEBSITE]';
146
+ }
147
+ elseif ($attribute->isScopeStore()) {
148
+ $html.= '[STORE VIEW]';
149
+ }
150
+
151
+ return $html;
152
+ }
153
+
154
+ /**
155
+ * Retrieve element label html
156
+ *
157
+ * @return string
158
+ */
159
+ public function getElementLabelHtml()
160
+ {
161
+ return $this->getElement()->getLabelHtml();
162
+ }
163
+
164
+ /**
165
+ * Retrieve element html
166
+ *
167
+ * @return string
168
+ */
169
+ public function getElementHtml()
170
+ {
171
+ return $this->getElement()->getElementHtml();
172
+ }
173
+
174
+ /**
175
+ * Default sore ID getter
176
+ *
177
+ * @return integer
178
+ */
179
+ protected function _getDefaultStoreId()
180
+ {
181
+ return Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
182
+ }
183
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Catalog textarea attribute WYSIWYG button
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg extends Varien_Data_Form_Element_Textarea
35
+ {
36
+ /**
37
+ * Retrieve additional html and put it at the end of element html
38
+ *
39
+ * @return string
40
+ */
41
+ public function getAfterElementHtml()
42
+ {
43
+ $html = parent::getAfterElementHtml();
44
+ if ($this->getIsWysiwygEnabled()) {
45
+ $disabled = ($this->getDisabled() || $this->getReadonly());
46
+ $html .= Mage::getSingleton('core/layout')
47
+ ->createBlock('adminhtml/widget_button', '', array(
48
+ 'label' => Mage::helper('catalog')->__('WYSIWYG Editor'),
49
+ 'type' => 'button',
50
+ 'disabled' => $disabled,
51
+ 'class' => ($disabled) ? 'disabled' : '',
52
+ 'onclick' => 'catalogWysiwygEditor.open(\''.Mage::helper('adminhtml')->getUrl('*/*/wysiwyg').'\', \''.$this->getHtmlId().'\')'
53
+ ))->toHtml();
54
+ }
55
+ return $html;
56
+ }
57
+
58
+ /**
59
+ * Check whether wysiwyg enabled or not
60
+ *
61
+ * @return boolean
62
+ */
63
+ public function getIsWysiwygEnabled()
64
+ {
65
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Cms')) {
66
+ return (bool)(Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && $this->getEntityAttribute()->getIsWysiwygEnabled());
67
+ }
68
+
69
+ return false;
70
+ }
71
+ }
72
+
app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Textarea attribute WYSIWYG content
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg_Content
35
+ extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+ /**
38
+ * Prepare form.
39
+ * Adding editor field to render
40
+ *
41
+ * @return Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg_Content
42
+ */
43
+ protected function _prepareForm()
44
+ {
45
+ $form = new Varien_Data_Form(array('id' => 'wysiwyg_edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
46
+
47
+ $config['document_base_url'] = $this->getData('store_media_url');
48
+ $config['store_id'] = $this->getData('store_id');
49
+ $config['add_variables'] = false;
50
+ $config['add_widgets'] = false;
51
+ $config['add_directives'] = true;
52
+ $config['use_container'] = true;
53
+ $config['container_class'] = 'hor-scroll';
54
+
55
+ $form->addField($this->getData('editor_element_id'), 'editor', array(
56
+ 'name' => 'content',
57
+ 'style' => 'width:725px;height:460px',
58
+ 'required' => true,
59
+ 'force_load' => true,
60
+ 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig($config)
61
+ ));
62
+ $this->setForm($form);
63
+ return parent::_prepareForm();
64
+ }
65
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Catalog manage products block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product extends Mage_Adminhtml_Block_Widget_Container
35
+ {
36
+ /**
37
+ * Set template
38
+ */
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setTemplate('catalog/product.phtml');
43
+ }
44
+
45
+ /**
46
+ * Prepare button and grid
47
+ *
48
+ * @return Mage_Adminhtml_Block_Catalog_Product
49
+ */
50
+ protected function _prepareLayout()
51
+ {
52
+ $this->_addButton('add_new', array(
53
+ 'label' => Mage::helper('catalog')->__('Add Product'),
54
+ 'onclick' => "setLocation('{$this->getUrl('*/*/new')}')",
55
+ 'class' => 'add'
56
+ ));
57
+
58
+ $this->setChild('grid', $this->getLayout()->createBlock('adminhtml/catalog_product_grid', 'product.grid'));
59
+ return parent::_prepareLayout();
60
+ }
61
+
62
+ /**
63
+ * Deprecated since 1.3.2
64
+ *
65
+ * @return string
66
+ */
67
+ public function getAddNewButtonHtml()
68
+ {
69
+ return $this->getChildHtml('add_new_button');
70
+ }
71
+
72
+ /**
73
+ * Render grid
74
+ *
75
+ * @return string
76
+ */
77
+ public function getGridHtml()
78
+ {
79
+ return $this->getChildHtml('grid');
80
+ }
81
+
82
+ /**
83
+ * Check whether it is single store mode
84
+ *
85
+ * @return bool
86
+ */
87
+ public function isSingleStoreMode()
88
+ {
89
+ if (!Mage::app()->isSingleStoreMode()) {
90
+ return false;
91
+ }
92
+ return true;
93
+ }
94
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml catalog product attributes block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute extends Mage_Adminhtml_Block_Widget_Grid_Container
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ $this->_controller = 'catalog_product_attribute';
41
+ $this->_headerText = Mage::helper('catalog')->__('Manage Attributes');
42
+ $this->_addButtonLabel = Mage::helper('catalog')->__('Add New Attribute');
43
+ parent::__construct();
44
+ }
45
+
46
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product attribute edit page
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ $this->_objectId = 'attribute_id';
41
+ $this->_controller = 'catalog_product_attribute';
42
+
43
+ parent::__construct();
44
+
45
+ if($this->getRequest()->getParam('popup')) {
46
+ $this->_removeButton('back');
47
+ $this->_addButton(
48
+ 'close',
49
+ array(
50
+ 'label' => Mage::helper('catalog')->__('Close Window'),
51
+ 'class' => 'cancel',
52
+ 'onclick' => 'window.close()',
53
+ 'level' => -1
54
+ )
55
+ );
56
+ } else {
57
+ $this->_addButton(
58
+ 'save_and_edit_button',
59
+ array(
60
+ 'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
61
+ 'onclick' => 'saveAndContinueEdit()',
62
+ 'class' => 'save'
63
+ ),
64
+ 100
65
+ );
66
+ }
67
+
68
+ $this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Attribute'));
69
+ $this->_updateButton('save', 'onclick', 'saveAttribute()');
70
+
71
+ if (! Mage::registry('entity_attribute')->getIsUserDefined()) {
72
+ $this->_removeButton('delete');
73
+ } else {
74
+ $this->_updateButton('delete', 'label', Mage::helper('catalog')->__('Delete Attribute'));
75
+ }
76
+ }
77
+
78
+ public function getHeaderText()
79
+ {
80
+ if (Mage::registry('entity_attribute')->getId()) {
81
+ $frontendLabel = Mage::registry('entity_attribute')->getFrontendLabel();
82
+ if (is_array($frontendLabel)) {
83
+ $frontendLabel = $frontendLabel[0];
84
+ }
85
+ return Mage::helper('catalog')->__('Edit Product Attribute "%s"', $this->htmlEscape($frontendLabel));
86
+ }
87
+ else {
88
+ return Mage::helper('catalog')->__('New Product Attribute');
89
+ }
90
+ }
91
+
92
+ public function getValidationUrl()
93
+ {
94
+ return $this->getUrl('*/*/validate', array('_current'=>true));
95
+ }
96
+
97
+ public function getSaveUrl()
98
+ {
99
+ return $this->getUrl('*/'.$this->_controller.'/save', array('_current'=>true, 'back'=>null));
100
+ }
101
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Form.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product attribute add/edit form block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+
38
+ protected function _prepareForm()
39
+ {
40
+ $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
41
+ $form->setUseContainer(true);
42
+ $this->setForm($form);
43
+ return parent::_prepareForm();
44
+ }
45
+
46
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product attribute add/edit form main tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Front extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+
38
+ protected function _prepareForm()
39
+ {
40
+ $model = Mage::registry('entity_attribute');
41
+
42
+ $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
43
+
44
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('catalog')->__('Frontend Properties')));
45
+
46
+ $yesno = array(
47
+ array(
48
+ 'value' => 0,
49
+ 'label' => Mage::helper('catalog')->__('No')
50
+ ),
51
+ array(
52
+ 'value' => 1,
53
+ 'label' => Mage::helper('catalog')->__('Yes')
54
+ ));
55
+
56
+
57
+ $fieldset->addField('is_searchable', 'select', array(
58
+ 'name' => 'is_searchable',
59
+ 'label' => Mage::helper('catalog')->__('Use in Quick Search'),
60
+ 'title' => Mage::helper('catalog')->__('Use in Quick Search'),
61
+ 'values' => $yesno,
62
+ ));
63
+
64
+ $fieldset->addField('is_visible_in_advanced_search', 'select', array(
65
+ 'name' => 'is_visible_in_advanced_search',
66
+ 'label' => Mage::helper('catalog')->__('Use in Advanced Search'),
67
+ 'title' => Mage::helper('catalog')->__('Use in Advanced Search'),
68
+ 'values' => $yesno,
69
+ ));
70
+
71
+ $fieldset->addField('is_comparable', 'select', array(
72
+ 'name' => 'is_comparable',
73
+ 'label' => Mage::helper('catalog')->__('Comparable on the Frontend'),
74
+ 'title' => Mage::helper('catalog')->__('Comparable on the Frontend'),
75
+ 'values' => $yesno,
76
+ ));
77
+
78
+
79
+ $fieldset->addField('is_filterable', 'select', array(
80
+ 'name' => 'is_filterable',
81
+ 'label' => Mage::helper('catalog')->__("Use in Layered Navigation<br/>(Can be used only with catalog input type 'Dropdown')"),
82
+ 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown'),
83
+ 'values' => array(
84
+ array('value' => '0', 'label' => Mage::helper('catalog')->__('No')),
85
+ array('value' => '1', 'label' => Mage::helper('catalog')->__('Filterable (with results)')),
86
+ array('value' => '2', 'label' => Mage::helper('catalog')->__('Filterable (no results)')),
87
+ ),
88
+ ));
89
+
90
+ // if ($model->getIsUserDefined() || !$model->getId()) {
91
+ $fieldset->addField('is_visible_on_front', 'select', array(
92
+ 'name' => 'is_visible_on_front',
93
+ 'label' => Mage::helper('catalog')->__('Visible on Catalog Pages on Front-end'),
94
+ 'title' => Mage::helper('catalog')->__('Visible on Catalog Pages on Front-end'),
95
+ 'values' => $yesno,
96
+ ));
97
+ // }
98
+
99
+ $form->setValues($model->getData());
100
+
101
+ $this->setForm($form);
102
+
103
+ return parent::_prepareForm();
104
+ }
105
+
106
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Product attribute add/edit form main tab
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract
36
+ {
37
+ /**
38
+ * Adding product form elements for editing attribute
39
+ *
40
+ * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main
41
+ */
42
+ protected function _prepareForm()
43
+ {
44
+ parent::_prepareForm();
45
+ $attributeObject = $this->getAttributeObject();
46
+ /* @var $form Varien_Data_Form */
47
+ $form = $this->getForm();
48
+ /* @var $fieldset Varien_Data_Form_Element_Fieldset */
49
+ $fieldset = $form->getElement('base_fieldset');
50
+
51
+ $frontendInputElm = $form->getElement('frontend_input');
52
+ $additionalTypes = array(
53
+ array(
54
+ 'value' => 'price',
55
+ 'label' => Mage::helper('catalog')->__('Price')
56
+ ),
57
+ array(
58
+ 'value' => 'media_image',
59
+ 'label' => Mage::helper('catalog')->__('Media Image')
60
+ )
61
+ );
62
+ if ($attributeObject->getFrontendInput() == 'gallery') {
63
+ $additionalTypes[] = array(
64
+ 'value' => 'gallery',
65
+ 'label' => Mage::helper('catalog')->__('Gallery')
66
+ );
67
+ }
68
+
69
+ $response = new Varien_Object();
70
+ $response->setTypes(array());
71
+ Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response));
72
+ $_disabledTypes = array();
73
+ $_hiddenFields = array();
74
+ foreach ($response->getTypes() as $type) {
75
+ $additionalTypes[] = $type;
76
+ if (isset($type['hide_fields'])) {
77
+ $_hiddenFields[$type['value']] = $type['hide_fields'];
78
+ }
79
+ if (isset($type['disabled_types'])) {
80
+ $_disabledTypes[$type['value']] = $type['disabled_types'];
81
+ }
82
+ }
83
+ Mage::register('attribute_type_hidden_fields', $_hiddenFields);
84
+ Mage::register('attribute_type_disabled_types', $_disabledTypes);
85
+
86
+ $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
87
+ $frontendInputElm->setValues($frontendInputValues);
88
+
89
+ $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
90
+
91
+ $scopes = array(
92
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('catalog')->__('Store View'),
93
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('catalog')->__('Website'),
94
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('catalog')->__('Global'),
95
+ );
96
+
97
+ if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id') {
98
+ unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]);
99
+ }
100
+
101
+ $fieldset->addField('is_global', 'select', array(
102
+ 'name' => 'is_global',
103
+ 'label' => Mage::helper('catalog')->__('Scope'),
104
+ 'title' => Mage::helper('catalog')->__('Scope'),
105
+ 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'),
106
+ 'values'=> $scopes
107
+ ), 'attribute_code');
108
+
109
+ $fieldset->addField('apply_to', 'apply', array(
110
+ 'name' => 'apply_to[]',
111
+ 'label' => Mage::helper('catalog')->__('Apply To'),
112
+ 'values' => Mage_Catalog_Model_Product_Type::getOptions(),
113
+ 'mode_labels' => array(
114
+ 'all' => Mage::helper('catalog')->__('All Product Types'),
115
+ 'custom' => Mage::helper('catalog')->__('Selected Product Types')
116
+ ),
117
+ 'required' => true
118
+ ), 'frontend_class');
119
+
120
+ $fieldset->addField('is_configurable', 'select', array(
121
+ 'name' => 'is_configurable',
122
+ 'label' => Mage::helper('catalog')->__('Use To Create Configurable Product'),
123
+ 'values' => $yesnoSource,
124
+ ), 'apply_to');
125
+
126
+ // frontend properties fieldset
127
+ $fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('catalog')->__('Frontend Properties')));
128
+
129
+ $fieldset->addField('is_searchable', 'select', array(
130
+ 'name' => 'is_searchable',
131
+ 'label' => Mage::helper('catalog')->__('Use in Quick Search'),
132
+ 'title' => Mage::helper('catalog')->__('Use in Quick Search'),
133
+ 'values' => $yesnoSource,
134
+ ));
135
+
136
+ $fieldset->addField('is_visible_in_advanced_search', 'select', array(
137
+ 'name' => 'is_visible_in_advanced_search',
138
+ 'label' => Mage::helper('catalog')->__('Use in Advanced Search'),
139
+ 'title' => Mage::helper('catalog')->__('Use in Advanced Search'),
140
+ 'values' => $yesnoSource,
141
+ ));
142
+
143
+ $fieldset->addField('is_comparable', 'select', array(
144
+ 'name' => 'is_comparable',
145
+ 'label' => Mage::helper('catalog')->__('Comparable on Front-end'),
146
+ 'title' => Mage::helper('catalog')->__('Comparable on Front-end'),
147
+ 'values' => $yesnoSource,
148
+ ));
149
+
150
+ $fieldset->addField('is_filterable', 'select', array(
151
+ 'name' => 'is_filterable',
152
+ 'label' => Mage::helper('catalog')->__("Use In Layered Navigation"),
153
+ 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
154
+ 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
155
+ 'values' => array(
156
+ array('value' => '0', 'label' => Mage::helper('catalog')->__('No')),
157
+ array('value' => '1', 'label' => Mage::helper('catalog')->__('Filterable (with results)')),
158
+ array('value' => '2', 'label' => Mage::helper('catalog')->__('Filterable (no results)')),
159
+ ),
160
+ ));
161
+
162
+ $fieldset->addField('is_filterable_in_search', 'select', array(
163
+ 'name' => 'is_filterable_in_search',
164
+ 'label' => Mage::helper('catalog')->__("Use In Search Results Layered Navigation"),
165
+ 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
166
+ 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
167
+ 'values' => $yesnoSource,
168
+ ));
169
+
170
+ $fieldset->addField('is_used_for_promo_rules', 'select', array(
171
+ 'name' => 'is_used_for_promo_rules',
172
+ 'label' => Mage::helper('catalog')->__('Use for Promo Rule Conditions'),
173
+ 'title' => Mage::helper('catalog')->__('Use for Promo Rule Conditions'),
174
+ 'values' => $yesnoSource,
175
+ ));
176
+
177
+ $fieldset->addField('position', 'text', array(
178
+ 'name' => 'position',
179
+ 'label' => Mage::helper('catalog')->__('Position'),
180
+ 'title' => Mage::helper('catalog')->__('Position in Layered Navigation'),
181
+ 'note' => Mage::helper('catalog')->__('Position of attribute in layered navigation block'),
182
+ 'class' => 'validate-digits',
183
+ ));
184
+
185
+ $fieldset->addField('is_wysiwyg_enabled', 'select', array(
186
+ 'name' => 'is_wysiwyg_enabled',
187
+ 'label' => Mage::helper('catalog')->__('Enable WYSIWYG'),
188
+ 'title' => Mage::helper('catalog')->__('Enable WYSIWYG'),
189
+ 'values' => $yesnoSource,
190
+ ));
191
+
192
+ $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'select', array(
193
+ 'name' => 'is_html_allowed_on_front',
194
+ 'label' => Mage::helper('catalog')->__('Allow HTML Tags on Frontend'),
195
+ 'title' => Mage::helper('catalog')->__('Allow HTML Tags on Frontend'),
196
+ 'values' => $yesnoSource,
197
+ ));
198
+ if (!$attributeObject->getId() || $attributeObject->getIsWysiwygEnabled()) {
199
+ $attributeObject->setIsHtmlAllowedOnFront(1);
200
+ }
201
+
202
+ $fieldset->addField('is_visible_on_front', 'select', array(
203
+ 'name' => 'is_visible_on_front',
204
+ 'label' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'),
205
+ 'title' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'),
206
+ 'values' => $yesnoSource,
207
+ ));
208
+
209
+ $fieldset->addField('used_in_product_listing', 'select', array(
210
+ 'name' => 'used_in_product_listing',
211
+ 'label' => Mage::helper('catalog')->__('Used in Product Listing'),
212
+ 'title' => Mage::helper('catalog')->__('Used in Product Listing'),
213
+ 'note' => Mage::helper('catalog')->__('Depends on design theme'),
214
+ 'values' => $yesnoSource,
215
+ ));
216
+ $fieldset->addField('used_for_sort_by', 'select', array(
217
+ 'name' => 'used_for_sort_by',
218
+ 'label' => Mage::helper('catalog')->__('Used for Sorting in Product Listing'),
219
+ 'title' => Mage::helper('catalog')->__('Used for Sorting in Product Listing'),
220
+ 'note' => Mage::helper('catalog')->__('Depends on design theme'),
221
+ 'values' => $yesnoSource,
222
+ ));
223
+
224
+ $form->getElement('apply_to')->setSize(5);
225
+
226
+ if ($applyTo = $attributeObject->getApplyTo()) {
227
+ $applyTo = is_array($applyTo) ? $applyTo : explode(',', $applyTo);
228
+ $form->getElement('apply_to')->setValue($applyTo);
229
+ } else {
230
+ $form->getElement('apply_to')->addClass('no-display ignore-validate');
231
+ }
232
+
233
+ // define field dependencies
234
+ $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
235
+ ->addFieldMap("is_wysiwyg_enabled", 'wysiwyg_enabled')
236
+ ->addFieldMap("is_html_allowed_on_front", 'html_allowed_on_front')
237
+ ->addFieldMap("frontend_input", 'frontend_input_type')
238
+ ->addFieldDependence('wysiwyg_enabled', 'frontend_input_type', 'textarea')
239
+ ->addFieldDependence('html_allowed_on_front', 'wysiwyg_enabled', '0')
240
+ );
241
+
242
+ Mage::dispatchEvent('adminhtml_catalog_product_attribute_edit_prepare_form', array(
243
+ 'form' => $form,
244
+ 'attribute' => $attributeObject
245
+ ));
246
+
247
+ return $this;
248
+ }
249
+
250
+ /**
251
+ * Retrieve additional element types for product attributes
252
+ *
253
+ * @return array
254
+ */
255
+ protected function _getAdditionalElementTypes()
256
+ {
257
+ return array(
258
+ 'apply' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_apply'),
259
+ );
260
+ }
261
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product attribute add/edit form options tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
35
+ {
36
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/System.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product attribute add/edit form system tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_System extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+
38
+ protected function _prepareForm()
39
+ {
40
+ $model = Mage::registry('entity_attribute');
41
+
42
+ $form = new Varien_Data_Form();
43
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('catalog')->__('System Properties')));
44
+
45
+ if ($model->getAttributeId()) {
46
+ $fieldset->addField('attribute_id', 'hidden', array(
47
+ 'name' => 'attribute_id',
48
+ ));
49
+ }
50
+
51
+ $yesno = array(
52
+ array(
53
+ 'value' => 0,
54
+ 'label' => Mage::helper('catalog')->__('No')
55
+ ),
56
+ array(
57
+ 'value' => 1,
58
+ 'label' => Mage::helper('catalog')->__('Yes')
59
+ ));
60
+
61
+ /*$fieldset->addField('attribute_model', 'text', array(
62
+ 'name' => 'attribute_model',
63
+ 'label' => Mage::helper('catalog')->__('Attribute Model'),
64
+ 'title' => Mage::helper('catalog')->__('Attribute Model'),
65
+ ));
66
+
67
+ $fieldset->addField('backend_model', 'text', array(
68
+ 'name' => 'backend_model',
69
+ 'label' => Mage::helper('catalog')->__('Backend Model'),
70
+ 'title' => Mage::helper('catalog')->__('Backend Model'),
71
+ ));*/
72
+
73
+ $fieldset->addField('backend_type', 'select', array(
74
+ 'name' => 'backend_type',
75
+ 'label' => Mage::helper('catalog')->__('Data Type for Saving in Database'),
76
+ 'title' => Mage::helper('catalog')->__('Data Type for Saving in Database'),
77
+ 'options' => array(
78
+ 'text' => Mage::helper('catalog')->__('Text'),
79
+ 'varchar' => Mage::helper('catalog')->__('Varchar'),
80
+ 'static' => Mage::helper('catalog')->__('Static'),
81
+ 'datetime' => Mage::helper('catalog')->__('Datetime'),
82
+ 'decimal' => Mage::helper('catalog')->__('Decimal'),
83
+ 'int' => Mage::helper('catalog')->__('Integer'),
84
+ ),
85
+ ));
86
+
87
+ /*$fieldset->addField('backend_table', 'text', array(
88
+ 'name' => 'backend_table',
89
+ 'label' => Mage::helper('catalog')->__('Backend Table'),
90
+ 'title' => Mage::helper('catalog')->__('Backend Table Title'),
91
+ ));
92
+
93
+ $fieldset->addField('frontend_model', 'text', array(
94
+ 'name' => 'frontend_model',
95
+ 'label' => Mage::helper('catalog')->__('Frontend Model'),
96
+ 'title' => Mage::helper('catalog')->__('Frontend Model'),
97
+ ));*/
98
+
99
+ /*$fieldset->addField('is_visible', 'select', array(
100
+ 'name' => 'is_visible',
101
+ 'label' => Mage::helper('catalog')->__('Visible'),
102
+ 'title' => Mage::helper('catalog')->__('Visible'),
103
+ 'values' => $yesno,
104
+ ));*/
105
+
106
+ /*$fieldset->addField('source_model', 'text', array(
107
+ 'name' => 'source_model',
108
+ 'label' => Mage::helper('catalog')->__('Source Model'),
109
+ 'title' => Mage::helper('catalog')->__('Source Model'),
110
+ ));*/
111
+
112
+ $fieldset->addField('is_global', 'select', array(
113
+ 'name' => 'is_global',
114
+ 'label' => Mage::helper('catalog')->__('Globally Editable'),
115
+ 'title' => Mage::helper('catalog')->__('Globally Editable'),
116
+ 'values'=> $yesno,
117
+ ));
118
+
119
+ $form->setValues($model->getData());
120
+
121
+ if ($model->getAttributeId()) {
122
+ $form->getElement('backend_type')->setDisabled(1);
123
+ if ($model->getIsGlobal()) {
124
+ #$form->getElement('is_global')->setDisabled(1);
125
+ }
126
+ } else {
127
+ }
128
+
129
+ $this->setForm($form);
130
+
131
+ return parent::_prepareForm();
132
+ }
133
+
134
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml product attribute edit page tabs
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('product_attribute_tabs');
41
+ $this->setDestElementId('edit_form');
42
+ $this->setTitle(Mage::helper('catalog')->__('Attribute Information'));
43
+ }
44
+
45
+ protected function _beforeToHtml()
46
+ {
47
+ $this->addTab('main', array(
48
+ 'label' => Mage::helper('catalog')->__('Properties'),
49
+ 'title' => Mage::helper('catalog')->__('Properties'),
50
+ 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit_tab_main')->toHtml(),
51
+ 'active' => true
52
+ ));
53
+
54
+ $model = Mage::registry('entity_attribute');
55
+
56
+ $this->addTab('labels', array(
57
+ 'label' => Mage::helper('catalog')->__('Manage Label / Options'),
58
+ 'title' => Mage::helper('catalog')->__('Manage Label / Options'),
59
+ 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit_tab_options')->toHtml(),
60
+ ));
61
+
62
+ /*if ('select' == $model->getFrontendInput()) {
63
+ $this->addTab('options_section', array(
64
+ 'label' => Mage::helper('catalog')->__('Options Control'),
65
+ 'title' => Mage::helper('catalog')->__('Options Control'),
66
+ 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit_tab_options')->toHtml(),
67
+ ));
68
+ }*/
69
+
70
+ return parent::_beforeToHtml();
71
+ }
72
+
73
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product attributes grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Grid extends Mage_Eav_Block_Adminhtml_Attribute_Grid_Abstract
35
+ {
36
+ /**
37
+ * Prepare product attributes grid collection object
38
+ *
39
+ * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Grid
40
+ */
41
+ protected function _prepareCollection()
42
+ {
43
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
44
+ ->addVisibleFilter();
45
+ $this->setCollection($collection);
46
+
47
+ return parent::_prepareCollection();
48
+ }
49
+
50
+ /**
51
+ * Prepare product attributes grid columns
52
+ *
53
+ * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Grid
54
+ */
55
+ protected function _prepareColumns()
56
+ {
57
+ parent::_prepareColumns();
58
+
59
+ $this->addColumnAfter('is_visible', array(
60
+ 'header'=>Mage::helper('catalog')->__('Visible'),
61
+ 'sortable'=>true,
62
+ 'index'=>'is_visible_on_front',
63
+ 'type' => 'options',
64
+ 'options' => array(
65
+ '1' => Mage::helper('catalog')->__('Yes'),
66
+ '0' => Mage::helper('catalog')->__('No'),
67
+ ),
68
+ 'align' => 'center',
69
+ ), 'frontend_label');
70
+
71
+ $this->addColumnAfter('is_global', array(
72
+ 'header'=>Mage::helper('catalog')->__('Scope'),
73
+ 'sortable'=>true,
74
+ 'index'=>'is_global',
75
+ 'type' => 'options',
76
+ 'options' => array(
77
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('catalog')->__('Store View'),
78
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('catalog')->__('Website'),
79
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('catalog')->__('Global'),
80
+ ),
81
+ 'align' => 'center',
82
+ ), 'is_visible');
83
+
84
+ $this->addColumn('is_searchable', array(
85
+ 'header'=>Mage::helper('catalog')->__('Searchable'),
86
+ 'sortable'=>true,
87
+ 'index'=>'is_searchable',
88
+ 'type' => 'options',
89
+ 'options' => array(
90
+ '1' => Mage::helper('catalog')->__('Yes'),
91
+ '0' => Mage::helper('catalog')->__('No'),
92
+ ),
93
+ 'align' => 'center',
94
+ ), 'is_user_defined');
95
+
96
+ $this->addColumnAfter('is_filterable', array(
97
+ 'header'=>Mage::helper('catalog')->__('Use in Layered Navigation'),
98
+ 'sortable'=>true,
99
+ 'index'=>'is_filterable',
100
+ 'type' => 'options',
101
+ 'options' => array(
102
+ '1' => Mage::helper('catalog')->__('Filterable (with results)'),
103
+ '2' => Mage::helper('catalog')->__('Filterable (no results)'),
104
+ '0' => Mage::helper('catalog')->__('No'),
105
+ ),
106
+ 'align' => 'center',
107
+ ), 'is_searchable');
108
+
109
+ $this->addColumnAfter('is_comparable', array(
110
+ 'header'=>Mage::helper('catalog')->__('Comparable'),
111
+ 'sortable'=>true,
112
+ 'index'=>'is_comparable',
113
+ 'type' => 'options',
114
+ 'options' => array(
115
+ '1' => Mage::helper('catalog')->__('Yes'),
116
+ '0' => Mage::helper('catalog')->__('No'),
117
+ ),
118
+ 'align' => 'center',
119
+ ), 'is_filterable');
120
+
121
+ return $this;
122
+ }
123
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Attributes.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product attributes tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Attributes extends Mage_Adminhtml_Block_Catalog_Form
35
+ {
36
+ protected function _prepareForm()
37
+ {
38
+
39
+ $form = new Varien_Data_Form();
40
+ /**
41
+ * Initialize product object as form property
42
+ * for using it in elements generation
43
+ */
44
+ $form->setDataObject(Mage::registry('product'));
45
+
46
+ $fieldset = $form->addFieldset('group_fields', array());
47
+
48
+ $attributes = $this->getGroupAttributes();
49
+
50
+ $this->_setFieldset($attributes, $fieldset, array('gallery'));
51
+
52
+ $values = Mage::registry('product')->getData();
53
+ /**
54
+ * Set attribute default values for new product
55
+ */
56
+ if (!Mage::registry('product')->getId()) {
57
+ foreach ($attributes as $attribute) {
58
+ if (!isset($values[$attribute->getAttributeCode()])) {
59
+ $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
60
+ }
61
+ }
62
+ }
63
+
64
+ Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form'=>$form));
65
+ $form->addValues($values);
66
+ $form->setFieldNameSuffix('product');
67
+ $this->setForm($form);
68
+ }
69
+
70
+ protected function _getAdditionalElementTypes()
71
+ {
72
+ $result = array(
73
+ 'price' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'),
74
+ 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'),
75
+ 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean')
76
+ );
77
+
78
+ $response = new Varien_Object();
79
+ $response->setTypes(array());
80
+ Mage::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response'=>$response));
81
+
82
+ foreach ($response->getTypes() as $typeName=>$typeClass) {
83
+ $result[$typeName] = $typeClass;
84
+ }
85
+
86
+ return $result;
87
+ }
88
+
89
+ protected function _toHtml()
90
+ {
91
+ parent::_toHtml();
92
+ return $this->getForm()->getElement('group_fields')->getChildrenHtml();
93
+ }
94
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * New product attribute created on product edit page
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Created extends Mage_Adminhtml_Block_Widget
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setTemplate('catalog/product/attribute/new/created.phtml');
40
+ }
41
+
42
+ protected function _prepareLayout()
43
+ {
44
+
45
+ $this->setChild(
46
+ 'attributes',
47
+ $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_new_product_attributes')
48
+ ->setGroupAttributes($this->_getGroupAttributes())
49
+ );
50
+
51
+ $this->setChild(
52
+ 'close_button',
53
+ $this->getLayout()->createBlock('adminhtml/widget_button')
54
+ ->setData(array(
55
+ 'label' => Mage::helper('catalog')->__('Close Window'),
56
+ 'onclick' => 'addAttribute(true)'
57
+ ))
58
+ );
59
+
60
+ }
61
+
62
+ protected function _getGroupAttributes()
63
+ {
64
+ $attributes = array();
65
+ $product = Mage::registry('product');
66
+ /* @var $product Mage_Catalog_Model_Product */
67
+ foreach($product->getAttributes($this->getRequest()->getParam('group')) as $attribute) {
68
+ /* @var $attribute Mage_Eav_Model_Entity_Attribute */
69
+ if ($attribute->getId() == $this->getRequest()->getParam('attribute')) {
70
+ $attributes[] = $attribute;
71
+ }
72
+ }
73
+ return $attributes;
74
+ }
75
+
76
+ public function getCloseButtonHtml()
77
+ {
78
+ return $this->getChildHtml('close_button');
79
+ }
80
+
81
+ public function getAttributesBlockJson()
82
+ {
83
+ $result = array(
84
+ $this->getRequest()->getParam('tab') => $this->getChildHtml('attributes')
85
+ );
86
+
87
+ return Mage::helper('core')->jsonEncode($result);
88
+ }
89
+ } // Class Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Created End
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Grid.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * description
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('setGrid');
41
+ $this->setDefaultSort('set_id');
42
+ $this->setDefaultDir('ASC');
43
+ $this->setSaveParametersInSession(true);
44
+ }
45
+
46
+ protected function _prepareCollection()
47
+ {
48
+ $collection = Mage::getResourceModel('eav/entity_attribute_set_collection')
49
+ ->setEntityTypeFilter(Mage::registry('entityType'));
50
+
51
+ $this->setCollection($collection);
52
+ return parent::_prepareCollection();
53
+ }
54
+
55
+ protected function _prepareColumns()
56
+ {
57
+ /*$this->addColumn('set_id', array(
58
+ 'header' => Mage::helper('catalog')->__('ID'),
59
+ 'align' => 'right',
60
+ 'sortable' => true,
61
+ 'width' => '50px',
62
+ 'index' => 'attribute_set_id',
63
+ ));*/
64
+
65
+ $this->addColumn('set_name', array(
66
+ 'header' => Mage::helper('catalog')->__('Set Name'),
67
+ 'align' => 'left',
68
+ 'sortable' => true,
69
+ 'index' => 'attribute_set_name',
70
+ ));
71
+ }
72
+
73
+ public function getRowUrl($row)
74
+ {
75
+ return $this->getUrl('*/*/edit', array('id'=>$row->getAttributeSetId()));
76
+ }
77
+
78
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml Catalog Attribute Set Main Block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main extends Mage_Adminhtml_Block_Template
35
+ {
36
+ /**
37
+ * Initialize template
38
+ *
39
+ */
40
+ protected function _construct()
41
+ {
42
+ $this->setTemplate('catalog/product/attribute/set/main.phtml');
43
+ }
44
+
45
+ /**
46
+ * Prepare Global Layout
47
+ *
48
+ * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main
49
+ */
50
+ protected function _prepareLayout()
51
+ {
52
+ $setId = $this->_getSetId();
53
+
54
+ $this->setChild('group_tree',
55
+ $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_set_main_tree_group')
56
+ );
57
+
58
+ $this->setChild('edit_set_form',
59
+ $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_set_main_formset')
60
+ );
61
+
62
+ $this->setChild('delete_group_button',
63
+ $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
64
+ 'label' => Mage::helper('catalog')->__('Delete Selected Group'),
65
+ 'onclick' => 'editSet.submit();',
66
+ 'class' => 'delete'
67
+ )));
68
+
69
+ $this->setChild('add_group_button',
70
+ $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
71
+ 'label' => Mage::helper('catalog')->__('Add New'),
72
+ 'onclick' => 'editSet.addGroup();',
73
+ 'class' => 'add'
74
+ )));
75
+
76
+ $this->setChild('back_button',
77
+ $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
78
+ 'label' => Mage::helper('catalog')->__('Back'),
79
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')',
80
+ 'class' => 'back'
81
+ )));
82
+
83
+ $this->setChild('reset_button',
84
+ $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
85
+ 'label' => Mage::helper('catalog')->__('Reset'),
86
+ 'onclick' => 'window.location.reload()'
87
+ )));
88
+
89
+ $this->setChild('save_button',
90
+ $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
91
+ 'label' => Mage::helper('catalog')->__('Save Attribute Set'),
92
+ 'onclick' => 'editSet.save();',
93
+ 'class' => 'save'
94
+ )));
95
+
96
+ $this->setChild('delete_button',
97
+ $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
98
+ 'label' => Mage::helper('catalog')->__('Delete Attribute Set'),
99
+ 'onclick' => 'deleteConfirm(\''. $this->jsQuoteEscape(Mage::helper('catalog')->__('All products of this set will be deleted! Are you sure you want to delete this attribute set?')) . '\', \'' . $this->getUrl('*/*/delete', array('id' => $setId)) . '\')',
100
+ 'class' => 'delete'
101
+ )));
102
+
103
+ $this->setChild('rename_button',
104
+ $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
105
+ 'label' => Mage::helper('catalog')->__('New Set Name'),
106
+ 'onclick' => 'editSet.rename()'
107
+ )));
108
+
109
+ return parent::_prepareLayout();
110
+ }
111
+
112
+ /**
113
+ * Retrieve Attribute Set Group Tree HTML
114
+ *
115
+ * @return string
116
+ */
117
+ public function getGroupTreeHtml()
118
+ {
119
+ return $this->getChildHtml('group_tree');
120
+ }
121
+
122
+ /**
123
+ * Retrieve Attribute Set Edit Form HTML
124
+ *
125
+ * @return string
126
+ */
127
+ public function getSetFormHtml()
128
+ {
129
+ return $this->getChildHtml('edit_set_form');
130
+ }
131
+
132
+ /**
133
+ * Retrieve Block Header Text
134
+ *
135
+ * @return string
136
+ */
137
+ protected function _getHeader()
138
+ {
139
+ return Mage::helper('catalog')->__("Edit Attribute Set '%s'", $this->_getAttributeSet()->getAttributeSetName());
140
+ }
141
+
142
+ /**
143
+ * Retrieve Attribute Set Save URL
144
+ *
145
+ * @return string
146
+ */
147
+ public function getMoveUrl()
148
+ {
149
+ return $this->getUrl('*/catalog_product_set/save', array('id' => $this->_getSetId()));
150
+ }
151
+
152
+ /**
153
+ * Retrieve Attribute Set Group Save URL
154
+ *
155
+ * @return string
156
+ */
157
+ public function getGroupUrl()
158
+ {
159
+ return $this->getUrl('*/catalog_product_group/save', array('id' => $this->_getSetId()));
160
+ }
161
+
162
+ /**
163
+ * Retrieve Attribute Set Group Tree as JSON format
164
+ *
165
+ * @return string
166
+ */
167
+ public function getGroupTreeJson()
168
+ {
169
+ $items = array();
170
+ $setId = $this->_getSetId();
171
+
172
+ /* @var $groups Mage_Eav_Model_Mysql4_Entity_Attribute_Group_Collection */
173
+ $groups = Mage::getModel('eav/entity_attribute_group')
174
+ ->getResourceCollection()
175
+ ->setAttributeSetFilter($setId)
176
+ ->setSortOrder()
177
+ ->load();
178
+
179
+ $configurable = Mage::getResourceModel('catalog/product_type_configurable_attribute')
180
+ ->getUsedAttributes($setId);
181
+
182
+ /* @var $node Mage_Eav_Model_Entity_Attribute_Group */
183
+ foreach ($groups as $node) {
184
+ $item = array();
185
+ $item['text'] = $node->getAttributeGroupName();
186
+ $item['id'] = $node->getAttributeGroupId();
187
+ $item['cls'] = 'folder';
188
+ $item['allowDrop'] = true;
189
+ $item['allowDrag'] = true;
190
+
191
+ $nodeChildren = Mage::getResourceModel('catalog/product_attribute_collection')
192
+ ->setAttributeGroupFilter($node->getId())
193
+ ->addVisibleFilter()
194
+ ->checkConfigurableProducts()
195
+ ->load();
196
+
197
+ if ($nodeChildren->getSize() > 0) {
198
+ $item['children'] = array();
199
+ foreach ($nodeChildren->getItems() as $child) {
200
+ /* @var $child Mage_Eav_Model_Entity_Attribute */
201
+ $attr = array(
202
+ 'text' => $child->getAttributeCode(),
203
+ 'id' => $child->getAttributeId(),
204
+ 'cls' => (!$child->getIsUserDefined()) ? 'system-leaf' : 'leaf',
205
+ 'allowDrop' => false,
206
+ 'allowDrag' => true,
207
+ 'leaf' => true,
208
+ 'is_user_defined' => $child->getIsUserDefined(),
209
+ 'is_configurable' => (int)in_array($child->getAttributeId(), $configurable),
210
+ 'entity_id' => $child->getEntityAttributeId()
211
+ );
212
+
213
+ $item['children'][] = $attr;
214
+ }
215
+ }
216
+
217
+ $items[] = $item;
218
+ }
219
+
220
+ return Mage::helper('core')->jsonEncode($items);
221
+ }
222
+
223
+ /**
224
+ * Retrieve Unused in Attribute Set Attribute Tree as JSON
225
+ *
226
+ * @return string
227
+ */
228
+ public function getAttributeTreeJson()
229
+ {
230
+ $items = array();
231
+ $setId = $this->_getSetId();
232
+
233
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
234
+ ->setAttributeSetFilter($setId)
235
+ ->load();
236
+
237
+ $attributesIds = array('0');
238
+ /* @var $item Mage_Eav_Model_Entity_Attribute */
239
+ foreach ($collection->getItems() as $item) {
240
+ $attributesIds[] = $item->getAttributeId();
241
+ }
242
+
243
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
244
+ ->setAttributesExcludeFilter($attributesIds)
245
+ ->addVisibleFilter()
246
+ ->load();
247
+
248
+ foreach ($attributes as $child) {
249
+ $attr = array(
250
+ 'text' => $child->getAttributeCode(),
251
+ 'id' => $child->getAttributeId(),
252
+ 'cls' => 'leaf',
253
+ 'allowDrop' => false,
254
+ 'allowDrag' => true,
255
+ 'leaf' => true,
256
+ 'is_user_defined' => $child->getIsUserDefined(),
257
+ 'is_configurable' => false,
258
+ 'entity_id' => $child->getEntityId()
259
+ );
260
+
261
+ $items[] = $attr;
262
+ }
263
+
264
+ if (count($items) == 0) {
265
+ $items[] = array(
266
+ 'text' => Mage::helper('catalog')->__('Empty'),
267
+ 'id' => 'empty',
268
+ 'cls' => 'folder',
269
+ 'allowDrop' => false,
270
+ 'allowDrag' => false,
271
+ );
272
+ }
273
+
274
+ return Mage::helper('core')->jsonEncode($items);
275
+ }
276
+
277
+ /**
278
+ * Retrieve Back Button HTML
279
+ *
280
+ * @return string
281
+ */
282
+ public function getBackButtonHtml()
283
+ {
284
+ return $this->getChildHtml('back_button');
285
+ }
286
+
287
+ /**
288
+ * Retrieve Reset Button HTML
289
+ *
290
+ * @return string
291
+ */
292
+ public function getResetButtonHtml()
293
+ {
294
+ return $this->getChildHtml('reset_button');
295
+ }
296
+
297
+ /**
298
+ * Retrieve Save Button HTML
299
+ *
300
+ * @return string
301
+ */
302
+ public function getSaveButtonHtml()
303
+ {
304
+ return $this->getChildHtml('save_button');
305
+ }
306
+
307
+ /**
308
+ * Retrieve Delete Button HTML
309
+ *
310
+ * @return string
311
+ */
312
+ public function getDeleteButtonHtml()
313
+ {
314
+ if ($this->getIsCurrentSetDefault()) {
315
+ return '';
316
+ }
317
+ return $this->getChildHtml('delete_button');
318
+ }
319
+
320
+ /**
321
+ * Retrieve Delete Group Button HTML
322
+ *
323
+ * @return string
324
+ */
325
+ public function getDeleteGroupButton()
326
+ {
327
+ return $this->getChildHtml('delete_group_button');
328
+ }
329
+
330
+ /**
331
+ * Retrieve Add New Group Button HTML
332
+ *
333
+ * @return string
334
+ */
335
+ public function getAddGroupButton()
336
+ {
337
+ return $this->getChildHtml('add_group_button');
338
+ }
339
+
340
+ /**
341
+ * Retrieve Rename Button HTML
342
+ *
343
+ * @return string
344
+ */
345
+ public function getRenameButton()
346
+ {
347
+ return $this->getChildHtml('rename_button');
348
+ }
349
+
350
+ /**
351
+ * Retrieve current Attribute Set object
352
+ *
353
+ * @return Mage_Eav_Model_Entity_Attribute_Set
354
+ */
355
+ protected function _getAttributeSet()
356
+ {
357
+ return Mage::registry('current_attribute_set');
358
+ }
359
+
360
+ /**
361
+ * Retrieve current attribute set Id
362
+ *
363
+ * @return int
364
+ */
365
+ protected function _getSetId()
366
+ {
367
+ return $this->_getAttributeSet()->getId();
368
+ }
369
+
370
+ /**
371
+ * Check Current Attribute Set is a default
372
+ *
373
+ * @return bool
374
+ */
375
+ public function getIsCurrentSetDefault()
376
+ {
377
+ $isDefault = $this->getData('is_current_set_default');
378
+ if (is_null($isDefault)) {
379
+ $defaultSetId = Mage::getModel('eav/entity_type')
380
+ ->load(Mage::registry('entityType'))
381
+ ->getDefaultAttributeSetId();
382
+ $isDefault = $this->_getSetId() == $defaultSetId;
383
+ $this->setData('is_current_set_default', $isDefault);
384
+ }
385
+ return $isDefault;
386
+ }
387
+
388
+ /**
389
+ * Retrieve current Attribute Set object
390
+ *
391
+ * @deprecated use _getAttributeSet
392
+ * @return Mage_Eav_Model_Entity_Attribute_Set
393
+ */
394
+ protected function _getSetData()
395
+ {
396
+ return $this->_getAttributeSet();
397
+ }
398
+
399
+ /**
400
+ * Prepare HTML
401
+ *
402
+ * @return string
403
+ */
404
+ protected function _toHtml()
405
+ {
406
+ Mage::dispatchEvent('adminhtml_catalog_product_attribute_set_main_html_before', array('block' => $this));
407
+ return parent::_toHtml();
408
+ }
409
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * @category Mage
29
+ * @package Mage_Adminhtml
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+
33
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main_Formattribute extends Mage_Adminhtml_Block_Widget_Form
34
+ {
35
+ public function __construct()
36
+ {
37
+ parent::__construct();
38
+ }
39
+
40
+ protected function _prepareForm()
41
+ {
42
+ $form = new Varien_Data_Form();
43
+
44
+ $fieldset = $form->addFieldset('set_fieldset', array('legend'=>Mage::helper('catalog')->__('Add New Attribute')));
45
+
46
+ $fieldset->addField('new_attribute', 'text',
47
+ array(
48
+ 'label' => Mage::helper('catalog')->__('Name'),
49
+ 'name' => 'new_attribute',
50
+ 'required' => true,
51
+ )
52
+ );
53
+
54
+ $fieldset->addField('submit', 'note',
55
+ array(
56
+ 'text' => $this->getLayout()->createBlock('adminhtml/widget_button')
57
+ ->setData(array(
58
+ 'label' => Mage::helper('catalog')->__('Add Attribute'),
59
+ 'onclick' => 'this.form.submit();',
60
+ 'class' => 'add'
61
+ ))
62
+ ->toHtml(),
63
+ )
64
+ );
65
+
66
+ $form->setUseContainer(true);
67
+ $form->setMethod('post');
68
+ $this->setForm($form);
69
+ }
70
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * @category Mage
29
+ * @package Mage_Adminhtml
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+
33
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main_Formgroup extends Mage_Adminhtml_Block_Widget_Form
34
+ {
35
+ public function __construct()
36
+ {
37
+ parent::__construct();
38
+ }
39
+
40
+ protected function _prepareForm()
41
+ {
42
+ $form = new Varien_Data_Form();
43
+
44
+ $fieldset = $form->addFieldset('set_fieldset', array('legend'=>Mage::helper('catalog')->__('Add New Group')));
45
+
46
+ $fieldset->addField('attribute_group_name', 'text',
47
+ array(
48
+ 'label' => Mage::helper('catalog')->__('Name'),
49
+ 'name' => 'attribute_group_name',
50
+ 'required' => true,
51
+ )
52
+ );
53
+
54
+ $fieldset->addField('submit', 'note',
55
+ array(
56
+ 'text' => $this->getLayout()->createBlock('adminhtml/widget_button')
57
+ ->setData(array(
58
+ 'label' => Mage::helper('catalog')->__('Add Group'),
59
+ 'onclick' => 'this.form.submit();',
60
+ 'class' => 'add'
61
+ ))
62
+ ->toHtml(),
63
+ )
64
+ );
65
+
66
+ $fieldset->addField('attribute_set_id', 'hidden',
67
+ array(
68
+ 'name' => 'attribute_set_id',
69
+ 'value' => $this->_getSetId(),
70
+ )
71
+
72
+ );
73
+
74
+ $form->setUseContainer(true);
75
+ $form->setMethod('post');
76
+ $form->setAction($this->getUrl('*/catalog_product_group/save'));
77
+ $this->setForm($form);
78
+ }
79
+
80
+ protected function _getSetId()
81
+ {
82
+ return ( intval($this->getRequest()->getParam('id')) > 0 )
83
+ ? intval($this->getRequest()->getParam('id'))
84
+ : Mage::getModel('eav/entity_type')
85
+ ->load(Mage::registry('entityType'))
86
+ ->getDefaultAttributeSetId();
87
+ }
88
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * @category Mage
29
+ * @package Mage_Adminhtml
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+
33
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main_Formset extends Mage_Adminhtml_Block_Widget_Form
34
+ {
35
+ public function __construct()
36
+ {
37
+ parent::__construct();
38
+ }
39
+
40
+ protected function _prepareForm()
41
+ {
42
+ $data = Mage::getModel('eav/entity_attribute_set')
43
+ ->load($this->getRequest()->getParam('id'));
44
+
45
+ $form = new Varien_Data_Form();
46
+ $fieldset = $form->addFieldset('set_name', array('legend'=> Mage::helper('catalog')->__('Edit Set Name')));
47
+ $fieldset->addField('attribute_set_name', 'text',
48
+ array(
49
+ 'label' => Mage::helper('catalog')->__('Name'),
50
+ 'note' => Mage::helper('catalog')->__('For internal use.'),
51
+ 'name' => 'attribute_set_name',
52
+ 'required' => true,
53
+ 'class' => 'required-entry',
54
+ 'value' => $data->getAttributeSetName()
55
+ ));
56
+
57
+ if( !$this->getRequest()->getParam('id', false) ) {
58
+ $fieldset->addField('gotoEdit', 'hidden',
59
+ array(
60
+ 'name' => 'gotoEdit',
61
+ 'value' => '1'
62
+ ));
63
+
64
+ $sets = Mage::getModel('eav/entity_attribute_set')
65
+ ->getResourceCollection()
66
+ ->setEntityTypeFilter(Mage::registry('entityType'))
67
+ ->load()
68
+ ->toOptionArray();
69
+
70
+ $fieldset->addField('skeleton_set', 'select',
71
+ array(
72
+ 'label' => Mage::helper('catalog')->__('Based On'),
73
+ 'name' => 'skeleton_set',
74
+ 'required' => true,
75
+ 'class' => 'required-entry',
76
+ 'values' => $sets,
77
+ ));
78
+ }
79
+
80
+ $form->setMethod('post');
81
+ $form->setUseContainer(true);
82
+ $form->setId('set_prop_form');
83
+ $form->setAction($this->getUrl('*/*/save'));
84
+ $form->setOnsubmit('return false;');
85
+ $this->setForm($form);
86
+ }
87
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Attribute.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * @category Mage
29
+ * @package Mage_Adminhtml
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+
33
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main_Tree_Attribute extends Mage_Adminhtml_Block_Template
34
+ {
35
+ protected function _construct()
36
+ {
37
+ $this->setTemplate('catalog/product/attribute/set/main/tree/attribute.phtml');
38
+ }
39
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Tree/Group.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * @category Mage
29
+ * @package Mage_Adminhtml
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+
33
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main_Tree_Group extends Mage_Adminhtml_Block_Template
34
+ {
35
+ protected function _construct()
36
+ {
37
+ $this->setTemplate('catalog/product/attribute/set/main/tree/group.phtml');
38
+ }
39
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * description
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Add extends Mage_Adminhtml_Block_Template
35
+ {
36
+ protected function _construct()
37
+ {
38
+ $this->setTemplate('catalog/product/attribute/set/toolbar/add.phtml');
39
+ }
40
+
41
+ protected function _prepareLayout()
42
+ {
43
+ $this->setChild('save_button',
44
+ $this->getLayout()->createBlock('adminhtml/widget_button')
45
+ ->setData(array(
46
+ 'label' => Mage::helper('catalog')->__('Save Attribute Set'),
47
+ 'onclick' => 'addSet.submit();',
48
+ 'class' => 'save'
49
+ )));
50
+ $this->setChild('back_button',
51
+ $this->getLayout()->createBlock('adminhtml/widget_button')
52
+ ->setData(array(
53
+ 'label' => Mage::helper('catalog')->__('Back'),
54
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')',
55
+ 'class' => 'back'
56
+ )));
57
+
58
+ $this->setChild('setForm',
59
+ $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_set_main_formset')
60
+ );
61
+ return parent::_prepareLayout();
62
+ }
63
+
64
+ protected function _getHeader()
65
+ {
66
+ return Mage::helper('catalog')->__('Add New Attribute Set');
67
+ }
68
+
69
+ protected function getSaveButtonHtml()
70
+ {
71
+ return $this->getChildHtml('save_button');
72
+ }
73
+
74
+ protected function getBackButtonHtml()
75
+ {
76
+ return $this->getChildHtml('back_button');
77
+ }
78
+
79
+ protected function getFormHtml()
80
+ {
81
+ return $this->getChildHtml('setForm');
82
+ }
83
+
84
+ protected function getFormId()
85
+ {
86
+ return $this->getChild('setForm')->getForm()->getId();
87
+ }
88
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml catalog product sets main page toolbar
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Main extends Mage_Adminhtml_Block_Template
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setTemplate('catalog/product/attribute/set/toolbar/main.phtml');
41
+ }
42
+
43
+ protected function _prepareLayout()
44
+ {
45
+ $this->setChild('addButton',
46
+ $this->getLayout()->createBlock('adminhtml/widget_button')
47
+ ->setData(array(
48
+ 'label' => Mage::helper('catalog')->__('Add New Set'),
49
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/add') . '\')',
50
+ 'class' => 'add',
51
+ ))
52
+ );
53
+ return parent::_prepareLayout();
54
+ }
55
+
56
+ protected function getNewButtonHtml()
57
+ {
58
+ return $this->getChildHtml('addButton');
59
+ }
60
+
61
+ protected function _getHeader()
62
+ {
63
+ return Mage::helper('catalog')->__('Manage Attribute Sets');
64
+ }
65
+
66
+ protected function _toHtml()
67
+ {
68
+ Mage::dispatchEvent('adminhtml_catalog_product_attribute_set_toolbar_main_html_before', array('block' => $this));
69
+ return parent::_toHtml();
70
+ }
71
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main/Filter.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * @category Mage
29
+ * @package Mage_Adminhtml
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+
33
+ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Main_Filter extends Mage_Adminhtml_Block_Widget_Form
34
+ {
35
+ public function __construct()
36
+ {
37
+ parent::__construct();
38
+ }
39
+
40
+ protected function _prepareForm()
41
+ {
42
+ $form = new Varien_Data_Form();
43
+
44
+ $collection = Mage::getModel('eav/entity_attribute_set')
45
+ ->getResourceCollection()
46
+ ->load()
47
+ ->toOptionArray();
48
+
49
+ $form->addField('set_switcher', 'select',
50
+ array(
51
+ 'name' => 'set_switcher',
52
+ 'required' => true,
53
+ 'class' => 'left-col-block',
54
+ 'no_span' => true,
55
+ 'values' => $collection,
56
+ 'onchange' => 'this.form.submit()',
57
+ )
58
+ );
59
+
60
+ $form->setUseContainer(true);
61
+ $form->setMethod('post');
62
+ $this->setForm($form);
63
+ }
64
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Configure.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml catalog product composite configure block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Composite_Configure extends Mage_Adminhtml_Block_Widget
35
+ {
36
+ protected $_product;
37
+
38
+ /**
39
+ * Set template
40
+ */
41
+ protected function _construct()
42
+ {
43
+ $this->setTemplate('catalog/product/composite/configure.phtml');
44
+ }
45
+
46
+ /**
47
+ * Retrieve product object
48
+ *
49
+ * @return Mage_Catalog_Model_Product
50
+ */
51
+ public function getProduct()
52
+ {
53
+ if (!$this->_product) {
54
+ if (Mage::registry('current_product')) {
55
+ $this->_product = Mage::registry('current_product');
56
+ } else {
57
+ $this->_product = Mage::getSingleton('catalog/product');
58
+ }
59
+ }
60
+ return $this->_product;
61
+ }
62
+
63
+ /**
64
+ * Set product object
65
+ *
66
+ * @param Mage_Catalog_Model_Product $product
67
+ * @return Mage_Adminhtml_Block_Catalog_Product_Composite_Configure
68
+ */
69
+ public function setProduct(Mage_Catalog_Model_Product $product = null)
70
+ {
71
+ $this->_product = $product;
72
+ return $this;
73
+ }
74
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Error.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml block for showing product options fieldsets
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Composite_Error extends Mage_Core_Block_Template
35
+ {
36
+ /**
37
+ * Returns error message to show what kind of error happened during retrieving of product
38
+ * configuration controls
39
+ *
40
+ * @return string
41
+ */
42
+ public function _toHtml()
43
+ {
44
+ $message = Mage::registry('composite_configure_result_error_message');
45
+ return Mage::helper('core')->jsonEncode(array('error' => true, 'message' => $message));
46
+ }
47
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml block for showing product options fieldsets
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Composite_Fieldset extends Mage_Core_Block_Text_List
35
+ {
36
+ /**
37
+ *
38
+ * Iterates through fieldsets and fetches complete html
39
+ *
40
+ * @return string
41
+ */
42
+ protected function _toHtml()
43
+ {
44
+ $children = $this->getSortedChildren();
45
+ $total = count($children);
46
+ $i = 0;
47
+ $this->setText('');
48
+ foreach ($children as $name) {
49
+ $block = $this->getLayout()->getBlock($name);
50
+ if (!$block) {
51
+ Mage::throwException(Mage::helper('core')->__('Invalid block: %s', $name));
52
+ }
53
+
54
+ $i++;
55
+ $block->setIsLastFieldset($i == $total);
56
+
57
+ $this->addText($block->toHtml());
58
+ }
59
+
60
+ return parent::_toHtml();
61
+ }
62
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Configurable.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml block for fieldset of configurable product
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Composite_Fieldset_Configurable extends Mage_Catalog_Block_Product_View_Type_Configurable
35
+ {
36
+ /**
37
+ * Retrieve product
38
+ *
39
+ * @return Mage_Catalog_Model_Product
40
+ */
41
+ public function getProduct()
42
+ {
43
+ if (!$this->hasData('product')) {
44
+ $this->setData('product', Mage::registry('product'));
45
+ }
46
+ $product = $this->getData('product');
47
+ if (is_null($product->getTypeInstance(true)->getStoreFilter($product))) {
48
+ $product->getTypeInstance(true)->setStoreFilter(Mage::app()->getStore($product->getStoreId()), $product);
49
+ }
50
+
51
+ return $product;
52
+ }
53
+
54
+ /**
55
+ * Retrieve current store
56
+ *
57
+ * @return Mage_Core_Model_Store
58
+ */
59
+ public function getCurrentStore()
60
+ {
61
+ return Mage::app()->getStore($this->getProduct()->getStoreId());
62
+ }
63
+
64
+ /**
65
+ * Returns additional values for js config, con be overriden by descedants
66
+ *
67
+ * @return array
68
+ */
69
+ protected function _getAdditionalConfig()
70
+ {
71
+ $result = parent::_getAdditionalConfig();
72
+ $result['disablePriceReload'] = true; // There's no field for price at popup
73
+ $result['stablePrices'] = true; // We don't want to recalc prices displayed in OPTIONs of SELECT
74
+ return $result;
75
+ }
76
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Grouped.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml block for fieldset of grouped product
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Composite_Fieldset_Grouped extends Mage_Catalog_Block_Product_View_Type_Grouped
35
+ {
36
+ /**
37
+ * Redefine default price block
38
+ * Set current customer to tax calculation
39
+ */
40
+ protected function _construct()
41
+ {
42
+ parent::_construct();
43
+
44
+ $this->_block = 'adminhtml/catalog_product_price';
45
+ $this->_useLinkForAsLowAs = false;
46
+
47
+ $taxCalculation = Mage::getSingleton('tax/calculation');
48
+ if (!$taxCalculation->getCustomer() && Mage::registry('current_customer')) {
49
+ $taxCalculation->setCustomer(Mage::registry('current_customer'));
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Retrieve product
55
+ *
56
+ * @return Mage_Catalog_Model_Product
57
+ */
58
+ public function getProduct()
59
+ {
60
+ if (!$this->hasData('product')) {
61
+ $this->setData('product', Mage::registry('product'));
62
+ }
63
+ $product = $this->getData('product');
64
+ if (is_null($product->getTypeInstance(true)->getStoreFilter($product))) {
65
+ $product->getTypeInstance(true)->setStoreFilter(Mage::app()->getStore($product->getStoreId()), $product);
66
+ }
67
+
68
+ return $product;
69
+ }
70
+
71
+ /**
72
+ * Retrieve array of associated products
73
+ *
74
+ * @return array
75
+ */
76
+ public function getAssociatedProducts()
77
+ {
78
+ $product = $this->getProduct();
79
+ $result = $product->getTypeInstance(true)
80
+ ->getAssociatedProducts($product);
81
+
82
+ $storeId = $product->getStoreId();
83
+ foreach ($result as $item) {
84
+ $item->setStoreId($storeId);
85
+ }
86
+
87
+ return $result;
88
+ }
89
+
90
+
91
+ /**
92
+ * Set preconfigured values to grouped associated products
93
+ *
94
+ * @return Mage_Catalog_Block_Product_View_Type_Grouped
95
+ */
96
+ public function setPreconfiguredValue() {
97
+ $configValues = $this->getProduct()->getPreconfiguredValues()->getSuperGroup();
98
+ if (is_array($configValues)) {
99
+ $associatedProducts = $this->getAssociatedProducts();
100
+ foreach ($associatedProducts as $item) {
101
+ if (isset($configValues[$item->getId()])) {
102
+ $item->setQty($configValues[$item->getId()]);
103
+ }
104
+ }
105
+ }
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Check whether the price can be shown for the specified product
111
+ *
112
+ * @param Mage_Catalog_Model_Product $product
113
+ * @return bool
114
+ */
115
+ public function getCanShowProductPrice($product)
116
+ {
117
+ return true;
118
+ }
119
+
120
+ /**
121
+ * Checks whether block is last fieldset in popup
122
+ *
123
+ * @return bool
124
+ */
125
+ public function getIsLastFieldset()
126
+ {
127
+ $isLast = $this->getData('is_last_fieldset');
128
+ if (!$isLast) {
129
+ $options = $this->getProduct()->getOptions();
130
+ return !$options || !count($options);
131
+ }
132
+ return $isLast;
133
+ }
134
+
135
+ /**
136
+ * Returns price converted to current currency rate
137
+ *
138
+ * @param float $price
139
+ * @return float
140
+ */
141
+ public function getCurrencyPrice($price)
142
+ {
143
+ $store = $this->getProduct()->getStore();
144
+ return $this->helper('core')->currencyByStore($price, $store, false);
145
+ }
146
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Options.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml block for fieldset of product custom options
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Composite_Fieldset_Options extends Mage_Catalog_Block_Product_View_Options
35
+ {
36
+ /**
37
+ * Constructor for our block with options
38
+ *
39
+ * @return void
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ $this->addOptionRenderer(
45
+ 'default',
46
+ 'catalog/product_view_options_type_default',
47
+ 'catalog/product/composite/fieldset/options/type/default.phtml'
48
+ );
49
+ }
50
+
51
+ /**
52
+ * Get option html block
53
+ *
54
+ * @param Mage_Catalog_Model_Product_Option $option
55
+ *
56
+ * @return string
57
+ */
58
+ public function getOptionHtml(Mage_Catalog_Model_Product_Option $option)
59
+ {
60
+ $renderer = $this->getOptionRender(
61
+ $this->getGroupOfOption($option->getType())
62
+ );
63
+ if (is_null($renderer['renderer'])) {
64
+ $renderer['renderer'] = $this->getLayout()->createBlock($renderer['block'])
65
+ ->setTemplate($renderer['template'])
66
+ ->setSkipJsReloadPrice(1);
67
+ }
68
+ return $renderer['renderer']
69
+ ->setProduct($this->getProduct())
70
+ ->setOption($option)
71
+ ->toHtml();
72
+ }
73
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Fieldset/Qty.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml block for fieldset of product custom options
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Composite_Fieldset_Qty extends Mage_Core_Block_Template
35
+ {
36
+ /**
37
+ * Constructor for our block with options
38
+ *
39
+ * @return void
40
+ */
41
+ public function _construct()
42
+ {
43
+ parent::_construct();
44
+ $this->setIsLastFieldset(true);
45
+ }
46
+
47
+ /**
48
+ * Retrieve product
49
+ *
50
+ * @return Mage_Catalog_Model_Product
51
+ */
52
+ public function getProduct()
53
+ {
54
+ if (!$this->hasData('product')) {
55
+ $this->setData('product', Mage::registry('product'));
56
+ }
57
+ $product = $this->getData('product');
58
+
59
+ return $product;
60
+ }
61
+
62
+ /**
63
+ * Return selected qty
64
+ *
65
+ * @return int
66
+ */
67
+ public function getQtyValue()
68
+ {
69
+ $qty = $this->getProduct()->getPreconfiguredValues()->getQty();
70
+ if (!$qty) {
71
+ $qty = 1;
72
+ }
73
+ return $qty;
74
+ }
75
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Composite/Update/Result.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml block for result of catalog product composite update
29
+ * Forms response for a popup window for a case when form is directly submitted
30
+ * for single item
31
+ *
32
+ * @category Mage
33
+ * @package Mage_Adminhtml
34
+ * @author Magento Core Team <core@magentocommerce.com>
35
+ */
36
+ class Mage_Adminhtml_Block_Catalog_Product_Composite_Update_Result extends Mage_Core_Block_Template
37
+ {
38
+ /**
39
+ * Forms script response
40
+ *
41
+ * @return string
42
+ */
43
+ public function _toHtml()
44
+ {
45
+ $updateResult = Mage::registry('composite_update_result');
46
+ $resultJson = Mage::helper('core')->jsonEncode($updateResult);
47
+ $jsVarname = $updateResult->getJsVarName();
48
+ return Mage::helper('adminhtml/js')->getScript(sprintf('var %s = %s', $jsVarname, $resultJson));
49
+ }
50
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Created.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product after creation popup window
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Created extends Mage_Adminhtml_Block_Widget
35
+ {
36
+ protected $_configurableProduct;
37
+ protected $_product;
38
+
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setTemplate('catalog/product/created.phtml');
43
+ }
44
+
45
+
46
+ protected function _prepareLayout()
47
+ {
48
+ $this->setChild(
49
+ 'close_button',
50
+ $this->getLayout()->createBlock('adminhtml/widget_button')
51
+ ->setData(array(
52
+ 'label' => Mage::helper('catalog')->__('Close Window'),
53
+ 'onclick' => 'addProduct(true)'
54
+ ))
55
+ );
56
+ }
57
+
58
+
59
+ public function getCloseButtonHtml()
60
+ {
61
+ return $this->getChildHtml('close_button');
62
+ }
63
+
64
+ public function getProductId()
65
+ {
66
+ return (int) $this->getRequest()->getParam('id');
67
+ }
68
+
69
+ /**
70
+ * Indentifies edit mode of popup
71
+ *
72
+ * @return boolean
73
+ */
74
+ public function isEdit()
75
+ {
76
+ return (bool) $this->getRequest()->getParam('edit');
77
+ }
78
+
79
+ /**
80
+ * Retrive serialized json with configurable attributes values of simple
81
+ *
82
+ * @return string
83
+ */
84
+ public function getAttributesJson()
85
+ {
86
+ $result = array();
87
+ foreach ($this->getAttributes() as $attribute) {
88
+ $value = $this->getProduct()->getAttributeText($attribute->getAttributeCode());
89
+
90
+ $result[] = array(
91
+ 'label' => $value,
92
+ 'value_index' => $this->getProduct()->getData($attribute->getAttributeCode()),
93
+ 'attribute_id' => $attribute->getId()
94
+ );
95
+ }
96
+
97
+ return Mage::helper('core')->jsonEncode($result);
98
+ }
99
+
100
+ public function getAttributes()
101
+ {
102
+ if ($this->getConfigurableProduct()->getId()) {
103
+ return $this->getConfigurableProduct()->getTypeInstance(true)->getUsedProductAttributes($this->getConfigurableProduct());
104
+ }
105
+
106
+ $attributes = array();
107
+
108
+ $attributesIds = $this->getRequest()->getParam('required');
109
+ if ($attributesIds) {
110
+ $attributesIds = explode(',', $attributesIds);
111
+ foreach ($attributesIds as $attributeId) {
112
+ $attribute = $this->getProduct()->getTypeInstance(true)->getAttributeById($attributeId, $this->getProduct());
113
+ if (!$attribute) {
114
+ continue;
115
+ }
116
+ $attributes[] = $attribute;
117
+ }
118
+ }
119
+
120
+ return $attributes;
121
+ }
122
+
123
+ /**
124
+ * Retrive configurable product for created/edited simple
125
+ *
126
+ * @return Mage_Catalog_Model_Product
127
+ */
128
+ public function getConfigurableProduct()
129
+ {
130
+ if (is_null($this->_configurableProduct)) {
131
+ $this->_configurableProduct = Mage::getModel('catalog/product')
132
+ ->setStore(0)
133
+ ->load($this->getRequest()->getParam('product'));
134
+ }
135
+ return $this->_configurableProduct;
136
+ }
137
+
138
+ /**
139
+ * Retrive product
140
+ *
141
+ * @return Mage_Catalog_Model_Product
142
+ */
143
+ public function getProduct()
144
+ {
145
+ if (is_null($this->_product)) {
146
+ $this->_product = Mage::getModel('catalog/product')
147
+ ->setStore(0)
148
+ ->load($this->getRequest()->getParam('id'));
149
+ }
150
+ return $this->_product;
151
+ }
152
+ } // Class Mage_Adminhtml_Block_Catalog_Product_Created End
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer edit block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit extends Mage_Adminhtml_Block_Widget
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setTemplate('catalog/product/edit.phtml');
40
+ $this->setId('product_edit');
41
+ }
42
+
43
+ /**
44
+ * Retrieve currently edited product object
45
+ *
46
+ * @return Mage_Catalog_Model_Product
47
+ */
48
+ public function getProduct()
49
+ {
50
+ return Mage::registry('current_product');
51
+ }
52
+
53
+ protected function _prepareLayout()
54
+ {
55
+ if (!$this->getRequest()->getParam('popup')) {
56
+ $this->setChild('back_button',
57
+ $this->getLayout()->createBlock('adminhtml/widget_button')
58
+ ->setData(array(
59
+ 'label' => Mage::helper('catalog')->__('Back'),
60
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store', 0))).'\')',
61
+ 'class' => 'back'
62
+ ))
63
+ );
64
+ } else {
65
+ $this->setChild('back_button',
66
+ $this->getLayout()->createBlock('adminhtml/widget_button')
67
+ ->setData(array(
68
+ 'label' => Mage::helper('catalog')->__('Close Window'),
69
+ 'onclick' => 'window.close()',
70
+ 'class' => 'cancel'
71
+ ))
72
+ );
73
+ }
74
+
75
+ if (!$this->getProduct()->isReadonly()) {
76
+ $this->setChild('reset_button',
77
+ $this->getLayout()->createBlock('adminhtml/widget_button')
78
+ ->setData(array(
79
+ 'label' => Mage::helper('catalog')->__('Reset'),
80
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/*', array('_current'=>true)).'\')'
81
+ ))
82
+ );
83
+
84
+ $this->setChild('save_button',
85
+ $this->getLayout()->createBlock('adminhtml/widget_button')
86
+ ->setData(array(
87
+ 'label' => Mage::helper('catalog')->__('Save'),
88
+ 'onclick' => 'productForm.submit()',
89
+ 'class' => 'save'
90
+ ))
91
+ );
92
+ }
93
+
94
+ if (!$this->getRequest()->getParam('popup')) {
95
+ if (!$this->getProduct()->isReadonly()) {
96
+ $this->setChild('save_and_edit_button',
97
+ $this->getLayout()->createBlock('adminhtml/widget_button')
98
+ ->setData(array(
99
+ 'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
100
+ 'onclick' => 'saveAndContinueEdit(\''.$this->getSaveAndContinueUrl().'\')',
101
+ 'class' => 'save'
102
+ ))
103
+ );
104
+ }
105
+ if ($this->getProduct()->isDeleteable()) {
106
+ $this->setChild('delete_button',
107
+ $this->getLayout()->createBlock('adminhtml/widget_button')
108
+ ->setData(array(
109
+ 'label' => Mage::helper('catalog')->__('Delete'),
110
+ 'onclick' => 'confirmSetLocation(\''.Mage::helper('catalog')->__('Are you sure?').'\', \''.$this->getDeleteUrl().'\')',
111
+ 'class' => 'delete'
112
+ ))
113
+ );
114
+ }
115
+
116
+ if ($this->getProduct()->isDuplicable()) {
117
+ $this->setChild('duplicate_button',
118
+ $this->getLayout()->createBlock('adminhtml/widget_button')
119
+ ->setData(array(
120
+ 'label' => Mage::helper('catalog')->__('Duplicate'),
121
+ 'onclick' => 'setLocation(\'' . $this->getDuplicateUrl() . '\')',
122
+ 'class' => 'add'
123
+ ))
124
+ );
125
+ }
126
+ }
127
+
128
+ return parent::_prepareLayout();
129
+ }
130
+
131
+ public function getBackButtonHtml()
132
+ {
133
+ return $this->getChildHtml('back_button');
134
+ }
135
+
136
+ public function getCancelButtonHtml()
137
+ {
138
+ return $this->getChildHtml('reset_button');
139
+ }
140
+
141
+ public function getSaveButtonHtml()
142
+ {
143
+ return $this->getChildHtml('save_button');
144
+ }
145
+
146
+ public function getSaveAndEditButtonHtml()
147
+ {
148
+ return $this->getChildHtml('save_and_edit_button');
149
+ }
150
+
151
+ public function getDeleteButtonHtml()
152
+ {
153
+ return $this->getChildHtml('delete_button');
154
+ }
155
+
156
+ public function getDuplicateButtonHtml()
157
+ {
158
+ return $this->getChildHtml('duplicate_button');
159
+ }
160
+
161
+ public function getValidationUrl()
162
+ {
163
+ return $this->getUrl('*/*/validate', array('_current'=>true));
164
+ }
165
+
166
+ public function getSaveUrl()
167
+ {
168
+ return $this->getUrl('*/*/save', array('_current'=>true, 'back'=>null));
169
+ }
170
+
171
+ public function getSaveAndContinueUrl()
172
+ {
173
+ return $this->getUrl('*/*/save', array(
174
+ '_current' => true,
175
+ 'back' => 'edit',
176
+ 'tab' => '{{tab_id}}',
177
+ 'active_tab' => null
178
+ ));
179
+ }
180
+
181
+ public function getProductId()
182
+ {
183
+ return $this->getProduct()->getId();
184
+ }
185
+
186
+ public function getProductSetId()
187
+ {
188
+ $setId = false;
189
+ if (!($setId = $this->getProduct()->getAttributeSetId()) && $this->getRequest()) {
190
+ $setId = $this->getRequest()->getParam('set', null);
191
+ }
192
+ return $setId;
193
+ }
194
+
195
+ public function getIsGrouped()
196
+ {
197
+ return $this->getProduct()->isGrouped();
198
+ }
199
+
200
+ public function getDeleteUrl()
201
+ {
202
+ return $this->getUrl('*/*/delete', array('_current'=>true));
203
+ }
204
+
205
+ public function getDuplicateUrl()
206
+ {
207
+ return $this->getUrl('*/*/duplicate', array('_current'=>true));
208
+ }
209
+
210
+ public function getHeader()
211
+ {
212
+ $header = '';
213
+ if ($this->getProduct()->getId()) {
214
+ $header = $this->htmlEscape($this->getProduct()->getName());
215
+ }
216
+ else {
217
+ $header = Mage::helper('catalog')->__('New Product');
218
+ }
219
+ if ($setName = $this->getAttributeSetName()) {
220
+ $header.= ' (' . $setName . ')';
221
+ }
222
+ return $header;
223
+ }
224
+
225
+ public function getAttributeSetName()
226
+ {
227
+ if ($setId = $this->getProduct()->getAttributeSetId()) {
228
+ $set = Mage::getModel('eav/entity_attribute_set')
229
+ ->load($setId);
230
+ return $set->getAttributeSetName();
231
+ }
232
+ return '';
233
+ }
234
+
235
+ public function getIsConfigured()
236
+ {
237
+ if ($this->getProduct()->isConfigurable()
238
+ && !($superAttributes = $this->getProduct()->getTypeInstance(true)->getUsedProductAttributeIds($this->getProduct()))) {
239
+ $superAttributes = false;
240
+ }
241
+
242
+ return !$this->getProduct()->isConfigurable() || $superAttributes !== false;
243
+ }
244
+
245
+ public function getSelectedTabId()
246
+ {
247
+ return addslashes(htmlspecialchars($this->getRequest()->getParam('tab')));
248
+ }
249
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml catalog product action attribute update
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Action_Attribute extends Mage_Adminhtml_Block_Widget
36
+ {
37
+
38
+ protected function _prepareLayout()
39
+ {
40
+ $this->setChild('back_button',
41
+ $this->getLayout()->createBlock('adminhtml/widget_button')
42
+ ->setData(array(
43
+ 'label' => Mage::helper('catalog')->__('Back'),
44
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/catalog_product/', array('store'=>$this->getRequest()->getParam('store', 0))).'\')',
45
+ 'class' => 'back'
46
+ ))
47
+ );
48
+
49
+ $this->setChild('reset_button',
50
+ $this->getLayout()->createBlock('adminhtml/widget_button')
51
+ ->setData(array(
52
+ 'label' => Mage::helper('catalog')->__('Reset'),
53
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/*', array('_current'=>true)).'\')'
54
+ ))
55
+ );
56
+
57
+ $this->setChild('save_button',
58
+ $this->getLayout()->createBlock('adminhtml/widget_button')
59
+ ->setData(array(
60
+ 'label' => Mage::helper('catalog')->__('Save'),
61
+ 'onclick' => 'attributesForm.submit()',
62
+ 'class' => 'save'
63
+ ))
64
+ );
65
+ }
66
+
67
+ /**
68
+ * Retrieve selected products for update
69
+ *
70
+ * @return unknown
71
+ */
72
+ public function getProducts()
73
+ {
74
+ return $this->_getHelper()->getProducts();
75
+ }
76
+
77
+ /**
78
+ * Retrieve block attributes update helper
79
+ *
80
+ * @return Mage_Adminhtml_Helper_Catalog_Product_Edit_Action_Attribute
81
+ */
82
+ protected function _getHelper()
83
+ {
84
+ return $this->helper('adminhtml/catalog_product_edit_action_attribute');
85
+ }
86
+
87
+ /**
88
+ * Retrieve back button html code
89
+ *
90
+ * @return string
91
+ */
92
+ public function getBackButtonHtml()
93
+ {
94
+ return $this->getChildHtml('back_button');
95
+ }
96
+
97
+ /**
98
+ * Retrieve cancel button html code
99
+ *
100
+ * @return string
101
+ */
102
+ public function getCancelButtonHtml()
103
+ {
104
+ return $this->getChildHtml('reset_button');
105
+ }
106
+
107
+ /**
108
+ * Retrieve save button html code
109
+ *
110
+ * @return string
111
+ */
112
+ public function getSaveButtonHtml()
113
+ {
114
+ return $this->getChildHtml('save_button');
115
+ }
116
+
117
+ /**
118
+ * Get save url
119
+ *
120
+ * @return string
121
+ */
122
+ public function getSaveUrl()
123
+ {
124
+ return $this->getUrl('*/*/save', array('store'=>Mage::helper('adminhtml/catalog_product_edit_action_attribute')->getSelectedStoreId()));
125
+ }
126
+
127
+ /**
128
+ * Get validation url
129
+ *
130
+ * @return string
131
+ */
132
+ public function getValidationUrl()
133
+ {
134
+ return $this->getUrl('*/*/validate', array('_current'=>true));
135
+ }
136
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Attributes.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml catalog product edit action attributes update tab block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Action_Attribute_Tab_Attributes
36
+ extends Mage_Adminhtml_Block_Catalog_Form
37
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
38
+ {
39
+ protected function _construct()
40
+ {
41
+ parent::_construct();
42
+ $this->setShowGlobalIcon(true);
43
+ }
44
+
45
+ protected function _prepareForm()
46
+ {
47
+ $this->setFormExcludedFieldList(array('tier_price','gallery', 'media_gallery', 'recurring_profile'));
48
+ Mage::dispatchEvent('adminhtml_catalog_product_form_prepare_excluded_field_list', array('object'=>$this));
49
+
50
+ $form = new Varien_Data_Form();
51
+ $fieldset = $form->addFieldset('fields', array('legend'=>Mage::helper('catalog')->__('Attributes')));
52
+ $attributes = $this->getAttributes();
53
+ /**
54
+ * Initialize product object as form property
55
+ * for using it in elements generation
56
+ */
57
+ $form->setDataObject(Mage::getModel('catalog/product'));
58
+ $this->_setFieldset($attributes, $fieldset, $this->getFormExcludedFieldList());
59
+ $form->setFieldNameSuffix('attributes');
60
+ $this->setForm($form);
61
+ }
62
+
63
+ /**
64
+ * Retrive attributes for product massupdate
65
+ *
66
+ * @return array
67
+ */
68
+ public function getAttributes()
69
+ {
70
+ return $this->helper('adminhtml/catalog_product_edit_action_attribute')->getAttributes()->getItems();
71
+ }
72
+
73
+ /**
74
+ * Additional element types for product attributes
75
+ *
76
+ * @return array
77
+ */
78
+ protected function _getAdditionalElementTypes()
79
+ {
80
+ return array(
81
+ 'price' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'),
82
+ 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'),
83
+ 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean')
84
+ );
85
+ }
86
+
87
+ /**
88
+ * Custom additional elemnt html
89
+ *
90
+ * @param Varien_Data_Form_Element_Abstract $element
91
+ * @return string
92
+ */
93
+ protected function _getAdditionalElementHtml($element)
94
+ {
95
+ return '<span class="attribute-change-checkbox"><input type="checkbox" id="' . $element->getId()
96
+ . '-checkbox" onclick="toogleFieldEditMode(this, \'' . $element->getId()
97
+ . '\')" /><label for="' . $element->getId() . '-checkbox">' . Mage::helper('catalog')->__('Change')
98
+ . '</label></span>
99
+ <script type="text/javascript">initDisableFields(\''.$element->getId().'\')</script>';
100
+ }
101
+
102
+ /**
103
+ * ######################## TAB settings #################################
104
+ */
105
+ public function getTabLabel()
106
+ {
107
+ return Mage::helper('catalog')->__('Attributes');
108
+ }
109
+
110
+ public function getTabTitle()
111
+ {
112
+ return Mage::helper('catalog')->__('Attributes');
113
+ }
114
+
115
+ public function canShowTab()
116
+ {
117
+ return true;
118
+ }
119
+
120
+ public function isHidden()
121
+ {
122
+ return false;
123
+ }
124
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Inventory.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Products mass update inventory tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Action_Attribute_Tab_Inventory
35
+ extends Mage_Adminhtml_Block_Widget
36
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
+ {
38
+ /**
39
+ * Retrieve Backorders Options
40
+ *
41
+ * @return array
42
+ */
43
+ public function getBackordersOption()
44
+ {
45
+ return Mage::getSingleton('cataloginventory/source_backorders')->toOptionArray();
46
+ }
47
+
48
+ /**
49
+ * Retrieve field suffix
50
+ *
51
+ * @return string
52
+ */
53
+ public function getFieldSuffix()
54
+ {
55
+ return 'inventory';
56
+ }
57
+
58
+ /**
59
+ * Retrieve current store id
60
+ *
61
+ * @return int
62
+ */
63
+ public function getStoreId()
64
+ {
65
+ $storeId = $this->getRequest()->getParam('store');
66
+ return intval($storeId);
67
+ }
68
+
69
+ /**
70
+ * Get default config value
71
+ *
72
+ * @param string $field
73
+ * @return mixed
74
+ */
75
+ public function getDefaultConfigValue($field)
76
+ {
77
+ return Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_ITEM . $field, $this->getStoreId());
78
+ }
79
+
80
+ /**
81
+ * ######################## TAB settings #################################
82
+ */
83
+ public function getTabLabel()
84
+ {
85
+ return Mage::helper('catalog')->__('Inventory');
86
+ }
87
+
88
+ public function getTabTitle()
89
+ {
90
+ return Mage::helper('catalog')->__('Inventory');
91
+ }
92
+
93
+ public function canShowTab()
94
+ {
95
+ return true;
96
+ }
97
+
98
+ public function isHidden()
99
+ {
100
+ return false;
101
+ }
102
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tab/Websites.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product mass attribute update websites tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Action_Attribute_Tab_Websites
35
+ extends Mage_Adminhtml_Block_Widget
36
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
+ {
38
+ public function getWebsiteCollection()
39
+ {
40
+ return Mage::app()->getWebsites();
41
+ }
42
+
43
+ public function getGroupCollection(Mage_Core_Model_Website $website)
44
+ {
45
+ return $website->getGroups();
46
+ }
47
+
48
+ public function getStoreCollection(Mage_Core_Model_Store_Group $group)
49
+ {
50
+ return $group->getStores();
51
+ }
52
+
53
+ /**
54
+ * ######################## TAB settings #################################
55
+ */
56
+ public function getTabLabel()
57
+ {
58
+ return Mage::helper('catalog')->__('Websites');
59
+ }
60
+
61
+ public function getTabTitle()
62
+ {
63
+ return Mage::helper('catalog')->__('Websites');
64
+ }
65
+
66
+ public function canShowTab()
67
+ {
68
+ return true;
69
+ }
70
+
71
+ public function isHidden()
72
+ {
73
+ return false;
74
+ }
75
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute/Tabs.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml catalog product edit action attributes update tabs block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Action_Attribute_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
36
+ {
37
+ protected function _construct()
38
+ {
39
+ parent::_construct();
40
+
41
+ $this->setId('attributes_update_tabs');
42
+ $this->setDestElementId('attributes_edit_form');
43
+ $this->setTitle(Mage::helper('catalog')->__('Products Information'));
44
+ }
45
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Js.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Js extends Mage_Adminhtml_Block_Template
28
+ {
29
+ /**
30
+ * Get currently edited product
31
+ *
32
+ * @return Mage_Catalog_Model_Product
33
+ */
34
+ public function getProduct()
35
+ {
36
+ return Mage::registry('current_product');
37
+ }
38
+
39
+ /**
40
+ * Get store object of curently edited product
41
+ *
42
+ * @return Mage_Core_Model_Store
43
+ */
44
+ public function getStore()
45
+ {
46
+ $product = $this->getProduct();
47
+ if ($product) {
48
+ return Mage::app()->getStore($product->getStoreId());
49
+ }
50
+ return Mage::app()->getStore();
51
+ }
52
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ *
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Ajax_Serializer extends Mage_Core_Block_Template
35
+ {
36
+ public function _construct()
37
+ {
38
+ parent::_construct();
39
+ $this->setTemplate('catalog/product/edit/serializer.phtml');
40
+ return $this;
41
+ }
42
+
43
+ public function getProductsJSON()
44
+ {
45
+ $result = array();
46
+ if ($this->getProducts()) {
47
+ $isEntityId = $this->getIsEntityId();
48
+ foreach ($this->getProducts() as $product) {
49
+ $id = $isEntityId ? $product->getEntityId() : $product->getId();
50
+ $result[$id] = $product->toArray(array('qty', 'position'));
51
+ }
52
+ }
53
+ return $result ? Zend_Json::encode($result) : '{}';
54
+ }
55
+
56
+ /**
57
+ * Initialize grid block under the "Related Products", "Up-sells", "Cross-sells" sections
58
+ *
59
+ * @param string $blockName
60
+ * @param string $getProductFunction
61
+ * @param string $inputName
62
+ */
63
+ public function initSerializerBlock($blockName, $getProductFunction, $inputName)
64
+ {
65
+ if ($block = $this->getLayout()->getBlock($blockName)) {
66
+ $this->setGridBlock($block)
67
+ ->setProducts(Mage::registry('current_product')->$getProductFunction())
68
+ ->setInputElementName($inputName);
69
+ }
70
+ }
71
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Product alerts tab
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+
36
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts extends Mage_Adminhtml_Block_Template
37
+ {
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setTemplate('catalog/product/tab/alert.phtml');
42
+ }
43
+
44
+ protected function _prepareLayout()
45
+ {
46
+ $accordion = $this->getLayout()->createBlock('adminhtml/widget_accordion')
47
+ ->setId('productAlerts');
48
+ /* @var $accordion Mage_Adminhtml_Block_Widget_Accordion */
49
+
50
+ $alertPriceAllow = Mage::getStoreConfig('catalog/productalert/allow_price');
51
+ $alertStockAllow = Mage::getStoreConfig('catalog/productalert/allow_stock');
52
+
53
+ if ($alertPriceAllow) {
54
+ $accordion->addItem('price', array(
55
+ 'title' => Mage::helper('adminhtml')->__('Price alert subscription was saved.'),
56
+ 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_alerts_price')->toHtml() . '<br />',
57
+ 'open' => true
58
+ ));
59
+ }
60
+ if ($alertStockAllow) {
61
+ $accordion->addItem('stock', array(
62
+ 'title' => Mage::helper('adminhtml')->__('Stock notification was saved.'),
63
+ 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_alerts_stock'),
64
+ 'open' => true
65
+ ));
66
+ }
67
+
68
+ $this->setChild('accordion', $accordion);
69
+
70
+ return parent::_prepareLayout();
71
+ }
72
+
73
+ public function getAccordionHtml()
74
+ {
75
+ return $this->getChildHtml('accordion');
76
+ }
77
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Sign up for an alert when the product price changes grid
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts_Price extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+
41
+ $this->setId('alertPrice');
42
+ $this->setDefaultSort('add_date');
43
+ $this->setDefaultSort('DESC');
44
+ $this->setUseAjax(true);
45
+ $this->setFilterVisibility(false);
46
+ $this->setEmptyText(Mage::helper('catalog')->__('There are no customers for this alert'));
47
+ }
48
+
49
+ protected function _prepareCollection()
50
+ {
51
+ $productId = $this->getRequest()->getParam('id');
52
+ $websiteId = 0;
53
+ if ($store = $this->getRequest()->getParam('store')) {
54
+ $websiteId = Mage::app()->getStore($store)->getWebsiteId();
55
+ }
56
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_ProductAlert')) {
57
+ $collection = Mage::getModel('productalert/price')
58
+ ->getCustomerCollection()
59
+ ->join($productId, $websiteId);
60
+ $this->setCollection($collection);
61
+ }
62
+ return parent::_prepareCollection();
63
+ }
64
+
65
+ protected function _prepareColumns()
66
+ {
67
+ $this->addColumn('firstname', array(
68
+ 'header' => Mage::helper('catalog')->__('First Name'),
69
+ 'index' => 'firstname',
70
+ ));
71
+
72
+ $this->addColumn('lastname', array(
73
+ 'header' => Mage::helper('catalog')->__('Last Name'),
74
+ 'index' => 'lastname',
75
+ ));
76
+
77
+ $this->addColumn('email', array(
78
+ 'header' => Mage::helper('catalog')->__('Email'),
79
+ 'index' => 'email',
80
+ ));
81
+
82
+ $this->addColumn('price', array(
83
+ 'header' => Mage::helper('catalog')->__('Price'),
84
+ 'index' => 'price',
85
+ 'type' => 'currency',
86
+ 'currency_code'
87
+ => Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE)
88
+ ));
89
+
90
+ $this->addColumn('add_date', array(
91
+ 'header' => Mage::helper('catalog')->__('Date Subscribed'),
92
+ 'index' => 'add_date',
93
+ 'type' => 'date'
94
+ ));
95
+
96
+ $this->addColumn('last_send_date', array(
97
+ 'header' => Mage::helper('catalog')->__('Last Notification'),
98
+ 'index' => 'last_send_date',
99
+ 'type' => 'date'
100
+ ));
101
+
102
+ $this->addColumn('send_count', array(
103
+ 'header' => Mage::helper('catalog')->__('Send Count'),
104
+ 'index' => 'send_count',
105
+ ));
106
+
107
+ return parent::_prepareColumns();
108
+ }
109
+
110
+ public function getGridUrl()
111
+ {
112
+ $productId = $this->getRequest()->getParam('id');
113
+ $storeId = $this->getRequest()->getParam('store', 0);
114
+ if ($storeId) {
115
+ $storeId = Mage::app()->getStore($storeId)->getId();
116
+ }
117
+ return $this->getUrl('*/catalog_product/alertsPriceGrid', array(
118
+ 'id' => $productId,
119
+ 'store' => $storeId
120
+ ));
121
+ }
122
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Sign up for an alert when the product price changes grid
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts_Stock extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+
41
+ $this->setId('alertStock');
42
+ $this->setDefaultSort('add_date');
43
+ $this->setDefaultSort('DESC');
44
+ $this->setUseAjax(true);
45
+ $this->setFilterVisibility(false);
46
+ $this->setEmptyText(Mage::helper('catalog')->__('There are no customers for this alert.'));
47
+ }
48
+
49
+ protected function _prepareCollection()
50
+ {
51
+ $productId = $this->getRequest()->getParam('id');
52
+ $websiteId = 0;
53
+ if ($store = $this->getRequest()->getParam('store')) {
54
+ $websiteId = Mage::app()->getStore($store)->getWebsiteId();
55
+ }
56
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_ProductAlert')) {
57
+ $collection = Mage::getModel('productalert/stock')
58
+ ->getCustomerCollection()
59
+ ->join($productId, $websiteId);
60
+ $this->setCollection($collection);
61
+ }
62
+ return parent::_prepareCollection();
63
+ }
64
+
65
+ protected function _prepareColumns()
66
+ {
67
+ $this->addColumn('firstname', array(
68
+ 'header' => Mage::helper('catalog')->__('First Name'),
69
+ 'index' => 'firstname',
70
+ ));
71
+
72
+ $this->addColumn('lastname', array(
73
+ 'header' => Mage::helper('catalog')->__('Last Name'),
74
+ 'index' => 'lastname',
75
+ ));
76
+
77
+ $this->addColumn('email', array(
78
+ 'header' => Mage::helper('catalog')->__('Email'),
79
+ 'index' => 'email',
80
+ ));
81
+
82
+ $this->addColumn('add_date', array(
83
+ 'header' => Mage::helper('catalog')->__('Date Subscribed'),
84
+ 'index' => 'add_date',
85
+ 'type' => 'date'
86
+ ));
87
+
88
+ $this->addColumn('send_date', array(
89
+ 'header' => Mage::helper('catalog')->__('Last Notification'),
90
+ 'index' => 'send_date',
91
+ 'type' => 'date'
92
+ ));
93
+
94
+ $this->addColumn('send_count', array(
95
+ 'header' => Mage::helper('catalog')->__('Send Count'),
96
+ 'index' => 'send_count',
97
+ ));
98
+
99
+ return parent::_prepareColumns();
100
+ }
101
+
102
+ public function getGridUrl()
103
+ {
104
+ $productId = $this->getRequest()->getParam('id');
105
+ $storeId = $this->getRequest()->getParam('store', 0);
106
+ if ($storeId) {
107
+ $storeId = Mage::app()->getStore($storeId)->getId();
108
+ }
109
+ return $this->getUrl('*/catalog_product/alertsStockGrid', array(
110
+ 'id' => $productId,
111
+ 'store' => $storeId
112
+ ));
113
+ }
114
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product attributes tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes extends Mage_Adminhtml_Block_Catalog_Form
35
+ {
36
+ /**
37
+ * Load Wysiwyg on demand and Prepare layout
38
+ */
39
+ protected function _prepareLayout()
40
+ {
41
+ parent::_prepareLayout();
42
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Cms')) {
43
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
44
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
45
+ }
46
+ }
47
+ }
48
+
49
+ protected function _prepareForm()
50
+ {
51
+ if ($group = $this->getGroup()) {
52
+ $form = new Varien_Data_Form();
53
+ /**
54
+ * Initialize product object as form property
55
+ * for using it in elements generation
56
+ */
57
+ $form->setDataObject(Mage::registry('product'));
58
+
59
+ $fieldset = $form->addFieldset('group_fields'.$group->getId(),
60
+ array(
61
+ 'legend'=>Mage::helper('catalog')->__($group->getAttributeGroupName()),
62
+ 'class'=>'fieldset-wide',
63
+ ));
64
+
65
+ $attributes = $this->getGroupAttributes();
66
+
67
+ $this->_setFieldset($attributes, $fieldset, array('gallery'));
68
+
69
+ if ($urlKey = $form->getElement('url_key')) {
70
+ $urlKey->setRenderer(
71
+ $this->getLayout()->createBlock('adminhtml/catalog_form_renderer_attribute_urlkey')
72
+ );
73
+ }
74
+
75
+ if ($tierPrice = $form->getElement('tier_price')) {
76
+ $tierPrice->setRenderer(
77
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_tier')
78
+ );
79
+ }
80
+
81
+ if ($recurringProfile = $form->getElement('recurring_profile')) {
82
+ $recurringProfile->setRenderer(
83
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_recurring')
84
+ );
85
+ }
86
+
87
+ /**
88
+ * Add new attribute button if not image tab
89
+ */
90
+ if (!$form->getElement('media_gallery')
91
+ && Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes')) {
92
+ $headerBar = $this->getLayout()->createBlock(
93
+ 'adminhtml/catalog_product_edit_tab_attributes_create'
94
+ );
95
+
96
+ $headerBar->getConfig()
97
+ ->setTabId('group_' . $group->getId())
98
+ ->setGroupId($group->getId())
99
+ ->setStoreId($form->getDataObject()->getStoreId())
100
+ ->setAttributeSetId($form->getDataObject()->getAttributeSetId())
101
+ ->setTypeId($form->getDataObject()->getTypeId())
102
+ ->setProductId($form->getDataObject()->getId());
103
+
104
+ $fieldset->setHeaderBar(
105
+ $headerBar->toHtml()
106
+ );
107
+ }
108
+
109
+ if ($form->getElement('meta_description')) {
110
+ $form->getElement('meta_description')->setOnkeyup('checkMaxLength(this, 255);');
111
+ }
112
+
113
+ $values = Mage::registry('product')->getData();
114
+ /**
115
+ * Set attribute default values for new product
116
+ */
117
+ if (!Mage::registry('product')->getId()) {
118
+ foreach ($attributes as $attribute) {
119
+ if (!isset($values[$attribute->getAttributeCode()])) {
120
+ $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
121
+ }
122
+ }
123
+ }
124
+
125
+ if (Mage::registry('product')->hasLockedAttributes()) {
126
+ foreach (Mage::registry('product')->getLockedAttributes() as $attribute) {
127
+ if ($element = $form->getElement($attribute)) {
128
+ $element->setReadonly(true, true);
129
+ }
130
+ }
131
+ }
132
+ $form->addValues($values);
133
+ $form->setFieldNameSuffix('product');
134
+
135
+ Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form'=>$form));
136
+
137
+ $this->setForm($form);
138
+ }
139
+ }
140
+
141
+ protected function _getAdditionalElementTypes()
142
+ {
143
+ $result = array(
144
+ 'price' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'),
145
+ 'gallery' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_gallery'),
146
+ 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'),
147
+ 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean'),
148
+ 'textarea' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_helper_form_wysiwyg')
149
+ );
150
+
151
+ $response = new Varien_Object();
152
+ $response->setTypes(array());
153
+ Mage::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response'=>$response));
154
+
155
+ foreach ($response->getTypes() as $typeName=>$typeClass) {
156
+ $result[$typeName] = $typeClass;
157
+ }
158
+
159
+ return $result;
160
+ }
161
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * New attribute panel on product edit page
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create extends Mage_Adminhtml_Block_Widget_Button
35
+ {
36
+ /**
37
+ * Config of create new attribute
38
+ *
39
+ * @var Varien_Object
40
+ */
41
+ protected $_config = null;
42
+
43
+ /**
44
+ * Retrive config of new attribute creation
45
+ *
46
+ * @return Varien_Object
47
+ */
48
+ public function getConfig()
49
+ {
50
+ if (is_null($this->_config)) {
51
+ $this->_config = new Varien_Object();
52
+ }
53
+
54
+ return $this->_config;
55
+ }
56
+
57
+ protected function _beforeToHtml()
58
+ {
59
+ $this->setId('create_attribute_' . $this->getConfig()->getGroupId())
60
+ ->setOnClick($this->getJsObjectName() . '.create();')
61
+ ->setType('button')
62
+ ->setClass('add')
63
+ ->setLabel(Mage::helper('adminhtml')->__('Create New Attribute'));
64
+
65
+ $this->getConfig()
66
+ ->setUrl($this->getUrl(
67
+ '*/catalog_product_attribute/new',
68
+ array(
69
+ 'group' => $this->getConfig()->getGroupId(),
70
+ 'tab' => $this->getConfig()->getTabId(),
71
+ 'store' => $this->getConfig()->getStoreId(),
72
+ 'product' => $this->getConfig()->getProductId(),
73
+ 'set' => $this->getConfig()->getAttributeSetId(),
74
+ 'type' => $this->getConfig()->getTypeId(),
75
+ 'popup' => 1
76
+ )
77
+ ));
78
+
79
+ return parent::_beforeToHtml();
80
+ }
81
+
82
+ protected function _toHtml()
83
+ {
84
+ $this->setCanShow(true);
85
+ Mage::dispatchEvent('adminhtml_catalog_product_edit_tab_attributes_create_html_before', array('block' => $this));
86
+ if (!$this->getCanShow()) {
87
+ return '';
88
+ }
89
+
90
+ $html = parent::_toHtml();
91
+ $html .= Mage::helper('adminhtml/js')->getScript(
92
+ "var {$this->getJsObjectName()} = new Product.Attributes('{$this->getId()}');\n"
93
+ . "{$this->getJsObjectName()}.setConfig(" . Mage::helper('core')->jsonEncode($this->getConfig()->getData()) . ");\n"
94
+ );
95
+
96
+ return $html;
97
+ }
98
+
99
+ public function getJsObjectName()
100
+ {
101
+ return $this->getId() . 'JsObject';
102
+ }
103
+ } // Class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create End
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product categories tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Categories extends Mage_Adminhtml_Block_Catalog_Category_Tree
35
+ {
36
+ protected $_categoryIds;
37
+ protected $_selectedNodes = null;
38
+
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setTemplate('catalog/product/edit/categories.phtml');
43
+ }
44
+
45
+ /**
46
+ * Retrieve currently edited product
47
+ *
48
+ * @return Mage_Catalog_Model_Product
49
+ */
50
+ public function getProduct()
51
+ {
52
+ return Mage::registry('current_product');
53
+ }
54
+
55
+ /**
56
+ * Checks when this block is readonly
57
+ *
58
+ * @return boolean
59
+ */
60
+ public function isReadonly()
61
+ {
62
+ return $this->getProduct()->getCategoriesReadonly();
63
+ }
64
+
65
+ protected function getCategoryIds()
66
+ {
67
+ return $this->getProduct()->getCategoryIds();
68
+ }
69
+
70
+ public function getIdsString()
71
+ {
72
+ return implode(',', $this->getCategoryIds());
73
+ }
74
+
75
+ public function getRootNode()
76
+ {
77
+ // $root = parent::getRoot();
78
+ $root = $this->getRoot();
79
+ if ($root && in_array($root->getId(), $this->getCategoryIds())) {
80
+ $root->setChecked(true);
81
+ }
82
+ return $root;
83
+ }
84
+
85
+ public function getRoot($parentNodeCategory=null, $recursionLevel=3)
86
+ {
87
+ if (!is_null($parentNodeCategory) && $parentNodeCategory->getId()) {
88
+ return $this->getNode($parentNodeCategory, $recursionLevel);
89
+ }
90
+ $root = Mage::registry('root');
91
+ if (is_null($root)) {
92
+ $storeId = (int) $this->getRequest()->getParam('store');
93
+
94
+ if ($storeId) {
95
+ $store = Mage::app()->getStore($storeId);
96
+ $rootId = $store->getRootCategoryId();
97
+ }
98
+ else {
99
+ $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID;
100
+ }
101
+
102
+ $ids = $this->getSelectedCategoriesPathIds($rootId);
103
+ $tree = Mage::getResourceSingleton('catalog/category_tree')
104
+ ->loadByIds($ids, false, false);
105
+
106
+ if ($this->getCategory()) {
107
+ $tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId));
108
+ }
109
+
110
+ $tree->addCollectionData($this->getCategoryCollection());
111
+
112
+ $root = $tree->getNodeById($rootId);
113
+
114
+ if ($root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID) {
115
+ $root->setIsVisible(true);
116
+ if ($this->isReadonly()) {
117
+ $root->setDisabled(true);
118
+ }
119
+ }
120
+ elseif($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) {
121
+ $root->setName(Mage::helper('catalog')->__('Root'));
122
+ }
123
+
124
+ Mage::register('root', $root);
125
+ }
126
+
127
+ return $root;
128
+ }
129
+
130
+ protected function _getNodeJson($node, $level=1)
131
+ {
132
+ $item = parent::_getNodeJson($node, $level);
133
+
134
+ $isParent = $this->_isParentSelectedCategory($node);
135
+
136
+ if ($isParent) {
137
+ $item['expanded'] = true;
138
+ }
139
+
140
+ // if ($node->getLevel() > 1 && !$isParent && isset($item['children'])) {
141
+ // $item['children'] = array();
142
+ // }
143
+
144
+
145
+ if (in_array($node->getId(), $this->getCategoryIds())) {
146
+ $item['checked'] = true;
147
+ }
148
+
149
+ if ($this->isReadonly()) {
150
+ $item['disabled'] = true;
151
+ }
152
+ return $item;
153
+ }
154
+
155
+ protected function _isParentSelectedCategory($node)
156
+ {
157
+ foreach ($this->_getSelectedNodes() as $selected) {
158
+ if ($selected) {
159
+ $pathIds = explode('/', $selected->getPathId());
160
+ if (in_array($node->getId(), $pathIds)) {
161
+ return true;
162
+ }
163
+ }
164
+ }
165
+
166
+ return false;
167
+ }
168
+
169
+ protected function _getSelectedNodes()
170
+ {
171
+ if ($this->_selectedNodes === null) {
172
+ $this->_selectedNodes = array();
173
+ $root = $this->getRoot();
174
+ foreach ($this->getCategoryIds() as $categoryId) {
175
+ if ($root) {
176
+ $this->_selectedNodes[] = $root->getTree()->getNodeById($categoryId);
177
+ }
178
+ }
179
+ }
180
+
181
+ return $this->_selectedNodes;
182
+ }
183
+
184
+ public function getCategoryChildrenJson($categoryId)
185
+ {
186
+ $category = Mage::getModel('catalog/category')->load($categoryId);
187
+ $node = $this->getRoot($category, 1)->getTree()->getNodeById($categoryId);
188
+
189
+ if (!$node || !$node->hasChildren()) {
190
+ return '[]';
191
+ }
192
+
193
+ $children = array();
194
+ foreach ($node->getChildren() as $child) {
195
+ $children[] = $this->_getNodeJson($child);
196
+ }
197
+
198
+ return Mage::helper('core')->jsonEncode($children);
199
+ }
200
+
201
+ public function getLoadTreeUrl($expanded=null)
202
+ {
203
+ return $this->getUrl('*/*/categoriesJson', array('_current'=>true));
204
+ }
205
+
206
+ /**
207
+ * Return distinct path ids of selected categories
208
+ *
209
+ * @param int $rootId Root category Id for context
210
+ * @return array
211
+ */
212
+ public function getSelectedCategoriesPathIds($rootId = false)
213
+ {
214
+ $ids = array();
215
+ $categoryIds = $this->getCategoryIds();
216
+ if (empty($categoryIds)) {
217
+ return array();
218
+ }
219
+ $collection = Mage::getResourceModel('catalog/category_collection');
220
+
221
+ if ($rootId) {
222
+ $collection->addFieldToFilter('parent_id', $rootId);
223
+ } else {
224
+ $collection->addFieldToFilter('entity_id', array('in'=>$categoryIds));
225
+ }
226
+
227
+ foreach ($collection as $item) {
228
+ if ($rootId && !in_array($rootId, $item->getPathIds())) {
229
+ continue;
230
+ }
231
+ foreach ($item->getPathIds() as $id) {
232
+ if (!in_array($id, $ids)) {
233
+ $ids[] = $id;
234
+ }
235
+ }
236
+ }
237
+ return $ids;
238
+ }
239
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Crossell products admin grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Crosssell extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ /**
37
+ * Set grid params
38
+ *
39
+ */
40
+ public function __construct()
41
+ {
42
+ parent::__construct();
43
+ $this->setId('cross_sell_product_grid');
44
+ $this->setDefaultSort('entity_id');
45
+ $this->setUseAjax(true);
46
+ if ($this->_getProduct()->getId()) {
47
+ $this->setDefaultFilter(array('in_products'=>1));
48
+ }
49
+ if ($this->isReadonly()) {
50
+ $this->setFilterVisibility(false);
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Retirve currently edited product model
56
+ *
57
+ * @return Mage_Catalog_Model_Product
58
+ */
59
+ protected function _getProduct()
60
+ {
61
+ return Mage::registry('current_product');
62
+ }
63
+
64
+ /**
65
+ * Add filter
66
+ *
67
+ * @param object $column
68
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Crosssell
69
+ */
70
+ protected function _addColumnFilterToCollection($column)
71
+ {
72
+ // Set custom filter for in product flag
73
+ if ($column->getId() == 'in_products') {
74
+ $productIds = $this->_getSelectedProducts();
75
+ if (empty($productIds)) {
76
+ $productIds = 0;
77
+ }
78
+ if ($column->getFilter()->getValue()) {
79
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
80
+ } else {
81
+ if($productIds) {
82
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
83
+ }
84
+ }
85
+ } else {
86
+ parent::_addColumnFilterToCollection($column);
87
+ }
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Prepare collection
93
+ *
94
+ * @return Mage_Adminhtml_Block_Widget_Grid
95
+ */
96
+ protected function _prepareCollection()
97
+ {
98
+ /* @var $collection Mage_Catalog_Model_Resource_Product_Link_Product_Collection */
99
+ $collection = Mage::getModel('catalog/product_link')->useCrossSellLinks()
100
+ ->getProductCollection()
101
+ ->setProduct($this->_getProduct())
102
+ ->addAttributeToSelect('*');
103
+
104
+ if ($this->isReadonly()) {
105
+ $productIds = $this->_getSelectedProducts();
106
+ if (empty($productIds)) {
107
+ $productIds = array(0);
108
+ }
109
+ $collection->addFieldToFilter('entity_id', array('in' => $productIds));
110
+ }
111
+
112
+
113
+ $this->setCollection($collection);
114
+
115
+ return parent::_prepareCollection();
116
+ }
117
+
118
+ /**
119
+ * Checks when this block is readonly
120
+ *
121
+ * @return boolean
122
+ */
123
+ public function isReadonly()
124
+ {
125
+ return $this->_getProduct()->getCrosssellReadonly();
126
+ }
127
+
128
+ /**
129
+ * Add columns to grid
130
+ *
131
+ * @return Mage_Adminhtml_Block_Widget_Grid
132
+ */
133
+ protected function _prepareColumns()
134
+ {
135
+ if (!$this->isReadonly()) {
136
+ $this->addColumn('in_products', array(
137
+ 'header_css_class' => 'a-center',
138
+ 'type' => 'checkbox',
139
+ 'name' => 'in_products',
140
+ 'values' => $this->_getSelectedProducts(),
141
+ 'align' => 'center',
142
+ 'index' => 'entity_id'
143
+ ));
144
+ }
145
+
146
+ $this->addColumn('entity_id', array(
147
+ 'header' => Mage::helper('catalog')->__('ID'),
148
+ 'sortable' => true,
149
+ 'width' => 60,
150
+ 'index' => 'entity_id'
151
+ ));
152
+
153
+ $this->addColumn('name', array(
154
+ 'header' => Mage::helper('catalog')->__('Name'),
155
+ 'index' => 'name'
156
+ ));
157
+
158
+ $this->addColumn('type', array(
159
+ 'header' => Mage::helper('catalog')->__('Type'),
160
+ 'width' => 100,
161
+ 'index' => 'type_id',
162
+ 'type' => 'options',
163
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
164
+ ));
165
+
166
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
167
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
168
+ ->load()
169
+ ->toOptionHash();
170
+
171
+ $this->addColumn('set_name', array(
172
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
173
+ 'width' => 130,
174
+ 'index' => 'attribute_set_id',
175
+ 'type' => 'options',
176
+ 'options' => $sets,
177
+ ));
178
+
179
+ $this->addColumn('status', array(
180
+ 'header' => Mage::helper('catalog')->__('Status'),
181
+ 'width' => 90,
182
+ 'index' => 'status',
183
+ 'type' => 'options',
184
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
185
+ ));
186
+
187
+ $this->addColumn('visibility', array(
188
+ 'header' => Mage::helper('catalog')->__('Visibility'),
189
+ 'width' => 90,
190
+ 'index' => 'visibility',
191
+ 'type' => 'options',
192
+ 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
193
+ ));
194
+
195
+ $this->addColumn('sku', array(
196
+ 'header' => Mage::helper('catalog')->__('SKU'),
197
+ 'width' => 80,
198
+ 'index' => 'sku'
199
+ ));
200
+
201
+ $this->addColumn('price', array(
202
+ 'header' => Mage::helper('catalog')->__('Price'),
203
+ 'type' => 'currency',
204
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
205
+ 'index' => 'price'
206
+ ));
207
+
208
+
209
+ $this->addColumn('position', array(
210
+ 'header' => Mage::helper('catalog')->__('Position'),
211
+ 'name' => 'position',
212
+ 'width' => 60,
213
+ 'type' => 'number',
214
+ 'validate_class' => 'validate-number',
215
+ 'index' => 'position',
216
+ 'editable' => !$this->isReadonly(),
217
+ 'edit_only' => !$this->_getProduct()->getId()
218
+ ));
219
+
220
+ return parent::_prepareColumns();
221
+ }
222
+
223
+ /**
224
+ * Rerieve grid URL
225
+ *
226
+ * @return string
227
+ */
228
+ public function getGridUrl()
229
+ {
230
+ return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/crosssellGrid', array('_current'=>true));
231
+ }
232
+
233
+ /**
234
+ * Retrieve selected crosssell products
235
+ *
236
+ * @return array
237
+ */
238
+ protected function _getSelectedProducts()
239
+ {
240
+ $products = $this->getProductsCrossSell();
241
+ if (!is_array($products)) {
242
+ $products = array_keys($this->getSelectedCrossSellProducts());
243
+ }
244
+ return $products;
245
+ }
246
+
247
+ /**
248
+ * Retrieve crosssell products
249
+ *
250
+ * @return array
251
+ */
252
+ public function getSelectedCrossSellProducts()
253
+ {
254
+ $products = array();
255
+ foreach (Mage::registry('current_product')->getCrossSellProducts() as $product) {
256
+ $products[$product->getId()] = array('position' => $product->getPosition());
257
+ }
258
+ return $products;
259
+ }
260
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product inventory data
29
+ *
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Inventory extends Mage_Adminhtml_Block_Widget
33
+ {
34
+ public function __construct()
35
+ {
36
+ parent::__construct();
37
+ $this->setTemplate('catalog/product/tab/inventory.phtml');
38
+ }
39
+
40
+ public function getBackordersOption()
41
+ {
42
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
43
+ return Mage::getSingleton('cataloginventory/source_backorders')->toOptionArray();
44
+ }
45
+
46
+ return array();
47
+ }
48
+
49
+ /**
50
+ * Retrieve stock option array
51
+ *
52
+ * @return array
53
+ */
54
+ public function getStockOption()
55
+ {
56
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
57
+ return Mage::getSingleton('cataloginventory/source_stock')->toOptionArray();
58
+ }
59
+
60
+ return array();
61
+ }
62
+
63
+ /**
64
+ * Return current product instance
65
+ *
66
+ * @return Mage_Catalog_Model_Product
67
+ */
68
+ public function getProduct()
69
+ {
70
+ return Mage::registry('product');
71
+ }
72
+
73
+ /**
74
+ * Retrieve Catalog Inventory Stock Item Model
75
+ *
76
+ * @return Mage_CatalogInventory_Model_Stock_Item
77
+ */
78
+ public function getStockItem()
79
+ {
80
+ return $this->getProduct()->getStockItem();
81
+ }
82
+
83
+ public function isConfigurable()
84
+ {
85
+ return $this->getProduct()->isConfigurable();
86
+ }
87
+
88
+ public function getFieldValue($field)
89
+ {
90
+ if ($this->getStockItem()) {
91
+ return $this->getStockItem()->getDataUsingMethod($field);
92
+ }
93
+
94
+ return Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_ITEM . $field);
95
+ }
96
+
97
+ public function getConfigFieldValue($field)
98
+ {
99
+ if ($this->getStockItem()) {
100
+ if ($this->getStockItem()->getData('use_config_' . $field) == 0) {
101
+ return $this->getStockItem()->getData($field);
102
+ }
103
+ }
104
+
105
+ return Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_ITEM . $field);
106
+ }
107
+
108
+ public function getDefaultConfigValue($field)
109
+ {
110
+ return Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_ITEM . $field);
111
+ }
112
+
113
+ /**
114
+ * Is readonly stock
115
+ *
116
+ * @return boolean
117
+ */
118
+ public function isReadonly()
119
+ {
120
+ return $this->getProduct()->getInventoryReadonly();
121
+ }
122
+
123
+ public function isNew()
124
+ {
125
+ if ($this->getProduct()->getId()) {
126
+ return false;
127
+ }
128
+ return true;
129
+ }
130
+
131
+ public function getFieldSuffix()
132
+ {
133
+ return 'product';
134
+ }
135
+
136
+ /**
137
+ * Check Whether product type can have fractional quantity or not
138
+ *
139
+ * @return bool
140
+ */
141
+ public function canUseQtyDecimals()
142
+ {
143
+ return $this->getProduct()->getTypeInstance()->canUseQtyDecimals();
144
+ }
145
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * customers defined options
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options extends Mage_Adminhtml_Block_Widget
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setTemplate('catalog/product/edit/options.phtml');
41
+ }
42
+
43
+
44
+ protected function _prepareLayout()
45
+ {
46
+ $this->setChild('add_button',
47
+ $this->getLayout()->createBlock('adminhtml/widget_button')
48
+ ->setData(array(
49
+ 'label' => Mage::helper('catalog')->__('Add New Option'),
50
+ 'class' => 'add',
51
+ 'id' => 'add_new_defined_option'
52
+ ))
53
+ );
54
+
55
+ $this->setChild('options_box',
56
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_options_option')
57
+ );
58
+
59
+ return parent::_prepareLayout();
60
+ }
61
+
62
+ public function getAddButtonHtml()
63
+ {
64
+ return $this->getChildHtml('add_button');
65
+ }
66
+
67
+ public function getOptionsBoxHtml()
68
+ {
69
+ return $this->getChildHtml('options_box');
70
+ }
71
+
72
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php ADDED
@@ -0,0 +1,345 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * customers defined options
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option extends Mage_Adminhtml_Block_Widget
36
+ {
37
+ protected $_product;
38
+
39
+ protected $_productInstance;
40
+
41
+ protected $_values;
42
+
43
+ protected $_itemCount = 1;
44
+
45
+ /**
46
+ * Class constructor
47
+ */
48
+ public function __construct()
49
+ {
50
+ parent::__construct();
51
+ $this->setTemplate('catalog/product/edit/options/option.phtml');
52
+ $this->setCanReadPrice(true);
53
+ $this->setCanEditPrice(true);
54
+ }
55
+
56
+ public function getItemCount()
57
+ {
58
+ return $this->_itemCount;
59
+ }
60
+
61
+ public function setItemCount($itemCount)
62
+ {
63
+ $this->_itemCount = max($this->_itemCount, $itemCount);
64
+ return $this;
65
+ }
66
+
67
+ /**
68
+ * Get Product
69
+ *
70
+ * @return Mage_Catalog_Model_Product
71
+ */
72
+ public function getProduct()
73
+ {
74
+ if (!$this->_productInstance) {
75
+ if ($product = Mage::registry('product')) {
76
+ $this->_productInstance = $product;
77
+ } else {
78
+ $this->_productInstance = Mage::getSingleton('catalog/product');
79
+ }
80
+ }
81
+
82
+ return $this->_productInstance;
83
+ }
84
+
85
+ public function setProduct($product)
86
+ {
87
+ $this->_productInstance = $product;
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Retrieve options field name prefix
93
+ *
94
+ * @return string
95
+ */
96
+ public function getFieldName()
97
+ {
98
+ return 'product[options]';
99
+ }
100
+
101
+ /**
102
+ * Retrieve options field id prefix
103
+ *
104
+ * @return string
105
+ */
106
+ public function getFieldId()
107
+ {
108
+ return 'product_option';
109
+ }
110
+
111
+ /**
112
+ * Check block is readonly
113
+ *
114
+ * @return boolean
115
+ */
116
+ public function isReadonly()
117
+ {
118
+ return $this->getProduct()->getOptionsReadonly();
119
+ }
120
+
121
+ protected function _prepareLayout()
122
+ {
123
+ $this->setChild('delete_button',
124
+ $this->getLayout()->createBlock('adminhtml/widget_button')
125
+ ->setData(array(
126
+ 'label' => Mage::helper('catalog')->__('Delete Option'),
127
+ 'class' => 'delete delete-product-option '
128
+ ))
129
+ );
130
+
131
+ $path = 'global/catalog/product/options/custom/groups';
132
+
133
+ foreach (Mage::getConfig()->getNode($path)->children() as $group) {
134
+ $this->setChild($group->getName() . '_option_type',
135
+ $this->getLayout()->createBlock(
136
+ (string) Mage::getConfig()->getNode($path . '/' . $group->getName() . '/render')
137
+ )
138
+ );
139
+ }
140
+
141
+ return parent::_prepareLayout();
142
+ }
143
+
144
+ public function getAddButtonId()
145
+ {
146
+ $buttonId = $this->getLayout()
147
+ ->getBlock('admin.product.options')
148
+ ->getChild('add_button')->getId();
149
+ return $buttonId;
150
+ }
151
+
152
+ public function getDeleteButtonHtml()
153
+ {
154
+ return $this->getChildHtml('delete_button');
155
+ }
156
+
157
+ public function getTypeSelectHtml()
158
+ {
159
+ $select = $this->getLayout()->createBlock('adminhtml/html_select')
160
+ ->setData(array(
161
+ 'id' => $this->getFieldId().'_{{id}}_type',
162
+ 'class' => 'select select-product-option-type required-option-select'
163
+ ))
164
+ ->setName($this->getFieldName().'[{{id}}][type]')
165
+ ->setOptions(Mage::getSingleton('adminhtml/system_config_source_product_options_type')->toOptionArray());
166
+
167
+ return $select->getHtml();
168
+ }
169
+
170
+ public function getRequireSelectHtml()
171
+ {
172
+ $select = $this->getLayout()->createBlock('adminhtml/html_select')
173
+ ->setData(array(
174
+ 'id' => $this->getFieldId().'_{{id}}_is_require',
175
+ 'class' => 'select'
176
+ ))
177
+ ->setName($this->getFieldName().'[{{id}}][is_require]')
178
+ ->setOptions(Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray());
179
+
180
+ return $select->getHtml();
181
+ }
182
+
183
+ /**
184
+ * Retrieve html templates for different types of product custom options
185
+ *
186
+ * @return string
187
+ */
188
+ public function getTemplatesHtml()
189
+ {
190
+ $canEditPrice = $this->getCanEditPrice();
191
+ $canReadPrice = $this->getCanReadPrice();
192
+ $this->getChild('select_option_type')
193
+ ->setCanReadPrice($canReadPrice)
194
+ ->setCanEditPrice($canEditPrice);
195
+
196
+ $this->getChild('file_option_type')
197
+ ->setCanReadPrice($canReadPrice)
198
+ ->setCanEditPrice($canEditPrice);
199
+
200
+ $this->getChild('date_option_type')
201
+ ->setCanReadPrice($canReadPrice)
202
+ ->setCanEditPrice($canEditPrice);
203
+
204
+ $this->getChild('text_option_type')
205
+ ->setCanReadPrice($canReadPrice)
206
+ ->setCanEditPrice($canEditPrice);
207
+
208
+ $templates = $this->getChildHtml('text_option_type') . "\n" .
209
+ $this->getChildHtml('file_option_type') . "\n" .
210
+ $this->getChildHtml('select_option_type') . "\n" .
211
+ $this->getChildHtml('date_option_type');
212
+
213
+ return $templates;
214
+ }
215
+
216
+ public function getOptionValues()
217
+ {
218
+ $optionsArr = array_reverse($this->getProduct()->getOptions(), true);
219
+ // $optionsArr = $this->getProduct()->getOptions();
220
+
221
+ if (!$this->_values) {
222
+ $showPrice = $this->getCanReadPrice();
223
+ $values = array();
224
+ $scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE);
225
+ foreach ($optionsArr as $option) {
226
+ /* @var $option Mage_Catalog_Model_Product_Option */
227
+
228
+ $this->setItemCount($option->getOptionId());
229
+
230
+ $value = array();
231
+
232
+ $value['id'] = $option->getOptionId();
233
+ $value['item_count'] = $this->getItemCount();
234
+ $value['option_id'] = $option->getOptionId();
235
+ $value['title'] = $this->htmlEscape($option->getTitle());
236
+ $value['type'] = $option->getType();
237
+ $value['is_require'] = $option->getIsRequire();
238
+ $value['sort_order'] = $option->getSortOrder();
239
+ $value['can_edit_price'] = $this->getCanEditPrice();
240
+
241
+ if ($this->getProduct()->getStoreId() != '0') {
242
+ $value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title',
243
+ is_null($option->getStoreTitle()));
244
+ $value['scopeTitleDisabled'] = is_null($option->getStoreTitle())?'disabled':null;
245
+ }
246
+
247
+ if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
248
+
249
+ // $valuesArr = array_reverse($option->getValues(), true);
250
+
251
+ $i = 0;
252
+ $itemCount = 0;
253
+ foreach ($option->getValues() as $_value) {
254
+ /* @var $_value Mage_Catalog_Model_Product_Option_Value */
255
+ $value['optionValues'][$i] = array(
256
+ 'item_count' => max($itemCount, $_value->getOptionTypeId()),
257
+ 'option_id' => $_value->getOptionId(),
258
+ 'option_type_id' => $_value->getOptionTypeId(),
259
+ 'title' => $this->htmlEscape($_value->getTitle()),
260
+ 'price' => ($showPrice)
261
+ ? $this->getPriceValue($_value->getPrice(), $_value->getPriceType()) : '',
262
+ 'price_type' => ($showPrice) ? $_value->getPriceType() : 0,
263
+ 'sku' => $this->htmlEscape($_value->getSku()),
264
+ 'sort_order' => $_value->getSortOrder(),
265
+ );
266
+
267
+ if ($this->getProduct()->getStoreId() != '0') {
268
+ $value['optionValues'][$i]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml(
269
+ $_value->getOptionId(), 'title', is_null($_value->getStoreTitle()),
270
+ $_value->getOptionTypeId());
271
+ $value['optionValues'][$i]['scopeTitleDisabled'] = is_null($_value->getStoreTitle())
272
+ ? 'disabled' : null;
273
+ if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
274
+ $value['optionValues'][$i]['checkboxScopePrice'] = $this->getCheckboxScopeHtml(
275
+ $_value->getOptionId(), 'price', is_null($_value->getstorePrice()),
276
+ $_value->getOptionTypeId());
277
+ $value['optionValues'][$i]['scopePriceDisabled'] = is_null($_value->getStorePrice())
278
+ ? 'disabled' : null;
279
+ }
280
+ }
281
+ $i++;
282
+ }
283
+ } else {
284
+ $value['price'] = ($showPrice)
285
+ ? $this->getPriceValue($option->getPrice(), $option->getPriceType()) : '';
286
+ $value['price_type'] = $option->getPriceType();
287
+ $value['sku'] = $this->htmlEscape($option->getSku());
288
+ $value['max_characters'] = $option->getMaxCharacters();
289
+ $value['file_extension'] = $option->getFileExtension();
290
+ $value['image_size_x'] = $option->getImageSizeX();
291
+ $value['image_size_y'] = $option->getImageSizeY();
292
+ if ($this->getProduct()->getStoreId() != '0' &&
293
+ $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
294
+ $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(),
295
+ 'price', is_null($option->getStorePrice()));
296
+ $value['scopePriceDisabled'] = is_null($option->getStorePrice())?'disabled':null;
297
+ }
298
+ }
299
+ $values[] = new Varien_Object($value);
300
+ }
301
+ $this->_values = $values;
302
+ }
303
+
304
+ return $this->_values;
305
+ }
306
+
307
+ /**
308
+ * Retrieve html of scope checkbox
309
+ *
310
+ * @param string $id
311
+ * @param string $name
312
+ * @param boolean $checked
313
+ * @param string $select_id
314
+ * @return string
315
+ */
316
+ public function getCheckboxScopeHtml($id, $name, $checked=true, $select_id='-1')
317
+ {
318
+ $checkedHtml = '';
319
+ if ($checked) {
320
+ $checkedHtml = ' checked="checked"';
321
+ }
322
+ $selectNameHtml = '';
323
+ $selectIdHtml = '';
324
+ if ($select_id != '-1') {
325
+ $selectNameHtml = '[values][' . $select_id . ']';
326
+ $selectIdHtml = 'select_' . $select_id . '_';
327
+ }
328
+ $checkbox = '<input type="checkbox" id="' . $this->getFieldId() . '_' . $id . '_' .
329
+ $selectIdHtml . $name . '_use_default" class="product-option-scope-checkbox" name="' .
330
+ $this->getFieldName() . '['.$id.']' . $selectNameHtml . '[scope][' . $name . ']" value="1" ' .
331
+ $checkedHtml . '/>';
332
+ $checkbox .= '<label class="normal" for="' . $this->getFieldId() . '_' . $id . '_' .
333
+ $selectIdHtml . $name . '_use_default">' . $this->__('Use Default Value') . '</label>';
334
+ return $checkbox;
335
+ }
336
+
337
+ public function getPriceValue($value, $type)
338
+ {
339
+ if ($type == 'percent') {
340
+ return number_format($value, 2, null, '');
341
+ } elseif ($type == 'fixed') {
342
+ return number_format($value, 2, null, '');
343
+ }
344
+ }
345
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * customers defined options
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract extends Mage_Adminhtml_Block_Widget
36
+ {
37
+ protected $_name = 'abstract';
38
+
39
+ protected function _prepareLayout()
40
+ {
41
+ $this->setChild('option_price_type',
42
+ $this->getLayout()->createBlock('adminhtml/html_select')
43
+ ->setData(array(
44
+ 'id' => 'product_option_{{option_id}}_price_type',
45
+ 'class' => 'select product-option-price-type'
46
+ ))
47
+ );
48
+
49
+ $this->getChild('option_price_type')->setName('product[options][{{option_id}}][price_type]')
50
+ ->setOptions(Mage::getSingleton('adminhtml/system_config_source_product_options_price')
51
+ ->toOptionArray());
52
+
53
+ return parent::_prepareLayout();
54
+ }
55
+
56
+ /**
57
+ * Get html of Price Type select element
58
+ *
59
+ * @return string
60
+ */
61
+ public function getPriceTypeSelectHtml()
62
+ {
63
+ if ($this->getCanEditPrice() === false) {
64
+ $this->getChild('option_price_type')->setExtraParams('disabled="disabled"');
65
+ }
66
+ return $this->getChildHtml('option_price_type');
67
+ }
68
+
69
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Date.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * customers defined options
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Date extends
36
+ Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract
37
+ {
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setTemplate('catalog/product/edit/options/type/date.phtml');
42
+ }
43
+
44
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/File.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * customers defined options
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_File extends
36
+ Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract
37
+ {
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setTemplate('catalog/product/edit/options/type/file.phtml');
42
+ }
43
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * customers defined options
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select extends
36
+ Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract
37
+ {
38
+ /**
39
+ * Class constructor
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ $this->setTemplate('catalog/product/edit/options/type/select.phtml');
45
+ $this->setCanEditPrice(true);
46
+ $this->setCanReadPrice(true);
47
+ }
48
+
49
+ protected function _prepareLayout()
50
+ {
51
+ $this->setChild('add_select_row_button',
52
+ $this->getLayout()->createBlock('adminhtml/widget_button')
53
+ ->setData(array(
54
+ 'label' => Mage::helper('catalog')->__('Add New Row'),
55
+ 'class' => 'add add-select-row',
56
+ 'id' => 'add_select_row_button_{{option_id}}'
57
+ ))
58
+ );
59
+
60
+ $this->setChild('delete_select_row_button',
61
+ $this->getLayout()->createBlock('adminhtml/widget_button')
62
+ ->setData(array(
63
+ 'label' => Mage::helper('catalog')->__('Delete Row'),
64
+ 'class' => 'delete delete-select-row icon-btn',
65
+ 'id' => 'delete_select_row_button'
66
+ ))
67
+ );
68
+
69
+ return parent::_prepareLayout();
70
+ }
71
+
72
+ public function getAddButtonHtml()
73
+ {
74
+ return $this->getChildHtml('add_select_row_button');
75
+ }
76
+
77
+ public function getDeleteButtonHtml()
78
+ {
79
+ return $this->getChildHtml('delete_select_row_button');
80
+ }
81
+
82
+ public function getPriceTypeSelectHtml()
83
+ {
84
+ $this->getChild('option_price_type')
85
+ ->setData('id', 'product_option_{{id}}_select_{{select_id}}_price_type')
86
+ ->setName('product[options][{{id}}][values][{{select_id}}][price_type]');
87
+
88
+ return parent::getPriceTypeSelectHtml();
89
+ }
90
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Text.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * customers defined options
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Text extends
36
+ Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract
37
+ {
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setTemplate('catalog/product/edit/options/type/text.phtml');
42
+ }
43
+
44
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml product edit price block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+ protected function _prepareForm()
37
+ {
38
+ $product = Mage::registry('product');
39
+
40
+ $form = new Varien_Data_Form();
41
+ $fieldset = $form->addFieldset('tiered_price', array('legend'=>Mage::helper('catalog')->__('Tier Pricing')));
42
+
43
+ $fieldset->addField('default_price', 'label', array(
44
+ 'label'=> Mage::helper('catalog')->__('Default Price'),
45
+ 'title'=> Mage::helper('catalog')->__('Default Price'),
46
+ 'name'=>'default_price',
47
+ 'bold'=>true,
48
+ 'value'=>$product->getPrice()
49
+ ));
50
+
51
+ $fieldset->addField('tier_price', 'text', array(
52
+ 'name'=>'tier_price',
53
+ 'class'=>'requried-entry',
54
+ 'value'=>$product->getData('tier_price')
55
+ ));
56
+
57
+ $form->getElement('tier_price')->setRenderer(
58
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_tier')
59
+ );
60
+
61
+ $this->setForm($form);
62
+ }
63
+ }// Class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price END
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Recurring.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Recurring profile attribute edit renderer
29
+ */
30
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Recurring
31
+ extends Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element
32
+ {
33
+ /**
34
+ * Element output getter
35
+ *
36
+ * @return string
37
+ */
38
+ public function getElementHtml()
39
+ {
40
+ $result = new StdClass;
41
+ $result->output = '';
42
+ Mage::dispatchEvent('catalog_product_edit_form_render_recurring', array(
43
+ 'result' => $result,
44
+ 'product_element' => $this->_element,
45
+ 'product' => Mage::registry('current_product'),
46
+ ));
47
+ return $result->output;
48
+ }
49
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml tier price item renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier
35
+ extends Mage_Adminhtml_Block_Widget
36
+ implements Varien_Data_Form_Element_Renderer_Interface
37
+ {
38
+ /**
39
+ * Form element instance
40
+ *
41
+ * @var Varien_Data_Form_Element
42
+ */
43
+ protected $_element;
44
+
45
+ /**
46
+ * Customer Groups cache
47
+ *
48
+ * @var array
49
+ */
50
+ protected $_customerGroups;
51
+
52
+ /**
53
+ * Websites cache
54
+ *
55
+ * @var array
56
+ */
57
+ protected $_websites;
58
+
59
+ /**
60
+ * Define tier price template file
61
+ *
62
+ */
63
+ public function __construct()
64
+ {
65
+ $this->setTemplate('catalog/product/edit/price/tier.phtml');
66
+ }
67
+
68
+ /**
69
+ * Retrieve current edit product instance
70
+ *
71
+ * @return Mage_Catalog_Model_Product
72
+ */
73
+ public function getProduct()
74
+ {
75
+ return Mage::registry('product');
76
+ }
77
+
78
+ /**
79
+ * Render HTML
80
+ *
81
+ * @param Varien_Data_Form_Element_Abstract $element
82
+ * @return string
83
+ */
84
+ public function render(Varien_Data_Form_Element_Abstract $element)
85
+ {
86
+ $this->setElement($element);
87
+ return $this->toHtml();
88
+ }
89
+
90
+ /**
91
+ * Set form element instance
92
+ *
93
+ * @param Varien_Data_Form_Element_Abstract $element
94
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier
95
+ */
96
+ public function setElement(Varien_Data_Form_Element_Abstract $element)
97
+ {
98
+ $this->_element = $element;
99
+ return $this;
100
+ }
101
+
102
+ /**
103
+ * Retrieve form element instance
104
+ *
105
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier
106
+ */
107
+ public function getElement()
108
+ {
109
+ return $this->_element;
110
+ }
111
+
112
+ /**
113
+ * Prepare Tier Price values
114
+ *
115
+ * @return array
116
+ */
117
+ public function getValues()
118
+ {
119
+ $values = array();
120
+ $data = $this->getElement()->getValue();
121
+
122
+ if (is_array($data)) {
123
+ usort($data, array($this, '_sortTierPrices'));
124
+ $values = $data;
125
+ }
126
+
127
+ foreach ($values as &$v) {
128
+ $v['readonly'] = $v['website_id'] == 0 && $this->isShowWebsiteColumn() && !$this->isAllowChangeWebsite();
129
+ }
130
+
131
+ return $values;
132
+ }
133
+
134
+ /**
135
+ * Sort tier price values callback method
136
+ *
137
+ * @param array $a
138
+ * @param array $b
139
+ * @return int
140
+ */
141
+ protected function _sortTierPrices($a, $b)
142
+ {
143
+ if ($a['website_id'] != $b['website_id']) {
144
+ return $a['website_id'] < $b['website_id'] ? -1 : 1;
145
+ }
146
+ if ($a['cust_group'] != $b['cust_group']) {
147
+ return $this->getCustomerGroups($a['cust_group']) < $this->getCustomerGroups($b['cust_group']) ? -1 : 1;
148
+ }
149
+ if ($a['price_qty'] != $b['price_qty']) {
150
+ return $a['price_qty'] < $b['price_qty'] ? -1 : 1;
151
+ }
152
+
153
+ return 0;
154
+ }
155
+
156
+ /**
157
+ * Retrieve allowed customer groups
158
+ *
159
+ * @param int $groupId return name by customer group id
160
+ * @return array|string
161
+ */
162
+ public function getCustomerGroups($groupId = null)
163
+ {
164
+ if ($this->_customerGroups === null) {
165
+ if (!Mage::helper('catalog')->isModuleEnabled('Mage_Customer')) {
166
+ return array();
167
+ }
168
+ $collection = Mage::getModel('customer/group')->getCollection();
169
+ $this->_customerGroups = array(
170
+ Mage_Customer_Model_Group::CUST_GROUP_ALL => Mage::helper('catalog')->__('ALL GROUPS')
171
+ );
172
+
173
+ foreach ($collection as $item) {
174
+ /* @var $item Mage_Customer_Model_Group */
175
+ $this->_customerGroups[$item->getId()] = $item->getCustomerGroupCode();
176
+ }
177
+ }
178
+
179
+ if ($groupId !== null) {
180
+ return isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : array();
181
+ }
182
+
183
+ return $this->_customerGroups;
184
+ }
185
+
186
+ /**
187
+ * Retrieve count of websites
188
+ *
189
+ * @return int
190
+ */
191
+ public function getWebsiteCount()
192
+ {
193
+ return count($this->getWebsites());
194
+ }
195
+
196
+ /**
197
+ * Show Website column and switcher for tier price table
198
+ *
199
+ * @return bool
200
+ */
201
+ public function isMultiWebsites()
202
+ {
203
+ return !Mage::app()->isSingleStoreMode();
204
+ }
205
+
206
+ /**
207
+ * Retrieve allowed for edit websites
208
+ *
209
+ * @return array
210
+ */
211
+ public function getWebsites()
212
+ {
213
+ if (!is_null($this->_websites)) {
214
+ return $this->_websites;
215
+ }
216
+
217
+ $this->_websites = array(
218
+ 0 => array(
219
+ 'name' => Mage::helper('catalog')->__('All Websites'),
220
+ 'currency' => Mage::app()->getBaseCurrencyCode()
221
+ )
222
+ );
223
+
224
+ if (!$this->isScopeGlobal() && $this->getProduct()->getStoreId()) {
225
+ /* @var $website Mage_Core_Model_Website */
226
+ $website = Mage::app()->getStore($this->getProduct()->getStoreId())->getWebsite();
227
+
228
+ $this->_websites[$website->getId()] = array(
229
+ 'name' => $website->getName(),
230
+ 'currency' => $website->getBaseCurrencyCode()
231
+ );
232
+ } else if (!$this->isScopeGlobal()) {
233
+ $websites = Mage::app()->getWebsites(false);
234
+ $productWebsiteIds = $this->getProduct()->getWebsiteIds();
235
+ foreach ($websites as $website) {
236
+ /* @var $website Mage_Core_Model_Website */
237
+ if (!in_array($website->getId(), $productWebsiteIds)) {
238
+ continue;
239
+ }
240
+ $this->_websites[$website->getId()] = array(
241
+ 'name' => $website->getName(),
242
+ 'currency' => $website->getBaseCurrencyCode()
243
+ );
244
+ }
245
+ }
246
+
247
+ return $this->_websites;
248
+ }
249
+
250
+ /**
251
+ * Retrieve default value for customer group
252
+ *
253
+ * @return int
254
+ */
255
+ public function getDefaultCustomerGroup()
256
+ {
257
+ return Mage_Customer_Model_Group::CUST_GROUP_ALL;
258
+ }
259
+
260
+ /**
261
+ * Retrieve default value for website
262
+ *
263
+ * @return int
264
+ */
265
+ public function getDefaultWebsite()
266
+ {
267
+ if ($this->isShowWebsiteColumn() && !$this->isAllowChangeWebsite()) {
268
+ return Mage::app()->getStore($this->getProduct()->getStoreId())->getWebsiteId();
269
+ }
270
+ return 0;
271
+ }
272
+
273
+ /**
274
+ * Prepare global layout
275
+ * Add "Add tier" button to layout
276
+ *
277
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier
278
+ */
279
+ protected function _prepareLayout()
280
+ {
281
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
282
+ ->setData(array(
283
+ 'label' => Mage::helper('catalog')->__('Add Tier'),
284
+ 'onclick' => 'return tierPriceControl.addItem()',
285
+ 'class' => 'add'
286
+ ));
287
+ $button->setName('add_tier_price_item_button');
288
+
289
+ $this->setChild('add_button', $button);
290
+ return parent::_prepareLayout();
291
+ }
292
+
293
+ /**
294
+ * Retrieve Add Tier Price Item button HTML
295
+ *
296
+ * @return string
297
+ */
298
+ public function getAddButtonHtml()
299
+ {
300
+ return $this->getChildHtml('add_button');
301
+ }
302
+
303
+ /**
304
+ * Returns customized price column header
305
+ * that was seted through set...
306
+ *
307
+ * @param string $default
308
+ * @return string
309
+ */
310
+ public function getPriceColumnHeader($default)
311
+ {
312
+ if ($this->hasData('price_column_header')) {
313
+ return $this->getData('price_column_header');
314
+ } else {
315
+ return $default;
316
+ }
317
+ }
318
+
319
+ /**
320
+ * Returns customized price column header
321
+ * that was seted through set...
322
+ *
323
+ * @param string $default
324
+ * @return string
325
+ */
326
+ public function getPriceValidation($default)
327
+ {
328
+ if ($this->hasData('price_validation')) {
329
+ return $this->getData('price_validation');
330
+ } else {
331
+ return $default;
332
+ }
333
+ }
334
+
335
+ /**
336
+ * Retrieve Tier Price entity attribute
337
+ *
338
+ * @return Mage_Catalog_Model_Resource_Eav_Attribute
339
+ */
340
+ public function getAttribute()
341
+ {
342
+ return $this->getElement()->getEntityAttribute();
343
+ }
344
+
345
+ /**
346
+ * Check tier price attribute scope is global
347
+ *
348
+ * @return bool
349
+ */
350
+ public function isScopeGlobal()
351
+ {
352
+ return $this->getAttribute()->isScopeGlobal();
353
+ }
354
+
355
+ /**
356
+ * Show tier prices grid website column
357
+ *
358
+ * @return bool
359
+ */
360
+ public function isShowWebsiteColumn()
361
+ {
362
+ if ($this->isScopeGlobal()) {
363
+ return false;
364
+ } else if (Mage::app()->isSingleStoreMode()) {
365
+ return false;
366
+ }
367
+ return true;
368
+ }
369
+
370
+ /**
371
+ * Check is allow change website value for combination
372
+ *
373
+ * @return bool
374
+ */
375
+ public function isAllowChangeWebsite()
376
+ {
377
+ if (!$this->isShowWebsiteColumn() || $this->getProduct()->getStoreId()) {
378
+ return false;
379
+ }
380
+ return true;
381
+ }
382
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Related products admin grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Related extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ /**
37
+ * Set grid params
38
+ *
39
+ */
40
+ public function __construct()
41
+ {
42
+ parent::__construct();
43
+ $this->setId('related_product_grid');
44
+ $this->setDefaultSort('entity_id');
45
+ $this->setUseAjax(true);
46
+ if ($this->_getProduct()->getId()) {
47
+ $this->setDefaultFilter(array('in_products' => 1));
48
+ }
49
+ if ($this->isReadonly()) {
50
+ $this->setFilterVisibility(false);
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Retirve currently edited product model
56
+ *
57
+ * @return Mage_Catalog_Model_Product
58
+ */
59
+ protected function _getProduct()
60
+ {
61
+ return Mage::registry('current_product');
62
+ }
63
+
64
+ /**
65
+ * Add filter
66
+ *
67
+ * @param object $column
68
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Related
69
+ */
70
+ protected function _addColumnFilterToCollection($column)
71
+ {
72
+ // Set custom filter for in product flag
73
+ if ($column->getId() == 'in_products') {
74
+ $productIds = $this->_getSelectedProducts();
75
+ if (empty($productIds)) {
76
+ $productIds = 0;
77
+ }
78
+ if ($column->getFilter()->getValue()) {
79
+ $this->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds));
80
+ } else {
81
+ if($productIds) {
82
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin' => $productIds));
83
+ }
84
+ }
85
+ } else {
86
+ parent::_addColumnFilterToCollection($column);
87
+ }
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Prepare collection
93
+ *
94
+ * @return Mage_Adminhtml_Block_Widget_Grid
95
+ */
96
+ protected function _prepareCollection()
97
+ {
98
+ $collection = Mage::getModel('catalog/product_link')->useRelatedLinks()
99
+ ->getProductCollection()
100
+ ->setProduct($this->_getProduct())
101
+ ->addAttributeToSelect('*');
102
+
103
+ if ($this->isReadonly()) {
104
+ $productIds = $this->_getSelectedProducts();
105
+ if (empty($productIds)) {
106
+ $productIds = array(0);
107
+ }
108
+ $collection->addFieldToFilter('entity_id', array('in' => $productIds));
109
+ }
110
+
111
+ $this->setCollection($collection);
112
+ return parent::_prepareCollection();
113
+ }
114
+
115
+ /**
116
+ * Checks when this block is readonly
117
+ *
118
+ * @return boolean
119
+ */
120
+ public function isReadonly()
121
+ {
122
+ return $this->_getProduct()->getRelatedReadonly();
123
+ }
124
+
125
+ /**
126
+ * Add columns to grid
127
+ *
128
+ * @return Mage_Adminhtml_Block_Widget_Grid
129
+ */
130
+ protected function _prepareColumns()
131
+ {
132
+ if (!$this->isReadonly()) {
133
+ $this->addColumn('in_products', array(
134
+ 'header_css_class' => 'a-center',
135
+ 'type' => 'checkbox',
136
+ 'name' => 'in_products',
137
+ 'values' => $this->_getSelectedProducts(),
138
+ 'align' => 'center',
139
+ 'index' => 'entity_id'
140
+ ));
141
+ }
142
+
143
+ $this->addColumn('entity_id', array(
144
+ 'header' => Mage::helper('catalog')->__('ID'),
145
+ 'sortable' => true,
146
+ 'width' => 60,
147
+ 'index' => 'entity_id'
148
+ ));
149
+
150
+ $this->addColumn('name', array(
151
+ 'header' => Mage::helper('catalog')->__('Name'),
152
+ 'index' => 'name'
153
+ ));
154
+
155
+ $this->addColumn('type', array(
156
+ 'header' => Mage::helper('catalog')->__('Type'),
157
+ 'width' => 100,
158
+ 'index' => 'type_id',
159
+ 'type' => 'options',
160
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
161
+ ));
162
+
163
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
164
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
165
+ ->load()
166
+ ->toOptionHash();
167
+
168
+ $this->addColumn('set_name', array(
169
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
170
+ 'width' => 130,
171
+ 'index' => 'attribute_set_id',
172
+ 'type' => 'options',
173
+ 'options' => $sets,
174
+ ));
175
+
176
+ $this->addColumn('status', array(
177
+ 'header' => Mage::helper('catalog')->__('Status'),
178
+ 'width' => 90,
179
+ 'index' => 'status',
180
+ 'type' => 'options',
181
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
182
+ ));
183
+
184
+ $this->addColumn('visibility', array(
185
+ 'header' => Mage::helper('catalog')->__('Visibility'),
186
+ 'width' => 90,
187
+ 'index' => 'visibility',
188
+ 'type' => 'options',
189
+ 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
190
+ ));
191
+
192
+ $this->addColumn('sku', array(
193
+ 'header' => Mage::helper('catalog')->__('SKU'),
194
+ 'width' => 80,
195
+ 'index' => 'sku'
196
+ ));
197
+
198
+ $this->addColumn('price', array(
199
+ 'header' => Mage::helper('catalog')->__('Price'),
200
+ 'type' => 'currency',
201
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
202
+ 'index' => 'price'
203
+ ));
204
+
205
+ $this->addColumn('position', array(
206
+ 'header' => Mage::helper('catalog')->__('Position'),
207
+ 'name' => 'position',
208
+ 'type' => 'number',
209
+ 'validate_class' => 'validate-number',
210
+ 'index' => 'position',
211
+ 'width' => 60,
212
+ 'editable' => !$this->_getProduct()->getRelatedReadonly(),
213
+ 'edit_only' => !$this->_getProduct()->getId()
214
+ ));
215
+
216
+ return parent::_prepareColumns();
217
+ }
218
+
219
+ /**
220
+ * Rerieve grid URL
221
+ *
222
+ * @return string
223
+ */
224
+ public function getGridUrl()
225
+ {
226
+ return $this->getData('grid_url')
227
+ ? $this->getData('grid_url')
228
+ : $this->getUrl('*/*/relatedGrid', array('_current' => true));
229
+ }
230
+
231
+ /**
232
+ * Retrieve selected related products
233
+ *
234
+ * @return array
235
+ */
236
+ protected function _getSelectedProducts()
237
+ {
238
+ $products = $this->getProductsRelated();
239
+ if (!is_array($products)) {
240
+ $products = array_keys($this->getSelectedRelatedProducts());
241
+ }
242
+ return $products;
243
+ }
244
+
245
+ /**
246
+ * Retrieve related products
247
+ *
248
+ * @return array
249
+ */
250
+ public function getSelectedRelatedProducts()
251
+ {
252
+ $products = array();
253
+ foreach (Mage::registry('current_product')->getRelatedProducts() as $product) {
254
+ $products[$product->getId()] = array('position' => $product->getPosition());
255
+ }
256
+ return $products;
257
+ }
258
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Reviews.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Reviews products admin grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Reviews extends Mage_Adminhtml_Block_Review_Grid
35
+ {
36
+ /**
37
+ * Hide grid mass action elements
38
+ *
39
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Reviews
40
+ */
41
+ protected function _prepareMassaction()
42
+ {
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Determine ajax url for grid refresh
48
+ *
49
+ * @return string
50
+ */
51
+ public function getGridUrl()
52
+ {
53
+ return $this->getUrl('*/*/reviews', array('_current' => true));
54
+ }
55
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Settings.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Create product settings tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Settings extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+ protected function _prepareLayout()
37
+ {
38
+ $this->setChild('continue_button',
39
+ $this->getLayout()->createBlock('adminhtml/widget_button')
40
+ ->setData(array(
41
+ 'label' => Mage::helper('catalog')->__('Continue'),
42
+ 'onclick' => "setSettings('".$this->getContinueUrl()."','attribute_set_id','product_type')",
43
+ 'class' => 'save'
44
+ ))
45
+ );
46
+ return parent::_prepareLayout();
47
+ }
48
+
49
+ protected function _prepareForm()
50
+ {
51
+ $form = new Varien_Data_Form();
52
+ $fieldset = $form->addFieldset('settings', array('legend'=>Mage::helper('catalog')->__('Create Product Settings')));
53
+
54
+ $entityType = Mage::registry('product')->getResource()->getEntityType();
55
+
56
+ $fieldset->addField('attribute_set_id', 'select', array(
57
+ 'label' => Mage::helper('catalog')->__('Attribute Set'),
58
+ 'title' => Mage::helper('catalog')->__('Attribute Set'),
59
+ 'name' => 'set',
60
+ 'value' => $entityType->getDefaultAttributeSetId(),
61
+ 'values'=> Mage::getResourceModel('eav/entity_attribute_set_collection')
62
+ ->setEntityTypeFilter($entityType->getId())
63
+ ->load()
64
+ ->toOptionArray()
65
+ ));
66
+
67
+ $fieldset->addField('product_type', 'select', array(
68
+ 'label' => Mage::helper('catalog')->__('Product Type'),
69
+ 'title' => Mage::helper('catalog')->__('Product Type'),
70
+ 'name' => 'type',
71
+ 'value' => '',
72
+ 'values'=> Mage::getModel('catalog/product_type')->getOptionArray()
73
+ ));
74
+
75
+ $fieldset->addField('continue_button', 'note', array(
76
+ 'text' => $this->getChildHtml('continue_button'),
77
+ ));
78
+
79
+ $this->setForm($form);
80
+ }
81
+
82
+ public function getContinueUrl()
83
+ {
84
+ return $this->getUrl('*/*/new', array(
85
+ '_current' => true,
86
+ 'set' => '{{attribute_set}}',
87
+ 'type' => '{{type}}'
88
+ ));
89
+ }
90
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml catalog super product configurable tab
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config extends Mage_Adminhtml_Block_Widget
36
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
+ {
38
+ /**
39
+ * Initialize block
40
+ *
41
+ */
42
+ public function __construct()
43
+ {
44
+ parent::__construct();
45
+ $this->setProductId($this->getRequest()->getParam('id'));
46
+ $this->setTemplate('catalog/product/edit/super/config.phtml');
47
+ $this->setId('config_super_product');
48
+ $this->setCanEditPrice(true);
49
+ $this->setCanReadPrice(true);
50
+ }
51
+
52
+ /**
53
+ * Retrieve Tab class (for loading)
54
+ *
55
+ * @return string
56
+ */
57
+ public function getTabClass()
58
+ {
59
+ return 'ajax';
60
+ }
61
+
62
+ /**
63
+ * Check block is readonly
64
+ *
65
+ * @return boolean
66
+ */
67
+ public function isReadonly()
68
+ {
69
+ return $this->_getProduct()->getCompositeReadonly();
70
+ }
71
+
72
+ /**
73
+ * Prepare Layout data
74
+ *
75
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config
76
+ */
77
+ protected function _prepareLayout()
78
+ {
79
+ $this->setChild('grid',
80
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_super_config_grid',
81
+ 'admin.product.edit.tab.super.config.grid')
82
+ );
83
+
84
+ $this->setChild('create_empty',
85
+ $this->getLayout()->createBlock('adminhtml/widget_button')
86
+ ->setData(array(
87
+ 'label' => Mage::helper('catalog')->__('Create Empty'),
88
+ 'class' => 'add',
89
+ 'onclick' => 'superProduct.createEmptyProduct()'
90
+ ))
91
+ );
92
+
93
+ if ($this->_getProduct()->getId()) {
94
+ $this->setChild('simple',
95
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_super_config_simple',
96
+ 'catalog.product.edit.tab.super.config.simple')
97
+ );
98
+
99
+ $this->setChild('create_from_configurable',
100
+ $this->getLayout()->createBlock('adminhtml/widget_button')
101
+ ->setData(array(
102
+ 'label' => Mage::helper('catalog')->__('Copy From Configurable'),
103
+ 'class' => 'add',
104
+ 'onclick' => 'superProduct.createNewProduct()'
105
+ ))
106
+ );
107
+ }
108
+
109
+ return parent::_prepareLayout();
110
+ }
111
+
112
+ /**
113
+ * Retrieve currently edited product object
114
+ *
115
+ * @return Mage_Catalog_Model_Product
116
+ */
117
+ protected function _getProduct()
118
+ {
119
+ return Mage::registry('current_product');
120
+ }
121
+
122
+ /**
123
+ * Retrieve attributes data in JSON format
124
+ *
125
+ * @return string
126
+ */
127
+ public function getAttributesJson()
128
+ {
129
+ $attributes = $this->_getProduct()->getTypeInstance(true)
130
+ ->getConfigurableAttributesAsArray($this->_getProduct());
131
+ if(!$attributes) {
132
+ return '[]';
133
+ } else {
134
+ // Hide price if needed
135
+ foreach ($attributes as &$attribute) {
136
+ if (isset($attribute['values']) && is_array($attribute['values'])) {
137
+ foreach ($attribute['values'] as &$attributeValue) {
138
+ if (!$this->getCanReadPrice()) {
139
+ $attributeValue['pricing_value'] = '';
140
+ $attributeValue['is_percent'] = 0;
141
+ }
142
+ $attributeValue['can_edit_price'] = $this->getCanEditPrice();
143
+ $attributeValue['can_read_price'] = $this->getCanReadPrice();
144
+ }
145
+ }
146
+ }
147
+ }
148
+ return Mage::helper('core')->jsonEncode($attributes);
149
+ }
150
+
151
+ /**
152
+ * Retrieve Links in JSON format
153
+ *
154
+ * @return string
155
+ */
156
+ public function getLinksJson()
157
+ {
158
+ $products = $this->_getProduct()->getTypeInstance(true)
159
+ ->getUsedProducts(null, $this->_getProduct());
160
+ if(!$products) {
161
+ return '{}';
162
+ }
163
+ $data = array();
164
+ foreach ($products as $product) {
165
+ $data[$product->getId()] = $this->getConfigurableSettings($product);
166
+ }
167
+ return Mage::helper('core')->jsonEncode($data);
168
+ }
169
+
170
+ /**
171
+ * Retrieve configurable settings
172
+ *
173
+ * @param Mage_Catalog_Model_Product $product
174
+ * @return array
175
+ */
176
+ public function getConfigurableSettings($product) {
177
+ $data = array();
178
+ $attributes = $this->_getProduct()->getTypeInstance(true)
179
+ ->getUsedProductAttributes($this->_getProduct());
180
+ foreach ($attributes as $attribute) {
181
+ $data[] = array(
182
+ 'attribute_id' => $attribute->getId(),
183
+ 'label' => $product->getAttributeText($attribute->getAttributeCode()),
184
+ 'value_index' => $product->getData($attribute->getAttributeCode())
185
+ );
186
+ }
187
+
188
+ return $data;
189
+ }
190
+
191
+ /**
192
+ * Retrieve Grid child HTML
193
+ *
194
+ * @return string
195
+ */
196
+ public function getGridHtml()
197
+ {
198
+ return $this->getChildHtml('grid');
199
+ }
200
+
201
+ /**
202
+ * Retrieve Grid JavaScript object name
203
+ *
204
+ * @return string
205
+ */
206
+ public function getGridJsObject()
207
+ {
208
+ return $this->getChild('grid')->getJsObjectName();
209
+ }
210
+
211
+ /**
212
+ * Retrieve Create New Empty Product URL
213
+ *
214
+ * @return string
215
+ */
216
+ public function getNewEmptyProductUrl()
217
+ {
218
+ return $this->getUrl(
219
+ '*/*/new',
220
+ array(
221
+ 'set' => $this->_getProduct()->getAttributeSetId(),
222
+ 'type' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
223
+ 'required' => $this->_getRequiredAttributesIds(),
224
+ 'popup' => 1
225
+ )
226
+ );
227
+ }
228
+
229
+ /**
230
+ * Retrieve Create New Product URL
231
+ *
232
+ * @return string
233
+ */
234
+ public function getNewProductUrl()
235
+ {
236
+ return $this->getUrl(
237
+ '*/*/new',
238
+ array(
239
+ 'set' => $this->_getProduct()->getAttributeSetId(),
240
+ 'type' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
241
+ 'required' => $this->_getRequiredAttributesIds(),
242
+ 'popup' => 1,
243
+ 'product' => $this->_getProduct()->getId()
244
+ )
245
+ );
246
+ }
247
+
248
+ /**
249
+ * Retrieve Quick create product URL
250
+ *
251
+ * @return string
252
+ */
253
+ public function getQuickCreationUrl()
254
+ {
255
+ return $this->getUrl(
256
+ '*/*/quickCreate',
257
+ array(
258
+ 'product' => $this->_getProduct()->getId()
259
+ )
260
+ );
261
+ }
262
+
263
+ /**
264
+ * Retrieve Required attributes Ids (comma separated)
265
+ *
266
+ * @return string
267
+ */
268
+ protected function _getRequiredAttributesIds()
269
+ {
270
+ $attributesIds = array();
271
+ $configurableAttributes = $this->_getProduct()
272
+ ->getTypeInstance(true)->getConfigurableAttributes($this->_getProduct());
273
+ foreach ($configurableAttributes as $attribute) {
274
+ $attributesIds[] = $attribute->getProductAttribute()->getId();
275
+ }
276
+
277
+ return implode(',', $attributesIds);
278
+ }
279
+
280
+ /**
281
+ * Escape JavaScript string
282
+ *
283
+ * @param string $string
284
+ * @return string
285
+ */
286
+ public function escapeJs($string)
287
+ {
288
+ return addcslashes($string, "'\r\n\\");
289
+ }
290
+
291
+ /**
292
+ * Retrieve Tab label
293
+ *
294
+ * @return string
295
+ */
296
+ public function getTabLabel()
297
+ {
298
+ return Mage::helper('catalog')->__('Associated Products');
299
+ }
300
+
301
+ /**
302
+ * Retrieve Tab title
303
+ *
304
+ * @return string
305
+ */
306
+ public function getTabTitle()
307
+ {
308
+ return Mage::helper('catalog')->__('Associated Products');
309
+ }
310
+
311
+ /**
312
+ * Can show tab flag
313
+ *
314
+ * @return bool
315
+ */
316
+ public function canShowTab()
317
+ {
318
+ return true;
319
+ }
320
+
321
+ /**
322
+ * Check is a hidden tab
323
+ *
324
+ * @return bool
325
+ */
326
+ public function isHidden()
327
+ {
328
+ return false;
329
+ }
330
+
331
+ /**
332
+ * Show "Use default price" checkbox
333
+ *
334
+ * @return bool
335
+ */
336
+ public function getShowUseDefaultPrice()
337
+ {
338
+ return !Mage::helper('catalog')->isPriceGlobal()
339
+ && $this->_getProduct()->getStoreId();
340
+ }
341
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid.php ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml super product links grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setUseAjax(true);
41
+ $this->setId('super_product_links');
42
+
43
+ if ($this->_getProduct()->getId()) {
44
+ $this->setDefaultFilter(array('in_products'=>1));
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Retrieve currently edited product object
50
+ *
51
+ * @return Mage_Catalog_Model_Product
52
+ */
53
+ protected function _getProduct()
54
+ {
55
+ return Mage::registry('current_product');
56
+ }
57
+
58
+ protected function _addColumnFilterToCollection($column)
59
+ {
60
+ // Set custom filter for in product flag
61
+ if ($column->getId() == 'in_products') {
62
+ $productIds = $this->_getSelectedProducts();
63
+
64
+ if (empty($productIds)) {
65
+ $productIds = 0;
66
+ }
67
+
68
+ $createdProducts = $this->_getCreatedProducts();
69
+
70
+ $existsProducts = $productIds; // Only for "Yes" Filter we will add created products
71
+
72
+ if(count($createdProducts)>0) {
73
+ if(!is_array($existsProducts)) {
74
+ $existsProducts = $createdProducts;
75
+ } else {
76
+ $existsProducts = array_merge($createdProducts);
77
+ }
78
+ }
79
+
80
+ if ($column->getFilter()->getValue()) {
81
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$existsProducts));
82
+ }
83
+ else {
84
+ if($productIds) {
85
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
86
+ }
87
+ }
88
+ }
89
+ else {
90
+ parent::_addColumnFilterToCollection($column);
91
+ }
92
+ return $this;
93
+ }
94
+
95
+ protected function _getCreatedProducts()
96
+ {
97
+ $products = $this->getRequest()->getPost('new_products', null);
98
+ if (!is_array($products)) {
99
+ $products = array();
100
+ }
101
+
102
+ return $products;
103
+ }
104
+
105
+ /**
106
+ * Prepare collection
107
+ *
108
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid
109
+ */
110
+ protected function _prepareCollection()
111
+ {
112
+ $allowProductTypes = array();
113
+ foreach (Mage::helper('catalog/product_configuration')->getConfigurableAllowedTypes() as $type) {
114
+ $allowProductTypes[] = $type->getName();
115
+ }
116
+
117
+ $product = $this->_getProduct();
118
+ $collection = $product->getCollection()
119
+ ->addAttributeToSelect('name')
120
+ ->addAttributeToSelect('sku')
121
+ ->addAttributeToSelect('attribute_set_id')
122
+ ->addAttributeToSelect('type_id')
123
+ ->addAttributeToSelect('price')
124
+ ->addFieldToFilter('attribute_set_id',$product->getAttributeSetId())
125
+ ->addFieldToFilter('type_id', $allowProductTypes)
126
+ ->addFilterByRequiredOptions()
127
+ ->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner');
128
+
129
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
130
+ Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($collection);
131
+ }
132
+
133
+ foreach ($product->getTypeInstance(true)->getUsedProductAttributes($product) as $attribute) {
134
+ $collection->addAttributeToSelect($attribute->getAttributeCode());
135
+ $collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull'=>1));
136
+ }
137
+
138
+ $this->setCollection($collection);
139
+
140
+ if ($this->isReadonly()) {
141
+ $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
142
+ }
143
+
144
+ parent::_prepareCollection();
145
+ return $this;
146
+ }
147
+
148
+ protected function _getSelectedProducts()
149
+ {
150
+ $products = $this->getRequest()->getPost('products', null);
151
+ if (!is_array($products)) {
152
+ $products = $this->_getProduct()->getTypeInstance(true)->getUsedProductIds($this->_getProduct());
153
+ }
154
+ return $products;
155
+ }
156
+
157
+ /**
158
+ * Check block is readonly
159
+ *
160
+ * @return boolean
161
+ */
162
+ public function isReadonly()
163
+ {
164
+ if ($this->hasData('is_readonly')) {
165
+ return $this->getData('is_readonly');
166
+ }
167
+ return $this->_getProduct()->getCompositeReadonly();
168
+ }
169
+
170
+ protected function _prepareColumns()
171
+ {
172
+ $product = $this->_getProduct();
173
+ $attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
174
+
175
+ if (!$this->isReadonly()) {
176
+ $this->addColumn('in_products', array(
177
+ 'header_css_class' => 'a-center',
178
+ 'type' => 'checkbox',
179
+ 'name' => 'in_products',
180
+ 'values' => $this->_getSelectedProducts(),
181
+ 'align' => 'center',
182
+ 'index' => 'entity_id',
183
+ 'renderer' => 'adminhtml/catalog_product_edit_tab_super_config_grid_renderer_checkbox',
184
+ 'attributes' => $attributes
185
+ ));
186
+ }
187
+
188
+ $this->addColumn('entity_id', array(
189
+ 'header' => Mage::helper('catalog')->__('ID'),
190
+ 'sortable' => true,
191
+ 'width' => '60px',
192
+ 'index' => 'entity_id'
193
+ ));
194
+ $this->addColumn('name', array(
195
+ 'header' => Mage::helper('catalog')->__('Name'),
196
+ 'index' => 'name'
197
+ ));
198
+
199
+
200
+ $sets = Mage::getModel('eav/entity_attribute_set')->getCollection()
201
+ ->setEntityTypeFilter($this->_getProduct()->getResource()->getTypeId())
202
+ ->load()
203
+ ->toOptionHash();
204
+
205
+ $this->addColumn('set_name',
206
+ array(
207
+ 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
208
+ 'width' => '130px',
209
+ 'index' => 'attribute_set_id',
210
+ 'type' => 'options',
211
+ 'options' => $sets,
212
+ ));
213
+
214
+ $this->addColumn('sku', array(
215
+ 'header' => Mage::helper('catalog')->__('SKU'),
216
+ 'width' => '80px',
217
+ 'index' => 'sku'
218
+ ));
219
+
220
+ $this->addColumn('price', array(
221
+ 'header' => Mage::helper('catalog')->__('Price'),
222
+ 'type' => 'currency',
223
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
224
+ 'index' => 'price'
225
+ ));
226
+
227
+ $this->addColumn('is_saleable', array(
228
+ 'header' => Mage::helper('catalog')->__('Inventory'),
229
+ 'renderer' => 'adminhtml/catalog_product_edit_tab_super_config_grid_renderer_inventory',
230
+ 'filter' => 'adminhtml/catalog_product_edit_tab_super_config_grid_filter_inventory',
231
+ 'index' => 'is_saleable'
232
+ ));
233
+
234
+ foreach ($attributes as $attribute) {
235
+ $productAttribute = $attribute->getProductAttribute();
236
+ $productAttribute->getSource();
237
+ $this->addColumn($productAttribute->getAttributeCode(), array(
238
+ 'header' => $productAttribute->getFrontend()->getLabel(),
239
+ 'index' => $productAttribute->getAttributeCode(),
240
+ 'type' => $productAttribute->getSourceModel() ? 'options' : 'number',
241
+ 'options' => $productAttribute->getSourceModel() ? $this->getOptions($attribute) : ''
242
+ ));
243
+ }
244
+
245
+ $this->addColumn('action',
246
+ array(
247
+ 'header' => Mage::helper('catalog')->__('Action'),
248
+ 'type' => 'action',
249
+ 'getter' => 'getId',
250
+ 'actions' => array(
251
+ array(
252
+ 'caption' => Mage::helper('catalog')->__('Edit'),
253
+ 'url' => $this->getEditParamsForAssociated(),
254
+ 'field' => 'id',
255
+ 'onclick' => 'superProduct.createPopup(this.href);return false;'
256
+ )
257
+ ),
258
+ 'filter' => false,
259
+ 'sortable' => false
260
+ ));
261
+
262
+ return parent::_prepareColumns();
263
+ }
264
+
265
+ public function getEditParamsForAssociated()
266
+ {
267
+ return array(
268
+ 'base' => '*/*/edit',
269
+ 'params' => array(
270
+ 'required' => $this->_getRequiredAttributesIds(),
271
+ 'popup' => 1,
272
+ 'product' => $this->_getProduct()->getId()
273
+ )
274
+ );
275
+ }
276
+
277
+ /**
278
+ * Retrieve Required attributes Ids (comma separated)
279
+ *
280
+ * @return string
281
+ */
282
+ protected function _getRequiredAttributesIds()
283
+ {
284
+ $attributesIds = array();
285
+ foreach (
286
+ $this->_getProduct()
287
+ ->getTypeInstance(true)
288
+ ->getConfigurableAttributes($this->_getProduct()) as $attribute
289
+ ) {
290
+ $attributesIds[] = $attribute->getProductAttribute()->getId();
291
+ }
292
+
293
+ return implode(',', $attributesIds);
294
+ }
295
+
296
+ public function getOptions($attribute) {
297
+ $result = array();
298
+ foreach ($attribute->getProductAttribute()->getSource()->getAllOptions() as $option) {
299
+ if($option['value']!='') {
300
+ $result[$option['value']] = $option['label'];
301
+ }
302
+ }
303
+
304
+ return $result;
305
+ }
306
+
307
+ public function getGridUrl()
308
+ {
309
+ return $this->getUrl('*/*/superConfig', array('_current'=>true));
310
+ }
311
+
312
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Configurable product associated products in stock filter
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid_Filter_Inventory extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
36
+ {
37
+
38
+ protected function _getOptions()
39
+ {
40
+ return array(
41
+ array(
42
+ 'value' => '',
43
+ 'label' => ''
44
+ ),
45
+ array(
46
+ 'value' => 1,
47
+ 'label' => Mage::helper('catalog')->__('In Stock')
48
+ ),
49
+ array(
50
+ 'value' => 0,
51
+ 'label' => Mage::helper('catalog')->__('Out of Stock')
52
+ )
53
+ );
54
+ }
55
+
56
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml catalog super product link grid checkbox renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid_Renderer_Checkbox extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Checkbox
36
+ {
37
+ /**
38
+ * Renders grid column
39
+ *
40
+ * @param Varien_Object $row
41
+ * @return string
42
+ */
43
+ public function render(Varien_Object $row)
44
+ {
45
+ $result = parent::render($row);
46
+ return $result.'<input type="hidden" class="value-json" value="'.htmlspecialchars($this->getAttributesJson($row)).'" />';
47
+ }
48
+
49
+ public function getAttributesJson(Varien_Object $row)
50
+ {
51
+ if(!$this->getColumn()->getAttributes()) {
52
+ return '[]';
53
+ }
54
+
55
+ $result = array();
56
+ foreach($this->getColumn()->getAttributes() as $attribute) {
57
+ $productAttribute = $attribute->getProductAttribute();
58
+ if($productAttribute->getSourceModel()) {
59
+ $label = $productAttribute->getSource()->getOptionText($row->getData($productAttribute->getAttributeCode()));
60
+ } else {
61
+ $label = $row->getData($productAttribute->getAttributeCode());
62
+ }
63
+ $item = array();
64
+ $item['label'] = $label;
65
+ $item['attribute_id'] = $productAttribute->getId();
66
+ $item['value_index'] = $row->getData($productAttribute->getAttributeCode());
67
+ $result[] = $item;
68
+ }
69
+
70
+ return Mage::helper('core')->jsonEncode($result);
71
+ }
72
+ }// Class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid_Renderer_Checkbox END
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Renderer/Inventory.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Configurable product assocciated products grid in stock renderer
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid_Renderer_Inventory extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
36
+ {
37
+ /**
38
+ * Renders grid column value
39
+ *
40
+ * @param Varien_Object $row
41
+ * @return string
42
+ */
43
+ public function render(Varien_Object $row)
44
+ {
45
+ $inStock = $this->_getValue($row);
46
+ return $inStock ?
47
+ Mage::helper('catalog')->__('In Stock')
48
+ : Mage::helper('catalog')->__('Out of Stock');
49
+ }
50
+
51
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Quiq simple product creation
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes
35
+ {
36
+ /**
37
+ * Link to currently editing product
38
+ *
39
+ * @var Mage_Catalog_Model_Product
40
+ */
41
+ protected $_product = null;
42
+
43
+ protected function _prepareForm()
44
+ {
45
+ $form = new Varien_Data_Form();
46
+
47
+ $form->setFieldNameSuffix('simple_product');
48
+ $form->setDataObject($this->_getProduct());
49
+
50
+ $fieldset = $form->addFieldset('simple_product', array(
51
+ 'legend' => Mage::helper('catalog')->__('Quick simple product creation')
52
+ ));
53
+ $this->_addElementTypes($fieldset);
54
+ $attributesConfig = array(
55
+ 'autogenerate' => array('name', 'sku'),
56
+ 'additional' => array('name', 'sku', 'visibility', 'status')
57
+ );
58
+
59
+ $availableTypes = array('text', 'select', 'multiselect', 'textarea', 'price');
60
+
61
+ $attributes = Mage::getModel('catalog/product')
62
+ ->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
63
+ ->setAttributeSetId($this->_getProduct()->getAttributeSetId())
64
+ ->getAttributes();
65
+
66
+ /* Standart attributes */
67
+ foreach ($attributes as $attribute) {
68
+ if (($attribute->getIsRequired()
69
+ && $attribute->getApplyTo()
70
+ // If not applied to configurable
71
+ && !in_array(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE, $attribute->getApplyTo())
72
+ // If not used in configurable
73
+ && !in_array($attribute->getId(),$this->_getProduct()->getTypeInstance(true)->getUsedProductAttributeIds($this->_getProduct())))
74
+ // Or in additional
75
+ || in_array($attribute->getAttributeCode(), $attributesConfig['additional'])) {
76
+
77
+ $inputType = $attribute->getFrontend()->getInputType();
78
+ if (!in_array($inputType, $availableTypes)) {
79
+ continue;
80
+ }
81
+ $attributeCode = $attribute->getAttributeCode();
82
+ $attribute->setAttributeCode('simple_product_' . $attributeCode);
83
+ $element = $fieldset->addField(
84
+ 'simple_product_' . $attributeCode,
85
+ $inputType,
86
+ array(
87
+ 'label' => $attribute->getFrontend()->getLabel(),
88
+ 'name' => $attributeCode,
89
+ 'required' => $attribute->getIsRequired(),
90
+ )
91
+ )->setEntityAttribute($attribute);
92
+
93
+ if (in_array($attributeCode, $attributesConfig['autogenerate'])) {
94
+ $element->setDisabled('true');
95
+ $element->setValue($this->_getProduct()->getData($attributeCode));
96
+ $element->setAfterElementHtml(
97
+ '<input type="checkbox" id="simple_product_' . $attributeCode . '_autogenerate" '
98
+ . 'name="simple_product[' . $attributeCode . '_autogenerate]" value="1" '
99
+ . 'onclick="toggleValueElements(this, this.parentNode)" checked="checked" /> '
100
+ . '<label for="simple_product_' . $attributeCode . '_autogenerate" >'
101
+ . Mage::helper('catalog')->__('Autogenerate')
102
+ . '</label>'
103
+ );
104
+ }
105
+
106
+
107
+ if ($inputType == 'select' || $inputType == 'multiselect') {
108
+ $element->setValues($attribute->getFrontend()->getSelectOptions());
109
+ }
110
+ }
111
+
112
+ }
113
+
114
+ /* Configurable attributes */
115
+ foreach ($this->_getProduct()->getTypeInstance(true)->getUsedProductAttributes($this->_getProduct()) as $attribute) {
116
+ $attributeCode = $attribute->getAttributeCode();
117
+ $fieldset->addField( 'simple_product_' . $attributeCode, 'select', array(
118
+ 'label' => $attribute->getFrontend()->getLabel(),
119
+ 'name' => $attributeCode,
120
+ 'values' => $attribute->getSource()->getAllOptions(true, true),
121
+ 'required' => true,
122
+ 'class' => 'validate-configurable',
123
+ 'onchange' => 'superProduct.showPricing(this, \'' . $attributeCode . '\')'
124
+ ));
125
+
126
+ $fieldset->addField('simple_product_' . $attributeCode . '_pricing_value', 'hidden', array(
127
+ 'name' => 'pricing[' . $attributeCode . '][value]'
128
+ ));
129
+
130
+ $fieldset->addField('simple_product_' . $attributeCode . '_pricing_type', 'hidden', array(
131
+ 'name' => 'pricing[' . $attributeCode . '][is_percent]'
132
+ ));
133
+ }
134
+
135
+ /* Inventory Data */
136
+ $fieldset->addField('simple_product_inventory_qty', 'text', array(
137
+ 'label' => Mage::helper('catalog')->__('Qty'),
138
+ 'name' => 'stock_data[qty]',
139
+ 'class' => 'validate-number',
140
+ 'required' => true,
141
+ 'value' => 0
142
+ ));
143
+
144
+ $fieldset->addField('simple_product_inventory_is_in_stock', 'select', array(
145
+ 'label' => Mage::helper('catalog')->__('Stock Availability'),
146
+ 'name' => 'stock_data[is_in_stock]',
147
+ 'values' => array(
148
+ array('value'=>1, 'label'=> Mage::helper('catalog')->__('In Stock')),
149
+ array('value'=>0, 'label'=> Mage::helper('catalog')->__('Out of Stock'))
150
+ ),
151
+ 'value' => 1
152
+ ));
153
+
154
+ $stockHiddenFields = array(
155
+ 'use_config_min_qty' => 1,
156
+ 'use_config_min_sale_qty' => 1,
157
+ 'use_config_max_sale_qty' => 1,
158
+ 'use_config_backorders' => 1,
159
+ 'use_config_notify_stock_qty' => 1,
160
+ 'is_qty_decimal' => 0
161
+ );
162
+
163
+ foreach ($stockHiddenFields as $fieldName=>$fieldValue) {
164
+ $fieldset->addField('simple_product_inventory_' . $fieldName, 'hidden', array(
165
+ 'name' => 'stock_data[' . $fieldName .']',
166
+ 'value' => $fieldValue
167
+ ));
168
+ }
169
+
170
+
171
+ $fieldset->addField('create_button', 'note', array(
172
+ 'text' => $this->getButtonHtml(
173
+ Mage::helper('catalog')->__('Quick Create'),
174
+ 'superProduct.quickCreateNewProduct()',
175
+ 'save'
176
+ )
177
+ ));
178
+
179
+
180
+
181
+ $this->setForm($form);
182
+ }
183
+
184
+ /**
185
+ * Retrieve currently edited product object
186
+ *
187
+ * @return Mage_Catalog_Model_Product
188
+ */
189
+ protected function _getProduct()
190
+ {
191
+ if (!$this->_product) {
192
+ $this->_product = Mage::registry('current_product');
193
+ }
194
+ return $this->_product;
195
+ }
196
+ } // Class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple End
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product in category grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group extends Mage_Adminhtml_Block_Widget_Grid
35
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('super_product_grid');
41
+ $this->setDefaultSort('entity_id');
42
+ $this->setSkipGenerateContent(true);
43
+ $this->setUseAjax(true);
44
+ if ($this->_getProduct()->getId()) {
45
+ $this->setDefaultFilter(array('in_products'=>1));
46
+ }
47
+ }
48
+
49
+ public function getTabUrl()
50
+ {
51
+ return $this->getUrl('*/*/superGroup', array('_current'=>true));
52
+ }
53
+
54
+ public function getTabClass()
55
+ {
56
+ return 'ajax';
57
+ }
58
+
59
+ /**
60
+ * Retrieve currently edited product model
61
+ *
62
+ * @return Mage_Catalog_Model_Product
63
+ */
64
+ protected function _getProduct()
65
+ {
66
+ return Mage::registry('current_product');
67
+ }
68
+
69
+ protected function _addColumnFilterToCollection($column)
70
+ {
71
+ // Set custom filter for in product flag
72
+ if ($column->getId() == 'in_products') {
73
+ $productIds = $this->_getSelectedProducts();
74
+ if (empty($productIds)) {
75
+ $productIds = 0;
76
+ }
77
+ if ($column->getFilter()->getValue()) {
78
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
79
+ }
80
+ else {
81
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
82
+ }
83
+ }
84
+ else {
85
+ parent::_addColumnFilterToCollection($column);
86
+ }
87
+
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Prepare collection
93
+ *
94
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group
95
+ */
96
+ protected function _prepareCollection()
97
+ {
98
+ $allowProductTypes = array();
99
+ $allowProductTypeNodes = Mage::getConfig()
100
+ ->getNode('global/catalog/product/type/grouped/allow_product_types')->children();
101
+ foreach ($allowProductTypeNodes as $type) {
102
+ $allowProductTypes[] = $type->getName();
103
+ }
104
+
105
+ $collection = Mage::getModel('catalog/product_link')->useGroupedLinks()
106
+ ->getProductCollection()
107
+ ->setProduct($this->_getProduct())
108
+ ->addAttributeToSelect('*')
109
+ ->addFilterByRequiredOptions()
110
+ ->addAttributeToFilter('type_id', $allowProductTypes);
111
+
112
+ if ($this->getIsReadonly() === true) {
113
+ $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
114
+ }
115
+ $this->setCollection($collection);
116
+ return parent::_prepareCollection();
117
+ }
118
+
119
+ protected function _prepareColumns()
120
+ {
121
+ $this->addColumn('in_products', array(
122
+ 'header_css_class' => 'a-center',
123
+ 'type' => 'checkbox',
124
+ 'name' => 'in_products',
125
+ 'values' => $this->_getSelectedProducts(),
126
+ 'align' => 'center',
127
+ 'index' => 'entity_id'
128
+ ));
129
+
130
+ $this->addColumn('entity_id', array(
131
+ 'header' => Mage::helper('catalog')->__('ID'),
132
+ 'sortable' => true,
133
+ 'width' => '60px',
134
+ 'index' => 'entity_id'
135
+ ));
136
+ $this->addColumn('name', array(
137
+ 'header' => Mage::helper('catalog')->__('Name'),
138
+ 'index' => 'name'
139
+ ));
140
+ $this->addColumn('sku', array(
141
+ 'header' => Mage::helper('catalog')->__('SKU'),
142
+ 'width' => '80px',
143
+ 'index' => 'sku'
144
+ ));
145
+ $this->addColumn('price', array(
146
+ 'header' => Mage::helper('catalog')->__('Price'),
147
+ 'type' => 'currency',
148
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
149
+ 'index' => 'price'
150
+ ));
151
+
152
+ $this->addColumn('qty', array(
153
+ 'header' => Mage::helper('catalog')->__('Default Qty'),
154
+ 'name' => 'qty',
155
+ 'type' => 'number',
156
+ 'validate_class' => 'validate-number',
157
+ 'index' => 'qty',
158
+ 'width' => '1',
159
+ 'editable' => true
160
+ ));
161
+
162
+ $this->addColumn('position', array(
163
+ 'header' => Mage::helper('catalog')->__('Position'),
164
+ 'name' => 'position',
165
+ 'type' => 'number',
166
+ 'validate_class' => 'validate-number',
167
+ 'index' => 'position',
168
+ 'width' => '1',
169
+ 'editable' => true,
170
+ 'edit_only' => !$this->_getProduct()->getId()
171
+ ));
172
+
173
+ return parent::_prepareColumns();
174
+ }
175
+
176
+ /**
177
+ * Get Grid Url
178
+ *
179
+ * @return string
180
+ */
181
+ public function getGridUrl()
182
+ {
183
+ return $this->_getData('grid_url')
184
+ ? $this->_getData('grid_url') : $this->getUrl('*/*/superGroupGridOnly', array('_current'=>true));
185
+ }
186
+
187
+ /**
188
+ * Retrieve selected grouped products
189
+ *
190
+ * @return array
191
+ */
192
+ protected function _getSelectedProducts()
193
+ {
194
+ $products = $this->getProductsGrouped();
195
+ if (!is_array($products)) {
196
+ $products = array_keys($this->getSelectedGroupedProducts());
197
+ }
198
+ return $products;
199
+ }
200
+
201
+ /**
202
+ * Retrieve grouped products
203
+ *
204
+ * @return array
205
+ */
206
+ public function getSelectedGroupedProducts()
207
+ {
208
+ $associatedProducts = Mage::registry('current_product')->getTypeInstance(true)
209
+ ->getAssociatedProducts(Mage::registry('current_product'));
210
+ $products = array();
211
+ foreach ($associatedProducts as $product) {
212
+ $products[$product->getId()] = array(
213
+ 'qty' => $product->getQty(),
214
+ 'position' => $product->getPosition()
215
+ );
216
+ }
217
+ return $products;
218
+ }
219
+
220
+ public function getTabLabel()
221
+ {
222
+ return Mage::helper('catalog')->__('Associated Products');
223
+ }
224
+ public function getTabTitle()
225
+ {
226
+ return Mage::helper('catalog')->__('Associated Products');
227
+ }
228
+ public function canShowTab()
229
+ {
230
+ return true;
231
+ }
232
+ public function isHidden()
233
+ {
234
+ return false;
235
+ }
236
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Create Configuranle procuct Settings Tab Block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+ /**
38
+ * Prepare block children and data
39
+ *
40
+ */
41
+ protected function _prepareLayout()
42
+ {
43
+ $onclick = "setSuperSettings('".$this->getContinueUrl()."','attribute-checkbox', 'attributes')";
44
+ $this->setChild('continue_button',
45
+ $this->getLayout()->createBlock('adminhtml/widget_button')
46
+ ->setData(array(
47
+ 'label' => Mage::helper('catalog')->__('Continue'),
48
+ 'onclick' => $onclick,
49
+ 'class' => 'save'
50
+ ))
51
+ );
52
+
53
+ $backButton = $this->getLayout()->createBlock('adminhtml/widget_button')
54
+ ->setData(array(
55
+ 'label' => Mage::helper('catalog')->__('Back'),
56
+ 'onclick' => "setLocation('".$this->getBackUrl()."')",
57
+ 'class' => 'back'
58
+ ));
59
+
60
+ $this->setChild('back_button', $backButton);
61
+ parent::_prepareLayout();
62
+ }
63
+
64
+ /**
65
+ * Retrieve currently edited product object
66
+ *
67
+ * @return Mage_Catalog_Model_Product
68
+ */
69
+ protected function _getProduct()
70
+ {
71
+ return Mage::registry('current_product');
72
+ }
73
+
74
+ /**
75
+ * Prepare form before rendering HTML
76
+ *
77
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings
78
+ */
79
+ protected function _prepareForm()
80
+ {
81
+ $form = new Varien_Data_Form();
82
+ $fieldset = $form->addFieldset('settings', array(
83
+ 'legend'=>Mage::helper('catalog')->__('Select Configurable Attributes ')
84
+ ));
85
+
86
+ $product = $this->_getProduct();
87
+ $attributes = $product->getTypeInstance(true)
88
+ ->getSetAttributes($product);
89
+
90
+ $fieldset->addField('req_text', 'note', array(
91
+ 'text' => '<ul class="messages"><li class="notice-msg"><ul><li>'
92
+ . $this->__('Only attributes with scope "Global", input type "Dropdown" and Use To Create Configurable Product "Yes" are available.')
93
+ . '</li></ul></li></ul>'
94
+ ));
95
+
96
+ $hasAttributes = false;
97
+
98
+ foreach ($attributes as $attribute) {
99
+ if ($product->getTypeInstance(true)->canUseAttribute($attribute, $product)) {
100
+ $hasAttributes = true;
101
+ $fieldset->addField('attribute_'.$attribute->getAttributeId(), 'checkbox', array(
102
+ 'label' => $attribute->getFrontend()->getLabel(),
103
+ 'title' => $attribute->getFrontend()->getLabel(),
104
+ 'name' => 'attribute',
105
+ 'class' => 'attribute-checkbox',
106
+ 'value' => $attribute->getAttributeId()
107
+ ));
108
+ }
109
+ }
110
+
111
+ if ($hasAttributes) {
112
+ $fieldset->addField('attributes', 'hidden', array(
113
+ 'name' => 'attribute_validate',
114
+ 'value' => '',
115
+ 'class' => 'validate-super-product-attributes'
116
+ ));
117
+
118
+ $fieldset->addField('continue_button', 'note', array(
119
+ 'text' => $this->getChildHtml('continue_button'),
120
+ ));
121
+ }
122
+ else {
123
+ $fieldset->addField('note_text', 'note', array(
124
+ 'text' => $this->__('This attribute set does not have attributes which we can use for configurable product')
125
+ ));
126
+ $fieldset->addField('back_button', 'note', array(
127
+ 'text' => $this->getChildHtml('back_button'),
128
+ ));
129
+ }
130
+
131
+
132
+ $this->setForm($form);
133
+
134
+ return parent::_prepareForm();
135
+ }
136
+
137
+ /**
138
+ * Retrieve Continue URL
139
+ *
140
+ * @return string
141
+ */
142
+ public function getContinueUrl()
143
+ {
144
+ return $this->getUrl('*/*/new', array(
145
+ '_current' => true,
146
+ 'attributes' => '{{attributes}}'
147
+ ));
148
+ }
149
+
150
+ /**
151
+ * Retrieve Back URL
152
+ *
153
+ * @return string
154
+ */
155
+ public function getBackUrl()
156
+ {
157
+ return $this->getUrl('*/*/new', array('set'=>null, 'type'=>null));
158
+ }
159
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Products' tags grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Tag extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('tag_grid');
41
+ $this->setDefaultSort('name');
42
+ $this->setDefaultDir('ASC');
43
+ $this->setUseAjax(true);
44
+ }
45
+
46
+ protected function _prepareCollection()
47
+ {
48
+ $collection = Mage::getModel('tag/tag')
49
+ ->getResourceCollection()
50
+ ->addProductFilter($this->getProductId())
51
+ ->addPopularity();
52
+
53
+ $this->setCollection($collection);
54
+ return parent::_prepareCollection();
55
+ }
56
+
57
+ protected function _afterLoadCollection()
58
+ {
59
+ return parent::_afterLoadCollection();
60
+ }
61
+
62
+ protected function _prepareColumns()
63
+ {
64
+ $this->addColumn('name', array(
65
+ 'header' => Mage::helper('catalog')->__('Tag Name'),
66
+ 'index' => 'name',
67
+ ));
68
+
69
+ $this->addColumn('popularity', array(
70
+ 'header' => Mage::helper('catalog')->__('# of Use'),
71
+ 'width' => '50px',
72
+ 'align' => 'right',
73
+ 'index' => 'popularity',
74
+ 'type' => 'number',
75
+ ));
76
+
77
+ $this->addColumn('status', array(
78
+ 'header' => Mage::helper('catalog')->__('Status'),
79
+ 'width' => '90px',
80
+ 'index' => 'status',
81
+ 'type' => 'options',
82
+ 'options' => array(
83
+ Mage_Tag_Model_Tag::STATUS_DISABLED => Mage::helper('catalog')->__('Disabled'),
84
+ Mage_Tag_Model_Tag::STATUS_PENDING => Mage::helper('catalog')->__('Pending'),
85
+ Mage_Tag_Model_Tag::STATUS_APPROVED => Mage::helper('catalog')->__('Approved'),
86
+ ),
87
+ ));
88
+
89
+ return parent::_prepareColumns();
90
+ }
91
+
92
+ public function getRowUrl($row)
93
+ {
94
+ return $this->getUrl('*/tag/edit', array(
95
+ 'tag_id' => $row->getId(),
96
+ 'product_id' => $this->getProductId(),
97
+ ));
98
+ }
99
+
100
+ public function getGridUrl()
101
+ {
102
+ return $this->getUrl('*/catalog_product/tagGrid', array(
103
+ '_current' => true,
104
+ 'id' => $this->getProductId(),
105
+ 'product_id' => $this->getProductId(),
106
+ ));
107
+ }
108
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag/Customer.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * List of customers tagged a product
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Tag_Customer extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('tag_customers_grid');
41
+ $this->setDefaultSort('firstname');
42
+ $this->setDefaultDir('ASC');
43
+ $this->setUseAjax(true);
44
+ }
45
+
46
+ protected function _prepareCollection()
47
+ {
48
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Tag')) {
49
+ $collection = Mage::getModel('tag/tag')
50
+ ->getCustomerCollection()
51
+ ->addProductFilter($this->getProductId())
52
+ ->addGroupByTag()
53
+ ->addDescOrder();
54
+
55
+ $this->setCollection($collection);
56
+ }
57
+ return parent::_prepareCollection();
58
+ }
59
+
60
+ protected function _afterLoadCollection()
61
+ {
62
+ return parent::_afterLoadCollection();
63
+ }
64
+
65
+ protected function _prepareColumns()
66
+ {
67
+ $this->addColumn('firstname', array(
68
+ 'header' => Mage::helper('catalog')->__('First Name'),
69
+ 'index' => 'firstname',
70
+ ));
71
+
72
+ $this->addColumn('lastname', array(
73
+ 'header' => Mage::helper('catalog')->__('Last Name'),
74
+ 'index' => 'lastname',
75
+ ));
76
+
77
+ $this->addColumn('email', array(
78
+ 'header' => Mage::helper('catalog')->__('Email'),
79
+ 'index' => 'email',
80
+ ));
81
+
82
+ $this->addColumn('name', array(
83
+ 'header' => Mage::helper('catalog')->__('Tag Name'),
84
+ 'index' => 'name',
85
+ ));
86
+
87
+ return parent::_prepareColumns();
88
+ }
89
+
90
+ public function getRowUrl($row)
91
+ {
92
+ return $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId()));
93
+ }
94
+
95
+ public function getGridUrl()
96
+ {
97
+ return $this->getUrl('*/catalog_product/tagCustomerGrid', array(
98
+ '_current' => true,
99
+ 'id' => $this->getProductId(),
100
+ 'product_id' => $this->getProductId(),
101
+ ));
102
+ }
103
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Upsell products admin grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Upsell extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ /**
38
+ * Set grid params
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ $this->setId('up_sell_product_grid');
45
+ $this->setDefaultSort('entity_id');
46
+ $this->setUseAjax(true);
47
+ if ($this->_getProduct()->getId()) {
48
+ $this->setDefaultFilter(array('in_products'=>1));
49
+ }
50
+ if ($this->isReadonly()) {
51
+ $this->setFilterVisibility(false);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Retirve currently edited product model
57
+ *
58
+ * @return Mage_Catalog_Model_Product
59
+ */
60
+ protected function _getProduct()
61
+ {
62
+ return Mage::registry('current_product');
63
+ }
64
+
65
+ /**
66
+ * Add filter
67
+ *
68
+ * @param object $column
69
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Upsell
70
+ */
71
+ protected function _addColumnFilterToCollection($column)
72
+ {
73
+ // Set custom filter for in product flag
74
+ if ($column->getId() == 'in_products') {
75
+ $productIds = $this->_getSelectedProducts();
76
+ if (empty($productIds)) {
77
+ $productIds = 0;
78
+ }
79
+ if ($column->getFilter()->getValue()) {
80
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
81
+ } else {
82
+ if($productIds) {
83
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
84
+ }
85
+ }
86
+ } else {
87
+ parent::_addColumnFilterToCollection($column);
88
+ }
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * Checks when this block is readonly
94
+ *
95
+ * @return boolean
96
+ */
97
+ public function isReadonly()
98
+ {
99
+ return $this->_getProduct()->getUpsellReadonly();
100
+ }
101
+
102
+ /**
103
+ * Prepare collection
104
+ *
105
+ * @return Mage_Adminhtml_Block_Widget_Grid
106
+ */
107
+ protected function _prepareCollection()
108
+ {
109
+ $collection = Mage::getModel('catalog/product_link')->useUpSellLinks()
110
+ ->getProductCollection()
111
+ ->setProduct($this->_getProduct())
112
+ ->addAttributeToSelect('*');
113
+
114
+ if ($this->isReadonly()) {
115
+ $productIds = $this->_getSelectedProducts();
116
+ if (empty($productIds)) {
117
+ $productIds = array(0);
118
+ }
119
+ $collection->addFieldToFilter('entity_id', array('in'=>$productIds));
120
+ }
121
+
122
+ $this->setCollection($collection);
123
+ return parent::_prepareCollection();
124
+ }
125
+
126
+ /**
127
+ * Add columns to grid
128
+ *
129
+ * @return Mage_Adminhtml_Block_Widget_Grid
130
+ */
131
+ protected function _prepareColumns()
132
+ {
133
+ if (!$this->_getProduct()->getUpsellReadonly()) {
134
+ $this->addColumn('in_products', array(
135
+ 'header_css_class' => 'a-center',
136
+ 'type' => 'checkbox',
137
+ 'name' => 'in_products',
138
+ 'values' => $this->_getSelectedProducts(),
139
+ 'align' => 'center',
140
+ 'index' => 'entity_id'
141
+ ));
142
+ }
143
+
144
+ $this->addColumn('entity_id', array(
145
+ 'header' => Mage::helper('catalog')->__('ID'),
146
+ 'sortable' => true,
147
+ 'width' => 60,
148
+ 'index' => 'entity_id'
149
+ ));
150
+ $this->addColumn('name', array(
151
+ 'header' => Mage::helper('catalog')->__('Name'),
152
+ 'index' => 'name'
153
+ ));
154
+
155
+ $this->addColumn('type', array(
156
+ 'header' => Mage::helper('catalog')->__('Type'),
157
+ 'width' => 100,
158
+ 'index' => 'type_id',
159
+ 'type' => 'options',
160
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
161
+ ));
162
+
163
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
164
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
165
+ ->load()
166
+ ->toOptionHash();
167
+
168
+ $this->addColumn('set_name', array(
169
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
170
+ 'width' => 130,
171
+ 'index' => 'attribute_set_id',
172
+ 'type' => 'options',
173
+ 'options' => $sets,
174
+ ));
175
+
176
+ $this->addColumn('status', array(
177
+ 'header' => Mage::helper('catalog')->__('Status'),
178
+ 'width' => 90,
179
+ 'index' => 'status',
180
+ 'type' => 'options',
181
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
182
+ ));
183
+
184
+ $this->addColumn('visibility', array(
185
+ 'header' => Mage::helper('catalog')->__('Visibility'),
186
+ 'width' => 90,
187
+ 'index' => 'visibility',
188
+ 'type' => 'options',
189
+ 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
190
+ ));
191
+
192
+ $this->addColumn('sku', array(
193
+ 'header' => Mage::helper('catalog')->__('SKU'),
194
+ 'width' => 80,
195
+ 'index' => 'sku'
196
+ ));
197
+
198
+ $this->addColumn('price', array(
199
+ 'header' => Mage::helper('catalog')->__('Price'),
200
+ 'type' => 'currency',
201
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
202
+ 'index' => 'price'
203
+ ));
204
+
205
+ $this->addColumn('position', array(
206
+ 'header' => Mage::helper('catalog')->__('Position'),
207
+ 'name' => 'position',
208
+ 'type' => 'number',
209
+ 'width' => 60,
210
+ 'validate_class' => 'validate-number',
211
+ 'index' => 'position',
212
+ 'editable' => !$this->_getProduct()->getUpsellReadonly(),
213
+ 'edit_only' => !$this->_getProduct()->getId()
214
+ ));
215
+
216
+ return parent::_prepareColumns();
217
+ }
218
+
219
+ /**
220
+ * Rerieve grid URL
221
+ *
222
+ * @return string
223
+ */
224
+ public function getGridUrl()
225
+ {
226
+ return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/upsellGrid', array('_current'=>true));
227
+ }
228
+
229
+ /**
230
+ * Retrieve selected upsell products
231
+ *
232
+ * @return array
233
+ */
234
+ protected function _getSelectedProducts()
235
+ {
236
+ $products = $this->getProductsUpsell();
237
+ if (!is_array($products)) {
238
+ $products = array_keys($this->getSelectedUpsellProducts());
239
+ }
240
+ return $products;
241
+ }
242
+
243
+ /**
244
+ * Retrieve upsell products
245
+ *
246
+ * @return array
247
+ */
248
+ public function getSelectedUpsellProducts()
249
+ {
250
+ $products = array();
251
+ foreach (Mage::registry('current_product')->getUpSellProducts() as $product) {
252
+ $products[$product->getId()] = array('position' => $product->getPosition());
253
+ }
254
+ return $products;
255
+ }
256
+
257
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Websites.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product Stores tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Websites extends Mage_Adminhtml_Block_Store_Switcher
35
+ {
36
+ protected $_storeFromHtml;
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setTemplate('catalog/product/edit/websites.phtml');
42
+ }
43
+
44
+ /**
45
+ * Retrieve edited product model instance
46
+ *
47
+ * @return Mage_Catalog_Model_Product
48
+ */
49
+ public function getProduct()
50
+ {
51
+ return Mage::registry('product');
52
+ }
53
+
54
+ public function getStoreId()
55
+ {
56
+ return $this->getProduct()->getStoreId();
57
+ }
58
+
59
+ public function getProductId()
60
+ {
61
+ return $this->getProduct()->getId();
62
+ }
63
+
64
+ public function getWebsites()
65
+ {
66
+ return $this->getProduct()->getWebsiteIds();
67
+ }
68
+
69
+ public function hasWebsite($websiteId)
70
+ {
71
+ return in_array($websiteId, $this->getProduct()->getWebsiteIds());
72
+ }
73
+
74
+ /**
75
+ * Check websites block is readonly
76
+ *
77
+ * @return boolean
78
+ */
79
+ public function isReadonly()
80
+ {
81
+ return $this->getProduct()->getWebsitesReadonly();
82
+ }
83
+
84
+ public function getStoreName($storeId)
85
+ {
86
+ return Mage::app()->getStore($storeId)->getName();
87
+ }
88
+
89
+ public function getChooseFromStoreHtml($storeTo)
90
+ {
91
+ if (!$this->_storeFromHtml) {
92
+ $this->_storeFromHtml = '<select name="copy_to_stores[__store_identifier__]" disabled="disabled">';
93
+ $this->_storeFromHtml.= '<option value="0">'.Mage::helper('catalog')->__('Default Values').'</option>';
94
+ foreach ($this->getWebsiteCollection() as $_website) {
95
+ if (!$this->hasWebsite($_website->getId())) {
96
+ continue;
97
+ }
98
+ $this->_storeFromHtml .= '<optgroup label="' . $_website->getName() . '"></optgroup>';
99
+ foreach ($this->getGroupCollection($_website) as $_group) {
100
+ $this->_storeFromHtml .= '<optgroup label="&nbsp;&nbsp;&nbsp;&nbsp;' . $_group->getName() . '">';
101
+ foreach ($this->getStoreCollection($_group) as $_store) {
102
+ $this->_storeFromHtml .= '<option value="' . $_store->getId() . '">&nbsp;&nbsp;&nbsp;&nbsp;' . $_store->getName() . '</option>';
103
+ }
104
+ }
105
+ $this->_storeFromHtml .= '</optgroup>';
106
+ }
107
+ $this->_storeFromHtml.= '</select>';
108
+ }
109
+ return str_replace('__store_identifier__', $storeTo->getId(), $this->_storeFromHtml);
110
+ }
111
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * admin product edit tabs
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35
+ {
36
+ protected $_attributeTabBlock = 'adminhtml/catalog_product_edit_tab_attributes';
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setId('product_info_tabs');
42
+ $this->setDestElementId('product_edit_form');
43
+ $this->setTitle(Mage::helper('catalog')->__('Product Information'));
44
+ }
45
+
46
+ protected function _prepareLayout()
47
+ {
48
+ $product = $this->getProduct();
49
+
50
+ if (!($setId = $product->getAttributeSetId())) {
51
+ $setId = $this->getRequest()->getParam('set', null);
52
+ }
53
+
54
+ if ($setId) {
55
+ $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
56
+ ->setAttributeSetFilter($setId)
57
+ ->setSortOrder()
58
+ ->load();
59
+
60
+ foreach ($groupCollection as $group) {
61
+ $attributes = $product->getAttributes($group->getId(), true);
62
+ // do not add groups without attributes
63
+
64
+ foreach ($attributes as $key => $attribute) {
65
+ if( !$attribute->getIsVisible() ) {
66
+ unset($attributes[$key]);
67
+ }
68
+ }
69
+
70
+ if (count($attributes)==0) {
71
+ continue;
72
+ }
73
+
74
+ $this->addTab('group_'.$group->getId(), array(
75
+ 'label' => Mage::helper('catalog')->__($group->getAttributeGroupName()),
76
+ 'content' => $this->_translateHtml($this->getLayout()->createBlock($this->getAttributeTabBlock(),
77
+ 'adminhtml.catalog.product.edit.tab.attributes')->setGroup($group)
78
+ ->setGroupAttributes($attributes)
79
+ ->toHtml()),
80
+ ));
81
+ }
82
+
83
+ if (Mage::helper('core')->isModuleEnabled('Mage_CatalogInventory')) {
84
+ $this->addTab('inventory', array(
85
+ 'label' => Mage::helper('catalog')->__('Inventory'),
86
+ 'content' => $this->_translateHtml($this->getLayout()
87
+ ->createBlock('adminhtml/catalog_product_edit_tab_inventory')->toHtml()),
88
+ ));
89
+ }
90
+
91
+ /**
92
+ * Don't display website tab for single mode
93
+ */
94
+ if (!Mage::app()->isSingleStoreMode()) {
95
+ $this->addTab('websites', array(
96
+ 'label' => Mage::helper('catalog')->__('Websites'),
97
+ 'content' => $this->_translateHtml($this->getLayout()
98
+ ->createBlock('adminhtml/catalog_product_edit_tab_websites')->toHtml()),
99
+ ));
100
+ }
101
+
102
+ $this->addTab('categories', array(
103
+ 'label' => Mage::helper('catalog')->__('Categories'),
104
+ 'url' => $this->getUrl('*/*/categories', array('_current' => true)),
105
+ 'class' => 'ajax',
106
+ ));
107
+
108
+ $this->addTab('related', array(
109
+ 'label' => Mage::helper('catalog')->__('Related Products'),
110
+ 'url' => $this->getUrl('*/*/related', array('_current' => true)),
111
+ 'class' => 'ajax',
112
+ ));
113
+
114
+ $this->addTab('upsell', array(
115
+ 'label' => Mage::helper('catalog')->__('Up-sells'),
116
+ 'url' => $this->getUrl('*/*/upsell', array('_current' => true)),
117
+ 'class' => 'ajax',
118
+ ));
119
+
120
+ $this->addTab('crosssell', array(
121
+ 'label' => Mage::helper('catalog')->__('Cross-sells'),
122
+ 'url' => $this->getUrl('*/*/crosssell', array('_current' => true)),
123
+ 'class' => 'ajax',
124
+ ));
125
+
126
+ $storeId = 0;
127
+ if ($this->getRequest()->getParam('store')) {
128
+ $storeId = Mage::app()->getStore($this->getRequest()->getParam('store'))->getId();
129
+ }
130
+
131
+ $alertPriceAllow = Mage::getStoreConfig('catalog/productalert/allow_price');
132
+ $alertStockAllow = Mage::getStoreConfig('catalog/productalert/allow_stock');
133
+
134
+ if (($alertPriceAllow || $alertStockAllow) && !$product->isGrouped()) {
135
+ $this->addTab('productalert', array(
136
+ 'label' => Mage::helper('catalog')->__('Product Alerts'),
137
+ 'content' => $this->_translateHtml($this->getLayout()
138
+ ->createBlock('adminhtml/catalog_product_edit_tab_alerts', 'admin.alerts.products')->toHtml())
139
+ ));
140
+ }
141
+
142
+ if( $this->getRequest()->getParam('id', false) ) {
143
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Review')) {
144
+ if (Mage::getSingleton('admin/session')->isAllowed('admin/catalog/reviews_ratings')){
145
+ $this->addTab('reviews', array(
146
+ 'label' => Mage::helper('catalog')->__('Product Reviews'),
147
+ 'url' => $this->getUrl('*/*/reviews', array('_current' => true)),
148
+ 'class' => 'ajax',
149
+ ));
150
+ }
151
+ }
152
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Tag')) {
153
+ if (Mage::getSingleton('admin/session')->isAllowed('admin/catalog/tag')){
154
+ $this->addTab('tags', array(
155
+ 'label' => Mage::helper('catalog')->__('Product Tags'),
156
+ 'url' => $this->getUrl('*/*/tagGrid', array('_current' => true)),
157
+ 'class' => 'ajax',
158
+ ));
159
+
160
+ $this->addTab('customers_tags', array(
161
+ 'label' => Mage::helper('catalog')->__('Customers Tagged Product'),
162
+ 'url' => $this->getUrl('*/*/tagCustomerGrid', array('_current' => true)),
163
+ 'class' => 'ajax',
164
+ ));
165
+ }
166
+ }
167
+
168
+ }
169
+
170
+ /**
171
+ * Do not change this tab id
172
+ * @see Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs_Configurable
173
+ * @see Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tabs
174
+ */
175
+ if (!$product->isGrouped()) {
176
+ $this->addTab('customer_options', array(
177
+ 'label' => Mage::helper('catalog')->__('Custom Options'),
178
+ 'url' => $this->getUrl('*/*/options', array('_current' => true)),
179
+ 'class' => 'ajax',
180
+ ));
181
+ }
182
+
183
+ }
184
+ else {
185
+ $this->addTab('set', array(
186
+ 'label' => Mage::helper('catalog')->__('Settings'),
187
+ 'content' => $this->_translateHtml($this->getLayout()
188
+ ->createBlock('adminhtml/catalog_product_edit_tab_settings')->toHtml()),
189
+ 'active' => true
190
+ ));
191
+ }
192
+ return parent::_prepareLayout();
193
+ }
194
+
195
+ /**
196
+ * Retrive product object from object if not from registry
197
+ *
198
+ * @return Mage_Catalog_Model_Product
199
+ */
200
+ public function getProduct()
201
+ {
202
+ if (!($this->getData('product') instanceof Mage_Catalog_Model_Product)) {
203
+ $this->setData('product', Mage::registry('product'));
204
+ }
205
+ return $this->getData('product');
206
+ }
207
+
208
+ /**
209
+ * Getting attribute block name for tabs
210
+ *
211
+ * @return string
212
+ */
213
+ public function getAttributeTabBlock()
214
+ {
215
+ if (is_null(Mage::helper('adminhtml/catalog')->getAttributeTabBlock())) {
216
+ return $this->_attributeTabBlock;
217
+ }
218
+ return Mage::helper('adminhtml/catalog')->getAttributeTabBlock();
219
+ }
220
+
221
+ public function setAttributeTabBlock($attributeTabBlock)
222
+ {
223
+ $this->_attributeTabBlock = $attributeTabBlock;
224
+ return $this;
225
+ }
226
+
227
+ /**
228
+ * Translate html content
229
+ *
230
+ * @param string $html
231
+ * @return string
232
+ */
233
+ protected function _translateHtml($html)
234
+ {
235
+ Mage::getSingleton('core/translate_inline')->processResponseBody($html);
236
+ return $html;
237
+ }
238
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Configurable.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * admin edit tabs for configurable products
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs_Configurable extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
35
+ {
36
+ protected function _prepareLayout()
37
+ {
38
+ // $product = $this->getProduct();
39
+
40
+ // if (!($superAttributes = $product->getTypeInstance()->getUsedProductAttributeIds())) {
41
+ $this->addTab('super_settings', array(
42
+ 'label' => Mage::helper('catalog')->__('Configurable Product Settings'),
43
+ 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_super_settings')->toHtml(),
44
+ 'active' => true
45
+ ));
46
+
47
+ // } else {
48
+ // parent::_prepareLayout();
49
+ //
50
+ // $this->addTab('configurable', array(
51
+ // 'label' => Mage::helper('catalog')->__('Associated Products'),
52
+ // 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_super_config', 'admin.super.config.product')
53
+ // ->setProductId($this->getRequest()->getParam('id'))
54
+ // ->toHtml(),
55
+ // ));
56
+ // $this->bindShadowTabs('configurable', 'customer_options');
57
+ // }
58
+ }
59
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs/Grouped.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * admin edit tabs for grouped product
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs_Grouped extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
35
+ {
36
+ protected function _prepareLayout()
37
+ {
38
+ parent::_prepareLayout();
39
+
40
+ $this->addTab('super', array(
41
+ 'label' => Mage::helper('catalog')->__('Associated Products'),
42
+ 'url' => $this->getUrl('*/*/superGroup', array('_current'=>true)),
43
+ 'class' => 'ajax',
44
+ ));
45
+ }
46
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Frontend/Product/Watermark.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Fieldset config form element renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Frontend_Product_Watermark extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
35
+ {
36
+ const XML_PATH_IMAGE_TYPES = 'global/catalog/product/media/image_types';
37
+
38
+ public function render(Varien_Data_Form_Element_Abstract $element)
39
+ {
40
+ $html = $this->_getHeaderHtml($element);
41
+ $renderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
42
+
43
+ $attributes = Mage::getConfig()->getNode(self::XML_PATH_IMAGE_TYPES)->asArray();
44
+
45
+ foreach ($attributes as $key => $attribute) {
46
+ /**
47
+ * Watermark size field
48
+ */
49
+ $field = new Varien_Data_Form_Element_Text();
50
+ $field->setName("groups[watermark][fields][{$key}_size][value]")
51
+ ->setForm( $this->getForm() )
52
+ ->setLabel(Mage::helper('adminhtml')->__('Size for %s', $attribute['title']))
53
+ ->setRenderer($renderer);
54
+ $html.= $field->toHtml();
55
+
56
+ /**
57
+ * Watermark upload field
58
+ */
59
+ $field = new Varien_Data_Form_Element_Imagefile();
60
+ $field->setName("groups[watermark][fields][{$key}_image][value]")
61
+ ->setForm( $this->getForm() )
62
+ ->setLabel(Mage::helper('adminhtml')->__('Watermark File for %s', $attribute['title']))
63
+ ->setRenderer($renderer);
64
+ $html.= $field->toHtml();
65
+
66
+ /**
67
+ * Watermark position field
68
+ */
69
+ $field = new Varien_Data_Form_Element_Select();
70
+ $field->setName("groups[watermark][fields][{$key}_position][value]")
71
+ ->setForm( $this->getForm() )
72
+ ->setLabel(Mage::helper('adminhtml')->__('Position of Watermark for %s', $attribute['title']))
73
+ ->setRenderer($renderer)
74
+ ->setValues(Mage::getSingleton('adminhtml/system_config_source_catalog_product_watermark_position')->toOptionArray());
75
+ $html.= $field->toHtml();
76
+ }
77
+
78
+ $html .= $this->_getFooterHtml($element);
79
+
80
+ return $html;
81
+ }
82
+
83
+ protected function _getHeaderHtml($element)
84
+ {
85
+ $id = $element->getHtmlId();
86
+ $default = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
87
+
88
+ $html = '<h4 class="icon-head head-edit-form">'.$element->getLegend().'</h4>';
89
+ $html.= '<fieldset class="config" id="'.$element->getHtmlId().'">';
90
+ $html.= '<legend>'.$element->getLegend().'</legend>';
91
+
92
+ // field label column
93
+ $html.= '<table cellspacing="0"><colgroup class="label" /><colgroup class="value" />';
94
+ if (!$default) {
95
+ $html.= '<colgroup class="use-default" />';
96
+ }
97
+ $html.= '<tbody>';
98
+
99
+ return $html;
100
+ }
101
+
102
+ protected function _getFooterHtml($element)
103
+ {
104
+ $html = '</tbody></table></fieldset>';
105
+ return $html;
106
+ }
107
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('productGrid');
41
+ $this->setDefaultSort('entity_id');
42
+ $this->setDefaultDir('DESC');
43
+ $this->setSaveParametersInSession(true);
44
+ $this->setUseAjax(true);
45
+ $this->setVarNameFilter('product_filter');
46
+
47
+ }
48
+
49
+ protected function _getStore()
50
+ {
51
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
52
+ return Mage::app()->getStore($storeId);
53
+ }
54
+
55
+ protected function _prepareCollection()
56
+ {
57
+ $store = $this->_getStore();
58
+ $collection = Mage::getModel('catalog/product')->getCollection()
59
+ ->addAttributeToSelect('sku')
60
+ ->addAttributeToSelect('name')
61
+ ->addAttributeToSelect('attribute_set_id')
62
+ ->addAttributeToSelect('type_id');
63
+
64
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
65
+ $collection->joinField('qty',
66
+ 'cataloginventory/stock_item',
67
+ 'qty',
68
+ 'product_id=entity_id',
69
+ '{{table}}.stock_id=1',
70
+ 'left');
71
+ }
72
+ if ($store->getId()) {
73
+ //$collection->setStoreId($store->getId());
74
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
75
+ $collection->addStoreFilter($store);
76
+ $collection->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner', $adminStore);
77
+ $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
78
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
79
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
80
+ $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
81
+ }
82
+ else {
83
+ $collection->addAttributeToSelect('price');
84
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
85
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
86
+ }
87
+
88
+ $this->setCollection($collection);
89
+
90
+ parent::_prepareCollection();
91
+ $this->getCollection()->addWebsiteNamesToResult();
92
+ return $this;
93
+ }
94
+
95
+ protected function _addColumnFilterToCollection($column)
96
+ {
97
+ if ($this->getCollection()) {
98
+ if ($column->getId() == 'websites') {
99
+ $this->getCollection()->joinField('websites',
100
+ 'catalog/product_website',
101
+ 'website_id',
102
+ 'product_id=entity_id',
103
+ null,
104
+ 'left');
105
+ }
106
+ }
107
+ return parent::_addColumnFilterToCollection($column);
108
+ }
109
+
110
+ protected function _prepareColumns()
111
+ {
112
+ $this->addColumn('entity_id',
113
+ array(
114
+ 'header'=> Mage::helper('catalog')->__('ID'),
115
+ 'width' => '50px',
116
+ 'type' => 'number',
117
+ 'index' => 'entity_id',
118
+ ));
119
+ $this->addColumn('name',
120
+ array(
121
+ 'header'=> Mage::helper('catalog')->__('Name'),
122
+ 'index' => 'name',
123
+ ));
124
+
125
+ $store = $this->_getStore();
126
+ if ($store->getId()) {
127
+ $this->addColumn('custom_name',
128
+ array(
129
+ 'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
130
+ 'index' => 'custom_name',
131
+ ));
132
+ }
133
+
134
+ $this->addColumn('type',
135
+ array(
136
+ 'header'=> Mage::helper('catalog')->__('Type'),
137
+ 'width' => '60px',
138
+ 'index' => 'type_id',
139
+ 'type' => 'options',
140
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
141
+ ));
142
+
143
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
144
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
145
+ ->load()
146
+ ->toOptionHash();
147
+
148
+ $this->addColumn('set_name',
149
+ array(
150
+ 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
151
+ 'width' => '100px',
152
+ 'index' => 'attribute_set_id',
153
+ 'type' => 'options',
154
+ 'options' => $sets,
155
+ ));
156
+
157
+ $this->addColumn('sku',
158
+ array(
159
+ 'header'=> Mage::helper('catalog')->__('SKU'),
160
+ 'width' => '80px',
161
+ 'index' => 'sku',
162
+ ));
163
+
164
+ $store = $this->_getStore();
165
+ $this->addColumn('price',
166
+ array(
167
+ 'header'=> Mage::helper('catalog')->__('Price'),
168
+ 'type' => 'price',
169
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
170
+ 'index' => 'price',
171
+ ));
172
+
173
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
174
+ $this->addColumn('qty',
175
+ array(
176
+ 'header'=> Mage::helper('catalog')->__('Qty'),
177
+ 'width' => '100px',
178
+ 'type' => 'number',
179
+ 'index' => 'qty',
180
+ ));
181
+ }
182
+
183
+ $this->addColumn('visibility',
184
+ array(
185
+ 'header'=> Mage::helper('catalog')->__('Visibility'),
186
+ 'width' => '70px',
187
+ 'index' => 'visibility',
188
+ 'type' => 'options',
189
+ 'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
190
+ ));
191
+
192
+ $this->addColumn('status',
193
+ array(
194
+ 'header'=> Mage::helper('catalog')->__('Status'),
195
+ 'width' => '70px',
196
+ 'index' => 'status',
197
+ 'type' => 'options',
198
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
199
+ ));
200
+
201
+ if (!Mage::app()->isSingleStoreMode()) {
202
+ $this->addColumn('websites',
203
+ array(
204
+ 'header'=> Mage::helper('catalog')->__('Websites'),
205
+ 'width' => '100px',
206
+ 'sortable' => false,
207
+ 'index' => 'websites',
208
+ 'type' => 'options',
209
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
210
+ ));
211
+ }
212
+
213
+ $this->addColumn('action',
214
+ array(
215
+ 'header' => Mage::helper('catalog')->__('Action'),
216
+ 'width' => '50px',
217
+ 'type' => 'action',
218
+ 'getter' => 'getId',
219
+ 'actions' => array(
220
+ array(
221
+ 'caption' => Mage::helper('catalog')->__('Edit'),
222
+ 'url' => array(
223
+ 'base'=>'*/*/edit',
224
+ 'params'=>array('store'=>$this->getRequest()->getParam('store'))
225
+ ),
226
+ 'field' => 'id'
227
+ )
228
+ ),
229
+ 'filter' => false,
230
+ 'sortable' => false,
231
+ 'index' => 'stores',
232
+ ));
233
+
234
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Rss')) {
235
+ $this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'));
236
+ }
237
+
238
+ return parent::_prepareColumns();
239
+ }
240
+
241
+ protected function _prepareMassaction()
242
+ {
243
+ $this->setMassactionIdField('entity_id');
244
+ $this->getMassactionBlock()->setFormFieldName('product');
245
+
246
+ $this->getMassactionBlock()->addItem('delete', array(
247
+ 'label'=> Mage::helper('catalog')->__('Delete'),
248
+ 'url' => $this->getUrl('*/*/massDelete'),
249
+ 'confirm' => Mage::helper('catalog')->__('Are you sure?')
250
+ ));
251
+
252
+ $statuses = Mage::getSingleton('catalog/product_status')->getOptionArray();
253
+
254
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
255
+ $this->getMassactionBlock()->addItem('status', array(
256
+ 'label'=> Mage::helper('catalog')->__('Change status'),
257
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
258
+ 'additional' => array(
259
+ 'visibility' => array(
260
+ 'name' => 'status',
261
+ 'type' => 'select',
262
+ 'class' => 'required-entry',
263
+ 'label' => Mage::helper('catalog')->__('Status'),
264
+ 'values' => $statuses
265
+ )
266
+ )
267
+ ));
268
+
269
+ if (Mage::getSingleton('admin/session')->isAllowed('catalog/update_attributes')){
270
+ $this->getMassactionBlock()->addItem('attributes', array(
271
+ 'label' => Mage::helper('catalog')->__('Update Attributes'),
272
+ 'url' => $this->getUrl('*/catalog_product_action_attribute/edit', array('_current'=>true))
273
+ ));
274
+ }
275
+
276
+ return $this;
277
+ }
278
+
279
+ public function getGridUrl()
280
+ {
281
+ return $this->getUrl('*/*/grid', array('_current'=>true));
282
+ }
283
+
284
+ public function getRowUrl($row)
285
+ {
286
+ return $this->getUrl('*/*/edit', array(
287
+ 'store'=>$this->getRequest()->getParam('store'),
288
+ 'id'=>$row->getId())
289
+ );
290
+ }
291
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Apply.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Attribute form apply element
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Apply extends Varien_Data_Form_Element_Multiselect
35
+ {
36
+ public function getElementHtml()
37
+ {
38
+ $elementAttributeHtml = '';
39
+
40
+ if ($this->getReadonly()) {
41
+ $elementAttributeHtml = $elementAttributeHtml . ' readonly="readonly"';
42
+ }
43
+
44
+ if ($this->getDisabled()) {
45
+ $elementAttributeHtml = $elementAttributeHtml . ' disabled="disabled"';
46
+ }
47
+
48
+ $html = '<select onchange="toggleApplyVisibility(this)"' . $elementAttributeHtml . '>'
49
+ . '<option value="0">' . $this->getModeLabels('all'). '</option>'
50
+ . '<option value="1" ' . ($this->getValue()==null ? '' : 'selected') . '>' . $this->getModeLabels('custom'). '</option>'
51
+ . '</select><br /><br />';
52
+
53
+ $html .= parent::getElementHtml();
54
+ return $html;
55
+ }
56
+
57
+ /**
58
+ * Dublicate interface of Varien_Data_Form_Element_Abstract::setReadonly
59
+ *
60
+ * @param bool $readonly
61
+ * @param bool $useDisabled
62
+ * @return Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Apply
63
+ */
64
+ public function setReadonly($readonly, $useDisabled = false)
65
+ {
66
+ $this->setData('readonly', $readonly);
67
+ $this->setData('disabled', $useDisabled);
68
+ return $this;
69
+ }
70
+
71
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Boolean.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product form boolean field helper
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Boolean extends Varien_Data_Form_Element_Select
35
+ {
36
+ public function __construct($attributes=array())
37
+ {
38
+ parent::__construct($attributes);
39
+ $this->setValues(array(
40
+ array(
41
+ 'label' => Mage::helper('catalog')->__('No'),
42
+ 'value' => 0,
43
+ ),
44
+ array(
45
+ 'label' => Mage::helper('catalog')->__('Yes'),
46
+ 'value' => 1,
47
+ ),
48
+ ));
49
+ }
50
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Config.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml additional helper block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Config extends Varien_Data_Form_Element_Select
35
+ {
36
+ /**
37
+ * Retrieve element html
38
+ *
39
+ * @return string
40
+ */
41
+ public function getElementHtml()
42
+ {
43
+ $value = $this->getValue();
44
+ if ($value == '') {
45
+ $this->setValue($this->_getValueFromConfig());
46
+ }
47
+ $html = parent::getElementHtml();
48
+
49
+ $htmlId = 'use_config_' . $this->getHtmlId();
50
+ $checked = ($value == '') ? ' checked="checked"' : '';
51
+ $disabled = ($this->getReadonly()) ? ' disabled="disabled"' : '';
52
+
53
+ $html .= '<input id="'.$htmlId.'" name="product['.$htmlId.']" '.$disabled.' value="1" ' . $checked;
54
+ $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />';
55
+ $html .= ' <label for="'.$htmlId.'">' . Mage::helper('adminhtml')->__('Use Config Settings').'</label>';
56
+ $html .= '<script type="text/javascript">toggleValueElements($(\''.$htmlId.'\'), $(\''.$htmlId.'\').parentNode);</script>';
57
+
58
+ return $html;
59
+ }
60
+
61
+ /**
62
+ * Get config value data
63
+ *
64
+ * @return mixed
65
+ */
66
+ protected function _getValueFromConfig()
67
+ {
68
+ return '';
69
+ }
70
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Catalog product gallery attribute
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery extends Varien_Data_Form_Element_Abstract
36
+ {
37
+
38
+ public function getElementHtml()
39
+ {
40
+ $html = $this->getContentHtml();
41
+ //$html.= $this->getAfterElementHtml();
42
+ return $html;
43
+ }
44
+
45
+ /**
46
+ * Prepares content block
47
+ *
48
+ * @return string
49
+ */
50
+ public function getContentHtml()
51
+ {
52
+
53
+ /* @var $content Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content */
54
+ $content = Mage::getSingleton('core/layout')
55
+ ->createBlock('adminhtml/catalog_product_helper_form_gallery_content');
56
+
57
+ $content->setId($this->getHtmlId() . '_content')
58
+ ->setElement($this);
59
+ return $content->toHtml();
60
+ }
61
+
62
+ public function getLabel()
63
+ {
64
+ return '';
65
+ }
66
+
67
+ /**
68
+ * Check "Use default" checkbox display availability
69
+ *
70
+ * @param Mage_Eav_Model_Entity_Attribute $attribute
71
+ * @return bool
72
+ */
73
+ public function canDisplayUseDefault($attribute)
74
+ {
75
+ if (!$attribute->isScopeGlobal() && $this->getDataObject()->getStoreId()) {
76
+ return true;
77
+ }
78
+
79
+ return false;
80
+ }
81
+
82
+ /**
83
+ * Check default value usage fact
84
+ *
85
+ * @param Mage_Eav_Model_Entity_Attribute $attribute
86
+ * @return bool
87
+ */
88
+ public function usedDefault($attribute)
89
+ {
90
+ $attributeCode = $attribute->getAttributeCode();
91
+ $defaultValue = $this->getDataObject()->getAttributeDefaultValue($attributeCode);
92
+
93
+ if (!$this->getDataObject()->getExistsStoreValueFlag($attributeCode)) {
94
+ return true;
95
+ } else if ($this->getValue() == $defaultValue &&
96
+ $this->getDataObject()->getStoreId() != $this->_getDefaultStoreId()) {
97
+ return false;
98
+ }
99
+ if ($defaultValue === false && !$attribute->getIsRequired() && $this->getValue()) {
100
+ return false;
101
+ }
102
+ return $defaultValue === false;
103
+ }
104
+
105
+ /**
106
+ * Retrieve label of attribute scope
107
+ *
108
+ * GLOBAL | WEBSITE | STORE
109
+ *
110
+ * @param Mage_Eav_Model_Entity_Attribute $attribute
111
+ * @return string
112
+ */
113
+ public function getScopeLabel($attribute)
114
+ {
115
+ $html = '';
116
+ if (Mage::app()->isSingleStoreMode()) {
117
+ return $html;
118
+ }
119
+
120
+ if ($attribute->isScopeGlobal()) {
121
+ $html.= '<br/>[GLOBAL]';
122
+ }
123
+ elseif ($attribute->isScopeWebsite()) {
124
+ $html.= '<br/>[WEBSITE]';
125
+ }
126
+ elseif ($attribute->isScopeStore()) {
127
+ $html.= '<br/>[STORE VIEW]';
128
+ }
129
+ return $html;
130
+ }
131
+
132
+ /**
133
+ * Retrieve data object related with form
134
+ *
135
+ * @return Mage_Catalog_Model_Product || Mage_Catalog_Model_Category
136
+ */
137
+ public function getDataObject()
138
+ {
139
+ return $this->getForm()->getDataObject();
140
+ }
141
+
142
+ /**
143
+ * Retrieve attribute field name
144
+ *
145
+ *
146
+ * @param Mage_Eav_Model_Entity_Attribute $attribute
147
+ * @return string
148
+ */
149
+ public function getAttributeFieldName($attribute)
150
+ {
151
+ $name = $attribute->getAttributeCode();
152
+ if ($suffix = $this->getForm()->getFieldNameSuffix()) {
153
+ $name = $this->getForm()->addSuffixToName($name, $suffix);
154
+ }
155
+ return $name;
156
+ }
157
+
158
+ /**
159
+ * Check readonly attribute
160
+ *
161
+ * @param Mage_Eav_Model_Entity_Attribute|string $attribute
162
+ * @return boolean
163
+ */
164
+ public function getAttributeReadonly($attribute)
165
+ {
166
+ if (is_object($attribute)) {
167
+ $attribute = $attribute->getAttributeCode();
168
+ }
169
+
170
+ if ($this->getDataObject()->isLockedAttribute($attribute)) {
171
+ return true;
172
+ }
173
+
174
+ return false;
175
+ }
176
+
177
+ public function toHtml()
178
+ {
179
+ return '<tr><td class="value" colspan="3">' . $this->getElementHtml() . '</td></tr>';
180
+ }
181
+
182
+ /**
183
+ * Default sore ID getter
184
+ *
185
+ * @return integer
186
+ */
187
+ protected function _getDefaultStoreId()
188
+ {
189
+ return Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
190
+ }
191
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Catalog product form gallery content
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content extends Mage_Adminhtml_Block_Widget
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setTemplate('catalog/product/helper/gallery.phtml');
42
+ }
43
+
44
+ protected function _prepareLayout()
45
+ {
46
+ $this->setChild('uploader',
47
+ $this->getLayout()->createBlock('adminhtml/media_uploader')
48
+ );
49
+
50
+ $this->getUploader()->getConfig()
51
+ ->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/catalog_product_gallery/upload'))
52
+ ->setFileField('image')
53
+ ->setFilters(array(
54
+ 'images' => array(
55
+ 'label' => Mage::helper('adminhtml')->__('Images (.gif, .jpg, .png)'),
56
+ 'files' => array('*.gif', '*.jpg','*.jpeg', '*.png')
57
+ )
58
+ ));
59
+
60
+ return parent::_prepareLayout();
61
+ }
62
+
63
+ /**
64
+ * Retrive uploader block
65
+ *
66
+ * @return Mage_Adminhtml_Block_Media_Uploader
67
+ */
68
+ public function getUploader()
69
+ {
70
+ return $this->getChild('uploader');
71
+ }
72
+
73
+ /**
74
+ * Retrive uploader block html
75
+ *
76
+ * @return string
77
+ */
78
+ public function getUploaderHtml()
79
+ {
80
+ return $this->getChildHtml('uploader');
81
+ }
82
+
83
+ public function getJsObjectName()
84
+ {
85
+ return $this->getHtmlId() . 'JsObject';
86
+ }
87
+
88
+ public function getAddImagesButton()
89
+ {
90
+ return $this->getButtonHtml(
91
+ Mage::helper('catalog')->__('Add New Images'),
92
+ $this->getJsObjectName() . '.showUploader()',
93
+ 'add',
94
+ $this->getHtmlId() . '_add_images_button'
95
+ );
96
+ }
97
+
98
+ public function getImagesJson()
99
+ {
100
+ if(is_array($this->getElement()->getValue())) {
101
+ $value = $this->getElement()->getValue();
102
+ if(count($value['images'])>0) {
103
+ foreach ($value['images'] as &$image) {
104
+ $image['url'] = Mage::getSingleton('catalog/product_media_config')
105
+ ->getMediaUrl($image['file']);
106
+ }
107
+ return Mage::helper('core')->jsonEncode($value['images']);
108
+ }
109
+ }
110
+ return '[]';
111
+ }
112
+
113
+ public function getImagesValuesJson()
114
+ {
115
+ $values = array();
116
+ foreach ($this->getMediaAttributes() as $attribute) {
117
+ /* @var $attribute Mage_Eav_Model_Entity_Attribute */
118
+ $values[$attribute->getAttributeCode()] = $this->getElement()->getDataObject()->getData(
119
+ $attribute->getAttributeCode()
120
+ );
121
+ }
122
+ return Mage::helper('core')->jsonEncode($values);
123
+ }
124
+
125
+ /**
126
+ * Enter description here...
127
+ *
128
+ * @return array
129
+ */
130
+ public function getImageTypes()
131
+ {
132
+ $imageTypes = array();
133
+ foreach ($this->getMediaAttributes() as $attribute) {
134
+ /* @var $attribute Mage_Eav_Model_Entity_Attribute */
135
+ $imageTypes[$attribute->getAttributeCode()] = array(
136
+ 'label' => $attribute->getFrontend()->getLabel() . ' '
137
+ . Mage::helper('catalog')->__($this->getElement()->getScopeLabel($attribute)),
138
+ 'field' => $this->getElement()->getAttributeFieldName($attribute)
139
+ );
140
+ }
141
+ return $imageTypes;
142
+ }
143
+
144
+ public function hasUseDefault()
145
+ {
146
+ foreach ($this->getMediaAttributes() as $attribute) {
147
+ if($this->getElement()->canDisplayUseDefault($attribute)) {
148
+ return true;
149
+ }
150
+ }
151
+
152
+ return false;
153
+ }
154
+
155
+ /**
156
+ * Enter description here...
157
+ *
158
+ * @return array
159
+ */
160
+ public function getMediaAttributes()
161
+ {
162
+ return $this->getElement()->getDataObject()->getMediaAttributes();
163
+ }
164
+
165
+ public function getImageTypesJson()
166
+ {
167
+ return Mage::helper('core')->jsonEncode($this->getImageTypes());
168
+ }
169
+
170
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Image.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product form image field helper
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Image extends Varien_Data_Form_Element_Image
35
+ {
36
+ protected function _getUrl()
37
+ {
38
+ $url = false;
39
+ if ($this->getValue()) {
40
+ $url = Mage::getBaseUrl('media').'catalog/product/'. $this->getValue();
41
+ }
42
+ return $url;
43
+ }
44
+
45
+ protected function _getDeleteCheckbox()
46
+ {
47
+ $html = '';
48
+ if ($attribute = $this->getEntityAttribute()) {
49
+ if (!$attribute->getIsRequired()) {
50
+ $html.= parent::_getDeleteCheckbox();
51
+ }
52
+ else {
53
+ $html.= '<input value="'.$this->getValue().'" id="'.$this->getHtmlId().'_hidden" type="hidden" class="required-entry" />';
54
+ $html.= '<script type="text/javascript">
55
+ syncOnchangeValue(\''.$this->getHtmlId().'\', \''.$this->getHtmlId().'_hidden\');
56
+ </script>';
57
+ }
58
+ }
59
+ else {
60
+ $html.= parent::_getDeleteCheckbox();
61
+ }
62
+ return $html;
63
+ }
64
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product form MAP Enabled field helper
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Msrp_Enabled extends Varien_Data_Form_Element_Select
35
+ {
36
+ /**
37
+ * Retrieve Element HTML fragment
38
+ *
39
+ * @return string
40
+ */
41
+ public function getElementHtml()
42
+ {
43
+ if (is_null($this->getValue())) {
44
+ $this->setValue(Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Enabled::MSRP_ENABLE_USE_CONFIG);
45
+ }
46
+ return parent::getElementHtml();
47
+ }
48
+ }
49
+
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product form MSRP field helper
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Msrp_Price extends Varien_Data_Form_Element_Select
35
+ {
36
+ /**
37
+ * Retrieve Element HTML fragment
38
+ *
39
+ * @return string
40
+ */
41
+ public function getElementHtml()
42
+ {
43
+ if (is_null($this->getValue())) {
44
+ $this->setValue(Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Price::TYPE_USE_CONFIG);
45
+ }
46
+ return parent::getElementHtml();
47
+ }
48
+ }
49
+
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product form price field helper
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Price extends Varien_Data_Form_Element_Text
35
+ {
36
+
37
+ public function __construct($attributes=array())
38
+ {
39
+ parent::__construct($attributes);
40
+ $this->addClass('validate-zero-or-greater');
41
+ }
42
+
43
+ public function getAfterElementHtml()
44
+ {
45
+ $html = parent::getAfterElementHtml();
46
+ /**
47
+ * getEntityAttribute - use __call
48
+ */
49
+ $addJsObserver = false;
50
+ if ($attribute = $this->getEntityAttribute()) {
51
+ if (!($storeId = $attribute->getStoreId())) {
52
+ $storeId = $this->getForm()->getDataObject()->getStoreId();
53
+ }
54
+ $store = Mage::app()->getStore($storeId);
55
+ $html.= '<strong>['.(string)$store->getBaseCurrencyCode().']</strong>';
56
+ if (Mage::helper('tax')->priceIncludesTax($store)) {
57
+ if ($attribute->getAttributeCode()!=='cost') {
58
+ $addJsObserver = true;
59
+ $html.= ' <strong>['.Mage::helper('tax')->__('Inc. Tax').'<span id="dynamic-tax-'.$attribute->getAttributeCode().'"></span>]</strong>';
60
+ }
61
+ }
62
+ }
63
+ if ($addJsObserver) {
64
+ $html .= $this->_getTaxObservingCode($attribute);
65
+ }
66
+
67
+ return $html;
68
+ }
69
+
70
+ protected function _getTaxObservingCode($attribute)
71
+ {
72
+ $spanId = "dynamic-tax-{$attribute->getAttributeCode()}";
73
+
74
+ $html = "<script type='text/javascript'>if (dynamicTaxes == undefined) var dynamicTaxes = new Array(); dynamicTaxes[dynamicTaxes.length]='{$attribute->getAttributeCode()}'</script>";
75
+ return $html;
76
+ }
77
+
78
+ public function getEscapedValue($index=null)
79
+ {
80
+ $value = $this->getValue();
81
+
82
+ if (!is_numeric($value)) {
83
+ return null;
84
+ }
85
+
86
+ return number_format($value, 2, null, '');
87
+ }
88
+
89
+ }
90
+
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Price.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Product price block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Price extends Mage_Catalog_Block_Product_Price
35
+ {
36
+
37
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser.php ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product Chooser for "Product Link" Cms Widget Plugin
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ protected $_selectedProducts = array();
37
+
38
+ /**
39
+ * Block construction, prepare grid params
40
+ *
41
+ * @param array $arguments Object data
42
+ */
43
+ public function __construct($arguments=array())
44
+ {
45
+ parent::__construct($arguments);
46
+ $this->setDefaultSort('name');
47
+ $this->setUseAjax(true);
48
+ }
49
+
50
+ /**
51
+ * Prepare chooser element HTML
52
+ *
53
+ * @param Varien_Data_Form_Element_Abstract $element Form Element
54
+ * @return Varien_Data_Form_Element_Abstract
55
+ */
56
+ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
57
+ {
58
+ $uniqId = Mage::helper('core')->uniqHash($element->getId());
59
+ $sourceUrl = $this->getUrl('*/catalog_product_widget/chooser', array(
60
+ 'uniq_id' => $uniqId,
61
+ 'use_massaction' => false,
62
+ ));
63
+
64
+ $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
65
+ ->setElement($element)
66
+ ->setTranslationHelper($this->getTranslationHelper())
67
+ ->setConfig($this->getConfig())
68
+ ->setFieldsetId($this->getFieldsetId())
69
+ ->setSourceUrl($sourceUrl)
70
+ ->setUniqId($uniqId);
71
+
72
+ if ($element->getValue()) {
73
+ $value = explode('/', $element->getValue());
74
+ $productId = false;
75
+ if (isset($value[0]) && isset($value[1]) && $value[0] == 'product') {
76
+ $productId = $value[1];
77
+ }
78
+ $categoryId = isset($value[2]) ? $value[2] : false;
79
+ $label = '';
80
+ if ($categoryId) {
81
+ $label = Mage::getResourceSingleton('catalog/category')
82
+ ->getAttributeRawValue($categoryId, 'name', Mage::app()->getStore()) . '/';
83
+ }
84
+ if ($productId) {
85
+ $label .= Mage::getResourceSingleton('catalog/product')
86
+ ->getAttributeRawValue($productId, 'name', Mage::app()->getStore());
87
+ }
88
+ $chooser->setLabel($label);
89
+ }
90
+
91
+ $element->setData('after_element_html', $chooser->toHtml());
92
+ return $element;
93
+ }
94
+
95
+ /**
96
+ * Checkbox Check JS Callback
97
+ *
98
+ * @return string
99
+ */
100
+ public function getCheckboxCheckCallback()
101
+ {
102
+ if ($this->getUseMassaction()) {
103
+ return "function (grid, event) {
104
+ $(grid.containerId).fire('product:changed', {});
105
+ }";
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Grid Row JS Callback
111
+ *
112
+ * @return string
113
+ */
114
+ public function getRowClickCallback()
115
+ {
116
+ if (!$this->getUseMassaction()) {
117
+ $chooserJsObject = $this->getId();
118
+ return '
119
+ function (grid, event) {
120
+ var trElement = Event.findElement(event, "tr");
121
+ var productId = trElement.down("td").innerHTML;
122
+ var productName = trElement.down("td").next().next().innerHTML;
123
+ var optionLabel = productName;
124
+ var optionValue = "product/" + productId.replace(/^\s+|\s+$/g,"");
125
+ if (grid.categoryId) {
126
+ optionValue += "/" + grid.categoryId;
127
+ }
128
+ if (grid.categoryName) {
129
+ optionLabel = grid.categoryName + " / " + optionLabel;
130
+ }
131
+ '.$chooserJsObject.'.setElementValue(optionValue);
132
+ '.$chooserJsObject.'.setElementLabel(optionLabel);
133
+ '.$chooserJsObject.'.close();
134
+ }
135
+ ';
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Category Tree node onClick listener js function
141
+ *
142
+ * @return string
143
+ */
144
+ public function getCategoryClickListenerJs()
145
+ {
146
+ $js = '
147
+ function (node, e) {
148
+ {jsObject}.addVarToUrl("category_id", node.attributes.id);
149
+ {jsObject}.reload({jsObject}.url);
150
+ {jsObject}.categoryId = node.attributes.id != "none" ? node.attributes.id : false;
151
+ {jsObject}.categoryName = node.attributes.id != "none" ? node.text : false;
152
+ }
153
+ ';
154
+ $js = str_replace('{jsObject}', $this->getJsObjectName(), $js);
155
+ return $js;
156
+ }
157
+
158
+ /**
159
+ * Filter checked/unchecked rows in grid
160
+ *
161
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
162
+ * @return Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser
163
+ */
164
+ protected function _addColumnFilterToCollection($column)
165
+ {
166
+ if ($column->getId() == 'in_products') {
167
+ $selected = $this->getSelectedProducts();
168
+ if ($column->getFilter()->getValue()) {
169
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$selected));
170
+ } else {
171
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$selected));
172
+ }
173
+ } else {
174
+ parent::_addColumnFilterToCollection($column);
175
+ }
176
+ return $this;
177
+ }
178
+
179
+ /**
180
+ * Prepare products collection, defined collection filters (category, product type)
181
+ *
182
+ * @return Mage_Adminhtml_Block_Widget_Grid
183
+ */
184
+ protected function _prepareCollection()
185
+ {
186
+ /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */
187
+ $collection = Mage::getResourceModel('catalog/product_collection')
188
+ ->setStoreId(0)
189
+ ->addAttributeToSelect('name');
190
+
191
+ if ($categoryId = $this->getCategoryId()) {
192
+ $category = Mage::getModel('catalog/category')->load($categoryId);
193
+ if ($category->getId()) {
194
+ // $collection->addCategoryFilter($category);
195
+ $productIds = $category->getProductsPosition();
196
+ $productIds = array_keys($productIds);
197
+ if (empty($productIds)) {
198
+ $productIds = 0;
199
+ }
200
+ $collection->addFieldToFilter('entity_id', array('in' => $productIds));
201
+ }
202
+ }
203
+
204
+ if ($productTypeId = $this->getProductTypeId()) {
205
+ $collection->addAttributeToFilter('type_id', $productTypeId);
206
+ }
207
+
208
+ $this->setCollection($collection);
209
+ return parent::_prepareCollection();
210
+ }
211
+
212
+ /**
213
+ * Prepare columns for products grid
214
+ *
215
+ * @return Mage_Adminhtml_Block_Widget_Grid
216
+ */
217
+ protected function _prepareColumns()
218
+ {
219
+ if ($this->getUseMassaction()) {
220
+ $this->addColumn('in_products', array(
221
+ 'header_css_class' => 'a-center',
222
+ 'type' => 'checkbox',
223
+ 'name' => 'in_products',
224
+ 'inline_css' => 'checkbox entities',
225
+ 'field_name' => 'in_products',
226
+ 'values' => $this->getSelectedProducts(),
227
+ 'align' => 'center',
228
+ 'index' => 'entity_id',
229
+ 'use_index' => true,
230
+ ));
231
+ }
232
+
233
+ $this->addColumn('entity_id', array(
234
+ 'header' => Mage::helper('catalog')->__('ID'),
235
+ 'sortable' => true,
236
+ 'width' => '60px',
237
+ 'index' => 'entity_id'
238
+ ));
239
+ $this->addColumn('chooser_sku', array(
240
+ 'header' => Mage::helper('catalog')->__('SKU'),
241
+ 'name' => 'chooser_sku',
242
+ 'width' => '80px',
243
+ 'index' => 'sku'
244
+ ));
245
+ $this->addColumn('chooser_name', array(
246
+ 'header' => Mage::helper('catalog')->__('Product Name'),
247
+ 'name' => 'chooser_name',
248
+ 'index' => 'name'
249
+ ));
250
+
251
+ return parent::_prepareColumns();
252
+ }
253
+
254
+ /**
255
+ * Adds additional parameter to URL for loading only products grid
256
+ *
257
+ * @return string
258
+ */
259
+ public function getGridUrl()
260
+ {
261
+ return $this->getUrl('*/catalog_product_widget/chooser', array(
262
+ 'products_grid' => true,
263
+ '_current' => true,
264
+ 'uniq_id' => $this->getId(),
265
+ 'use_massaction' => $this->getUseMassaction(),
266
+ 'product_type_id' => $this->getProductTypeId()
267
+ ));
268
+ }
269
+
270
+ /**
271
+ * Setter
272
+ *
273
+ * @param array $selectedProducts
274
+ * @return Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser
275
+ */
276
+ public function setSelectedProducts($selectedProducts)
277
+ {
278
+ $this->_selectedProducts = $selectedProducts;
279
+ return $this;
280
+ }
281
+
282
+ /**
283
+ * Getter
284
+ *
285
+ * @return array
286
+ */
287
+ public function getSelectedProducts()
288
+ {
289
+ if ($selectedProducts = $this->getRequest()->getParam('selected_products', null)) {
290
+ $this->setSelectedProducts($selectedProducts);
291
+ }
292
+ return $this->_selectedProducts;
293
+ }
294
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Widget/Chooser/Container.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Chooser Container for "Product Link" Cms Widget Plugin
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser_Container extends Mage_Adminhtml_Block_Template
35
+ {
36
+ /**
37
+ * Block construction
38
+ *
39
+ * @param array $arguments Object data
40
+ */
41
+ public function __construct($arguments=array())
42
+ {
43
+ parent::__construct($arguments);
44
+ $this->setTemplate('catalog/product/widget/chooser/container.phtml');
45
+ }
46
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Search.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Catalog price rules
29
+ *
30
+ * @category Mage
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+
36
+ class Mage_Adminhtml_Block_Catalog_Search extends Mage_Adminhtml_Block_Widget_Grid_Container
37
+ {
38
+ public function __construct()
39
+ {
40
+ $this->_controller = 'catalog_search';
41
+ $this->_headerText = Mage::helper('catalog')->__('Search');
42
+ $this->_addButtonLabel = Mage::helper('catalog')->__('Add New Search Term');
43
+ parent::__construct();
44
+
45
+ }
46
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Admin tag edit block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Search_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ $this->_objectId = 'id';
41
+ $this->_controller = 'catalog_search';
42
+
43
+ parent::__construct();
44
+
45
+ $this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Search'));
46
+ $this->_updateButton('delete', 'label', Mage::helper('catalog')->__('Delete Search'));
47
+ }
48
+
49
+ public function getHeaderText()
50
+ {
51
+ if (Mage::registry('current_catalog_search')->getId()) {
52
+ return Mage::helper('catalog')->__("Edit Search '%s'", $this->htmlEscape(Mage::registry('current_catalog_search')->getQueryText()));
53
+ }
54
+ else {
55
+ return Mage::helper('catalog')->__('New Search');
56
+ }
57
+ }
58
+
59
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml tag edit form
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Catalog_Search_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+ /**
38
+ * Init Form properties
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ $this->setId('catalog_search_form');
45
+ $this->setTitle(Mage::helper('catalog')->__('Search Information'));
46
+ }
47
+
48
+ /**
49
+ * Prepare form fields
50
+ *
51
+ * @return Mage_Adminhtml_Block_Catalog_Search_Edit_Form
52
+ */
53
+ protected function _prepareForm()
54
+ {
55
+ $model = Mage::registry('current_catalog_search');
56
+ /* @var $model Mage_CatalogSearch_Model_Query */
57
+
58
+ $form = new Varien_Data_Form(array(
59
+ 'id' => 'edit_form',
60
+ 'action' => $this->getData('action'),
61
+ 'method' => 'post'
62
+ ));
63
+
64
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('catalog')->__('General Information')));
65
+
66
+ $yesno = array(
67
+ array(
68
+ 'value' => 0,
69
+ 'label' => Mage::helper('catalog')->__('No')
70
+ ),
71
+ array(
72
+ 'value' => 1,
73
+ 'label' => Mage::helper('catalog')->__('Yes')
74
+ ));
75
+
76
+ if ($model->getId()) {
77
+ $fieldset->addField('query_id', 'hidden', array(
78
+ 'name' => 'query_id',
79
+ ));
80
+ }
81
+
82
+ $fieldset->addField('query_text', 'text', array(
83
+ 'name' => 'query_text',
84
+ 'label' => Mage::helper('catalog')->__('Search Query'),
85
+ 'title' => Mage::helper('catalog')->__('Search Query'),
86
+ 'required' => true,
87
+ ));
88
+
89
+ if (!Mage::app()->isSingleStoreMode()) {
90
+ $fieldset->addField('store_id', 'select', array(
91
+ 'name' => 'store_id',
92
+ 'label' => Mage::helper('catalog')->__('Store'),
93
+ 'title' => Mage::helper('catalog')->__('Store'),
94
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(true, false),
95
+ 'required' => true,
96
+ ));
97
+ }
98
+ else {
99
+ $fieldset->addField('store_id', 'hidden', array(
100
+ 'name' => 'store_id'
101
+ ));
102
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
103
+ }
104
+
105
+ if ($model->getId()) {
106
+ $fieldset->addField('num_results', 'text', array(
107
+ 'name' => 'num_results',
108
+ 'label' => Mage::helper('catalog')->__('Number of results<br/>(For the last time placed)'),
109
+ 'title' => Mage::helper('catalog')->__('Number of results<br/>(For the last time placed)'),
110
+ 'required' => true,
111
+ ));
112
+
113
+ $fieldset->addField('popularity', 'text', array(
114
+ 'name' => 'popularity',
115
+ 'label' => Mage::helper('catalog')->__('Number of Uses'),
116
+ 'title' => Mage::helper('catalog')->__('Number of Uses'),
117
+ 'required' => true,
118
+ ));
119
+ }
120
+
121
+ $afterElementHtml = '<p class="nm"><small>'
122
+ . Mage::helper('catalog')->__('(Will make search for the query above return results for this search.)')
123
+ . '</small></p>';
124
+
125
+ $fieldset->addField('synonym_for', 'text', array(
126
+ 'name' => 'synonym_for',
127
+ 'label' => Mage::helper('catalog')->__('Synonym For'),
128
+ 'title' => Mage::helper('catalog')->__('Synonym For'),
129
+ 'after_element_html' => $afterElementHtml,
130
+ ));
131
+
132
+ $afterElementHtml = '<p class="nm"><small>'
133
+ . Mage::helper('catalog')->__('ex. http://domain.com')
134
+ . '</small></p>';
135
+
136
+ $fieldset->addField('redirect', 'text', array(
137
+ 'name' => 'redirect',
138
+ 'label' => Mage::helper('catalog')->__('Redirect URL'),
139
+ 'title' => Mage::helper('catalog')->__('Redirect URL'),
140
+ 'class' => 'validate-url',
141
+ 'after_element_html' => $afterElementHtml,
142
+ ));
143
+
144
+ $fieldset->addField('display_in_terms', 'select', array(
145
+ 'name' => 'display_in_terms',
146
+ 'label' => Mage::helper('catalog')->__('Display in Suggested Terms'),
147
+ 'title' => Mage::helper('catalog')->__('Display in Suggested Terms'),
148
+ 'values' => $yesno,
149
+ ));
150
+
151
+ $form->setValues($model->getData());
152
+ $form->setUseContainer(true);
153
+ $this->setForm($form);
154
+
155
+ return parent::_prepareForm();
156
+ }
157
+ }
app/code/core/Mage/Adminhtml/Block/Catalog/Search/Grid.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * description
29
+ *
30
+ * @category Mage
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Catalog_Search_Grid extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ /**
38
+ * Init Grid default properties
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ $this->setId('catalog_search_grid');
45
+ $this->setDefaultSort('name');
46
+ $this->setDefaultDir('ASC');
47
+ $this->setSaveParametersInSession(true);
48
+ }
49
+
50
+ /**
51
+ * Prepare collection for Grid
52
+ *
53
+ * @return Mage_Adminhtml_Block_Catalog_Search_Grid
54
+ */
55
+ protected function _prepareCollection()
56
+ {
57
+ $collection = Mage::getModel('catalogsearch/query')
58
+ ->getResourceCollection();
59
+ $this->setCollection($collection);
60
+ return parent::_prepareCollection();
61
+ }
62
+
63
+ /**
64
+ * Prepare Grid columns
65
+ *
66
+ * @return Mage_Adminhtml_Block_Catalog_Search_Grid
67
+ */
68
+ protected function _prepareColumns()
69
+ {
70
+ /*$this->addColumn('query_id', array(
71
+ 'header' => Mage::helper('catalog')->__('ID'),
72
+ 'width' => '50px',
73
+ 'index' => 'query_id',
74
+ ));*/
75
+
76
+ $this->addColumn('search_query', array(
77
+ 'header' => Mage::helper('catalog')->__('Search Query'),
78
+ 'index' => 'query_text',
79
+ ));
80
+
81
+ if (!Mage::app()->isSingleStoreMode()) {
82
+ $this->addColumn('store_id', array(
83
+ 'header' => Mage::helper('catalog')->__('Store'),
84
+ 'index' => 'store_id',
85
+ 'type' => 'store',
86
+ 'store_view' => true,
87
+ 'sortable' => false
88
+ ));
89
+ }
90
+
91
+ $this->addColumn('num_results', array(
92
+ 'header' => Mage::helper('catalog')->__('Results'),
93
+ 'index' => 'num_results',
94
+ 'type' => 'number'
95
+ ));
96
+
97
+ $this->addColumn('popularity', array(
98
+ 'header' => Mage::helper('catalog')->__('Number of Uses'),
99
+ 'index' => 'popularity',
100
+ 'type' => 'number'
101
+ ));
102
+
103
+ $this->addColumn('synonym_for', array(
104
+ 'header' => Mage::helper('catalog')->__('Synonym For'),
105
+ 'align' => 'left',
106
+ 'index' => 'synonym_for',
107
+ 'width' => '160px'
108
+ ));
109
+
110
+ $this->addColumn('redirect', array(
111
+ 'header' => Mage::helper('catalog')->__('Redirect'),
112
+ 'align' => 'left',
113
+ 'index' => 'redirect',
114
+ 'width' => '200px'
115
+ ));
116
+
117
+ $this->addColumn('display_in_terms', array(
118
+ 'header'=>Mage::helper('catalog')->__('Display in Suggested Terms'),
119
+ 'sortable'=>true,
120
+ 'index'=>'display_in_terms',
121
+ 'type' => 'options',
122
+ 'width' => '100px',
123
+ 'options' => array(
124
+ '1' => Mage::helper('catalog')->__('Yes'),
125
+ '0' => Mage::helper('catalog')->__('No'),
126
+ ),
127
+ 'align' => 'left',
128
+ ));
129
+ $this->addColumn('action',
130
+ array(
131
+ 'header' => Mage::helper('catalog')->__('Action'),
132
+ 'width' => '100px',
133
+ 'type' => 'action',
134
+ 'getter' => 'getId',
135
+ 'actions' => array(array(
136
+ 'caption' => Mage::helper('catalog')->__('Edit'),
137
+ 'url' => array(
138
+ 'base'=>'*/*/edit'
139
+ ),
140
+ 'field' => 'id'
141
+ )),
142
+ 'filter' => false,
143
+ 'sortable' => false,
144
+ 'index' => 'catalog',
145
+ ));
146
+ return parent::_prepareColumns();
147
+ }
148
+
149
+ /**
150
+ * Prepare grid massaction actions
151
+ *
152
+ * @return Mage_Adminhtml_Block_Catalog_Search_Grid
153
+ */
154
+ protected function _prepareMassaction()
155
+ {
156
+ $this->setMassactionIdField('query_id');
157
+ $this->getMassactionBlock()->setFormFieldName('search');
158
+
159
+ $this->getMassactionBlock()->addItem('delete', array(
160
+ 'label' => Mage::helper('catalog')->__('Delete'),
161
+ 'url' => $this->getUrl('*/*/massDelete'),
162
+ 'confirm' => Mage::helper('catalog')->__('Are you sure?')
163
+ ));
164
+
165
+ return parent::_prepareMassaction();
166
+ }
167
+
168
+ /**
169
+ * Retrieve Row Click callback URL
170
+ *
171
+ * @return string
172
+ */
173
+ public function getRowUrl($row)
174
+ {
175
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
176
+ }
177
+
178
+ }
app/code/core/Mage/Adminhtml/Block/Checkout/Agreement.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Admin tax rule content block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Checkout_Agreement extends Mage_Adminhtml_Block_Widget_Grid_Container
36
+ {
37
+ public function __construct()
38
+ {
39
+ $this->_controller = 'checkout_agreement';
40
+ $this->_headerText = Mage::helper('checkout')->__('Manage Checkout Terms and Conditions');
41
+ $this->_addButtonLabel = Mage::helper('checkout')->__('Add New Condition');
42
+ parent::__construct();
43
+ }
44
+ }
app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Edit.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml tax rule Edit Container
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Checkout_Agreement_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
36
+ {
37
+ /**
38
+ * Init class
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ $this->_objectId = 'id';
44
+ $this->_controller = 'checkout_agreement';
45
+
46
+ parent::__construct();
47
+
48
+ $this->_updateButton('save', 'label', Mage::helper('checkout')->__('Save Condition'));
49
+ $this->_updateButton('delete', 'label', Mage::helper('checkout')->__('Delete Condition'));
50
+ }
51
+
52
+ /**
53
+ * Get Header text
54
+ *
55
+ * @return string
56
+ */
57
+ public function getHeaderText()
58
+ {
59
+ if (Mage::registry('checkout_agreement')->getId()) {
60
+ return Mage::helper('checkout')->__('Edit Terms and Conditions');
61
+ }
62
+ else {
63
+ return Mage::helper('checkout')->__('New Condition');
64
+ }
65
+ }
66
+ }
app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Edit/Form.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml Tax Rule Edit Form
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Checkout_Agreement_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+ /**
38
+ * Init class
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+
45
+ $this->setId('checkoutAgreementForm');
46
+ $this->setTitle(Mage::helper('checkout')->__('Terms and Conditions Information'));
47
+ }
48
+
49
+ /**
50
+ *
51
+ * return Mage_Adminhtml_Block_Widget_Form
52
+ */
53
+ protected function _prepareForm()
54
+ {
55
+ $model = Mage::registry('checkout_agreement');
56
+ $form = new Varien_Data_Form(array(
57
+ 'id' => 'edit_form',
58
+ 'action' => $this->getData('action'),
59
+ 'method' => 'post'
60
+ ));
61
+
62
+ $fieldset = $form->addFieldset('base_fieldset', array(
63
+ 'legend' => Mage::helper('checkout')->__('Terms and Conditions Information'),
64
+ 'class' => 'fieldset-wide',
65
+ ));
66
+
67
+ if ($model->getId()) {
68
+ $fieldset->addField('agreement_id', 'hidden', array(
69
+ 'name' => 'agreement_id',
70
+ ));
71
+ }
72
+ $fieldset->addField('name', 'text', array(
73
+ 'name' => 'name',
74
+ 'label' => Mage::helper('checkout')->__('Condition Name'),
75
+ 'title' => Mage::helper('checkout')->__('Condition Name'),
76
+ 'required' => true,
77
+ ));
78
+
79
+ $fieldset->addField('is_active', 'select', array(
80
+ 'label' => Mage::helper('checkout')->__('Status'),
81
+ 'title' => Mage::helper('checkout')->__('Status'),
82
+ 'name' => 'is_active',
83
+ 'required' => true,
84
+ 'options' => array(
85
+ '1' => Mage::helper('checkout')->__('Enabled'),
86
+ '0' => Mage::helper('checkout')->__('Disabled'),
87
+ ),
88
+ ));
89
+
90
+ $fieldset->addField('is_html', 'select', array(
91
+ 'label' => Mage::helper('checkout')->__('Show Content as'),
92
+ 'title' => Mage::helper('checkout')->__('Show Content as'),
93
+ 'name' => 'is_html',
94
+ 'required' => true,
95
+ 'options' => array(
96
+ 0 => Mage::helper('checkout')->__('Text'),
97
+ 1 => Mage::helper('checkout')->__('HTML'),
98
+ ),
99
+ ));
100
+
101
+ if (!Mage::app()->isSingleStoreMode()) {
102
+ $fieldset->addField('store_id', 'multiselect', array(
103
+ 'name' => 'stores[]',
104
+ 'label' => Mage::helper('checkout')->__('Store View'),
105
+ 'title' => Mage::helper('checkout')->__('Store View'),
106
+ 'required' => true,
107
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
108
+ ));
109
+ }
110
+ else {
111
+ $fieldset->addField('store_id', 'hidden', array(
112
+ 'name' => 'stores[]',
113
+ 'value' => Mage::app()->getStore(true)->getId()
114
+ ));
115
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
116
+ }
117
+
118
+ $fieldset->addField('checkbox_text', 'editor', array(
119
+ 'name' => 'checkbox_text',
120
+ 'label' => Mage::helper('checkout')->__('Checkbox Text'),
121
+ 'title' => Mage::helper('checkout')->__('Checkbox Text'),
122
+ 'rows' => '5',
123
+ 'cols' => '30',
124
+ 'wysiwyg' => false,
125
+ 'required' => true,
126
+ ));
127
+
128
+ $fieldset->addField('content', 'editor', array(
129
+ 'name' => 'content',
130
+ 'label' => Mage::helper('checkout')->__('Content'),
131
+ 'title' => Mage::helper('checkout')->__('Content'),
132
+ 'style' => 'height:24em;',
133
+ 'wysiwyg' => false,
134
+ 'required' => true,
135
+ ));
136
+
137
+ $fieldset->addField('content_height', 'text', array(
138
+ 'name' => 'content_height',
139
+ 'label' => Mage::helper('checkout')->__('Content Height (css)'),
140
+ 'title' => Mage::helper('checkout')->__('Content Height'),
141
+ 'maxlength' => 25,
142
+ 'class' => 'validate-css-length',
143
+ ));
144
+
145
+ $form->setValues($model->getData());
146
+ $form->setUseContainer(true);
147
+ $this->setForm($form);
148
+
149
+ return parent::_prepareForm();
150
+ }
151
+ }
app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Grid.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Mage_Adminhtml_Block_Checkout_Agreement_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
+ {
28
+
29
+ public function __construct()
30
+ {
31
+ parent::__construct();
32
+ $this->setDefaultSort('agreement_id');
33
+ $this->setId('agreementGrid');
34
+ $this->setDefaultDir('asc');
35
+ $this->setSaveParametersInSession(true);
36
+ }
37
+
38
+ protected function _prepareCollection()
39
+ {
40
+ $collection = Mage::getModel('checkout/agreement')
41
+ ->getCollection();
42
+ $this->setCollection($collection);
43
+ return parent::_prepareCollection();
44
+ }
45
+
46
+ protected function _prepareColumns()
47
+ {
48
+ $this->addColumn('agreement_id',
49
+ array(
50
+ 'header'=>Mage::helper('checkout')->__('ID'),
51
+ 'align' =>'right',
52
+ 'width' => '50px',
53
+ 'index' => 'agreement_id'
54
+ )
55
+ );
56
+
57
+ $this->addColumn('name',
58
+ array(
59
+ 'header'=>Mage::helper('checkout')->__('Condition Name'),
60
+ 'index' => 'name'
61
+ )
62
+ );
63
+
64
+ if (!Mage::app()->isSingleStoreMode()) {
65
+ $this->addColumn('store_id', array(
66
+ 'header' => Mage::helper('adminhtml')->__('Store View'),
67
+ 'index' => 'store_id',
68
+ 'type' => 'store',
69
+ 'store_all' => true,
70
+ 'store_view' => true,
71
+ 'sortable' => false,
72
+ 'filter_condition_callback'
73
+ => array($this, '_filterStoreCondition'),
74
+ ));
75
+ }
76
+
77
+ $this->addColumn('is_active', array(
78
+ 'header' => Mage::helper('adminhtml')->__('Status'),
79
+ 'index' => 'is_active',
80
+ 'type' => 'options',
81
+ 'options' => array(
82
+ 0 => Mage::helper('adminhtml')->__('Disabled'),
83
+ 1 => Mage::helper('adminhtml')->__('Enabled')
84
+ ),
85
+ ));
86
+
87
+ return parent::_prepareColumns();
88
+ }
89
+
90
+ protected function _afterLoadCollection()
91
+ {
92
+ $this->getCollection()->walk('afterLoad');
93
+ parent::_afterLoadCollection();
94
+ }
95
+
96
+ protected function _filterStoreCondition($collection, $column)
97
+ {
98
+ if (!$value = $column->getFilter()->getValue()) {
99
+ return;
100
+ }
101
+
102
+ $this->getCollection()->addStoreFilter($value);
103
+ }
104
+
105
+ public function getRowUrl($row)
106
+ {
107
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
108
+ }
109
+
110
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Block.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml cms blocks content block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Block extends Mage_Adminhtml_Block_Widget_Grid_Container
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ $this->_controller = 'cms_block';
40
+ $this->_headerText = Mage::helper('cms')->__('Static Blocks');
41
+ $this->_addButtonLabel = Mage::helper('cms')->__('Add New Block');
42
+ parent::__construct();
43
+ }
44
+
45
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * CMS block edit form container
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Cms_Block_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
36
+ {
37
+ public function __construct()
38
+ {
39
+ $this->_objectId = 'block_id';
40
+ $this->_controller = 'cms_block';
41
+
42
+ parent::__construct();
43
+
44
+ $this->_updateButton('save', 'label', Mage::helper('cms')->__('Save Block'));
45
+ $this->_updateButton('delete', 'label', Mage::helper('cms')->__('Delete Block'));
46
+
47
+ $this->_addButton('saveandcontinue', array(
48
+ 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
49
+ 'onclick' => 'saveAndContinueEdit()',
50
+ 'class' => 'save',
51
+ ), -100);
52
+
53
+ $this->_formScripts[] = "
54
+ function toggleEditor() {
55
+ if (tinyMCE.getInstanceById('block_content') == null) {
56
+ tinyMCE.execCommand('mceAddControl', false, 'block_content');
57
+ } else {
58
+ tinyMCE.execCommand('mceRemoveControl', false, 'block_content');
59
+ }
60
+ }
61
+
62
+ function saveAndContinueEdit(){
63
+ editForm.submit($('edit_form').action+'back/edit/');
64
+ }
65
+ ";
66
+ }
67
+
68
+ /**
69
+ * Get edit form container header text
70
+ *
71
+ * @return string
72
+ */
73
+ public function getHeaderText()
74
+ {
75
+ if (Mage::registry('cms_block')->getId()) {
76
+ return Mage::helper('cms')->__("Edit Block '%s'", $this->htmlEscape(Mage::registry('cms_block')->getTitle()));
77
+ }
78
+ else {
79
+ return Mage::helper('cms')->__('New Block');
80
+ }
81
+ }
82
+
83
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml cms block edit form
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Cms_Block_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+
38
+ /**
39
+ * Init form
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ $this->setId('block_form');
45
+ $this->setTitle(Mage::helper('cms')->__('Block Information'));
46
+ }
47
+
48
+ /**
49
+ * Load Wysiwyg on demand and Prepare layout
50
+ */
51
+ protected function _prepareLayout()
52
+ {
53
+ parent::_prepareLayout();
54
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
55
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
56
+ }
57
+ }
58
+
59
+ protected function _prepareForm()
60
+ {
61
+ $model = Mage::registry('cms_block');
62
+
63
+ $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
64
+
65
+ $form->setHtmlIdPrefix('block_');
66
+
67
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('cms')->__('General Information'), 'class' => 'fieldset-wide'));
68
+
69
+ if ($model->getBlockId()) {
70
+ $fieldset->addField('block_id', 'hidden', array(
71
+ 'name' => 'block_id',
72
+ ));
73
+ }
74
+
75
+ $fieldset->addField('title', 'text', array(
76
+ 'name' => 'title',
77
+ 'label' => Mage::helper('cms')->__('Block Title'),
78
+ 'title' => Mage::helper('cms')->__('Block Title'),
79
+ 'required' => true,
80
+ ));
81
+
82
+ $fieldset->addField('identifier', 'text', array(
83
+ 'name' => 'identifier',
84
+ 'label' => Mage::helper('cms')->__('Identifier'),
85
+ 'title' => Mage::helper('cms')->__('Identifier'),
86
+ 'required' => true,
87
+ 'class' => 'validate-xml-identifier',
88
+ ));
89
+
90
+ /**
91
+ * Check is single store mode
92
+ */
93
+ if (!Mage::app()->isSingleStoreMode()) {
94
+ $fieldset->addField('store_id', 'multiselect', array(
95
+ 'name' => 'stores[]',
96
+ 'label' => Mage::helper('cms')->__('Store View'),
97
+ 'title' => Mage::helper('cms')->__('Store View'),
98
+ 'required' => true,
99
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
100
+ ));
101
+ }
102
+ else {
103
+ $fieldset->addField('store_id', 'hidden', array(
104
+ 'name' => 'stores[]',
105
+ 'value' => Mage::app()->getStore(true)->getId()
106
+ ));
107
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
108
+ }
109
+
110
+ $fieldset->addField('is_active', 'select', array(
111
+ 'label' => Mage::helper('cms')->__('Status'),
112
+ 'title' => Mage::helper('cms')->__('Status'),
113
+ 'name' => 'is_active',
114
+ 'required' => true,
115
+ 'options' => array(
116
+ '1' => Mage::helper('cms')->__('Enabled'),
117
+ '0' => Mage::helper('cms')->__('Disabled'),
118
+ ),
119
+ ));
120
+ if (!$model->getId()) {
121
+ $model->setData('is_active', '1');
122
+ }
123
+
124
+ $fieldset->addField('content', 'editor', array(
125
+ 'name' => 'content',
126
+ 'label' => Mage::helper('cms')->__('Content'),
127
+ 'title' => Mage::helper('cms')->__('Content'),
128
+ 'style' => 'height:36em',
129
+ 'required' => true,
130
+ 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()
131
+ ));
132
+
133
+ $form->setValues($model->getData());
134
+ $form->setUseContainer(true);
135
+ $this->setForm($form);
136
+
137
+ return parent::_prepareForm();
138
+ }
139
+
140
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Block/Grid.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml cms blocks grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Block_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('cmsBlockGrid');
41
+ $this->setDefaultSort('block_identifier');
42
+ $this->setDefaultDir('ASC');
43
+ }
44
+
45
+ protected function _prepareCollection()
46
+ {
47
+ $collection = Mage::getModel('cms/block')->getCollection();
48
+ /* @var $collection Mage_Cms_Model_Mysql4_Block_Collection */
49
+ $this->setCollection($collection);
50
+ return parent::_prepareCollection();
51
+ }
52
+
53
+ protected function _prepareColumns()
54
+ {
55
+ $baseUrl = $this->getUrl();
56
+
57
+ $this->addColumn('title', array(
58
+ 'header' => Mage::helper('cms')->__('Title'),
59
+ 'align' => 'left',
60
+ 'index' => 'title',
61
+ ));
62
+
63
+ $this->addColumn('identifier', array(
64
+ 'header' => Mage::helper('cms')->__('Identifier'),
65
+ 'align' => 'left',
66
+ 'index' => 'identifier'
67
+ ));
68
+
69
+ if (!Mage::app()->isSingleStoreMode()) {
70
+ $this->addColumn('store_id', array(
71
+ 'header' => Mage::helper('cms')->__('Store View'),
72
+ 'index' => 'store_id',
73
+ 'type' => 'store',
74
+ 'store_all' => true,
75
+ 'store_view' => true,
76
+ 'sortable' => false,
77
+ 'filter_condition_callback'
78
+ => array($this, '_filterStoreCondition'),
79
+ ));
80
+ }
81
+
82
+ $this->addColumn('is_active', array(
83
+ 'header' => Mage::helper('cms')->__('Status'),
84
+ 'index' => 'is_active',
85
+ 'type' => 'options',
86
+ 'options' => array(
87
+ 0 => Mage::helper('cms')->__('Disabled'),
88
+ 1 => Mage::helper('cms')->__('Enabled')
89
+ ),
90
+ ));
91
+
92
+ $this->addColumn('creation_time', array(
93
+ 'header' => Mage::helper('cms')->__('Date Created'),
94
+ 'index' => 'creation_time',
95
+ 'type' => 'datetime',
96
+ ));
97
+
98
+ $this->addColumn('update_time', array(
99
+ 'header' => Mage::helper('cms')->__('Last Modified'),
100
+ 'index' => 'update_time',
101
+ 'type' => 'datetime',
102
+ ));
103
+
104
+ return parent::_prepareColumns();
105
+ }
106
+
107
+ protected function _afterLoadCollection()
108
+ {
109
+ $this->getCollection()->walk('afterLoad');
110
+ parent::_afterLoadCollection();
111
+ }
112
+
113
+ protected function _filterStoreCondition($collection, $column)
114
+ {
115
+ if (!$value = $column->getFilter()->getValue()) {
116
+ return;
117
+ }
118
+
119
+ $this->getCollection()->addStoreFilter($value);
120
+ }
121
+
122
+ /**
123
+ * Row click url
124
+ *
125
+ * @return string
126
+ */
127
+ public function getRowUrl($row)
128
+ {
129
+ return $this->getUrl('*/*/edit', array('block_id' => $row->getId()));
130
+ }
131
+
132
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Block/Widget/Chooser.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * CMS block chooser for Wysiwyg CMS widget
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Block_Widget_Chooser extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ /**
37
+ * Block construction, prepare grid params
38
+ *
39
+ * @param array $arguments Object data
40
+ */
41
+ public function __construct($arguments=array())
42
+ {
43
+ parent::__construct($arguments);
44
+ $this->setDefaultSort('block_identifier');
45
+ $this->setDefaultDir('ASC');
46
+ $this->setUseAjax(true);
47
+ $this->setDefaultFilter(array('chooser_is_active' => '1'));
48
+ }
49
+
50
+ /**
51
+ * Prepare chooser element HTML
52
+ *
53
+ * @param Varien_Data_Form_Element_Abstract $element Form Element
54
+ * @return Varien_Data_Form_Element_Abstract
55
+ */
56
+ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
57
+ {
58
+ $uniqId = Mage::helper('core')->uniqHash($element->getId());
59
+ $sourceUrl = $this->getUrl('*/cms_block_widget/chooser', array('uniq_id' => $uniqId));
60
+
61
+ $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
62
+ ->setElement($element)
63
+ ->setTranslationHelper($this->getTranslationHelper())
64
+ ->setConfig($this->getConfig())
65
+ ->setFieldsetId($this->getFieldsetId())
66
+ ->setSourceUrl($sourceUrl)
67
+ ->setUniqId($uniqId);
68
+
69
+
70
+ if ($element->getValue()) {
71
+ $block = Mage::getModel('cms/block')->load($element->getValue());
72
+ if ($block->getId()) {
73
+ $chooser->setLabel($block->getTitle());
74
+ }
75
+ }
76
+
77
+ $element->setData('after_element_html', $chooser->toHtml());
78
+ return $element;
79
+ }
80
+
81
+ /**
82
+ * Grid Row JS Callback
83
+ *
84
+ * @return string
85
+ */
86
+ public function getRowClickCallback()
87
+ {
88
+ $chooserJsObject = $this->getId();
89
+ $js = '
90
+ function (grid, event) {
91
+ var trElement = Event.findElement(event, "tr");
92
+ var blockId = trElement.down("td").innerHTML.replace(/^\s+|\s+$/g,"");
93
+ var blockTitle = trElement.down("td").next().innerHTML;
94
+ '.$chooserJsObject.'.setElementValue(blockId);
95
+ '.$chooserJsObject.'.setElementLabel(blockTitle);
96
+ '.$chooserJsObject.'.close();
97
+ }
98
+ ';
99
+ return $js;
100
+ }
101
+
102
+ /**
103
+ * Prepare Cms static blocks collection
104
+ *
105
+ * @return Mage_Adminhtml_Block_Widget_Grid
106
+ */
107
+ protected function _prepareCollection()
108
+ {
109
+ $collection = Mage::getModel('cms/block')->getCollection();
110
+ /* @var $collection Mage_Cms_Model_Mysql4_Block_Collection */
111
+ $this->setCollection($collection);
112
+ return parent::_prepareCollection();
113
+ }
114
+
115
+ /**
116
+ * Prepare columns for Cms blocks grid
117
+ *
118
+ * @return Mage_Adminhtml_Block_Widget_Grid
119
+ */
120
+ protected function _prepareColumns()
121
+ {
122
+ $this->addColumn('chooser_id', array(
123
+ 'header' => Mage::helper('cms')->__('ID'),
124
+ 'align' => 'right',
125
+ 'index' => 'block_id',
126
+ 'width' => 50
127
+ ));
128
+
129
+ $this->addColumn('chooser_title', array(
130
+ 'header' => Mage::helper('cms')->__('Title'),
131
+ 'align' => 'left',
132
+ 'index' => 'title',
133
+ ));
134
+
135
+ $this->addColumn('chooser_identifier', array(
136
+ 'header' => Mage::helper('cms')->__('Identifier'),
137
+ 'align' => 'left',
138
+ 'index' => 'identifier'
139
+ ));
140
+
141
+
142
+ $this->addColumn('chooser_is_active', array(
143
+ 'header' => Mage::helper('cms')->__('Status'),
144
+ 'index' => 'is_active',
145
+ 'type' => 'options',
146
+ 'options' => array(
147
+ 0 => Mage::helper('cms')->__('Disabled'),
148
+ 1 => Mage::helper('cms')->__('Enabled')
149
+ ),
150
+ ));
151
+
152
+ return parent::_prepareColumns();
153
+ }
154
+
155
+ public function getGridUrl()
156
+ {
157
+ return $this->getUrl('*/cms_block_widget/chooser', array('_current' => true));
158
+ }
159
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml cms pages content block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Cms_Page extends Mage_Adminhtml_Block_Widget_Grid_Container
36
+ {
37
+
38
+ /**
39
+ * Block constructor
40
+ */
41
+ public function __construct()
42
+ {
43
+ $this->_controller = 'cms_page';
44
+ $this->_headerText = Mage::helper('cms')->__('Manage Pages');
45
+
46
+ parent::__construct();
47
+
48
+ if ($this->_isAllowedAction('save')) {
49
+ $this->_updateButton('add', 'label', Mage::helper('cms')->__('Add New Page'));
50
+ } else {
51
+ $this->_removeButton('add');
52
+ }
53
+
54
+ }
55
+
56
+ /**
57
+ * Check permission for passed action
58
+ *
59
+ * @param string $action
60
+ * @return bool
61
+ */
62
+ protected function _isAllowedAction($action)
63
+ {
64
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
65
+ }
66
+
67
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Admin CMS page
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Page_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ $this->_objectId = 'page_id';
40
+ $this->_controller = 'cms_page';
41
+
42
+ parent::__construct();
43
+
44
+ if ($this->_isAllowedAction('save')) {
45
+ $this->_updateButton('save', 'label', Mage::helper('cms')->__('Save Page'));
46
+ $this->_addButton('saveandcontinue', array(
47
+ 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
48
+ 'onclick' => 'saveAndContinueEdit(\''.$this->_getSaveAndContinueUrl().'\')',
49
+ 'class' => 'save',
50
+ ), -100);
51
+ } else {
52
+ $this->_removeButton('save');
53
+ }
54
+
55
+ if ($this->_isAllowedAction('delete')) {
56
+ $this->_updateButton('delete', 'label', Mage::helper('cms')->__('Delete Page'));
57
+ } else {
58
+ $this->_removeButton('delete');
59
+ }
60
+
61
+ }
62
+
63
+ /**
64
+ * Retrieve text for header element depending on loaded page
65
+ *
66
+ * @return string
67
+ */
68
+ public function getHeaderText()
69
+ {
70
+ if (Mage::registry('cms_page')->getId()) {
71
+ return Mage::helper('cms')->__("Edit Page '%s'", $this->htmlEscape(Mage::registry('cms_page')->getTitle()));
72
+ }
73
+ else {
74
+ return Mage::helper('cms')->__('New Page');
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Check permission for passed action
80
+ *
81
+ * @param string $action
82
+ * @return bool
83
+ */
84
+ protected function _isAllowedAction($action)
85
+ {
86
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
87
+ }
88
+
89
+ /**
90
+ * Getter of url for "Save and Continue" button
91
+ * tab_id will be replaced by desired by JS later
92
+ *
93
+ * @return string
94
+ */
95
+ protected function _getSaveAndContinueUrl()
96
+ {
97
+ return $this->getUrl('*/*/save', array(
98
+ '_current' => true,
99
+ 'back' => 'edit',
100
+ 'active_tab' => '{{tab_id}}'
101
+ ));
102
+ }
103
+
104
+ /**
105
+ * @see Mage_Adminhtml_Block_Widget_Container::_prepareLayout()
106
+ */
107
+ protected function _prepareLayout()
108
+ {
109
+ $tabsBlock = $this->getLayout()->getBlock('cms_page_edit_tabs');
110
+ if ($tabsBlock) {
111
+ $tabsBlockJsObject = $tabsBlock->getJsObjectName();
112
+ $tabsBlockPrefix = $tabsBlock->getId() . '_';
113
+ } else {
114
+ $tabsBlockJsObject = 'page_tabsJsTabs';
115
+ $tabsBlockPrefix = 'page_tabs_';
116
+ }
117
+
118
+ $this->_formScripts[] = "
119
+ function toggleEditor() {
120
+ if (tinyMCE.getInstanceById('page_content') == null) {
121
+ tinyMCE.execCommand('mceAddControl', false, 'page_content');
122
+ } else {
123
+ tinyMCE.execCommand('mceRemoveControl', false, 'page_content');
124
+ }
125
+ }
126
+
127
+ function saveAndContinueEdit(urlTemplate) {
128
+ var tabsIdValue = " . $tabsBlockJsObject . ".activeTab.id;
129
+ var tabsBlockPrefix = '" . $tabsBlockPrefix . "';
130
+ if (tabsIdValue.startsWith(tabsBlockPrefix)) {
131
+ tabsIdValue = tabsIdValue.substr(tabsBlockPrefix.length)
132
+ }
133
+ var template = new Template(urlTemplate, /(^|.|\\r|\\n)({{(\w+)}})/);
134
+ var url = template.evaluate({tab_id:tabsIdValue});
135
+ editForm.submit(url);
136
+ }
137
+ ";
138
+ return parent::_prepareLayout();
139
+ }
140
+
141
+
142
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Form.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml cms page edit form block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Cms_Page_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+
38
+ protected function _prepareForm()
39
+ {
40
+ $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
41
+ $form->setUseContainer(true);
42
+ $this->setForm($form);
43
+ return parent::_prepareForm();
44
+ }
45
+
46
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Cms page edit form main tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Content
36
+ extends Mage_Adminhtml_Block_Widget_Form
37
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
38
+ {
39
+ /**
40
+ * Load Wysiwyg on demand and Prepare layout
41
+ */
42
+ protected function _prepareLayout()
43
+ {
44
+ parent::_prepareLayout();
45
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
46
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
47
+ }
48
+ }
49
+
50
+ protected function _prepareForm()
51
+ {
52
+ /** @var $model Mage_Cms_Model_Page */
53
+ $model = Mage::registry('cms_page');
54
+
55
+ /*
56
+ * Checking if user have permissions to save information
57
+ */
58
+ if ($this->_isAllowedAction('save')) {
59
+ $isElementDisabled = false;
60
+ } else {
61
+ $isElementDisabled = true;
62
+ }
63
+
64
+
65
+ $form = new Varien_Data_Form();
66
+
67
+ $form->setHtmlIdPrefix('page_');
68
+
69
+ $fieldset = $form->addFieldset('content_fieldset', array('legend'=>Mage::helper('cms')->__('Content'),'class'=>'fieldset-wide'));
70
+
71
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(
72
+ array('tab_id' => $this->getTabId())
73
+ );
74
+
75
+ $fieldset->addField('content_heading', 'text', array(
76
+ 'name' => 'content_heading',
77
+ 'label' => Mage::helper('cms')->__('Content Heading'),
78
+ 'title' => Mage::helper('cms')->__('Content Heading'),
79
+ 'disabled' => $isElementDisabled
80
+ ));
81
+
82
+ $contentField = $fieldset->addField('content', 'editor', array(
83
+ 'name' => 'content',
84
+ 'style' => 'height:36em;',
85
+ 'required' => true,
86
+ 'disabled' => $isElementDisabled,
87
+ 'config' => $wysiwygConfig
88
+ ));
89
+
90
+ // Setting custom renderer for content field to remove label column
91
+ $renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element')
92
+ ->setTemplate('cms/page/edit/form/renderer/content.phtml');
93
+ $contentField->setRenderer($renderer);
94
+
95
+ $form->setValues($model->getData());
96
+ $this->setForm($form);
97
+
98
+ Mage::dispatchEvent('adminhtml_cms_page_edit_tab_content_prepare_form', array('form' => $form));
99
+
100
+ return parent::_prepareForm();
101
+ }
102
+
103
+ /**
104
+ * Prepare label for tab
105
+ *
106
+ * @return string
107
+ */
108
+ public function getTabLabel()
109
+ {
110
+ return Mage::helper('cms')->__('Content');
111
+ }
112
+
113
+ /**
114
+ * Prepare title for tab
115
+ *
116
+ * @return string
117
+ */
118
+ public function getTabTitle()
119
+ {
120
+ return Mage::helper('cms')->__('Content');
121
+ }
122
+
123
+ /**
124
+ * Returns status flag about this tab can be shown or not
125
+ *
126
+ * @return true
127
+ */
128
+ public function canShowTab()
129
+ {
130
+ return true;
131
+ }
132
+
133
+ /**
134
+ * Returns status flag about this tab hidden or not
135
+ *
136
+ * @return true
137
+ */
138
+ public function isHidden()
139
+ {
140
+ return false;
141
+ }
142
+
143
+ /**
144
+ * Check permission for passed action
145
+ *
146
+ * @param string $action
147
+ * @return bool
148
+ */
149
+ protected function _isAllowedAction($action)
150
+ {
151
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
152
+ }
153
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Design
27
+ extends Mage_Adminhtml_Block_Widget_Form
28
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
29
+ {
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setShowGlobalIcon(true);
34
+ }
35
+
36
+ protected function _prepareForm()
37
+ {
38
+ /*
39
+ * Checking if user have permissions to save information
40
+ */
41
+ if ($this->_isAllowedAction('save')) {
42
+ $isElementDisabled = false;
43
+ } else {
44
+ $isElementDisabled = true;
45
+ }
46
+
47
+ $form = new Varien_Data_Form();
48
+
49
+ $form->setHtmlIdPrefix('page_');
50
+
51
+ $model = Mage::registry('cms_page');
52
+
53
+ $layoutFieldset = $form->addFieldset('layout_fieldset', array(
54
+ 'legend' => Mage::helper('cms')->__('Page Layout'),
55
+ 'class' => 'fieldset-wide',
56
+ 'disabled' => $isElementDisabled
57
+ ));
58
+
59
+ $layoutFieldset->addField('root_template', 'select', array(
60
+ 'name' => 'root_template',
61
+ 'label' => Mage::helper('cms')->__('Layout'),
62
+ 'required' => true,
63
+ 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(),
64
+ 'disabled' => $isElementDisabled
65
+ ));
66
+ if (!$model->getId()) {
67
+ $model->setRootTemplate(Mage::getSingleton('page/source_layout')->getDefaultValue());
68
+ }
69
+
70
+ $layoutFieldset->addField('layout_update_xml', 'textarea', array(
71
+ 'name' => 'layout_update_xml',
72
+ 'label' => Mage::helper('cms')->__('Layout Update XML'),
73
+ 'style' => 'height:24em;',
74
+ 'disabled' => $isElementDisabled
75
+ ));
76
+
77
+ $designFieldset = $form->addFieldset('design_fieldset', array(
78
+ 'legend' => Mage::helper('cms')->__('Custom Design'),
79
+ 'class' => 'fieldset-wide',
80
+ 'disabled' => $isElementDisabled
81
+ ));
82
+
83
+ $dateFormatIso = Mage::app()->getLocale()->getDateFormat(
84
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
85
+ );
86
+
87
+ $designFieldset->addField('custom_theme_from', 'date', array(
88
+ 'name' => 'custom_theme_from',
89
+ 'label' => Mage::helper('cms')->__('Custom Design From'),
90
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
91
+ 'format' => $dateFormatIso,
92
+ 'disabled' => $isElementDisabled
93
+ ));
94
+
95
+ $designFieldset->addField('custom_theme_to', 'date', array(
96
+ 'name' => 'custom_theme_to',
97
+ 'label' => Mage::helper('cms')->__('Custom Design To'),
98
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
99
+ 'format' => $dateFormatIso,
100
+ 'disabled' => $isElementDisabled
101
+ ));
102
+
103
+ $designFieldset->addField('custom_theme', 'select', array(
104
+ 'name' => 'custom_theme',
105
+ 'label' => Mage::helper('cms')->__('Custom Theme'),
106
+ 'values' => Mage::getModel('core/design_source_design')->getAllOptions(),
107
+ 'disabled' => $isElementDisabled
108
+ ));
109
+
110
+
111
+ $designFieldset->addField('custom_root_template', 'select', array(
112
+ 'name' => 'custom_root_template',
113
+ 'label' => Mage::helper('cms')->__('Custom Layout'),
114
+ 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(true),
115
+ 'disabled' => $isElementDisabled
116
+ ));
117
+
118
+ $designFieldset->addField('custom_layout_update_xml', 'textarea', array(
119
+ 'name' => 'custom_layout_update_xml',
120
+ 'label' => Mage::helper('cms')->__('Custom Layout Update XML'),
121
+ 'style' => 'height:24em;',
122
+ 'disabled' => $isElementDisabled
123
+ ));
124
+
125
+ Mage::dispatchEvent('adminhtml_cms_page_edit_tab_design_prepare_form', array('form' => $form));
126
+
127
+ $form->setValues($model->getData());
128
+
129
+ $this->setForm($form);
130
+
131
+ return parent::_prepareForm();
132
+ }
133
+
134
+ /**
135
+ * Prepare label for tab
136
+ *
137
+ * @return string
138
+ */
139
+ public function getTabLabel()
140
+ {
141
+ return Mage::helper('cms')->__('Design');
142
+ }
143
+
144
+ /**
145
+ * Prepare title for tab
146
+ *
147
+ * @return string
148
+ */
149
+ public function getTabTitle()
150
+ {
151
+ return Mage::helper('cms')->__('Design');
152
+ }
153
+
154
+ /**
155
+ * Returns status flag about this tab can be showen or not
156
+ *
157
+ * @return true
158
+ */
159
+ public function canShowTab()
160
+ {
161
+ return true;
162
+ }
163
+
164
+ /**
165
+ * Returns status flag about this tab hidden or not
166
+ *
167
+ * @return true
168
+ */
169
+ public function isHidden()
170
+ {
171
+ return false;
172
+ }
173
+
174
+ /**
175
+ * Check permission for passed action
176
+ *
177
+ * @param string $action
178
+ * @return bool
179
+ */
180
+ protected function _isAllowedAction($action)
181
+ {
182
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
183
+ }
184
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Cms page edit form main tab
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Main
36
+ extends Mage_Adminhtml_Block_Widget_Form
37
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
38
+ {
39
+ protected function _prepareForm()
40
+ {
41
+ /* @var $model Mage_Cms_Model_Page */
42
+ $model = Mage::registry('cms_page');
43
+
44
+ /*
45
+ * Checking if user have permissions to save information
46
+ */
47
+ if ($this->_isAllowedAction('save')) {
48
+ $isElementDisabled = false;
49
+ } else {
50
+ $isElementDisabled = true;
51
+ }
52
+
53
+
54
+ $form = new Varien_Data_Form();
55
+
56
+ $form->setHtmlIdPrefix('page_');
57
+
58
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('cms')->__('Page Information')));
59
+
60
+ if ($model->getPageId()) {
61
+ $fieldset->addField('page_id', 'hidden', array(
62
+ 'name' => 'page_id',
63
+ ));
64
+ }
65
+
66
+ $fieldset->addField('title', 'text', array(
67
+ 'name' => 'title',
68
+ 'label' => Mage::helper('cms')->__('Page Title'),
69
+ 'title' => Mage::helper('cms')->__('Page Title'),
70
+ 'required' => true,
71
+ 'disabled' => $isElementDisabled
72
+ ));
73
+
74
+ $fieldset->addField('identifier', 'text', array(
75
+ 'name' => 'identifier',
76
+ 'label' => Mage::helper('cms')->__('URL Key'),
77
+ 'title' => Mage::helper('cms')->__('URL Key'),
78
+ 'required' => true,
79
+ 'class' => 'validate-identifier',
80
+ 'note' => Mage::helper('cms')->__('Relative to Website Base URL'),
81
+ 'disabled' => $isElementDisabled
82
+ ));
83
+
84
+ /**
85
+ * Check is single store mode
86
+ */
87
+ if (!Mage::app()->isSingleStoreMode()) {
88
+ $fieldset->addField('store_id', 'multiselect', array(
89
+ 'name' => 'stores[]',
90
+ 'label' => Mage::helper('cms')->__('Store View'),
91
+ 'title' => Mage::helper('cms')->__('Store View'),
92
+ 'required' => true,
93
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
94
+ 'disabled' => $isElementDisabled
95
+ ));
96
+ }
97
+ else {
98
+ $fieldset->addField('store_id', 'hidden', array(
99
+ 'name' => 'stores[]',
100
+ 'value' => Mage::app()->getStore(true)->getId()
101
+ ));
102
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
103
+ }
104
+
105
+ $fieldset->addField('is_active', 'select', array(
106
+ 'label' => Mage::helper('cms')->__('Status'),
107
+ 'title' => Mage::helper('cms')->__('Page Status'),
108
+ 'name' => 'is_active',
109
+ 'required' => true,
110
+ 'options' => $model->getAvailableStatuses(),
111
+ 'disabled' => $isElementDisabled,
112
+ ));
113
+ if (!$model->getId()) {
114
+ $model->setData('is_active', $isElementDisabled ? '0' : '1');
115
+ }
116
+
117
+ Mage::dispatchEvent('adminhtml_cms_page_edit_tab_main_prepare_form', array('form' => $form));
118
+
119
+ $form->setValues($model->getData());
120
+ $this->setForm($form);
121
+
122
+ return parent::_prepareForm();
123
+ }
124
+
125
+ /**
126
+ * Prepare label for tab
127
+ *
128
+ * @return string
129
+ */
130
+ public function getTabLabel()
131
+ {
132
+ return Mage::helper('cms')->__('Page Information');
133
+ }
134
+
135
+ /**
136
+ * Prepare title for tab
137
+ *
138
+ * @return string
139
+ */
140
+ public function getTabTitle()
141
+ {
142
+ return Mage::helper('cms')->__('Page Information');
143
+ }
144
+
145
+ /**
146
+ * Returns status flag about this tab can be shown or not
147
+ *
148
+ * @return true
149
+ */
150
+ public function canShowTab()
151
+ {
152
+ return true;
153
+ }
154
+
155
+ /**
156
+ * Returns status flag about this tab hidden or not
157
+ *
158
+ * @return true
159
+ */
160
+ public function isHidden()
161
+ {
162
+ return false;
163
+ }
164
+
165
+ /**
166
+ * Check permission for passed action
167
+ *
168
+ * @param string $action
169
+ * @return bool
170
+ */
171
+ protected function _isAllowedAction($action)
172
+ {
173
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
174
+ }
175
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer account form block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Meta
35
+ extends Mage_Adminhtml_Block_Widget_Form
36
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
+ {
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ }
42
+
43
+ protected function _prepareForm()
44
+ {
45
+ /*
46
+ * Checking if user have permissions to save information
47
+ */
48
+ if ($this->_isAllowedAction('save')) {
49
+ $isElementDisabled = false;
50
+ } else {
51
+ $isElementDisabled = true;
52
+ }
53
+
54
+ $form = new Varien_Data_Form();
55
+
56
+ $form->setHtmlIdPrefix('page_');
57
+
58
+ $model = Mage::registry('cms_page');
59
+
60
+ $fieldset = $form->addFieldset('meta_fieldset', array('legend' => Mage::helper('cms')->__('Meta Data'), 'class' => 'fieldset-wide'));
61
+
62
+ $fieldset->addField('meta_keywords', 'textarea', array(
63
+ 'name' => 'meta_keywords',
64
+ 'label' => Mage::helper('cms')->__('Keywords'),
65
+ 'title' => Mage::helper('cms')->__('Meta Keywords'),
66
+ 'disabled' => $isElementDisabled
67
+ ));
68
+
69
+ $fieldset->addField('meta_description', 'textarea', array(
70
+ 'name' => 'meta_description',
71
+ 'label' => Mage::helper('cms')->__('Description'),
72
+ 'title' => Mage::helper('cms')->__('Meta Description'),
73
+ 'disabled' => $isElementDisabled
74
+ ));
75
+
76
+ Mage::dispatchEvent('adminhtml_cms_page_edit_tab_meta_prepare_form', array('form' => $form));
77
+
78
+ $form->setValues($model->getData());
79
+
80
+ $this->setForm($form);
81
+
82
+ return parent::_prepareForm();
83
+ }
84
+
85
+ /**
86
+ * Prepare label for tab
87
+ *
88
+ * @return string
89
+ */
90
+ public function getTabLabel()
91
+ {
92
+ return Mage::helper('cms')->__('Meta Data');
93
+ }
94
+
95
+ /**
96
+ * Prepare title for tab
97
+ *
98
+ * @return string
99
+ */
100
+ public function getTabTitle()
101
+ {
102
+ return Mage::helper('cms')->__('Meta Data');
103
+ }
104
+
105
+ /**
106
+ * Returns status flag about this tab can be showen or not
107
+ *
108
+ * @return true
109
+ */
110
+ public function canShowTab()
111
+ {
112
+ return true;
113
+ }
114
+
115
+ /**
116
+ * Returns status flag about this tab hidden or not
117
+ *
118
+ * @return true
119
+ */
120
+ public function isHidden()
121
+ {
122
+ return false;
123
+ }
124
+
125
+ /**
126
+ * Check permission for passed action
127
+ *
128
+ * @param string $action
129
+ * @return bool
130
+ */
131
+ protected function _isAllowedAction($action)
132
+ {
133
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
134
+ }
135
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Admin page left menu
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Page_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('page_tabs');
41
+ $this->setDestElementId('edit_form');
42
+ $this->setTitle(Mage::helper('cms')->__('Page Information'));
43
+ }
44
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml cms pages grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Page_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('cmsPageGrid');
41
+ $this->setDefaultSort('identifier');
42
+ $this->setDefaultDir('ASC');
43
+ }
44
+
45
+ protected function _prepareCollection()
46
+ {
47
+ $collection = Mage::getModel('cms/page')->getCollection();
48
+ /* @var $collection Mage_Cms_Model_Mysql4_Page_Collection */
49
+ $collection->setFirstStoreFlag(true);
50
+ $this->setCollection($collection);
51
+
52
+ return parent::_prepareCollection();
53
+ }
54
+
55
+ protected function _prepareColumns()
56
+ {
57
+ $baseUrl = $this->getUrl();
58
+
59
+ $this->addColumn('title', array(
60
+ 'header' => Mage::helper('cms')->__('Title'),
61
+ 'align' => 'left',
62
+ 'index' => 'title',
63
+ ));
64
+
65
+ $this->addColumn('identifier', array(
66
+ 'header' => Mage::helper('cms')->__('URL Key'),
67
+ 'align' => 'left',
68
+ 'index' => 'identifier'
69
+ ));
70
+
71
+
72
+
73
+ $this->addColumn('root_template', array(
74
+ 'header' => Mage::helper('cms')->__('Layout'),
75
+ 'index' => 'root_template',
76
+ 'type' => 'options',
77
+ 'options' => Mage::getSingleton('page/source_layout')->getOptions(),
78
+ ));
79
+
80
+ /**
81
+ * Check is single store mode
82
+ */
83
+ if (!Mage::app()->isSingleStoreMode()) {
84
+ $this->addColumn('store_id', array(
85
+ 'header' => Mage::helper('cms')->__('Store View'),
86
+ 'index' => 'store_id',
87
+ 'type' => 'store',
88
+ 'store_all' => true,
89
+ 'store_view' => true,
90
+ 'sortable' => false,
91
+ 'filter_condition_callback'
92
+ => array($this, '_filterStoreCondition'),
93
+ ));
94
+ }
95
+
96
+ $this->addColumn('is_active', array(
97
+ 'header' => Mage::helper('cms')->__('Status'),
98
+ 'index' => 'is_active',
99
+ 'type' => 'options',
100
+ 'options' => Mage::getSingleton('cms/page')->getAvailableStatuses()
101
+ ));
102
+
103
+ $this->addColumn('creation_time', array(
104
+ 'header' => Mage::helper('cms')->__('Date Created'),
105
+ 'index' => 'creation_time',
106
+ 'type' => 'datetime',
107
+ ));
108
+
109
+ $this->addColumn('update_time', array(
110
+ 'header' => Mage::helper('cms')->__('Last Modified'),
111
+ 'index' => 'update_time',
112
+ 'type' => 'datetime',
113
+ ));
114
+
115
+ $this->addColumn('page_actions', array(
116
+ 'header' => Mage::helper('cms')->__('Action'),
117
+ 'width' => 10,
118
+ 'sortable' => false,
119
+ 'filter' => false,
120
+ 'renderer' => 'adminhtml/cms_page_grid_renderer_action',
121
+ ));
122
+
123
+ return parent::_prepareColumns();
124
+ }
125
+
126
+ protected function _afterLoadCollection()
127
+ {
128
+ $this->getCollection()->walk('afterLoad');
129
+ parent::_afterLoadCollection();
130
+ }
131
+
132
+ protected function _filterStoreCondition($collection, $column)
133
+ {
134
+ if (!$value = $column->getFilter()->getValue()) {
135
+ return;
136
+ }
137
+
138
+ $this->getCollection()->addStoreFilter($value);
139
+ }
140
+
141
+ /**
142
+ * Row click url
143
+ *
144
+ * @return string
145
+ */
146
+ public function getRowUrl($row)
147
+ {
148
+ return $this->getUrl('*/*/edit', array('page_id' => $row->getId()));
149
+ }
150
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid/Renderer/Action.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Cms_Page_Grid_Renderer_Action
28
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
29
+ {
30
+ public function render(Varien_Object $row)
31
+ {
32
+ $urlModel = Mage::getModel('core/url')->setStore($row->getData('_first_store_id'));
33
+ $href = $urlModel->getUrl(
34
+ $row->getIdentifier(), array(
35
+ '_current' => false,
36
+ '_query' => '___store='.$row->getStoreCode()
37
+ )
38
+ );
39
+ return '<a href="'.$href.'" target="_blank">'.$this->__('Preview').'</a>';
40
+ }
41
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Page/Widget/Chooser.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * CMS page chooser for Wysiwyg CMS widget
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Page_Widget_Chooser extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ /**
37
+ * Block construction, prepare grid params
38
+ *
39
+ * @param array $arguments Object data
40
+ */
41
+ public function __construct($arguments=array())
42
+ {
43
+ parent::__construct($arguments);
44
+ //$this->setDefaultSort('name');
45
+ $this->setUseAjax(true);
46
+ $this->setDefaultFilter(array('chooser_is_active' => '1'));
47
+ }
48
+
49
+ /**
50
+ * Prepare chooser element HTML
51
+ *
52
+ * @param Varien_Data_Form_Element_Abstract $element Form Element
53
+ * @return Varien_Data_Form_Element_Abstract
54
+ */
55
+ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
56
+ {
57
+ $uniqId = Mage::helper('core')->uniqHash($element->getId());
58
+ $sourceUrl = $this->getUrl('*/cms_page_widget/chooser', array('uniq_id' => $uniqId));
59
+
60
+ $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
61
+ ->setElement($element)
62
+ ->setTranslationHelper($this->getTranslationHelper())
63
+ ->setConfig($this->getConfig())
64
+ ->setFieldsetId($this->getFieldsetId())
65
+ ->setSourceUrl($sourceUrl)
66
+ ->setUniqId($uniqId);
67
+
68
+
69
+ if ($element->getValue()) {
70
+ $page = Mage::getModel('cms/page')->load((int)$element->getValue());
71
+ if ($page->getId()) {
72
+ $chooser->setLabel($page->getTitle());
73
+ }
74
+ }
75
+
76
+ $element->setData('after_element_html', $chooser->toHtml());
77
+ return $element;
78
+ }
79
+
80
+ /**
81
+ * Grid Row JS Callback
82
+ *
83
+ * @return string
84
+ */
85
+ public function getRowClickCallback()
86
+ {
87
+ $chooserJsObject = $this->getId();
88
+ $js = '
89
+ function (grid, event) {
90
+ var trElement = Event.findElement(event, "tr");
91
+ var pageTitle = trElement.down("td").next().innerHTML;
92
+ var pageId = trElement.down("td").innerHTML.replace(/^\s+|\s+$/g,"");
93
+ '.$chooserJsObject.'.setElementValue(pageId);
94
+ '.$chooserJsObject.'.setElementLabel(pageTitle);
95
+ '.$chooserJsObject.'.close();
96
+ }
97
+ ';
98
+ return $js;
99
+ }
100
+
101
+ /**
102
+ * Prepare pages collection
103
+ *
104
+ * @return Mage_Adminhtml_Block_Widget_Grid
105
+ */
106
+ protected function _prepareCollection()
107
+ {
108
+ $collection = Mage::getModel('cms/page')->getCollection();
109
+ /* @var $collection Mage_Cms_Model_Mysql4_Page_Collection */
110
+ $collection->setFirstStoreFlag(true);
111
+ $this->setCollection($collection);
112
+
113
+ return parent::_prepareCollection();
114
+ }
115
+
116
+ /**
117
+ * Prepare columns for pages grid
118
+ *
119
+ * @return Mage_Adminhtml_Block_Widget_Grid
120
+ */
121
+ protected function _prepareColumns()
122
+ {
123
+ $this->addColumn('chooser_id', array(
124
+ 'header' => Mage::helper('cms')->__('ID'),
125
+ 'align' => 'right',
126
+ 'index' => 'page_id',
127
+ 'width' => 50
128
+ ));
129
+
130
+ $this->addColumn('chooser_title', array(
131
+ 'header' => Mage::helper('cms')->__('Title'),
132
+ 'align' => 'left',
133
+ 'index' => 'title',
134
+ ));
135
+
136
+ $this->addColumn('chooser_identifier', array(
137
+ 'header' => Mage::helper('cms')->__('URL Key'),
138
+ 'align' => 'left',
139
+ 'index' => 'identifier'
140
+ ));
141
+
142
+ $this->addColumn('chooser_root_template', array(
143
+ 'header' => Mage::helper('cms')->__('Layout'),
144
+ 'index' => 'root_template',
145
+ 'type' => 'options',
146
+ 'options' => Mage::getSingleton('page/source_layout')->getOptions(),
147
+ 'width' => '100',
148
+ ));
149
+
150
+ $this->addColumn('chooser_is_active', array(
151
+ 'header' => Mage::helper('cms')->__('Status'),
152
+ 'index' => 'is_active',
153
+ 'type' => 'options',
154
+ 'options' => Mage::getModel('cms/page')->getAvailableStatuses(),
155
+ 'width' => '100',
156
+ ));
157
+
158
+ return parent::_prepareColumns();
159
+ }
160
+
161
+ public function getGridUrl()
162
+ {
163
+ return $this->getUrl('*/cms_page_widget/chooser', array('_current' => true));
164
+ }
165
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Wysiwyg Images content block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content extends Mage_Adminhtml_Block_Widget_Container
35
+ {
36
+ /**
37
+ * Block construction
38
+ */
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->_headerText = $this->helper('cms')->__('Media Storage');
43
+ $this->_removeButton('back')->_removeButton('edit');
44
+ $this->_addButton('newfolder', array(
45
+ 'class' => 'save',
46
+ 'label' => $this->helper('cms')->__('Create Folder...'),
47
+ 'type' => 'button',
48
+ 'onclick' => 'MediabrowserInstance.newFolder();'
49
+ ));
50
+
51
+ $this->_addButton('delete_folder', array(
52
+ 'class' => 'delete no-display',
53
+ 'label' => $this->helper('cms')->__('Delete Folder'),
54
+ 'type' => 'button',
55
+ 'onclick' => 'MediabrowserInstance.deleteFolder();',
56
+ 'id' => 'button_delete_folder'
57
+ ));
58
+
59
+ $this->_addButton('delete_files', array(
60
+ 'class' => 'delete no-display',
61
+ 'label' => $this->helper('cms')->__('Delete File'),
62
+ 'type' => 'button',
63
+ 'onclick' => 'MediabrowserInstance.deleteFiles();',
64
+ 'id' => 'button_delete_files'
65
+ ));
66
+
67
+ $this->_addButton('insert_files', array(
68
+ 'class' => 'save no-display',
69
+ 'label' => $this->helper('cms')->__('Insert File'),
70
+ 'type' => 'button',
71
+ 'onclick' => 'MediabrowserInstance.insert();',
72
+ 'id' => 'button_insert_files'
73
+ ));
74
+ }
75
+
76
+ /**
77
+ * Files action source URL
78
+ *
79
+ * @return string
80
+ */
81
+ public function getContentsUrl()
82
+ {
83
+ return $this->getUrl('*/*/contents', array('type' => $this->getRequest()->getParam('type')));
84
+ }
85
+
86
+ /**
87
+ * Javascript setup object for filebrowser instance
88
+ *
89
+ * @return string
90
+ */
91
+ public function getFilebrowserSetupObject()
92
+ {
93
+ $setupObject = new Varien_Object();
94
+
95
+ $setupObject->setData(array(
96
+ 'newFolderPrompt' => $this->helper('cms')->__('New Folder Name:'),
97
+ 'deleteFolderConfirmationMessage' => $this->helper('cms')->__('Are you sure you want to delete current folder?'),
98
+ 'deleteFileConfirmationMessage' => $this->helper('cms')->__('Are you sure you want to delete the selected file?'),
99
+ 'targetElementId' => $this->getTargetElementId(),
100
+ 'contentsUrl' => $this->getContentsUrl(),
101
+ 'onInsertUrl' => $this->getOnInsertUrl(),
102
+ 'newFolderUrl' => $this->getNewfolderUrl(),
103
+ 'deleteFolderUrl' => $this->getDeletefolderUrl(),
104
+ 'deleteFilesUrl' => $this->getDeleteFilesUrl(),
105
+ 'headerText' => $this->getHeaderText()
106
+ ));
107
+
108
+ return Mage::helper('core')->jsonEncode($setupObject);
109
+ }
110
+
111
+ /**
112
+ * New directory action target URL
113
+ *
114
+ * @return string
115
+ */
116
+ public function getNewfolderUrl()
117
+ {
118
+ return $this->getUrl('*/*/newFolder');
119
+ }
120
+
121
+ /**
122
+ * Delete directory action target URL
123
+ *
124
+ * @return string
125
+ */
126
+ protected function getDeletefolderUrl()
127
+ {
128
+ return $this->getUrl('*/*/deleteFolder');
129
+ }
130
+
131
+ /**
132
+ * Description goes here...
133
+ *
134
+ * @param none
135
+ * @return void
136
+ */
137
+ public function getDeleteFilesUrl()
138
+ {
139
+ return $this->getUrl('*/*/deleteFiles');
140
+ }
141
+
142
+ /**
143
+ * New directory action target URL
144
+ *
145
+ * @return string
146
+ */
147
+ public function getOnInsertUrl()
148
+ {
149
+ return $this->getUrl('*/*/onInsert');
150
+ }
151
+
152
+ /**
153
+ * Target element ID getter
154
+ *
155
+ * @return string
156
+ */
157
+ public function getTargetElementId()
158
+ {
159
+ return $this->getRequest()->getParam('target_element_id');
160
+ }
161
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Files.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Directory contents block for Wysiwyg Images
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Files extends Mage_Adminhtml_Block_Template
35
+ {
36
+ /**
37
+ * Files collection object
38
+ *
39
+ * @var Varien_Data_Collection_Filesystem
40
+ */
41
+ protected $_filesCollection;
42
+
43
+ /**
44
+ * Prepared Files collection for current directory
45
+ *
46
+ * @return Varien_Data_Collection_Filesystem
47
+ */
48
+ public function getFiles()
49
+ {
50
+ if (! $this->_filesCollection) {
51
+ $this->_filesCollection = Mage::getSingleton('cms/wysiwyg_images_storage')->getFilesCollection(Mage::helper('cms/wysiwyg_images')->getCurrentPath(), $this->_getMediaType());
52
+
53
+ }
54
+
55
+ return $this->_filesCollection;
56
+ }
57
+
58
+ /**
59
+ * Files collection count getter
60
+ *
61
+ * @return int
62
+ */
63
+ public function getFilesCount()
64
+ {
65
+ return $this->getFiles()->count();
66
+ }
67
+
68
+ /**
69
+ * File idetifier getter
70
+ *
71
+ * @param Varien_Object $file
72
+ * @return string
73
+ */
74
+ public function getFileId(Varien_Object $file)
75
+ {
76
+ return $file->getId();
77
+ }
78
+
79
+ /**
80
+ * File thumb URL getter
81
+ *
82
+ * @param Varien_Object $file
83
+ * @return string
84
+ */
85
+ public function getFileThumbUrl(Varien_Object $file)
86
+ {
87
+ return $file->getThumbUrl();
88
+ }
89
+
90
+ /**
91
+ * File name URL getter
92
+ *
93
+ * @param Varien_Object $file
94
+ * @return string
95
+ */
96
+ public function getFileName(Varien_Object $file)
97
+ {
98
+ return $file->getName();
99
+ }
100
+
101
+ /**
102
+ * Image file width getter
103
+ *
104
+ * @param Varien_Object $file
105
+ * @return string
106
+ */
107
+ public function getFileWidth(Varien_Object $file)
108
+ {
109
+ return $file->getWidth();
110
+ }
111
+
112
+ /**
113
+ * Image file height getter
114
+ *
115
+ * @param Varien_Object $file
116
+ * @return string
117
+ */
118
+ public function getFileHeight(Varien_Object $file)
119
+ {
120
+ return $file->getHeight();
121
+ }
122
+
123
+ /**
124
+ * File short name getter
125
+ *
126
+ * @param Varien_Object $file
127
+ * @return string
128
+ */
129
+ public function getFileShortName(Varien_Object $file)
130
+ {
131
+ return $file->getShortName();
132
+ }
133
+
134
+ public function getImagesWidth()
135
+ {
136
+ return Mage::getSingleton('cms/wysiwyg_images_storage')->getConfigData('resize_width');
137
+ }
138
+
139
+ public function getImagesHeight()
140
+ {
141
+ return Mage::getSingleton('cms/wysiwyg_images_storage')->getConfigData('resize_height');
142
+ }
143
+
144
+ /**
145
+ * Return current media type based on request or data
146
+ * @return string
147
+ */
148
+ protected function _getMediaType()
149
+ {
150
+ if ($this->hasData('media_type')) {
151
+ return $this->_getData('media_type');
152
+ }
153
+ return $this->getRequest()->getParam('type');
154
+ }
155
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Newfolder.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * New directory block for Wysiwyg Images
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Newfolder extends Mage_Adminhtml_Block_Template
35
+ {
36
+
37
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Content/Uploader.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Uploader block for Wysiwyg Images
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Uploader extends Mage_Adminhtml_Block_Media_Uploader
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $params = $this->getConfig()->getParams();
40
+ $type = $this->_getMediaType();
41
+ $allowed = Mage::getSingleton('cms/wysiwyg_images_storage')->getAllowedExtensions($type);
42
+ $labels = array();
43
+ $files = array();
44
+ foreach ($allowed as $ext) {
45
+ $labels[] = '.' . $ext;
46
+ $files[] = '*.' . $ext;
47
+ }
48
+ $this->getConfig()
49
+ ->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/upload', array('type' => $type)))
50
+ ->setParams($params)
51
+ ->setFileField('image')
52
+ ->setFilters(array(
53
+ 'images' => array(
54
+ 'label' => $this->helper('cms')->__('Images (%s)', implode(', ', $labels)),
55
+ 'files' => $files
56
+ )
57
+ ));
58
+ }
59
+
60
+ /**
61
+ * Return current media type based on request or data
62
+ * @return string
63
+ */
64
+ protected function _getMediaType()
65
+ {
66
+ if ($this->hasData('media_type')) {
67
+ return $this->_getData('media_type');
68
+ }
69
+ return $this->getRequest()->getParam('type');
70
+ }
71
+ }
app/code/core/Mage/Adminhtml/Block/Cms/Wysiwyg/Images/Tree.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Directoty tree renderer for Cms Wysiwyg Images
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Tree extends Mage_Adminhtml_Block_Template
35
+ {
36
+
37
+ /**
38
+ * Json tree builder
39
+ *
40
+ * @return string
41
+ */
42
+ public function getTreeJson()
43
+ {
44
+ $helper = Mage::helper('cms/wysiwyg_images');
45
+ $storageRoot = $helper->getStorageRoot();
46
+ $collection = Mage::registry('storage')->getDirsCollection($helper->getCurrentPath());
47
+ $jsonArray = array();
48
+ foreach ($collection as $item) {
49
+ $jsonArray[] = array(
50
+ 'text' => $helper->getShortFilename($item->getBasename(), 20),
51
+ 'id' => $helper->convertPathToId($item->getFilename()),
52
+ 'cls' => 'folder'
53
+ );
54
+ }
55
+ return Zend_Json::encode($jsonArray);
56
+ }
57
+
58
+ /**
59
+ * Json source URL
60
+ *
61
+ * @return string
62
+ */
63
+ public function getTreeLoaderUrl()
64
+ {
65
+ return $this->getUrl('*/*/treeJson');
66
+ }
67
+
68
+ /**
69
+ * Root node name of tree
70
+ *
71
+ * @return string
72
+ */
73
+ public function getRootNodeName()
74
+ {
75
+ return $this->helper('cms')->__('Storage Root');
76
+ }
77
+
78
+ /**
79
+ * Return tree node full path based on current path
80
+ *
81
+ * @return string
82
+ */
83
+ public function getTreeCurrentPath()
84
+ {
85
+ $treePath = '/root';
86
+ if ($path = Mage::registry('storage')->getSession()->getCurrentPath()) {
87
+ $helper = Mage::helper('cms/wysiwyg_images');
88
+ $path = str_replace($helper->getStorageRoot(), '', $path);
89
+ $relative = '';
90
+ foreach (explode(DS, $path) as $dirName) {
91
+ if ($dirName) {
92
+ $relative .= DS . $dirName;
93
+ $treePath .= '/' . $helper->idEncode($relative);
94
+ }
95
+ }
96
+ }
97
+ return $treePath;
98
+ }
99
+ }
app/code/core/Mage/Adminhtml/Block/Customer.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers list block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Customer extends Mage_Adminhtml_Block_Widget_Grid_Container
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ $this->_controller = 'customer';
41
+ $this->_headerText = Mage::helper('customer')->__('Manage Customers');
42
+ $this->_addButtonLabel = Mage::helper('customer')->__('Add New Customer');
43
+ parent::__construct();
44
+ }
45
+
46
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer edit block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
35
+ {
36
+ public function __construct()
37
+ {
38
+ $this->_objectId = 'id';
39
+ $this->_controller = 'customer';
40
+
41
+ if ($this->getCustomerId() &&
42
+ Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/create')) {
43
+ $this->_addButton('order', array(
44
+ 'label' => Mage::helper('customer')->__('Create Order'),
45
+ 'onclick' => 'setLocation(\'' . $this->getCreateOrderUrl() . '\')',
46
+ 'class' => 'add',
47
+ ), 0);
48
+ }
49
+
50
+ parent::__construct();
51
+
52
+ $this->_updateButton('save', 'label', Mage::helper('customer')->__('Save Customer'));
53
+ $this->_updateButton('delete', 'label', Mage::helper('customer')->__('Delete Customer'));
54
+
55
+ if (Mage::registry('current_customer')->isReadonly()) {
56
+ $this->_removeButton('save');
57
+ $this->_removeButton('reset');
58
+ }
59
+
60
+ if (!Mage::registry('current_customer')->isDeleteable()) {
61
+ $this->_removeButton('delete');
62
+ }
63
+ }
64
+
65
+ public function getCreateOrderUrl()
66
+ {
67
+ return $this->getUrl('*/sales_order_create/start', array('customer_id' => $this->getCustomerId()));
68
+ }
69
+
70
+ public function getCustomerId()
71
+ {
72
+ return Mage::registry('current_customer')->getId();
73
+ }
74
+
75
+ public function getHeaderText()
76
+ {
77
+ if (Mage::registry('current_customer')->getId()) {
78
+ return $this->htmlEscape(Mage::registry('current_customer')->getName());
79
+ }
80
+ else {
81
+ return Mage::helper('customer')->__('New Customer');
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Prepare form html. Add block for configurable product modification interface
87
+ *
88
+ * @return string
89
+ */
90
+ public function getFormHtml()
91
+ {
92
+ $html = parent::getFormHtml();
93
+ $html .= $this->getLayout()->createBlock('adminhtml/catalog_product_composite_configure')->toHtml();
94
+ return $html;
95
+ }
96
+
97
+ public function getValidationUrl()
98
+ {
99
+ return $this->getUrl('*/*/validate', array('_current'=>true));
100
+ }
101
+
102
+ protected function _prepareLayout()
103
+ {
104
+ if (!Mage::registry('current_customer')->isReadonly()) {
105
+ $this->_addButton('save_and_continue', array(
106
+ 'label' => Mage::helper('customer')->__('Save and Continue Edit'),
107
+ 'onclick' => 'saveAndContinueEdit(\''.$this->_getSaveAndContinueUrl().'\')',
108
+ 'class' => 'save'
109
+ ), 10);
110
+ }
111
+
112
+ return parent::_prepareLayout();
113
+ }
114
+
115
+ protected function _getSaveAndContinueUrl()
116
+ {
117
+ return $this->getUrl('*/*/save', array(
118
+ '_current' => true,
119
+ 'back' => 'edit',
120
+ 'tab' => '{{tab_id}}'
121
+ ));
122
+ }
123
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Form.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer edit form block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Customer_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+
38
+ protected function _prepareForm()
39
+ {
40
+ $form = new Varien_Data_Form(array(
41
+ 'id' => 'edit_form',
42
+ 'action' => $this->getData('action'),
43
+ 'method' => 'post',
44
+ 'enctype' => 'multipart/form-data'
45
+ ));
46
+
47
+ $customer = Mage::registry('current_customer');
48
+
49
+ if ($customer->getId()) {
50
+ $form->addField('entity_id', 'hidden', array(
51
+ 'name' => 'customer_id',
52
+ ));
53
+ $form->setValues($customer->getData());
54
+ }
55
+
56
+ $form->setUseContainer(true);
57
+ $this->setForm($form);
58
+ return parent::_prepareForm();
59
+ }
60
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Newpass.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer new password field renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Renderer_Newpass extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
35
+ {
36
+
37
+ public function render(Varien_Data_Form_Element_Abstract $element)
38
+ {
39
+ $html = '<tr>';
40
+ $html.= '<td class="label">'.$element->getLabelHtml().'</td>';
41
+ $html.= '<td class="value">'.$element->getElementHtml().'</td>';
42
+ $html.= '</tr>'."\n";
43
+ $html.= '<tr>';
44
+ $html.= '<td class="label"><label>&nbsp;</label></td>';
45
+ $html.= '<td class="value">'.Mage::helper('customer')->__('or').'</td>';
46
+ $html.= '</tr>'."\n";
47
+ $html.= '<tr>';
48
+ $html.= '<td class="label"><label>&nbsp;</label></td>';
49
+ $html.= '<td class="value"><input type="checkbox" id="account-send-pass" name="'.$element->getName().'" value="auto" onclick="setElementDisable(\''.$element->getHtmlId().'\', this.checked)"/>&nbsp;';
50
+ $html.= '<label for="account-send-pass">'.Mage::helper('customer')->__('Send auto-generated password').'</label></td>';
51
+ $html.= '</tr>'."\n";
52
+
53
+ return $html;
54
+ }
55
+
56
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer address region field renderer
29
+ *
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+ class Mage_Adminhtml_Block_Customer_Edit_Renderer_Region extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
33
+ {
34
+ /**
35
+ * Output the region element and javasctipt that makes it dependent from country element
36
+ *
37
+ * @param Varien_Data_Form_Element_Abstract $element
38
+ * @return string
39
+ */
40
+ public function render(Varien_Data_Form_Element_Abstract $element)
41
+ {
42
+ if ($country = $element->getForm()->getElement('country_id')) {
43
+ $countryId = $country->getValue();
44
+ }
45
+ else {
46
+ return $element->getDefaultHtml();
47
+ }
48
+
49
+ $regionId = $element->getForm()->getElement('region_id')->getValue();
50
+
51
+ $html = '<tr>';
52
+ $element->setClass('input-text');
53
+ $html.= '<td class="label">'.$element->getLabelHtml().'</td><td class="value">';
54
+ $html.= $element->getElementHtml();
55
+
56
+ $selectName = str_replace('region', 'region_id', $element->getName());
57
+ $selectId = $element->getHtmlId().'_id';
58
+ $html.= '<select id="'.$selectId.'" name="'.$selectName.'" class="select required-entry" style="display:none">';
59
+ $html.= '<option value="">'.Mage::helper('customer')->__('Please select').'</option>';
60
+ $html.= '</select>';
61
+
62
+ $html.= '<script type="text/javascript">'."\n";
63
+ $html.= 'new regionUpdater("'.$country->getHtmlId().'", "'.$element->getHtmlId().'", "'.$selectId.'", '.$this->helper('directory')->getRegionJson().');'."\n";
64
+ $html.= '</script>'."\n";
65
+
66
+ $html.= '</td></tr>'."\n";
67
+ return $html;
68
+ }
69
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer account form block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Account extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ }
40
+
41
+ public function initForm()
42
+ {
43
+ $form = new Varien_Data_Form();
44
+ $form->setHtmlIdPrefix('_account');
45
+ $form->setFieldNameSuffix('account');
46
+
47
+ $customer = Mage::registry('current_customer');
48
+
49
+ /* @var $customerForm Mage_Customer_Model_Form */
50
+ $customerForm = Mage::getModel('customer/form');
51
+ $customerForm->setEntity($customer)
52
+ ->setFormCode('adminhtml_customer')
53
+ ->initDefaultValues();
54
+
55
+ $fieldset = $form->addFieldset('base_fieldset',
56
+ array('legend'=>Mage::helper('customer')->__('Account Information'))
57
+ );
58
+
59
+ $attributes = $customerForm->getAttributes();
60
+ foreach ($attributes as $attribute) {
61
+ $attribute->unsIsVisible();
62
+ }
63
+ $this->_setFieldset($attributes, $fieldset);
64
+
65
+ if ($customer->getId()) {
66
+ $form->getElement('website_id')->setDisabled('disabled');
67
+ $form->getElement('created_in')->setDisabled('disabled');
68
+ } else {
69
+ $fieldset->removeField('created_in');
70
+ }
71
+
72
+ // if (Mage::app()->isSingleStoreMode()) {
73
+ // $fieldset->removeField('website_id');
74
+ // $fieldset->addField('website_id', 'hidden', array(
75
+ // 'name' => 'website_id'
76
+ // ));
77
+ // $customer->setWebsiteId(Mage::app()->getStore(true)->getWebsiteId());
78
+ // }
79
+
80
+ $customerStoreId = null;
81
+ if ($customer->getId()) {
82
+ $customerStoreId = Mage::app()->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId();
83
+ }
84
+
85
+ $prefixElement = $form->getElement('prefix');
86
+ if ($prefixElement) {
87
+ $prefixOptions = $this->helper('customer')->getNamePrefixOptions($customerStoreId);
88
+ if (!empty($prefixOptions)) {
89
+ $fieldset->removeField($prefixElement->getId());
90
+ $prefixField = $fieldset->addField($prefixElement->getId(),
91
+ 'select',
92
+ $prefixElement->getData(),
93
+ $form->getElement('group_id')->getId()
94
+ );
95
+ $prefixField->setValues($prefixOptions);
96
+ if ($customer->getId()) {
97
+ $prefixField->addElementValues($customer->getPrefix());
98
+ }
99
+
100
+ }
101
+ }
102
+
103
+ $suffixElement = $form->getElement('suffix');
104
+ if ($suffixElement) {
105
+ $suffixOptions = $this->helper('customer')->getNameSuffixOptions($customerStoreId);
106
+ if (!empty($suffixOptions)) {
107
+ $fieldset->removeField($suffixElement->getId());
108
+ $suffixField = $fieldset->addField($suffixElement->getId(),
109
+ 'select',
110
+ $suffixElement->getData(),
111
+ $form->getElement('lastname')->getId()
112
+ );
113
+ $suffixField->setValues($suffixOptions);
114
+ if ($customer->getId()) {
115
+ $suffixField->addElementValues($customer->getSuffix());
116
+ }
117
+ }
118
+ }
119
+
120
+ if ($customer->getId()) {
121
+ if (!$customer->isReadonly()) {
122
+ // add password management fieldset
123
+ $newFieldset = $form->addFieldset(
124
+ 'password_fieldset',
125
+ array('legend'=>Mage::helper('customer')->__('Password Management'))
126
+ );
127
+ // New customer password
128
+ $field = $newFieldset->addField('new_password', 'text',
129
+ array(
130
+ 'label' => Mage::helper('customer')->__('New Password'),
131
+ 'name' => 'new_password',
132
+ 'class' => 'validate-new-password'
133
+ )
134
+ );
135
+ $field->setRenderer($this->getLayout()->createBlock('adminhtml/customer_edit_renderer_newpass'));
136
+
137
+ // prepare customer confirmation control (only for existing customers)
138
+ $confirmationKey = $customer->getConfirmation();
139
+ if ($confirmationKey || $customer->isConfirmationRequired()) {
140
+ $confirmationAttribute = $customer->getAttribute('confirmation');
141
+ if (!$confirmationKey) {
142
+ $confirmationKey = $customer->getRandomConfirmationKey();
143
+ }
144
+ $element = $fieldset->addField('confirmation', 'select', array(
145
+ 'name' => 'confirmation',
146
+ 'label' => Mage::helper('customer')->__($confirmationAttribute->getFrontendLabel()),
147
+ ))->setEntityAttribute($confirmationAttribute)
148
+ ->setValues(array('' => 'Confirmed', $confirmationKey => 'Not confirmed'));
149
+
150
+ // prepare send welcome email checkbox, if customer is not confirmed
151
+ // no need to add it, if website id is empty
152
+ if ($customer->getConfirmation() && $customer->getWebsiteId()) {
153
+ $fieldset->addField('sendemail', 'checkbox', array(
154
+ 'name' => 'sendemail',
155
+ 'label' => Mage::helper('customer')->__('Send Welcome Email after Confirmation')
156
+ ));
157
+ $customer->setData('sendemail', '1');
158
+ }
159
+ }
160
+ }
161
+ } else {
162
+ $newFieldset = $form->addFieldset(
163
+ 'password_fieldset',
164
+ array('legend'=>Mage::helper('customer')->__('Password Management'))
165
+ );
166
+ $field = $newFieldset->addField('password', 'text',
167
+ array(
168
+ 'label' => Mage::helper('customer')->__('Password'),
169
+ 'class' => 'input-text required-entry validate-password',
170
+ 'name' => 'password',
171
+ 'required' => true
172
+ )
173
+ );
174
+ $field->setRenderer($this->getLayout()->createBlock('adminhtml/customer_edit_renderer_newpass'));
175
+
176
+ // prepare send welcome email checkbox
177
+ $fieldset->addField('sendemail', 'checkbox', array(
178
+ 'label' => Mage::helper('customer')->__('Send Welcome Email'),
179
+ 'name' => 'sendemail',
180
+ 'id' => 'sendemail',
181
+ ));
182
+ $customer->setData('sendemail', '1');
183
+ if (!Mage::app()->isSingleStoreMode()) {
184
+ $fieldset->addField('sendemail_store_id', 'select', array(
185
+ 'label' => $this->helper('customer')->__('Send From'),
186
+ 'name' => 'sendemail_store_id',
187
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm()
188
+ ));
189
+ }
190
+ }
191
+
192
+ // make sendemail and sendmail_store_id disabled, if website_id has empty value
193
+ $isSingleMode = Mage::app()->isSingleStoreMode();
194
+ $sendEmailId = $isSingleMode ? 'sendemail' : 'sendemail_store_id';
195
+ $sendEmail = $form->getElement($sendEmailId);
196
+
197
+ $prefix = $form->getHtmlIdPrefix();
198
+ if ($sendEmail) {
199
+ $_disableStoreField = '';
200
+ if (!$isSingleMode) {
201
+ $_disableStoreField = "$('{$prefix}sendemail_store_id').disabled=(''==this.value || '0'==this.value);";
202
+ }
203
+ $sendEmail->setAfterElementHtml(
204
+ '<script type="text/javascript">'
205
+ . "
206
+ $('{$prefix}website_id').disableSendemail = function() {
207
+ $('{$prefix}sendemail').disabled = ('' == this.value || '0' == this.value);".
208
+ $_disableStoreField
209
+ ."}.bind($('{$prefix}website_id'));
210
+ Event.observe('{$prefix}website_id', 'change', $('{$prefix}website_id').disableSendemail);
211
+ $('{$prefix}website_id').disableSendemail();
212
+ "
213
+ . '</script>'
214
+ );
215
+ }
216
+
217
+ if ($customer->isReadonly()) {
218
+ foreach ($customer->getAttributes() as $attribute) {
219
+ $element = $form->getElement($attribute->getAttributeCode());
220
+ if ($element) {
221
+ $element->setReadonly(true, true);
222
+ }
223
+ }
224
+ }
225
+
226
+ $form->setValues($customer->getData());
227
+ $this->setForm($form);
228
+ return $this;
229
+ }
230
+
231
+ /**
232
+ * Return predefined additional element types
233
+ *
234
+ * @return array
235
+ */
236
+ protected function _getAdditionalElementTypes()
237
+ {
238
+ return array(
239
+ 'file' => Mage::getConfig()->getBlockClassName('adminhtml/customer_form_element_file'),
240
+ 'image' => Mage::getConfig()->getBlockClassName('adminhtml/customer_form_element_image'),
241
+ 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/customer_form_element_boolean'),
242
+ );
243
+ }
244
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer addresses forms
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setTemplate('customer/tab/addresses.phtml');
40
+ }
41
+
42
+ public function getRegionsUrl()
43
+ {
44
+ return $this->getUrl('*/json/countryRegion');
45
+ }
46
+
47
+ protected function _prepareLayout()
48
+ {
49
+ $this->setChild('delete_button',
50
+ $this->getLayout()->createBlock('adminhtml/widget_button')
51
+ ->setData(array(
52
+ 'label' => Mage::helper('customer')->__('Delete Address'),
53
+ 'name' => 'delete_address',
54
+ 'element_name' => 'delete_address',
55
+ 'disabled' => $this->isReadonly(),
56
+ 'class' => 'delete' . ($this->isReadonly() ? ' disabled' : '')
57
+ ))
58
+ );
59
+ $this->setChild('add_address_button',
60
+ $this->getLayout()->createBlock('adminhtml/widget_button')
61
+ ->setData(array(
62
+ 'label' => Mage::helper('customer')->__('Add New Address'),
63
+ 'id' => 'add_address_button',
64
+ 'name' => 'add_address_button',
65
+ 'element_name' => 'add_address_button',
66
+ 'disabled' => $this->isReadonly(),
67
+ 'class' => 'add' . ($this->isReadonly() ? ' disabled' : ''),
68
+ 'onclick'=> 'customerAddresses.addNewAddress()'
69
+ ))
70
+ );
71
+ $this->setChild('cancel_button',
72
+ $this->getLayout()->createBlock('adminhtml/widget_button')
73
+ ->setData(array(
74
+ 'label' => Mage::helper('customer')->__('Cancel'),
75
+ 'id' => 'cancel_add_address'.$this->getTemplatePrefix(),
76
+ 'name' => 'cancel_address',
77
+ 'element_name' => 'cancel_address',
78
+ 'class' => 'cancel delete-address' . ($this->isReadonly() ? ' disabled' : ''),
79
+ 'disabled' => $this->isReadonly(),
80
+ 'onclick'=> 'customerAddresses.cancelAdd(this)',
81
+ ))
82
+ );
83
+ return parent::_prepareLayout();
84
+ }
85
+
86
+ /**
87
+ * Check block is readonly.
88
+ *
89
+ * @return boolean
90
+ */
91
+ public function isReadonly()
92
+ {
93
+ $customer = Mage::registry('current_customer');
94
+ return $customer->isReadonly();
95
+ }
96
+
97
+ public function getDeleteButtonHtml()
98
+ {
99
+ return $this->getChildHtml('delete_button');
100
+ }
101
+
102
+ /**
103
+ * Initialize form object
104
+ *
105
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses
106
+ */
107
+ public function initForm()
108
+ {
109
+ /* @var $customer Mage_Customer_Model_Customer */
110
+ $customer = Mage::registry('current_customer');
111
+
112
+ $form = new Varien_Data_Form();
113
+ $fieldset = $form->addFieldset('address_fieldset', array(
114
+ 'legend' => Mage::helper('customer')->__("Edit Customer's Address"))
115
+ );
116
+
117
+ $addressModel = Mage::getModel('customer/address');
118
+ $addressModel->setCountryId(Mage::helper('core')->getDefaultCountry($customer->getStore()));
119
+ /** @var $addressForm Mage_Customer_Model_Form */
120
+ $addressForm = Mage::getModel('customer/form');
121
+ $addressForm->setFormCode('adminhtml_customer_address')
122
+ ->setEntity($addressModel)
123
+ ->initDefaultValues();
124
+
125
+ $attributes = $addressForm->getAttributes();
126
+ if(isset($attributes['street'])) {
127
+ Mage::helper('adminhtml/addresses')
128
+ ->processStreetAttribute($attributes['street']);
129
+ }
130
+ foreach ($attributes as $attribute) {
131
+ $attribute->unsIsVisible();
132
+ }
133
+ $this->_setFieldset($attributes, $fieldset);
134
+
135
+ $regionElement = $form->getElement('region');
136
+ if ($regionElement) {
137
+ $regionElement->setRenderer(Mage::getModel('adminhtml/customer_renderer_region'));
138
+ }
139
+
140
+ $regionElement = $form->getElement('region_id');
141
+ if ($regionElement) {
142
+ $regionElement->setNoDisplay(true);
143
+ }
144
+
145
+ $country = $form->getElement('country_id');
146
+ if ($country) {
147
+ $country->addClass('countries');
148
+ }
149
+
150
+ if ($this->isReadonly()) {
151
+ foreach ($addressModel->getAttributes() as $attribute) {
152
+ $element = $form->getElement($attribute->getAttributeCode());
153
+ if ($element) {
154
+ $element->setReadonly(true, true);
155
+ }
156
+ }
157
+ }
158
+
159
+ $customerStoreId = null;
160
+ if ($customer->getId()) {
161
+ $customerStoreId = Mage::app()->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId();
162
+ }
163
+
164
+ $prefixElement = $form->getElement('prefix');
165
+ if ($prefixElement) {
166
+ $prefixOptions = $this->helper('customer')->getNamePrefixOptions($customerStoreId);
167
+ if (!empty($prefixOptions)) {
168
+ $fieldset->removeField($prefixElement->getId());
169
+ $prefixField = $fieldset->addField($prefixElement->getId(),
170
+ 'select',
171
+ $prefixElement->getData(),
172
+ '^'
173
+ );
174
+ $prefixField->setValues($prefixOptions);
175
+ }
176
+ }
177
+
178
+ $suffixElement = $form->getElement('suffix');
179
+ if ($suffixElement) {
180
+ $suffixOptions = $this->helper('customer')->getNameSuffixOptions($customerStoreId);
181
+ if (!empty($suffixOptions)) {
182
+ $fieldset->removeField($suffixElement->getId());
183
+ $suffixField = $fieldset->addField($suffixElement->getId(),
184
+ 'select',
185
+ $suffixElement->getData(),
186
+ $form->getElement('lastname')->getId()
187
+ );
188
+ $suffixField->setValues($suffixOptions);
189
+ }
190
+ }
191
+
192
+ $addressCollection = $customer->getAddresses();
193
+ $this->assign('customer', $customer);
194
+ $this->assign('addressCollection', $addressCollection);
195
+ $form->setValues($addressModel->getData());
196
+ $this->setForm($form);
197
+
198
+ return $this;
199
+ }
200
+
201
+ public function getCancelButtonHtml()
202
+ {
203
+ return $this->getChildHtml('cancel_button');
204
+ }
205
+
206
+ public function getAddNewButtonHtml()
207
+ {
208
+ return $this->getChildHtml('add_address_button');
209
+ }
210
+
211
+ public function getTemplatePrefix()
212
+ {
213
+ return '_template_';
214
+ }
215
+
216
+ /**
217
+ * Return predefined additional element types
218
+ *
219
+ * @return array
220
+ */
221
+ protected function _getAdditionalElementTypes()
222
+ {
223
+ return array(
224
+ 'file' => Mage::getConfig()->getBlockClassName('adminhtml/customer_form_element_file'),
225
+ 'image' => Mage::getConfig()->getBlockClassName('adminhtml/customer_form_element_image'),
226
+ 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/customer_form_element_boolean'),
227
+ );
228
+ }
229
+
230
+ /**
231
+ * Return JSON object with countries associated to possible websites
232
+ *
233
+ * @return string
234
+ */
235
+ public function getDefaultCountriesJson() {
236
+ $websites = Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm(false, true);
237
+ $result = array();
238
+ foreach ($websites as $website) {
239
+ $result[$website['value']] = Mage::app()->getWebsite($website['value'])->getConfig(
240
+ Mage_Core_Helper_Data::XML_PATH_DEFAULT_COUNTRY
241
+ );
242
+ }
243
+
244
+ return Mage::helper('core')->jsonEncode($result);
245
+ }
246
+
247
+ /**
248
+ * Add specified values to name prefix element values
249
+ *
250
+ * @param string|int|array $values
251
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses
252
+ */
253
+ public function addValuesToNamePrefixElement($values)
254
+ {
255
+ if ($this->getForm() && $this->getForm()->getElement('prefix')) {
256
+ $this->getForm()->getElement('prefix')->addElementValues($values);
257
+ }
258
+ return $this;
259
+ }
260
+
261
+ /**
262
+ * Add specified values to name suffix element values
263
+ *
264
+ * @param string|int|array $values
265
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses
266
+ */
267
+ public function addValuesToNameSuffixElement($values)
268
+ {
269
+ if ($this->getForm() && $this->getForm()->getElement('suffix')) {
270
+ $this->getForm()->getElement('suffix')->addElementValues($values);
271
+ }
272
+ return $this;
273
+ }
274
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Cart.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml customer orders grid block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Cart extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ public function __construct($attributes=array())
38
+ {
39
+ parent::__construct($attributes);
40
+ $this->setId('customer_cart_grid'.$this->getWebsiteId());
41
+ $this->setUseAjax(true);
42
+ $this->_parentTemplate = $this->getTemplate();
43
+ $this->setTemplate('customer/tab/cart.phtml');
44
+ }
45
+
46
+ protected function _prepareCollection()
47
+ {
48
+ $customer = Mage::registry('current_customer');
49
+ $storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds();
50
+
51
+ $quote = Mage::getModel('sales/quote')
52
+ ->setSharedStoreIds($storeIds)
53
+ ->loadByCustomer($customer);
54
+
55
+ if ($quote) {
56
+ $collection = $quote->getItemsCollection(false);
57
+ }
58
+ else {
59
+ $collection = new Varien_Data_Collection();
60
+ }
61
+
62
+ $collection->addFieldToFilter('parent_item_id', array('null' => true));
63
+
64
+ $this->setCollection($collection);
65
+
66
+ return parent::_prepareCollection();
67
+ }
68
+
69
+ protected function _prepareColumns()
70
+ {
71
+ $this->addColumn('product_id', array(
72
+ 'header' => Mage::helper('catalog')->__('Product ID'),
73
+ 'index' => 'product_id',
74
+ 'width' => '100px',
75
+ ));
76
+
77
+ $this->addColumn('name', array(
78
+ 'header' => Mage::helper('catalog')->__('Product Name'),
79
+ 'index' => 'name',
80
+ 'renderer' => 'adminhtml/customer_edit_tab_view_grid_renderer_item'
81
+ ));
82
+
83
+ $this->addColumn('sku', array(
84
+ 'header' => Mage::helper('catalog')->__('SKU'),
85
+ 'index' => 'sku',
86
+ 'width' => '100px',
87
+ ));
88
+
89
+ $this->addColumn('qty', array(
90
+ 'header' => Mage::helper('catalog')->__('Qty'),
91
+ 'index' => 'qty',
92
+ 'type' => 'number',
93
+ 'width' => '60px',
94
+ ));
95
+
96
+ $this->addColumn('price', array(
97
+ 'header' => Mage::helper('catalog')->__('Price'),
98
+ 'index' => 'price',
99
+ 'type' => 'currency',
100
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
101
+ ));
102
+
103
+ $this->addColumn('total', array(
104
+ 'header' => Mage::helper('sales')->__('Total'),
105
+ 'index' => 'row_total',
106
+ 'type' => 'currency',
107
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
108
+ ));
109
+
110
+ $this->addColumn('action', array(
111
+ 'header' => Mage::helper('customer')->__('Action'),
112
+ 'index' => 'quote_item_id',
113
+ 'renderer' => 'adminhtml/customer_grid_renderer_multiaction',
114
+ 'filter' => false,
115
+ 'sortable' => false,
116
+ 'actions' => array(
117
+ array(
118
+ 'caption' => Mage::helper('customer')->__('Configure'),
119
+ 'url' => 'javascript:void(0)',
120
+ 'process' => 'configurable',
121
+ 'control_object' => $this->getJsObjectName() . 'cartControl'
122
+ ),
123
+ array(
124
+ 'caption' => Mage::helper('customer')->__('Delete'),
125
+ 'url' => '#',
126
+ 'onclick' => 'return ' . $this->getJsObjectName() . 'cartControl.removeItem($item_id);'
127
+ )
128
+ )
129
+ ));
130
+
131
+ return parent::_prepareColumns();
132
+ }
133
+
134
+ /**
135
+ * Gets customer assigned to this block
136
+ *
137
+ * @return Mage_Customer_Model_Customer
138
+ */
139
+ public function getCustomer() {
140
+ return Mage::registry('current_customer');
141
+ }
142
+
143
+ public function getGridUrl()
144
+ {
145
+ return $this->getUrl('*/*/cart', array('_current'=>true, 'website_id' => $this->getWebsiteId()));
146
+ }
147
+
148
+ public function getGridParentHtml()
149
+ {
150
+ $templateName = Mage::getDesign()->getTemplateFilename($this->_parentTemplate, array('_relative'=>true));
151
+ return $this->fetchView($templateName);
152
+ }
153
+
154
+ public function getRowUrl($row)
155
+ {
156
+ return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId()));
157
+ }
158
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Carts.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Obtain all carts contents for specified client
29
+ *
30
+ */
31
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Carts extends Mage_Adminhtml_Block_Template
32
+ {
33
+ /**
34
+ * Add shopping cart grid of each website
35
+ *
36
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Carts
37
+ */
38
+ protected function _prepareLayout()
39
+ {
40
+ $sharedWebsiteIds = Mage::registry('current_customer')->getSharedWebsiteIds();
41
+ $isShared = count($sharedWebsiteIds) > 1;
42
+ foreach ($sharedWebsiteIds as $websiteId) {
43
+ $blockName = 'customer_cart_' . $websiteId;
44
+ $block = $this->getLayout()->createBlock('adminhtml/customer_edit_tab_cart',
45
+ $blockName, array('website_id' => $websiteId));
46
+ if ($isShared) {
47
+ $block->setCartHeader($this->__('Shopping Cart from %s', Mage::app()->getWebsite($websiteId)->getName()));
48
+ }
49
+ $this->setChild($blockName, $block);
50
+ }
51
+ return parent::_prepareLayout();
52
+ }
53
+
54
+ /**
55
+ * Just get child blocks html
56
+ *
57
+ * @return string
58
+ */
59
+ protected function _toHtml()
60
+ {
61
+ Mage::dispatchEvent('adminhtml_block_html_before', array('block' => $this));
62
+ return $this->getChildHtml();
63
+ }
64
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer account form block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Newsletter extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setTemplate('customer/tab/newsletter.phtml');
41
+ }
42
+
43
+ public function initForm()
44
+ {
45
+ $form = new Varien_Data_Form();
46
+ $form->setHtmlIdPrefix('_newsletter');
47
+ $customer = Mage::registry('current_customer');
48
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
49
+ Mage::register('subscriber', $subscriber);
50
+
51
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('customer')->__('Newsletter Information')));
52
+
53
+ $fieldset->addField('subscription', 'checkbox',
54
+ array(
55
+ 'label' => Mage::helper('customer')->__('Subscribed to Newsletter?'),
56
+ 'name' => 'subscription'
57
+ )
58
+ );
59
+
60
+ if ($customer->isReadonly()) {
61
+ $form->getElement('subscription')->setReadonly(true, true);
62
+ }
63
+
64
+ $form->getElement('subscription')->setIsChecked($subscriber->isSubscribed());
65
+
66
+ if($changedDate = $this->getStatusChangedDate()) {
67
+ $fieldset->addField('change_status_date', 'label',
68
+ array(
69
+ 'label' => $subscriber->isSubscribed() ? Mage::helper('customer')->__('Last Date Subscribed') : Mage::helper('customer')->__('Last Date Unsubscribed'),
70
+ 'value' => $changedDate,
71
+ 'bold' => true
72
+ )
73
+ );
74
+ }
75
+
76
+
77
+ $this->setForm($form);
78
+ return $this;
79
+ }
80
+
81
+ public function getStatusChangedDate()
82
+ {
83
+ $subscriber = Mage::registry('subscriber');
84
+ if($subscriber->getChangeStatusAt()) {
85
+ return $this->formatDate($subscriber->getChangeStatusAt(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
86
+ }
87
+
88
+ return null;
89
+ }
90
+
91
+ protected function _prepareLayout()
92
+ {
93
+ $this->setChild('grid',
94
+ $this->getLayout()->createBlock('adminhtml/customer_edit_tab_newsletter_grid','newsletter.grid')
95
+ );
96
+ return parent::_prepareLayout();
97
+ }
98
+
99
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter queue grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Newsletter_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('queueGrid');
41
+ $this->setDefaultSort('start_at');
42
+ $this->setDefaultDir('desc');
43
+
44
+ $this->setUseAjax(true);
45
+
46
+ $this->setEmptyText(Mage::helper('customer')->__('No Newsletter Found'));
47
+
48
+ }
49
+
50
+ public function getGridUrl()
51
+ {
52
+ return $this->getUrl('*/*/newsletter', array('_current'=>true));
53
+ }
54
+
55
+ protected function _prepareCollection()
56
+ {
57
+ $collection = Mage::getResourceModel('newsletter/queue_collection')
58
+ ->addTemplateInfo()
59
+ ->addSubscriberFilter(Mage::registry('subscriber')->getId());
60
+
61
+ $this->setCollection($collection);
62
+
63
+ return parent::_prepareCollection();
64
+ }
65
+
66
+ protected function _prepareColumns()
67
+ {
68
+ $this->addColumn('queue_id', array(
69
+ 'header' => Mage::helper('customer')->__('ID'),
70
+ 'align' => 'left',
71
+ 'index' => 'queue_id',
72
+ 'width' => 10
73
+ ));
74
+
75
+ $this->addColumn('start_at', array(
76
+ 'header' => Mage::helper('customer')->__('Newsletter Start'),
77
+ 'type' => 'datetime',
78
+ 'align' => 'center',
79
+ 'index' => 'queue_start_at',
80
+ 'default' => ' ---- '
81
+ ));
82
+
83
+ $this->addColumn('finish_at', array(
84
+ 'header' => Mage::helper('customer')->__('Newsletter Finish'),
85
+ 'type' => 'datetime',
86
+ 'align' => 'center',
87
+ 'index' => 'queue_finish_at',
88
+ 'gmtoffset' => true,
89
+ 'default' => ' ---- '
90
+ ));
91
+
92
+ $this->addColumn('letter_sent_at', array(
93
+ 'header' => Mage::helper('customer')->__('Newsletter Received'),
94
+ 'type' => 'datetime',
95
+ 'align' => 'center',
96
+ 'index' => 'letter_sent_at',
97
+ 'gmtoffset' => true,
98
+ 'default' => ' ---- '
99
+ ));
100
+
101
+ $this->addColumn('template_subject', array(
102
+ 'header' => Mage::helper('customer')->__('Subject'),
103
+ 'align' => 'center',
104
+ 'index' => 'template_subject'
105
+ ));
106
+
107
+ $this->addColumn('status', array(
108
+ 'header' => Mage::helper('customer')->__('Status'),
109
+ 'align' => 'center',
110
+ 'filter' => 'adminhtml/customer_edit_tab_newsletter_grid_filter_status',
111
+ 'index' => 'queue_status',
112
+ 'renderer' => 'adminhtml/customer_edit_tab_newsletter_grid_renderer_status'
113
+ ));
114
+
115
+ $this->addColumn('action', array(
116
+ 'header' => Mage::helper('customer')->__('Action'),
117
+ 'align' => 'center',
118
+ 'filter' => false,
119
+ 'sortable' => false,
120
+ 'renderer' => 'adminhtml/customer_edit_tab_newsletter_grid_renderer_action'
121
+ ));
122
+
123
+ return parent::_prepareColumns();
124
+ }
125
+
126
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Filter/Status.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter subscribers grid website filter
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Newsletter_Grid_Filter_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
35
+ {
36
+
37
+ protected static $_statuses;
38
+
39
+ public function __construct()
40
+ {
41
+ self::$_statuses = array(
42
+ null => null,
43
+ Mage_Newsletter_Model_Queue::STATUS_SENT => Mage::helper('customer')->__('Sent'),
44
+ Mage_Newsletter_Model_Queue::STATUS_CANCEL => Mage::helper('customer')->__('Cancel'),
45
+ Mage_Newsletter_Model_Queue::STATUS_NEVER => Mage::helper('customer')->__('Not Sent'),
46
+ Mage_Newsletter_Model_Queue::STATUS_SENDING => Mage::helper('customer')->__('Sending'),
47
+ Mage_Newsletter_Model_Queue::STATUS_PAUSE => Mage::helper('customer')->__('Paused'),
48
+ );
49
+ parent::__construct();
50
+ }
51
+
52
+ protected function _getOptions()
53
+ {
54
+ $result = array();
55
+ foreach (self::$_statuses as $code=>$label) {
56
+ $result[] = array('value'=>$code, 'label'=>Mage::helper('customer')->__($label));
57
+ }
58
+
59
+ return $result;
60
+ }
61
+
62
+ public function getCondition()
63
+ {
64
+ if(is_null($this->getValue())) {
65
+ return null;
66
+ }
67
+
68
+ return array('eq'=>$this->getValue());
69
+ }
70
+
71
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Action.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter queue grid block action item renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Newsletter_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
35
+ {
36
+
37
+ public function render(Varien_Object $row)
38
+ {
39
+ $actions = array();
40
+
41
+ $actions[] = array(
42
+ '@' => array(
43
+ 'href' => $this->getUrl('*/newsletter_template/preview',
44
+ array(
45
+ 'id' => $row->getTemplateId(),
46
+ 'subscriber'=> Mage::registry('subscriber')->getId()
47
+ )
48
+ ),
49
+ 'target'=> '_blank'
50
+ ),
51
+ '#' => Mage::helper('customer')->__('View')
52
+ );
53
+
54
+ return $this->_actionsToHtml($actions);
55
+ }
56
+
57
+ protected function _getEscapedValue($value)
58
+ {
59
+ return addcslashes(htmlspecialchars($value),'\\\'');
60
+ }
61
+
62
+ protected function _actionsToHtml(array $actions)
63
+ {
64
+ $html = array();
65
+ $attributesObject = new Varien_Object();
66
+ foreach ($actions as $action) {
67
+ $attributesObject->setData($action['@']);
68
+ $html[] = '<a ' . $attributesObject->serialize() . '>' . $action['#'] . '</a>';
69
+ }
70
+ return implode('<span class="separator">&nbsp;|&nbsp;</span>', $html);
71
+ }
72
+
73
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid/Renderer/Status.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter queue grid block status item renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Newsletter_Grid_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
35
+ {
36
+
37
+ protected static $_statuses;
38
+
39
+ public function __construct()
40
+ {
41
+ self::$_statuses = array(
42
+ Mage_Newsletter_Model_Queue::STATUS_SENT => Mage::helper('customer')->__('Sent'),
43
+ Mage_Newsletter_Model_Queue::STATUS_CANCEL => Mage::helper('customer')->__('Cancel'),
44
+ Mage_Newsletter_Model_Queue::STATUS_NEVER => Mage::helper('customer')->__('Not Sent'),
45
+ Mage_Newsletter_Model_Queue::STATUS_SENDING => Mage::helper('customer')->__('Sending'),
46
+ Mage_Newsletter_Model_Queue::STATUS_PAUSE => Mage::helper('customer')->__('Paused'),
47
+ );
48
+ parent::__construct();
49
+ }
50
+
51
+ public function render(Varien_Object $row)
52
+ {
53
+ return Mage::helper('customer')->__($this->getStatus($row->getQueueStatus()));
54
+ }
55
+
56
+ public static function getStatus($status)
57
+ {
58
+ if(isset(self::$_statuses[$status])) {
59
+ return self::$_statuses[$status];
60
+ }
61
+
62
+ return Mage::helper('customer')->__('Unknown');
63
+ }
64
+
65
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Orders.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer orders grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Orders extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('customer_orders_grid');
41
+ $this->setDefaultSort('created_at', 'desc');
42
+ $this->setUseAjax(true);
43
+ }
44
+
45
+ protected function _prepareCollection()
46
+ {
47
+ $collection = Mage::getResourceModel('sales/order_grid_collection')
48
+ ->addFieldToSelect('entity_id')
49
+ ->addFieldToSelect('increment_id')
50
+ ->addFieldToSelect('customer_id')
51
+ ->addFieldToSelect('created_at')
52
+ ->addFieldToSelect('grand_total')
53
+ ->addFieldToSelect('order_currency_code')
54
+ ->addFieldToSelect('store_id')
55
+ ->addFieldToSelect('billing_name')
56
+ ->addFieldToSelect('shipping_name')
57
+ ->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
58
+ ->setIsCustomerMode(true);
59
+
60
+ $this->setCollection($collection);
61
+ return parent::_prepareCollection();
62
+ }
63
+
64
+ protected function _prepareColumns()
65
+ {
66
+ $this->addColumn('increment_id', array(
67
+ 'header' => Mage::helper('customer')->__('Order #'),
68
+ 'width' => '100',
69
+ 'index' => 'increment_id',
70
+ ));
71
+
72
+ $this->addColumn('created_at', array(
73
+ 'header' => Mage::helper('customer')->__('Purchase On'),
74
+ 'index' => 'created_at',
75
+ 'type' => 'datetime',
76
+ ));
77
+
78
+ /*$this->addColumn('shipping_firstname', array(
79
+ 'header' => Mage::helper('customer')->__('Shipped to First Name'),
80
+ 'index' => 'shipping_firstname',
81
+ ));
82
+
83
+ $this->addColumn('shipping_lastname', array(
84
+ 'header' => Mage::helper('customer')->__('Shipped to Last Name'),
85
+ 'index' => 'shipping_lastname',
86
+ ));*/
87
+ $this->addColumn('billing_name', array(
88
+ 'header' => Mage::helper('customer')->__('Bill to Name'),
89
+ 'index' => 'billing_name',
90
+ ));
91
+
92
+ $this->addColumn('shipping_name', array(
93
+ 'header' => Mage::helper('customer')->__('Shipped to Name'),
94
+ 'index' => 'shipping_name',
95
+ ));
96
+
97
+ $this->addColumn('grand_total', array(
98
+ 'header' => Mage::helper('customer')->__('Order Total'),
99
+ 'index' => 'grand_total',
100
+ 'type' => 'currency',
101
+ 'currency' => 'order_currency_code',
102
+ ));
103
+
104
+ if (!Mage::app()->isSingleStoreMode()) {
105
+ $this->addColumn('store_id', array(
106
+ 'header' => Mage::helper('customer')->__('Bought From'),
107
+ 'index' => 'store_id',
108
+ 'type' => 'store',
109
+ 'store_view' => true
110
+ ));
111
+ }
112
+
113
+ if (Mage::helper('sales/reorder')->isAllow()) {
114
+ $this->addColumn('action', array(
115
+ 'header' => ' ',
116
+ 'filter' => false,
117
+ 'sortable' => false,
118
+ 'width' => '100px',
119
+ 'renderer' => 'adminhtml/sales_reorder_renderer_action'
120
+ ));
121
+ }
122
+
123
+ return parent::_prepareColumns();
124
+ }
125
+
126
+ public function getRowUrl($row)
127
+ {
128
+ return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
129
+ }
130
+
131
+ public function getGridUrl()
132
+ {
133
+ return $this->getUrl('*/*/orders', array('_current' => true));
134
+ }
135
+
136
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Reviews.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer orders grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Reviews extends Mage_Adminhtml_Block_Review_Grid
35
+ {
36
+ /**
37
+ * Hide grid mass action elements
38
+ *
39
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Reviews
40
+ */
41
+ protected function _prepareMassaction()
42
+ {
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Determine ajax url for grid refresh
48
+ *
49
+ * @return string
50
+ */
51
+ public function getGridUrl()
52
+ {
53
+ return $this->getUrl('*/*/productReviews', array('_current' => true));
54
+ }
55
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Tag.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer's tags grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Tag extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('tag_grid');
41
+ $this->setDefaultSort('name');
42
+ $this->setDefaultDir('ASC');
43
+ $this->setUseAjax(true);
44
+ $this->setFilterVisibility(false);
45
+ }
46
+
47
+ protected function _prepareCollection()
48
+ {
49
+ $tagId = Mage::registry('tagId');
50
+
51
+ if( $this->getCustomerId() instanceof Mage_Customer_Model_Customer ) {
52
+ $this->setCustomerId( $this->getCustomerId()->getId() );
53
+ }
54
+
55
+ $collection = Mage::getResourceModel('tag/customer_collection')
56
+ ->addCustomerFilter($this->getCustomerId())
57
+ ->addGroupByTag();
58
+
59
+ $this->setCollection($collection);
60
+ return parent::_prepareCollection();
61
+ }
62
+
63
+ protected function _afterLoadCollection()
64
+ {
65
+ $this->getCollection()->addProductName();
66
+ return parent::_afterLoadCollection();
67
+ }
68
+
69
+ protected function _prepareColumns()
70
+ {
71
+ $this->addColumn('name', array(
72
+ 'header' => Mage::helper('customer')->__('Tag Name'),
73
+ 'index' => 'name',
74
+ ));
75
+
76
+ $this->addColumn('status', array(
77
+ 'header' => Mage::helper('customer')->__('Status'),
78
+ 'width' => '90px',
79
+ 'index' => 'status',
80
+ 'type' => 'options',
81
+ 'options' => array(
82
+ Mage_Tag_Model_Tag::STATUS_DISABLED => Mage::helper('customer')->__('Disabled'),
83
+ Mage_Tag_Model_Tag::STATUS_PENDING => Mage::helper('customer')->__('Pending'),
84
+ Mage_Tag_Model_Tag::STATUS_APPROVED => Mage::helper('customer')->__('Approved'),
85
+ ),
86
+ 'filter' => false,
87
+ ));
88
+
89
+ $this->addColumn('product', array(
90
+ 'header' => Mage::helper('customer')->__('Product Name'),
91
+ 'index' => 'product',
92
+ 'filter' => false,
93
+ 'sortable' => false,
94
+ ));
95
+
96
+ $this->addColumn('product_sku', array(
97
+ 'header' => Mage::helper('customer')->__('SKU'),
98
+ 'index' => 'product_sku',
99
+ 'filter' => false,
100
+ 'sortable' => false,
101
+ ));
102
+
103
+ return parent::_prepareColumns();
104
+ }
105
+
106
+ public function getRowUrl($row)
107
+ {
108
+ return $this->getUrl('*/tag/edit', array(
109
+ 'tag_id' => $row->getTagId(),
110
+ 'customer_id' => $this->getCustomerId(),
111
+ ));
112
+ }
113
+
114
+ public function getGridUrl()
115
+ {
116
+ return $this->getUrl('*/customer/tagGrid', array(
117
+ '_current' => true,
118
+ 'id' => $this->getCustomerId()
119
+ ));
120
+ }
121
+
122
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Tags.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer orders grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Tags extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('ordersGrid');
41
+ $this->setUseAjax(true);
42
+ }
43
+
44
+ protected function _prepareCollection()
45
+ {
46
+ $collection = Mage::getResourceModel('customer/customer_collection')
47
+ ->addNameToSelect()
48
+ ->addAttributeToSelect('email')
49
+ ->addAttributeToSelect('created_at')
50
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing')
51
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing')
52
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing')
53
+ ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing');
54
+
55
+ $this->setCollection($collection);
56
+
57
+ return parent::_prepareCollection();
58
+ }
59
+
60
+ protected function _prepareColumns()
61
+ {
62
+ $this->addColumn('entity_id', array(
63
+ 'header' => Mage::helper('customer')->__('ID'),
64
+ 'width' =>5,
65
+ 'align' =>'center',
66
+ 'sortable' =>true,
67
+ 'index' =>'entity_id'
68
+ ));
69
+ $this->addColumn('name', array(
70
+ 'header' => Mage::helper('customer')->__('Name'),
71
+ 'index' =>'name'
72
+ ));
73
+ $this->addColumn('email', array(
74
+ 'header' => Mage::helper('customer')->__('Email'),
75
+ 'width' =>40,
76
+ 'align' =>'center',
77
+ 'index' =>'email'
78
+ ));
79
+ $this->addColumn('telephone', array(
80
+ 'header' => Mage::helper('customer')->__('Telephone'),
81
+ 'align' =>'center',
82
+ 'index' =>'billing_telephone'
83
+ ));
84
+ $this->addColumn('billing_postcode', array(
85
+ 'header' => Mage::helper('customer')->__('ZIP/Post Code'),
86
+ 'index' =>'billing_postcode',
87
+ ));
88
+ $this->addColumn('billing_country_id', array(
89
+ 'header' => Mage::helper('customer')->__('Country'),
90
+ 'type' => 'country',
91
+ 'index' => 'billing_country_id',
92
+ ));
93
+ $this->addColumn('customer_since', array(
94
+ 'header' => Mage::helper('customer')->__('Customer Since'),
95
+ 'type' => 'date',
96
+ 'format' => 'Y.m.d',
97
+ 'index' =>'created_at',
98
+ ));
99
+ $this->addColumn('action', array(
100
+ 'header' => Mage::helper('customer')->__('Action'),
101
+ 'align' =>'center',
102
+ 'format' =>'<a href="'.$this->getUrl('*/sales/edit/id/$entity_id').'">'.Mage::helper('customer')->__('Edit').'</a>',
103
+ 'filter' =>false,
104
+ 'sortable' =>false,
105
+ 'is_system' =>true
106
+ ));
107
+
108
+ $this->setColumnFilter('entity_id')
109
+ ->setColumnFilter('email')
110
+ ->setColumnFilter('name');
111
+
112
+ $this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
113
+ $this->addExportType('*/*/exportXml', Mage::helper('customer')->__('Excel XML'));
114
+ return parent::_prepareColumns();
115
+ }
116
+
117
+ public function getGridUrl()
118
+ {
119
+ return $this->getUrl('*/*/index', array('_current'=>true));
120
+ }
121
+
122
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer account form block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_View
35
+ extends Mage_Adminhtml_Block_Template
36
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
37
+ {
38
+
39
+ protected $_customer;
40
+
41
+ protected $_customerLog;
42
+
43
+ public function getCustomer()
44
+ {
45
+ if (!$this->_customer) {
46
+ $this->_customer = Mage::registry('current_customer');
47
+ }
48
+ return $this->_customer;
49
+ }
50
+
51
+ public function getGroupName()
52
+ {
53
+ if ($groupId = $this->getCustomer()->getGroupId()) {
54
+ return Mage::getModel('customer/group')
55
+ ->load($groupId)
56
+ ->getCustomerGroupCode();
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Load Customer Log model
62
+ *
63
+ * @return Mage_Log_Model_Customer
64
+ */
65
+ public function getCustomerLog()
66
+ {
67
+ if (!$this->_customerLog) {
68
+ $this->_customerLog = Mage::getModel('log/customer')
69
+ ->loadByCustomer($this->getCustomer()->getId());
70
+ }
71
+ return $this->_customerLog;
72
+ }
73
+
74
+ public function getCreateDate()
75
+ {
76
+ $date = Mage::app()->getLocale()->date($this->getCustomer()->getCreatedAtTimestamp());
77
+ return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
78
+ }
79
+
80
+ public function getStoreCreateDate()
81
+ {
82
+ $date = Mage::app()->getLocale()->storeDate(
83
+ $this->getCustomer()->getStoreId(),
84
+ $this->getCustomer()->getCreatedAtTimestamp(),
85
+ true
86
+ );
87
+ return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
88
+ }
89
+
90
+ public function getStoreCreateDateTimezone()
91
+ {
92
+ return Mage::app()->getStore($this->getCustomer()->getStoreId())
93
+ ->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
94
+ }
95
+
96
+ public function getLastLoginDate()
97
+ {
98
+ if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
99
+ $date = Mage::app()->getLocale()->date($date);
100
+ return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
101
+ }
102
+ return Mage::helper('customer')->__('Never');
103
+ }
104
+
105
+ public function getStoreLastLoginDate()
106
+ {
107
+ if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
108
+ $date = Mage::app()->getLocale()->storeDate(
109
+ $this->getCustomer()->getStoreId(),
110
+ $date,
111
+ true
112
+ );
113
+ return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
114
+ }
115
+ return Mage::helper('customer')->__('Never');
116
+ }
117
+
118
+ public function getStoreLastLoginDateTimezone()
119
+ {
120
+ return Mage::app()->getStore($this->getCustomer()->getStoreId())
121
+ ->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
122
+ }
123
+
124
+ public function getCurrentStatus()
125
+ {
126
+ $log = $this->getCustomerLog();
127
+ if ($log->getLogoutAt() ||
128
+ strtotime(now())-strtotime($log->getLastVisitAt())>Mage_Log_Model_Visitor::getOnlineMinutesInterval()*60) {
129
+ return Mage::helper('customer')->__('Offline');
130
+ }
131
+ return Mage::helper('customer')->__('Online');
132
+ }
133
+
134
+ public function getIsConfirmedStatus()
135
+ {
136
+ $this->getCustomer();
137
+ if (!$this->_customer->getConfirmation()) {
138
+ return Mage::helper('customer')->__('Confirmed');
139
+ }
140
+ if ($this->_customer->isConfirmationRequired()) {
141
+ return Mage::helper('customer')->__('Not confirmed, cannot login');
142
+ }
143
+ return Mage::helper('customer')->__('Not confirmed, can login');
144
+ }
145
+
146
+ public function getCreatedInStore()
147
+ {
148
+ return Mage::app()->getStore($this->getCustomer()->getStoreId())->getName();
149
+ }
150
+
151
+ public function getStoreId()
152
+ {
153
+ return $this->getCustomer()->getStoreId();
154
+ }
155
+
156
+ public function getBillingAddressHtml()
157
+ {
158
+ $html = '';
159
+ if ($address = $this->getCustomer()->getPrimaryBillingAddress()) {
160
+ $html = $address->format('html');
161
+ }
162
+ else {
163
+ $html = Mage::helper('customer')->__('The customer does not have default billing address.');
164
+ }
165
+ return $html;
166
+ }
167
+
168
+ public function getAccordionHtml()
169
+ {
170
+ return $this->getChildHtml('accordion');
171
+ }
172
+
173
+ public function getSalesHtml()
174
+ {
175
+ return $this->getChildHtml('sales');
176
+ }
177
+
178
+ public function getTabLabel()
179
+ {
180
+ return Mage::helper('customer')->__('Customer View');
181
+ }
182
+
183
+ public function getTabTitle()
184
+ {
185
+ return Mage::helper('customer')->__('Customer View');
186
+ }
187
+
188
+ public function canShowTab()
189
+ {
190
+ if (Mage::registry('current_customer')->getId()) {
191
+ return true;
192
+ }
193
+ return false;
194
+ }
195
+
196
+ public function isHidden()
197
+ {
198
+ if (Mage::registry('current_customer')->getId()) {
199
+ return false;
200
+ }
201
+ return true;
202
+ }
203
+
204
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer recent orders grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Accordion extends Mage_Adminhtml_Block_Widget_Accordion
35
+ {
36
+ protected function _prepareLayout()
37
+ {
38
+ $customer = Mage::registry('current_customer');
39
+
40
+ $this->setId('customerViewAccordion');
41
+
42
+ $this->addItem('lastOrders', array(
43
+ 'title' => Mage::helper('customer')->__('Recent Orders'),
44
+ 'ajax' => true,
45
+ 'content_url' => $this->getUrl('*/*/lastOrders', array('_current' => true)),
46
+ ));
47
+
48
+ // add shopping cart block of each website
49
+ foreach (Mage::registry('current_customer')->getSharedWebsiteIds() as $websiteId) {
50
+ $website = Mage::app()->getWebsite($websiteId);
51
+
52
+ // count cart items
53
+ $cartItemsCount = Mage::getModel('sales/quote')
54
+ ->setWebsite($website)->loadByCustomer($customer)
55
+ ->getItemsCollection(false)
56
+ ->addFieldToFilter('parent_item_id', array('null' => true))
57
+ ->getSize();
58
+ // prepare title for cart
59
+ $title = Mage::helper('customer')->__('Shopping Cart - %d item(s)', $cartItemsCount);
60
+ if (count($customer->getSharedWebsiteIds()) > 1) {
61
+ $title = Mage::helper('customer')->__('Shopping Cart of %1$s - %2$d item(s)',
62
+ $website->getName(), $cartItemsCount
63
+ );
64
+ }
65
+
66
+ // add cart ajax accordion
67
+ $this->addItem('shopingCart' . $websiteId, array(
68
+ 'title' => $title,
69
+ 'ajax' => true,
70
+ 'content_url' => $this->getUrl('*/*/viewCart', array('_current' => true, 'website_id' => $websiteId)),
71
+ ));
72
+ }
73
+
74
+ // count wishlist items
75
+ $wishlist = Mage::getModel('wishlist/wishlist');
76
+ $wishlistCount = $wishlist->loadByCustomer($customer)
77
+ ->setSharedStoreIds($wishlist->getSharedStoreIds(false))
78
+ ->getItemCollection()
79
+ ->addStoreData()
80
+ ->getSize();
81
+ // add wishlist ajax accordion
82
+ $this->addItem('wishlist', array(
83
+ 'title' => Mage::helper('customer')->__('Wishlist - %d item(s)', $wishlistCount),
84
+ 'ajax' => true,
85
+ 'content_url' => $this->getUrl('*/*/viewWishlist', array('_current' => true)),
86
+ ));
87
+ }
88
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer cart items grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Cart extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('customer_view_cart_grid');
41
+ $this->setDefaultSort('added_at', 'desc');
42
+ $this->setSortable(false);
43
+ $this->setPagerVisibility(false);
44
+ $this->setFilterVisibility(false);
45
+ $this->setEmptyText(Mage::helper('customer')->__('There are no items in customer\'s shopping cart at the moment'));
46
+ }
47
+
48
+ protected function _prepareCollection()
49
+ {
50
+ $quote = Mage::getModel('sales/quote');
51
+ // set website to quote, if any
52
+ if ($this->getWebsiteId()) {
53
+ $quote->setWebsite(Mage::app()->getWebsite($this->getWebsiteId()));
54
+ }
55
+ $quote->loadByCustomer(Mage::registry('current_customer'));
56
+
57
+ if ($quote) {
58
+ $collection = $quote->getItemsCollection(false);
59
+ }
60
+ else {
61
+ $collection = new Varien_Data_Collection();
62
+ }
63
+
64
+ $collection->addFieldToFilter('parent_item_id', array('null' => true));
65
+ $this->setCollection($collection);
66
+
67
+ return parent::_prepareCollection();
68
+ }
69
+
70
+ protected function _prepareColumns()
71
+ {
72
+ $this->addColumn('product_id', array(
73
+ 'header' => Mage::helper('customer')->__('Product ID'),
74
+ 'index' => 'product_id',
75
+ 'width' => '100px',
76
+ ));
77
+
78
+ $this->addColumn('name', array(
79
+ 'header' => Mage::helper('customer')->__('Product Name'),
80
+ 'index' => 'name',
81
+ ));
82
+
83
+ $this->addColumn('sku', array(
84
+ 'header' => Mage::helper('customer')->__('SKU'),
85
+ 'index' => 'sku',
86
+ 'width' => '100px',
87
+ ));
88
+
89
+ $this->addColumn('qty', array(
90
+ 'header' => Mage::helper('customer')->__('Qty'),
91
+ 'index' => 'qty',
92
+ 'type' => 'number',
93
+ 'width' => '60px',
94
+ ));
95
+
96
+ $this->addColumn('price', array(
97
+ 'header' => Mage::helper('customer')->__('Price'),
98
+ 'index' => 'price',
99
+ 'type' => 'currency',
100
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
101
+ ));
102
+
103
+ $this->addColumn('total', array(
104
+ 'header' => Mage::helper('customer')->__('Total'),
105
+ 'index' => 'row_total',
106
+ 'type' => 'currency',
107
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
108
+ ));
109
+
110
+ return parent::_prepareColumns();
111
+ }
112
+
113
+ public function getRowUrl($row)
114
+ {
115
+ return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId()));
116
+ }
117
+
118
+ public function getHeadersVisibility()
119
+ {
120
+ return ($this->getCollection()->getSize() > 0);
121
+ }
122
+
123
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers wishlist grid item renderer for name/options cell
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Grid_Renderer_Item extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
35
+ {
36
+ /**
37
+ * Constructor to set default template
38
+ *
39
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_View_Grid_Renderer_Item
40
+ */
41
+ protected function _construct()
42
+ {
43
+ parent::_construct();
44
+ $this->setTemplate('customer/edit/tab/view/grid/item.phtml');
45
+ return $this;
46
+ }
47
+
48
+ /**
49
+ * Returns helper for product type
50
+ *
51
+ * @param Mage_Catalog_Model_Product $product
52
+ * @return Mage_Catalog_Helper_Product_Configuration_Interface
53
+ */
54
+ protected function _getProductHelper($product)
55
+ {
56
+ // Retrieve whole array of renderers
57
+ $productHelpers = $this->getProductHelpers();
58
+ if (!is_array($productHelpers)) {
59
+ $column = $this->getColumn();
60
+ if ($column) {
61
+ $grid = $column->getGrid();
62
+ if ($grid) {
63
+ $productHelpers = $grid->getProductConfigurationHelpers();
64
+ $this->setProductHelpers($productHelpers ? $productHelpers : array());
65
+ }
66
+ }
67
+ }
68
+
69
+ // Check whether we have helper for our product
70
+ $productType = $product->getTypeId();
71
+ if (isset($productHelpers[$productType])) {
72
+ $helperName = $productHelpers[$productType];
73
+ } else if (isset($productHelpers['default'])) {
74
+ $helperName = $productHelpers['default'];
75
+ } else {
76
+ $helperName = 'catalog/product_configuration';
77
+ }
78
+
79
+ $helper = Mage::helper($helperName);
80
+ if (!($helper instanceof Mage_Catalog_Helper_Product_Configuration_Interface)) {
81
+ Mage::throwException($this->__("Helper for options rendering doesn't implement required interface."));
82
+ }
83
+
84
+ return $helper;
85
+ }
86
+
87
+ /*
88
+ * Returns product associated with this block
89
+ *
90
+ * @param Mage_Catalog_Model_Product $product
91
+ * @return string
92
+ */
93
+ public function getProduct()
94
+ {
95
+ return $this->getItem()->getProduct();
96
+ }
97
+
98
+ /**
99
+ * Returns list of options and their values for product configuration
100
+ *
101
+ * @return array
102
+ */
103
+ protected function getOptionList()
104
+ {
105
+ $item = $this->getItem();
106
+ $product = $item->getProduct();
107
+ $helper = $this->_getProductHelper($product);
108
+ return $helper->getOptions($item);
109
+ }
110
+
111
+ /**
112
+ * Returns formatted option value for an item
113
+ *
114
+ * @param Mage_Wishlist_Item_Option
115
+ * @return array
116
+ */
117
+ protected function getFormattedOptionValue($option)
118
+ {
119
+ $params = array(
120
+ 'max_length' => 55
121
+ );
122
+ return Mage::helper('catalog/product_configuration')->getFormattedOptionValue($option, $params);
123
+ }
124
+
125
+ /*
126
+ * Renders item product name and its configuration
127
+ *
128
+ * @param Mage_Catalog_Model_Product_Configuration_Item_Interface $item
129
+ * @return string
130
+ */
131
+ public function render(Varien_Object $item)
132
+ {
133
+ $this->setItem($item);
134
+ return $this->toHtml();
135
+ }
136
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer recent orders grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Orders extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('customer_view_orders_grid');
41
+ $this->setDefaultSort('created_at', 'desc');
42
+ $this->setSortable(false);
43
+ $this->setPagerVisibility(false);
44
+ $this->setFilterVisibility(false);
45
+ }
46
+
47
+ protected function _preparePage()
48
+ {
49
+ $this->getCollection()
50
+ ->setPageSize(5)
51
+ ->setCurPage(1);
52
+ }
53
+
54
+ protected function _prepareCollection()
55
+ {
56
+ $collection = Mage::getResourceModel('sales/order_grid_collection')
57
+ ->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
58
+ ->setIsCustomerMode(true);
59
+ $this->setCollection($collection);
60
+ return parent::_prepareCollection();
61
+ }
62
+
63
+ protected function _prepareColumns()
64
+ {
65
+
66
+ $this->addColumn('increment_id', array(
67
+ 'header' => Mage::helper('customer')->__('Order #'),
68
+ 'align' => 'center',
69
+ 'index' => 'increment_id',
70
+ 'width' => '100px',
71
+ ));
72
+
73
+ $this->addColumn('created_at', array(
74
+ 'header' => Mage::helper('customer')->__('Purchased At'),
75
+ 'index' => 'created_at',
76
+ 'type' => 'datetime',
77
+ ));
78
+
79
+ $this->addColumn('billing_name', array(
80
+ 'header' => Mage::helper('customer')->__('Bill to Name'),
81
+ 'index' => 'billing_name',
82
+ ));
83
+
84
+ $this->addColumn('shipping_name', array(
85
+ 'header' => Mage::helper('customer')->__('Shipped to Name'),
86
+ 'index' => 'shipping_name',
87
+ ));
88
+
89
+ $this->addColumn('grand_total', array(
90
+ 'header' => Mage::helper('customer')->__('Grand Total'),
91
+ 'index' => 'grand_total',
92
+ 'type' => 'currency',
93
+ 'currency' => 'order_currency_code',
94
+ ));
95
+
96
+ if (!Mage::app()->isSingleStoreMode()) {
97
+ $this->addColumn('store_id', array(
98
+ 'header' => Mage::helper('customer')->__('Bought From'),
99
+ 'index' => 'store_id',
100
+ 'type' => 'store',
101
+ 'store_view' => true,
102
+ ));
103
+ }
104
+
105
+ $this->addColumn('action', array(
106
+ 'header' => ' ',
107
+ 'filter' => false,
108
+ 'sortable' => false,
109
+ 'width' => '100px',
110
+ 'renderer' => 'adminhtml/sales_reorder_renderer_action'
111
+ ));
112
+
113
+ return parent::_prepareColumns();
114
+ }
115
+
116
+ public function getRowUrl($row)
117
+ {
118
+ return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
119
+ }
120
+
121
+ public function getHeadersVisibility()
122
+ {
123
+ return ($this->getCollection()->getSize() > 0);
124
+ }
125
+
126
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Sales.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer view wishlist block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Sales extends Mage_Adminhtml_Block_Template
35
+ {
36
+
37
+ /**
38
+ * Sales entity collection
39
+ *
40
+ * @var Mage_Sales_Model_Entity_Sale_Collection
41
+ */
42
+ protected $_collection;
43
+
44
+ protected $_groupedCollection;
45
+ protected $_websiteCounts;
46
+
47
+ /**
48
+ * Currency model
49
+ *
50
+ * @var Mage_Directory_Model_Currency
51
+ */
52
+ protected $_currency;
53
+
54
+ public function __construct()
55
+ {
56
+ parent::__construct();
57
+ $this->setId('customer_view_sales_grid');
58
+ }
59
+
60
+ public function _beforeToHtml()
61
+ {
62
+ $this->_currency = Mage::getModel('directory/currency')
63
+ ->load(Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE))
64
+ ;
65
+
66
+ $this->_collection = Mage::getResourceModel('sales/sale_collection')
67
+ ->setCustomerFilter(Mage::registry('current_customer'))
68
+ ->setOrderStateFilter(Mage_Sales_Model_Order::STATE_CANCELED, true)
69
+ ->load()
70
+ ;
71
+
72
+ $this->_groupedCollection = array();
73
+
74
+ foreach ($this->_collection as $sale) {
75
+ if (!is_null($sale->getStoreId())) {
76
+ $store = Mage::app()->getStore($sale->getStoreId());
77
+ $websiteId = $store->getWebsiteId();
78
+ $groupId = $store->getGroupId();
79
+ $storeId = $store->getId();
80
+
81
+ $sale->setWebsiteId($store->getWebsiteId());
82
+ $sale->setWebsiteName($store->getWebsite()->getName());
83
+ $sale->setGroupId($store->getGroupId());
84
+ $sale->setGroupName($store->getGroup()->getName());
85
+ }
86
+ else {
87
+ $websiteId = 0;
88
+ $groupId = 0;
89
+ $storeId = 0;
90
+
91
+ $sale->setStoreName(Mage::helper('customer')->__('Deleted Stores'));
92
+ }
93
+
94
+ $this->_groupedCollection[$websiteId][$groupId][$storeId] = $sale;
95
+ $this->_websiteCounts[$websiteId] = isset($this->_websiteCounts[$websiteId]) ? $this->_websiteCounts[$websiteId] + 1 : 1;
96
+ }
97
+
98
+ return parent::_beforeToHtml();
99
+ }
100
+
101
+ public function getWebsiteCount($websiteId)
102
+ {
103
+ return isset($this->_websiteCounts[$websiteId]) ? $this->_websiteCounts[$websiteId] : 0;
104
+ }
105
+
106
+ public function getRows()
107
+ {
108
+ return $this->_groupedCollection;
109
+ }
110
+
111
+ public function getTotals()
112
+ {
113
+ return $this->_collection->getTotals();
114
+ }
115
+
116
+ /**
117
+ * @deprecated after 1.4.0.0-rc1
118
+ *
119
+ * @param float $price
120
+ * @return string
121
+ */
122
+ public function getPriceFormatted($price)
123
+ {
124
+ return $this->_currency->format($price);
125
+ }
126
+
127
+ /**
128
+ * Format price by specified website
129
+ *
130
+ * @param float $price
131
+ * @param null|int $websiteId
132
+ * @return string
133
+ */
134
+ public function formatCurrency($price, $websiteId = null)
135
+ {
136
+ return Mage::app()->getWebsite($websiteId)->getBaseCurrency()->format($price);
137
+ }
138
+
139
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer view wishlist block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Wishlist extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ /**
37
+ * Initial settings
38
+ *
39
+ * @return void
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ $this->setId('customer_view_wishlist_grid');
45
+ $this->setSortable(false);
46
+ $this->setPagerVisibility(false);
47
+ $this->setFilterVisibility(false);
48
+ $this->setEmptyText(Mage::helper('customer')->__("There are no items in customer's wishlist at the moment"));
49
+ }
50
+
51
+ /**
52
+ * Prepare collection
53
+ *
54
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_View_Wishlist
55
+ */
56
+ protected function _prepareCollection()
57
+ {
58
+ $wishlist = Mage::getModel('wishlist/wishlist');
59
+ $collection = $wishlist->loadByCustomer(Mage::registry('current_customer'))
60
+ ->setSharedStoreIds($wishlist->getSharedStoreIds(false))
61
+ ->getItemCollection()
62
+ ->addDaysInWishlist(true)
63
+ ->addStoreData()
64
+ ->setInStockFilter(true);
65
+
66
+ $this->setCollection($collection);
67
+
68
+ return parent::_prepareCollection();
69
+ }
70
+
71
+ /**
72
+ * Prepare columns
73
+ *
74
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_View_Wishlist
75
+ */
76
+ protected function _prepareColumns()
77
+ {
78
+ $this->addColumn('product_id', array(
79
+ 'header' => Mage::helper('customer')->__('Product ID'),
80
+ 'index' => 'product_id',
81
+ 'type' => 'number',
82
+ 'width' => '100px'
83
+ ));
84
+
85
+ $this->addColumn('product_name', array(
86
+ 'header' => Mage::helper('customer')->__('Product Name'),
87
+ 'index' => 'product_name',
88
+ 'renderer' => 'adminhtml/customer_edit_tab_view_grid_renderer_item'
89
+ ));
90
+
91
+ if (!Mage::app()->isSingleStoreMode()) {
92
+ $this->addColumn('store', array(
93
+ 'header' => Mage::helper('customer')->__('Added From'),
94
+ 'index' => 'store_id',
95
+ 'type' => 'store',
96
+ 'width' => '160px',
97
+ ));
98
+ }
99
+
100
+ $this->addColumn('added_at', array(
101
+ 'header' => Mage::helper('customer')->__('Date Added'),
102
+ 'index' => 'added_at',
103
+ 'type' => 'date',
104
+ 'width' => '140px',
105
+ ));
106
+
107
+ $this->addColumn('days', array(
108
+ 'header' => Mage::helper('customer')->__('Days in Wishlist'),
109
+ 'index' => 'days_in_wishlist',
110
+ 'type' => 'number',
111
+ 'width' => '140px',
112
+ ));
113
+
114
+ return parent::_prepareColumns();
115
+ }
116
+
117
+ /**
118
+ * Get headers visibility
119
+ *
120
+ * @return bool
121
+ */
122
+ public function getHeadersVisibility()
123
+ {
124
+ return ($this->getCollection()->getSize() > 0);
125
+ }
126
+
127
+ /**
128
+ * Get row url
129
+ *
130
+ * @param Mage_Wishlist_Model_Item $item
131
+ * @return string
132
+ */
133
+ public function getRowUrl($row)
134
+ {
135
+ return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId()));
136
+ }
137
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml customer orders grid block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ /**
38
+ * Default sort field
39
+ *
40
+ * @var string
41
+ */
42
+
43
+ protected $_defaultSort = 'added_at';
44
+ /**
45
+ * Parent template name
46
+ *
47
+ * @var string
48
+ */
49
+ protected $_parentTemplate;
50
+
51
+ /**
52
+ * List of helpers to show options for product cells
53
+ */
54
+ protected $_productHelpers = array();
55
+
56
+ /**
57
+ * Initialize Grid
58
+ *
59
+ */
60
+ public function __construct()
61
+ {
62
+ parent::__construct();
63
+ $this->setId('wishlistGrid');
64
+ $this->setUseAjax(true);
65
+ $this->_parentTemplate = $this->getTemplate();
66
+ $this->setTemplate('customer/tab/wishlist.phtml');
67
+ $this->setEmptyText(Mage::helper('customer')->__('No Items Found'));
68
+ $this->addProductConfigurationHelper('default', 'catalog/product_configuration');
69
+ }
70
+
71
+ /**
72
+ * Retrieve current customer object
73
+ *
74
+ * @return Mage_Customer_Model_Customer
75
+ */
76
+ protected function _getCustomer()
77
+ {
78
+ return Mage::registry('current_customer');
79
+ }
80
+
81
+ /**
82
+ * Prepare customer wishlist product collection
83
+ *
84
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist
85
+ */
86
+ protected function _prepareCollection()
87
+ {
88
+ $wishlist = Mage::getModel('wishlist/wishlist');
89
+ $collection = $wishlist->loadByCustomer($this->_getCustomer())
90
+ ->setSharedStoreIds($wishlist->getSharedStoreIds(false))
91
+ ->getItemCollection()
92
+ ->resetSortOrder()
93
+ ->addDaysInWishlist()
94
+ ->addStoreData();
95
+
96
+ $this->setCollection($collection);
97
+
98
+ return parent::_prepareCollection();
99
+ }
100
+
101
+ /**
102
+ * Prepare Grid columns
103
+ *
104
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist
105
+ */
106
+ protected function _prepareColumns()
107
+ {
108
+ $this->addColumn('product_name', array(
109
+ 'header' => Mage::helper('catalog')->__('Product name'),
110
+ 'index' => 'product_name',
111
+ 'renderer' => 'adminhtml/customer_edit_tab_view_grid_renderer_item'
112
+ ));
113
+
114
+ $this->addColumn('description', array(
115
+ 'header' => Mage::helper('wishlist')->__('User description'),
116
+ 'index' => 'description',
117
+ 'renderer' => 'adminhtml/customer_edit_tab_wishlist_grid_renderer_description'
118
+ ));
119
+
120
+ $this->addColumn('qty', array(
121
+ 'header' => Mage::helper('catalog')->__('Qty'),
122
+ 'index' => 'qty',
123
+ 'type' => 'number',
124
+ 'width' => '60px'
125
+ ));
126
+
127
+ if (!Mage::app()->isSingleStoreMode()) {
128
+ $this->addColumn('store', array(
129
+ 'header' => Mage::helper('wishlist')->__('Added From'),
130
+ 'index' => 'store_id',
131
+ 'type' => 'store',
132
+ 'width' => '160px'
133
+ ));
134
+ }
135
+
136
+ $this->addColumn('added_at', array(
137
+ 'header' => Mage::helper('wishlist')->__('Date Added'),
138
+ 'index' => 'added_at',
139
+ 'gmtoffset' => true,
140
+ 'type' => 'date'
141
+ ));
142
+
143
+ $this->addColumn('days', array(
144
+ 'header' => Mage::helper('wishlist')->__('Days in Wishlist'),
145
+ 'index' => 'days_in_wishlist',
146
+ 'type' => 'number'
147
+ ));
148
+
149
+ $this->addColumn('action', array(
150
+ 'header' => Mage::helper('customer')->__('Action'),
151
+ 'index' => 'wishlist_item_id',
152
+ 'renderer' => 'adminhtml/customer_grid_renderer_multiaction',
153
+ 'filter' => false,
154
+ 'sortable' => false,
155
+ 'actions' => array(
156
+ array(
157
+ 'caption' => Mage::helper('customer')->__('Configure'),
158
+ 'url' => 'javascript:void(0)',
159
+ 'process' => 'configurable',
160
+ 'control_object' => 'wishlistControl'
161
+ ),
162
+ array(
163
+ 'caption' => Mage::helper('customer')->__('Delete'),
164
+ 'url' => '#',
165
+ 'onclick' => 'return wishlistControl.removeItem($wishlist_item_id);'
166
+ )
167
+ )
168
+ ));
169
+
170
+ return parent::_prepareColumns();
171
+ }
172
+
173
+ /**
174
+ * Retrieve Grid URL
175
+ *
176
+ * @return string
177
+ */
178
+ public function getGridUrl()
179
+ {
180
+ return $this->getUrl('*/*/wishlist', array('_current'=>true));
181
+ }
182
+
183
+ /**
184
+ * Add column filter to collection
185
+ *
186
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
187
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist
188
+ */
189
+ protected function _addColumnFilterToCollection($column)
190
+ {
191
+ /* @var $collection Mage_Wishlist_Model_Mysql4_Item_Collection */
192
+ $collection = $this->getCollection();
193
+ $value = $column->getFilter()->getValue();
194
+ if ($collection && $value) {
195
+ switch ($column->getId()) {
196
+ case 'product_name':
197
+ $collection->addProductNameFilter($value);
198
+ break;
199
+ case 'store':
200
+ $collection->addStoreFilter($value);
201
+ break;
202
+ case 'days':
203
+ $collection->addDaysFilter($value);
204
+ break;
205
+ default:
206
+ $collection->addFieldToFilter($column->getIndex(), $column->getFilter()->getCondition());
207
+ break;
208
+ }
209
+ }
210
+ return $this;
211
+ }
212
+
213
+ /**
214
+ * Sets sorting order by some column
215
+ *
216
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
217
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist
218
+ */
219
+ protected function _setCollectionOrder($column)
220
+ {
221
+ $collection = $this->getCollection();
222
+ if ($collection) {
223
+ switch ($column->getId()) {
224
+ case 'product_name':
225
+ $collection->setOrderByProductName($column->getDir());
226
+ break;
227
+ default:
228
+ parent::_setCollectionOrder($column);
229
+ break;
230
+ }
231
+ }
232
+ return $this;
233
+ }
234
+
235
+ /**
236
+ * Retrieve Grid Parent Block HTML
237
+ *
238
+ * @return string
239
+ */
240
+ public function getGridParentHtml()
241
+ {
242
+ $templateName = Mage::getDesign()->getTemplateFilename($this->_parentTemplate, array('_relative'=>true));
243
+ return $this->fetchView($templateName);
244
+ }
245
+
246
+ /**
247
+ * Retrieve Row click URL
248
+ *
249
+ * @return string
250
+ */
251
+ public function getRowUrl($row)
252
+ {
253
+ return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId()));
254
+ }
255
+
256
+ /**
257
+ * Adds product type helper depended on product type (used to show options in item cell)
258
+ *
259
+ * @param string $productType
260
+ * @param string $helperName
261
+ *
262
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist
263
+ */
264
+ public function addProductConfigurationHelper($productType, $helperName)
265
+ {
266
+ $this->_productHelpers[$productType] = $helperName;
267
+ return $this;
268
+ }
269
+
270
+ /**
271
+ * Returns array of product configuration helpers
272
+ *
273
+ * @return array
274
+ */
275
+ public function getProductConfigurationHelpers()
276
+ {
277
+ return $this->_productHelpers;
278
+ }
279
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers wishlist grid item renderer for item visibility
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist_Grid_Renderer_Description extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
35
+ {
36
+
37
+ public function render(Varien_Object $row)
38
+ {
39
+ return nl2br(htmlspecialchars($row->getData($this->getColumn()->getIndex())));
40
+ }
41
+
42
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * admin customer left menu
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('customer_info_tabs');
41
+ $this->setDestElementId('edit_form');
42
+ $this->setTitle(Mage::helper('customer')->__('Customer Information'));
43
+ }
44
+
45
+ protected function _beforeToHtml()
46
+ {
47
+ /*
48
+ if (Mage::registry('current_customer')->getId()) {
49
+ $this->addTab('view', array(
50
+ 'label' => Mage::helper('customer')->__('Customer View'),
51
+ 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_view')->toHtml(),
52
+ 'active' => true
53
+ ));
54
+ }
55
+ */
56
+ $this->addTab('account', array(
57
+ 'label' => Mage::helper('customer')->__('Account Information'),
58
+ 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_account')->initForm()->toHtml(),
59
+ 'active' => Mage::registry('current_customer')->getId() ? false : true
60
+ ));
61
+
62
+ $this->addTab('addresses', array(
63
+ 'label' => Mage::helper('customer')->__('Addresses'),
64
+ 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_addresses')->initForm()->toHtml(),
65
+ ));
66
+
67
+
68
+ // load: Orders, Shopping Cart, Wishlist, Product Reviews, Product Tags - with ajax
69
+
70
+ if (Mage::registry('current_customer')->getId()) {
71
+
72
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
73
+ $this->addTab('orders', array(
74
+ 'label' => Mage::helper('customer')->__('Orders'),
75
+ 'class' => 'ajax',
76
+ 'url' => $this->getUrl('*/*/orders', array('_current' => true)),
77
+ ));
78
+ }
79
+
80
+ $this->addTab('cart', array(
81
+ 'label' => Mage::helper('customer')->__('Shopping Cart'),
82
+ 'class' => 'ajax',
83
+ 'url' => $this->getUrl('*/*/carts', array('_current' => true)),
84
+ ));
85
+
86
+ $this->addTab('wishlist', array(
87
+ 'label' => Mage::helper('customer')->__('Wishlist'),
88
+ 'class' => 'ajax',
89
+ 'url' => $this->getUrl('*/*/wishlist', array('_current' => true)),
90
+ ));
91
+
92
+ if (Mage::getSingleton('admin/session')->isAllowed('newsletter/subscriber')) {
93
+ $this->addTab('newsletter', array(
94
+ 'label' => Mage::helper('customer')->__('Newsletter'),
95
+ 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_newsletter')->initForm()->toHtml()
96
+ ));
97
+ }
98
+
99
+ if (Mage::getSingleton('admin/session')->isAllowed('catalog/reviews_ratings')) {
100
+ $this->addTab('reviews', array(
101
+ 'label' => Mage::helper('customer')->__('Product Reviews'),
102
+ 'class' => 'ajax',
103
+ 'url' => $this->getUrl('*/*/productReviews', array('_current' => true)),
104
+ ));
105
+ }
106
+
107
+ if (Mage::getSingleton('admin/session')->isAllowed('catalog/tag')) {
108
+ $this->addTab('tags', array(
109
+ 'label' => Mage::helper('customer')->__('Product Tags'),
110
+ 'class' => 'ajax',
111
+ 'url' => $this->getUrl('*/*/productTags', array('_current' => true)),
112
+ ));
113
+ }
114
+ }
115
+
116
+ $this->_updateActiveTab();
117
+ Varien_Profiler::stop('customer/tabs');
118
+ return parent::_beforeToHtml();
119
+ }
120
+
121
+ protected function _updateActiveTab()
122
+ {
123
+ $tabId = $this->getRequest()->getParam('tab');
124
+ if( $tabId ) {
125
+ $tabId = preg_replace("#{$this->getId()}_#", '', $tabId);
126
+ if($tabId) {
127
+ $this->setActiveTab($tabId);
128
+ }
129
+ }
130
+ }
131
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/Boolean.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Customer Widget Form Boolean Element Block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Customer_Form_Element_Boolean extends Varien_Data_Form_Element_Select
36
+ {
37
+ /**
38
+ * Prepare default SELECT values
39
+ *
40
+ * @param array $attributes
41
+ */
42
+ public function __construct($attributes=array())
43
+ {
44
+ parent::__construct($attributes);
45
+ $this->setValues(array(
46
+ array(
47
+ 'label' => Mage::helper('adminhtml')->__('No'),
48
+ 'value' => '0',
49
+ ),
50
+ array(
51
+ 'label' => Mage::helper('adminhtml')->__('Yes'),
52
+ 'value' => 1,
53
+ )
54
+ ));
55
+ }
56
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/File.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Customer Widget Form File Element Block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Customer_Form_Element_File extends Varien_Data_Form_Element_Abstract
36
+ {
37
+ /**
38
+ * Initialize Form Element
39
+ *
40
+ * @param array $attributes
41
+ */
42
+ public function __construct($attributes = array())
43
+ {
44
+ parent::__construct($attributes);
45
+ $this->setType('file');
46
+ }
47
+
48
+ /**
49
+ * Return Form Element HTML
50
+ *
51
+ * @return string
52
+ */
53
+ public function getElementHtml()
54
+ {
55
+ $this->addClass('input-file');
56
+ if ($this->getRequired()) {
57
+ $this->removeClass('required-entry');
58
+ $this->addClass('required-file');
59
+ }
60
+
61
+ $element = sprintf('<input id="%s" name="%s" %s />%s%s',
62
+ $this->getHtmlId(),
63
+ $this->getName(),
64
+ $this->serialize($this->getHtmlAttributes()),
65
+ $this->getAfterElementHtml(),
66
+ $this->_getHiddenInput()
67
+ );
68
+
69
+ return $this->_getPreviewHtml() . $element . $this->_getDeleteCheckboxHtml();
70
+ }
71
+
72
+ /**
73
+ * Return Delete File CheckBox HTML
74
+ *
75
+ * @return string
76
+ */
77
+ protected function _getDeleteCheckboxHtml()
78
+ {
79
+ $html = '';
80
+ if ($this->getValue() && !$this->getRequired() && !is_array($this->getValue())) {
81
+ $checkboxId = sprintf('%s_delete', $this->getHtmlId());
82
+ $checkbox = array(
83
+ 'type' => 'checkbox',
84
+ 'name' => sprintf('%s[delete]', $this->getName()),
85
+ 'value' => '1',
86
+ 'class' => 'checkbox',
87
+ 'id' => $checkboxId
88
+ );
89
+ $label = array(
90
+ 'for' => $checkboxId
91
+ );
92
+ if ($this->getDisabled()) {
93
+ $checkbox['disabled'] = 'disabled';
94
+ $label['class'] = 'disabled';
95
+ }
96
+
97
+ $html .= '<span class="' . $this->_getDeleteCheckboxSpanClass() . '">';
98
+ $html .= $this->_drawElementHtml('input', $checkbox) . ' ';
99
+ $html .= $this->_drawElementHtml('label', $label, false) . $this->_getDeleteCheckboxLabel() . '</label>';
100
+ $html .= '</span>';
101
+ }
102
+ return $html;
103
+ }
104
+
105
+ /**
106
+ * Return Delete CheckBox SPAN Class name
107
+ *
108
+ * @return string
109
+ */
110
+ protected function _getDeleteCheckboxSpanClass()
111
+ {
112
+ return 'delete-file';
113
+ }
114
+
115
+ /**
116
+ * Return Delete CheckBox Label
117
+ *
118
+ * @return string
119
+ */
120
+ protected function _getDeleteCheckboxLabel()
121
+ {
122
+ return Mage::helper('adminhtml')->__('Delete File');
123
+ }
124
+
125
+ /**
126
+ * Return File preview link HTML
127
+ *
128
+ * @return string
129
+ */
130
+ protected function _getPreviewHtml()
131
+ {
132
+ $html = '';
133
+ if ($this->getValue() && !is_array($this->getValue())) {
134
+ $image = array(
135
+ 'alt' => Mage::helper('adminhtml')->__('Download'),
136
+ 'title' => Mage::helper('adminhtml')->__('Download'),
137
+ 'src' => Mage::getDesign()->getSkinUrl('images/fam_bullet_disk.gif'),
138
+ 'class' => 'v-middle'
139
+ );
140
+ $url = $this->_getPreviewUrl();
141
+ $html .= '<span>';
142
+ $html .= '<a href="' . $url . '">' . $this->_drawElementHtml('img', $image) . '</a> ';
143
+ $html .= '<a href="' . $url . '">' . Mage::helper('adminhtml')->__('Download') . '</a>';
144
+ $html .= '</span>';
145
+ }
146
+ return $html;
147
+ }
148
+
149
+ /**
150
+ * Return Hidden element with current value
151
+ *
152
+ * @return string
153
+ */
154
+ protected function _getHiddenInput()
155
+ {
156
+ return $this->_drawElementHtml('input', array(
157
+ 'type' => 'hidden',
158
+ 'name' => sprintf('%s[value]', $this->getName()),
159
+ 'id' => sprintf('%s_value', $this->getHtmlId()),
160
+ 'value' => $this->getEscapedValue()
161
+ ));
162
+ }
163
+
164
+ /**
165
+ * Return Preview/Download URL
166
+ *
167
+ * @return string
168
+ */
169
+ protected function _getPreviewUrl()
170
+ {
171
+ return Mage::helper('adminhtml')->getUrl('adminhtml/customer/viewfile', array(
172
+ 'file' => Mage::helper('core')->urlEncode($this->getValue()),
173
+ ));
174
+ }
175
+
176
+ /**
177
+ * Return Element HTML
178
+ *
179
+ * @param string $element
180
+ * @param array $attributes
181
+ * @param boolean $closed
182
+ * @return string
183
+ */
184
+ protected function _drawElementHtml($element, array $attributes, $closed = true)
185
+ {
186
+ $parts = array();
187
+ foreach ($attributes as $k => $v) {
188
+ $parts[] = sprintf('%s="%s"', $k, $v);
189
+ }
190
+
191
+ return sprintf('<%s %s%s>', $element, implode(' ', $parts), $closed ? ' /' : '');
192
+ }
193
+
194
+ /**
195
+ * Return escaped value
196
+ *
197
+ * @param int $index
198
+ * @return string
199
+ */
200
+ public function getEscapedValue($index = null)
201
+ {
202
+ if (is_array($this->getValue())) {
203
+ return false;
204
+ }
205
+ $value = $this->getValue();
206
+ if (is_array($value) && is_null($index)) {
207
+ $index = 'value';
208
+ }
209
+
210
+ return parent::getEscapedValue($index);
211
+ }
212
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Form/Element/Image.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Customer Widget Form Image File Element Block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Customer_Form_Element_Image extends Mage_Adminhtml_Block_Customer_Form_Element_File
36
+ {
37
+ /**
38
+ * Return Delete CheckBox Label
39
+ *
40
+ * @return string
41
+ */
42
+ protected function _getDeleteCheckboxLabel()
43
+ {
44
+ return Mage::helper('adminhtml')->__('Delete Image');
45
+ }
46
+
47
+ /**
48
+ * Return Delete CheckBox SPAN Class name
49
+ *
50
+ * @return string
51
+ */
52
+ protected function _getDeleteCheckboxSpanClass()
53
+ {
54
+ return 'delete-image';
55
+ }
56
+
57
+ /**
58
+ * Return File preview link HTML
59
+ *
60
+ * @return string
61
+ */
62
+ protected function _getPreviewHtml()
63
+ {
64
+ $html = '';
65
+ if ($this->getValue() && !is_array($this->getValue())) {
66
+ $url = $this->_getPreviewUrl();
67
+ $imageId = sprintf('%s_image', $this->getHtmlId());
68
+ $image = array(
69
+ 'alt' => Mage::helper('adminhtml')->__('View Full Size'),
70
+ 'title' => Mage::helper('adminhtml')->__('View Full Size'),
71
+ 'src' => $url,
72
+ 'class' => 'small-image-preview v-middle',
73
+ 'height' => 22,
74
+ 'width' => 22,
75
+ 'id' => $imageId
76
+ );
77
+ $link = array(
78
+ 'href' => $url,
79
+ 'onclick' => "imagePreview('{$imageId}'); return false;",
80
+ );
81
+
82
+ $html = sprintf('%s%s</a> ',
83
+ $this->_drawElementHtml('a', $link, false),
84
+ $this->_drawElementHtml('img', $image)
85
+ );
86
+ }
87
+ return $html;
88
+ }
89
+
90
+ /**
91
+ * Return Image URL
92
+ *
93
+ * @return string
94
+ */
95
+ protected function _getPreviewUrl()
96
+ {
97
+ if (is_array($this->getValue())) {
98
+ return false;
99
+ }
100
+ return Mage::helper('adminhtml')->getUrl('adminhtml/customer/viewfile', array(
101
+ 'image' => Mage::helper('core')->urlEncode($this->getValue()),
102
+ ));
103
+ }
104
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Grid.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('customerGrid');
41
+ $this->setUseAjax(true);
42
+ $this->setDefaultSort('entity_id');
43
+ $this->setSaveParametersInSession(true);
44
+ }
45
+
46
+ protected function _prepareCollection()
47
+ {
48
+ $collection = Mage::getResourceModel('customer/customer_collection')
49
+ ->addNameToSelect()
50
+ ->addAttributeToSelect('email')
51
+ ->addAttributeToSelect('created_at')
52
+ ->addAttributeToSelect('group_id')
53
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
54
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
55
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
56
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
57
+ ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
58
+
59
+ $this->setCollection($collection);
60
+
61
+ return parent::_prepareCollection();
62
+ }
63
+
64
+ protected function _prepareColumns()
65
+ {
66
+ $this->addColumn('entity_id', array(
67
+ 'header' => Mage::helper('customer')->__('ID'),
68
+ 'width' => '50px',
69
+ 'index' => 'entity_id',
70
+ 'type' => 'number',
71
+ ));
72
+ /*$this->addColumn('firstname', array(
73
+ 'header' => Mage::helper('customer')->__('First Name'),
74
+ 'index' => 'firstname'
75
+ ));
76
+ $this->addColumn('lastname', array(
77
+ 'header' => Mage::helper('customer')->__('Last Name'),
78
+ 'index' => 'lastname'
79
+ ));*/
80
+ $this->addColumn('name', array(
81
+ 'header' => Mage::helper('customer')->__('Name'),
82
+ 'index' => 'name'
83
+ ));
84
+ $this->addColumn('email', array(
85
+ 'header' => Mage::helper('customer')->__('Email'),
86
+ 'width' => '150',
87
+ 'index' => 'email'
88
+ ));
89
+
90
+ $groups = Mage::getResourceModel('customer/group_collection')
91
+ ->addFieldToFilter('customer_group_id', array('gt'=> 0))
92
+ ->load()
93
+ ->toOptionHash();
94
+
95
+ $this->addColumn('group', array(
96
+ 'header' => Mage::helper('customer')->__('Group'),
97
+ 'width' => '100',
98
+ 'index' => 'group_id',
99
+ 'type' => 'options',
100
+ 'options' => $groups,
101
+ ));
102
+
103
+ $this->addColumn('Telephone', array(
104
+ 'header' => Mage::helper('customer')->__('Telephone'),
105
+ 'width' => '100',
106
+ 'index' => 'billing_telephone'
107
+ ));
108
+
109
+ $this->addColumn('billing_postcode', array(
110
+ 'header' => Mage::helper('customer')->__('ZIP'),
111
+ 'width' => '90',
112
+ 'index' => 'billing_postcode',
113
+ ));
114
+
115
+ $this->addColumn('billing_country_id', array(
116
+ 'header' => Mage::helper('customer')->__('Country'),
117
+ 'width' => '100',
118
+ 'type' => 'country',
119
+ 'index' => 'billing_country_id',
120
+ ));
121
+
122
+ $this->addColumn('billing_region', array(
123
+ 'header' => Mage::helper('customer')->__('State/Province'),
124
+ 'width' => '100',
125
+ 'index' => 'billing_region',
126
+ ));
127
+
128
+ $this->addColumn('customer_since', array(
129
+ 'header' => Mage::helper('customer')->__('Customer Since'),
130
+ 'type' => 'datetime',
131
+ 'align' => 'center',
132
+ 'index' => 'created_at',
133
+ 'gmtoffset' => true
134
+ ));
135
+
136
+ if (!Mage::app()->isSingleStoreMode()) {
137
+ $this->addColumn('website_id', array(
138
+ 'header' => Mage::helper('customer')->__('Website'),
139
+ 'align' => 'center',
140
+ 'width' => '80px',
141
+ 'type' => 'options',
142
+ 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
143
+ 'index' => 'website_id',
144
+ ));
145
+ }
146
+
147
+ $this->addColumn('action',
148
+ array(
149
+ 'header' => Mage::helper('customer')->__('Action'),
150
+ 'width' => '100',
151
+ 'type' => 'action',
152
+ 'getter' => 'getId',
153
+ 'actions' => array(
154
+ array(
155
+ 'caption' => Mage::helper('customer')->__('Edit'),
156
+ 'url' => array('base'=> '*/*/edit'),
157
+ 'field' => 'id'
158
+ )
159
+ ),
160
+ 'filter' => false,
161
+ 'sortable' => false,
162
+ 'index' => 'stores',
163
+ 'is_system' => true,
164
+ ));
165
+
166
+ $this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
167
+ $this->addExportType('*/*/exportXml', Mage::helper('customer')->__('Excel XML'));
168
+ return parent::_prepareColumns();
169
+ }
170
+
171
+ protected function _prepareMassaction()
172
+ {
173
+ $this->setMassactionIdField('entity_id');
174
+ $this->getMassactionBlock()->setFormFieldName('customer');
175
+
176
+ $this->getMassactionBlock()->addItem('delete', array(
177
+ 'label' => Mage::helper('customer')->__('Delete'),
178
+ 'url' => $this->getUrl('*/*/massDelete'),
179
+ 'confirm' => Mage::helper('customer')->__('Are you sure?')
180
+ ));
181
+
182
+ $this->getMassactionBlock()->addItem('newsletter_subscribe', array(
183
+ 'label' => Mage::helper('customer')->__('Subscribe to Newsletter'),
184
+ 'url' => $this->getUrl('*/*/massSubscribe')
185
+ ));
186
+
187
+ $this->getMassactionBlock()->addItem('newsletter_unsubscribe', array(
188
+ 'label' => Mage::helper('customer')->__('Unsubscribe from Newsletter'),
189
+ 'url' => $this->getUrl('*/*/massUnsubscribe')
190
+ ));
191
+
192
+ $groups = $this->helper('customer')->getGroups()->toOptionArray();
193
+
194
+ array_unshift($groups, array('label'=> '', 'value'=> ''));
195
+ $this->getMassactionBlock()->addItem('assign_group', array(
196
+ 'label' => Mage::helper('customer')->__('Assign a Customer Group'),
197
+ 'url' => $this->getUrl('*/*/massAssignGroup'),
198
+ 'additional' => array(
199
+ 'visibility' => array(
200
+ 'name' => 'group',
201
+ 'type' => 'select',
202
+ 'class' => 'required-entry',
203
+ 'label' => Mage::helper('customer')->__('Group'),
204
+ 'values' => $groups
205
+ )
206
+ )
207
+ ));
208
+
209
+ return $this;
210
+ }
211
+
212
+ public function getGridUrl()
213
+ {
214
+ return $this->getUrl('*/*/grid', array('_current'=> true));
215
+ }
216
+
217
+ public function getRowUrl($row)
218
+ {
219
+ return $this->getUrl('*/*/edit', array('id'=>$row->getId()));
220
+ }
221
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Grid/Filter/Country.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Country customer grid column filter
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Grid_Filter_Country extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
35
+ {
36
+
37
+ protected function _getOptions()
38
+ {
39
+ $options = Mage::getResourceModel('directory/country_collection')->load()->toOptionArray();
40
+ array_unshift($options, array('value'=>'', 'label'=>Mage::helper('customer')->__('All countries')));
41
+ return $options;
42
+ }
43
+
44
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Grid/Renderer/Multiaction.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers wishlist grid item action renderer for few action controls in one cell
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Grid_Renderer_Multiaction
35
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
36
+ {
37
+ /**
38
+ * Renders column
39
+ *
40
+ * @param Varien_Object $row
41
+ * @return string
42
+ */
43
+ public function render(Varien_Object $row)
44
+ {
45
+ $html = '';
46
+ $actions = $this->getColumn()->getActions();
47
+ if (!empty($actions) && is_array($actions)) {
48
+ $links = array();
49
+ foreach ($actions as $action) {
50
+ if (is_array($action)) {
51
+ $link = $this->_toLinkHtml($action, $row);
52
+ if ($link) {
53
+ $links[] = $link;
54
+ }
55
+ }
56
+ }
57
+ $html = implode('<br />', $links);
58
+ }
59
+
60
+ if ($html == '') {
61
+ $html = '&nbsp;';
62
+ }
63
+
64
+ return $html;
65
+ }
66
+
67
+ /**
68
+ * Render single action as link html
69
+ *
70
+ * @param array $action
71
+ * @param Varien_Object $row
72
+ * @return string
73
+ */
74
+ protected function _toLinkHtml($action, Varien_Object $row)
75
+ {
76
+ $product = $row->getProduct();
77
+
78
+ if (isset($action['process']) && $action['process'] == 'configurable') {
79
+ if ($product->canConfigure()) {
80
+ $style = '';
81
+ $onClick = sprintf('onclick="return %s.configureItem(%s)"', $action['control_object'], $row->getId());
82
+ } else {
83
+ $style = 'style="color: #CCC;"';
84
+ $onClick = '';
85
+ }
86
+
87
+ return sprintf('<a href="%s" %s %s>%s</a>', $action['url'], $style, $onClick, $action['caption']);
88
+ } else {
89
+ return parent::_toLinkHtml($action, $row);
90
+ }
91
+ }
92
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Group.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers group page content block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Group extends Mage_Adminhtml_Block_Widget_Grid_Container//Mage_Adminhtml_Block_Template
35
+ {
36
+
37
+ /**
38
+ * Modify header & button labels
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ $this->_controller = 'customer_group';
44
+ $this->_headerText = Mage::helper('customer')->__('Customer Groups');
45
+ $this->_addButtonLabel = Mage::helper('customer')->__('Add New Customer Group');
46
+ parent::__construct();
47
+ }
48
+
49
+ /**
50
+ * Redefine header css class
51
+ *
52
+ * @return string
53
+ */
54
+ public function getHeaderCssClass() {
55
+ return 'icon-head head-customer-groups';
56
+ }
57
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Customer group edit block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Group_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+
41
+ $this->_objectId = 'id';
42
+ $this->_controller = 'customer_group';
43
+
44
+ $this->_updateButton('save', 'label', Mage::helper('customer')->__('Save Customer Group'));
45
+ $this->_updateButton('delete', 'label', Mage::helper('customer')->__('Delete Customer Group'));
46
+
47
+ if(!Mage::registry('current_group')->getId() || Mage::registry('current_group')->usesAsDefault()) {
48
+ $this->_removeButton('delete');
49
+ }
50
+ }
51
+
52
+ public function getHeaderText()
53
+ {
54
+ if(!is_null(Mage::registry('current_group')->getId())) {
55
+ return Mage::helper('customer')->__('Edit Customer Group "%s"', $this->htmlEscape(Mage::registry('current_group')->getCustomerGroupCode()));
56
+ } else {
57
+ return Mage::helper('customer')->__('New Customer Group');
58
+ }
59
+ }
60
+
61
+ public function getHeaderCssClass() {
62
+ return 'icon-head head-customer-groups';
63
+ }
64
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit/Form.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer groups edit form
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Group_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+ /**
37
+ * Prepare form for render
38
+ */
39
+ protected function _prepareLayout()
40
+ {
41
+ parent::_prepareLayout();
42
+ $form = new Varien_Data_Form();
43
+ $customerGroup = Mage::registry('current_group');
44
+
45
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('customer')->__('Group Information')));
46
+
47
+ $validateClass = sprintf('required-entry validate-length maximum-length-%d',
48
+ Mage_Customer_Model_Group::GROUP_CODE_MAX_LENGTH);
49
+ $name = $fieldset->addField('customer_group_code', 'text',
50
+ array(
51
+ 'name' => 'code',
52
+ 'label' => Mage::helper('customer')->__('Group Name'),
53
+ 'title' => Mage::helper('customer')->__('Group Name'),
54
+ 'note' => Mage::helper('customer')->__('Maximum length must be less then %s symbols',
55
+ Mage_Customer_Model_Group::GROUP_CODE_MAX_LENGTH),
56
+ 'class' => $validateClass,
57
+ 'required' => true,
58
+ )
59
+ );
60
+
61
+ if ($customerGroup->getId()==0 && $customerGroup->getCustomerGroupCode() ) {
62
+ $name->setDisabled(true);
63
+ }
64
+
65
+ $fieldset->addField('tax_class_id', 'select',
66
+ array(
67
+ 'name' => 'tax_class',
68
+ 'label' => Mage::helper('customer')->__('Tax Class'),
69
+ 'title' => Mage::helper('customer')->__('Tax Class'),
70
+ 'class' => 'required-entry',
71
+ 'required' => true,
72
+ 'values' => Mage::getSingleton('tax/class_source_customer')->toOptionArray()
73
+ )
74
+ );
75
+
76
+ if (!is_null($customerGroup->getId())) {
77
+ // If edit add id
78
+ $form->addField('id', 'hidden',
79
+ array(
80
+ 'name' => 'id',
81
+ 'value' => $customerGroup->getId(),
82
+ )
83
+ );
84
+ }
85
+
86
+ if( Mage::getSingleton('adminhtml/session')->getCustomerGroupData() ) {
87
+ $form->addValues(Mage::getSingleton('adminhtml/session')->getCustomerGroupData());
88
+ Mage::getSingleton('adminhtml/session')->setCustomerGroupData(null);
89
+ } else {
90
+ $form->addValues($customerGroup->getData());
91
+ }
92
+
93
+ $form->setUseContainer(true);
94
+ $form->setId('edit_form');
95
+ $form->setAction($this->getUrl('*/*/save'));
96
+ $this->setForm($form);
97
+ }
98
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Group/Grid.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers groups grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Group_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('customerGroupGrid');
41
+ $this->setDefaultSort('type');
42
+ $this->setDefaultDir('asc');
43
+ $this->setSaveParametersInSession(true);
44
+ }
45
+
46
+ /**
47
+ * Init customer groups collection
48
+ * @return void
49
+ */
50
+ protected function _prepareCollection()
51
+ {
52
+ $collection = Mage::getResourceModel('customer/group_collection')
53
+ ->addTaxClass();
54
+
55
+ $this->setCollection($collection);
56
+ return parent::_prepareCollection();
57
+ }
58
+
59
+ /**
60
+ * Configuration of grid
61
+ */
62
+ protected function _prepareColumns()
63
+ {
64
+ $this->addColumn('time', array(
65
+ 'header' => Mage::helper('customer')->__('ID'),
66
+ 'width' => '50px',
67
+ 'align' => 'right',
68
+ 'index' => 'customer_group_id',
69
+ ));
70
+
71
+ $this->addColumn('type', array(
72
+ 'header' => Mage::helper('customer')->__('Group Name'),
73
+ 'index' => 'customer_group_code',
74
+ ));
75
+
76
+ $this->addColumn('class_name', array(
77
+ 'header' => Mage::helper('customer')->__('Tax Class'),
78
+ 'index' => 'class_name',
79
+ 'width' => '200px'
80
+ ));
81
+
82
+ return parent::_prepareColumns();
83
+ }
84
+
85
+ public function getRowUrl($row)
86
+ {
87
+ return $this->getUrl('*/*/edit', array('id'=>$row->getId()));
88
+ }
89
+
90
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Online.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml online customers page content block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Online extends Mage_Adminhtml_Block_Template
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setTemplate('customer/online.phtml');
41
+ }
42
+
43
+ public function _beforeToHtml()
44
+ {
45
+ $this->setChild('grid', $this->getLayout()->createBlock('adminhtml/customer_online_grid', 'customer.grid'));
46
+ return parent::_beforeToHtml();
47
+ }
48
+
49
+ protected function _prepareLayout()
50
+ {
51
+ $this->setChild('filterForm', $this->getLayout()->createBlock('adminhtml/customer_online_filter'));
52
+ return parent::_prepareLayout();
53
+ }
54
+
55
+ public function getFilterFormHtml()
56
+ {
57
+ return $this->getChild('filterForm')->toHtml();
58
+ }
59
+
60
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Online/Filter.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers online filter
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Customer_Online_Filter extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ }
41
+
42
+ protected function _prepareForm()
43
+ {
44
+ $form = new Varien_Data_Form();
45
+
46
+ $form->addField('filter_value', 'select',
47
+ array(
48
+ 'name' => 'filter_value',
49
+ 'onchange' => 'this.form.submit()',
50
+ 'values' => array(
51
+ array(
52
+ 'label' => Mage::helper('customer')->__('All'),
53
+ 'value' => '',
54
+ ),
55
+
56
+ array(
57
+ 'label' => Mage::helper('customer')->__('Customers Only'),
58
+ 'value' => 'filterCustomers',
59
+ ),
60
+
61
+ array(
62
+ 'label' => Mage::helper('customer')->__('Visitors Only'),
63
+ 'value' => 'filterGuests',
64
+ )
65
+ ),
66
+ 'no_span' => true
67
+ )
68
+ );
69
+
70
+ $form->setUseContainer(true);
71
+ $form->setId('filter_form');
72
+ $form->setMethod('post');
73
+
74
+ $this->setForm($form);
75
+ return parent::_prepareForm();
76
+ }
77
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Online_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ /**
37
+ * Initialize Grid block
38
+ *
39
+ */
40
+ public function __construct()
41
+ {
42
+ parent::__construct();
43
+ $this->setId('onlineGrid');
44
+ $this->setSaveParametersInSession(true);
45
+ $this->setDefaultSort('last_activity');
46
+ $this->setDefaultDir('DESC');
47
+ }
48
+
49
+ /**
50
+ * Prepare collection for grid
51
+ *
52
+ * @return Mage_Adminhtml_Block_Customer_Online_Grid
53
+ */
54
+ protected function _prepareCollection()
55
+ {
56
+ $collection = Mage::getModel('log/visitor_online')
57
+ ->prepare()
58
+ ->getCollection();
59
+ /* @var $collection Mage_Log_Model_Mysql4_Visitor_Online_Collection */
60
+ $collection->addCustomerData();
61
+
62
+ $this->setCollection($collection);
63
+ parent::_prepareCollection();
64
+
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Prepare columns
70
+ *
71
+ * @return Mage_Adminhtml_Block_Customer_Online_Grid
72
+ */
73
+ protected function _prepareColumns()
74
+ {
75
+ $this->addColumn('customer_id', array(
76
+ 'header' => Mage::helper('customer')->__('ID'),
77
+ 'width' => '40px',
78
+ 'align' => 'right',
79
+ 'type' => 'number',
80
+ 'default' => Mage::helper('customer')->__('n/a'),
81
+ 'index' => 'customer_id'
82
+ ));
83
+
84
+ $this->addColumn('firstname', array(
85
+ 'header' => Mage::helper('customer')->__('First Name'),
86
+ 'default' => Mage::helper('customer')->__('Guest'),
87
+ 'index' => 'customer_firstname'
88
+ ));
89
+
90
+ $this->addColumn('lastname', array(
91
+ 'header' => Mage::helper('customer')->__('Last Name'),
92
+ 'default' => Mage::helper('customer')->__('n/a'),
93
+ 'index' => 'customer_lastname'
94
+ ));
95
+
96
+ $this->addColumn('email', array(
97
+ 'header' => Mage::helper('customer')->__('Email'),
98
+ 'default' => Mage::helper('customer')->__('n/a'),
99
+ 'index' => 'customer_email'
100
+ ));
101
+
102
+ $this->addColumn('ip_address', array(
103
+ 'header' => Mage::helper('customer')->__('IP Address'),
104
+ 'default' => Mage::helper('customer')->__('n/a'),
105
+ 'index' => 'remote_addr',
106
+ 'renderer' => 'adminhtml/customer_online_grid_renderer_ip',
107
+ 'filter' => false,
108
+ 'sort' => false
109
+ ));
110
+
111
+ $this->addColumn('session_start_time', array(
112
+ 'header' => Mage::helper('customer')->__('Session Start Time'),
113
+ 'align' => 'left',
114
+ 'width' => '200px',
115
+ 'type' => 'datetime',
116
+ 'default' => Mage::helper('customer')->__('n/a'),
117
+ 'index' =>'first_visit_at'
118
+ ));
119
+
120
+ $this->addColumn('last_activity', array(
121
+ 'header' => Mage::helper('customer')->__('Last Activity'),
122
+ 'align' => 'left',
123
+ 'width' => '200px',
124
+ 'type' => 'datetime',
125
+ 'default' => Mage::helper('customer')->__('n/a'),
126
+ 'index' => 'last_visit_at'
127
+ ));
128
+
129
+ $typeOptions = array(
130
+ Mage_Log_Model_Visitor::VISITOR_TYPE_CUSTOMER => Mage::helper('customer')->__('Customer'),
131
+ Mage_Log_Model_Visitor::VISITOR_TYPE_VISITOR => Mage::helper('customer')->__('Visitor'),
132
+ );
133
+
134
+ $this->addColumn('type', array(
135
+ 'header' => Mage::helper('customer')->__('Type'),
136
+ 'index' => 'type',
137
+ 'type' => 'options',
138
+ 'options' => $typeOptions,
139
+ // 'renderer' => 'adminhtml/customer_online_grid_renderer_type',
140
+ 'index' => 'visitor_type'
141
+ ));
142
+
143
+ $this->addColumn('last_url', array(
144
+ 'header' => Mage::helper('customer')->__('Last URL'),
145
+ 'type' => 'wrapline',
146
+ 'lineLength' => '60',
147
+ 'default' => Mage::helper('customer')->__('n/a'),
148
+ 'renderer' => 'adminhtml/customer_online_grid_renderer_url',
149
+ 'index' => 'last_url'
150
+ ));
151
+
152
+ return parent::_prepareColumns();
153
+ }
154
+
155
+ /**
156
+ * Retrieve Row URL
157
+ *
158
+ * @param Mage_Core_Model_Abstract
159
+ * @return string
160
+ */
161
+ public function getRowUrl($row)
162
+ {
163
+ return (Mage::getSingleton('admin/session')->isAllowed('customer/manage') && $row->getCustomerId())
164
+ ? $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId())) : '';
165
+ }
166
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Ip.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers online grid block item renderer by ip.
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Online_Grid_Renderer_Ip extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
35
+ {
36
+
37
+ public function render(Varien_Object $row)
38
+ {
39
+ return long2ip($row->getData($this->getColumn()->getIndex()));
40
+ }
41
+
42
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Type.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customers online grid renderer for customer type.
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Customer_Online_Grid_Renderer_Type extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
35
+ {
36
+
37
+ public function render(Varien_Object $row)
38
+ {
39
+ return ($row->getCustomerId() > 0 ) ? Mage::helper('customer')->__('Customer') : Mage::helper('customer')->__('Visitor') ;
40
+ }
41
+
42
+ }
app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Url.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml Online Customer last URL renderer
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Customer_Online_Grid_Renderer_Url extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
36
+ {
37
+ /**
38
+ * Renders grid column
39
+ *
40
+ * @param Varien_Object $row
41
+ * @return string
42
+ */
43
+ public function render(Varien_Object $row)
44
+ {
45
+ return htmlspecialchars($row->getData($this->getColumn()->getIndex()));
46
+ }
47
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Dashboard extends Mage_Adminhtml_Block_Template
28
+ {
29
+ protected $_locale;
30
+
31
+ /**
32
+ * Location of the "Enable Chart" config param
33
+ */
34
+ const XML_PATH_ENABLE_CHARTS = 'admin/dashboard/enable_charts';
35
+
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setTemplate('dashboard/index.phtml');
40
+
41
+ }
42
+
43
+ protected function _prepareLayout()
44
+ {
45
+ $this->setChild('lastOrders',
46
+ $this->getLayout()->createBlock('adminhtml/dashboard_orders_grid')
47
+ );
48
+
49
+ $this->setChild('totals',
50
+ $this->getLayout()->createBlock('adminhtml/dashboard_totals')
51
+ );
52
+
53
+ $this->setChild('sales',
54
+ $this->getLayout()->createBlock('adminhtml/dashboard_sales')
55
+ );
56
+
57
+ $this->setChild('lastSearches',
58
+ $this->getLayout()->createBlock('adminhtml/dashboard_searches_last')
59
+ );
60
+
61
+ $this->setChild('topSearches',
62
+ $this->getLayout()->createBlock('adminhtml/dashboard_searches_top')
63
+ );
64
+
65
+ if (Mage::getStoreConfig(self::XML_PATH_ENABLE_CHARTS)) {
66
+ $block = $this->getLayout()->createBlock('adminhtml/dashboard_diagrams');
67
+ } else {
68
+ $block = $this->getLayout()->createBlock('adminhtml/template')
69
+ ->setTemplate('dashboard/graph/disabled.phtml')
70
+ ->setConfigUrl($this->getUrl('adminhtml/system_config/edit', array('section'=>'admin')));
71
+ }
72
+ $this->setChild('diagrams', $block);
73
+
74
+ $this->setChild('grids',
75
+ $this->getLayout()->createBlock('adminhtml/dashboard_grids')
76
+ );
77
+
78
+ parent::_prepareLayout();
79
+ }
80
+
81
+ public function getSwitchUrl()
82
+ {
83
+ if ($url = $this->getData('switch_url')) {
84
+ return $url;
85
+ }
86
+ return $this->getUrl('*/*/*', array('_current'=>true, 'period'=>null));
87
+ }
88
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Abstract.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard tab abstract
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ abstract class Mage_Adminhtml_Block_Dashboard_Abstract extends Mage_Adminhtml_Block_Widget
36
+ {
37
+ protected $_dataHelperName = null;
38
+
39
+ public function __construct($attributes=array())
40
+ {
41
+ parent::__construct($attributes);
42
+ }
43
+
44
+ public function getCollection()
45
+ {
46
+ return $this->getDataHelper()->getCollection();
47
+ }
48
+
49
+ public function getCount()
50
+ {
51
+ return $this->getDataHelper()->getCount();
52
+ }
53
+
54
+ public function getDataHelper()
55
+ {
56
+ return $this->helper($this->getDataHelperName());
57
+ }
58
+
59
+ public function getDataHelperName()
60
+ {
61
+ return $this->_dataHelperName;
62
+ }
63
+
64
+ public function setDataHelperName($dataHelperName)
65
+ {
66
+ $this->_dataHelperName = $dataHelperName;
67
+ return $this;
68
+ }
69
+
70
+ protected function _prepareData()
71
+ {
72
+ return $this;
73
+ }
74
+
75
+ protected function _prepareLayout()
76
+ {
77
+ $this->_prepareData();
78
+ return parent::_prepareLayout();
79
+ }
80
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard bar block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Bar extends Mage_Adminhtml_Block_Dashboard_Abstract
36
+ {
37
+ protected $_totals = array();
38
+ protected $_currentCurrencyCode = null;
39
+
40
+ protected function _construct()
41
+ {
42
+ parent::_construct();
43
+ $this->setTemplate('dashboard/bar.phtml');
44
+ }
45
+
46
+ protected function getTotals()
47
+ {
48
+ return $this->_totals;
49
+ }
50
+
51
+ public function addTotal($label, $value, $isQuantity=false)
52
+ {
53
+ /*if (!$isQuantity) {
54
+ $value = $this->format($value);
55
+ $decimals = substr($value, -2);
56
+ $value = substr($value, 0, -2);
57
+ } else {
58
+ $value = ($value != '')?$value:0;
59
+ $decimals = '';
60
+ }*/
61
+ if (!$isQuantity) {
62
+ $value = $this->format($value);
63
+ }
64
+ $decimals = '';
65
+ $this->_totals[] = array(
66
+ 'label' => $label,
67
+ 'value' => $value,
68
+ 'decimals' => $decimals,
69
+ );
70
+
71
+ return $this;
72
+ }
73
+
74
+ /**
75
+ * Formating value specific for this store
76
+ *
77
+ * @param decimal $price
78
+ * @return string
79
+ */
80
+ public function format($price)
81
+ {
82
+ return $this->getCurrency()->format($price);
83
+ }
84
+
85
+ /**
86
+ * Setting currency model
87
+ *
88
+ * @param Mage_Directory_Model_Currency $currency
89
+ */
90
+ public function setCurrency($currency)
91
+ {
92
+ $this->_currency = $currency;
93
+ }
94
+
95
+ /**
96
+ * Retrieve currency model if not set then return currency model for current store
97
+ *
98
+ * @return Mage_Directory_Model_Currency
99
+ */
100
+ public function getCurrency()
101
+ {
102
+ if (is_null($this->_currentCurrencyCode)) {
103
+ if ($this->getRequest()->getParam('store')) {
104
+ $this->_currentCurrencyCode = Mage::app()->getStore($this->getRequest()->getParam('store'))->getBaseCurrency();
105
+ } else if ($this->getRequest()->getParam('website')){
106
+ $this->_currentCurrencyCode = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getBaseCurrency();
107
+ } else if ($this->getRequest()->getParam('group')){
108
+ $this->_currentCurrencyCode = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getWebsite()->getBaseCurrency();
109
+ } else {
110
+ $this->_currentCurrencyCode = Mage::app()->getStore()->getBaseCurrency();
111
+ }
112
+ }
113
+
114
+ return $this->_currentCurrencyCode;
115
+ }
116
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Diagrams.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard diagram tabs
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Diagrams extends Mage_Adminhtml_Block_Widget_Tabs
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('diagram_tab');
41
+ $this->setDestElementId('diagram_tab_content');
42
+ $this->setTemplate('widget/tabshoriz.phtml');
43
+ }
44
+
45
+ protected function _prepareLayout()
46
+ {
47
+ $this->addTab('orders', array(
48
+ 'label' => $this->__('Orders'),
49
+ 'content' => $this->getLayout()->createBlock('adminhtml/dashboard_tab_orders')->toHtml(),
50
+ 'active' => true
51
+ ));
52
+
53
+ $this->addTab('amounts', array(
54
+ 'label' => $this->__('Amounts'),
55
+ 'content' => $this->getLayout()->createBlock('adminhtml/dashboard_tab_amounts')->toHtml(),
56
+ ));
57
+ return parent::_prepareLayout();
58
+ }
59
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php ADDED
@@ -0,0 +1,560 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard google chart block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Graph extends Mage_Adminhtml_Block_Dashboard_Abstract
36
+ {
37
+ /**
38
+ * Api URL
39
+ */
40
+ const API_URL = 'http://chart.apis.google.com/chart';
41
+
42
+ /**
43
+ * All series
44
+ *
45
+ * @var array
46
+ */
47
+ protected $_allSeries = array();
48
+
49
+ /**
50
+ * Axis labels
51
+ *
52
+ * @var array
53
+ */
54
+ protected $_axisLabels = array();
55
+
56
+ /**
57
+ * Axis maps
58
+ *
59
+ * @var array
60
+ */
61
+ protected $_axisMaps = array();
62
+
63
+ /**
64
+ * Data rows
65
+ *
66
+ * @var array
67
+ */
68
+ protected $_dataRows = array();
69
+
70
+ /**
71
+ * Simple encoding chars
72
+ *
73
+ * @var string
74
+ */
75
+ protected $_simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
76
+
77
+ /**
78
+ * Extended encoding chars
79
+ *
80
+ * @var string
81
+ */
82
+ protected $_extendedEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.';
83
+
84
+ /**
85
+ * Chart width
86
+ *
87
+ * @var string
88
+ */
89
+ protected $_width = '587';
90
+
91
+ /**
92
+ * Chart height
93
+ *
94
+ * @var string
95
+ */
96
+ protected $_height = '300';
97
+
98
+ /**
99
+ * Google chart api data encoding
100
+ *
101
+ * @var string
102
+ */
103
+ protected $_encoding = 'e';
104
+
105
+ /**
106
+ * Html identifier
107
+ *
108
+ * @var string
109
+ */
110
+ protected $_htmlId = '';
111
+
112
+ /**
113
+ * Initialize object
114
+ *
115
+ * @return void
116
+ */
117
+ public function __construct()
118
+ {
119
+ parent::__construct();
120
+ $this->setTemplate('dashboard/graph.phtml');
121
+ }
122
+
123
+ /**
124
+ * Get tab template
125
+ *
126
+ * @return string
127
+ */
128
+ protected function _getTabTemplate()
129
+ {
130
+ return 'dashboard/graph.phtml';
131
+ }
132
+
133
+ /**
134
+ * Set data rows
135
+ *
136
+ * @param mixed $rows
137
+ * @return void
138
+ */
139
+ public function setDataRows($rows)
140
+ {
141
+ $this->_dataRows = (array)$rows;
142
+ }
143
+
144
+ /**
145
+ * Add series
146
+ *
147
+ * @param string $seriesId
148
+ * @param array $options
149
+ * @return void
150
+ */
151
+ public function addSeries($seriesId, array $options)
152
+ {
153
+ $this->_allSeries[$seriesId] = $options;
154
+ }
155
+
156
+ /**
157
+ * Get series
158
+ *
159
+ * @param string $seriesId
160
+ * @return mixed
161
+ */
162
+ public function getSeries($seriesId)
163
+ {
164
+ if (isset($this->_allSeries[$seriesId])) {
165
+ return $this->_allSeries[$seriesId];
166
+ } else {
167
+ return false;
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Get all series
173
+ *
174
+ * @return array
175
+ */
176
+ public function getAllSeries()
177
+ {
178
+ return $this->_allSeries;
179
+ }
180
+
181
+ /**
182
+ * Get chart url
183
+ *
184
+ * @param bool $directUrl
185
+ * @return string
186
+ */
187
+ public function getChartUrl($directUrl = true)
188
+ {
189
+ $params = array(
190
+ 'cht' => 'lc',
191
+ 'chf' => 'bg,s,f4f4f4|c,lg,90,ffffff,0.1,ededed,0',
192
+ 'chm' => 'B,f4d4b2,0,0,0',
193
+ 'chco' => 'db4814'
194
+ );
195
+
196
+ $this->_allSeries = $this->getRowsData($this->_dataRows);
197
+
198
+ foreach ($this->_axisMaps as $axis => $attr){
199
+ $this->setAxisLabels($axis, $this->getRowsData($attr, true));
200
+ }
201
+
202
+ $timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
203
+
204
+ list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection')
205
+ ->getDateRange($this->getDataHelper()->getParam('period'), '', '', true);
206
+
207
+ $dateStart->setTimezone($timezoneLocal);
208
+ $dateEnd->setTimezone($timezoneLocal);
209
+
210
+ $dates = array();
211
+ $datas = array();
212
+
213
+ while($dateStart->compare($dateEnd) < 0){
214
+ switch ($this->getDataHelper()->getParam('period')) {
215
+ case '24h':
216
+ $d = $dateStart->toString('yyyy-MM-dd HH:00');
217
+ $dateStart->addHour(1);
218
+ break;
219
+ case '7d':
220
+ case '1m':
221
+ $d = $dateStart->toString('yyyy-MM-dd');
222
+ $dateStart->addDay(1);
223
+ break;
224
+ case '1y':
225
+ case '2y':
226
+ $d = $dateStart->toString('yyyy-MM');
227
+ $dateStart->addMonth(1);
228
+ break;
229
+ }
230
+ foreach ($this->getAllSeries() as $index=>$serie) {
231
+ if (in_array($d, $this->_axisLabels['x'])) {
232
+ $datas[$index][] = (float)array_shift($this->_allSeries[$index]);
233
+ } else {
234
+ $datas[$index][] = 0;
235
+ }
236
+ }
237
+ $dates[] = $d;
238
+ }
239
+
240
+ /**
241
+ * setting skip step
242
+ */
243
+ if (count($dates) > 8 && count($dates) < 15) {
244
+ $c = 1;
245
+ } else if (count($dates) >= 15){
246
+ $c = 2;
247
+ } else {
248
+ $c = 0;
249
+ }
250
+ /**
251
+ * skipping some x labels for good reading
252
+ */
253
+ $i=0;
254
+ foreach ($dates as $k => $d) {
255
+ if ($i == $c) {
256
+ $dates[$k] = $d;
257
+ $i = 0;
258
+ } else {
259
+ $dates[$k] = '';
260
+ $i++;
261
+ }
262
+ }
263
+
264
+ $this->_axisLabels['x'] = $dates;
265
+ $this->_allSeries = $datas;
266
+
267
+ //Google encoding values
268
+ if ($this->_encoding == "s") {
269
+ // simple encoding
270
+ $params['chd'] = "s:";
271
+ $dataDelimiter = "";
272
+ $dataSetdelimiter = ",";
273
+ $dataMissing = "_";
274
+ } else {
275
+ // extended encoding
276
+ $params['chd'] = "e:";
277
+ $dataDelimiter = "";
278
+ $dataSetdelimiter = ",";
279
+ $dataMissing = "__";
280
+ }
281
+
282
+ // process each string in the array, and find the max length
283
+ foreach ($this->getAllSeries() as $index => $serie) {
284
+ $localmaxlength[$index] = sizeof($serie);
285
+ $localmaxvalue[$index] = max($serie);
286
+ $localminvalue[$index] = min($serie);
287
+ }
288
+
289
+ if (is_numeric($this->_max)) {
290
+ $maxvalue = $this->_max;
291
+ } else {
292
+ $maxvalue = max($localmaxvalue);
293
+ }
294
+ if (is_numeric($this->_min)) {
295
+ $minvalue = $this->_min;
296
+ } else {
297
+ $minvalue = min($localminvalue);
298
+ }
299
+
300
+ // default values
301
+ $yrange = 0;
302
+ $yLabels = array();
303
+ $miny = 0;
304
+ $maxy = 0;
305
+ $yorigin = 0;
306
+
307
+ $maxlength = max($localmaxlength);
308
+ if ($minvalue >= 0 && $maxvalue >= 0) {
309
+ $miny = 0;
310
+ if ($maxvalue > 10) {
311
+ $p = pow(10, $this->_getPow($maxvalue));
312
+ $maxy = (ceil($maxvalue/$p))*$p;
313
+ $yLabels = range($miny, $maxy, $p);
314
+ } else {
315
+ $maxy = ceil($maxvalue+1);
316
+ $yLabels = range($miny, $maxy, 1);
317
+ }
318
+ $yrange = $maxy;
319
+ $yorigin = 0;
320
+ }
321
+
322
+ $chartdata = array();
323
+
324
+ foreach ($this->getAllSeries() as $index => $serie) {
325
+ $thisdataarray = $serie;
326
+ if ($this->_encoding == "s") {
327
+ // SIMPLE ENCODING
328
+ for ($j = 0; $j < sizeof($thisdataarray); $j++) {
329
+ $currentvalue = $thisdataarray[$j];
330
+ if (is_numeric($currentvalue)) {
331
+ $ylocation = round((strlen($this->_simpleEncoding)-1) * ($yorigin + $currentvalue) / $yrange);
332
+ array_push($chartdata, substr($this->_simpleEncoding, $ylocation, 1) . $dataDelimiter);
333
+ } else {
334
+ array_push($chartdata, $dataMissing . $dataDelimiter);
335
+ }
336
+ }
337
+ // END SIMPLE ENCODING
338
+ } else {
339
+ // EXTENDED ENCODING
340
+ for ($j = 0; $j < sizeof($thisdataarray); $j++) {
341
+ $currentvalue = $thisdataarray[$j];
342
+ if (is_numeric($currentvalue)) {
343
+ if ($yrange) {
344
+ $ylocation = (4095 * ($yorigin + $currentvalue) / $yrange);
345
+ } else {
346
+ $ylocation = 0;
347
+ }
348
+ $firstchar = floor($ylocation / 64);
349
+ $secondchar = $ylocation % 64;
350
+ $mappedchar = substr($this->_extendedEncoding, $firstchar, 1)
351
+ . substr($this->_extendedEncoding, $secondchar, 1);
352
+ array_push($chartdata, $mappedchar . $dataDelimiter);
353
+ } else {
354
+ array_push($chartdata, $dataMissing . $dataDelimiter);
355
+ }
356
+ }
357
+ // ============= END EXTENDED ENCODING =============
358
+ }
359
+ array_push($chartdata, $dataSetdelimiter);
360
+ }
361
+ $buffer = implode('', $chartdata);
362
+
363
+ $buffer = rtrim($buffer, $dataSetdelimiter);
364
+ $buffer = rtrim($buffer, $dataDelimiter);
365
+ $buffer = str_replace(($dataDelimiter . $dataSetdelimiter), $dataSetdelimiter, $buffer);
366
+
367
+ $params['chd'] .= $buffer;
368
+
369
+ $labelBuffer = "";
370
+ $valueBuffer = array();
371
+ $rangeBuffer = "";
372
+
373
+ if (sizeof($this->_axisLabels) > 0) {
374
+ $params['chxt'] = implode(',', array_keys($this->_axisLabels));
375
+ $indexid = 0;
376
+ foreach ($this->_axisLabels as $idx=>$labels){
377
+ if ($idx == 'x') {
378
+ /**
379
+ * Format date
380
+ */
381
+ foreach ($this->_axisLabels[$idx] as $_index=>$_label) {
382
+ if ($_label != '') {
383
+ switch ($this->getDataHelper()->getParam('period')) {
384
+ case '24h':
385
+ $this->_axisLabels[$idx][$_index] = $this->formatTime(
386
+ new Zend_Date($_label, 'yyyy-MM-dd HH:00'), 'short', false
387
+ );
388
+ break;
389
+ case '7d':
390
+ case '1m':
391
+ $this->_axisLabels[$idx][$_index] = $this->formatDate(
392
+ new Zend_Date($_label, 'yyyy-MM-dd')
393
+ );
394
+ break;
395
+ case '1y':
396
+ case '2y':
397
+ $formats = Mage::app()->getLocale()->getTranslationList('datetime');
398
+ $format = isset($formats['yyMM']) ? $formats['yyMM'] : 'MM/yyyy';
399
+ $format = str_replace(array("yyyy", "yy", "MM"), array("Y", "y", "m"), $format);
400
+ $this->_axisLabels[$idx][$_index] = date($format, strtotime($_label));
401
+ break;
402
+ }
403
+ } else {
404
+ $this->_axisLabels[$idx][$_index] = '';
405
+ }
406
+
407
+ }
408
+
409
+ $tmpstring = implode('|', $this->_axisLabels[$idx]);
410
+
411
+ $valueBuffer[] = $indexid . ":|" . $tmpstring;
412
+ if (sizeof($this->_axisLabels[$idx]) > 1) {
413
+ $deltaX = 100/(sizeof($this->_axisLabels[$idx])-1);
414
+ } else {
415
+ $deltaX = 100;
416
+ }
417
+ } else if ($idx == 'y') {
418
+ $valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
419
+ if (sizeof($yLabels)-1) {
420
+ $deltaY = 100/(sizeof($yLabels)-1);
421
+ } else {
422
+ $deltaY = 100;
423
+ }
424
+ // setting range values for y axis
425
+ $rangeBuffer = $indexid . "," . $miny . "," . $maxy . "|";
426
+ }
427
+ $indexid++;
428
+ }
429
+ $params['chxl'] = implode('|', $valueBuffer);
430
+ };
431
+
432
+ // chart size
433
+ $params['chs'] = $this->getWidth().'x'.$this->getHeight();
434
+
435
+ if (isset($deltaX) && isset($deltaY)) {
436
+ $params['chg'] = $deltaX . ',' . $deltaY . ',1,0';
437
+ }
438
+
439
+ // return the encoded data
440
+ if ($directUrl) {
441
+ $p = array();
442
+ foreach ($params as $name => $value) {
443
+ $p[] = $name . '=' .urlencode($value);
444
+ }
445
+ return self::API_URL . '?' . implode('&', $p);
446
+ } else {
447
+ $gaData = urlencode(base64_encode(serialize($params)));
448
+ $gaHash = Mage::helper('adminhtml/dashboard_data')->getChartDataHash($gaData);
449
+ $params = array('ga' => $gaData, 'h' => $gaHash);
450
+ return $this->getUrl('*/*/tunnel', array('_query' => $params));
451
+ }
452
+ }
453
+
454
+ /**
455
+ * Get rows data
456
+ *
457
+ * @param array $attributes
458
+ * @param bool $single
459
+ * @return array
460
+ */
461
+ protected function getRowsData($attributes, $single = false)
462
+ {
463
+ $items = $this->getCollection()->getItems();
464
+ $options = array();
465
+ foreach ($items as $item){
466
+ if ($single) {
467
+ $options[] = max(0, $item->getData($attributes));
468
+ } else {
469
+ foreach ((array)$attributes as $attr){
470
+ $options[$attr][] = max(0, $item->getData($attr));
471
+ }
472
+ }
473
+ }
474
+ return $options;
475
+ }
476
+
477
+ /**
478
+ * Set axis labels
479
+ *
480
+ * @param string $axis
481
+ * @param array $labels
482
+ * @return void
483
+ */
484
+ public function setAxisLabels($axis, $labels)
485
+ {
486
+ $this->_axisLabels[$axis] = $labels;
487
+ }
488
+
489
+ /**
490
+ * Set html id
491
+ *
492
+ * @param string $htmlId
493
+ * @return void
494
+ */
495
+ public function setHtmlId($htmlId)
496
+ {
497
+ $this->_htmlId = $htmlId;
498
+ }
499
+
500
+ /**
501
+ * Get html id
502
+ *
503
+ * @return string
504
+ */
505
+ public function getHtmlId()
506
+ {
507
+ return $this->_htmlId;
508
+ }
509
+
510
+ /**
511
+ * Return pow
512
+ *
513
+ * @param int $number
514
+ * @return int
515
+ */
516
+ protected function _getPow($number)
517
+ {
518
+ $pow = 0;
519
+ while ($number >= 10) {
520
+ $number = $number/10;
521
+ $pow++;
522
+ }
523
+ return $pow;
524
+ }
525
+
526
+ /**
527
+ * Return chart width
528
+ *
529
+ * @return string
530
+ */
531
+ protected function getWidth()
532
+ {
533
+ return $this->_width;
534
+ }
535
+
536
+ /**
537
+ * Return chart height
538
+ *
539
+ * @return string
540
+ */
541
+ protected function getHeight()
542
+ {
543
+ return $this->_height;
544
+ }
545
+
546
+ /**
547
+ * Prepare chart data
548
+ *
549
+ * @return void
550
+ */
551
+ protected function _prepareData()
552
+ {
553
+ $availablePeriods = array_keys($this->helper('adminhtml/dashboard_data')->getDatePeriods());
554
+ $period = $this->getRequest()->getParam('period');
555
+
556
+ $this->getDataHelper()->setParam('period',
557
+ ($period && in_array($period, $availablePeriods)) ? $period : '24h'
558
+ );
559
+ }
560
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Grid.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Grid extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+
38
+ /**
39
+ * Setting default for every grid on dashboard
40
+ *
41
+ */
42
+
43
+ public function __construct()
44
+ {
45
+ parent::__construct();
46
+ $this->setTemplate('dashboard/grid.phtml');
47
+ $this->setDefaultLimit(5);
48
+ }
49
+ }
50
+
app/code/core/Mage/Adminhtml/Block/Dashboard/Grids.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard bottom tabs
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Grids extends Mage_Adminhtml_Block_Widget_Tabs
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('grid_tab');
41
+ $this->setDestElementId('grid_tab_content');
42
+ $this->setTemplate('widget/tabshoriz.phtml');
43
+ }
44
+
45
+ /**
46
+ * Prepare layout for dashboard bottom tabs
47
+ *
48
+ * To load block statically:
49
+ * 1) content must be generated
50
+ * 2) url should not be specified
51
+ * 3) class should not be 'ajax'
52
+ * To load with ajax:
53
+ * 1) do not load content
54
+ * 2) specify url (BE CAREFUL)
55
+ * 3) specify class 'ajax'
56
+ *
57
+ * @return Mage_Adminhtml_Block_Dashboard_Grids
58
+ */
59
+ protected function _prepareLayout()
60
+ {
61
+ // load this active tab statically
62
+ $this->addTab('ordered_products', array(
63
+ 'label' => $this->__('Bestsellers'),
64
+ 'content' => $this->getLayout()->createBlock('adminhtml/dashboard_tab_products_ordered')->toHtml(),
65
+ 'active' => true
66
+ ));
67
+
68
+ // load other tabs with ajax
69
+ $this->addTab('reviewed_products', array(
70
+ 'label' => $this->__('Most Viewed Products'),
71
+ 'url' => $this->getUrl('*/*/productsViewed', array('_current'=>true)),
72
+ 'class' => 'ajax'
73
+ ));
74
+
75
+ $this->addTab('new_customers', array(
76
+ 'label' => $this->__('New Customers'),
77
+ 'url' => $this->getUrl('*/*/customersNewest', array('_current'=>true)),
78
+ 'class' => 'ajax'
79
+ ));
80
+
81
+ $this->addTab('customers', array(
82
+ 'label' => $this->__('Customers'),
83
+ 'url' => $this->getUrl('*/*/customersMost', array('_current'=>true)),
84
+ 'class' => 'ajax'
85
+ ));
86
+
87
+ return parent::_prepareLayout();
88
+ }
89
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard recent orders grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Orders_Grid extends Mage_Adminhtml_Block_Dashboard_Grid
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setId('lastOrdersGrid');
42
+ }
43
+
44
+ protected function _prepareCollection()
45
+ {
46
+ if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
47
+ return $this;
48
+ }
49
+ $collection = Mage::getResourceModel('reports/order_collection')
50
+ ->addItemCountExpr()
51
+ ->joinCustomerName('customer')
52
+ ->orderByCreatedAt();
53
+
54
+ if($this->getParam('store') || $this->getParam('website') || $this->getParam('group')) {
55
+ if ($this->getParam('store')) {
56
+ $collection->addAttributeToFilter('store_id', $this->getParam('store'));
57
+ } else if ($this->getParam('website')){
58
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
59
+ $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
60
+ } else if ($this->getParam('group')){
61
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
62
+ $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
63
+ }
64
+
65
+ $collection->addRevenueToSelect();
66
+ } else {
67
+ $collection->addRevenueToSelect(true);
68
+ }
69
+
70
+ $this->setCollection($collection);
71
+
72
+ return parent::_prepareCollection();
73
+ }
74
+
75
+ /**
76
+ * Prepares page sizes for dashboard grid with las 5 orders
77
+ *
78
+ * @return void
79
+ */
80
+ protected function _preparePage()
81
+ {
82
+ $this->getCollection()->setPageSize($this->getParam($this->getVarNameLimit(), $this->_defaultLimit));
83
+ // Remove count of total orders $this->getCollection()->setCurPage($this->getParam($this->getVarNamePage(), $this->_defaultPage));
84
+ }
85
+
86
+ protected function _prepareColumns()
87
+ {
88
+ $this->addColumn('customer', array(
89
+ 'header' => $this->__('Customer'),
90
+ 'sortable' => false,
91
+ 'index' => 'customer',
92
+ 'default' => $this->__('Guest'),
93
+ ));
94
+
95
+ $this->addColumn('items', array(
96
+ 'header' => $this->__('Items'),
97
+ 'align' => 'right',
98
+ 'type' => 'number',
99
+ 'sortable' => false,
100
+ 'index' => 'items_count'
101
+ ));
102
+
103
+ $baseCurrencyCode = Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode();
104
+
105
+ $this->addColumn('total', array(
106
+ 'header' => $this->__('Grand Total'),
107
+ 'align' => 'right',
108
+ 'sortable' => false,
109
+ 'type' => 'currency',
110
+ 'currency_code' => $baseCurrencyCode,
111
+ 'index' => 'revenue'
112
+ ));
113
+
114
+ $this->setFilterVisibility(false);
115
+ $this->setPagerVisibility(false);
116
+
117
+ return parent::_prepareColumns();
118
+ }
119
+
120
+ public function getRowUrl($row)
121
+ {
122
+ return $this->getUrl('*/sales_order/view', array('order_id'=>$row->getId()));
123
+ }
124
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Sales.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard sales statistics bar
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Sales extends Mage_Adminhtml_Block_Dashboard_Bar
36
+ {
37
+ protected function _construct()
38
+ {
39
+ parent::_construct();
40
+ $this->setTemplate('dashboard/salebar.phtml');
41
+
42
+
43
+ }
44
+
45
+ protected function _prepareLayout()
46
+ {
47
+ if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
48
+ return $this;
49
+ }
50
+ $isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
51
+
52
+ $collection = Mage::getResourceModel('reports/order_collection')
53
+ ->calculateSales($isFilter);
54
+
55
+ if ($this->getRequest()->getParam('store')) {
56
+ $collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
57
+ } else if ($this->getRequest()->getParam('website')){
58
+ $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
59
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
60
+ } else if ($this->getRequest()->getParam('group')){
61
+ $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
62
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
63
+ }
64
+
65
+ $collection->load();
66
+ $sales = $collection->getFirstItem();
67
+
68
+ $this->addTotal($this->__('Lifetime Sales'), $sales->getLifetime());
69
+ $this->addTotal($this->__('Average Orders'), $sales->getAverage());
70
+ }
71
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Last.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard last search keywords block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Searches_Last extends Mage_Adminhtml_Block_Dashboard_Grid
36
+ {
37
+ protected $_collection;
38
+
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setId('lastSearchGrid');
43
+ }
44
+
45
+ protected function _prepareCollection()
46
+ {
47
+ if (!Mage::helper('core')->isModuleEnabled('Mage_CatalogSearch')) {
48
+ return parent::_prepareCollection();
49
+ }
50
+ $this->_collection = Mage::getModel('catalogsearch/query')
51
+ ->getResourceCollection();
52
+ $this->_collection->setRecentQueryFilter();
53
+
54
+ if ($this->getRequest()->getParam('store')) {
55
+ $this->_collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
56
+ } else if ($this->getRequest()->getParam('website')){
57
+ $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
58
+ $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
59
+ } else if ($this->getRequest()->getParam('group')){
60
+ $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
61
+ $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
62
+ }
63
+
64
+ $this->setCollection($this->_collection);
65
+
66
+ return parent::_prepareCollection();
67
+ }
68
+
69
+ protected function _prepareColumns()
70
+ {
71
+ $this->addColumn('search_query', array(
72
+ 'header' => $this->__('Search Term'),
73
+ 'sortable' => false,
74
+ 'index' => 'query_text',
75
+ 'renderer' => 'adminhtml/dashboard_searches_renderer_searchquery',
76
+ ));
77
+
78
+ $this->addColumn('num_results', array(
79
+ 'header' => $this->__('Results'),
80
+ 'sortable' => false,
81
+ 'index' => 'num_results',
82
+ 'type' => 'number'
83
+ ));
84
+
85
+ $this->addColumn('popularity', array(
86
+ 'header' => $this->__('Number of Uses'),
87
+ 'sortable' => false,
88
+ 'index' => 'popularity',
89
+ 'type' => 'number'
90
+ ));
91
+
92
+ $this->setFilterVisibility(false);
93
+ $this->setPagerVisibility(false);
94
+
95
+ return parent::_prepareColumns();
96
+ }
97
+
98
+ public function getRowUrl($row)
99
+ {
100
+ return $this->getUrl('*/catalog_search/edit', array('id'=>$row->getId()));
101
+ }
102
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Dashboard search query column renderer
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ */
34
+ class Mage_Adminhtml_Block_Dashboard_Searches_Renderer_Searchquery extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
35
+ {
36
+ public function render(Varien_Object $row)
37
+ {
38
+ $value = $row->getData($this->getColumn()->getIndex());
39
+ if (Mage::helper('core/string')->strlen($value) > 30) {
40
+ $value = '<span title="'. $this->htmlEscape($value) .'">' . $this->htmlEscape(Mage::helper('core/string')->truncate($value, 30)) . '</span>';
41
+ }
42
+ else {
43
+ $value = $this->htmlEscape($value);
44
+ }
45
+ return $value;
46
+ }
47
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Top.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard last search keywords block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Searches_Top extends Mage_Adminhtml_Block_Dashboard_Grid
36
+ {
37
+ protected $_collection;
38
+
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setId('topSearchGrid');
43
+ }
44
+
45
+ protected function _prepareCollection()
46
+ {
47
+ if (!Mage::helper('core')->isModuleEnabled('Mage_CatalogSearch')) {
48
+ return parent::_prepareCollection();
49
+ }
50
+ $this->_collection = Mage::getModel('catalogsearch/query')
51
+ ->getResourceCollection();
52
+
53
+ if ($this->getRequest()->getParam('store')) {
54
+ $storeIds = $this->getRequest()->getParam('store');
55
+ } else if ($this->getRequest()->getParam('website')){
56
+ $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
57
+ } else if ($this->getRequest()->getParam('group')){
58
+ $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
59
+ } else {
60
+ $storeIds = '';
61
+ }
62
+
63
+ $this->_collection
64
+ ->setPopularQueryFilter($storeIds);
65
+
66
+ $this->setCollection($this->_collection);
67
+
68
+ return parent::_prepareCollection();
69
+ }
70
+
71
+ protected function _prepareColumns()
72
+ {
73
+ $this->addColumn('search_query', array(
74
+ 'header' => $this->__('Search Term'),
75
+ 'sortable' => false,
76
+ 'index' => 'name',
77
+ 'renderer' => 'adminhtml/dashboard_searches_renderer_searchquery',
78
+ ));
79
+
80
+ $this->addColumn('num_results', array(
81
+ 'header' => $this->__('Results'),
82
+ 'sortable' => false,
83
+ 'index' => 'num_results',
84
+ 'type' => 'number'
85
+ ));
86
+
87
+ $this->addColumn('popularity', array(
88
+ 'header' => $this->__('Number of Uses'),
89
+ 'sortable' => false,
90
+ 'index' => 'popularity',
91
+ 'type' => 'number'
92
+ ));
93
+
94
+ $this->setFilterVisibility(false);
95
+ $this->setPagerVisibility(false);
96
+
97
+ return parent::_prepareColumns();
98
+ }
99
+
100
+ public function getRowUrl($row)
101
+ {
102
+ return $this->getUrl('*/catalog_search/edit', array('id'=>$row->getId()));
103
+ }
104
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Amounts.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard order amounts diagram
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Tab_Amounts extends Mage_Adminhtml_Block_Dashboard_Graph
36
+ {
37
+ /**
38
+ * Initialize object
39
+ *
40
+ * @return void
41
+ */
42
+ public function __construct()
43
+ {
44
+ $this->setHtmlId('amounts');
45
+ parent::__construct();
46
+ }
47
+
48
+ /**
49
+ * Prepare chart data
50
+ *
51
+ * @return void
52
+ */
53
+ protected function _prepareData()
54
+ {
55
+ $this->setDataHelperName('adminhtml/dashboard_order');
56
+ $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store'));
57
+ $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website'));
58
+ $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group'));
59
+
60
+ $this->setDataRows('revenue');
61
+ $this->_axisMaps = array(
62
+ 'x' => 'range',
63
+ 'y' => 'revenue'
64
+ );
65
+
66
+ parent::_prepareData();
67
+ }
68
+ }
69
+
app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Most.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard most active buyers
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Tab_Customers_Most extends Mage_Adminhtml_Block_Dashboard_Grid
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setId('customersMostGrid');
42
+ }
43
+
44
+ protected function _prepareCollection()
45
+ {
46
+ $collection = Mage::getResourceModel('reports/order_collection');
47
+ /* @var $collection Mage_Reports_Model_Mysql4_Order_Collection */
48
+ $collection
49
+ ->groupByCustomer()
50
+ ->addOrdersCount()
51
+ ->joinCustomerName();
52
+
53
+ $storeFilter = 0;
54
+ if ($this->getParam('store')) {
55
+ $collection->addAttributeToFilter('store_id', $this->getParam('store'));
56
+ $storeFilter = 1;
57
+ } else if ($this->getParam('website')){
58
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
59
+ $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
60
+ } else if ($this->getParam('group')){
61
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
62
+ $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
63
+ }
64
+
65
+ $collection->addSumAvgTotals($storeFilter)
66
+ ->orderByTotalAmount();
67
+
68
+ $this->setCollection($collection);
69
+
70
+ return parent::_prepareCollection();
71
+ }
72
+
73
+ protected function _prepareColumns()
74
+ {
75
+ $this->addColumn('name', array(
76
+ 'header' => $this->__('Customer Name'),
77
+ 'sortable' => false,
78
+ 'index' => 'name'
79
+ ));
80
+
81
+ $this->addColumn('orders_count', array(
82
+ 'header' => $this->__('Number of Orders'),
83
+ 'sortable' => false,
84
+ 'index' => 'orders_count',
85
+ 'type' => 'number'
86
+ ));
87
+
88
+ $baseCurrencyCode = (string) Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode();
89
+
90
+ $this->addColumn('orders_avg_amount', array(
91
+ 'header' => $this->__('Average Order Amount'),
92
+ 'align' => 'right',
93
+ 'sortable' => false,
94
+ 'type' => 'currency',
95
+ 'currency_code' => $baseCurrencyCode,
96
+ 'index' => 'orders_avg_amount'
97
+ ));
98
+
99
+ $this->addColumn('orders_sum_amount', array(
100
+ 'header' => $this->__('Total Order Amount'),
101
+ 'align' => 'right',
102
+ 'sortable' => false,
103
+ 'type' => 'currency',
104
+ 'currency_code' => $baseCurrencyCode,
105
+ 'index' => 'orders_sum_amount'
106
+ ));
107
+
108
+ $this->setFilterVisibility(false);
109
+ $this->setPagerVisibility(false);
110
+
111
+ return parent::_prepareColumns();
112
+ }
113
+
114
+ public function getRowUrl($row)
115
+ {
116
+ return $this->getUrl('*/customer/edit', array('id'=>$row->getCustomerId()));
117
+ }
118
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Customers/Newest.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard most recent customers grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Tab_Customers_Newest extends Mage_Adminhtml_Block_Dashboard_Grid
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setId('customersNewestGrid');
42
+ }
43
+
44
+ protected function _prepareCollection()
45
+ {
46
+ $collection = Mage::getResourceModel('reports/customer_collection')
47
+ ->addCustomerName();
48
+
49
+ $storeFilter = 0;
50
+ if ($this->getParam('store')) {
51
+ $collection->addAttributeToFilter('store_id', $this->getParam('store'));
52
+ $storeFilter = 1;
53
+ } else if ($this->getParam('website')){
54
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
55
+ $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
56
+ } else if ($this->getParam('group')){
57
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
58
+ $collection->addAttributeToFilter('store_id', array('in' => $storeIds));
59
+ }
60
+
61
+ $collection->addOrdersStatistics($storeFilter)
62
+ ->orderByCustomerRegistration();
63
+
64
+ $this->setCollection($collection);
65
+
66
+ return parent::_prepareCollection();
67
+ }
68
+
69
+ protected function _prepareColumns()
70
+ {
71
+ $this->addColumn('name', array(
72
+ 'header' => $this->__('Customer Name'),
73
+ 'sortable' => false,
74
+ 'index' => 'name'
75
+ ));
76
+
77
+ $this->addColumn('orders_count', array(
78
+ 'header' => $this->__('Number of Orders'),
79
+ 'sortable' => false,
80
+ 'index' => 'orders_count',
81
+ 'type' => 'number'
82
+ ));
83
+
84
+ $baseCurrencyCode = (string) Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode();
85
+
86
+ $this->addColumn('orders_avg_amount', array(
87
+ 'header' => $this->__('Average Order Amount'),
88
+ 'align' => 'right',
89
+ 'sortable' => false,
90
+ 'type' => 'currency',
91
+ 'currency_code' => $baseCurrencyCode,
92
+ 'index' => 'orders_avg_amount',
93
+ 'renderer' =>'adminhtml/report_grid_column_renderer_currency'
94
+ ));
95
+
96
+ $this->addColumn('orders_sum_amount', array(
97
+ 'header' => $this->__('Total Order Amount'),
98
+ 'align' => 'right',
99
+ 'sortable' => false,
100
+ 'type' => 'currency',
101
+ 'currency_code' => $baseCurrencyCode,
102
+ 'index' => 'orders_sum_amount',
103
+ 'renderer' =>'adminhtml/report_grid_column_renderer_currency'
104
+ ));
105
+
106
+ $this->setFilterVisibility(false);
107
+ $this->setPagerVisibility(false);
108
+
109
+ return parent::_prepareColumns();
110
+ }
111
+
112
+ public function getRowUrl($row)
113
+ {
114
+ return $this->getUrl('*/customer/edit', array('id'=>$row->getId()));
115
+ }
116
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Orders.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard orders diagram
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Tab_Orders extends Mage_Adminhtml_Block_Dashboard_Graph
36
+ {
37
+ /**
38
+ * Initialize object
39
+ *
40
+ * @return void
41
+ */
42
+ public function __construct()
43
+ {
44
+ $this->setHtmlId('orders');
45
+ parent::__construct();
46
+ }
47
+
48
+ /**
49
+ * Prepare chart data
50
+ *
51
+ * @return void
52
+ */
53
+ protected function _prepareData()
54
+ {
55
+ $this->setDataHelperName('adminhtml/dashboard_order');
56
+ $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store'));
57
+ $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website'));
58
+ $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group'));
59
+
60
+ $this->setDataRows('quantity');
61
+ $this->_axisMaps = array(
62
+ 'x' => 'range',
63
+ 'y' => 'quantity'
64
+ );
65
+
66
+ parent::_prepareData();
67
+ }
68
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Products/Ordered.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard most ordered products grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Tab_Products_Ordered extends Mage_Adminhtml_Block_Dashboard_Grid
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setId('productsOrderedGrid');
42
+ }
43
+
44
+ protected function _prepareCollection()
45
+ {
46
+ if (!Mage::helper('core')->isModuleEnabled('Mage_Sales')) {
47
+ return $this;
48
+ }
49
+ if ($this->getParam('website')) {
50
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
51
+ $storeId = array_pop($storeIds);
52
+ } else if ($this->getParam('group')) {
53
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
54
+ $storeId = array_pop($storeIds);
55
+ } else {
56
+ $storeId = (int)$this->getParam('store');
57
+ }
58
+
59
+ $collection = Mage::getResourceModel('sales/report_bestsellers_collection')
60
+ ->setModel('catalog/product')
61
+ ->addStoreFilter($storeId)
62
+ ;
63
+
64
+ $this->setCollection($collection);
65
+
66
+ return parent::_prepareCollection();
67
+ }
68
+
69
+ protected function _prepareColumns()
70
+ {
71
+
72
+ $this->addColumn('name', array(
73
+ 'header' => Mage::helper('sales')->__('Product Name'),
74
+ 'sortable' => false,
75
+ 'index' => 'product_name'
76
+ ));
77
+
78
+ $this->addColumn('price', array(
79
+ 'header' => Mage::helper('sales')->__('Price'),
80
+ 'width' => '120px',
81
+ 'type' => 'currency',
82
+ 'currency_code' => (string) Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode(),
83
+ 'sortable' => false,
84
+ 'index' => 'product_price'
85
+ ));
86
+
87
+ $this->addColumn('ordered_qty', array(
88
+ 'header' => Mage::helper('sales')->__('Quantity Ordered'),
89
+ 'width' => '120px',
90
+ 'align' => 'right',
91
+ 'sortable' => false,
92
+ 'index' => 'qty_ordered',
93
+ 'type' => 'number'
94
+ ));
95
+
96
+ $this->setFilterVisibility(false);
97
+ $this->setPagerVisibility(false);
98
+
99
+ return parent::_prepareColumns();
100
+ }
101
+
102
+ /*
103
+ * Returns row url to show in admin dashboard
104
+ * $row is bestseller row wrapped in Product model
105
+ *
106
+ * @param Mage_Catalog_Model_Product $row
107
+ *
108
+ * @return string
109
+ */
110
+ public function getRowUrl($row)
111
+ {
112
+ // getId() would return id of bestseller row, and product id we get by getProductId()
113
+ $productId = $row->getProductId();
114
+
115
+ // No url is possible for non-existing products
116
+ if (!$productId) {
117
+ return '';
118
+ }
119
+
120
+ $params = array('id' => $productId);
121
+ if ($this->getRequest()->getParam('store')) {
122
+ $params['store'] = $this->getRequest()->getParam('store');
123
+ }
124
+ return $this->getUrl('*/catalog_product/edit', $params);
125
+ }
126
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Tab/Products/Viewed.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard most viewed products grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Dashboard_Tab_Products_Viewed extends Mage_Adminhtml_Block_Dashboard_Grid
36
+ {
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setId('productsReviewedGrid');
42
+ }
43
+
44
+ protected function _prepareCollection()
45
+ {
46
+ if ($this->getParam('website')) {
47
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
48
+ $storeId = array_pop($storeIds);
49
+ } else if ($this->getParam('group')) {
50
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
51
+ $storeId = array_pop($storeIds);
52
+ } else {
53
+ $storeId = (int)$this->getParam('store');
54
+ }
55
+ $collection = Mage::getResourceModel('reports/product_collection')
56
+ ->addAttributeToSelect('*')
57
+ ->addViewsCount()
58
+ ->setStoreId($storeId)
59
+ ->addStoreFilter($storeId);
60
+
61
+ $this->setCollection($collection);
62
+
63
+ return parent::_prepareCollection();
64
+ }
65
+
66
+ protected function _prepareColumns()
67
+ {
68
+ $this->addColumn('name', array(
69
+ 'header' =>Mage::helper('reports')->__('Product Name'),
70
+ 'sortable' => false,
71
+ 'index' =>'name'
72
+ ));
73
+
74
+ $this->addColumn('price', array(
75
+ 'header' =>Mage::helper('reports')->__('Price'),
76
+ 'width' =>'120px',
77
+ 'type' =>'currency',
78
+ 'currency_code' => (string) Mage::app()->getStore((int)$this->getParam('store'))->getBaseCurrencyCode(),
79
+ 'sortable' => false,
80
+ 'index' =>'price'
81
+ ));
82
+
83
+ $this->addColumn('views', array(
84
+ 'header' =>Mage::helper('reports')->__('Number of Views'),
85
+ 'width' =>'120px',
86
+ 'align' =>'right',
87
+ 'sortable' => false,
88
+ 'index' =>'views'
89
+ ));
90
+
91
+ $this->setFilterVisibility(false);
92
+ $this->setPagerVisibility(false);
93
+
94
+ return parent::_prepareColumns();
95
+ }
96
+
97
+ public function getRowUrl($row)
98
+ {
99
+ $params = array('id'=>$row->getId());
100
+ if ($this->getRequest()->getParam('store')) {
101
+ $params['store'] = $this->getRequest()->getParam('store');
102
+ }
103
+ return $this->getUrl('*/catalog_product/edit', $params);
104
+ }
105
+ }
app/code/core/Mage/Adminhtml/Block/Dashboard/Totals.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml dashboard totals bar
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Dashboard_Totals extends Mage_Adminhtml_Block_Dashboard_Bar
36
+ {
37
+ protected function _construct()
38
+ {
39
+ parent::_construct();
40
+ $this->setTemplate('dashboard/totalbar.phtml');
41
+ }
42
+
43
+ protected function _prepareLayout()
44
+ {
45
+ if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
46
+ return $this;
47
+ }
48
+ $isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
49
+ $period = $this->getRequest()->getParam('period', '24h');
50
+
51
+ /* @var $collection Mage_Reports_Model_Mysql4_Order_Collection */
52
+ $collection = Mage::getResourceModel('reports/order_collection')
53
+ ->addCreateAtPeriodFilter($period)
54
+ ->calculateTotals($isFilter);
55
+
56
+ if ($this->getRequest()->getParam('store')) {
57
+ $collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
58
+ } else if ($this->getRequest()->getParam('website')){
59
+ $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
60
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
61
+ } else if ($this->getRequest()->getParam('group')){
62
+ $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
63
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
64
+ } elseif (!$collection->isLive()) {
65
+ $collection->addFieldToFilter('store_id',
66
+ array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId())
67
+ );
68
+ }
69
+
70
+ $collection->load();
71
+
72
+ $totals = $collection->getFirstItem();
73
+
74
+ $this->addTotal($this->__('Revenue'), $totals->getRevenue());
75
+ $this->addTotal($this->__('Tax'), $totals->getTax());
76
+ $this->addTotal($this->__('Shipping'), $totals->getShipping());
77
+ $this->addTotal($this->__('Quantity'), $totals->getQuantity()*1, true);
78
+ }
79
+ }
app/code/core/Mage/Adminhtml/Block/Denied.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Denied extends Mage_Adminhtml_Block_Template
28
+ {
29
+ public function hasAvailaleResources()
30
+ {
31
+ $user = Mage::getSingleton('admin/session')->getUser();
32
+ if ($user && $user->hasAvailableResources()) {
33
+ return true;
34
+ }
35
+ return false;
36
+ }
37
+ }
app/code/core/Mage/Adminhtml/Block/Html/Date.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml HTML select element block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Core
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Html_Date extends Mage_Core_Block_Html_Date
36
+ {
37
+
38
+ /**
39
+ * Enter description here...
40
+ *
41
+ * @return string
42
+ */
43
+ protected function _getUrlModelClass()
44
+ {
45
+ return 'adminhtml/url';
46
+ }
47
+
48
+ }
app/code/core/Mage/Adminhtml/Block/Html/Select.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml HTML select element block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Core
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Html_Select extends Mage_Core_Block_Html_Select
35
+ {
36
+
37
+ /**
38
+ * Enter description here...
39
+ *
40
+ * @return string
41
+ */
42
+ protected function _getUrlModelClass()
43
+ {
44
+ return 'adminhtml/url';
45
+ }
46
+
47
+ }
app/code/core/Mage/Adminhtml/Block/Media/Editor.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml media library image editor
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Media_Editor extends Mage_Adminhtml_Block_Widget
36
+ {
37
+
38
+ protected $_config;
39
+
40
+ public function __construct()
41
+ {
42
+ parent::__construct();
43
+ $this->setTemplate('media/editor.phtml');
44
+ $this->getConfig()->setImage($this->getSkinUrl('images/image.jpg'));
45
+ $this->getConfig()->setParams();
46
+ }
47
+
48
+ protected function _prepareLayout()
49
+ {
50
+ $this->setChild(
51
+ 'rotatecw_button',
52
+ $this->getLayout()->createBlock('adminhtml/widget_button')
53
+ ->addData(array(
54
+ 'id' => $this->_getButtonId('rotatecw'),
55
+ 'label' => Mage::helper('adminhtml')->__('Rotate CW'),
56
+ 'onclick' => $this->getJsObjectName() . '.rotateCw()'
57
+ ))
58
+ );
59
+
60
+ $this->setChild(
61
+ 'rotateccw_button',
62
+ $this->getLayout()->createBlock('adminhtml/widget_button')
63
+ ->addData(array(
64
+ 'id' => $this->_getButtonId('rotateccw'),
65
+ 'label' => Mage::helper('adminhtml')->__('Rotate CCW'),
66
+ 'onclick' => $this->getJsObjectName() . '.rotateCCw()'
67
+ ))
68
+ );
69
+
70
+ $this->setChild(
71
+ 'resize_button',
72
+ $this->getLayout()->createBlock('adminhtml/widget_button')
73
+ ->addData(array(
74
+ 'id' => $this->_getButtonId('upload'),
75
+ 'label' => Mage::helper('adminhtml')->__('Resize'),
76
+ 'onclick' => $this->getJsObjectName() . '.resize()'
77
+ ))
78
+ );
79
+
80
+ $this->setChild(
81
+ 'image_button',
82
+ $this->getLayout()->createBlock('adminhtml/widget_button')
83
+ ->addData(array(
84
+ 'id' => $this->_getButtonId('image'),
85
+ 'label' => Mage::helper('adminhtml')->__('Get Image Base64'),
86
+ 'onclick' => $this->getJsObjectName() . '.getImage()'
87
+ ))
88
+ );
89
+
90
+ return parent::_prepareLayout();
91
+ }
92
+
93
+ protected function _getButtonId($buttonName)
94
+ {
95
+ return $this->getHtmlId() . '-' . $buttonName;
96
+ }
97
+
98
+ public function getRotatecwButtonHtml()
99
+ {
100
+ return $this->getChildHtml('rotatecw_button');
101
+ }
102
+
103
+ public function getImageButtonHtml()
104
+ {
105
+ return $this->getChildHtml('image_button');
106
+ }
107
+
108
+ public function getRotateccwButtonHtml()
109
+ {
110
+ return $this->getChildHtml('rotateccw_button');
111
+ }
112
+
113
+ public function getResizeButtonHtml()
114
+ {
115
+ return $this->getChildHtml('resize_button');
116
+ }
117
+
118
+ /**
119
+ * Retrive uploader js object name
120
+ *
121
+ * @return string
122
+ */
123
+ public function getJsObjectName()
124
+ {
125
+ return $this->getHtmlId() . 'JsObject';
126
+ }
127
+
128
+ /**
129
+ * Retrive config json
130
+ *
131
+ * @return string
132
+ */
133
+ public function getConfigJson()
134
+ {
135
+ return Mage::helper('core')->jsonEncode($this->getConfig()->getData());
136
+ }
137
+
138
+ /**
139
+ * Retrive config object
140
+ *
141
+ * @return Varien_Config
142
+ */
143
+ public function getConfig()
144
+ {
145
+ if(is_null($this->_config)) {
146
+ $this->_config = new Varien_Object();
147
+ }
148
+
149
+ return $this->_config;
150
+ }
151
+
152
+ }
app/code/core/Mage/Adminhtml/Block/Media/Uploader.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml media library uploader
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Media_Uploader extends Mage_Adminhtml_Block_Widget
35
+ {
36
+
37
+ protected $_config;
38
+
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setId($this->getId() . '_Uploader');
43
+ $this->setTemplate('media/uploader.phtml');
44
+ $this->getConfig()->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/upload'));
45
+ $this->getConfig()->setParams(array('form_key' => $this->getFormKey()));
46
+ $this->getConfig()->setFileField('file');
47
+ $this->getConfig()->setFilters(array(
48
+ 'images' => array(
49
+ 'label' => Mage::helper('adminhtml')->__('Images (.gif, .jpg, .png)'),
50
+ 'files' => array('*.gif', '*.jpg', '*.png')
51
+ ),
52
+ 'media' => array(
53
+ 'label' => Mage::helper('adminhtml')->__('Media (.avi, .flv, .swf)'),
54
+ 'files' => array('*.avi', '*.flv', '*.swf')
55
+ ),
56
+ 'all' => array(
57
+ 'label' => Mage::helper('adminhtml')->__('All Files'),
58
+ 'files' => array('*.*')
59
+ )
60
+ ));
61
+ }
62
+
63
+ protected function _prepareLayout()
64
+ {
65
+ $this->setChild(
66
+ 'browse_button',
67
+ $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->addData(array(
69
+ 'id' => $this->_getButtonId('browse'),
70
+ 'label' => Mage::helper('adminhtml')->__('Browse Files...'),
71
+ 'type' => 'button',
72
+ 'onclick' => $this->getJsObjectName() . '.browse()'
73
+ ))
74
+ );
75
+
76
+ $this->setChild(
77
+ 'upload_button',
78
+ $this->getLayout()->createBlock('adminhtml/widget_button')
79
+ ->addData(array(
80
+ 'id' => $this->_getButtonId('upload'),
81
+ 'label' => Mage::helper('adminhtml')->__('Upload Files'),
82
+ 'type' => 'button',
83
+ 'onclick' => $this->getJsObjectName() . '.upload()'
84
+ ))
85
+ );
86
+
87
+ $this->setChild(
88
+ 'delete_button',
89
+ $this->getLayout()->createBlock('adminhtml/widget_button')
90
+ ->addData(array(
91
+ 'id' => '{{id}}-delete',
92
+ 'class' => 'delete',
93
+ 'type' => 'button',
94
+ 'label' => Mage::helper('adminhtml')->__('Remove'),
95
+ 'onclick' => $this->getJsObjectName() . '.removeFile(\'{{fileId}}\')'
96
+ ))
97
+ );
98
+
99
+ return parent::_prepareLayout();
100
+ }
101
+
102
+ protected function _getButtonId($buttonName)
103
+ {
104
+ return $this->getHtmlId() . '-' . $buttonName;
105
+ }
106
+
107
+ public function getBrowseButtonHtml()
108
+ {
109
+ return $this->getChildHtml('browse_button');
110
+ }
111
+
112
+ public function getUploadButtonHtml()
113
+ {
114
+ return $this->getChildHtml('upload_button');
115
+ }
116
+
117
+ public function getDeleteButtonHtml()
118
+ {
119
+ return $this->getChildHtml('delete_button');
120
+ }
121
+
122
+ /**
123
+ * Retrive uploader js object name
124
+ *
125
+ * @return string
126
+ */
127
+ public function getJsObjectName()
128
+ {
129
+ return $this->getHtmlId() . 'JsObject';
130
+ }
131
+
132
+ /**
133
+ * Retrive config json
134
+ *
135
+ * @return string
136
+ */
137
+ public function getConfigJson()
138
+ {
139
+ return Mage::helper('core')->jsonEncode($this->getConfig()->getData());
140
+ }
141
+
142
+ /**
143
+ * Retrive config object
144
+ *
145
+ * @return Varien_Config
146
+ */
147
+ public function getConfig()
148
+ {
149
+ if(is_null($this->_config)) {
150
+ $this->_config = new Varien_Object();
151
+ }
152
+
153
+ return $this->_config;
154
+ }
155
+
156
+ public function getPostMaxSize()
157
+ {
158
+ return ini_get('post_max_size');
159
+ }
160
+
161
+ public function getUploadMaxSize()
162
+ {
163
+ return ini_get('upload_max_filesize');
164
+ }
165
+
166
+ public function getDataMaxSize()
167
+ {
168
+ return min($this->getPostMaxSize(), $this->getUploadMaxSize());
169
+ }
170
+
171
+ public function getDataMaxSizeInBytes()
172
+ {
173
+ $iniSize = $this->getDataMaxSize();
174
+ $size = substr($iniSize, 0, strlen($iniSize)-1);
175
+ $parsedSize = 0;
176
+ switch (strtolower(substr($iniSize, strlen($iniSize)-1))) {
177
+ case 't':
178
+ $parsedSize = $size*(1024*1024*1024*1024);
179
+ break;
180
+ case 'g':
181
+ $parsedSize = $size*(1024*1024*1024);
182
+ break;
183
+ case 'm':
184
+ $parsedSize = $size*(1024*1024);
185
+ break;
186
+ case 'k':
187
+ $parsedSize = $size*1024;
188
+ break;
189
+ case 'b':
190
+ default:
191
+ $parsedSize = $size;
192
+ break;
193
+ }
194
+ return $parsedSize;
195
+ }
196
+
197
+ /**
198
+ * Retrive full uploader SWF's file URL
199
+ * Implemented to solve problem with cross domain SWFs
200
+ * Now uploader can be only in the same URL where backend located
201
+ *
202
+ * @param string url to uploader in current theme
203
+ * @return string full URL
204
+ */
205
+ public function getUploaderUrl($url)
206
+ {
207
+ if (!is_string($url)) {
208
+ $url = '';
209
+ }
210
+ $design = Mage::getDesign();
211
+ $theme = $design->getTheme('skin');
212
+ if (empty($url) || !$design->validateFile($url, array('_type' => 'skin', '_theme' => $theme))) {
213
+ $theme = $design->getDefaultTheme();
214
+ }
215
+ return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) .
216
+ $design->getArea() . '/' . $design->getPackageName() . '/' . $theme . '/' . $url;
217
+ }
218
+ }
app/code/core/Mage/Adminhtml/Block/Messages.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml messages block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Messages extends Mage_Core_Block_Messages
36
+ {
37
+
38
+ /**
39
+ * Enter description here...
40
+ *
41
+ * @return string
42
+ */
43
+ protected function _getUrlModelClass()
44
+ {
45
+ return 'adminhtml/url';
46
+ }
47
+
48
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Problem.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter problem block template.
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Problem extends Mage_Adminhtml_Block_Template
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setTemplate('newsletter/problem/list.phtml');
41
+ $collection = Mage::getResourceSingleton('newsletter/problem_collection')
42
+ ->addSubscriberInfo()
43
+ ->addQueueInfo();
44
+
45
+ }
46
+
47
+ protected function _prepareLayout()
48
+ {
49
+ $this->setChild('grid',
50
+ $this->getLayout()->createBlock('adminhtml/newsletter_problem_grid','newsletter.problem.grid')
51
+ );
52
+
53
+ $this->setChild('deleteButton',
54
+ $this->getLayout()->createBlock('adminhtml/widget_button','del.button')
55
+ ->setData(
56
+ array(
57
+ 'label' => Mage::helper('newsletter')->__('Delete Selected Problems'),
58
+ 'onclick' => 'problemController.deleteSelected();'
59
+ )
60
+ )
61
+ );
62
+
63
+ $this->setChild('unsubscribeButton',
64
+ $this->getLayout()->createBlock('adminhtml/widget_button','unsubscribe.button')
65
+ ->setData(
66
+ array(
67
+ 'label' => Mage::helper('newsletter')->__('Unsubscribe Selected'),
68
+ 'onclick' => 'problemController.unsubscribe();'
69
+ )
70
+ )
71
+ );
72
+ return parent::_prepareLayout();
73
+ }
74
+
75
+ public function getUnsubscribeButtonHtml()
76
+ {
77
+ return $this->getChildHtml('unsubscribeButton');
78
+ }
79
+
80
+ public function getDeleteButtonHtml()
81
+ {
82
+ return $this->getChildHtml('deleteButton');
83
+ }
84
+
85
+ public function getShowButtons()
86
+ {
87
+ return Mage::getResourceSingleton('newsletter/problem_collection')->getSize() > 0;
88
+ }
89
+
90
+ }// Class Mage_Adminhtml_Block_Newsletter_Problem END
app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter problem grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Problem_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setId('problemGrid');
40
+ $this->setSaveParametersInSession(true);
41
+ $this->setMessageBlockVisibility(true);
42
+ $this->setUseAjax(true);
43
+ $this->setEmptyText(Mage::helper('newsletter')->__('No problems found.'));
44
+ }
45
+
46
+ protected function _prepareCollection()
47
+ {
48
+ $collection = Mage::getResourceModel('newsletter/problem_collection')
49
+ ->addSubscriberInfo()
50
+ ->addQueueInfo();
51
+
52
+ $this->setCollection($collection);
53
+
54
+ return parent::_prepareCollection();
55
+ }
56
+
57
+ protected function _prepareColumns()
58
+ {
59
+ $this->addColumn('checkbox', array(
60
+ 'sortable' => false,
61
+ 'filter' => 'adminhtml/newsletter_problem_grid_filter_checkbox',
62
+ 'renderer' => 'adminhtml/newsletter_problem_grid_renderer_checkbox',
63
+ 'width' => '20px'
64
+ ));
65
+
66
+ $this->addColumn('problem_id', array(
67
+ 'header' => Mage::helper('newsletter')->__('ID'),
68
+ 'index' => 'problem_id',
69
+ 'width' => '50px'
70
+ ));
71
+
72
+ $this->addColumn('subscriber', array(
73
+ 'header' => Mage::helper('newsletter')->__('Subscriber'),
74
+ 'index' => 'subscriber_id',
75
+ 'format' => '#$subscriber_id $customer_name ($subscriber_email)'
76
+ ));
77
+
78
+ $this->addColumn('queue_start', array(
79
+ 'header' => Mage::helper('newsletter')->__('Queue Date Start'),
80
+ 'index' => 'queue_start_at',
81
+ 'gmtoffset' => true,
82
+ 'type' => 'datetime'
83
+ ));
84
+
85
+ $this->addColumn('queue', array(
86
+ 'header' => Mage::helper('newsletter')->__('Queue Subject'),
87
+ 'index' => 'template_subject'
88
+ ));
89
+
90
+ $this->addColumn('problem_code', array(
91
+ 'header' => Mage::helper('newsletter')->__('Error Code'),
92
+ 'index' => 'problem_error_code',
93
+ 'type' => 'number'
94
+ ));
95
+
96
+ $this->addColumn('problem_text', array(
97
+ 'header' => Mage::helper('newsletter')->__('Error Text'),
98
+ 'index' => 'problem_error_text'
99
+ ));
100
+ return parent::_prepareColumns();
101
+ }
102
+ }// Class Mage_Adminhtml_Block_Newsletter_Problem_Grid END
app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Filter/Checkbox.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter subscribers grid filter checkbox
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Problem_Grid_Filter_Checkbox extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract
36
+ {
37
+ public function getCondition()
38
+ {
39
+ return array();
40
+ }
41
+
42
+ public function getHtml()
43
+ {
44
+ return '<input type="checkbox" onclick="problemController.checkCheckboxes(this)"/>';
45
+ }
46
+ }// Class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid_Filter_Checkbox END
app/code/core/Mage/Adminhtml/Block/Newsletter/Problem/Grid/Renderer/Checkbox.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter subscribers grid checkbox item renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Problem_Grid_Renderer_Checkbox extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
36
+ {
37
+ /**
38
+ * Renders grid column
39
+ *
40
+ * @param Varien_Object $row
41
+ * @return string
42
+ */
43
+ public function render(Varien_Object $row)
44
+ {
45
+ return '<input type="checkbox" name="problem[]" value="' . $row->getId() . '" class="problemCheckbox"/>';
46
+ }
47
+ }// Class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid_Renderer_Checkbox END
app/code/core/Mage/Adminhtml/Block/Newsletter/Queue.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml queue grid block.
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Queue extends Mage_Adminhtml_Block_Template
35
+ {
36
+ public function __construct()
37
+ {
38
+ $this->setTemplate('newsletter/queue/list.phtml');
39
+ }
40
+
41
+ protected function _beforeToHtml()
42
+ {
43
+ $this->setChild('grid', $this->getLayout()->createBlock('adminhtml/newsletter_queue_grid', 'newsletter.queue.grid'));
44
+ return parent::_beforeToHtml();
45
+ }
46
+
47
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter queue edit block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Queue_Edit extends Mage_Adminhtml_Block_Template
36
+ {
37
+ /**
38
+ * Check for template Id in request
39
+ *
40
+ */
41
+ protected function _construct()
42
+ {
43
+ parent::_construct();
44
+ $templateId = $this->getRequest()->getParam('template_id');
45
+ if ($templateId) {
46
+ $this->setTemplateId($templateId);
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Retrieve current Newsletter Queue Object
52
+ *
53
+ * @return Mage_Newsletter_Model_Queue
54
+ */
55
+ public function getQueue()
56
+ {
57
+ return Mage::registry('current_queue');
58
+ }
59
+
60
+ protected function _beforeToHtml() {
61
+
62
+ $this->setTemplate('newsletter/queue/edit.phtml');
63
+
64
+ $this->setChild('form',
65
+ $this->getLayout()->createBlock('adminhtml/newsletter_queue_edit_form','form')
66
+ );
67
+
68
+ return parent::_beforeToHtml();
69
+ }
70
+
71
+ public function getSaveUrl()
72
+ {
73
+ if ($this->getTemplateId()) {
74
+ $params = array('template_id' => $this->getTemplateId());
75
+ } else {
76
+ $params = array('id' => $this->getRequest()->getParam('id'));
77
+ }
78
+ return $this->getUrl('*/*/save', $params);
79
+ }
80
+
81
+ protected function _prepareLayout()
82
+ {
83
+ // Load Wysiwyg on demand and Prepare layout
84
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
85
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
86
+ }
87
+
88
+ $this->setChild('preview_button',
89
+ $this->getLayout()->createBlock('adminhtml/widget_button')
90
+ ->setData(array(
91
+ 'label' => Mage::helper('newsletter')->__('Preview Template'),
92
+ 'onclick' => 'queueControl.preview();',
93
+ 'class' => 'task'
94
+ ))
95
+ );
96
+
97
+ $this->setChild('save_button',
98
+ $this->getLayout()->createBlock('adminhtml/widget_button')
99
+ ->setData(array(
100
+ 'label' => Mage::helper('newsletter')->__('Save Newsletter'),
101
+ 'onclick' => 'queueControl.save()',
102
+ 'class' => 'save'
103
+ ))
104
+ );
105
+
106
+ $this->setChild('save_and_resume',
107
+ $this->getLayout()->createBlock('adminhtml/widget_button')
108
+ ->setData(array(
109
+ 'label' => Mage::helper('newsletter')->__('Save and Resume'),
110
+ 'onclick' => 'queueControl.resume()',
111
+ 'class' => 'save'
112
+ ))
113
+ );
114
+
115
+ $this->setChild('reset_button',
116
+ $this->getLayout()->createBlock('adminhtml/widget_button')
117
+ ->setData(array(
118
+ 'label' => Mage::helper('newsletter')->__('Reset'),
119
+ 'onclick' => 'window.location = window.location'
120
+ ))
121
+ );
122
+
123
+ $this->setChild('back_button',
124
+ $this->getLayout()->createBlock('adminhtml/widget_button')
125
+ ->setData(
126
+ array(
127
+ 'label' => Mage::helper('newsletter')->__('Back'),
128
+ 'onclick' => "window.location.href = '" . $this->getUrl((
129
+ $this->getTemplateId() ? '*/newsletter_template/' : '*/*')) . "'",
130
+ 'class' => 'back'
131
+ )
132
+ )
133
+ );
134
+
135
+ return parent::_prepareLayout();
136
+ }
137
+
138
+ /**
139
+ * Return preview action url for form
140
+ *
141
+ * @return string
142
+ */
143
+ public function getPreviewUrl()
144
+ {
145
+ return $this->getUrl('*/*/preview');
146
+ }
147
+
148
+ /**
149
+ * Retrieve Preview Button HTML
150
+ *
151
+ * @return string
152
+ */
153
+ public function getPreviewButtonHtml()
154
+ {
155
+ return $this->getChildHtml('preview_button');
156
+ }
157
+
158
+ /**
159
+ * Retrieve Save Button HTML
160
+ *
161
+ * @return string
162
+ */
163
+ public function getSaveButtonHtml()
164
+ {
165
+ return $this->getChildHtml('save_button');
166
+ }
167
+
168
+ /**
169
+ * Retrieve Reset Button HTML
170
+ *
171
+ * @return string
172
+ */
173
+ public function getResetButtonHtml()
174
+ {
175
+ return $this->getChildHtml('reset_button');
176
+ }
177
+
178
+ /**
179
+ * Retrieve Back Button HTML
180
+ *
181
+ * @return string
182
+ */
183
+ public function getBackButtonHtml()
184
+ {
185
+ return $this->getChildHtml('back_button');
186
+ }
187
+
188
+ /**
189
+ * Retrieve Resume Button HTML
190
+ *
191
+ * @return string
192
+ */
193
+ public function getResumeButtonHtml()
194
+ {
195
+ return $this->getChildHtml('save_and_resume');
196
+ }
197
+
198
+ /**
199
+ * Getter for availability preview mode
200
+ *
201
+ * @return boolean
202
+ */
203
+ public function getIsPreview()
204
+ {
205
+ return !in_array($this->getQueue()->getQueueStatus(), array(
206
+ Mage_Newsletter_Model_Queue::STATUS_NEVER,
207
+ Mage_Newsletter_Model_Queue::STATUS_PAUSE
208
+ ));
209
+ }
210
+
211
+ /**
212
+ * Getter for single store mode check
213
+ *
214
+ * @return boolean
215
+ */
216
+ protected function isSingleStoreMode()
217
+ {
218
+ return Mage::app()->isSingleStoreMode();
219
+ }
220
+
221
+ /**
222
+ * Getter for id of current store (the only one in single-store mode and current in multi-stores mode)
223
+ *
224
+ * @return boolean
225
+ */
226
+ protected function getStoreId()
227
+ {
228
+ return Mage::app()->getStore(true)->getId();
229
+ }
230
+
231
+ /**
232
+ * Getter for check is this newsletter the plain text.
233
+ *
234
+ * @return boolean
235
+ */
236
+ public function getIsTextType()
237
+ {
238
+ return $this->getQueue()->isPlain();
239
+ }
240
+
241
+ /**
242
+ * Getter for availability resume action
243
+ *
244
+ * @return boolean
245
+ */
246
+ public function getCanResume()
247
+ {
248
+ return in_array($this->getQueue()->getQueueStatus(), array(
249
+ Mage_Newsletter_Model_Queue::STATUS_PAUSE
250
+ ));
251
+ }
252
+
253
+ /**
254
+ * Getter for header text
255
+ *
256
+ * @return boolean
257
+ */
258
+ public function getHeaderText()
259
+ {
260
+ return ( $this->getIsPreview() ? Mage::helper('newsletter')->__('View Newsletter') : Mage::helper('newsletter')->__('Edit Newsletter'));
261
+ }
262
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit/Form.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter queue edit form
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Queue_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+ /**
38
+ * Prepare form for newsletter queue editing.
39
+ * Form can be run from newsletter template grid by option "Queue newsletter"
40
+ * or from newsletter queue grid by edit option.
41
+ *
42
+ * @param void
43
+ * @return Mage_Adminhtml_Block_Newsletter_Queue_Edit_Form
44
+ */
45
+ protected function _prepareForm()
46
+ {
47
+ /* @var $queue Mage_Newsletter_Model_Queue */
48
+ $queue = Mage::getSingleton('newsletter/queue');
49
+
50
+ $form = new Varien_Data_Form();
51
+
52
+ $fieldset = $form->addFieldset('base_fieldset', array(
53
+ 'legend' => Mage::helper('newsletter')->__('Queue Information')
54
+ ));
55
+
56
+ $outputFormat = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
57
+
58
+ if($queue->getQueueStatus() == Mage_Newsletter_Model_Queue::STATUS_NEVER) {
59
+ $fieldset->addField('date', 'date',array(
60
+ 'name' => 'start_at',
61
+ 'time' => true,
62
+ 'format' => $outputFormat,
63
+ 'label' => Mage::helper('newsletter')->__('Queue Date Start'),
64
+ 'image' => $this->getSkinUrl('images/grid-cal.gif')
65
+ ));
66
+
67
+ if (!Mage::app()->isSingleStoreMode()) {
68
+ $fieldset->addField('stores','multiselect',array(
69
+ 'name' => 'stores[]',
70
+ 'label' => Mage::helper('newsletter')->__('Subscribers From'),
71
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
72
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(),
73
+ 'value' => $queue->getStores()
74
+ ));
75
+ }
76
+ else {
77
+ $fieldset->addField('stores', 'hidden', array(
78
+ 'name' => 'stores[]',
79
+ 'value' => Mage::app()->getStore(true)->getId()
80
+ ));
81
+ }
82
+ } else {
83
+ $fieldset->addField('date','date',array(
84
+ 'name' => 'start_at',
85
+ 'time' => true,
86
+ 'disabled' => 'true',
87
+ 'style' => 'width:38%;',
88
+ 'format' => $outputFormat,
89
+ 'label' => Mage::helper('newsletter')->__('Queue Date Start'),
90
+ 'image' => $this->getSkinUrl('images/grid-cal.gif')
91
+ ));
92
+
93
+ if (!Mage::app()->isSingleStoreMode()) {
94
+ $fieldset->addField('stores','multiselect',array(
95
+ 'name' => 'stores[]',
96
+ 'label' => Mage::helper('newsletter')->__('Subscribers From'),
97
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
98
+ 'required' => true,
99
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(),
100
+ 'value' => $queue->getStores()
101
+ ));
102
+ }
103
+ else {
104
+ $fieldset->addField('stores', 'hidden', array(
105
+ 'name' => 'stores[]',
106
+ 'value' => Mage::app()->getStore(true)->getId()
107
+ ));
108
+ }
109
+ }
110
+
111
+ if ($queue->getQueueStartAt()) {
112
+ $form->getElement('date')->setValue(
113
+ Mage::app()->getLocale()->date($queue->getQueueStartAt(), Varien_Date::DATETIME_INTERNAL_FORMAT)
114
+ );
115
+ }
116
+
117
+ $fieldset->addField('subject', 'text', array(
118
+ 'name' =>'subject',
119
+ 'label' => Mage::helper('newsletter')->__('Subject'),
120
+ 'required' => true,
121
+ 'value' => ($queue->isNew() ? $queue->getTemplate()->getTemplateSubject() : $queue->getNewsletterSubject())
122
+ ));
123
+
124
+ $fieldset->addField('sender_name', 'text', array(
125
+ 'name' =>'sender_name',
126
+ 'label' => Mage::helper('newsletter')->__('Sender Name'),
127
+ 'title' => Mage::helper('newsletter')->__('Sender Name'),
128
+ 'required' => true,
129
+ 'value' => ($queue->isNew() ? $queue->getTemplate()->getTemplateSenderName() : $queue->getNewsletterSenderName())
130
+ ));
131
+
132
+ $fieldset->addField('sender_email', 'text', array(
133
+ 'name' =>'sender_email',
134
+ 'label' => Mage::helper('newsletter')->__('Sender Email'),
135
+ 'title' => Mage::helper('newsletter')->__('Sender Email'),
136
+ 'class' => 'validate-email',
137
+ 'required' => true,
138
+ 'value' => ($queue->isNew() ? $queue->getTemplate()->getTemplateSenderEmail() : $queue->getNewsletterSenderEmail())
139
+ ));
140
+
141
+ $widgetFilters = array('is_email_compatible' => 1);
142
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('widget_filters' => $widgetFilters));
143
+
144
+ if ($queue->isNew()) {
145
+ $fieldset->addField('text','editor', array(
146
+ 'name' => 'text',
147
+ 'label' => Mage::helper('newsletter')->__('Message'),
148
+ 'state' => 'html',
149
+ 'required' => true,
150
+ 'value' => $queue->getTemplate()->getTemplateText(),
151
+ 'style' => 'width:98%; height: 600px;',
152
+ 'config' => $wysiwygConfig
153
+ ));
154
+
155
+ $fieldset->addField('styles', 'textarea', array(
156
+ 'name' =>'styles',
157
+ 'label' => Mage::helper('newsletter')->__('Newsletter Styles'),
158
+ 'container_id' => 'field_newsletter_styles',
159
+ 'value' => $queue->getTemplate()->getTemplateStyles()
160
+ ));
161
+ } elseif (Mage_Newsletter_Model_Queue::STATUS_NEVER != $queue->getQueueStatus()) {
162
+ $fieldset->addField('text','textarea', array(
163
+ 'name' => 'text',
164
+ 'label' => Mage::helper('newsletter')->__('Message'),
165
+ 'value' => $queue->getNewsletterText(),
166
+ ));
167
+
168
+ $fieldset->addField('styles', 'textarea', array(
169
+ 'name' =>'styles',
170
+ 'label' => Mage::helper('newsletter')->__('Newsletter Styles'),
171
+ 'value' => $queue->getNewsletterStyles()
172
+ ));
173
+
174
+ $form->getElement('text')->setDisabled('true')->setRequired(false);
175
+ $form->getElement('styles')->setDisabled('true')->setRequired(false);
176
+ $form->getElement('subject')->setDisabled('true')->setRequired(false);
177
+ $form->getElement('sender_name')->setDisabled('true')->setRequired(false);
178
+ $form->getElement('sender_email')->setDisabled('true')->setRequired(false);
179
+ $form->getElement('stores')->setDisabled('true');
180
+ } else {
181
+ $fieldset->addField('text','editor', array(
182
+ 'name' => 'text',
183
+ 'label' => Mage::helper('newsletter')->__('Message'),
184
+ 'state' => 'html',
185
+ 'required' => true,
186
+ 'value' => $queue->getNewsletterText(),
187
+ 'style' => 'width:98%; height: 600px;',
188
+ 'config' => $wysiwygConfig
189
+ ));
190
+
191
+ $fieldset->addField('styles', 'textarea', array(
192
+ 'name' =>'styles',
193
+ 'label' => Mage::helper('newsletter')->__('Newsletter Styles'),
194
+ 'value' => $queue->getNewsletterStyles(),
195
+ 'style' => 'width:98%; height: 300px;',
196
+ ));
197
+ }
198
+
199
+ $this->setForm($form);
200
+ return $this;
201
+ }
202
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Grid.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter queue grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Queue_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('queueGrid');
41
+ $this->setDefaultSort('start_at');
42
+ $this->setDefaultDir('desc');
43
+ $this->setSaveParametersInSession(true);
44
+ $this->setUseAjax(true);
45
+ }
46
+
47
+ protected function _prepareCollection()
48
+ {
49
+ $collection = Mage::getResourceModel('newsletter/queue_collection')
50
+ ->addSubscribersInfo();
51
+
52
+ $this->setCollection($collection);
53
+
54
+ return parent::_prepareCollection();
55
+ }
56
+
57
+ protected function _prepareColumns()
58
+ {
59
+ $this->addColumn('queue_id', array(
60
+ 'header' => Mage::helper('newsletter')->__('ID'),
61
+ 'index' => 'queue_id',
62
+ 'width' => 10
63
+ ));
64
+
65
+ $this->addColumn('start_at', array(
66
+ 'header' => Mage::helper('newsletter')->__('Queue Start'),
67
+ 'type' => 'datetime',
68
+ 'index' => 'queue_start_at',
69
+ 'gmtoffset' => true,
70
+ 'default' => ' ---- '
71
+ ));
72
+
73
+ $this->addColumn('finish_at', array(
74
+ 'header' => Mage::helper('newsletter')->__('Queue Finish'),
75
+ 'type' => 'datetime',
76
+ 'index' => 'queue_finish_at',
77
+ 'gmtoffset' => true,
78
+ 'default' => ' ---- '
79
+ ));
80
+
81
+ $this->addColumn('newsletter_subject', array(
82
+ 'header' => Mage::helper('newsletter')->__('Subject'),
83
+ 'index' => 'newsletter_subject'
84
+ ));
85
+
86
+ $this->addColumn('status', array(
87
+ 'header' => Mage::helper('newsletter')->__('Status'),
88
+ 'index' => 'queue_status',
89
+ 'type' => 'options',
90
+ 'options' => array(
91
+ Mage_Newsletter_Model_Queue::STATUS_SENT => Mage::helper('newsletter')->__('Sent'),
92
+ Mage_Newsletter_Model_Queue::STATUS_CANCEL => Mage::helper('newsletter')->__('Cancelled'),
93
+ Mage_Newsletter_Model_Queue::STATUS_NEVER => Mage::helper('newsletter')->__('Not Sent'),
94
+ Mage_Newsletter_Model_Queue::STATUS_SENDING => Mage::helper('newsletter')->__('Sending'),
95
+ Mage_Newsletter_Model_Queue::STATUS_PAUSE => Mage::helper('newsletter')->__('Paused'),
96
+ ),
97
+ 'width' => '100px',
98
+ ));
99
+
100
+ $this->addColumn('subscribers_sent', array(
101
+ 'header' => Mage::helper('newsletter')->__('Processed'),
102
+ 'type' => 'number',
103
+ 'index' => 'subscribers_sent'
104
+ ));
105
+
106
+ $this->addColumn('subscribers_total', array(
107
+ 'header' => Mage::helper('newsletter')->__('Recipients'),
108
+ 'type' => 'number',
109
+ 'index' => 'subscribers_total'
110
+ ));
111
+
112
+ $this->addColumn('action', array(
113
+ 'header' => Mage::helper('newsletter')->__('Action'),
114
+ 'filter' => false,
115
+ 'sortable' => false,
116
+ 'no_link' => true,
117
+ 'width' => '100px',
118
+ 'renderer' => 'adminhtml/newsletter_queue_grid_renderer_action'
119
+ ));
120
+
121
+ return parent::_prepareColumns();
122
+ }
123
+
124
+ public function getRowUrl($row)
125
+ {
126
+ return $this->getUrl('*/*/edit', array('id'=>$row->getId()));
127
+ }
128
+
129
+ }
130
+
app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Grid/Renderer/Action.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter queue grid block action item renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Queue_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
36
+ {
37
+ public function render(Varien_Object $row)
38
+ {
39
+ $actions = array();
40
+
41
+ if($row->getQueueStatus()==Mage_Newsletter_Model_Queue::STATUS_NEVER) {
42
+ if(!$row->getQueueStartAt() && $row->getSubscribersTotal()) {
43
+ $actions[] = array(
44
+ 'url' => $this->getUrl('*/*/start', array('id'=>$row->getId())),
45
+ 'caption' => Mage::helper('newsletter')->__('Start')
46
+ );
47
+ }
48
+ } else if ($row->getQueueStatus()==Mage_Newsletter_Model_Queue::STATUS_SENDING) {
49
+ $actions[] = array(
50
+ 'url' => $this->getUrl('*/*/pause', array('id'=>$row->getId())),
51
+ 'caption' => Mage::helper('newsletter')->__('Pause')
52
+ );
53
+
54
+ $actions[] = array(
55
+ 'url' => $this->getUrl('*/*/cancel', array('id'=>$row->getId())),
56
+ 'confirm' => Mage::helper('newsletter')->__('Do you really want to cancel the queue?'),
57
+ 'caption' => Mage::helper('newsletter')->__('Cancel')
58
+ );
59
+
60
+
61
+ } else if ($row->getQueueStatus()==Mage_Newsletter_Model_Queue::STATUS_PAUSE) {
62
+
63
+ $actions[] = array(
64
+ 'url' => $this->getUrl('*/*/resume', array('id'=>$row->getId())),
65
+ 'caption' => Mage::helper('newsletter')->__('Resume')
66
+ );
67
+
68
+ }
69
+
70
+ $actions[] = array(
71
+ 'url' => $this->getUrl('*/newsletter_queue/preview',array('id'=>$row->getId())),
72
+ 'caption' => Mage::helper('newsletter')->__('Preview'),
73
+ 'popup' => true
74
+ );
75
+
76
+ $this->getColumn()->setActions($actions);
77
+ return parent::render($row);
78
+ }
79
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter template preview block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Queue_Preview extends Mage_Adminhtml_Block_Widget
35
+ {
36
+
37
+ protected function _toHtml()
38
+ {
39
+ /* @var $template Mage_Newsletter_Model_Template */
40
+ $template = Mage::getModel('newsletter/template');
41
+
42
+ if($id = (int)$this->getRequest()->getParam('id')) {
43
+ $queue = Mage::getModel('newsletter/queue');
44
+ $queue->load($id);
45
+ $template->setTemplateType($queue->getNewsletterType());
46
+ $template->setTemplateText($queue->getNewsletterText());
47
+ $template->setTemplateStyles($queue->getNewsletterStyles());
48
+ } else {
49
+ $template->setTemplateType($this->getRequest()->getParam('type'));
50
+ $template->setTemplateText($this->getRequest()->getParam('text'));
51
+ $template->setTemplateStyles($this->getRequest()->getParam('styles'));
52
+ }
53
+
54
+
55
+ $storeId = (int)$this->getRequest()->getParam('store_id');
56
+ if(!$storeId) {
57
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
58
+ }
59
+
60
+ Varien_Profiler::start("newsletter_queue_proccessing");
61
+ $vars = array();
62
+
63
+ $vars['subscriber'] = Mage::getModel('newsletter/subscriber');
64
+
65
+ $template->emulateDesign($storeId);
66
+ $templateProcessed = $template->getProcessedTemplate($vars, true);
67
+ $template->revertDesign();
68
+
69
+ if($template->isPlain()) {
70
+ $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
71
+ }
72
+
73
+ Varien_Profiler::stop("newsletter_queue_proccessing");
74
+
75
+ return $templateProcessed;
76
+
77
+ }
78
+
79
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview/Form.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Admin form widget
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Queue_Preview_Form extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+
37
+ /**
38
+ * Preparing from for revision page
39
+ *
40
+ * @return Mage_Adminhtml_Block_Widget_Form
41
+ */
42
+ protected function _prepareForm()
43
+ {
44
+ $form = new Varien_Data_Form(array(
45
+ 'id' => 'preview_form',
46
+ 'action' => $this->getUrl('*/*/drop', array('_current' => true)),
47
+ 'method' => 'post'
48
+ ));
49
+
50
+ if ($data = $this->getFormData()) {
51
+
52
+ $mapper = array('preview_store_id' => 'store_id');
53
+
54
+ foreach ($data as $key => $value) {
55
+ if(array_key_exists($key, $mapper)) {
56
+ $name = $mapper[$key];
57
+ } else {
58
+ $name = $key;
59
+ }
60
+ $form->addField($key, 'hidden', array('name' => $name));
61
+ }
62
+ $form->setValues($data);
63
+ }
64
+
65
+ $form->setUseContainer(true);
66
+ $this->setForm($form);
67
+ return parent::_prepareForm();
68
+ }
69
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter subscriber grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Subscriber extends Mage_Adminhtml_Block_Template
36
+ {
37
+ /**
38
+ * Queue collection
39
+ *
40
+ * @var Mage_Newsletter_Model_Mysql4_Queue_Collection
41
+ */
42
+ protected $_queueCollection = null;
43
+
44
+ /**
45
+ * Constructor
46
+ *
47
+ * Initializes block
48
+ */
49
+ public function __construct()
50
+ {
51
+ $this->setTemplate('newsletter/subscriber/list.phtml');
52
+ }
53
+
54
+ /**
55
+ * Prepares block to render
56
+ *
57
+ * @return Mage_Adminhtml_Block_Newsletter_Subscriber
58
+ */
59
+ protected function _beforeToHtml()
60
+ {
61
+ $this->setChild('grid', $this->getLayout()->createBlock('adminhtml/newsletter_subscriber_grid','grid'));
62
+ return parent::_beforeToHtml();
63
+ }
64
+
65
+ /**
66
+ * Return queue collection with loaded neversent queues
67
+ *
68
+ * @return Mage_Newsletter_Model_Mysql4_Queue_Collection
69
+ */
70
+ public function getQueueCollection()
71
+ {
72
+ if(is_null($this->_queueCollection)) {
73
+ $this->_queueCollection = Mage::getResourceSingleton('newsletter/queue_collection')
74
+ ->addTemplateInfo()
75
+ ->addOnlyUnsentFilter()
76
+ ->load();
77
+ }
78
+
79
+ return $this->_queueCollection;
80
+ }
81
+
82
+ public function getShowQueueAdd()
83
+ {
84
+ return $this->getChild('grid')->getShowQueueAdd();
85
+ }
86
+
87
+ /**
88
+ * Return list of neversent queues for select
89
+ *
90
+ * @return array
91
+ */
92
+ public function getQueueAsOptions()
93
+ {
94
+ return $this->getQueueCollection()->toOptionArray();
95
+ }
96
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter subscribers grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ /**
37
+ * Constructor
38
+ *
39
+ * Set main configuration of grid
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ $this->setId('subscriberGrid');
45
+ $this->setUseAjax(true);
46
+ $this->setDefaultSort('subscriber_id', 'desc');
47
+ }
48
+
49
+ /**
50
+ * Prepare collection for grid
51
+ *
52
+ * @return Mage_Adminhtml_Block_Widget_Grid
53
+ */
54
+ protected function _prepareCollection()
55
+ {
56
+ $collection = Mage::getResourceSingleton('newsletter/subscriber_collection');
57
+ /* @var $collection Mage_Newsletter_Model_Mysql4_Subscriber_Collection */
58
+ $collection
59
+ ->showCustomerInfo(true)
60
+ ->addSubscriberTypeField()
61
+ ->showStoreInfo();
62
+
63
+ if($this->getRequest()->getParam('queue', false)) {
64
+ $collection->useQueue(Mage::getModel('newsletter/queue')
65
+ ->load($this->getRequest()->getParam('queue')));
66
+ }
67
+
68
+ $this->setCollection($collection);
69
+
70
+ return parent::_prepareCollection();
71
+ }
72
+
73
+ protected function _prepareColumns()
74
+ {
75
+
76
+ $this->addColumn('subscriber_id', array(
77
+ 'header' => Mage::helper('newsletter')->__('ID'),
78
+ 'index' => 'subscriber_id'
79
+ ));
80
+
81
+ $this->addColumn('email', array(
82
+ 'header' => Mage::helper('newsletter')->__('Email'),
83
+ 'index' => 'subscriber_email'
84
+ ));
85
+
86
+ $this->addColumn('type', array(
87
+ 'header' => Mage::helper('newsletter')->__('Type'),
88
+ 'index' => 'type',
89
+ 'type' => 'options',
90
+ 'options' => array(
91
+ 1 => Mage::helper('newsletter')->__('Guest'),
92
+ 2 => Mage::helper('newsletter')->__('Customer')
93
+ )
94
+ ));
95
+
96
+ $this->addColumn('firstname', array(
97
+ 'header' => Mage::helper('newsletter')->__('Customer First Name'),
98
+ 'index' => 'customer_firstname',
99
+ 'default' => '----'
100
+ ));
101
+
102
+ $this->addColumn('lastname', array(
103
+ 'header' => Mage::helper('newsletter')->__('Customer Last Name'),
104
+ 'index' => 'customer_lastname',
105
+ 'default' => '----'
106
+ ));
107
+
108
+ $this->addColumn('status', array(
109
+ 'header' => Mage::helper('newsletter')->__('Status'),
110
+ 'index' => 'subscriber_status',
111
+ 'type' => 'options',
112
+ 'options' => array(
113
+ Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE => Mage::helper('newsletter')->__('Not Activated'),
114
+ Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED => Mage::helper('newsletter')->__('Subscribed'),
115
+ Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED => Mage::helper('newsletter')->__('Unsubscribed'),
116
+ Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED => Mage::helper('newsletter')->__('Unconfirmed'),
117
+ )
118
+ ));
119
+
120
+ $this->addColumn('website', array(
121
+ 'header' => Mage::helper('newsletter')->__('Website'),
122
+ 'index' => 'website_id',
123
+ 'type' => 'options',
124
+ 'options' => $this->_getWebsiteOptions()
125
+ ));
126
+
127
+ $this->addColumn('group', array(
128
+ 'header' => Mage::helper('newsletter')->__('Store'),
129
+ 'index' => 'group_id',
130
+ 'type' => 'options',
131
+ 'options' => $this->_getStoreGroupOptions()
132
+ ));
133
+
134
+ $this->addColumn('store', array(
135
+ 'header' => Mage::helper('newsletter')->__('Store View'),
136
+ 'index' => 'store_id',
137
+ 'type' => 'options',
138
+ 'options' => $this->_getStoreOptions()
139
+ ));
140
+
141
+ $this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
142
+ $this->addExportType('*/*/exportXml', Mage::helper('customer')->__('Excel XML'));
143
+ return parent::_prepareColumns();
144
+ }
145
+
146
+ /**
147
+ * Convert OptionsValue array to Options array
148
+ *
149
+ * @param array $optionsArray
150
+ * @return array
151
+ */
152
+ protected function _getOptions($optionsArray)
153
+ {
154
+ $options = array();
155
+ foreach ($optionsArray as $option) {
156
+ $options[$option['value']] = $option['label'];
157
+ }
158
+ return $options;
159
+ }
160
+
161
+ /**
162
+ * Retrieve Website Options array
163
+ *
164
+ * @return array
165
+ */
166
+ protected function _getWebsiteOptions()
167
+ {
168
+ return Mage::getModel('adminhtml/system_store')->getWebsiteOptionHash();
169
+ }
170
+
171
+ /**
172
+ * Retrieve Store Group Options array
173
+ *
174
+ * @return array
175
+ */
176
+ protected function _getStoreGroupOptions()
177
+ {
178
+ return Mage::getModel('adminhtml/system_store')->getStoreGroupOptionHash();
179
+ }
180
+
181
+ /**
182
+ * Retrieve Store Options array
183
+ *
184
+ * @return array
185
+ */
186
+ protected function _getStoreOptions()
187
+ {
188
+ return Mage::getModel('adminhtml/system_store')->getStoreOptionHash();
189
+ }
190
+
191
+ protected function _prepareMassaction()
192
+ {
193
+ $this->setMassactionIdField('subscriber_id');
194
+ $this->getMassactionBlock()->setFormFieldName('subscriber');
195
+
196
+ $this->getMassactionBlock()->addItem('unsubscribe', array(
197
+ 'label' => Mage::helper('newsletter')->__('Unsubscribe'),
198
+ 'url' => $this->getUrl('*/*/massUnsubscribe')
199
+ ));
200
+
201
+ $this->getMassactionBlock()->addItem('delete', array(
202
+ 'label' => Mage::helper('newsletter')->__('Delete'),
203
+ 'url' => $this->getUrl('*/*/massDelete')
204
+ ));
205
+
206
+ return $this;
207
+ }
208
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Checkbox.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter subscribers grid filter checkbox
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid_Filter_Checkbox extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract
36
+ {
37
+ public function getCondition()
38
+ {
39
+ return array();
40
+ }
41
+
42
+ public function getHtml()
43
+ {
44
+ return '<input type="checkbox" onclick="subscriberController.checkCheckboxes(this)"/>';
45
+ }
46
+ }// Class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid_Filter_Checkbox END
app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Filter/Website.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter subscribers grid website filter
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid_Filter_Website extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
35
+ {
36
+
37
+ protected $_websiteCollection = null;
38
+
39
+ protected function _getOptions()
40
+ {
41
+ $result = $this->getCollection()->toOptionArray();
42
+ array_unshift($result, array('label'=>null, 'value'=>null));
43
+ return $result;
44
+ }
45
+
46
+ public function getCollection()
47
+ {
48
+ if(is_null($this->_websiteCollection)) {
49
+ $this->_websiteCollection = Mage::getResourceModel('core/website_collection')
50
+ ->load();
51
+ }
52
+
53
+ Mage::register('website_collection', $this->_websiteCollection);
54
+
55
+ return $this->_websiteCollection;
56
+ }
57
+
58
+ public function getCondition()
59
+ {
60
+
61
+ $id = $this->getValue();
62
+ if(!$id) {
63
+ return null;
64
+ }
65
+
66
+ $website = Mage::app()->getWebsite($id);
67
+
68
+ return array('in'=>$website->getStoresIds(true));
69
+ }
70
+
71
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid/Renderer/Checkbox.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter subscribers grid checkbox item renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid_Renderer_Checkbox extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
36
+ {
37
+ /**
38
+ * Renders grid column
39
+ *
40
+ * @param Varien_Object $row
41
+ * @return string
42
+ */
43
+ public function render(Varien_Object $row)
44
+ {
45
+ if($row->getSubscriberStatus()==Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
46
+ return '<input type="checkbox" name="subscriber[]" value="' . $row->getId() . '" class="subscriberCheckbox"/>';
47
+ } else {
48
+ return '';
49
+ }
50
+
51
+ }
52
+ }// Class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid_Renderer_Checkbox END
app/code/core/Mage/Adminhtml/Block/Newsletter/Template.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter templates page content block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Template extends Mage_Adminhtml_Block_Template
36
+ {
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setTemplate('newsletter/template/list.phtml');
41
+ }
42
+
43
+
44
+ protected function _prepareLayout()
45
+ {
46
+ $this->setChild('grid', $this->getLayout()->createBlock('adminhtml/newsletter_template_grid', 'newsletter.template.grid'));
47
+ return parent::_prepareLayout();
48
+ }
49
+
50
+ public function getCreateUrl()
51
+ {
52
+ return $this->getUrl('*/*/new');
53
+ }
54
+
55
+ public function getHeaderText()
56
+ {
57
+ return Mage::helper('newsletter')->__('Newsletter Templates');
58
+ }
59
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml Newsletter Template Edit Block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Newsletter_Template_Edit extends Mage_Adminhtml_Block_Widget
36
+ {
37
+ /**
38
+ * Edit Block model
39
+ *
40
+ * @var bool
41
+ */
42
+ protected $_editMode = false;
43
+
44
+ /**
45
+ * Retrieve template object
46
+ *
47
+ * @return Mage_Newsletter_Model_Template
48
+ */
49
+ public function getModel()
50
+ {
51
+ return Mage::registry('_current_template');
52
+ }
53
+
54
+ /**
55
+ * Preparing block layout
56
+ *
57
+ * @return Mage_Adminhtml_Block_Newsletter_Template_Edit
58
+ */
59
+ protected function _prepareLayout()
60
+ {
61
+ // Load Wysiwyg on demand and Prepare layout
62
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))) {
63
+ $block->setCanLoadTinyMce(true);
64
+ }
65
+
66
+ $this->setChild('back_button',
67
+ $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->setData(array(
69
+ 'label' => Mage::helper('newsletter')->__('Back'),
70
+ 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'",
71
+ 'class' => 'back'
72
+ ))
73
+ );
74
+
75
+ $this->setChild('reset_button',
76
+ $this->getLayout()->createBlock('adminhtml/widget_button')
77
+ ->setData(array(
78
+ 'label' => Mage::helper('newsletter')->__('Reset'),
79
+ 'onclick' => 'window.location.href = window.location.href'
80
+ ))
81
+ );
82
+
83
+ $this->setChild('to_plain_button',
84
+ $this->getLayout()->createBlock('adminhtml/widget_button')
85
+ ->setData(array(
86
+ 'label' => Mage::helper('newsletter')->__('Convert to Plain Text'),
87
+ 'onclick' => 'templateControl.stripTags();',
88
+ 'id' => 'convert_button',
89
+ 'class' => 'task'
90
+ ))
91
+ );
92
+
93
+ $this->setChild('to_html_button',
94
+ $this->getLayout()->createBlock('adminhtml/widget_button')
95
+ ->setData(array(
96
+ 'label' => Mage::helper('newsletter')->__('Return HTML Version'),
97
+ 'onclick' => 'templateControl.unStripTags();',
98
+ 'id' => 'convert_button_back',
99
+ 'style' => 'display:none',
100
+ 'class' => 'task'
101
+ ))
102
+ );
103
+
104
+ $this->setChild('save_button',
105
+ $this->getLayout()->createBlock('adminhtml/widget_button')
106
+ ->setData(array(
107
+ 'label' => Mage::helper('newsletter')->__('Save Template'),
108
+ 'onclick' => 'templateControl.save();',
109
+ 'class' => 'save'
110
+ ))
111
+ );
112
+
113
+ $this->setChild('save_as_button',
114
+ $this->getLayout()->createBlock('adminhtml/widget_button')
115
+ ->setData(array(
116
+ 'label' => Mage::helper('newsletter')->__('Save As'),
117
+ 'onclick' => 'templateControl.saveAs();',
118
+ 'class' => 'save'
119
+ ))
120
+ );
121
+
122
+ $this->setChild('preview_button',
123
+ $this->getLayout()->createBlock('adminhtml/widget_button')
124
+ ->setData(array(
125
+ 'label' => Mage::helper('newsletter')->__('Preview Template'),
126
+ 'onclick' => 'templateControl.preview();',
127
+ 'class' => 'task'
128
+ ))
129
+ );
130
+
131
+ $this->setChild('delete_button',
132
+ $this->getLayout()->createBlock('adminhtml/widget_button')
133
+ ->setData(array(
134
+ 'label' => Mage::helper('newsletter')->__('Delete Template'),
135
+ 'onclick' => 'templateControl.deleteTemplate();',
136
+ 'class' => 'delete'
137
+ ))
138
+ );
139
+
140
+ return parent::_prepareLayout();
141
+ }
142
+
143
+ /**
144
+ * Retrieve Back Button HTML
145
+ *
146
+ * @return string
147
+ */
148
+ public function getBackButtonHtml()
149
+ {
150
+ return $this->getChildHtml('back_button');
151
+ }
152
+
153
+ /**
154
+ * Retrieve Reset Button HTML
155
+ *
156
+ * @return string
157
+ */
158
+ public function getResetButtonHtml()
159
+ {
160
+ return $this->getChildHtml('reset_button');
161
+ }
162
+
163
+ /**
164
+ * Retrieve Convert To Plain Button HTML
165
+ *
166
+ * @return string
167
+ */
168
+ public function getToPlainButtonHtml()
169
+ {
170
+ return $this->getChildHtml('to_plain_button');
171
+ }
172
+
173
+ /**
174
+ * Retrieve Convert to HTML Button HTML
175
+ *
176
+ * @return string
177
+ */
178
+ public function getToHtmlButtonHtml()
179
+ {
180
+ return $this->getChildHtml('to_html_button');
181
+ }
182
+
183
+ /**
184
+ * Retrieve Save Button HTML
185
+ *
186
+ * @return string
187
+ */
188
+ public function getSaveButtonHtml()
189
+ {
190
+ return $this->getChildHtml('save_button');
191
+ }
192
+
193
+ /**
194
+ * Retrieve Preview Button HTML
195
+ *
196
+ * @return string
197
+ */
198
+ public function getPreviewButtonHtml()
199
+ {
200
+ return $this->getChildHtml('preview_button');
201
+ }
202
+
203
+ /**
204
+ * Retrieve Delete Button HTML
205
+ *
206
+ * @return string
207
+ */
208
+ public function getDeleteButtonHtml()
209
+ {
210
+ return $this->getChildHtml('delete_button');
211
+ }
212
+
213
+ /**
214
+ * Retrieve Save as Button HTML
215
+ *
216
+ * @return string
217
+ */
218
+ public function getSaveAsButtonHtml()
219
+ {
220
+ return $this->getChildHtml('save_as_button');
221
+ }
222
+
223
+ /**
224
+ * Set edit flag for block
225
+ *
226
+ * @param boolean $value
227
+ * @return Mage_Adminhtml_Block_Newsletter_Template_Edit
228
+ */
229
+ public function setEditMode($value = true)
230
+ {
231
+ $this->_editMode = (bool)$value;
232
+ return $this;
233
+ }
234
+
235
+ /**
236
+ * Return edit flag for block
237
+ *
238
+ * @return boolean
239
+ */
240
+ public function getEditMode()
241
+ {
242
+ return $this->_editMode;
243
+ }
244
+
245
+ /**
246
+ * Return header text for form
247
+ *
248
+ * @return string
249
+ */
250
+ public function getHeaderText()
251
+ {
252
+ if ($this->getEditMode()) {
253
+ return Mage::helper('newsletter')->__('Edit Newsletter Template');
254
+ }
255
+
256
+ return Mage::helper('newsletter')->__('New Newsletter Template');
257
+ }
258
+
259
+ /**
260
+ * Return form block HTML
261
+ *
262
+ * @return string
263
+ */
264
+ public function getForm()
265
+ {
266
+ return $this->getLayout()
267
+ ->createBlock('adminhtml/newsletter_template_edit_form')
268
+ ->toHtml();
269
+ }
270
+
271
+ /**
272
+ * Return return template name for JS
273
+ *
274
+ * @return string
275
+ */
276
+ public function getJsTemplateName()
277
+ {
278
+ return addcslashes($this->getModel()->getTemplateCode(), "\"\r\n\\");
279
+ }
280
+
281
+ /**
282
+ * Return action url for form
283
+ *
284
+ * @return string
285
+ */
286
+ public function getSaveUrl()
287
+ {
288
+ return $this->getUrl('*/*/save');
289
+ }
290
+
291
+ /**
292
+ * Return preview action url for form
293
+ *
294
+ * @return string
295
+ */
296
+ public function getPreviewUrl()
297
+ {
298
+ return $this->getUrl('*/*/preview');
299
+ }
300
+
301
+ /**
302
+ * Check Template Type is Plain Text
303
+ *
304
+ * @return bool
305
+ */
306
+ public function isTextType()
307
+ {
308
+ return $this->getModel()->isPlain();
309
+ }
310
+
311
+ /**
312
+ * Return delete url for customer group
313
+ *
314
+ * @return string
315
+ */
316
+ public function getDeleteUrl()
317
+ {
318
+ return $this->getUrl('*/*/delete', array('id' => $this->getRequest()->getParam('id')));
319
+ }
320
+
321
+ /**
322
+ * Retrieve Save As Flag
323
+ *
324
+ * @return int
325
+ */
326
+ public function getSaveAsFlag()
327
+ {
328
+ return $this->getRequest()->getParam('_save_as_flag') ? '1' : '';
329
+ }
330
+
331
+ /**
332
+ * Getter for single store mode check
333
+ *
334
+ * @return boolean
335
+ */
336
+ protected function isSingleStoreMode()
337
+ {
338
+ return Mage::app()->isSingleStoreMode();
339
+ }
340
+
341
+ /**
342
+ * Getter for id of current store (the only one in single-store mode and current in multi-stores mode)
343
+ *
344
+ * @return boolean
345
+ */
346
+ protected function getStoreId()
347
+ {
348
+ return Mage::app()->getStore(true)->getId();
349
+ }
350
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit/Form.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml Newsletter Template Edit Form Block
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Newsletter_Template_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+ /**
38
+ * Define Form settings
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ }
45
+
46
+ /**
47
+ * Retrieve template object
48
+ *
49
+ * @return Mage_Newsletter_Model_Template
50
+ */
51
+ public function getModel()
52
+ {
53
+ return Mage::registry('_current_template');
54
+ }
55
+
56
+ /**
57
+ * Prepare form before rendering HTML
58
+ *
59
+ * @return Mage_Adminhtml_Block_Newsletter_Template_Edit_Form
60
+ */
61
+ protected function _prepareForm()
62
+ {
63
+ $model = $this->getModel();
64
+ $identity = Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY);
65
+ $identityName = Mage::getStoreConfig('trans_email/ident_'.$identity.'/name');
66
+ $identityEmail = Mage::getStoreConfig('trans_email/ident_'.$identity.'/email');
67
+
68
+ $form = new Varien_Data_Form(array(
69
+ 'id' => 'edit_form',
70
+ 'action' => $this->getData('action'),
71
+ 'method' => 'post'
72
+ ));
73
+
74
+ $fieldset = $form->addFieldset('base_fieldset', array(
75
+ 'legend' => Mage::helper('newsletter')->__('Template Information'),
76
+ 'class' => 'fieldset-wide'
77
+ ));
78
+
79
+ if ($model->getId()) {
80
+ $fieldset->addField('id', 'hidden', array(
81
+ 'name' => 'id',
82
+ 'value' => $model->getId(),
83
+ ));
84
+ }
85
+
86
+ $fieldset->addField('code', 'text', array(
87
+ 'name' => 'code',
88
+ 'label' => Mage::helper('newsletter')->__('Template Name'),
89
+ 'title' => Mage::helper('newsletter')->__('Template Name'),
90
+ 'required' => true,
91
+ 'value' => $model->getTemplateCode(),
92
+ ));
93
+
94
+ $fieldset->addField('subject', 'text', array(
95
+ 'name' => 'subject',
96
+ 'label' => Mage::helper('newsletter')->__('Template Subject'),
97
+ 'title' => Mage::helper('newsletter')->__('Template Subject'),
98
+ 'required' => true,
99
+ 'value' => $model->getTemplateSubject(),
100
+ ));
101
+
102
+ $fieldset->addField('sender_name', 'text', array(
103
+ 'name' =>'sender_name',
104
+ 'label' => Mage::helper('newsletter')->__('Sender Name'),
105
+ 'title' => Mage::helper('newsletter')->__('Sender Name'),
106
+ 'required' => true,
107
+ 'value' => $model->getId() !== null
108
+ ? $model->getTemplateSenderName()
109
+ : $identityName,
110
+ ));
111
+
112
+ $fieldset->addField('sender_email', 'text', array(
113
+ 'name' =>'sender_email',
114
+ 'label' => Mage::helper('newsletter')->__('Sender Email'),
115
+ 'title' => Mage::helper('newsletter')->__('Sender Email'),
116
+ 'class' => 'validate-email',
117
+ 'required' => true,
118
+ 'value' => $model->getId() !== null
119
+ ? $model->getTemplateSenderEmail()
120
+ : $identityEmail
121
+ ));
122
+
123
+
124
+ $widgetFilters = array('is_email_compatible' => 1);
125
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('widget_filters' => $widgetFilters));
126
+ if ($model->isPlain()) {
127
+ $wysiwygConfig->setEnabled(false);
128
+ }
129
+ $fieldset->addField('text', 'editor', array(
130
+ 'name' => 'text',
131
+ 'label' => Mage::helper('newsletter')->__('Template Content'),
132
+ 'title' => Mage::helper('newsletter')->__('Template Content'),
133
+ 'required' => true,
134
+ 'state' => 'html',
135
+ 'style' => 'height:36em;',
136
+ 'value' => $model->getTemplateText(),
137
+ 'config' => $wysiwygConfig
138
+ ));
139
+
140
+ if (!$model->isPlain()) {
141
+ $fieldset->addField('template_styles', 'textarea', array(
142
+ 'name' =>'styles',
143
+ 'label' => Mage::helper('newsletter')->__('Template Styles'),
144
+ 'container_id' => 'field_template_styles',
145
+ 'value' => $model->getTemplateStyles()
146
+ ));
147
+ }
148
+
149
+ $form->setAction($this->getUrl('*/*/save'));
150
+ $form->setUseContainer(true);
151
+ $this->setForm($form);
152
+
153
+ return parent::_prepareForm();
154
+ }
155
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter templates grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Template_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ protected function _construct()
37
+ {
38
+ $this->setEmptyText(Mage::helper('newsletter')->__('No Templates Found'));
39
+ }
40
+
41
+ protected function _prepareCollection()
42
+ {
43
+ $collection = Mage::getResourceSingleton('newsletter/template_collection')
44
+ ->useOnlyActual();
45
+
46
+ $this->setCollection($collection);
47
+
48
+ return parent::_prepareCollection();
49
+ }
50
+
51
+ protected function _prepareColumns()
52
+ {
53
+ $this->addColumn('template_code',
54
+ array('header'=>Mage::helper('newsletter')->__('ID'), 'align'=>'center', 'index'=>'template_id'));
55
+ $this->addColumn('code',
56
+ array(
57
+ 'header'=>Mage::helper('newsletter')->__('Template Name'),
58
+ 'index'=>'template_code'
59
+ ));
60
+
61
+ $this->addColumn('added_at',
62
+ array(
63
+ 'header'=>Mage::helper('newsletter')->__('Date Added'),
64
+ 'index'=>'added_at',
65
+ 'gmtoffset' => true,
66
+ 'type'=>'datetime'
67
+ ));
68
+
69
+ $this->addColumn('modified_at',
70
+ array(
71
+ 'header'=>Mage::helper('newsletter')->__('Date Updated'),
72
+ 'index'=>'modified_at',
73
+ 'gmtoffset' => true,
74
+ 'type'=>'datetime'
75
+ ));
76
+
77
+ $this->addColumn('subject',
78
+ array(
79
+ 'header'=>Mage::helper('newsletter')->__('Subject'),
80
+ 'index'=>'template_subject'
81
+ ));
82
+
83
+ $this->addColumn('sender',
84
+ array(
85
+ 'header'=>Mage::helper('newsletter')->__('Sender'),
86
+ 'index'=>'template_sender_email',
87
+ 'renderer' => 'adminhtml/newsletter_template_grid_renderer_sender'
88
+ ));
89
+
90
+ $this->addColumn('type',
91
+ array(
92
+ 'header'=>Mage::helper('newsletter')->__('Template Type'),
93
+ 'index'=>'template_type',
94
+ 'type' => 'options',
95
+ 'options' => array(
96
+ Mage_Newsletter_Model_Template::TYPE_HTML => 'html',
97
+ Mage_Newsletter_Model_Template::TYPE_TEXT => 'text'
98
+ ),
99
+ ));
100
+
101
+ $this->addColumn('action',
102
+ array(
103
+ 'header' => Mage::helper('newsletter')->__('Action'),
104
+ 'index' =>'template_id',
105
+ 'sortable' =>false,
106
+ 'filter' => false,
107
+ 'no_link' => true,
108
+ 'width' => '170px',
109
+ 'renderer' => 'adminhtml/newsletter_template_grid_renderer_action'
110
+ ));
111
+
112
+ return $this;
113
+ }
114
+
115
+ public function getRowUrl($row)
116
+ {
117
+ return $this->getUrl('*/*/edit', array('id'=>$row->getId()));
118
+ }
119
+
120
+ }
121
+
app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter templates grid block action item renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Template_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
36
+ {
37
+ /**
38
+ * Renderer for "Action" column in Newsletter templates grid
39
+ *
40
+ * @var Mage_Newsletter_Model_Template $row
41
+ * @return string
42
+ */
43
+ public function render(Varien_Object $row)
44
+ {
45
+ if($row->isValidForSend()) {
46
+ $actions[] = array(
47
+ 'url' => $this->getUrl('*/newsletter_queue/edit', array('template_id' => $row->getId())),
48
+ 'caption' => Mage::helper('newsletter')->__('Queue Newsletter...')
49
+ );
50
+ }
51
+
52
+ $actions[] = array(
53
+ 'url' => $this->getUrl('*/*/preview', array('id'=>$row->getId())),
54
+ 'popup' => true,
55
+ 'caption' => Mage::helper('newsletter')->__('Preview')
56
+ );
57
+
58
+ $this->getColumn()->setActions($actions);
59
+
60
+ return parent::render($row);
61
+ }
62
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Sender.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter templates grid block sender item renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Mage_Adminhtml_Block_Newsletter_Template_Grid_Renderer_Sender extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
36
+ {
37
+ public function render(Varien_Object $row)
38
+ {
39
+ $str = '';
40
+ if($row->getTemplateSenderName()) {
41
+ $str .= htmlspecialchars($row->getTemplateSenderName()) . ' ';
42
+ }
43
+ if($row->getTemplateSenderEmail()) {
44
+ $str .= '[' . $row->getTemplateSenderEmail() . ']';
45
+ }
46
+ if($str == '') {
47
+ $str .= '---';
48
+ }
49
+ return $str;
50
+ }
51
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter template preview block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Template_Preview extends Mage_Adminhtml_Block_Widget
35
+ {
36
+
37
+ protected function _toHtml()
38
+ {
39
+ /* @var $template Mage_Newsletter_Model_Template */
40
+ $template = Mage::getModel('newsletter/template');
41
+
42
+ if($id = (int)$this->getRequest()->getParam('id')) {
43
+ $template->load($id);
44
+ } else {
45
+ $template->setTemplateType($this->getRequest()->getParam('type'));
46
+ $template->setTemplateText($this->getRequest()->getParam('text'));
47
+ $template->setTemplateStyles($this->getRequest()->getParam('styles'));
48
+ }
49
+
50
+ $storeId = (int)$this->getRequest()->getParam('store_id');
51
+ if(!$storeId) {
52
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
53
+ }
54
+
55
+ Varien_Profiler::start("newsletter_template_proccessing");
56
+ $vars = array();
57
+
58
+ $vars['subscriber'] = Mage::getModel('newsletter/subscriber');
59
+ if($this->getRequest()->getParam('subscriber')) {
60
+ $vars['subscriber']->load($this->getRequest()->getParam('subscriber'));
61
+ }
62
+
63
+ $template->emulateDesign($storeId);
64
+ $templateProcessed = $template->getProcessedTemplate($vars, true);
65
+ $template->revertDesign();
66
+
67
+ if($template->isPlain()) {
68
+ $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
69
+ }
70
+
71
+ Varien_Profiler::stop("newsletter_template_proccessing");
72
+
73
+ return $templateProcessed;
74
+ }
75
+
76
+ }
app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview/Form.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_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Admin form widget
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Newsletter_Template_Preview_Form extends Mage_Adminhtml_Block_Widget_Form
35
+ {
36
+
37
+ /**
38
+ * Preparing from for revision page
39
+ *
40
+ * @return Mage_Adminhtml_Block_Widget_Form
41
+ */
42
+ protected function _prepareForm()
43
+ {
44
+ $form = new Varien_Data_Form(array(
45
+ 'id' => 'preview_form',
46
+ 'action' => $this->getUrl('*/*/drop', array('_current' => true)),
47
+ 'method' => 'post'
48
+ ));
49
+
50
+ if ($data = $this->getFormData()) {
51
+
52
+ $mapper = array('preview_store_id' => 'store_id');
53
+
54
+ foreach ($data as $key => $value) {
55
+ if(array_key_exists($key, $mapper)) {
56
+ $name = $mapper[$key];
57
+ } else {
58
+ $name = $key;
59
+ }
60
+ $form->addField($key, 'hidden', array('name' => $name));
61
+ }
62
+ $form->setValues($data);
63
+ }
64
+
65
+ $form->setUseContainer(true);
66
+ $this->setForm($form);
67
+ return parent::_prepareForm();
68
+ }
69
+ }
70
+
app/code/core/Mage/Adminhtml/Block/Notification/Baseurl.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Adminhtml_Block_Notification_Baseurl extends Mage_Adminhtml_Block_Template
28
+ {
29
+ /**
30
+ * Get url for config settings where base url option can be changed
31
+ *
32
+ * @return string | false
33
+ */
34
+ public function getConfigUrl()
35
+ {
36
+ $defaultUnsecure= (string) Mage::getConfig()->getNode('default/'.Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL);
37
+ $defaultSecure = (string) Mage::getConfig()->getNode('default/'.Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);
38
+
39
+ if ($defaultSecure == '{{base_url}}' || $defaultUnsecure == '{{base_url}}') {
40
+ return $this->getUrl('adminhtml/system_config/edit', array('section'=>'web'));
41
+ }
42
+
43
+ $configData = Mage::getModel('core/config_data');
44
+ $dataCollection = $configData->getCollection()
45
+ ->addValueFilter('{{base_url}}');
46
+
47
+ $url = false;
48
+ foreach ($dataCollection as $data) {
49
+ if ($data->getScope() == 'stores') {
50
+ $code = Mage::app()->getStore($data->getScopeId())->getCode();
51
+ $url = $this->getUrl('adminhtml/system_config/edit', array('section'=>'web', 'store'=>$code));
52
+ }
53
+ if ($data->getScope() == 'websites') {
54
+ $code = Mage::app()->getWebsite($data->getScopeId())->getCode();
55
+ $url = $this->getUrl('adminhtml/system_config/edit', array('section'=>'web', 'website'=>$code));
56
+ }
57
+
58
+ if ($url) {
59
+ return $url;
60
+ }
61
+ }
62
+ return $url;
63
+ }
64
+ }
app/code/core/Mage/Adminhtml/Block/Notification/Grid.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml AdminNotification inbox grid
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Adminhtml_Block_Notification_Grid extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ protected function _construct()
38
+ {
39
+ $this->setSaveParametersInSession(true);
40
+ $this->setId('notificationGrid');
41
+ $this->setIdFieldName('notification_id');
42
+ $this->setDefaultSort('date_added', 'desc');
43
+ $this->setFilterVisibility(false);
44
+ }
45
+
46
+ /**
47
+ * Init backups collection
48
+ */
49
+ protected function _prepareCollection()
50
+ {
51
+ $collection = Mage::getModel('adminnotification/inbox')
52
+ ->getCollection()
53
+ ->addRemoveFilter();
54
+ $this->setCollection($collection);
55
+ return parent::_prepareCollection();
56
+ }
57
+
58
+ /**
59
+ * Configuration of grid
60
+ */
61
+ protected function _prepareColumns()
62
+ {
63
+ $this->addColumn('severity', array(
64
+ 'header' => Mage::helper('adminnotification')->__('Severity'),
65
+ 'width' => '60px',
66
+ 'index' => 'severity',
67
+ 'renderer' => 'adminhtml/notification_grid_renderer_severity',
68
+