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
+