Ultimate_ModuleCreator - Version 1.9.0.0

Version Notes

Major fixes and features in this version:

Features:
- Support for EAV entities.
- Module Admin menu can be placed anywhere in the menu tree.
- The frontend route of the module can be set manually on creation instead of using the module name.
- Allow users to comment on the generated entities.
- Link entities in a many to many relation with the catalog categories.
- Additional attribute types (dropdown, multiselects)
- Ability to add many to many relations between tree entities
- Displaying flat entities by store is optional now.

Bug Fixes:
- Most important: Module names can include uppercase letters. Until now using 'ModuleName' for the name of the module would make that module unusable on UX servers. Now it works.
- Entities were not displaying in product page unless they had a separate view page.
- Replaced 'addFilter' that had no effect with 'addFieldToFilter'
- Date fields were not saved properly when using some locale settings (French for example)

Improvements
- Pimped up the admin UI of the module creator
- Faster admin UI. No more ajax calls to add a new attribute or a new entity.
Made the HELP section include more valuable data.
- The aliases for models/blocks/helpers include the module namespace to avoid conflicts
- Generate an uninstall file to make it easier to remove installed modules.

For full release notes see https://github.com/tzyganu/UMC1.9/blob/master/README.md

Download this release

Release Info

Developer Marius
Extension Ultimate_ModuleCreator
Version 1.9.0.0
Comparing to
See all releases


Code changes from version 1.6.3.1 to 1.9.0.0

Files changed (280) hide show
  1. LICENSE_UMC.txt +0 -7
  2. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator.php +22 -22
  3. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit.php +240 -153
  4. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Form.php +22 -22
  5. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Entities.php +74 -100
  6. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Entities/Entity.php +43 -75
  7. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Entities/Entity/Attribute.php +43 -79
  8. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Help.php +284 -58
  9. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Help/Fieldset.php +73 -0
  10. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Relation.php +59 -131
  11. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Settings.php +72 -191
  12. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tabs.php +27 -25
  13. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Grid.php +153 -97
  14. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Grid/Column/Renderer/Download.php +71 -0
  15. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Menu.php +95 -0
  16. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Abstract.php +126 -0
  17. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Attribute.php +36 -0
  18. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Entity.php +36 -0
  19. app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Settings.php +36 -0
  20. app/code/community/Ultimate/ModuleCreator/Exception.php +7 -13
  21. app/code/community/Ultimate/ModuleCreator/Helper/Adminhtml.php +0 -51
  22. app/code/community/Ultimate/ModuleCreator/Helper/Data.php +473 -333
  23. app/code/community/Ultimate/ModuleCreator/Model/Abstract.php +95 -21
  24. app/code/community/Ultimate/ModuleCreator/Model/Adminhtml/System/Config/Source/Codepool.php +0 -55
  25. app/code/community/Ultimate/ModuleCreator/Model/Adminhtml/System/Config/Source/Install.php +0 -55
  26. app/code/community/Ultimate/ModuleCreator/Model/Adminhtml/System/Config/Source/Layout.php +0 -60
  27. app/code/community/Ultimate/ModuleCreator/Model/Attribute.php +550 -240
  28. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Abstract.php +355 -182
  29. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Country.php +114 -81
  30. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Decimal.php +36 -33
  31. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown.php +280 -0
  32. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Abstract.php +72 -0
  33. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Category.php +32 -0
  34. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Custom.php +94 -0
  35. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Customer.php +32 -0
  36. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Product.php +157 -0
  37. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/File.php +109 -77
  38. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Image.php +103 -73
  39. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Int.php +46 -32
  40. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Multiselect.php +118 -0
  41. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Text.php +32 -14
  42. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Textarea.php +85 -72
  43. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Timestamp.php +100 -70
  44. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Website.php +0 -101
  45. app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Yesno.php +147 -103
  46. app/code/community/Ultimate/ModuleCreator/Model/Config.php +71 -0
  47. app/code/community/Ultimate/ModuleCreator/Model/Entity.php +2740 -1651
  48. app/code/community/Ultimate/ModuleCreator/Model/Entity/Type/Abstract.php +434 -0
  49. app/code/community/Ultimate/ModuleCreator/Model/Entity/Type/Eav.php +737 -0
  50. app/code/community/Ultimate/ModuleCreator/Model/Entity/Type/Flat.php +28 -0
  51. app/code/community/Ultimate/ModuleCreator/Model/Module.php +1736 -987
  52. app/code/community/Ultimate/ModuleCreator/Model/Module/Collection.php +74 -74
  53. app/code/community/Ultimate/ModuleCreator/Model/Relation.php +199 -181
  54. app/code/community/Ultimate/ModuleCreator/Model/Source/Attribute/Scope.php +60 -0
  55. app/code/community/Ultimate/ModuleCreator/Model/Source/Attribute/Type.php +62 -0
  56. app/code/community/Ultimate/ModuleCreator/Model/Source/Attribute/Value/Source.php +53 -0
  57. app/code/community/Ultimate/ModuleCreator/Model/Source/Codepool.php +64 -0
  58. app/code/community/Ultimate/ModuleCreator/Model/Source/Entity/Layout.php +51 -0
  59. app/code/community/Ultimate/ModuleCreator/Model/Source/Entity/Menu.php +55 -0
  60. app/code/community/Ultimate/ModuleCreator/Model/Source/Entity/Type.php +51 -0
  61. app/code/community/Ultimate/ModuleCreator/Model/Source/Install.php +74 -0
  62. app/code/community/Ultimate/ModuleCreator/Model/Writer.php +65 -65
  63. app/code/community/Ultimate/ModuleCreator/controllers/Adminhtml/ModulecreatorController.php +242 -363
  64. app/code/community/Ultimate/ModuleCreator/etc/adminhtml.xml +42 -47
  65. app/code/community/Ultimate/ModuleCreator/etc/config.xml +123 -100
  66. app/code/community/Ultimate/ModuleCreator/etc/jstranslator.xml +26 -0
  67. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Catalog/Product/Edit/Tab/Entity/01_content.php +0 -176
  68. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Catalog/Product/Edit/Tab/Entity/IsTree/01_content.php +0 -229
  69. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/01_content.php +0 -24
  70. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Abstract/01_content.php +0 -179
  71. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/01_content.php +0 -48
  72. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/01_content.php +0 -29
  73. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/IsTree/01_top.php +0 -198
  74. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/IsTree/02_product_relation.php +0 -17
  75. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/IsTree/03_entity_relation.php +0 -17
  76. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/IsTree/04_footer.php +0 -1
  77. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/IsTree/01_content.php +0 -25
  78. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/01_top.php +0 -22
  79. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/02_image.php +0 -1
  80. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/03_file.php +0 -1
  81. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/04_wysiwyg.php +0 -1
  82. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/05_wysiwyg_is_tree.php +0 -1
  83. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/06_path_tree.php +0 -20
  84. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/07_parents.php +0 -8
  85. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/08_attributes.php +0 -5
  86. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/09_url_rewrite.php +0 -7
  87. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/10_status.php +0 -14
  88. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/11_rss.php +0 -14
  89. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/12_stores.php +0 -7
  90. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/13_add_values_not_tree.php +0 -9
  91. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/14_add_values_tree.php +0 -3
  92. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/15_get_entity_tree.php +0 -8
  93. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/16_footer.php +0 -1
  94. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Meta/01_content.php +0 -37
  95. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Product/01_content.php +0 -192
  96. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Sibling/01_content.php +0 -175
  97. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Sibling/IsTree/01_content.php +0 -224
  98. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Stores/01_content.php +0 -34
  99. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/01_top.php +0 -34
  100. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/02_seo.php +0 -5
  101. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/03_stores.php +0 -7
  102. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/04_relations_tabs.php +0 -5
  103. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/05_product_relation.php +0 -5
  104. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/06_footer.php +0 -3
  105. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/01_top.php +0 -43
  106. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/02_seo.php +0 -5
  107. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/03_stores.php +0 -7
  108. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/04_relations_tabs.php +0 -4
  109. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/05_product_relation.php +0 -4
  110. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/06_footer.php +0 -3
  111. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/01_top.php +0 -35
  112. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/02_columns_top.php +0 -12
  113. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/03_parents.php +0 -7
  114. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/04_grid_attributes.php +0 -5
  115. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/05_url_rewrite.php +0 -4
  116. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/06_grid_status.php +0 -9
  117. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/07_stores.php +0 -11
  118. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/08_created_at.php +0 -6
  119. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/09_updated_at.php +0 -6
  120. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/10_grid_actions.php +0 -17
  121. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/11_grid_export.php +0 -3
  122. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/12_columns_footer.php +0 -2
  123. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/13_mass_action_top.php +0 -14
  124. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/14_mass_action_status.php +0 -16
  125. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/15_mass_action_flags.php +0 -16
  126. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/16_mass_action_parents.php +0 -17
  127. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/17_footer.php +0 -47
  128. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Helper/File/01_content.php +0 -87
  129. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Helper/Image/01_content.php +0 -25
  130. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Tree/01_top.php +0 -219
  131. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Tree/02_status.php +0 -6
  132. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Tree/03_footer.php +0 -84
  133. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/01_top.php +0 -22
  134. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/02_top_status.php +0 -1
  135. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/03_content.php +0 -88
  136. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/04_status.php +0 -9
  137. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/05_footer.php +0 -22
  138. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/IsTree/01_content.php +0 -135
  139. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Helper/Wysiwyg/01_content.php +0 -30
  140. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Catalog/Product/List/Entity/01_top.php +0 -22
  141. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Catalog/Product/List/Entity/02_status.php +0 -1
  142. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Catalog/Product/List/Entity/03_footer.php +0 -7
  143. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Catalog/Product/List/01_content.php +0 -35
  144. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Child/List/01_content.php +0 -42
  145. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Children/01_content.php +0 -30
  146. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/01_top.php +0 -20
  147. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/02_status.php +0 -1
  148. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/03_footer.php +0 -28
  149. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/01_top.php +0 -20
  150. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/02_status.php +0 -1
  151. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/03_center.php +0 -58
  152. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/04_status_draw.php +0 -3
  153. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/05_children.php +0 -1
  154. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/06_active_children.php +0 -13
  155. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/07_active_children_no_status.php +0 -9
  156. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/08_footer.php +0 -25
  157. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/01_top.php +0 -49
  158. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/02_status.php +0 -1
  159. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/03_content_top.php +0 -5
  160. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/04_content.php +0 -1
  161. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/05_footer.php +0 -11
  162. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Sibling/List/01_content.php +0 -43
  163. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/View/01_content.php +0 -20
  164. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/Link/01_content.php +0 -12
  165. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/Subtree/01_content.php +0 -43
  166. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/01_top.php +0 -24
  167. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/02_status.php +0 -1
  168. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/03_template.php +0 -2
  169. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/04_status.php +0 -1
  170. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/05_footer.php +0 -4
  171. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Rss/01_content.php +0 -38
  172. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Controller/Adminhtml/Module/01_content.php +0 -46
  173. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Controller/Router/01_top.php +0 -38
  174. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Controller/Router/02_entity.php +0 -6
  175. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Controller/Router/03_footer.php +0 -18
  176. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Data/01_top.php +0 -10
  177. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Data/02_entity.php +0 -9
  178. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Data/03_footer.php +0 -1
  179. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/01_top.php +0 -10
  180. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/02_tree.php +0 -10
  181. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/03_rss.php +0 -18
  182. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/04_file.php +0 -18
  183. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/05_footer.php +0 -10
  184. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/Image/01_content.php +0 -21
  185. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Image/Abstract/01_content.php +0 -447
  186. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Product/01_top.php +0 -10
  187. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Product/02_content.php +0 -28
  188. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Product/03_footer.php +0 -1
  189. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/01_top.php +0 -32
  190. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/02_entity.php +0 -19
  191. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/03_entity_save.php +0 -16
  192. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/04_entity_save_tree.php +0 -17
  193. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/05_footer.php +0 -1
  194. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Search/Entity/01_content.php +0 -40
  195. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/01_top.php +0 -27
  196. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/02_var_sibling.php +0 -1
  197. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/03_var_product_relation.php +0 -1
  198. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/04_construct.php +0 -25
  199. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/05_url.php +0 -9
  200. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/06_url_rewrite_not_status.php +0 -22
  201. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/07_url_rewrite_status.php +0 -23
  202. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/08_editors.php +0 -13
  203. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/09_after_save_top.php +0 -7
  204. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/10_after_save_product.php +0 -1
  205. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/11_after_save_sibling.php +0 -1
  206. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/12_after_save_footer.php +0 -2
  207. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/13_product_relation.php +0 -38
  208. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/14_sibling_relation.php +0 -38
  209. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/15_tree.php +0 -224
  210. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/16_tree_status.php +0 -15
  211. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/17_footer.php +0 -1
  212. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/01_top.php +0 -116
  213. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/02_product_relation_info.php +0 -6
  214. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/03_sibling_info.php +0 -6
  215. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/04_info_footer.php +0 -2
  216. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/05_tree.php +0 -26
  217. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/06_product_relation.php +0 -55
  218. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/07_sibling_relation.php +0 -55
  219. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/08_footer.php +0 -1
  220. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/V2/01_top.php +0 -13
  221. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/V2/02_product_relation.php +0 -3
  222. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/V2/03_sibling_relation.php +0 -3
  223. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/V2/04_footer.php +0 -3
  224. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Product/01_content.php +0 -46
  225. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Sibling/01_content.php +0 -46
  226. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/01_top.php +0 -10
  227. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/02_tree_var.php +0 -5
  228. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/03_constructor.php +0 -62
  229. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/04_not_tree.php +0 -35
  230. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/05_tree.php +0 -193
  231. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/06_tree_before_save_no_url_rewrite.php +0 -34
  232. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/07_tree_before_save_url_rewrite.php +0 -45
  233. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/08_children_no_status.php +0 -67
  234. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/09_children_status.php +0 -73
  235. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/10_content.php +0 -186
  236. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/11_url_rewrite_status.php +0 -82
  237. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/12_url_rewrite_not_status.php +0 -78
  238. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/13_url_rewrite_before_save_not_tree.php +0 -19
  239. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/14_footer.php +0 -1
  240. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/01_top.php +0 -101
  241. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/02_tree.php +0 -95
  242. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/03_tree_status.php +0 -9
  243. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/04_product_relation.php +0 -22
  244. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/05_sibling_relation.php +0 -22
  245. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/06_footer.php +0 -1
  246. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Product/01_content.php +0 -69
  247. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Product/Collection/01_content.php +0 -50
  248. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Product/IsTree/01_content.php +0 -90
  249. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/01_top.php +0 -20
  250. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/02_save_relation.php +0 -24
  251. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/03_save_relation_tree.php +0 -47
  252. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/04_footer.php +0 -1
  253. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/Collection/01_content.php +0 -50
  254. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/01_top.php +0 -18
  255. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/02_status_top.php +0 -5
  256. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/03_content.php +0 -226
  257. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/04_not_status.php +0 -41
  258. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/05_status.php +0 -144
  259. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/06_footer.php +0 -1
  260. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Setup/01_content.php +0 -12
  261. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/Catalog/ProductController/01_content.php +0 -48
  262. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/Catalog/ProductController/IsTree/01_content.php +0 -35
  263. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/WidgetController/01_content.php +0 -23
  264. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/WidgetController/02_tree.php +0 -30
  265. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/WidgetController/03_footer.php +0 -1
  266. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/01_top.php +0 -98
  267. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/02_upload_image.php +0 -2
  268. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/03_upload_files.php +0 -2
  269. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/04_save_product_relation.php +0 -4
  270. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/05_save_sibling_relation.php +0 -4
  271. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/06_save_sibling_relation_tree.php +0 -6
  272. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/07_save.php +0 -11
  273. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/08_exception_upload.php +0 -3
  274. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/09_exception.php +0 -7
  275. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/10_center.php +0 -67
  276. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/11_mass_status.php +0 -31
  277. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/12_mass_update.php +0 -31
  278. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/13_mass_parents.php +0 -31
  279. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/14_product_relation_actions.php +0 -26
  280. app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/15_sibling_actions.php +0 -16
LICENSE_UMC.txt DELETED
@@ -1,7 +0,0 @@
1
- Copyright (c) 2012 Marius Strajeru
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator.php CHANGED
@@ -9,30 +9,30 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
  */
17
  /**
18
  * main admin block - grid container.
19
  *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
  */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator extends Mage_Adminhtml_Block_Widget_Grid_Container{
25
- /**
26
- * constructor
27
- * @access protected
28
- * @return void
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function __construct() {
32
- $this->_controller = 'adminhtml_modulecreator';
33
- $this->_blockGroup = 'modulecreator';
34
- $this->_headerText = Mage::helper('modulecreator')->__('Manage modules');
35
- parent::__construct();
36
- $this->_updateButton('add', 'label', Mage::helper('modulecreator')->__('Create new module'));
37
- }
38
- }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
  */
17
  /**
18
  * main admin block - grid container.
19
  *
20
+ * @category Ultimate
21
+ * @package Ultimate_ModuleCreator
22
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
23
  */
24
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator
25
+ extends Mage_Adminhtml_Block_Widget_Grid_Container {
26
+ /**
27
+ * constructor
28
+ * @access public
29
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
30
+ */
31
+ public function __construct() {
32
+ $this->_controller = 'adminhtml_modulecreator';
33
+ $this->_blockGroup = 'modulecreator';
34
+ $this->_headerText = Mage::helper('modulecreator')->__('Manage modules');
35
+ parent::__construct();
36
+ $this->_updateButton('add', 'label', Mage::helper('modulecreator')->__('Create new module'));
37
+ }
38
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit.php CHANGED
@@ -9,157 +9,244 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * admin edit block.
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{
25
- /**
26
- * construct
27
- * @access public
28
- * @return void
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function __construct(){
32
- parent::__construct();
33
- $this->_blockGroup = 'adminhtml';
34
- $this->_controller = 'modulecreator';
35
- $this->setTemplate('ultimate_modulecreator/edit.phtml');
36
- }
37
- /**
38
- * get header text
39
- * @access public
40
- * @return string
41
- * @see Mage_Adminhtml_Block_Widget_Container::getHeaderText()
42
- * @author Marius Strajeru <marius.strajeru@gmail.com>
43
- */
44
- public function getHeaderText(){
45
- $data = Mage::registry('current_module');
46
- if ($data){
47
- return Mage::helper('modulecreator')->__('Edit "%s" module', $data->extension);
48
- }
49
- return Mage::helper('modulecreator')->__('Create Module');
50
- }
51
- /**
52
- * prepare the layout
53
- * @access protected
54
- * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit
55
- * @see Mage_Adminhtml_Block_Widget_Form_Container::_prepareLayout()
56
- * @author Marius Strajeru <marius.strajeru@gmail.com>
57
- */
58
- protected function _prepareLayout(){
59
- $this->setChild('back_button',
60
- $this->getLayout()
61
- ->createBlock('adminhtml/widget_button')
62
- ->setData(array(
63
- 'label' => Mage::helper('modulecreator')->__('Back'),
64
- 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')',
65
- 'class' => 'back'
66
- ))
67
- );
68
- $this->setChild('reset_button',
69
- $this->getLayout()
70
- ->createBlock('adminhtml/widget_button')
71
- ->setData(array(
72
- 'label' => Mage::helper('modulecreator')->__('Reset'),
73
- 'onclick' => 'setLocation(\''.$this->getUrl('*/*/*', array('_current'=>true)).'\')'
74
- ))
75
- );
76
- $this->setChild('save_button',
77
- $this->getLayout()
78
- ->createBlock('adminhtml/widget_button')
79
- ->setData(array(
80
- 'label' => Mage::helper('modulecreator')->__('Save'),
81
- 'onclick' => 'moduleForm.submit()',
82
- 'class' => 'save'
83
- ))
84
- );
85
- $this->setChild('save_and_edit_button',
86
- $this->getLayout()
87
- ->createBlock('adminhtml/widget_button')
88
- ->setData(array(
89
- 'label' => Mage::helper('modulecreator')->__('Save and Continue Edit'),
90
- 'onclick' => 'saveAndContinueEdit(\''.$this->getSaveAndContinueUrl().'\')',
91
- 'class' => 'save'
92
- ))
93
- );
94
- return $this;
95
- }
96
- /**
97
- * get the back button html
98
- * @access public
99
- * @return string
100
- * @author Marius Strajeru <marius.strajeru@gmail.com>
101
- */
102
- public function getBackButtonHtml(){
103
- return $this->getChildHtml('back_button');
104
- }
105
- /**
106
- * get the cancel button html
107
- * @access public
108
- * @return string
109
- * @author Marius Strajeru <marius.strajeru@gmail.com>
110
- */
111
- public function getCancelButtonHtml(){
112
- return $this->getChildHtml('reset_button');
113
- }
114
- /**
115
- * get the save button html
116
- * @access public
117
- * @return string
118
- * @author Marius Strajeru <marius.strajeru@gmail.com>
119
- */
120
- public function getSaveButtonHtml(){
121
- return $this->getChildHtml('save_button');
122
- }
123
- /**
124
- * get the save and continue edit button html
125
- * @access public
126
- * @return string
127
- * @author Marius Strajeru <marius.strajeru@gmail.com>
128
- */
129
- public function getSaveAndEditButtonHtml(){
130
- return $this->getChildHtml('save_and_edit_button');
131
- }
132
- /**
133
- * get the save and continue edit url
134
- * @access public
135
- * @return string
136
- * @author Marius Strajeru <marius.strajeru@gmail.com>
137
- */
138
- public function getSaveAndContinueUrl(){
139
- return $this->getUrl('*/*/save', array(
140
- '_current' => true,
141
- 'back' => 'edit',
142
- 'tab'=> '{{tab_id}}',
143
- 'active_tab' => null
144
- ));
145
- }
146
- /**
147
- * get the validation url
148
- * @access public
149
- * @return string
150
- * @author Marius Strajeru <marius.strajeru@gmail.com>
151
- */
152
- public function getValidationUrl(){
153
- return $this->getUrl('*/*/validate', array('_current'=>true));
154
- }
155
- /**
156
- * check if edit mode is read only
157
- * @deprecated 1.3
158
- * @access public
159
- * @return bool
160
- * @author Marius Strajeru <marius.strajeru@gmail.com>
161
- */
162
- public function isReadonly(){
163
- return false;
164
- }
165
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * module edit block
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit
26
+ extends Mage_Adminhtml_Block_Widget_Form_Container {
27
+ const XML_FIELDSET_COLLAPSED = 'modulecreator/general/collapsed';
28
+ /**
29
+ * construct
30
+ * @access public
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function __construct() {
34
+ parent::__construct();
35
+ $this->_blockGroup = 'adminhtml_modulecreator';
36
+ $this->_controller = 'modulecreator';
37
+ $this->setTemplate('ultimate_modulecreator/edit.phtml');
38
+ }
39
+
40
+ /**
41
+ * get current module
42
+ * @access public
43
+ * @return mixed
44
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
45
+ */
46
+ public function getModule() {
47
+ return Mage::registry('current_module');
48
+ }
49
+ /**
50
+ * get header text
51
+ * @access public
52
+ * @return string
53
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
54
+ */
55
+ public function getHeaderText() {
56
+ $module = $this->getModule();
57
+ if ($module){
58
+ return Mage::helper('modulecreator')->__('Edit module "%s"', $module->getExtensionName());
59
+ }
60
+ return Mage::helper('modulecreator')->__('Create Module');
61
+ }
62
+ /**
63
+ * prepare the layout
64
+ * @access protected
65
+ * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit
66
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
67
+ */
68
+ protected function _prepareLayout() {
69
+ $this->setChild('back_button',
70
+ $this->getLayout()
71
+ ->createBlock('adminhtml/widget_button')
72
+ ->setData(array(
73
+ 'label' => Mage::helper('modulecreator')->__('Back'),
74
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')',
75
+ 'class' => 'back'
76
+ ))
77
+ );
78
+ $this->setChild('reset_button',
79
+ $this->getLayout()
80
+ ->createBlock('adminhtml/widget_button')
81
+ ->setData(array(
82
+ 'label' => Mage::helper('modulecreator')->__('Reset'),
83
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/*', array('_current'=>true)).'\')'
84
+ ))
85
+ );
86
+ $this->setChild('save_button',
87
+ $this->getLayout()
88
+ ->createBlock('adminhtml/widget_button')
89
+ ->setData(array(
90
+ 'label' => Mage::helper('modulecreator')->__('Save'),
91
+ 'onclick' => 'moduleForm.submit()',
92
+ 'class' => 'save'
93
+ ))
94
+ );
95
+ $this->setChild('save_and_edit_button',
96
+ $this->getLayout()
97
+ ->createBlock('adminhtml/widget_button')
98
+ ->setData(array(
99
+ 'label' => Mage::helper('modulecreator')->__('Save and Continue Edit'),
100
+ 'onclick' => 'saveAndContinueEdit(\''.$this->getSaveAndContinueUrl().'\')',
101
+ 'class' => 'save'
102
+ ))
103
+ );
104
+ $this->setChild('add-entity',
105
+ $this->getLayout()
106
+ ->createBlock('adminhtml/widget_button')
107
+ ->setData(array(
108
+ 'label' => Mage::helper('modulecreator')->__('Add entity'),
109
+ 'class' => 'add add-entity'
110
+ ))
111
+ );
112
+
113
+ $block = Mage::app()->getLayout()
114
+ ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_entities_entity')
115
+ ->setTemplate('ultimate_modulecreator/edit/tab/entities/entity.phtml')
116
+ ->setDefaultEntity()
117
+ ->setIncrement('{{entity_id}}');
118
+ $this->setChild('entity-template', $block);
119
+
120
+ $block = Mage::app()->getLayout()
121
+ ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_entities_entity_attribute')
122
+ ->setTemplate('ultimate_modulecreator/edit/tab/entities/entity/attribute.phtml')
123
+ ->setDefaultAttributeInstance()
124
+ ->setIncrement('{{attribute_id}}')
125
+ ->setEntityId('{{entity_id}}');
126
+ $this->setChild('attribute-template', $block);
127
+
128
+ $this->setChild('menu-selector', Mage::app()->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_menu'));
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * get the back button html
134
+ * @access public
135
+ * @return string
136
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
137
+ */
138
+ public function getBackButtonHtml() {
139
+ return $this->getChildHtml('back_button');
140
+ }
141
+ /**
142
+ * get the cancel button html
143
+ * @access public
144
+ * @return string
145
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
146
+ */
147
+ public function getCancelButtonHtml() {
148
+ return $this->getChildHtml('reset_button');
149
+ }
150
+ /**
151
+ * get the save button html
152
+ * @access public
153
+ * @return string
154
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
155
+ */
156
+ public function getSaveButtonHtml() {
157
+ return $this->getChildHtml('save_button');
158
+ }
159
+ /**
160
+ * get the save and continue edit button html
161
+ * @access public
162
+ * @return string
163
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
164
+ */
165
+ public function getSaveAndEditButtonHtml() {
166
+ return $this->getChildHtml('save_and_edit_button');
167
+ }
168
+ /**
169
+ * get html for "add entity" button
170
+ * @access public
171
+ * @return string
172
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
173
+ */
174
+ public function getAddEntityButtonHtml() {
175
+ return $this->getChildHtml('add-entity');
176
+ }
177
+
178
+ /**
179
+ * get the save and continue edit url
180
+ * @access public
181
+ * @return string
182
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
183
+ */
184
+ public function getSaveAndContinueUrl() {
185
+ return $this->getUrl('*/*/save', array(
186
+ '_current' => true,
187
+ 'back' => 'edit',
188
+ 'tab'=> '{{tab_id}}',
189
+ 'active_tab' => null
190
+ ));
191
+ }
192
+ /**
193
+ * get the validation url
194
+ * @access public
195
+ * @return string
196
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
197
+ */
198
+ public function getValidationUrl() {
199
+ return $this->getUrl('*/*/validate', array('_current'=>true));
200
+ }
201
+ /**
202
+ * check if edit mode is read only
203
+ * @access public
204
+ * @return bool
205
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
206
+ */
207
+ public function isReadonly() {
208
+ $module = $this->getModule();
209
+ if (!$module) {
210
+ return false;
211
+ }
212
+ if (Mage::registry('module_read_only')) {
213
+ return true;
214
+ }
215
+ if ($module = Mage::registry('current_module')) {
216
+ $installedModules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
217
+ foreach ($installedModules as $installed){
218
+ if ($installed == $module->getExtensionName()){
219
+ Mage::register('module_read_only', true);
220
+ return true;
221
+ }
222
+ }
223
+ }
224
+ return false;
225
+ }
226
+
227
+ /**
228
+ * get select for relations
229
+ * @access public
230
+ * @return string
231
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
232
+ */
233
+ public function getRelationSelectTemplate() {
234
+ $types = Mage::helper('modulecreator')->getRelationTypes();
235
+ $template = '<select class="relation-select" name="relation[#{e1}][#{e2}]" id="relation_#{e1}_#{e2}">';
236
+ foreach ($types as $type=>$values){
237
+ $template .= '<option value="'.$type.'">'.(string)$values->label.'</option>';
238
+ }
239
+ $template .= '</select>';
240
+ return $template;
241
+ }
242
+
243
+ /**
244
+ * check if fieldsets should be collapsed
245
+ * @access public
246
+ * @return int
247
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
248
+ */
249
+ public function getShowFieldsetsCollapsed(){
250
+ return (int)Mage::getStoreConfigFlag(self::XML_FIELDSET_COLLAPSED);
251
+ }
252
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Form.php CHANGED
@@ -9,30 +9,30 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
  */
17
  /**
18
  * admin form block
19
  *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
  */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Form extends Mage_Adminhtml_Block_Widget_Form{
25
- /**
26
- * prepare form
27
- * @access protected
28
- * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Form
29
- * @see Mage_Adminhtml_Block_Widget_Form::_prepareForm()
30
- * @author Marius Strajeru <marius.strajeru@gmail.com>
31
- */
32
- protected function _prepareForm() {
33
- $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/modulecreator/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post'));
34
- $form->setUseContainer(true);
35
- $this->setForm($form);
36
- return parent::_prepareForm();
37
- }
38
- }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
  */
17
  /**
18
  * admin form block
19
  *
20
+ * @category Ultimate
21
+ * @package Ultimate_ModuleCreator
22
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
23
  */
24
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Form
25
+ extends Mage_Adminhtml_Block_Widget_Form {
26
+ /**
27
+ * prepare form
28
+ * @access protected
29
+ * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Form
30
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
31
+ */
32
+ protected function _prepareForm() {
33
+ $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/modulecreator/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post'));
34
+ $form->setUseContainer(true);
35
+ $this->setForm($form);
36
+ return parent::_prepareForm();
37
+ }
38
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Entities.php CHANGED
@@ -9,107 +9,81 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
  * entities tab
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
  */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface{
25
- /**
26
- * constructor
27
- * @access public
28
- * @return void
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function __construct(){
32
- parent::__construct();
33
- $this->setTemplate('ultimate_modulecreator/edit/tab/entities.phtml');
34
- }
35
- /**
36
- * Return Tab label
37
- * @access public
38
- * @return string
39
- * @author Marius Strajeru <marius.strajeru@gmail.com>
40
- */
41
- public function getTabLabel(){
42
- return Mage::helper('modulecreator')->__('Entities');
43
- }
44
- /**
45
- * Return Tab title
46
- * @access public
47
- * @return string
48
- * @author Marius Strajeru <marius.strajeru@gmail.com>
49
- */
50
- public function getTabTitle(){
51
- return Mage::helper('modulecreator')->__('Entities');
52
- }
53
- /**
54
- * Can show tab in tabs
55
- * @access public
56
- * @return boolean
57
- * @author Marius Strajeru <marius.strajeru@gmail.com>
58
- */
59
- public function canShowTab(){
60
- return true;
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
- /**
64
- * Tab is hidden
65
- * @access public
66
- * @return boolean
67
- * @author Marius Strajeru <marius.strajeru@gmail.com>
68
- */
69
- public function isHidden(){
70
- return false;
71
- }
72
- /**
73
- * get the "add entity" button html
74
- * @access public
75
- * @return string
76
- * @author Marius Strajeru <marius.strajeru@gmail.com>
77
- */
78
- public function getAddButtonHtml($suffix = ""){
79
- $button = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
80
- 'label' => Mage::helper('modulecreator')->__('Add entity'),
81
- 'onclick' => 'addEntity();',
82
- 'class' => 'add',
83
- 'id' => 'add_entity_button'.$suffix
84
- ));
85
- return $button->toHtml();
86
- }
87
- /**
88
- * get the url for adding an entity
89
- * @access public
90
- * @return string
91
- * @author Marius Strajeru <marius.strajeru@gmail.com>
92
- */
93
- public function getAddEntityUrl(){
94
- return $this->getUrl('adminhtml/modulecreator/addEntity');
95
- }
96
- /**
97
- * get the url for adding an attribute
98
- * @access public
99
- * @return string
100
- * @author Marius Strajeru <marius.strajeru@gmail.com>
101
- */
102
- public function getAddAttributeUrl(){
103
- return $this->getUrl('adminhtml/modulecreator/addAttribute');
104
- }
105
- /**
106
- * get the list of entities
107
- * @access public
108
- * @return array()
109
- * @author Marius Strajeru <marius.strajeru@gmail.com>
110
- */
111
- public function getEntities(){
112
- $data = Mage::registry('current_module');
113
- return Mage::helper('modulecreator')->getXmlEntities($data);
114
- }
115
- }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
  * entities tab
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
  */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Tab_Entities
26
+ extends Mage_Adminhtml_Block_Widget
27
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface {
28
+ /**
29
+ * constructor
30
+ * @access public
31
+ * @return void
32
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
33
+ */
34
+ public function _construct() {
35
+ parent::_construct();
36
+ $this->setTemplate('ultimate_modulecreator/edit/tab/entities.phtml');
37
+ }
38
+ /**
39
+ * Return Tab label
40
+ * @access public
41
+ * @return string
42
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
43
+ */
44
+ public function getTabLabel() {
45
+ return Mage::helper('modulecreator')->__('Entities');
46
+ }
47
+ /**
48
+ * Return Tab title
49
+ * @access public
50
+ * @return string
51
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
52
+ */
53
+ public function getTabTitle() {
54
+ return Mage::helper('modulecreator')->__('Entities');
55
+ }
56
+ /**
57
+ * Can show tab in tabs
58
+ * @access public
59
+ * @return boolean
60
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
61
+ */
62
+ public function canShowTab() {
63
+ return true;
64
+ }
65
+
66
+ /**
67
+ * Tab is hidden
68
+ * @access public
69
+ * @return boolean
70
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
71
+ */
72
+ public function isHidden() {
73
+ return false;
74
+ }
75
 
76
+ /**
77
+ * get the list of entities
78
+ * @access public
79
+ * @return array()
80
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
81
+ */
82
+ public function getEntities() {
83
+ $module = Mage::registry('current_module');
84
+ if ($module) {
85
+ return $module->getEntities();
86
+ }
87
+ return array();
88
+ }
89
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Entities/Entity.php CHANGED
@@ -9,79 +9,47 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * entity block
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity extends Mage_Adminhtml_Block_Abstract{
25
- /**
26
- * get the field id
27
- * @access public
28
- * @return string
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function getFieldId(){
32
- return 'entity';
33
- }
34
- /**
35
- * get a yes/no select
36
- * @param string $id
37
- * @param string $name
38
- * @param int $selected
39
- * @access public
40
- * @return string
41
- * @author Marius Strajeru <marius.strajeru@gmail.com>
42
- */
43
- public function getYesNoSelect($id, $name, $selected){
44
- $options[(int)($selected == 1)] = array('selected'=>'selected');
45
- $options[1 - (int)($selected == 1)] = array();
46
- $select = $this->getLayout()->createBlock('adminhtml/html_select')
47
- ->setData(array(
48
- 'class' => 'select required-entry',
49
- 'id' => $id,
50
- 'name' => $name
51
- ))
52
- ->addOption(1, Mage::helper('modulecreator')->__('Yes'), $options[1])
53
- ->addOption(0, Mage::helper('modulecreator')->__('No'), $options[0]);
54
- return $select->getHtml();
55
- }
56
- /**
57
- * get a page template select
58
- * @param string $id
59
- * @param string $name
60
- * @param string $selected
61
- * @access public
62
- * @return string
63
- * @author Marius Strajeru <marius.strajeru@gmail.com>
64
- */
65
- public function getTemplateSelect($id, $name, $selected){
66
- $options = array();
67
- $layouts = Mage::getSingleton('page/config')->getPageLayouts();
68
- foreach ($layouts as $layout){
69
- if ($selected == $layout->getTemplate()){
70
- $options[$layout->getTemplate()] = array('selected'=>'selected');
71
- }
72
- else {
73
- $options[$layout->getTemplate()] = array();
74
- }
75
- }
76
- $select = $this->getLayout()->createBlock('adminhtml/html_select')
77
- ->setData(array(
78
- 'class' => 'select required-entry',
79
- 'id' => $id,
80
- 'name' => $name
81
- ));
82
- foreach ($layouts as $layout){
83
- $select->addOption($layout->getTemplate(), $layout->getLabel(), $options[$layout->getTemplate()]);
84
- }
85
- return $select->toHtml();
86
- }
87
- }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * add entity form
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity
26
+ extends Mage_Adminhtml_Block_Widget_Form {
27
+ /**
28
+ * prepare entity form
29
+ * @access protected
30
+ * @return string
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ protected function _prepareForm() {
34
+ $form = Mage::helper('modulecreator')->getXmlForm('entity');
35
+ $form->setHtmlIdPrefix('entity_'.$this->getIncrement().'_');
36
+ $form->addFieldNameSuffix('entity['.$this->getIncrement().']');
37
+ $this->setForm($form);
38
+ $form->addValues($this->getEntity()->getData());
39
+ return parent::_prepareForm();
40
+ }
41
+
42
+ /**
43
+ * set an entity with default values
44
+ * @access public
45
+ * @return Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity
46
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
47
+ */
48
+ public function setDefaultEntity() {
49
+ $entity = Mage::getModel('modulecreator/entity');
50
+ $settings = Mage::getStoreConfig(Ultimate_ModuleCreator_Helper_Data::XML_ENTITY_CONFIG_PATH);
51
+ $entity->addData($settings);
52
+ $this->setEntity($entity);
53
+ return $this;
54
+ }
55
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Entities/Entity/Attribute.php CHANGED
@@ -9,83 +9,47 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute block
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity_Attribute extends Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity{
25
- /**
26
- * get the field id
27
- * @access public
28
- * @return string
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function getFieldId(){
32
- return 'attribute';
33
- }
34
- /**
35
- * get the select with the attribute types
36
- * @param string $id
37
- * @param string $name
38
- * @param string $selected
39
- * @access public
40
- * @return string
41
- * @author Marius Strajeru <marius.strajeru@gmail.com>
42
- */
43
- public function getAttributeTypeSelect($id, $name, $selected){
44
- $types = Mage::helper('modulecreator')->getAttributeTypes();
45
- $select = $this->getLayout()->createBlock('adminhtml/html_select')
46
- ->setData(array(
47
- 'class' => 'select required-entry',
48
- 'id' => $id,
49
- 'name' => $name
50
- ));
51
- foreach ($types as $key=>$type){
52
- if ($key === $selected){
53
- $options = array('selected'=>'selected');
54
- }
55
- else{
56
- $options = array();
57
- }
58
- $select->addOption($key, $type, $options);
59
- }
60
- return $select->getHtml();
61
- }
62
- /**
63
- * get the select for the attribute scope
64
- * not used yet... maybe used in the future for EAV entities
65
- * @param string $id
66
- * @param string $name
67
- * @param string $selected
68
- * @access public
69
- * @return string
70
- * @author Marius Strajeru <marius.strajeru@gmail.com>
71
- */
72
- public function getScopeSelect($id, $name, $selected){
73
- $scopes = Mage::helper('modulecreator')->getScopes();
74
- $select = $this->getLayout()->createBlock('adminhtml/html_select')
75
- ->setData(array(
76
- 'class' => 'select required-entry',
77
- 'id' => $id,
78
- 'name' => $name
79
- ));
80
- foreach ($scopes as $key=>$scope){
81
- if ($key === $selected){
82
- $options = array('selected'=>'selected');
83
- }
84
- else{
85
- $options = array();
86
- }
87
- $select->addOption($key, $scope, $options);
88
- }
89
- return $select->getHtml();
90
- }
91
- }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * add attribute form
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity_Attribute
26
+ extends Mage_Adminhtml_Block_Widget_Form {
27
+ /**
28
+ * prepare attribute form
29
+ * @access protected
30
+ * @return string
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ protected function _prepareForm() {
34
+ $form = Mage::helper('modulecreator')->getXmlForm('attribute', false);
35
+ $form->setHtmlIdPrefix('attribute_'.$this->getEntityId().'_'.$this->getIncrement().'_');
36
+ $form->addFieldNameSuffix('entity['.$this->getEntityId().'][attributes]['.$this->getIncrement().']');
37
+ $this->setForm($form);
38
+ $form->addValues($this->getAttributeInstance()->getData());
39
+ return parent::_prepareForm();
40
+ }
41
+
42
+ /**
43
+ * set an entity with default values
44
+ * @access public
45
+ * @return Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity
46
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
47
+ */
48
+ public function setDefaultAttributeInstance() {
49
+ $attribute = Mage::getModel('modulecreator/attribute');
50
+ $settings = Mage::getStoreConfig(Ultimate_ModuleCreator_Helper_Data::XML_ATTRIBUTE_CONFIG_PATH);
51
+ $attribute->addData($settings);
52
+ $this->setAttributeInstance($attribute);
53
+ return $this;
54
+ }
55
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Help.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
  /**
3
  * Ultimate_ModuleCreator extension
4
  *
@@ -9,64 +9,290 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
  /**
18
  * help tab block
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
  */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface{
25
- /**
26
- * constructor
27
- * @access public
28
- * @return string
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function __construct(){
32
- parent::__construct();
33
- $this->setTemplate('ultimate_modulecreator/edit/tab/help.phtml');
34
- }
35
- /**
36
- * Return Tab label
37
- * @access public
38
- * @return string
39
- * @author Marius Strajeru <marius.strajeru@gmail.com>
40
- */
41
- public function getTabLabel(){
42
- return Mage::helper('modulecreator')->__('Help');
43
- }
44
- /**
45
- * Return Tab title
46
- * @access public
47
- * @return string
48
- * @author Marius Strajeru <marius.strajeru@gmail.com>
49
- */
50
- public function getTabTitle(){
51
- return Mage::helper('modulecreator')->__('Help');
52
- }
53
- /**
54
- * Can show tab in tabs
55
- * @access public
56
- * @return boolean
57
- * @author Marius Strajeru <marius.strajeru@gmail.com>
58
- */
59
- public function canShowTab(){
60
- return true;
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
- /**
64
- * Tab is hidden
65
- * @access public
66
- * @return boolean
67
- * @author Marius Strajeru <marius.strajeru@gmail.com>
68
- */
69
- public function isHidden(){
70
- return false;
71
- }
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
  /**
3
  * Ultimate_ModuleCreator extension
4
  *
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
  /**
18
  * help tab block
19
+ *
20
+ * @category Ultimate
21
+ * @package Ultimate_ModuleCreator
22
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
23
  */
24
+ class Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Tab_Help
25
+ extends Mage_Adminhtml_Block_Widget_Form
26
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface {
27
+ /**
28
+ * constructor
29
+ * @access public
30
+ * @return void
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function _construct() {
34
+ parent::_construct();
35
+ $this->setTemplate('ultimate_modulecreator/edit/tab/help.phtml');
36
+ }
37
+ /**
38
+ * Return Tab label
39
+ * @access public
40
+ * @return string
41
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
42
+ */
43
+ public function getTabLabel() {
44
+ return Mage::helper('modulecreator')->__('Help');
45
+ }
46
+ /**
47
+ * Return Tab title
48
+ * @access public
49
+ * @return string
50
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
51
+ */
52
+ public function getTabTitle() {
53
+ return Mage::helper('modulecreator')->__('Help');
54
+ }
55
+ /**
56
+ * Can show tab in tabs
57
+ * @access public
58
+ * @return boolean
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function canShowTab() {
62
+ return true;
63
+ }
64
+
65
+ /**
66
+ * Tab is hidden
67
+ * @access public
68
+ * @return boolean
69
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
70
+ */
71
+ public function isHidden() {
72
+ return false;
73
+ }
74
+ /**
75
+ * get UMC version
76
+ * @access public
77
+ * @return string
78
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
79
+ */
80
+ public function getVersion(){
81
+ $version = (string)Mage::app()->getConfig()->getNode('modules/Ultimate_ModuleCreator/version');
82
+ $build = (string)Mage::app()->getConfig()->getNode('modules/Ultimate_ModuleCreator/build');
83
+ if ($build){
84
+ $version .= ' - '.$build;
85
+ }
86
+ return $version;
87
+ }
88
+ /**
89
+ * prepare tab layout
90
+ * @return Mage_Core_Block_Abstract
91
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
92
+ */
93
+ protected function _prepareLayout() {
94
+ $columns = array(
95
+ 'label' => array(
96
+ 'header'=>Mage::helper('modulecreator')->__('Field'),
97
+ 'key' =>'label'
98
+ ),
99
+ 'type' => array(
100
+ 'header'=>Mage::helper('modulecreator')->__('Type'),
101
+ 'key' =>'type'
102
+ ),
103
+ 'required' => array(
104
+ 'header'=>Mage::helper('modulecreator')->__('Required'),
105
+ 'type' => 'bool',
106
+ 'key' =>'required'
107
+ ),
108
+ 'system' => array(
109
+ 'header'=>Mage::helper('modulecreator')->__('Has default'),
110
+ 'type' => 'bool',
111
+ 'key' =>'system'
112
+ ),
113
+ 'tooltip' => array(
114
+ 'header'=>Mage::helper('modulecreator')->__('Description'),
115
+ 'key' =>'tooltip'
116
+ ),
117
+ );
118
+ $settingsTabHelp = $this->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset')
119
+ ->setFieldsets(Mage::helper('modulecreator')->getFieldsetXmlData('settings'))
120
+ ->setColumns($columns)
121
+ ->setDescription(Mage::helper('modulecreator')->__('General settings tab.'));
122
+
123
+ $entityTabHelp = $this->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset')
124
+ ->setFieldsets(Mage::helper('modulecreator')->getFieldsetXmlData('entity'))
125
+ ->setColumns($columns)
126
+ ->setDescription(Mage::helper('modulecreator')->__('Entity management.'));
127
+
128
+ $attributeTabHelp = $this->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset')
129
+ ->setFieldsets(Mage::helper('modulecreator')->getFieldsetXmlData('attribute'))
130
+ ->setColumns($columns)
131
+ ->setDescription(Mage::helper('modulecreator')->__('Field/Attribute management.'));
132
+
133
+ $fieldTypes = array(
134
+ 'field_types'=> array(
135
+ 'label'=>Mage::helper('modulecreator')->__('Supported field / attribute types'),
136
+ 'fields' => Mage::helper('modulecreator')->getAttributeTypes())
137
+ );
138
+ $fieldTypesHelp = $this->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset')
139
+ ->setFieldsets($fieldTypes)
140
+ ->setColumns(array(
141
+ 'label' => array(
142
+ 'header'=>Mage::helper('modulecreator')->__('Field'),
143
+ 'key' =>'label'
144
+ ),
145
+ 'allow_is_name' => array(
146
+ 'header'=>Mage::helper('modulecreator')->__('Can behave as name'),
147
+ 'key' =>'allow_is_name',
148
+ 'type' => 'bool'
149
+ ),
150
+ ))
151
+ ->setDescription(Mage::helper('modulecreator')->__('Supported field / attribute types'));
152
+
153
+ $relationTypes = array(
154
+ 'field_types'=> array(
155
+ 'label'=>Mage::helper('modulecreator')->__('Relation types'),
156
+ 'fields' => Mage::helper('modulecreator')->getRelationTypes()
157
+ ));
158
+ $relationsTypesHelp = $this->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset')
159
+ ->setFieldsets($relationTypes)
160
+ ->setColumns(array(
161
+ 'label' => array(
162
+ 'header'=>Mage::helper('modulecreator')->__('Relation'),
163
+ 'key' =>'label'
164
+ ),
165
+ 'description' => array(
166
+ 'header'=>Mage::helper('modulecreator')->__('Description'),
167
+ 'key' =>'description',
168
+ ),
169
+ ))
170
+ ->setDescription(Mage::helper('modulecreator')->__('Entity Relations'));
171
+
172
+ $objN = new stdClass();
173
+ $objN->restricted = 'Mage';
174
+ $objN->label = Mage::helper('modulecreator')->__('Disallowed namespace names');
175
+
176
+ $routers = (array)Mage::getConfig()->getNode('frontend/routers');
177
+ $objM = new stdClass();
178
+ $objM->restricted = implode(', ',array_keys($routers));
179
+ $objM->label = Mage::helper('modulecreator')->__('Disallowed module names');
180
+
181
+ $entityRestrictedNames = implode(', ',array_keys((array)Mage::helper('modulecreator')->getConfig()->getNode('restricted/entity')));
182
+ $objE = new stdClass();
183
+ $objE->restricted = $entityRestrictedNames;
184
+ $objE->label = Mage::helper('modulecreator')->__('Disallowed entity names');
185
+
186
+ $attributeRestrictedNames = implode(', ',array_keys((array)Mage::helper('modulecreator')->getConfig()->getNode('restricted/attribute')));
187
+ $objA = new stdClass();
188
+ $objA->restricted = $attributeRestrictedNames;
189
+ $objA->label = Mage::helper('modulecreator')->__('Disallowed field/attribute names');
190
+ $restrictions = array(
191
+ 'field_types'=> array(
192
+ 'label'=>Mage::helper('modulecreator')->__('Naming restrictions'),
193
+ 'fields' => array($objN, $objM, $objE, $objA))
194
+ );
195
+
196
+ $restrictionsHelp = $this->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset')
197
+ ->setFieldsets($restrictions)
198
+ ->setColumns(array(
199
+ 'label' => array(
200
+ 'header'=>Mage::helper('modulecreator')->__('Entity'),
201
+ 'key' =>'label'
202
+ ),
203
+ 'description' => array(
204
+ 'header'=>Mage::helper('modulecreator')->__('Resticted'),
205
+ 'key' =>'restricted',
206
+ ),
207
+ ))
208
+ ->setDescription(Mage::helper('modulecreator')->__('Naming restrictions'));
209
+ $currentModule = Mage::registry('current_module');
210
+ if (!$currentModule){
211
+ $currentModule = Mage::getModel('modulecreator/module');
212
+ }
213
+ $files = $currentModule->getConfig()->getNode('files');
214
+ $allowedFiles = array();
215
+ foreach ((array)$files as $key=>$file){
216
+ if ($file->scope == 'disabled'){
217
+ continue;
218
+ }
219
+ $allowedFiles[] = $file;
220
+ }
221
+
222
+ $filesHelp = $this->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset')
223
+ ->setFieldsets(array(
224
+ 'files'=> array(
225
+ 'label'=>Mage::helper('modulecreator')->__('Generated files'),
226
+ 'fields' => $allowedFiles)
227
+ ))
228
+ ->setColumns(array(
229
+ 'label' => array(
230
+ 'header'=>Mage::helper('modulecreator')->__('File'),
231
+ 'key' =>'title'
232
+ ),
233
+ 'destination'=> array(
234
+ 'header'=>Mage::helper('modulecreator')->__('Path'),
235
+ 'key' =>'destination'
236
+ ),
237
+ 'description' => array(
238
+ 'header'=>Mage::helper('modulecreator')->__('Description'),
239
+ 'key' =>'description',
240
+ ),
241
+ 'condition' => array(
242
+ 'header'=>Mage::helper('modulecreator')->__('Condition'),
243
+ 'key' =>'condition',
244
+ ),
245
+ ))
246
+ ->setDescription(Mage::helper('modulecreator')->__('Created files'));
247
+
248
+ $this->setChild('settings_tab_help', $settingsTabHelp);
249
+ $this->setChild('entity_tab_help', $entityTabHelp);
250
+ $this->setChild('attribute_tab_help', $attributeTabHelp);
251
+ $this->setChild('attribute_types_help', $fieldTypesHelp);
252
+ $this->setChild('relation_types_help', $relationsTypesHelp);
253
+ $this->setChild('restrictions_help', $restrictionsHelp);
254
+ $this->setChild('files_help', $filesHelp);
255
+
256
+ $releaseNotes = (array)Mage::helper('modulecreator')->getReleaseNotes();
257
+ $releaseNotesHelp = $this->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset')
258
+ ->setFieldsets($releaseNotes)
259
+ ->setColumns(array(
260
+ 'type' => array(
261
+ 'header'=>Mage::helper('modulecreator')->__('Type'),
262
+ 'key' =>'type'
263
+ ),
264
+ 'label' => array(
265
+ 'header'=>Mage::helper('modulecreator')->__('Label'),
266
+ 'key' =>'label'
267
+ ),
268
+ 'comment' => array(
269
+ 'header'=>Mage::helper('modulecreator')->__('Comment'),
270
+ 'key' =>'comment'
271
+ ),
272
+ ))
273
+ ->setDescription(Mage::helper('modulecreator')->__('Release notes'))
274
+ ;
275
+ $this->setChild('release_notes', $releaseNotesHelp);
276
 
277
+ $thanks = $this->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset')
278
+ ->setFieldsets(array(
279
+ 'files'=> array(
280
+ 'label'=>Mage::helper('modulecreator')->__('Thanks'),
281
+ 'fields' => (array)Mage::helper('modulecreator')->getThanks())
282
+ ))
283
+ ->setColumns(array(
284
+ 'type' => array(
285
+ 'header'=>Mage::helper('modulecreator')->__('To'),
286
+ 'key' =>'to'
287
+ ),
288
+ 'label' => array(
289
+ 'header'=>Mage::helper('modulecreator')->__('Because'),
290
+ 'key' =>'for'
291
+ ),
292
+ )
293
+ )
294
+ ->setDescription(Mage::helper('modulecreator')->__('Thank you for your help'));
295
+ $this->setChild('thanks', $thanks);
296
+ return parent::_prepareLayout();
297
+ }
298
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Help/Fieldset.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * help fieldset
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Tab_Help_Fieldset
26
+ extends Mage_Adminhtml_Block_Template {
27
+ /**
28
+ * default column type
29
+ */
30
+ const DEFAULT_COLUMN_TYPE = 'text';
31
+
32
+ /**
33
+ * constructor
34
+ * @access public
35
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
36
+ */
37
+ public function __construct(){
38
+ parent::__construct();
39
+ $this->setTemplate('ultimate_modulecreator/edit/tab/help/fieldset.phtml');
40
+ }
41
+
42
+ /**
43
+ * format value
44
+ * @param $field
45
+ * @param $column
46
+ * @return string
47
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
48
+ */
49
+ public function getFormatedValue($field, $column){
50
+ if (!isset($column['type'])){
51
+ $column['type'] = self::DEFAULT_COLUMN_TYPE;
52
+ }
53
+ if (!isset($column['key'])){
54
+ return '';
55
+ }
56
+ $key = $column['key'];
57
+ $rawValue = $field->$key;
58
+ switch($column['type']){
59
+ case 'bool':
60
+ $value = (bool)(string)$rawValue;
61
+ if ($value == 1){
62
+ return Mage::helper('modulecreator')->__('Yes');
63
+ }
64
+ return Mage::helper('modulecreator')->__('No');
65
+ break;
66
+ case 'text':
67
+ //intentional fall through
68
+ default:
69
+ return $rawValue;
70
+ break;
71
+ }
72
+ }
73
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Relation.php CHANGED
@@ -9,138 +9,66 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
  /**
18
  * relations tab block
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Relation extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface{
25
- /**
26
- * constructor
27
- * @access public
28
- * @return void
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function __construct(){
32
- parent::__construct();
33
- $this->setTemplate('ultimate_modulecreator/edit/tab/relation.phtml');
34
- }
35
- /**
36
- * Return Tab label
37
- * @access public
38
- * @return string
39
- * @author Marius Strajeru <marius.strajeru@gmail.com>
40
- */
41
- public function getTabLabel(){
42
- return Mage::helper('modulecreator')->__('Entity Relations');
43
- }
44
- /**
45
- * Return Tab title
46
- * @access public
47
- * @return string
48
- * @author Marius Strajeru <marius.strajeru@gmail.com>
49
- */
50
- public function getTabTitle(){
51
- return Mage::helper('modulecreator')->__('Entity Relations');
52
- }
53
- /**
54
- * Can show tab in tabs
55
- * @access public
56
- * @return boolean
57
- * @author Marius Strajeru <marius.strajeru@gmail.com>
58
- */
59
- public function canShowTab(){
60
- return true;
61
- }
 
 
62
 
63
- /**
64
- * Tab is hidden
65
- * @access public
66
- * @return boolean
67
- * @author Marius Strajeru <marius.strajeru@gmail.com>
68
- */
69
- public function isHidden(){
70
- return count($this->getRelations()) > 0;
71
- }
72
- /**
73
- * select with relations
74
- * @access public
75
- * @return string
76
- * @author Marius Strajeru <marius.strajeru@gmail.com>
77
- */
78
- public function getRelationSelect($id, $name, $selected){
79
- $options = array();
80
- $relations = Mage::helper('modulecreator')->getAvailableRelations();
81
- foreach ($relations as $key=>$relation){
82
- if ($selected == $key){
83
- $options[$key] = array('selected'=>'selected');
84
- }
85
- else {
86
- $options[$key] = array();
87
- }
88
- }
89
- $select = $this->getLayout()->createBlock('adminhtml/html_select')
90
- ->setData(array(
91
- 'class' => 'select',
92
- 'id' => $id,
93
- 'name' => $name
94
- ));
95
- foreach ($relations as $key=>$relation){
96
- $select->addOption($key, $relation, $options[$key]);
97
- }
98
- return $select->toHtml();
99
- }
100
- /**
101
- * get the list of relations
102
- * @access public
103
- * @return array()
104
- * @author Marius Strajeru <marius.strajeru@gmail.com>
105
- */
106
- public function getRelations(){
107
- if (!$this->hasData('relations')){
108
- $data = Mage::registry('current_module');
109
- $entities = Mage::helper('modulecreator')->getXmlEntities($data);
110
- $relations = array();
111
- if ($data){
112
- $xmlRelations = $data->descend('relations');
113
- if ($xmlRelations){
114
- foreach ($xmlRelations->children() as $key =>$xmlRelation){
115
- foreach ($xmlRelation->asArray() as $key=>$value){
116
- $parts = explode('_', $key);
117
- if (count($parts) != 2){
118
- continue;
119
- }
120
- $found0 = -1;
121
- $found1 = -1;
122
- $title0 = '';
123
- $title1 = '';
124
- foreach ($entities as $ek=>$entity){
125
- if ($entity->getNameSingular() == $parts[0]){
126
- $found0 = $ek;
127
- $title0 = $entity->getLabelSingular();
128
- }
129
- if ($entity->getNameSingular() == $parts[1]){
130
- $found1 = $ek;
131
- $title1 = $entity->getLabelSingular();
132
- }
133
- }
134
- if ($found0 != -1 && $found1 != -1){
135
- $val = array('t0'=>$title0, 't1'=>$title1, 'val'=>(string)$value);
136
- $relations[$found0][$found1] = new Varien_Object($val);
137
- }
138
- }
139
- }
140
- }
141
- }
142
- $this->setData('relations', $relations);
143
- }
144
- return $this->getData('relations');
145
- }
146
  }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
  /**
18
  * relations tab block
19
+ *
20
+ * @category Ultimate
21
+ * @package Ultimate_ModuleCreator
22
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
23
+ */
24
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Relation
25
+ extends Mage_Adminhtml_Block_Widget_Form
26
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface {
27
+ /**
28
+ * constructor
29
+ * @access public
30
+ * @return void
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function _construct() {
34
+ parent::_construct();
35
+ $this->setTemplate('ultimate_modulecreator/edit/tab/relation.phtml');
36
+ }
37
+ /**
38
+ * Return Tab label
39
+ * @access public
40
+ * @return string
41
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
42
+ */
43
+ public function getTabLabel() {
44
+ return Mage::helper('modulecreator')->__('Entity Relations');
45
+ }
46
+ /**
47
+ * Return Tab title
48
+ * @access public
49
+ * @return string
50
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
51
+ */
52
+ public function getTabTitle() {
53
+ return Mage::helper('modulecreator')->__('Entity Relations');
54
+ }
55
+ /**
56
+ * Can show tab in tabs
57
+ * @access public
58
+ * @return boolean
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function canShowTab() {
62
+ return true;
63
+ }
64
 
65
+ /**
66
+ * Tab is hidden
67
+ * @access public
68
+ * @return boolean
69
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
70
+ */
71
+ public function isHidden() {
72
+ return count($this->getRelations()) == 0;
73
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Settings.php CHANGED
@@ -9,198 +9,79 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
  * settings tab block
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
  */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Settings extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface{
25
- /**
26
- * Return Tab label
27
- * @access public
28
- * @return string
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function getTabLabel(){
32
- return Mage::helper('modulecreator')->__('General Settings');
33
- }
34
- /**
35
- * Return Tab title
36
- * @access public
37
- * @return string
38
- * @author Marius Strajeru <marius.strajeru@gmail.com>
39
- */
40
- public function getTabTitle(){
41
- return Mage::helper('modulecreator')->__('General Settings');
42
- }
43
- /**
44
- * Can show tab in tabs
45
- * @access public
46
- * @return boolean
47
- * @author Marius Strajeru <marius.strajeru@gmail.com>
48
- */
49
- public function canShowTab(){
50
- return true;
51
- }
 
 
52
 
53
- /**
54
- * Tab is hidden
55
- * @access public
56
- * @return boolean
57
- * @author Marius Strajeru <marius.strajeru@gmail.com>
58
- */
59
- public function isHidden(){
60
- return false;
61
- }
62
- /**
63
- * prepare the form
64
- * @access public
65
- * @return Ultimate_ModuleCreator_Block_Adminhtml_Edit_Tab_Settings
66
- * @author Marius Strajeru <marius.strajeru@gmail.com>
67
- */
68
- protected function _prepareForm(){
69
- $form = new Varien_Data_Form();
70
- $form->setHtmlIdPrefix('settings_');
71
- $fieldWidth = '255';
72
- $fieldset = $form->addFieldset('settings_fieldset', array('legend'=>Mage::helper('modulecreator')->__('General Information')));
73
- $data = Mage::registry('current_module');
74
- if ($data){
75
- $values = new Varien_Object($data->asArray());
76
- }
77
- else{
78
- $values = new Varien_Object(Mage::getStoreConfig('modulecreator/settings'));
79
- }
80
- $fieldset->addField('current_extension', 'hidden', array(
81
- 'name' => 'current_extension',
82
- 'value' => $values->getExtension()
83
- ));
84
- $fieldset->addField('namespace', 'text', array(
85
- 'name' => 'namespace',
86
- 'label' => Mage::helper('modulecreator')->__('Namespace'),
87
- 'title' => Mage::helper('modulecreator')->__('Namespace'),
88
- 'required' => true,
89
- 'style' => 'width:'.$fieldWidth.'px',
90
- 'value' => $values->getNamespace(),
91
- 'class' => 'validate-alphanum',
92
- 'after_element_html'=> Mage::helper('modulecreator/adminhtml')->getTooltipHtml(Mage::helper('modulecreator')->__('Namespace'), Mage::helper('modulecreator')->__('This is the folder name of your new extension. Your company name could go here. Use only letters and numbers. Start with a capital letter.'))
93
- ));
94
- $fieldset->addField('module_name', 'text', array(
95
- 'name' => 'module_name',
96
- 'label' => Mage::helper('modulecreator')->__('Module name'),
97
- 'title' => Mage::helper('modulecreator')->__('Module name'),
98
- 'required' => true,
99
- 'value' => $values->getModuleName(),
100
- 'class' => 'validate-alphanum',
101
- 'style' => 'width:'.$fieldWidth.'px',
102
- 'after_element_html'=> Mage::helper('modulecreator/adminhtml')->getTooltipHtml(Mage::helper('modulecreator')->__('Module name'), Mage::helper('modulecreator')->__('This is your extension name. You cannot name your extension with an existing name, not even under a different namespace.'))
103
- ));
104
- $fieldset->addField('codepool', 'select', array(
105
- 'name' => 'codepool',
106
- 'label' => Mage::helper('modulecreator')->__('Code pool'),
107
- 'title' => Mage::helper('modulecreator')->__('Code pool'),
108
- 'options' => Mage::getModel('modulecreator/adminhtml_system_config_source_codepool')->getAllOptions(),
109
- 'required' => true,
110
- 'value' => $values->getCodepool(),
111
- 'style' => 'width:'.$fieldWidth.'px',
112
- 'after_element_html'=> Mage::helper('modulecreator/adminhtml')->getTooltipHtml(Mage::helper('modulecreator')->__('Code pool'), Mage::helper('modulecreator')->__('This is the code folder in which your extension will be installed. If you don\'t know what goes here, choose "local"'))
113
- ));
114
- $installOptions = array(
115
- 'name' => 'install',
116
- 'label' => Mage::helper('modulecreator')->__('Action'),
117
- 'title' => Mage::helper('modulecreator')->__('Action'),
118
- 'options' => Mage::getModel('modulecreator/adminhtml_system_config_source_install')->getAllOptions(),
119
- 'required' => true,
120
- 'value' => $values->getInstall(),
121
- 'style' => 'width:'.$fieldWidth.'px',
122
- 'after_element_html'=> Mage::helper('modulecreator/adminhtml')->getTooltipHtml(Mage::helper('modulecreator')->__('Action'), Mage::helper('modulecreator')->__('This allows you to create an archive with your extension located in var/modulecreator folder of your current instance so you can edit it later or install it later manually by copying the "app" folder in the archive over the "app" folder of your instance and the "skin" folder in the archive over the "skin" folder of your instance. If you choose to install it directly please backup first. If you choose to install it you will be able to edit later but you will have to install the modified version manually.' ))
123
- );
124
- if (!$this->_canInstall()){
125
- $installOptions['disabled'] = 'disabled';
126
- $installOptions['value'] = 0;
127
- }
128
- $fieldset->addField('install', 'select', $installOptions);
129
- $fieldsetDesign = $form->addFieldset('settings_design_fieldset', array('legend'=>Mage::helper('modulecreator')->__('Design')));
130
- $fieldsetDesign->addField('front_package', 'text', array(
131
- 'name' => 'front_package',
132
- 'label' => Mage::helper('modulecreator')->__('Frontend package'),
133
- 'title' => Mage::helper('modulecreator')->__('Frontend package'),
134
- 'required' => true,
135
- 'value' => ($values->getFrontPackage()) ? $values->getFrontPackage() : Mage_Core_Model_Design_Package::BASE_PACKAGE,
136
- 'style' => 'width:'.$fieldWidth.'px',
137
- 'after_element_html'=> Mage::helper('modulecreator/adminhtml')->getTooltipHtml(Mage::helper('modulecreator')->__('Frontend package'), Mage::helper('modulecreator')->__('This is the name of the design interface (package) of your mangento instance. If you don\'t know what goes here put "base".' ))
138
- ));
139
- $fieldsetDesign->addField('front_templates', 'text', array(
140
- 'name' => 'front_templates',
141
- 'label' => Mage::helper('modulecreator')->__('Frontend theme - templates'),
142
- 'title' => Mage::helper('modulecreator')->__('Frontend theme - templates'),
143
- 'required' => true,
144
- 'value' => ($values->getFrontTemplates()) ? $values->getFrontTemplates() : Mage_Core_Model_Design_Package::DEFAULT_THEME,
145
- 'style' => 'width:'.$fieldWidth.'px',
146
- 'after_element_html'=> Mage::helper('modulecreator/adminhtml')->getTooltipHtml(Mage::helper('modulecreator')->__('Frontend theme - templates'), Mage::helper('modulecreator')->__('This is the name of the theme of your mangento instance for the template files. If you don\'t know what goes here put "default".' ))
147
- ));
148
- $fieldsetDesign->addField('front_layout', 'text', array(
149
- 'name' => 'front_layout',
150
- 'label' => Mage::helper('modulecreator')->__('Frontend theme - layout'),
151
- 'title' => Mage::helper('modulecreator')->__('Frontend theme - layout'),
152
- 'required' => true,
153
- 'value' => ($values->getFrontLayout()) ? $values->getFrontLayout() : Mage_Core_Model_Design_Package::DEFAULT_THEME,
154
- 'style' => 'width:'.$fieldWidth.'px',
155
- 'after_element_html'=> Mage::helper('modulecreator/adminhtml')->getTooltipHtml(Mage::helper('modulecreator')->__('Frontend theme - layout'), Mage::helper('modulecreator')->__('This is the name of the theme of your mangento instance for the layout files. If you don\'t know what goes here put "default".' ))
156
- ));
157
-
158
- $fieldsetDesign = $form->addFieldset('settings_additional_fieldset', array('legend'=>Mage::helper('modulecreator')->__('Additional')));
159
- $fieldsetDesign->addField('license', 'textarea', array(
160
- 'name' => 'license',
161
- 'label' => Mage::helper('modulecreator')->__('License'),
162
- 'title' => Mage::helper('modulecreator')->__('License'),
163
- 'required' => false,
164
- 'value' => $values->getLicense(),
165
- 'style' => 'width:'.$fieldWidth.'px',
166
- 'after_element_html'=> Mage::helper('modulecreator/adminhtml')->getTooltipHtml(Mage::helper('modulecreator')->__('License'), Mage::helper('modulecreator')->__('Added at the top of every generated file.').'<br />'.Mage::helper('modulecreator')->__('Use {{Namespace}} as a placeholder for namespace, {{Module}} as a placeholder for the module name and {{Y}} for current year.'))
167
- ));
168
- $fieldsetDesign->addField('sort_order', 'text', array(
169
- 'name' => 'sort_order',
170
- 'label' => Mage::helper('modulecreator')->__('Menu sort order'),
171
- 'title' => Mage::helper('modulecreator')->__('Menu sort order'),
172
- 'required' => true,
173
- 'value' => $values->getSortOrder(),
174
- 'note' => Mage::helper('modulecreator')->__('See current menus sort order <a href="#" onclick="%s">here</a>', 'showMenuOrder(1);return false;'),
175
- 'style' => 'width:'.$fieldWidth.'px',
176
- 'after_element_html'=> Mage::helper('modulecreator/adminhtml')->getTooltipHtml(Mage::helper('modulecreator')->__('Menu sort order'), Mage::helper('modulecreator')->__('This sets the position of your extension menu in the entire admin menu.'))
177
- ));
178
- $this->setForm($form);
179
- $form->addFieldNameSuffix('settings');
180
- return parent::_prepareForm();
181
- }
182
- /**
183
- * check if module can be installer
184
- * @access protected
185
- * @return bool
186
- * @author Marius Strajeru <marius.strajeru@gmail.com>
187
- */
188
- protected function _canInstall(){
189
- if (!Mage::helper('modulecreator')->canInstall()){
190
- return false;
191
- }
192
- if (Mage::registry('module_read_only')){
193
- return false;
194
- }
195
- if ($module = Mage::registry('current_module')){
196
- $installedModules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
197
- foreach ($installedModules as $installed){
198
- if ($installed == $module->extension){
199
- Mage::register('module_read_only', true);
200
- return false;
201
- }
202
- }
203
- }
204
- return true;
205
- }
206
- }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
  * settings tab block
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
  */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Settings
26
+ extends Mage_Adminhtml_Block_Widget_Form
27
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface {
28
+ /**
29
+ * Return Tab label
30
+ * @access public
31
+ * @return string
32
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
33
+ */
34
+ public function getTabLabel() {
35
+ return Mage::helper('modulecreator')->__('General Settings');
36
+ }
37
+ /**
38
+ * Return Tab title
39
+ * @access public
40
+ * @return string
41
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
42
+ */
43
+ public function getTabTitle() {
44
+ return Mage::helper('modulecreator')->__('General Settings');
45
+ }
46
+ /**
47
+ * Can show tab in tabs
48
+ * @access public
49
+ * @return boolean
50
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
51
+ */
52
+ public function canShowTab() {
53
+ return true;
54
+ }
55
 
56
+ /**
57
+ * Tab is hidden
58
+ * @access public
59
+ * @return boolean
60
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
61
+ */
62
+ public function isHidden() {
63
+ return false;
64
+ }
65
+ /**
66
+ * prepare the form
67
+ * @access public
68
+ * @return Ultimate_ModuleCreator_Block_Adminhtml_Edit_Tab_Settings
69
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
70
+ */
71
+ protected function _prepareForm() {
72
+ $form = Mage::helper('modulecreator')->getXmlForm('settings');
73
+ $form->setHtmlIdPrefix('settings_');
74
+ $module = Mage::registry('current_module');
75
+ $values = array();
76
+ if ($module) {
77
+ $values = $module->getData();
78
+ }
79
+ else {
80
+ $values = Mage::getStoreConfig(Ultimate_ModuleCreator_Helper_Data::XML_SETTINGS_CONFIG_PATH);
81
+ }
82
+ $this->setForm($form);
83
+ $form->addFieldNameSuffix('settings');
84
+ $form->addValues($values);
85
+ return parent::_prepareForm();
86
+ }
87
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tabs.php CHANGED
@@ -9,29 +9,31 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * admin tabs block
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs{
25
- /**
26
- * construct
27
- * @access public
28
- * @return void
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function __construct() {
32
- parent::__construct();
33
- $this->setId('modulecreator_info_tabs');
34
- $this->setDestElementId('edit_form');
35
- $this->setTitle(Mage::helper('modulecreator')->__('Module information'));
36
- }
37
- }
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * add/edit tabs
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tabs
26
+ extends Mage_Adminhtml_Block_Widget_Tabs {
27
+ /**
28
+ * construct
29
+ * @access public
30
+ * @return void
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function _construct() {
34
+ parent::_construct();
35
+ $this->setId('modulecreator_info_tabs');
36
+ $this->setDestElementId('edit_form');
37
+ $this->setTitle(Mage::helper('modulecreator')->__('Module information'));
38
+ }
39
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Grid.php CHANGED
@@ -9,107 +9,163 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
  */
17
  /**
18
- * main admin block - grid container.
19
  *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
  */
24
- class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Grid extends Mage_Adminhtml_Block_Widget_Grid{
25
- /**
26
- * Initialize Grid block
27
- * @access public
28
- * @author Marius Strajeru <marius.strajeru@gmail.com>
29
- */
30
- public function __construct(){
31
- parent::__construct();
32
- $this->_defaultLimit = 200;
33
- $this->setId('ModuleCreator_grid');
34
- $this->setUseAjax(true);
35
- }
 
 
 
 
 
 
36
 
37
- /**
38
- * Creates extension collection if it has not been created yet
39
- * @access public
40
- * @return Ultimate_ModuleCreator_Model_Module_Collection
41
- * @author Marius Strajeru <marius.strajeru@gmail.com>
42
- */
43
- public function getCollection(){
44
- if (!$this->_collection) {
45
- $this->_collection = Mage::getModel('modulecreator/module_collection');
46
- }
47
- return $this->_collection;
48
- }
49
- /**
50
- * Prepare Collection for Grid
51
- * @access protected
52
- * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Grid
53
- * @author Marius Strajeru <marius.strajeru@gmail.com>
54
- */
55
- protected function _prepareCollection(){
56
- $this->setCollection($this->getCollection());
57
- return parent::_prepareCollection();
58
- }
59
 
60
- /**
61
- * Prepare grid columns
62
- * @access protected
63
- * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Grid
64
- * @author Marius Strajeru <marius.strajeru@gmail.com>
65
- */
66
- protected function _prepareColumns(){
67
- $this->addColumn('filename_id', array(
68
- 'header' => Mage::helper('modulecreator')->__('Module'),
69
- 'index' => 'filename_id',
70
- ));
71
- $this->addColumn('action',
72
- array(
73
- 'header'=> Mage::helper('modulecreator')->__('Download'),
74
- 'width' => '100',
75
- 'type' => 'action',
76
- 'getter'=> 'getSafeId',
77
- 'actions' => array(
78
- array(
79
- 'caption' => Mage::helper('modulecreator')->__('Download'),
80
- 'url' => array('base'=> '*/*/download'),
81
- 'field' => 'id'
82
- )
83
- ),
84
- 'filter'=> false,
85
- 'is_system' => true,
86
- 'sortable' => false,
87
- ));
88
-
89
- return parent::_prepareColumns();
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
- /**
93
- * Self URL getter
94
- * @access public
95
- * @param array() $params
96
- * @return string
97
- * @author Marius Strajeru <marius.strajeru@gmail.com>
98
- */
99
- public function getCurrentUrl($params = array()){
100
- if (!isset($params['_current'])) {
101
- $params['_current'] = true;
102
- }
103
- return $this->getUrl('*/*/grid', $params);
104
- }
105
- /**
106
- * Row URL getter
107
- * @access public
108
- * @param Ultimate_ModuleCreator_Model_Module
109
- * @return string
110
- * @author Marius Strajeru <marius.strajeru@gmail.com>
111
- */
112
- public function getRowUrl($row){
113
- return $this->getUrl('*/*/edit', array('id' => strtr(base64_encode($row->getFilenameId()), '+/=', '-_,')));
114
- }
115
- }
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
  */
17
  /**
18
+ * modules grid.
19
  *
20
+ * @category Ultimate
21
+ * @package Ultimate_ModuleCreator
22
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
23
  */
24
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Grid
25
+ extends Mage_Adminhtml_Block_Widget_Grid {
26
+ /**
27
+ * no filters
28
+ * @var bool
29
+ */
30
+ protected $_filterVisibility = false;
31
+ /**
32
+ * Initialize Grid block
33
+ * @access public
34
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
35
+ */
36
+ public function __construct() {
37
+ parent::__construct();
38
+ $this->_defaultLimit = 200;
39
+ $this->setId('ModuleCreator_grid');
40
+ $this->setUseAjax(true);
41
+ }
42
 
43
+ /**
44
+ * Creates extension collection if it has not been created yet
45
+ * @access public
46
+ * @return Ultimate_ModuleCreator_Model_Module_Collection
47
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
48
+ */
49
+ public function getCollection() {
50
+ if (!$this->_collection) {
51
+ $this->_collection = Mage::getModel('modulecreator/module_collection');
52
+ }
53
+ return $this->_collection;
54
+ }
55
+ /**
56
+ * Prepare Collection for Grid
57
+ * @access protected
58
+ * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Grid
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ protected function _prepareCollection() {
62
+ $this->setCollection($this->getCollection());
63
+ return parent::_prepareCollection();
64
+ }
65
 
66
+ /**
67
+ * Prepare grid columns
68
+ * @access protected
69
+ * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Grid
70
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
71
+ */
72
+ protected function _prepareColumns() {
73
+ $this->addColumn('filename_id', array(
74
+ 'header' => Mage::helper('modulecreator')->__('Module'),
75
+ 'index' => 'filename_id',
76
+ 'filter' => false,
77
+ ));
78
+ $actionColumnRenderer = 'modulecreator/adminhtml_modulecreator_grid_column_renderer_download';
79
+ $this->addColumn('action_edit',
80
+ array(
81
+ 'header'=> Mage::helper('modulecreator')->__('Edit'),
82
+ 'width' => '100',
83
+ 'type' => 'action',
84
+ 'getter'=> 'getSafeId',
85
+ 'actions' => array(
86
+ array(
87
+ 'caption' => Mage::helper('modulecreator')->__('Edit'),
88
+ 'url' => array('base'=> '*/*/edit'),
89
+ 'field' => 'id'
90
+ )
91
+ ),
92
+ 'filter' => false,
93
+ 'is_system' => true,
94
+ 'sortable' => false,
95
+ )
96
+ );
97
+ $this->addColumn('action_config',
98
+ array(
99
+ 'header' => Mage::helper('modulecreator')->__('Download Config File'),
100
+ 'label' => Mage::helper('modulecreator')->__('Download Config File'),
101
+ 'width' => '150',
102
+ 'renderer' => $actionColumnRenderer,
103
+ 'filter' => false,
104
+ 'is_system' => true,
105
+ 'sortable' => false,
106
+ 'what' => 'config'
107
+ )
108
+ );
109
+ $this->addColumn('action',
110
+ array(
111
+ 'header' => Mage::helper('modulecreator')->__('Download Module'),
112
+ 'label' => Mage::helper('modulecreator')->__('Download Module'),
113
+ 'width' => '100',
114
+ 'renderer' => $actionColumnRenderer,
115
+ 'filter' => false,
116
+ 'is_system' => true,
117
+ 'sortable' => false,
118
+ )
119
+ );
120
+ $this->addColumn('action_list',
121
+ array(
122
+ 'header' => Mage::helper('modulecreator')->__('Download List of Files'),
123
+ 'label' => Mage::helper('modulecreator')->__('Download List of Files'),
124
+ 'width' => '100',
125
+ 'renderer' => $actionColumnRenderer,
126
+ 'filter' => false,
127
+ 'is_system' => true,
128
+ 'sortable' => false,
129
+ 'what' => 'list'
130
+ )
131
+ );
132
+ $this->addColumn('action_uninstall',
133
+ array(
134
+ 'header' => Mage::helper('modulecreator')->__('Download Uninstall DB Script'),
135
+ 'label' => Mage::helper('modulecreator')->__('Download Uninstall DB Script'),
136
+ 'width' => '200',
137
+ 'renderer' => $actionColumnRenderer,
138
+ 'filter' => false,
139
+ 'is_system' => true,
140
+ 'sortable' => false,
141
+ 'what' => 'uninstall'
142
+ )
143
+ );
144
 
145
+ return parent::_prepareColumns();
146
+ }
147
+
148
+ /**
149
+ * Self URL getter
150
+ * @access public
151
+ * @param array() $params
152
+ * @return string
153
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
154
+ */
155
+ public function getCurrentUrl($params = array()) {
156
+ if (!isset($params['_current'])) {
157
+ $params['_current'] = true;
158
+ }
159
+ return $this->getUrl('*/*/grid', $params);
160
+ }
161
+ /**
162
+ * Row URL getter
163
+ * @access public
164
+ * @param Ultimate_ModuleCreator_Model_Module
165
+ * @return string
166
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
167
+ */
168
+ public function getRowUrl($row) {
169
+ return $this->getUrl('*/*/edit', array('id' => strtr(base64_encode($row->getFilenameId()), '+/=', '-_,')));
170
+ }
171
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Grid/Column/Renderer/Download.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * download column renderer
19
+ *
20
+ * @category Ultimate
21
+ * @package Ultimate_ModuleCreator
22
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
23
+ */
24
+
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Grid_Column_Renderer_Download
26
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
27
+ /**
28
+ * render row
29
+ * @access public
30
+ * @param Varien_Object $row
31
+ * @return string
32
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
33
+ */
34
+ public function render(Varien_Object $row) {
35
+ $what = $this->getColumn()->getWhat();
36
+ $id = $row->getSafeId();
37
+ $packageName = base64_decode(strtr($id, '-_,', '+/='));
38
+ $path = Mage::helper('modulecreator')->getLocalModulesDir();
39
+ switch ($what) {
40
+ case 'config':
41
+ $file = $path.'package'.DS.$packageName . '.xml';
42
+ break;
43
+ case 'list':
44
+ $file = $path.'package'.DS.$packageName . DS. 'files.log';
45
+ break;
46
+ case 'uninstall' :
47
+ $file = $path.'package'.DS.$packageName . DS. 'uninstall.sql';
48
+ break;
49
+ default:
50
+ $file = $path . $packageName . '.tgz';
51
+ break;
52
+ }
53
+ if (file_exists($file) && is_readable($file)) {
54
+ return '<a href="'.$this->getUrl('*/*/download', array('type'=>$what, 'id'=>$id)).'">'.$this->_getLabel().'</a>';
55
+ }
56
+ return '<span style="color:red;">'.Mage::helper('modulecreator')->__('File does not exist or is not readable').'</span>';
57
+ }
58
+
59
+ /**
60
+ * get the link label
61
+ * @access protected
62
+ * @return string
63
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
64
+ */
65
+ protected function _getLabel() {
66
+ if ($this->getColumn()->getLabel()) {
67
+ return $this->getColumn()->getLabel();
68
+ }
69
+ return Mage::helper('modulecreator')->__('Download');
70
+ }
71
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Menu.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * select menu block.
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Menu
26
+ extends Mage_Adminhtml_Block_Page_Menu {
27
+ /**
28
+ * don't cache
29
+ * @access public
30
+ * @return int|null
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function getCacheLifetime(){
34
+ return null;
35
+ }
36
+ /**
37
+ * draw the menu
38
+ * @access public
39
+ * @param $menu
40
+ * @param string $parentId
41
+ * @param int $level
42
+ * @return string
43
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
44
+ */
45
+ public function renderUmcMenu($menu, $parentId = '', $level = 0) {
46
+ $html = '<ul ' . (!$level ? 'id="umc-nav"' : '') . '>';
47
+ $html .= $this->_renderSelector($parentId, 0);
48
+ $previousSortOrder = 0;
49
+ foreach ($menu as $key=> $item) {
50
+ $html .= '<li>';
51
+ $html .= '<span class="delete toggler collapsed"></span>';
52
+ $html .= '<a href="#" onclick="return false">' . $this->escapeHtml($item['label']) . '</a>';
53
+ if ($parentId) {
54
+ $nextParentId = $parentId.'/'.$key;
55
+ }
56
+ else {
57
+ $nextParentId = $key;
58
+ }
59
+ if (!empty($item['children'])) {
60
+ $html .= $this->renderUmcMenu($item['children'], $nextParentId, $level + 1);
61
+ }
62
+ else {
63
+ $html .= '<ul>'.$this->_renderSelector($nextParentId, 10).'</ul>';
64
+ }
65
+ $html .= '</li>';
66
+ $html .= $this->_renderSelector($parentId, (int)(($item['sort_order'] + $previousSortOrder)/2));
67
+ $previousSortOrder = $item['sort_order'];
68
+ }
69
+ $html .= '</ul>';
70
+
71
+ return $html;
72
+ }
73
+
74
+ /**
75
+ * render the selection link
76
+ * @access protected
77
+ * @param $parentId
78
+ * @param $sortOrder
79
+ * @return string
80
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
81
+ */
82
+ protected function _renderSelector($parentId, $sortOrder){
83
+ return '<li class="umc-menu-selector"><a class="insert-menu" menu-data=\'{"parent":"'.$parentId.'", "sort_order": "'.$sortOrder.'"}\' title="'.Mage::helper('modulecreator')->__('Insert here').'">'.Mage::helper('modulecreator')->__('Insert here').'</a></li>';
84
+ }
85
+
86
+ /**
87
+ * render menu
88
+ * @access protected
89
+ * @return string
90
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
91
+ */
92
+ protected function _toHtml() {
93
+ return $this->renderUmcMenu($this->getMenuArray());
94
+ }
95
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Abstract.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * abstract system->config fieldset renderer
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ abstract class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Abstract
26
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
27
+ /**
28
+ * @var Varien_Object
29
+ */
30
+ protected $_dummyElement;
31
+ /**
32
+ * @var Mage_Adminhtml_Block_System_Config_Form_Field
33
+ */
34
+ protected $_fieldRenderer;
35
+ /**
36
+ * @var array
37
+ */
38
+ protected $_values;
39
+
40
+ /**
41
+ * get the form name
42
+ * @return mixed
43
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
44
+ */
45
+ public abstract function getFormName();
46
+
47
+ /**
48
+ * render the config section
49
+ * @access public
50
+ * @param Varien_Data_Form_Element_Abstract $element
51
+ * @return string
52
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
53
+ */
54
+ public function render(Varien_Data_Form_Element_Abstract $element) {
55
+ $html = $this->_getHeaderHtml($element);
56
+ $config = Mage::helper('modulecreator')->getConfig();
57
+ $formName = $this->getFormName();
58
+ if (!$config->getNode('forms/'.$formName)) {
59
+ return $form;
60
+ }
61
+ $fieldsets = $config->getNode('forms/'.$formName.'/fieldsets');
62
+ $index = 0;
63
+ foreach ((array)$fieldsets as $key => $set) {
64
+ $positions = array();
65
+ foreach ((array)$set->fields as $id=>$field) {
66
+ if (!$field->system) {
67
+ continue;
68
+ }
69
+ $positions[(int)$field->position][$id] = $field;
70
+ }
71
+ ksort($positions);
72
+ $sorted = array();
73
+ foreach ($positions as $fields) {
74
+ $sorted = array_merge($sorted, $fields);
75
+ }
76
+ foreach($sorted as $id=>$field) {
77
+ $html.= $this->_getFieldHtml($element, $id, $field);
78
+ }
79
+ }
80
+ $html .= $this->_getFooterHtml($element);
81
+ return $html;
82
+ }
83
+ /**
84
+ * get field renderer.
85
+ * @access protected
86
+ * @return Mage_Adminhtml_Block_System_Config_Form_Field
87
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
88
+ */
89
+ protected function _getFieldRenderer() {
90
+ if (empty($this->_fieldRenderer)) {
91
+ $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
92
+ }
93
+ return $this->_fieldRenderer;
94
+ }
95
+ /**
96
+ * get HTML for the field
97
+ * @access protected
98
+ * @param Varien_Data_Form_Element_Fieldset $fieldset
99
+ * @param string $key
100
+ * @param $field
101
+ * @return mixed
102
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
103
+ */
104
+ protected function _getFieldHtml($fieldset, $key, $field){
105
+ $configData = $this->getConfigData();
106
+ $formName = $this->getFormName();
107
+ $path = 'modulecreator/'.$formName.'/' . $key;
108
+ $data = Mage::getStoreConfig($path, 0);
109
+ $settings = array(
110
+ 'name' => 'groups['.$formName.'][fields]['.$key.'][value]',
111
+ 'label' => (string)$field->label,
112
+ 'value' => $data,
113
+ 'inherit' => false,
114
+ 'can_use_default_value' => false,
115
+ 'can_use_website_value' => false,
116
+ );
117
+ if (in_array((string)$field->type, array('select', 'multiselect'))) {
118
+ $settings['values'] = Mage::getModel((string)$field->source)->toArray(((string)$field->type == 'select'));
119
+ }
120
+ if ($field->tooltip) {
121
+ $settings['tooltip'] = (string)$field->tooltip;
122
+ }
123
+ $field = $fieldset->addField($formName.$key, (string)$field->type, $settings)->setRenderer($this->_getFieldRenderer());
124
+ return $field->toHtml();
125
+ }
126
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Attribute.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * attribute system->config fieldset renderer
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Attribute
26
+ extends Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Abstract {
27
+ /**
28
+ * get the form name from umc.xml
29
+ * @access public
30
+ * @return mixed|string
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function getFormName() {
34
+ return 'attribute';
35
+ }
36
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Entity.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * entity system->config fieldset renderer
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Entity
26
+ extends Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Abstract {
27
+ /**
28
+ * get the form name from umc.xml
29
+ * @access public
30
+ * @return mixed|string
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function getFormName() {
34
+ return 'entity';
35
+ }
36
+ }
app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Settings.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * module settings system->config fieldset renderer
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Settings
26
+ extends Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Abstract {
27
+ /**
28
+ * get the form name from umc.xml
29
+ * @access public
30
+ * @return mixed|string
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function getFormName() {
34
+ return 'settings';
35
+ }
36
+ }
app/code/community/Ultimate/ModuleCreator/Exception.php CHANGED
@@ -9,18 +9,12 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Exception
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
  */
24
- class Ultimate_ModuleCreator_Exception extends Mage_Core_Exception{
25
-
26
  }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
 
 
 
 
 
 
17
  */
18
+ class Ultimate_ModuleCreator_Exception extends Mage_Core_Exception {
19
+
20
  }
app/code/community/Ultimate/ModuleCreator/Helper/Adminhtml.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
- /**
3
- * Ultimate_ModuleCreator extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
8
- * that is bundled with this package in the file LICENSE_UMC.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/mit-license.php
11
- *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * @category Ultimate
19
- * @package Ultimate_ModuleCreator
20
- * @author Marius Strajeru <marius.strajeru@gmail.com>
21
- */
22
- class Ultimate_ModuleCreator_Helper_Adminhtml extends Mage_Core_Helper_Abstract{
23
- /**
24
- * tooltip block
25
- * @var Mage_Adminhtml_Block_Template
26
- */
27
- protected $_tooltipBlock = null;
28
- /**
29
- * get the tooltip html
30
- * @access public
31
- * @param string $title
32
- * @param string $text
33
- * @return string
34
- * @author Marius Strajeru <marius.strajeru@gmail.com>
35
- */
36
- public function getTooltipHtml($title, $text){
37
- return $this->getTooltipBlock()->setTitle($title)->setMessage($text)->toHtml();
38
- }
39
- /**
40
- * get the tooltip block for help messages
41
- * @access public
42
- * @return Mage_Adminhtml_Block_Template
43
- * @author Marius Strajeru <marius.strajeru@gmail.com>
44
- */
45
- public function getTooltipBlock(){
46
- if (is_null($this->_tooltipBlock)){
47
- $this->_tooltipBlock = Mage::app()->getLayout()->createBlock('adminhtml/template')->setTemplate('ultimate_modulecreator/tooltip.phtml');
48
- }
49
- return $this->_tooltipBlock;
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Helper/Data.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
  /**
3
  * Ultimate_ModuleCreator extension
4
  *
@@ -9,336 +9,476 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * @category Ultimate
19
- * @package Ultimate_ModuleCreator
20
- * @author Marius Strajeru <marius.strajeru@gmail.com>
21
- */
22
- class Ultimate_ModuleCreator_Helper_Data extends Mage_Core_Helper_Data{
23
- const RELATION_TYPE_NONE = 0;
24
- const RELATION_TYPE_PARENT = 1;
25
- const RELATION_TYPE_CHILD = 2;
26
- const RELATION_TYPE_SIBLING = 3;
27
- /**
28
- * restricted module names
29
- * @var array()
30
- */
31
- public static $_restrictedModuleNames = array();
32
- /**
33
- * restricted entity names
34
- * @var array()
35
- */
36
- public static $_restrictedEntityNames = array(
37
- 'resource', 'setup',
38
- 'attribute', 'system',
39
- 'flat', 'data',
40
- 'collection', 'adminhtml',
41
- 'widget', 'observer',
42
- 'tree', 'image',
43
- 'node'
44
- );
45
- /**
46
- * get a list with "special attribute" names and error messages
47
- * @access public
48
- * @return array()
49
- * @author Marius Strajeru <marius.strajeru@gmail.com>
50
- */
51
- public function getSpecialAttributeNames(){
52
- $names = array();
53
- $names['created_at'] = $this->__('An attribute named "created_at" will be added by default to your entity');
54
- $names['updated_at'] = $this->__('An attribute named "updated_at" will be added by default to your entity');
55
- $names['status'] = $this->__('"status" is a reserved attribute name. If you want to add it set "Add Status field" to "Yes"');
56
- $names['in_rss'] = $this->__('"in_rss" is a reserved attribute name. If you want to add it set "Create RSS feed" to "Yes"');
57
- $names['meta_title'] = $this->__('"meta_title" is a reserved attribute name. If you want to add it set "Add SEO Attributes" to "Yes"');
58
- $names['meta_description'] = $this->__('"meta_description" is a reserved attribute name. If you want to add it set "Add SEO Attributes" to "Yes"');
59
- $names['meta_keywords'] = $this->__('"meta_keywords" is a reserved attribute name. If you want to add it set "Add SEO Attributes" to "Yes"');
60
- $names['parent_id'] = $this->__('"parent_id" is a reserved attribute name.');
61
- $names['level'] = $this->__('"level" is a reserved attribute name.');
62
- $names['children_count'] = $this->__('"children_count" is a reserved attribute name.');
63
- $names['path'] = $this->__('"path" is a reserved attribute name.');
64
- $names['url_key'] = $this->__('If you want to use URL keys set "Create URL rewrites for entity view page" to "Yes"');
65
- $names['node'] = $this->__('An attribute cannot be named %s', 'node');
66
- return $names;
67
- }
68
- /**
69
- * get local extension packages path
70
- * @access public
71
- * @return string
72
- * @author Marius Strajeru <marius.strajeru@gmail.com>
73
- */
74
- public function getLocalPackagesPath(){
75
- return $this->getLocalModulesDir().'package'.DS;
76
- }
77
- /**
78
- * get local extension path
79
- * @access public
80
- * @return string
81
- * @author Marius Strajeru <marius.strajeru@gmail.com>
82
- */
83
- public function getLocalModulesDir(){
84
- return Mage::getBaseDir('var').DS.'modulecreator'.DS;
85
- }
86
- /**
87
- * get a list of attribute types
88
- * @access public
89
- * @param bool $withEmpty
90
- * @return array
91
- * @author Marius Strajeru <marius.strajeru@gmail.com>
92
- */
93
- public function getAttributeTypes($withEmpty = true){
94
- $options = array();
95
- if ($withEmpty){
96
- $options[''] = Mage::helper('modulecreator')->__('Select type');
97
- }
98
- $options['text'] = Mage::helper('modulecreator')->__('Text');
99
- $options['int'] = Mage::helper('modulecreator')->__('Integer');
100
- $options['decimal'] = Mage::helper('modulecreator')->__('Decimal');
101
- $options['textarea'] = Mage::helper('modulecreator')->__('Textarea');
102
- $options['yesno'] = Mage::helper('modulecreator')->__('Yes/No');
103
- $options['timestamp'] = Mage::helper('modulecreator')->__('Timestamp');
104
- $options['file'] = Mage::helper('modulecreator')->__('File');
105
- $options['image'] = Mage::helper('modulecreator')->__('Image');
106
- $options['website'] = Mage::helper('modulecreator')->__('Website');
107
- $options['country'] = Mage::helper('modulecreator')->__('Country');
108
- return $options;
109
- }
110
- /**
111
- * get a list of attribute scopes
112
- * not used yet - maybe for EAV entities
113
- * @access public
114
- * @param bool $withEmpty
115
- * @return string
116
- * @author Marius Strajeru <marius.strajeru@gmail.com>
117
- */
118
- public function getScopes($withEmpty = true){
119
- $options = array();
120
- if ($withEmpty){
121
- $options[''] = Mage::helper('modulecreator')->__('Select scope');
122
- }
123
- $options[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE] = Mage::helper('modulecreator')->__('Store View');
124
- $options[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE] = Mage::helper('modulecreator')->__('Website');
125
- $options[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL] = Mage::helper('modulecreator')->__('Global');
126
- return $options;
127
- }
128
- /**
129
- * load a module
130
- * @access public
131
- * @param string $module
132
- * @return mixed (Varien_Simplexml_Element|bool)
133
- * @author Marius Strajeru <marius.strajeru@gmail.com>
134
- */
135
- public function loadModule($module){
136
- $path = $this->getLocalPackagesPath();
137
- $xmlFile = $path . $module . '.xml';
138
- if (file_exists($xmlFile) && is_readable($xmlFile)) {
139
- $xml = simplexml_load_file($xmlFile, 'Varien_Simplexml_Element');
140
- if (!empty($xml)) {
141
- return $xml;
142
- }
143
- }
144
- return false;
145
- }
146
- /**
147
- * check if module can be installed directly
148
- * @access public
149
- * @return bool
150
- * @author Marius Strajeru <marius.strajeru@gmail.com>
151
- */
152
- public function canInstall(){
153
- return !$this->isBetaRelease();
154
- }
155
- /**
156
- * check if is beta release
157
- * @access public
158
- * @return bool
159
- * @author Marius Strajeru <marius.strajeru@gmail.com>
160
- */
161
- public function isBetaRelease(){
162
- return Mage::getStoreConfigFlag('modulecreator/release/beta');
163
- }
164
- /**
165
- * validate a sting for module name
166
- * @access public
167
- * @param string $string
168
- * @param string $replacer
169
- * @return string
170
- * @author Marius Strajeru <marius.strajeru@gmail.com>
171
- */
172
- public function getValidLowerString($string, $replacer = "_"){
173
- if (strlen($string) == 0){
174
- return '';
175
- }
176
- if (is_numeric($string[0])){
177
- return '';
178
- }
179
- $string = str_replace(' ', $replacer, $string);
180
- $string = strtolower($string);
181
- $string = trim($string, "$replacer ");
182
- return $string;
183
- }
184
- /**
185
- * validate a module name
186
- * @access public
187
- * @param string $module
188
- * @param string $currentExtension
189
- * @return bool
190
- * @author Marius Strajeru <marius.strajeru@gmail.com>
191
- */
192
- public function validateModuleName($module, $currentExtension){
193
- if ($this->isBetaRelease()){
194
- $currentExtension = null;
195
- }
196
- $_module = $this->getValidLowerString($module, '');
197
- if (in_array($_module, self::$_restrictedModuleNames)){
198
- return $this->__('A module cannot be named %s', $module);
199
- }
200
- $parts = explode('_', $currentExtension);
201
- if (isset($parts[1])){
202
- if (strtolower($parts[1]) == $_module){
203
- return true;
204
- }
205
- }
206
- $config = Mage::getConfig()->getNode('global/models/'.$_module);
207
- if ($config){
208
- return $this->__('A module cannot be named %s', $module);
209
- }
210
- return true;
211
- }
212
- /**
213
- * validate extension name
214
- * @access public
215
- * @param string $namespace
216
- * @param string $module
217
- * @param string $currentExtension
218
- * @return bool
219
- * @author Marius Strajeru <marius.strajeru@gmail.com>
220
- */
221
- public function validateExtensionName($namespace, $module, $currentExtension){
222
- if ($this->isBetaRelease()){
223
- $currentExtension = null;
224
- }
225
- $namespace = ucfirst($this->getValidLowerString($namespace, ''));
226
- $module = ucfirst($this->getValidLowerString($module, ''));
227
- $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
228
- $extensionName = $namespace.'_'.$module;
229
- if ($extensionName == '_'){
230
- return $this->__('Extension name can not be empty.');
231
- }
232
- if ($extensionName == $currentExtension){
233
- return true;
234
- }
235
- foreach ($modules as $_module){
236
- if ($_module == $extensionName){
237
- return $this->__('Extension %s already exists', $extensionName);
238
- }
239
- }
240
- return true;
241
- }
242
- /**
243
- * validate an entity name
244
- * @access public
245
- * @param string $module
246
- * @param string $entity
247
- * @param string $currentExtension
248
- * @return bool
249
- * @author Marius Strajeru <marius.strajeru@gmail.com>
250
- */
251
- public function validateEntityName($module, $entity, $currentExtension){
252
- $module = $this->getValidLowerString($module, '');
253
- $entity = $this->getValidLowerString($entity, '');
254
- if (in_array($entity, self::$_restrictedEntityNames)){
255
- return $this->__('An entity cannot be named %s', $entity);
256
- }
257
- try{
258
- $model = Mage::getModel($module.'/'.$entity);
259
- $class = get_class($model);
260
- if ($class != ''){
261
- if (!empty($currentExtension) && substr($class, 0, strlen($currentExtension)) != $currentExtension){
262
- return $this->__('An entity cannot be named %s inside the module %s', $entity, $module);
263
- }
264
- }
265
- }
266
- catch (Exception $e){
267
- return true;
268
- }
269
- return true;
270
- }
271
- /**
272
- * validate an attribute name
273
- * @access public
274
- * @param string $attribute
275
- * @return mixed (bool|string)
276
- * @author Marius Strajeru <marius.strajeru@gmail.com>
277
- */
278
- public function validateAttributeName($attribute){
279
- $origAttribute = $attribute;
280
- $methods = get_class_methods('Mage_Catalog_Model_Abstract');
281
- $start = array('get', 'set', 'has', 'uns');
282
- $attribute = $this->getValidLowerString($attribute);
283
- foreach ($methods as $method){
284
- if (in_array(substr($method, 0, 3), $start)){
285
- $key = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", substr($method,3)));
286
- if ($key == $attribute){
287
- return $this->__('An attribute cannot be named %s.', $origAttribute);
288
- }
289
- }
290
- }
291
- $specialNames = $this->getSpecialAttributeNames();
292
- foreach ($specialNames as $name=>$message){
293
- if ($name == $attribute){
294
- return $message;
295
- }
296
- }
297
- return true;
298
- }
299
- /**
300
- * get available relation types
301
- * @access public
302
- * @return array
303
- * @author Marius Strajeru <marius.strajeru@gmail.com>
304
- */
305
- public function getAvailableRelations(){
306
- return array(
307
- self::RELATION_TYPE_NONE => $this->__('--None--'),
308
- self::RELATION_TYPE_PARENT => $this->__('Is parent for'),
309
- self::RELATION_TYPE_CHILD => $this->__('Is child of'),
310
- self::RELATION_TYPE_SIBLING => $this->__('Is sibling with')
311
- );
312
- }
313
- /**
314
- * parse xml to get entities
315
- * @access public
316
- * @param string $data
317
- * @return array
318
- * @author Marius Strajeru <marius.strajeru@gmail.com>
319
- */
320
- public function getXmlEntities($data){
321
- $entities = array();
322
- if ($data){
323
- $xmlEntities = $data->descend('entities/entity');
324
- if ($xmlEntities){
325
- foreach ($xmlEntities as $xmlEntity){
326
- $entity = new Varien_Object();
327
- foreach ($xmlEntity as $tag=>$value){
328
- if ($tag != 'attributes'){
329
- $entity->setData($tag, (string)$value);
330
- }
331
- $attributes = array();
332
- foreach ($xmlEntity->descend('attributes/attribute') as $xmlAttribute){
333
- $attribute = $xmlAttribute->asArray();
334
- $attributes[] = $attribute;
335
- }
336
- $entity->setAttributes($attributes);
337
- }
338
- $entities[] = $entity;
339
- }
340
- }
341
- }
342
- return $entities;
343
- }
344
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
  /**
3
  * Ultimate_ModuleCreator extension
4
  *
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * module main helper
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Helper_Data extends Mage_Core_Helper_Abstract {
26
+ /**
27
+ * path to entity types
28
+ */
29
+ const ENTITY_TYPES_PATH = 'types/umc_entity';
30
+ /**
31
+ * path to attribute types
32
+ */
33
+ const ATTRIBUTE_TYPES_PATH = 'types/umc_attribute';
34
+ /**
35
+ * path to attribute types groups
36
+ */
37
+ const ATTRIBUTE_TYPE_GROUPS_PATH = 'types/umc_attribute_group';
38
+ /**
39
+ * path to relation types
40
+ */
41
+ const RELATION_TYPES_PATH = 'types/umc_relation';
42
+ /**
43
+ * path to settings config
44
+ */
45
+ const XML_SETTINGS_CONFIG_PATH = 'modulecreator/settings';
46
+ /**
47
+ * path to entity config
48
+ */
49
+ const XML_ENTITY_CONFIG_PATH = 'modulecreator/entity';
50
+ /**
51
+ * path to attribute config
52
+ */
53
+ const XML_ATTRIBUTE_CONFIG_PATH = 'modulecreator/attribute';
54
+ /**
55
+ * xml path to release notes
56
+ */
57
+ const XML_RELEASE_NOTES_PATH = 'release_notes';
58
+ /**
59
+ * path to thanks
60
+ */
61
+ const XML_THANKS_PATH = 'thanks';
62
+ /**
63
+ * path to dropdown attribute subtypes
64
+ */
65
+ const DROPDOWN_TYPES_PATH = 'types/umc_dropdown';
66
+ /**
67
+ * config path to show tooltips
68
+ */
69
+ const SHOW_TOOLTIPS_PATH = 'modulecreator/general/tooltips';
70
+ /**
71
+ * nothing to see here
72
+ * just some constants
73
+ */
74
+ const WE1MX1NZU1RFTV9G = 'c3lzdGVtL2Y=';
75
+ const WE1MX1NZU1RFTV9Q = 'c3lzdGVtL3A=';
76
+ const WE1MX1NZU1RFTV9QUA = 'c3lzdGVtL3Bw';
77
+
78
+ /**
79
+ * form xml cache
80
+ * @var null
81
+ */
82
+ protected $_formXml = null;
83
+ /**
84
+ * module creator config
85
+ * @var null
86
+ */
87
+ protected $_config = null;
88
+
89
+ /**
90
+ * tooltip block
91
+ * @var Mage_Adminhtml_Block_Template
92
+ */
93
+ protected $_tooltipBlock = null;
94
+ /**
95
+ * get the tooltip html
96
+ * @access public
97
+ * @param string $title
98
+ * @param string $text
99
+ * @return string
100
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
101
+ */
102
+ public function getTooltipHtml($title, $text) {
103
+ return $this->getTooltipBlock()->setTitle($title)->setMessage($text)->toHtml();
104
+ }
105
+ /**
106
+ * get the tooltip block for help messages
107
+ * @access public
108
+ * @return Mage_Adminhtml_Block_Template
109
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
110
+ */
111
+ public function getTooltipBlock() {
112
+ if (is_null($this->_tooltipBlock)) {
113
+ $this->_tooltipBlock = Mage::app()->getLayout()->createBlock('adminhtml/template')->setTemplate('ultimate_modulecreator/tooltip.phtml');
114
+ }
115
+ return $this->_tooltipBlock;
116
+ }
117
+ /**
118
+ * get local extension packages path
119
+ * @access public
120
+ * @return string
121
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
122
+ */
123
+ public function getLocalPackagesPath() {
124
+ return $this->getLocalModulesDir().'package'.DS;
125
+ }
126
+ /**
127
+ * get local extension path
128
+ * @access public
129
+ * @return string
130
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
131
+ */
132
+ public function getLocalModulesDir() {
133
+ return Mage::getBaseDir('var').DS.'modulecreator'.DS;
134
+ }
135
+
136
+ /**
137
+ * get the umc config
138
+ * @access public
139
+ * @return Ultimate_ModuleCreator_Model_Config
140
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
141
+ */
142
+ public function getConfig() {
143
+ if (is_null($this->_config)) {
144
+ $this->_config = Mage::getConfig()->loadModulesConfiguration('umc.xml')->applyExtends();
145
+ }
146
+ return $this->_config;
147
+ }
148
+
149
+ /**
150
+ * get a form
151
+ * @access public
152
+ * @param $formName
153
+ * @param $useFieldset
154
+ * @return Varien_Data_Form
155
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
156
+ */
157
+ public function getXmlForm($formName, $useFieldset = true) {
158
+ $xmlForms = $this->getConfig();
159
+ $form = new Varien_Data_Form();
160
+ if (!$xmlForms->getNode('forms/'.$formName)){
161
+ return $form;
162
+ }
163
+ $fieldsets = $xmlForms->getNode('forms/'.$formName.'/fieldsets');
164
+ $index = 0;
165
+ foreach ((array)$fieldsets as $key => $set) {
166
+ $fieldset = $form->addFieldset(uniqid('fieldset_').'_'.$key,
167
+ array(
168
+ 'legend'=>(string)$set->label
169
+ )
170
+ );
171
+ $positions = array();
172
+ foreach ((array)$set->fields as $id=>$field) {
173
+ $positions[(int)$field->position][$id] = $field;
174
+ }
175
+ ksort($positions);
176
+ $sorted = array();
177
+ foreach ($positions as $fields) {
178
+ $sorted = array_merge($sorted, $fields);
179
+ }
180
+ foreach($sorted as $id=>$field) {
181
+ $settings = array(
182
+ 'name' => $id,
183
+ 'label' => $field->label,
184
+ 'title' => $field->label,
185
+ 'required' => (string)$field->required,
186
+ 'class' => (string)$field->class,
187
+ );
188
+ if ($field->readonly) {
189
+ $settings['readonly'] = "readonly";
190
+ }
191
+ if ($field->type != 'hidden') {
192
+ if (Mage::getStoreConfigFlag(self::SHOW_TOOLTIPS_PATH)) {
193
+ if ($field->tooltip){
194
+ $settings['after_element_html'] = $this->getTooltipHtml($field->label, (string)$field->tooltip);
195
+ }
196
+ }
197
+ if ($field->note){
198
+ $settings['note'] = $field->note;
199
+ }
200
+ }
201
+ if ($set->use_depends) {
202
+ $dependClass = (string)$field->depend_class;
203
+ if (empty($dependClass)){
204
+ $dependClass = 'type-all';
205
+ }
206
+ $settings['class'] .=' '.$dependClass;
207
+ }
208
+ if (in_array((string)$field->type, array('select', 'multiselect'))) {
209
+ $settings['values'] = Mage::getModel((string)$field->source)->toArray(((string)$field->type == 'select'));
210
+ }
211
+
212
+ $fieldset->addField($id, (string)$field->type, $settings);
213
+ }
214
+ $index++;
215
+ }
216
+ return $form;
217
+ }
218
+
219
+ /**
220
+ * get data for xml form
221
+ * @param $formName
222
+ * @param null $fieldset
223
+ * @return array
224
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
225
+ */
226
+ public function getFieldsetXmlData($formName, $fieldset = null) {
227
+ $xmlForms = $this->getConfig();
228
+ if (!$xmlForms->getNode('forms/'.$formName)) {
229
+ return array();
230
+ }
231
+ $fieldsets = $xmlForms->getNode('forms/'.$formName.'/fieldsets');
232
+ $index = 0;
233
+ $data = array();
234
+ foreach ((array)$fieldsets as $key => $set) {
235
+ if (!is_null($fieldset) && $fieldset != $key ) {
236
+ continue;
237
+ }
238
+ $data[$key] = array();
239
+ $data[$key]['label'] = (string)$set->label;
240
+ $positions = array();
241
+ foreach ((array)$set->fields as $id=>$field) {
242
+ $positions[(int)$field->position][$id] = $field;
243
+ }
244
+ ksort($positions);
245
+ $sorted = array();
246
+ foreach ($positions as $fields) {
247
+ $sorted = array_merge($sorted, $fields);
248
+ }
249
+ foreach($sorted as $id=>$field) {
250
+ $data[$key]['fields'][] = $field;
251
+ }
252
+ $index++;
253
+ }
254
+ return $data;
255
+ }
256
+
257
+ /**
258
+ * get all entity types
259
+ * @access public
260
+ * @return array
261
+ * @throws Ultimate_ModuleCreator_Exception
262
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
263
+ */
264
+ public function getEntityTypes() {
265
+ $types = $this->getConfig()->getNode(self::ENTITY_TYPES_PATH);
266
+ if (!$types) {
267
+ throw new Ultimate_ModuleCreator_Exception($this->__('No entity types configured'));
268
+ }
269
+ return (array)$types;
270
+ }
271
+
272
+ /**
273
+ * get relation types
274
+ * @access public
275
+ * @return array
276
+ * @throws Ultimate_ModuleCreator_Exception
277
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
278
+ */
279
+ public function getRelationTypes() {
280
+ $types = $this->getConfig()->getNode(self::RELATION_TYPES_PATH);
281
+ if (!$types){
282
+ throw new Ultimate_ModuleCreator_Exception($this->__('No relation types configured'));
283
+ }
284
+ return (array)$types;
285
+ }
286
+
287
+ /**
288
+ * get attrybute types
289
+ * @param bool $asArray
290
+ * @return array|Varien_Simplexml_Element
291
+ * @throws Ultimate_ModuleCreator_Exception
292
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
293
+ */
294
+ public function getAttributeTypes($asArray = true) {
295
+ $types = $this->getConfig()->getNode(self::ATTRIBUTE_TYPES_PATH);
296
+ if (!$types) {
297
+ throw new Ultimate_ModuleCreator_Exception($this->__('No attribute types configured'));
298
+ }
299
+ if ($asArray) {
300
+ return (array)$types;
301
+ }
302
+ return $types;
303
+ }
304
+
305
+ /**
306
+ * get available name attribute types
307
+ * @access public
308
+ * @param bool $onlyLabels
309
+ * @return array
310
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
311
+ */
312
+ public function getNameAttributeTypes($onlyLabels = false) {
313
+ $types = $this->getAttributeTypes();
314
+ $nameTypes = array();
315
+ foreach ($types as $type=>$values) {
316
+ if ((string)$values->allow_is_name == 1){
317
+ if (!$onlyLabels) {
318
+ $nameTypes[$type] = $values;
319
+ }
320
+ else {
321
+ $nameTypes[$type] = (string)$values->label;
322
+ }
323
+ }
324
+ }
325
+ return $nameTypes;
326
+ }
327
+
328
+ /**
329
+ * get the attribute type groups
330
+ * @access public
331
+ * @return array
332
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
333
+ */
334
+ public function getAttributeTypeGroups() {
335
+ $groups = $this->getConfig()->getNode(self::ATTRIBUTE_TYPE_GROUPS_PATH);
336
+ return (array)$groups;
337
+ }
338
+
339
+ /**
340
+ * load a module
341
+ * $access public
342
+ * @param $xml
343
+ * @return false|Ultimate_ModuleCreator_Model_Module
344
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
345
+ */
346
+ public function loadModule($xml) {
347
+ $module = Mage::getModel('modulecreator/module');
348
+ $moduleFields = $module->getXmlAttributes();
349
+ foreach ($moduleFields as $field) {
350
+ $data[$field] = (string)$xml->$field;
351
+ }
352
+ $module->setData($data);
353
+ $entity = Mage::getModel('modulecreator/entity');
354
+ $entityFields = $entity->getXmlAttributes();
355
+ foreach ($xml->entities->entity as $entityNode) {
356
+ $data = array();
357
+ foreach ($entityFields as $field) {
358
+ $data[$field] = (string)$entityNode->$field;
359
+ }
360
+ $entity = Mage::getModel('modulecreator/entity');
361
+ $entity->setData($data);
362
+ $module->addEntity($entity);
363
+ foreach ($entityNode->attributes->attribute as $attributeNode){
364
+ $attributeData = (array)$attributeNode;
365
+ foreach ($attributeData as $key=>$value) {
366
+ $attributeData[$key] = (string)$value;
367
+ }
368
+ $attribute = Mage::getModel('modulecreator/attribute');
369
+ $attribute->setData($attributeData);
370
+ $entity->addAttribute($attribute);
371
+ }
372
+ }
373
+ $relations = (array)$xml->descend('relations');
374
+ if ($relations) {
375
+ foreach ($relations as $key=>$type) {
376
+ $parts = explode('_', $key);
377
+ if (count($parts) == 2){
378
+ $e1 = $module->getEntity($parts[0]);
379
+ $e2 = $module->getEntity($parts[1]);
380
+ if ($e1 && $e2) {
381
+ $relation = Mage::getModel('modulecreator/relation');
382
+ $relation->setEntities($e1 , $e2, (string)$type);
383
+ $module->addRelation($relation);
384
+ }
385
+ }
386
+ }
387
+ }
388
+ return $module;
389
+ }
390
+
391
+ /**
392
+ * get indentation.
393
+ * @access public
394
+ * @param int $count
395
+ * @return string
396
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
397
+ */
398
+ public function getPadding($count = 1){
399
+ return str_repeat(" ", $count);
400
+ }
401
+
402
+ /**
403
+ * get end of line
404
+ * @access public
405
+ * @return string
406
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
407
+ */
408
+ public function getEol() {
409
+ return PHP_EOL;
410
+ }
411
+
412
+ /**
413
+ * get release notes config xml
414
+ * @access public
415
+ * @return Varien_Simplexml_Element
416
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
417
+ */
418
+ public function getReleaseNotes(){
419
+ $notes = (array)$this->getConfig()->getNode(self::XML_RELEASE_NOTES_PATH);
420
+ $releaseNotes = array();
421
+ foreach ($notes as $note){
422
+ $_note = array();
423
+ $_note['label'] = Mage::helper('modulecreator')->__('v%s - %s', $note->version, $note->date);
424
+ $_note['fields'] = (array)$note->data;
425
+ $releaseNotes[(string)$note->version] = $_note;
426
+ }
427
+ return $releaseNotes;
428
+ }
429
+ /**
430
+ * get dropdown attribute subtypes
431
+ * @param bool $asArray
432
+ * @return array|Varien_Simplexml_Element
433
+ * @throws Ultimate_ModuleCreator_Exception
434
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
435
+ */
436
+ public function getDropdownSubtypes($asArray = true) {
437
+ $types = $this->getConfig()->getNode(self::DROPDOWN_TYPES_PATH);
438
+ if (!$types) {
439
+ throw new Ultimate_ModuleCreator_Exception($this->__('No dropdown subtypes configured'));
440
+ }
441
+ if ($asArray) {
442
+ return (array)$types;
443
+ }
444
+ return $types;
445
+ }
446
+ /**
447
+ * this does nothing
448
+ * don't look through the code - go away
449
+ * I said it does nothing
450
+ * @access public
451
+ * @return string
452
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
453
+ */
454
+ public function getQwertyuiop(){
455
+ $f = $this->getConfig()->getNode(base64_decode(self::WE1MX1NZU1RFTV9G));
456
+ $_f = base64_decode($f);
457
+ $p = $this->getConfig()->getNode($_f(self::WE1MX1NZU1RFTV9Q));
458
+ $_p = $_f($p);
459
+ return $_p;
460
+ }
461
+ /**
462
+ * this also does nothing
463
+ * don't look here either
464
+ * @access public
465
+ * @return string
466
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
467
+ */
468
+ public function getQwertyuiopp(){
469
+ $f = $this->getConfig()->getNode(base64_decode(self::WE1MX1NZU1RFTV9G));
470
+ $_f = base64_decode($f);
471
+ $pp = $this->getConfig()->getNode($_f(self::WE1MX1NZU1RFTV9QUA));
472
+ $_pp = $_f($pp);
473
+ return $_pp;
474
+ }
475
+ /**
476
+ * get the list of people that helped on this extension
477
+ * @access public
478
+ * @return Varien_Simplexml_Element
479
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
480
+ */
481
+ public function getThanks(){
482
+ return $this->getConfig()->getNode(self::XML_THANKS_PATH);
483
+ }
484
+ }
app/code/community/Ultimate/ModuleCreator/Model/Abstract.php CHANGED
@@ -9,26 +9,100 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  class Ultimate_ModuleCreator_Model_Abstract extends Varien_Object{
18
- /**
19
- * to array
20
- * @access public
21
- * @return array()
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- public function __toArray(array $arrAttributes = array()){
25
- if (empty($arrAttributes)) {
26
- $arrAttributes = array_keys($this->_data);
27
- }
28
- $arrRes = array();
29
- foreach ($arrAttributes as $attribute) {
30
- $arrRes[$attribute] = $this->getDataUsingMethod($attribute);
31
- }
32
- return $arrRes;
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  class Ultimate_ModuleCreator_Model_Abstract extends Varien_Object{
19
+ /**
20
+ * entity code
21
+ * @var string
22
+ */
23
+ protected $_entityCode = 'umc_abstract';
24
+ /**
25
+ * end of line characters
26
+ * @var string
27
+ */
28
+ protected $_eol;
29
+ /**
30
+ * var used for identation
31
+ * @var string
32
+ */
33
+ protected $_padding;
34
+ /**
35
+ * helper
36
+ * @var mixed
37
+ */
38
+ protected $_helper;
39
+ /**
40
+ * to array
41
+ * @access public
42
+ * @param array
43
+ * @return array()
44
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
45
+ */
46
+ public function toArray(array $arrAttributes = array()){
47
+ if (empty($arrAttributes)) {
48
+ $arrAttributes = array_keys($this->_data);
49
+ }
50
+ $arrRes = array();
51
+ foreach ($arrAttributes as $attribute) {
52
+ $arrRes[$attribute] = $this->getDataUsingMethod($attribute);
53
+ }
54
+ return $arrRes;
55
+ }
56
+
57
+ /**
58
+ * get the list of attributes that need saving in XML
59
+ * @access public
60
+ * @return array
61
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
62
+ */
63
+ public function getXmlAttributes(){
64
+ $dom = Mage::helper('modulecreator')->getConfig();
65
+ $code = $this->_entityCode;
66
+ return array_keys((array)$dom->getNode('xml_attributes/'.$code));
67
+ }
68
+
69
+ /**
70
+ * getter for helper member
71
+ * @access public
72
+ * @return Mage_Core_Helper_Abstract|mixed
73
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
74
+ */
75
+ public function getHelper(){
76
+ if (is_null($this->_helper)){
77
+ $this->_helper = Mage::helper('modulecreator');
78
+ }
79
+ return $this->_helper;
80
+ }
81
+
82
+ /**
83
+ * getter for padding
84
+ * @access public
85
+ * @param int $length
86
+ * @return string
87
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
88
+ */
89
+ public function getPadding($length = 1){
90
+ if (is_null($this->_padding)){
91
+ $this->_padding = Mage::helper('modulecreator')->getPadding();
92
+ }
93
+ return str_repeat($this->_padding, $length);
94
+ }
95
+
96
+ /**
97
+ * getter for end of line
98
+ * @access public
99
+ * @return string
100
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
101
+ */
102
+ public function getEol(){
103
+ if (is_null($this->_eol)){
104
+ $this->_eol = Mage::helper('modulecreator')->getEol();
105
+ }
106
+ return $this->_eol;
107
+ }
108
  }
app/code/community/Ultimate/ModuleCreator/Model/Adminhtml/System/Config/Source/Codepool.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * Ultimate_ModuleCreator extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
8
- * that is bundled with this package in the file LICENSE_UMC.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/mit-license.php
11
- *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * codepool source model
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Adminhtml_System_Config_Source_Codepool{
25
- /**
26
- * get the list of available codepools - intentionally not translated
27
- * @access public
28
- * @param bool $withEmpty
29
- * @return array
30
- * @author Marius Strajeru <marius.strajeru@gmail.com>
31
- */
32
- public function toOptionArray($withEmpty = false){
33
- $options = array();
34
- if ($withEmpty){
35
- $options[] = array('value'=>'', 'label'=>Mage::helper('modulecreator')->__('Select a codepool'));
36
- }
37
- $options[] = array('value' => 'local', 'label'=>'local');
38
- $options[] = array('value' => 'community', 'label'=>'community');
39
- return $options;
40
- }
41
- /**
42
- * get options as an array
43
- * @access public
44
- * @params bool $withEmpty
45
- * @return array
46
- * @author Marius Strajeru <marius.strajeru@gmail.com>
47
- */
48
- public function getAllOptions($withEmpty = true){
49
- $options = array();
50
- foreach ($this->toOptionArray($withEmpty) as $key=>$option){
51
- $options[$option['value']] = $option['label'];
52
- }
53
- return $options;
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Model/Adminhtml/System/Config/Source/Install.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * Ultimate_ModuleCreator extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
8
- * that is bundled with this package in the file LICENSE_UMC.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/mit-license.php
11
- *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * install source model
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Adminhtml_System_Config_Source_Install{
25
- /**
26
- * get the list of available install actions
27
- * @access public
28
- * @param bool $withEmpty
29
- * @return array
30
- * @author Marius Strajeru <marius.strajeru@gmail.com>
31
- */
32
- public function toOptionArray($withEmpty = false){
33
- $options = array();
34
- if ($withEmpty){
35
- $options[] = array('value'=>'', 'label'=>Mage::helper('modulecreator')->__('Select action'));
36
- }
37
- $options[] = array('value' => '1', 'label'=>Mage::helper('modulecreator')->__('Install new extension on the current instance.'));
38
- $options[] = array('value' => '0', 'label'=>Mage::helper('modulecreator')->__('Create archive. I will install it later'));
39
- return $options;
40
- }
41
- /**
42
- * get options as an array
43
- * @access public
44
- * @params bool $withEmpty
45
- * @return array
46
- * @author Marius Strajeru <marius.strajeru@gmail.com>
47
- */
48
- public function getAllOptions($withEmpty = true){
49
- $options = array();
50
- foreach ($this->toOptionArray($withEmpty) as $key=>$option){
51
- $options[$option['value']] = $option['label'];
52
- }
53
- return $options;
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Model/Adminhtml/System/Config/Source/Layout.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
- /**
3
- * Ultimate_ModuleCreator extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
8
- * that is bundled with this package in the file LICENSE_UMC.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/mit-license.php
11
- *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * layout source model
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
-
25
- class Ultimate_ModuleCreator_Model_Adminhtml_System_Config_Source_Layout{
26
- /**
27
- * get the list of available layouts
28
- * @access public
29
- * @return array
30
- * @author Marius Strajeru <marius.strajeru@gmail.com>
31
- */
32
- public function toOptionArray(){
33
- $options = array();
34
- $layouts = Mage::getSingleton('page/config')->getPageLayouts();
35
- foreach ($layouts as $layout){
36
- $options[] = array(
37
- 'value'=>$layout->getTemplate(),
38
- 'label'=>$layout->getLabel()
39
- );
40
- }
41
- return $options;
42
- }
43
- /**
44
- * get options as an array
45
- * @access public
46
- * @param bool $includeEmpty
47
- * @return array
48
- * @author Marius Strajeru <marius.strajeru@gmail.com>
49
- */
50
- public function getAllOptions($includeEmpty = true){
51
- $options = array();
52
- foreach ($this->toOptionArray() as $key=>$option){
53
- if (!$includeEmpty && $key == 0){
54
- continue;
55
- }
56
- $options[$option['value']] = $option['label'];
57
- }
58
- return $options;
59
- }
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Model/Attribute.php CHANGED
@@ -9,244 +9,554 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * entity model
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
  class Ultimate_ModuleCreator_Model_Attribute extends Ultimate_ModuleCreator_Model_Abstract{
25
- /**
26
- * entity object
27
- * @var mixed(null|Ultimate_ModuleCreator_Model_Entity)
28
- */
29
- protected $_entity = null;
30
- /**
31
- * attribyte type instance
32
- * @var mixed(null|Ultimate_ModuleCreator_Model_Attribute_Type_Abstract)
33
- */
34
- protected $_typeInstance = null;
35
- /**
36
- * set the model entity
37
- * @access public
38
- * @param Ultimate_ModuleCreator_Model_Entity $entity
39
- * @return Ultimate_ModuleCreator_Model_Attribute
40
- * @author Marius Strajeru <marius.strajeru@gmail.com>
41
- */
42
- public function setEntity(Ultimate_ModuleCreator_Model_Entity $entity){
43
- $this->_entity = $entity;
44
- return $this;
45
- }
46
- /**
47
- * get the attribute entity
48
- * @access public
49
- * @return mixed (Ultimate_ModuleCreator_Model_Entity|null)
50
- * @author Marius Strajeru <marius.strajeru@gmail.com>
51
- */
52
- public function getEntity(){
53
- return $this->_entity;
54
- }
55
- /**
56
- * get placeholders
57
- * @access publoc
58
- * @return array
59
- * @author Marius Strajeru <marius.strajeru@gmail.com>
60
- */
61
- public function getPlaceholders(){
62
- $placeholders['{{attributeLabel}}'] = $this->getLabel();
63
- $placeholders['{{AttributeMagicCode}}'] = $this->getMagicMethodCode();
64
- $placeholders['{{attributeCode}}'] = $this->getCode();
65
- $placeholders['{{attributeColumnOptions}}'] = $this->getColumnOptions();
66
- $placeholders['{{attributeFormType}}'] = $this->getFormType();
67
- $placeholders['{{attributeFormOptions}}'] = $this->getFormOptions();
68
- $placeholders['{{attributePreElementText}}']= $this->getPreElementText();
69
- $placeholders['{{attributeRssText}}'] = $this->getRssText();
70
- $placeholders['{{attributeNote}}'] = $this->getNote();
71
- return $placeholders;
72
- }
73
- /**
74
- * get the magic function code for attribute
75
- * @access public
76
- * @return string
77
- * @author Marius Strajeru <marius.strajeru@gmail.com>
78
- */
79
- public function getMagicMethodCode(){
80
- $code = $this->getCode();
81
- return $this->_camelize($code);
82
- }
83
- /**
84
- * get attribute the type instance
85
- * @access public
86
- * @return Ultimate_ModuleCreator_Model_Attribute_Type_Abstract
87
- * @author Marius Strajeru <marius.strajeru@gmail.com>
88
- */
89
- public function getTypeInstance(){
90
- if (!$this->_typeInstance){
91
- if (!$this->getType()){
92
- $type = 'abstract';
93
- }
94
- else{
95
- $type = $this->getType();
96
- }
97
- try{
98
- $this->_typeInstance = Mage::getModel('modulecreator/attribute_type_'.$type);
99
- $this->_typeInstance->setAttribute($this);
100
- }
101
- catch (Exception $e){
102
- throw new Ultimate_ModuleCreator_Exception("Invalid attribute type: ". $type);
103
- }
104
- }
105
- return $this->_typeInstance;
106
- }
107
- /**
108
- * get the admin grid column options
109
- * @access public
110
- * @return string
111
- * @author Marius Strajeru <marius.strajeru@gmail.com>
112
- */
113
- public function getColumnOptions(){
114
- return $this->getTypeInstance()->getColumnOptions();
115
- }
116
- /**
117
- * check if an attribute is in the admin grid
118
- * @access public
119
- * @return bool
120
- * @author Marius Strajeru <marius.strajeru@gmail.com>
121
- */
122
- public function getAdminGrid(){
123
- if ($this->getIsName()){
124
- return true;
125
- }
126
- return $this->getTypeInstance()->getAdminGrid();
127
- }
128
- /**
129
- * check if an attribute can use an editor
130
- * @access public
131
- * @return bool
132
- * @author Marius Strajeru <marius.strajeru@gmail.com>
133
- */
134
- public function getEditor(){
135
- return $this->getTypeInstance()->getEditor();
136
- }
137
- /**
138
- * get the type for the form
139
- * @access public
140
- * @return string
141
- * @author Marius Strajeru <marius.strajeru@gmail.com>
142
- */
143
- public function getFormType(){
144
- return $this->getTypeInstance()->getFormType();
145
- }
146
- /**
147
- * get the additional data for the form
148
- * @access public
149
- * @return string
150
- * @author Marius Strajeru <marius.strajeru@gmail.com>
151
- */
152
- public function getFormOptions(){
153
- return $this->getTypeInstance()->getFormOptions();
154
- }
155
- /**
156
- * get the sql column
157
- * @access public
158
- * @return string
159
- * @author Marius Strajeru <marius.strajeru@gmail.com>
160
- */
161
- public function getSqlColumn(){
162
- return $this->getTypeInstance()->getSqlColumn();
163
- }
164
- /**
165
- * get the sql column
166
- * @access public
167
- * @return string
168
- * @author Marius Strajeru <marius.strajeru@gmail.com>
169
- */
170
- public function getDdlSqlColumn(){
171
- $ddl = '';
172
- $ddl .= "->addColumn('{$this->getCode()}', Varien_Db_Ddl_Table::".$this->getTypeDdl().", ".$this->getSizeDdl().", array(\n";
173
- if ($this->getRequired()){
174
- $ddl .= "\t\t"."'nullable' => false,\n";
175
- }
176
- if ($this->getType() == 'int'){
177
- $ddl .= "\t\t"."'unsigned' => true,\n";
178
- }
179
- $ddl .= "\t\t), '".$this->getLabel()."')\n";
180
- return $ddl;
181
- }
182
- /**
183
- * get column ddl type
184
- * @access public
185
- * @return string
186
- * @author Marius Strajeru <marius.strajeru@gmail.com>
187
- */
188
- public function getTypeDdl(){
189
- return $this->getTypeInstance()->getTypeDdl();
190
- }
191
- /**
192
- * get column ddl size
193
- * @access public
194
- * @return string
195
- * @author Marius Strajeru <marius.strajeru@gmail.com>
196
- */
197
- public function getSizeDdl(){
198
- return $this->getTypeInstance()->getSizeDdl();
199
- }
200
- /**
201
- * get the frontend html
202
- * @access public
203
- * @return string
204
- * @author Marius Strajeru <marius.strajeru@gmail.com>
205
- */
206
- public function getFrontendHtml(){
207
- return $this->getTypeInstance()->getFrontendHtml();
208
- }
209
- /**
210
- * get text before the element in the admin grid
211
- * @access public
212
- * @return string
213
- * @author Marius Strajeru <marius.strajeru@gmail.com>
214
- */
215
- public function getPreElementText(){
216
- return $this->getTypeInstance()->getPreElementText();
217
- }
218
- /**
219
- * get RSS feed text
220
- * @access public
221
- * @return string
222
- * @author Marius Strajeru <marius.strajeru@gmail.com>
223
- */
224
- public function getRssText(){
225
- return $this->getTypeInstance()->getRssText();
226
- }
227
- /**
228
- * gcheck if attribute is required
229
- * @access public
230
- * @return string
231
- * @author Marius Strajeru <marius.strajeru@gmail.com>
232
- */
233
- public function getRequired(){
234
- if ($this->getIsName()){
235
- return true;
236
- }
237
- return $this->getTypeInstance()->getRequired();
238
- }
239
- /**
240
- * get wsdl format for attribute
241
- * @access public
242
- * @param bool $wsi
243
- * @return string
244
- * @author Marius Strajeru <marius.strajeru@gmail.com>
245
- */
246
- public function getWsdlFormat($wsi = false){
247
- if ($wsi){
248
- return '<xsd:element name="'.$this->getCode().'" type="xsd:string" />';
249
- }
250
- return '<element name="'.$this->getCode().'" type="xsd:string" minOccurs="'.(int)$this->getRequired().'" />';
251
- }
252
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
 
 
 
 
 
 
18
  class Ultimate_ModuleCreator_Model_Attribute extends Ultimate_ModuleCreator_Model_Abstract{
19
+ /**
20
+ * custom option separator
21
+ */
22
+ const OPTION_SEPARATOR = '|';
23
+ /**
24
+ * entity object
25
+ * @var mixed(null|Ultimate_ModuleCreator_Model_Entity)
26
+ */
27
+ protected $_entity = null;
28
+ /**
29
+ * attribute type instance
30
+ * @var mixed(null|Ultimate_ModuleCreator_Model_Attribute_Type_Abstract)
31
+ */
32
+ protected $_typeInstance = null;
33
+ /**
34
+ * placeholders for replacing in source
35
+ * @var mixed
36
+ */
37
+ protected $_placeholders = null;
38
+ /**
39
+ * set the model entity
40
+ * @access public
41
+ * @param Ultimate_ModuleCreator_Model_Entity $entity
42
+ * @return Ultimate_ModuleCreator_Model_Attribute
43
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
44
+ */
45
+ public function setEntity(Ultimate_ModuleCreator_Model_Entity $entity){
46
+ $this->_entity = $entity;
47
+ return $this;
48
+ }
49
+ /**
50
+ * get the attribute entity
51
+ * @access public
52
+ * @return Ultimate_ModuleCreator_Model_Entity
53
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
54
+ */
55
+ public function getEntity(){
56
+ return $this->_entity;
57
+ }
58
+ /**
59
+ * get the magic function code for attribute
60
+ * @access public
61
+ * @param bool $ucFirst
62
+ * @return string
63
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
64
+ */
65
+ public function getMagicMethodCode($ucFirst = true){
66
+ $code = $this->getCode();
67
+ $code = $this->_camelize($code);
68
+ if ($ucFirst){
69
+ return $code;
70
+ }
71
+ //lcfirst only works for php 5.3+
72
+ $code{0} = strtolower($code{0});
73
+ return $code;
74
+ }
75
+ /**
76
+ * get attribute the type instance
77
+ * @access public
78
+ * @return Ultimate_ModuleCreator_Model_Attribute_Type_Abstract
79
+ * @throws Ultimate_ModuleCreator_Exception
80
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
81
+ */
82
+ public function getTypeInstance(){
83
+ if (!$this->_typeInstance){
84
+ $type = $this->getType();
85
+ try{
86
+ $types = Mage::helper('modulecreator')->getAttributeTypes(false);
87
+ $instanceModel = $types->$type->type_model;
88
+ $this->_typeInstance = Mage::getModel($instanceModel);
89
+ $this->_typeInstance->setAttribute($this);
90
+ }
91
+ catch (Exception $e){
92
+ throw new Ultimate_ModuleCreator_Exception("Invalid attribute type: ". $type);
93
+ }
94
+ }
95
+ return $this->_typeInstance;
96
+ }
97
+ /**
98
+ * check if an attribute is in the admin grid
99
+ * @access public
100
+ * @return bool
101
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
102
+ */
103
+ public function getAdminGrid(){
104
+ if ($this->getIsName()){
105
+ return true;
106
+ }
107
+ return $this->getTypeInstance()->getAdminGrid();
108
+ }
109
+ /**
110
+ * check if an attribute can use an editor
111
+ * @access public
112
+ * @return bool
113
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
114
+ */
115
+ public function getEditor(){
116
+ return $this->getTypeInstance()->getEditor();
117
+ }
118
+ /**
119
+ * check if attribute is required
120
+ * @access public
121
+ * @return string
122
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
123
+ */
124
+ public function getRequired(){
125
+ if ($this->getIsName()){
126
+ return true;
127
+ }
128
+ return $this->getTypeInstance()->getRequired();
129
+ }
130
+ /**
131
+ * check if attribute can behave as name
132
+ * @access public
133
+ * @return bool
134
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
135
+ */
136
+ public function getIsAllowedAsName(){
137
+ return $this->getTypeInstance()->getIsAllowedAsName();
138
+ }
139
+
140
+ /**
141
+ * check if the attribute acts as name
142
+ * @access public
143
+ * @return bool
144
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
145
+ */
146
+ public function getNotIsName(){
147
+ return !$this->getIsName();
148
+ }
149
+
150
+ /**
151
+ * get attribute placeholders
152
+ * @access public
153
+ * @param null $key
154
+ * @return mixed|null|string
155
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
156
+ */
157
+ public function getPlaceholders($key = null){
158
+ if (is_null($this->_placeholders)){
159
+ $placeholders['{{attributeLabel}}'] = $this->getLabel();
160
+ $placeholders['{{AttributeMagicCode}}'] = $this->getMagicMethodCode();
161
+ $placeholders['{{attributeMagicCode}}'] = $this->getMagicMethodCode(false);
162
+ $placeholders['{{attributeCode}}'] = $this->getCode();
163
+ $placeholders['{{attributeColumnOptions}}'] = $this->getAdminColumnOptions();
164
+ $placeholders['{{attributeFormType}}'] = $this->getFormType();
165
+ $placeholders['{{attributeFormOptions}}'] = $this->getFormOptions();
166
+ $placeholders['{{attributePreElementText}}'] = $this->getPreElementText();
167
+ $placeholders['{{attributeRssText}}'] = $this->getRssText();
168
+ $placeholders['{{attributeNote}}'] = $this->getNote();
169
+ $placeholders['{{AttributeCodeForFile}}'] = $this->getCodeForFileName(true);
170
+ $placeholders['{{attributeCodeForFile}}'] = $this->getCodeForFileName(false);
171
+ $placeholders['{{attributeOptions}}'] = $this->getAttributeOptions();
172
+ $placeholders['{{massActionValues}}'] = $this->getMassActionValues();
173
+
174
+ $eventObject = new Varien_Object(
175
+ array(
176
+ 'placeholders' => $placeholders
177
+ )
178
+ );
179
+ Mage::dispatchEvent('umc_attribute_placeholdrers', array('event_object'=>$eventObject));
180
+ $placeholders = $eventObject->getPlaceholders();
181
+ $this->_placeholders = $placeholders;
182
+ }
183
+ if (is_null($key)){
184
+ return $this->_placeholders;
185
+ }
186
+ if (isset($this->_placeholders[$key])){
187
+ return $this->_placeholders[$key];
188
+ }
189
+ return '';
190
+ }
191
+
192
+ /**
193
+ * get additional admin grid column options
194
+ * @access public
195
+ * @return string
196
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
197
+ */
198
+ public function getAdminColumnOptions(){
199
+ $options = $this->getTypeInstance()->getAdminColumnOptions();
200
+ if ($this->getUseFilterIndex()){
201
+ $options .= $this->getPadding(3)."'filter_index' => '".$this->getEntity()->getEntityTableAlias().".".$this->getCode()."'".$this->getEol();
202
+ }
203
+ return $options;
204
+ }
205
+
206
+ /**
207
+ * get options for attribute
208
+ * @access public
209
+ * @param bool $asArray
210
+ * @return array|mixed
211
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
212
+ */
213
+ public function getOptions($asArray = false){
214
+ if (!$asArray){
215
+ return $this->getData('options');
216
+ }
217
+ return explode(self::OPTION_SEPARATOR, $this->getData('options'));
218
+ }
219
+
220
+ /**
221
+ * get form type
222
+ * @access public
223
+ * @return string
224
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
225
+ */
226
+ public function getFormType(){
227
+ return $this->getTypeInstance()->getFormType();
228
+ }
229
+
230
+ /**
231
+ * get text for rss
232
+ * @access public
233
+ * @return string
234
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
235
+ */
236
+ public function getRssText(){
237
+ return $this->getTypeInstance()->getRssText();
238
+ }
239
+ /**
240
+ * get the sql column
241
+ * @access public
242
+ * @return string
243
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
244
+ */
245
+ public function getDdlSqlColumn(){
246
+ $helper = Mage::helper('modulecreator');
247
+ $ddl = '';
248
+ $ddl .= "->addColumn('{$this->getCode()}', Varien_Db_Ddl_Table::".$this->getTypeDdl().", ".$this->getSizeDdl().", array(".$this->getEol();
249
+ if ($this->getRequired()){
250
+ $ddl .= $helper->getPadding(2)."'nullable' => false,".$this->getEol();
251
+ }
252
+ if ($this->getType() == 'int'){
253
+ $ddl .= $helper->getPadding(2)."'unsigned' => true,".$this->getEol();
254
+ }
255
+ $ddl .= $helper->getPadding(2)."), '".$this->getLabel()."')".$this->getEol();
256
+ return $ddl;
257
+ }
258
+ /**
259
+ * get column ddl type
260
+ * @access public
261
+ * @return string
262
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
263
+ */
264
+ public function getTypeDdl(){
265
+ return $this->getTypeInstance()->getTypeDdl();
266
+ }
267
+ /**
268
+ * get column ddl size
269
+ * @access public
270
+ * @return string
271
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
272
+ */
273
+ public function getSizeDdl(){
274
+ return $this->getTypeInstance()->getSizeDdl();
275
+ }
276
+ /**
277
+ * get the frontend html
278
+ * @access public
279
+ * @return string
280
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
281
+ */
282
+ public function getFrontendHtml(){
283
+ return $this->getTypeInstance()->getFrontendHtml();
284
+ }
285
+ /**
286
+ * get wsdl format for attribute
287
+ * @access public
288
+ * @param bool $wsi
289
+ * @return string
290
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
291
+ */
292
+ public function getWsdlFormat($wsi = false){
293
+ if ($wsi){
294
+ return '<xsd:element name="'.$this->getCode().'" type="xsd:string" />';
295
+ }
296
+ return '<element name="'.$this->getCode().'" type="xsd:string" minOccurs="'.(int)$this->getRequired().'" />';
297
+ }
298
+
299
+ /**
300
+ * get setup content for attribute
301
+ * @access public
302
+ * @return mixed
303
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
304
+ */
305
+ public function getSetupContent(){
306
+ $content = '';
307
+ $padding5 = $this->getPadding(5);
308
+ $padding6 = $this->getPadding(6);
309
+ $eol = $this->getEol();
310
+ $content .= $padding5."'".$this->getCode()."' => array(".$eol;
311
+ $content .= $padding6."'group' => 'General',".$eol;
312
+ $content .= $padding6."'type' => '".$this->getSetupType()."',".$eol;
313
+ $content .= $padding6."'backend' => '".$this->getSetupBackend()."',".$eol;
314
+ $content .= $padding6."'frontend' => '',".$eol;
315
+ $content .= $padding6."'label' => '".$this->getLabel()."',".$eol;
316
+ $content .= $padding6."'input' => '".$this->getSetupInput()."',".$eol;
317
+ $content .= $padding6."'source' => '".$this->getSetupSource()."',".$eol;
318
+ $content .= $padding6."'global' => ".$this->getSetupIsGlobal().",".$eol;
319
+ $content .= $padding6."'required' => '".$this->getRequired()."',".$eol;
320
+ $content .= $padding6."'user_defined' => ".$this->getIsUserDefined().",".$eol;
321
+ $content .= $padding6."'default' => '',".$eol;
322
+ $content .= $padding6."'unique' => false,".$eol;
323
+ $content .= $padding6."'position' => '".(int)$this->getPosition()."',".$eol;
324
+ $content .= $padding6."'note' => '".$this->getNote()."',".$eol;
325
+ $content .= $padding6."'visible' => '".(int)$this->getVisible()."',".$eol;
326
+ $content .= $padding6."'wysiwyg_enabled'=> '".(int)$this->getEditor()."',".$eol;
327
+ $content .= $this->getAdditionalSetup();
328
+ $content .= $padding5 .'),'.$eol;
329
+
330
+ return $content;
331
+ }
332
+ /**
333
+ * get setup type
334
+ * @access public
335
+ * @return string
336
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
337
+ */
338
+ public function getSetupType(){
339
+ if ($this->hasForcedSetupType()){
340
+ return $this->getForcedSetupType();
341
+ }
342
+ return $this->getTypeInstance()->getSetupType();
343
+ }
344
+ /**
345
+ * get setup backend
346
+ * @access public
347
+ * @return string
348
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
349
+ */
350
+ public function getSetupBackend(){
351
+ if ($this->getForcedSetupBackend()){
352
+ return $this->getForcedSetupBackend();
353
+ }
354
+ return $this->getTypeInstance()->getSetupBackend();
355
+ }
356
+ /**
357
+ * get setup input
358
+ * @access public
359
+ * @return string
360
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
361
+ */
362
+ public function getSetupInput(){
363
+ return $this->getTypeInstance()->getSetupInput();
364
+ }
365
+ /**
366
+ * get setup source
367
+ * @access public
368
+ * @return string
369
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
370
+ */
371
+ public function getSetupSource(){
372
+ if ($this->getForcedSource()){
373
+ return $this->getForcedSource();
374
+ }
375
+ return $this->getTypeInstance()->getSetupSource();
376
+ }
377
+ /**
378
+ * check id an attribute is global
379
+ * @access public
380
+ * @return int
381
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
382
+ */
383
+ public function getSetupIsGlobal(){
384
+ switch ($this->getScope()){
385
+ case Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE:
386
+ return 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE';
387
+ break;
388
+ case Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL:
389
+ return 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL';
390
+ break;
391
+ case Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE:
392
+ return 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE';
393
+ break;
394
+ default :
395
+ return '';
396
+ break;
397
+ }
398
+ }
399
+
400
+
401
+ /**
402
+ * get attribute code for file name
403
+ * @access public
404
+ * @param bool $uppercase
405
+ * @return string
406
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
407
+ */
408
+ public function getCodeForFileName($uppercase = false){
409
+ $code = str_replace('_', '', $this->getCode());
410
+ if ($uppercase){
411
+ $code = ucfirst($code);
412
+ }
413
+ return $code;
414
+ }
415
+ /**
416
+ * check if attribute is visible
417
+ * @access public
418
+ * @return string
419
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
420
+ */
421
+ public function getVisible(){
422
+ if (($this->hasForcedVisible())){
423
+ return $this->getForcedVisible();
424
+ }
425
+ return $this->getTypeInstance()->getVisible();
426
+ }
427
+ /**
428
+ * check if source needs to be generated
429
+ * @access public
430
+ * @return string
431
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
432
+ */
433
+ public function getGenerateSource() {
434
+ return $this->getTypeInstance()->getGenerateSource();
435
+ }
436
+
437
+ /**
438
+ * get additional setup values
439
+ * @access public
440
+ * @return string
441
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
442
+ */
443
+ public function getAdditionalSetup() {
444
+ return $this->getTypeInstance()->getAdditionalSetup();
445
+ }
446
+ /**
447
+ * check if attribute is yes/no
448
+ * @access public
449
+ * @return bool
450
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
451
+ */
452
+ public function getIsYesNo() {
453
+ return $this->getTypeInstance()->getIsYesNo();
454
+ }
455
+
456
+ /**
457
+ * get attribute options for source model
458
+ * @access public
459
+ * @return string
460
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
461
+ */
462
+ public function getAttributeOptions() {
463
+ return $this->getTypeInstance()->getAttributeOptions();
464
+ }
465
+
466
+ /**
467
+ * check if attribute is user defined
468
+ * @access public
469
+ * @param bool $asText
470
+ * @return string
471
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
472
+ */
473
+ public function getIsUserDefined($asText = true) {
474
+ if (!$this->hasData('user_defined')) {
475
+ $this->setData('user_defined', true);
476
+ }
477
+ if (!$asText) {
478
+ return $this->getData('user_defined');
479
+ }
480
+ if ($this->getData('user_defined')) {
481
+ return 'true';
482
+ }
483
+ return 'false';
484
+ }
485
+ /**
486
+ * get admin from options
487
+ * @access public
488
+ * @return string
489
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
490
+ */
491
+ public function getFormOptions(){
492
+ return $this->getTypeInstance()->getFormOptions();
493
+ }
494
+
495
+ /**
496
+ * check if attribute is multiple select
497
+ * @access public
498
+ * @return bool
499
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
500
+ */
501
+ public function getIsMultipleSelect(){
502
+ return $this->getTypeInstance()->getIsMultipleSelect();
503
+ }
504
+ /**
505
+ * check if entity is eav
506
+ * @access public
507
+ * @return bool
508
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
509
+ */
510
+ public function getEntityEav() {
511
+ return $this->getEntity()->getIsEav();
512
+ }
513
+ /**
514
+ * check if entity is not eav
515
+ * @access public
516
+ * @return bool
517
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
518
+ */
519
+ public function getNotEntityEav() {
520
+ return !$this->getEntityEav();
521
+ }
522
+
523
+ /**
524
+ * check if attribute can be in mass update
525
+ * @access public
526
+ * @return mixed
527
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
528
+ */
529
+ public function getMassUpdate() {
530
+ return $this->getTypeInstance()->getMassUpdate();
531
+ }
532
+
533
+ /**
534
+ * get values for mass action
535
+ * @access public
536
+ * @return string
537
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
538
+ */
539
+ public function getMassActionValues() {
540
+ return $this->getTypeInstance()->getMassActionValues();
541
+ }
542
+
543
+ /**
544
+ * get module
545
+ * @access public
546
+ * @return Ultimate_ModuleCreator_Model_Module
547
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
548
+ */
549
+ public function getModule(){
550
+ return $this->getEntity()->getModule();
551
+ }
552
+ /**
553
+ * get namespace
554
+ * @access public
555
+ * @param bool $lower
556
+ * @return string
557
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
558
+ */
559
+ public function getNamespace($lower = false){
560
+ return $this->getModule()->getNamespace($lower);
561
+ }
562
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Abstract.php CHANGED
@@ -9,186 +9,359 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type abstract
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Abstract extends Varien_Object{
25
- /**
26
- * separator for options
27
- * @var string
28
- */
29
- const OPTION_SEPARATOR = "\t\t\t";
30
- /**
31
- * attribute memebr
32
- * @var mixed(null|Ultimate_ModuleCreator_Model_Attribute)
33
- */
34
- protected $_attribute = null;
35
- /**
36
- * sql colum ddl type
37
- * @var string
38
- */
39
- protected $_typeDdl = 'TYPE_TEXT';
40
- /**
41
- * sql colum ddl size
42
- * @var string
43
- */
44
- protected $_sizeDdl = '255';
45
- /**
46
- * set attribute
47
- * @access public
48
- * @param Ultimate_ModuleCreator_Model_Attribute $attribute
49
- * @return Ultimate_ModuleCreator_Model_Attribute_Type_Abstract
50
- * @author Marius Strajeru <marius.strajeru@gmail.com>
51
- */
52
- public function setAttribute(Ultimate_ModuleCreator_Model_Attribute $attribute){
53
- $this->_attribute = $attribute;
54
- return $this;
55
- }
56
- /**
57
- * get the attribute
58
- * @access public
59
- * @return mixed(null|Ultimate_ModuleCreator_Model_Attribute)
60
- * @author Marius Strajeru <marius.strajeru@gmail.com>
61
- */
62
- public function getAttribute(){
63
- return $this->_attribute;
64
- }
65
- /**
66
- * get the grid column options
67
- * @access public
68
- * @return string
69
- * @author Marius Strajeru <marius.strajeru@gmail.com>
70
- */
71
- public function getColumnOptions(){
72
- return "'type' => 'text',"."\n";
73
- }
74
- /**
75
- * check if an attribute is in the admin grid
76
- * @access public
77
- * @return bool
78
- * @author Marius Strajeru <marius.strajeru@gmail.com>
79
- */
80
- public function getAdminGrid(){
81
- return $this->getAttribute()->getData('admin_grid');
82
- }
83
- /**
84
- * check if an attribute uses an editor
85
- * @access public
86
- * @return bool
87
- * @author Marius Strajeru <marius.strajeru@gmail.com>
88
- */
89
- public function getEditor(){
90
- return false;
91
- }
92
- /**
93
- * check if an attribute is required
94
- * @access public
95
- * @return bool
96
- * @author Marius Strajeru <marius.strajeru@gmail.com>
97
- */
98
- public function getRequired(){
99
- return $this->getAttribute()->getData('required');
100
- }
101
- /**
102
- * get the type for the form
103
- * @access public
104
- * @return string
105
- * @author Marius Strajeru <marius.strajeru@gmail.com>
106
- */
107
- public function getFormType(){
108
- return 'text';
109
- }
110
- /**
111
- * get the options for form input
112
- * @access public
113
- * @return string
114
- * @author Marius Strajeru <marius.strajeru@gmail.com>
115
- */
116
- public function getFormOptions(){
117
- $options = '';
118
- $note = $this->getAttribute()->getNote();
119
- if ($note){
120
- $options .= self::OPTION_SEPARATOR."'note' => $"."this->__('".$note."'),"."\n";
121
- }
122
- if ($this->getRequired()){
123
- $options .= self::OPTION_SEPARATOR."'required' => true,"."\n";
124
- $options .= self::OPTION_SEPARATOR."'class' => 'required-entry',"."\n";
125
- }
126
- return $options."\n";
127
- }
128
- /**
129
- * get the text before the element in the admin form
130
- * @access public
131
- * @return string
132
- * @author Marius Strajeru <marius.strajeru@gmail.com>
133
- */
134
- public function getPreElementText(){
135
- return '';
136
- }
137
- /**
138
- * get the sql column
139
- * @access public
140
- * @return string
141
- * @author Marius Strajeru <marius.strajeru@gmail.com>
142
- */
143
- public function getSqlColumn(){
144
- return '`'.$this->getAttribute()->getCode().'` varchar(255) '.$this->getNullSql().' default \'\',';
145
- }
146
- /**
147
- * check if sql column can be null
148
- * @access public
149
- * @return string
150
- * @author Marius Strajeru <marius.strajeru@gmail.com>
151
- */
152
- public function getNullSql(){
153
- if ($this->getAttribute()->getRequired()){
154
- return 'NOT NULL';
155
- }
156
- return 'NULL';
157
- }
158
- /**
159
- * get the html for frontend
160
- * @access public
161
- * @return string
162
- * @author Marius Strajeru <marius.strajeru@gmail.com>
163
- */
164
- public function getFrontendHtml(){
165
- return '<?php echo Mage::helper(\''.strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName()).'\')->__(\''.$this->getAttribute()->getLabel().'\');?>:<?php echo $_'.strtolower($this->getAttribute()->getEntity()->getNameSingular()).'->get'.$this->getAttribute()->getMagicMethodCode().'();?>'."\n";
166
- }
167
- /**
168
- * get the text for RSS
169
- * @access public
170
- * @return string
171
- * @author Marius Strajeru <marius.strajeru@gmail.com>
172
- */
173
- public function getRssText(){
174
- return ' $'.'description .= $item->get'.$this->getAttribute()->getMagicMethodCode().'();';
175
- }
176
- /**
177
- * get column ddl type
178
- * @access public
179
- * @return string
180
- * @author Marius Strajeru <marius.strajeru@gmail.com>
181
- */
182
- public function getTypeDdl(){
183
- return $this->_typeDdl;
184
- }
185
- /**
186
- * get column ddl size
187
- * @access public
188
- * @return string
189
- * @author Marius Strajeru <marius.strajeru@gmail.com>
190
- */
191
- public function getSizeDdl(){
192
- return $this->_sizeDdl;
193
- }
194
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * abstract attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Abstract
26
+ extends Ultimate_ModuleCreator_Model_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'abstract';
32
+ /**
33
+ * attribute object
34
+ * @var mixed
35
+ */
36
+ protected $_attribute = null;
37
+ /**
38
+ * sql column ddl type
39
+ * @var string
40
+ */
41
+ protected $_typeDdl = 'TYPE_TEXT';
42
+ /**
43
+ * sql column ddl size
44
+ * @var string
45
+ */
46
+ protected $_sizeDdl = '255';
47
+
48
+ /**
49
+ * eav setup type
50
+ */
51
+ protected $_setupType = 'varchar';
52
+ /**
53
+ * eav setup backend
54
+ * @var string
55
+ */
56
+ protected $_setupBackend = '';
57
+ /**
58
+ * eav setup input
59
+ * @var string
60
+ */
61
+ protected $_setupInput = 'text';
62
+ /**
63
+ * eav setup source
64
+ * @var string
65
+ */
66
+ protected $_setupSource = '';
67
+
68
+ /**
69
+ * set the attribute
70
+ * @param Ultimate_ModuleCreator_Model_Attribute $attribute
71
+ * @return Ultimate_ModuleCreator_Model_Attribute_Type_Abstract
72
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
73
+ */
74
+ public function setAttribute(Ultimate_ModuleCreator_Model_Attribute $attribute) {
75
+ $this->_attribute = $attribute;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * get attribute object
81
+ * @access public
82
+ * @return Ultimate_ModuleCreator_Model_Attribute|null
83
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
84
+ */
85
+ public function getAttribute() {
86
+ return $this->_attribute;
87
+ }
88
+ /**
89
+ * get module
90
+ * @access public
91
+ * @return Ultimate_ModuleCreator_Model_Module
92
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
93
+ */
94
+ public function getEntity(){
95
+ return $this->getAttribute()->getEntity();
96
+ }
97
+ /**
98
+ * get module
99
+ * @access public
100
+ * @return Ultimate_ModuleCreator_Model_Module
101
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
102
+ */
103
+ public function getModule(){
104
+ return $this->getAttribute()->getModule();
105
+ }
106
+ /**
107
+ * get namespace
108
+ * @access public
109
+ * @param bool $lower
110
+ * @return string
111
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
112
+ */
113
+ public function getNamespace($lower = false){
114
+ return $this->getModule()->getNamespace($lower);
115
+ }
116
+ /**
117
+ * check if attribute can be in admin grid
118
+ * @access public
119
+ * @return bool
120
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
121
+ */
122
+ public function getAdminGrid() {
123
+ return $this->getAttribute()->getData('admin_grid');
124
+ }
125
+ /**
126
+ * get column options
127
+ * @access public
128
+ * @return string
129
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
130
+ */
131
+ public function getAdminColumnOptions() {
132
+ return '';
133
+ }
134
+
135
+ /**
136
+ * get text for rss
137
+ * @access public
138
+ * @return string
139
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
140
+ */
141
+ public function getRssText() {
142
+ $attribute = $this->getAttribute();
143
+ $module = $this->getModule()->getLowerModuleName();
144
+ $namespace = $this->getNamespace(true);
145
+ return $this->getPadding(3).'$'.'description .= \'<div>\'.Mage::helper(\''.$namespace.'_'.$module.'\')->__(\''.$attribute->getLabel().'\').\': \'.$item->get'.$this->getAttribute()->getMagicMethodCode().'().\'</div>\';'.$this->getEol();
146
+ }
147
+ /**
148
+ * get the type for the form
149
+ * @access public
150
+ * @return string
151
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
152
+ */
153
+ public function getFormType() {
154
+ return 'text';
155
+ }
156
+ /**
157
+ * get column ddl type
158
+ * @access public
159
+ * @return string
160
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
161
+ */
162
+ public function getTypeDdl() {
163
+ return $this->_typeDdl;
164
+ }
165
+ /**
166
+ * get column ddl size
167
+ * @access public
168
+ * @return string
169
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
170
+ */
171
+ public function getSizeDdl() {
172
+ return $this->_sizeDdl;
173
+ }
174
+ /**
175
+ * get the html for frontend
176
+ * @access public
177
+ * @return string
178
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
179
+ */
180
+ public function getFrontendHtml() {
181
+ return '<?php echo Mage::helper(\''.$this->getNamespace(true).'_'.$this->getModule()->getLowerModuleName().'\')->__(\''.$this->getAttribute()->getLabel().'\');?>:<?php echo $_'.strtolower($this->getAttribute()->getEntity()->getNameSingular()).'->get'.$this->getAttribute()->getMagicMethodCode().'();?>'.$this->getHelper()->getEol();
182
+ }
183
+ /**
184
+ * get the setup type
185
+ * @access public
186
+ * @return string
187
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
188
+ */
189
+ public function getSetupType(){
190
+ return $this->_setupType;
191
+ }
192
+ /**
193
+ * get setup backend type
194
+ * @access public
195
+ * @return string
196
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
197
+ */
198
+ public function getSetupBackend(){
199
+ return $this->_setupBackend;
200
+ }
201
+ /**
202
+ * get the setup input
203
+ * @access public
204
+ * @return string
205
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
206
+ */
207
+ public function getSetupInput(){
208
+ return $this->_setupInput;
209
+ }
210
+ /**
211
+ * get the setup source
212
+ * @access public
213
+ * @return string
214
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
215
+ */
216
+ public function getSetupSource(){
217
+ return $this->_setupSource;
218
+ }
219
+ /**
220
+ * check if attribute is visible
221
+ * @access public
222
+ * @return string
223
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
224
+ */
225
+ public function getVisible(){
226
+ return true;
227
+ }
228
+ /**
229
+ * check if source needs to be generated
230
+ * @access public
231
+ * @return string
232
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
233
+ */
234
+ public function getGenerateSource(){
235
+ return false;
236
+ }
237
+ /**
238
+ * get additional setup values
239
+ * @access public
240
+ * @return string
241
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
242
+ */
243
+ public function getAdditionalSetup(){
244
+ return '';
245
+ }
246
+
247
+ /**
248
+ * check if attribute is required
249
+ * @access public
250
+ * @return mixed
251
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
252
+ */
253
+ public function getRequired(){
254
+ return $this->getAttribute()->getData('required');
255
+ }
256
+
257
+ /**
258
+ * check if attribute is yes/no
259
+ * @access public
260
+ * @return bool
261
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
262
+ */
263
+ public function getIsYesNo() {
264
+ return false;
265
+ }
266
+
267
+ /**
268
+ * can use editor
269
+ * @access public
270
+ * @return bool
271
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
272
+ */
273
+ public function getEditor() {
274
+ return false;
275
+ }
276
+ /**
277
+ * get attribute options for source model
278
+ * @access public
279
+ * @return string
280
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
281
+ */
282
+ public function getAttributeOptions(){
283
+ return $this->getPadding(2).'return array();';
284
+ }
285
+ /**
286
+ * get admin from options
287
+ * @access public
288
+ * @return string
289
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
290
+ */
291
+ public function getFormOptions(){
292
+ $options = '';
293
+ $padding = $this->getPadding(3);
294
+ $eol = $this->getEol();
295
+ $note = $this->getAttribute()->getNote();
296
+ if ($note){
297
+ $options .= $padding."'note' => $"."this->__('".$note."'),".$eol;
298
+ }
299
+ if ($this->getRequired()){
300
+ $options .= $padding."'required' => true,".$eol;
301
+ $options .= $padding."'class' => 'required-entry',".$eol;
302
+ }
303
+ return $options.$eol;
304
+ }
305
+
306
+ /**
307
+ * getter for attribute type
308
+ * @return string
309
+ * @access public
310
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
311
+ */
312
+ public function getType(){
313
+ return $this->_type;
314
+ }
315
+ /**
316
+ * getter xml node for attribute
317
+ * @return string
318
+ * @access public
319
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
320
+ */
321
+ public function getTypeConfigPath() {
322
+ return Ultimate_ModuleCreator_Helper_Data::ATTRIBUTE_TYPES_PATH.'/'.$this->getType();
323
+ }
324
+ /**
325
+ * getter config for attribute
326
+ * @access public
327
+ * @param $path
328
+ * @return mixed
329
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
330
+ */
331
+ public function getConfig($path = null) {
332
+ if (!is_null($path)){
333
+ $path = $this->getTypeConfigPath().'/'.$path;
334
+ }
335
+ else {
336
+ $path = $this->getTypeConfigPath();
337
+ }
338
+ return Mage::helper('modulecreator')->getConfig()->getNode($path);
339
+ }
340
+ /**
341
+ * check if attribute can behave as name
342
+ * @access public
343
+ * @return bool
344
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
345
+ */
346
+ public function getIsAllowedAsName() {
347
+ return (bool)(string)$this->getConfig('allow_is_name');
348
+ }
349
+ /**
350
+ * check if attribute can be in mass update
351
+ * @access public
352
+ * @return mixed
353
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
354
+ */
355
+ public function getMassUpdate() {
356
+ return (bool)(string)$this->getConfig('mass_update');
357
+ }
358
+ /**
359
+ * get values for mass action
360
+ * @access public
361
+ * @return string
362
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
363
+ */
364
+ public function getMassActionValues() {
365
+ return '';
366
+ }
367
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Country.php CHANGED
@@ -9,85 +9,118 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type country
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Country extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract{
25
- /**
26
- * sql colum ddl size
27
- * @var string
28
- */
29
- protected $_sizeDdl = '2';
30
- /**
31
- * get the type for the form
32
- * @access public
33
- * @return string
34
- * @author Marius Strajeru <marius.strajeru@gmail.com>
35
- */
36
- public function getFormType(){
37
- return 'select';
38
- }
39
- /**
40
- * get the options for form input
41
- * @access public
42
- * @return string
43
- * @author Marius Strajeru <marius.strajeru@gmail.com>
44
- */
45
- public function getFormOptions(){
46
- $options = parent::getFormOptions();
47
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
48
- $options .= self::OPTION_SEPARATOR."'values'=> Mage::getResourceModel('directory/country_collection')->toOptionArray(),\n";
49
- return $options;
50
- }
51
- /**
52
- * get the sql column
53
- * @access public
54
- * @return string
55
- * @author Marius Strajeru <marius.strajeru@gmail.com>
56
- */
57
- public function getSqlColumn(){
58
- return '`'.$this->getAttribute()->getCode().'` VARCHAR(3) '.$this->getNullSql().' default \'\',';
59
- }
60
- /**
61
- * get html for frontend
62
- * @access public
63
- * @return string
64
- * @author Marius Strajeru <marius.strajeru@gmail.com>
65
- */
66
- public function getFrontendHtml(){
67
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
68
- $ucEntity = ucfirst($entityName);
69
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
70
- return '<?php echo Mage::helper(\''.$module.'\')->__("'.$this->getAttribute()->getLabel().'");?>:<?php echo ($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'()) ? Mage::getModel(\'directory/country\')->load($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'())->getName():Mage::helper(\''.$module.'\')->__(\'None\') ?>'."\n";
71
- }
72
- /**
73
- * get the grid column options
74
- * @access public
75
- * @return string
76
- * @author Marius Strajeru <marius.strajeru@gmail.com>
77
- */
78
- public function getColumnOptions(){
79
- return "'type' => 'country',\n";
80
- }
81
- /**
82
- * get the RSS feed text
83
- * @access public
84
- * @return string
85
- * @author Marius Strajeru <marius.strajeru@gmail.com>
86
- */
87
- public function getRssText(){
88
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
89
- $ucEntity = ucfirst($entityName);
90
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
91
- return ' $description .= Mage::helper(\''.$module.'\')->__("'.$this->getAttribute()->getLabel().'").\':\'.(($item->get'.$this->getAttribute()->getMagicMethodCode().'()) ? Mage::getModel(\'directory/country\')->load($item->get'.$this->getAttribute()->getMagicMethodCode().'())->getName():Mage::helper(\''.$module.'\')->__(\'None\'));';
92
- }
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * country attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Country
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'country';
32
+ /**
33
+ * sql column ddl size
34
+ * @var string
35
+ */
36
+ protected $_sizeDdl = '2';
37
+ /**
38
+ * eav setup input
39
+ */
40
+ protected $_setupInput = 'select';
41
+
42
+
43
+ /**
44
+ * get admin column options
45
+ * @access public
46
+ * @return string
47
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
48
+ */
49
+ public function getAdminColumnOptions() {
50
+ $options = $this->getEol();
51
+ $options .= $this->getPadding(3);
52
+ $options .= "'type'=> 'country',".$this->getEol();
53
+ return $options;
54
+ }
55
+ /**
56
+ * get the type for the form
57
+ * @access public
58
+ * @return string
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function getFormType() {
62
+ return 'select';
63
+ }
64
+
65
+ /**
66
+ * get text for rss
67
+ * @access public
68
+ * @return string
69
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
70
+ */
71
+ public function getRssText() {
72
+ $entityName = $this->getEntity()->getNameSingular(true);
73
+ $ucEntity = ucfirst($entityName);
74
+ $module = $this->getModule()->getLowerModuleName();
75
+ $namespace = $this->getNamespace(true);
76
+ return $this->getPadding(3).'$description .= \'<div>\'.Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'").\':\'.(($item->get'.$this->getAttribute()->getMagicMethodCode().'()) ? Mage::getModel(\'directory/country\')->load($item->get'.$this->getAttribute()->getMagicMethodCode().'())->getName():Mage::helper(\''.$namespace.'_'.$module.'\')->__(\'None\')).\'</div>\';'.$this->getEol();
77
+ }
78
+ /**
79
+ * get html for frontend
80
+ * @access public
81
+ * @return string
82
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
83
+ */
84
+ public function getFrontendHtml() {
85
+ $entityName = $this->getEntity()->getNameSingular(true);
86
+ $ucEntity = ucfirst($entityName);
87
+ $module = $this->getModule()->getLowerModuleName();
88
+ $namespace = $this->getNamespace(true);
89
+ if ($this->getEntity()->getIsEav()){
90
+ return '<?php echo Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'");?>:<?php echo $_'.$this->getEntity()->getNameSingular(true).'->getAttributeText(\''.$this->getAttribute()->getCode().'\');?>'.$this->getEol();
91
+ }
92
+ return '<?php echo Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'");?>:<?php echo ($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'()) ? Mage::getModel(\'directory/country\')->load($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'())->getName():Mage::helper(\''.$namespace.'_'.$module.'\')->__(\'None\') ?>'.$this->getEol();
93
+ }
94
+ /**
95
+ * get source for setup
96
+ * @access public
97
+ * @return string|void
98
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
99
+ */
100
+ public function getSetupSource() {
101
+ $module = $this->getModule()->getLowerModuleName();
102
+ $namespace = $this->getNamespace(true);
103
+ return $namespace.'_'.$module.'/attribute_source_country';
104
+ }
105
+ /**
106
+ * get admin from options
107
+ * @access public
108
+ * @return string
109
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
110
+ */
111
+ public function getFormOptions(){
112
+ $options = parent::getFormOptions();
113
+ $module = $this->getModule()->getLowerModuleName();
114
+ $options .= $this->getPadding(3)."'values'=> Mage::getResourceModel('directory/country_collection')->toOptionArray(),".$this->getEol();
115
+ return $options;
116
+ }
117
+ /**
118
+ * get values for mass action
119
+ * @access public
120
+ * @return string
121
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
122
+ */
123
+ public function getMassActionValues() {
124
+ return 'Mage::getResourceModel(\'directory/country_collection\')->toOptionArray()'.$this->getEol();
125
+ }
126
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Decimal.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
  /**
3
  * Ultimate_ModuleCreator extension
4
  *
@@ -9,36 +9,39 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type decimal
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Decimal extends Ultimate_ModuleCreator_Model_Attribute_Type_Int{
25
- /**
26
- * sql colum ddl type
27
- * @var string
28
- */
29
- protected $_typeDdl = 'TYPE_DECIMAL';
30
- /**
31
- * sql colum ddl size
32
- * @var string
33
- */
34
- protected $_sizeDdl = "'12,4'";
35
- /**
36
- * get the sql column format
37
- * @access public
38
- * @return string
39
- * @author Marius Strajeru <marius.strajeru@gmail.com>
40
- */
41
- public function getSqlColumn(){
42
- return '`'.$this->getAttribute()->getCode().'` decimal(12,4) '.$this->getNullSql().' default \'0\',';
43
- }
44
- }
 
 
1
+ <?php
2
  /**
3
  * Ultimate_ModuleCreator extension
4
  *
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * decimal attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Decimal
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Int {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'decimal';
32
+ /**
33
+ * sql column ddl type
34
+ * @var string
35
+ */
36
+ protected $_typeDdl = 'TYPE_DECIMAL';
37
+ /**
38
+ * sql column ddl size
39
+ * @var string
40
+ */
41
+ protected $_sizeDdl = "'12,4'";
42
+ /**
43
+ * eav setup type
44
+ * @var string
45
+ */
46
+ protected $_setupType = 'decimal';
47
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown.php ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * dropdown attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'dropdown';
32
+ /**
33
+ * dropdown subtype
34
+ * @var Ultimate_ModuleCreator_Model_Abstract
35
+ */
36
+ protected $_subTypeInstance;
37
+ /**
38
+ * sql colum ddl type
39
+ * @var string
40
+ */
41
+ protected $_typeDdl = 'TYPE_INTEGER';
42
+ /**
43
+ * sql colum ddl size
44
+ * @var string
45
+ */
46
+ protected $_sizeDdl = 'null';
47
+ /**
48
+ * eav setup type
49
+ */
50
+ protected $_setupType = 'int';
51
+ /**
52
+ * eav setup input
53
+ */
54
+ protected $_setupInput = 'select';
55
+ /**
56
+ * eav setup source
57
+ * @var string
58
+ */
59
+ protected $_setupSource = 'eav/entity_attribute_source_table';
60
+
61
+ /**
62
+ * get source for setup
63
+ * @access public
64
+ * @return string|void
65
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
66
+ */
67
+ public function getSetupSource() {
68
+ if (!$this->getGenerateSource()){
69
+ return parent::getSetupSource();
70
+ }
71
+ $module = $this->getModule()->getLowerModuleName();
72
+ $namespace = $this->getNamespace(true);
73
+ $entity = $this->getEntity()->getNameSingular(true);
74
+ return $namespace.'_'.$module.'/'.$entity.'_attribute_source_'.$this->getAttribute()->getCodeForFileName();
75
+ }
76
+ /**
77
+ * get admin column options
78
+ * @return string
79
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
80
+ */
81
+ public function getAdminColumnOptions() {
82
+ $options = $this->getEol();
83
+ $module = $this->getModule()->getLowerModuleName();
84
+ $namespace = $this->getNamespace(true);
85
+ $entity = strtolower($this->getAttribute()->getEntity()->getNameSingular());
86
+ $attr = $this->getAttribute()->getCode();
87
+ $options .= $this->getPadding(3)."'type' => 'options',".$this->getEol();
88
+ if ($this->getAttribute()->getEntity()->getIsEav()) {
89
+ $options .= $this->getPadding(3)."'options' => Mage::helper('".$namespace.'_'.$module."')->convertOptions(Mage::getModel('eav/config')->getAttribute('".$namespace.'_'.$module.'_'.$entity."', '".$attr."')->getSource()->getAllOptions(false))".$this->getEol();
90
+ }
91
+ else {
92
+ $options .= $this->getPadding(3)."'options' => Mage::helper('".$namespace.'_'.$module."')->convertOptions(Mage::getModel('".$namespace.'_'.$module.'/'.$entity."_attribute_source_".$this->getAttribute()->getCodeForFileName(false)."')->getAllOptions(false))".$this->getEol();
93
+ }
94
+ return $options;
95
+ }
96
+ /**
97
+ * get the type for the form
98
+ * @access public
99
+ * @return string
100
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
101
+ */
102
+ public function getFormType(){
103
+ return 'select';
104
+ }
105
+ /**
106
+ * get text for rss
107
+ * @access public
108
+ * @return string
109
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
110
+ */
111
+ public function getRssText(){
112
+ $entityName = $this->getEntity()->getNameSingular(true);
113
+ $ucEntity = ucfirst($entityName);
114
+ $module = $this->getModule()->getLowerModuleName();
115
+ $namespace = $this->getNamespace(true);
116
+ $content = '';
117
+ if ($this->getAttribute()->getEntity()->getIsEav()){
118
+ return $this->getPadding(3).'$description .= \'<div>\'.Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'").\': \'.$item->getAttributeText(\''.$this->getAttribute()->getCode().'\').\'</div>\';'.$this->getEol();
119
+ }
120
+ else {
121
+ $attributeFile = $this->getAttribute()->getCodeForFileName(false);
122
+ $code = $this->getAttribute()->getMagicMethodCode();
123
+ return $this->getPadding(3).'$description .= \'<div>\'.Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'").\': \'.Mage::getSingleton(\''.$namespace.'_'.$module.'/'.$entityName.'_attribute_source_'.$attributeFile.'\')->getOptionText($item->get'.$code.'()).\'</div>\';'.$this->getEol();
124
+ }
125
+ }
126
+ /**
127
+ * check if source needs to be generated
128
+ * @access public
129
+ * @return string
130
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
131
+ */
132
+ public function getGenerateSource(){
133
+ return $this->getSubTypeInstance()->getGenerateSource();
134
+ }
135
+ /**
136
+ * get subtype instance
137
+ * @access public
138
+ * @return Ultimate_ModuleCreator_Model_Attribute_Dropdown_Abstract
139
+ * @throws Ultimate_ModuleCreator_Exception
140
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
141
+ */
142
+ public function getSubTypeInstance(){
143
+ if (!$this->_subTypeInstance){
144
+ $type = $this->getAttribute()->getOptionsSource();
145
+ try{
146
+ $types = Mage::helper('modulecreator')->getDropdownSubtypes(false);
147
+ $instanceModel = (string)$types->$type->type_model;
148
+ $this->_subTypeInstance = Mage::getModel($instanceModel);
149
+ $this->_subTypeInstance->setTypeAttribute($this);
150
+ }
151
+ catch (Exception $e){
152
+ throw new Ultimate_ModuleCreator_Exception("Invalid dropdown subtype: ". $type);
153
+ }
154
+ }
155
+ return $this->_subTypeInstance;
156
+ }
157
+ /**
158
+ * get additional setup values
159
+ * @access public
160
+ * @return string
161
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
162
+ */
163
+ public function getAdditionalSetup(){
164
+ return $this->getSubTypeInstance()->getAdditionalSetup();
165
+ }
166
+ /**
167
+ * get html for frontend
168
+ * @access public
169
+ * @return string
170
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
171
+ */
172
+ public function getFrontendHtml() {
173
+ $entityName = $this->getEntity()->getNameSingular(true);
174
+ $ucEntity = ucfirst($entityName);
175
+ $module = $this->getModule()->getLowerModuleName();
176
+ $namespace = $this->getNamespace(true);
177
+ if ($this->getAttribute()->getEntity()->getIsEav()){
178
+ return '<?php echo Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'");?>:<?php echo $_'.$entityName.'->getAttributeText(\''.$this->getAttribute()->getCode().'\');?>'.$this->getEol();
179
+ }
180
+ else {
181
+ $attributeFile = $this->getAttribute()->getCodeForFileName(false);
182
+ $code = $this->getAttribute()->getMagicMethodCode();
183
+ return '<?php echo Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'");?>:<?php echo Mage::getSingleton(\''.$namespace.'_'.$module.'/'.$entityName.'_attribute_source_'.$attributeFile.'\')->getOptionText($_'.$entityName.'->get'.$code.'())'.';?>'.$this->getEol();
184
+ }
185
+ }
186
+ /**
187
+ * get attribute options for source model
188
+ * @access public
189
+ * @return string
190
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
191
+ */
192
+ public function getAttributeOptions(){
193
+ return $this->getSubTypeInstance()->getAttributeOptions();
194
+ }
195
+ /**
196
+ * get the options for form input
197
+ * @access public
198
+ * @return string
199
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
200
+ */
201
+ public function getFormOptions(){
202
+ $options = parent::getFormOptions();
203
+ $padding = $this->getPadding(3);
204
+ $tab = $this->getPadding();
205
+ $eol = $this->getEol();
206
+ $module = $this->getModule()->getLowerModuleName();
207
+ $entity = $this->getEntity()->getNameSingular(true);
208
+ $namespace = $this->getNamespace(true);
209
+ $flag = $this->getOptionsFlag();
210
+ $options .= $padding."'values'=> Mage::getModel('".$namespace.'_'.$module.'/'.$entity."_attribute_source_".$this->getAttribute()->getCodeForFileName(false)."')->getAllOptions(".$this->getOptionsFlag()."),".$this->getEol();
211
+ return $options;
212
+ }
213
+
214
+ /**
215
+ * check if options should be returned with empty
216
+ * @access public
217
+ * @return string
218
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
219
+ */
220
+ public function getOptionsFlag() {
221
+ return 'true';
222
+ }
223
+ /**
224
+ * get the setup type of the dropdown
225
+ * @access public
226
+ * @return string|void
227
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
228
+ */
229
+ public function getSetupType(){
230
+ $setupType = $this->getSubTypeInstance()->getSetupType();
231
+ if (empty($setupType)) {
232
+ return parent::getSetupType();
233
+ }
234
+ return $setupType;
235
+ }
236
+ /**
237
+ * get the setup type of the dropdown
238
+ * @access public
239
+ * @return string|void
240
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
241
+ */
242
+ public function getTypeDdl(){
243
+ $setupType = $this->getSubTypeInstance()->getTypeDdl();
244
+ if (empty($setupType)) {
245
+ return parent::getTypeDdl();
246
+ }
247
+ return $setupType;
248
+ }
249
+ /**
250
+ * get column ddl size
251
+ * @access public
252
+ * @return string
253
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
254
+ */
255
+ public function getSizeDdl() {
256
+ $size = $this->getSubTypeInstance()->getSizeDdl();
257
+ if (empty($size)) {
258
+ return parent::getSizeDdl();
259
+ }
260
+ return $size;
261
+ }
262
+ /**
263
+ * get values for mass action
264
+ * @access public
265
+ * @return string
266
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
267
+ */
268
+ public function getMassActionValues() {
269
+ $module = $this->getModule()->getLowerModuleName();
270
+ $entity = $this->getEntity()->getNameSingular(true);
271
+ $namespace = $this->getNamespace(true);
272
+ if ($this->getEntity()->getIsEav()) {
273
+ return "Mage::getModel('eav/config')->getAttribute('".$namespace.'_'.$module."_".$entity."', '".$this->getAttribute()->getCode()."')->getSource()->getAllOptions(".$this->getOptionsFlag()."),".$this->getEol();
274
+ }
275
+ else {
276
+ return "Mage::getModel('".$namespace.'_'.$module.'/'.$entity."_attribute_source_".$this->getAttribute()->getCodeForFileName(false)."')->getAllOptions(".$this->getOptionsFlag()."),".$this->getEol();
277
+ }
278
+ }
279
+
280
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Abstract.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * abstract attribute dropdown type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract
26
+ extends Ultimate_ModuleCreator_Model_Abstract {
27
+ /**
28
+ * type attribute
29
+ * @var Ultimate_ModuleCreator_Model_Attribute_Type_Decimal
30
+ */
31
+ protected $_typeAttribute;
32
+ /**
33
+ * check if source needs to be generated
34
+ * @access public
35
+ * @return string
36
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
37
+ */
38
+ public function getGenerateSource(){
39
+ return true;
40
+ }
41
+
42
+ /**
43
+ * type attribute setter
44
+ * @access public
45
+ * @param Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown $attributeType
46
+ * @return $this
47
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
48
+ */
49
+ public function setTypeAttribute(Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown $attributeType){
50
+ $this->_typeAttribute = $attributeType;
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * type attribute getter
56
+ * @access public
57
+ * @return Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown
58
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
59
+ */
60
+ public function getTypeAttribute(){
61
+ return $this->_typeAttribute;
62
+ }
63
+ /**
64
+ * get additional setup values
65
+ * @access public
66
+ * @return string
67
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
68
+ */
69
+ public function getAdditionalSetup(){
70
+ return '';
71
+ }
72
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Category.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * category attribute dropdown type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Category
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Product {
27
+ /**
28
+ * entity code for source
29
+ * @var string
30
+ */
31
+ protected $_entityCode = 'catalog_category';
32
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Custom.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * custom attribute dropdown type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Custom
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract {
27
+ /**
28
+ * check if source needs to be generated
29
+ * @access public
30
+ * @return string
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function getGenerateSource(){
34
+ return $this->getTypeAttribute()->getAttribute()->getEntity()->getIsFlat();
35
+ }
36
+ /**
37
+ * get additional setup values
38
+ * @access public
39
+ * @return string
40
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
41
+ */
42
+ public function getAdditionalSetup(){
43
+ $content = '';
44
+ if ($this->getTypeAttribute()->getAttribute()->getEntity()->getIsEav()){
45
+ $padding = $this->getPadding(6);
46
+ $tab = $this->getPadding();
47
+ $eol = $this->getEol();
48
+ if ($this->getTypeAttribute()->getAttribute()->getOptions()) {
49
+ $content .= $padding."'option' =>".$eol;
50
+ $content .= $padding.$tab."array (".$eol;
51
+ $content .= $padding.$tab.$tab."'values' =>".$eol;
52
+ $content .= $padding.$tab.$tab.$tab."array (".$eol;
53
+ foreach ($this->getTypeAttribute()->getAttribute()->getOptions(true) as $option) {
54
+ $content .= $padding.$tab.$tab.$tab.$tab."'".$option."',".$eol;
55
+ }
56
+ $content .= $padding.$tab.$tab.$tab."),".$eol;
57
+ $content .= $padding.$tab.$tab."),".$eol;
58
+ }
59
+ }
60
+ return $content;
61
+ }
62
+ /**
63
+ * get attribute options for source model
64
+ * @access public
65
+ * @return string
66
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
67
+ */
68
+ public function getAttributeOptions(){
69
+ $content = '';
70
+ $padding = $this->getPadding(2);
71
+ $tab = $this->getPadding();
72
+ $eol = $this->getEol();
73
+ $module = $this->getTypeAttribute()->getAttribute()->getEntity()->getModule()->getLowerModuleName();
74
+ $namespace = $this->getTypeAttribute()->getAttribute()->getEntity()->getModule()->getNamespace(true);
75
+ if ($this->getTypeAttribute()->getAttribute()->getOptions()) {
76
+ $content = $padding.'$options = array('.$eol;
77
+ foreach ($this->getTypeAttribute()->getAttribute()->getOptions(true) as $index=>$option) {
78
+ $content .= $padding.$tab.'array('.$eol;
79
+ $content .= $padding.$tab.$tab."'label' => Mage::helper('".$namespace.'_'.$module."')->__('".$option."'),".$eol;
80
+ $content .= $padding.$tab.$tab."'value' => ".($index+1).$eol;
81
+ $content .= $padding.$tab.'),'.$eol;
82
+ }
83
+ $content .= $padding.");".$eol;
84
+ $content .= $padding.'if ($withEmpty) {'.$eol;
85
+ $content .= $padding.$tab.'array_unshift($options, array(\'label\'=>\'\', \'value\'=>\'\'));'.$eol;
86
+ $content .= $padding.'}'.$eol;
87
+ $content .= $padding.'return $options;'.$eol;
88
+ }
89
+ else {
90
+ $content = $padding.'return array();';
91
+ }
92
+ return $content;
93
+ }
94
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Customer.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * customer attribute dropdown type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Customer
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Product {
27
+ /**
28
+ * entity code for source
29
+ * @var string
30
+ */
31
+ protected $_entityCode = 'customer';
32
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Product.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * product attribute dropdown type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Product
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract {
27
+ /**
28
+ * entity code for source
29
+ * @var string
30
+ */
31
+ protected $_entityCode = 'catalog_product';
32
+ /**
33
+ * entity attribute
34
+ * @var string
35
+ */
36
+ protected $_entityAttribute = null;
37
+ /**
38
+ * get attribute options for source model
39
+ * @access public
40
+ * @return string
41
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
42
+ */
43
+ public function getAttributeOptions(){
44
+ $content = '';
45
+ $padding = $this->getPadding(2);
46
+ $tab = $this->getPadding();
47
+ $eol = $this->getEol();
48
+ $module = $this->getTypeAttribute()->getAttribute()->getEntity()->getModule()->getLowerModuleName();
49
+ $attrCode = $this->getTypeAttribute()->getAttribute()->getOptionsSourceAttribute();
50
+ $content .= $padding.'$'."source = Mage::getModel('eav/config')->getAttribute('".$this->getEntityCode()."', '".$attrCode."');".$eol;
51
+ $content .= $padding.'return $source->getSource()->getAllOptions($withEmpty, $defaultValues);';
52
+ return $content;
53
+ }
54
+
55
+ /**
56
+ * get entity code
57
+ * @access public
58
+ * @return string
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function getEntityCode(){
62
+ return $this->_entityCode;
63
+ }
64
+ /**
65
+ * get attribute setup type
66
+ * @access public
67
+ * @return string
68
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
69
+ */
70
+ public function getSetupType(){
71
+ $attrCode = $this->getTypeAttribute()->getAttribute()->getOptionsSourceAttribute();
72
+ $productAttribute = Mage::getModel('eav/config')->getAttribute($this->getEntityCode(), $attrCode);
73
+ Mage::log($attrCode);
74
+ Mage::log($productAttribute);
75
+ if ($productAttribute->getId()){
76
+ $type = $productAttribute->getBackendType();
77
+ if ($type == 'static'){
78
+ return false;
79
+ }
80
+ return $type;
81
+ }
82
+ return false;
83
+ }
84
+ /**
85
+ * get attribute setup type
86
+ * @access public
87
+ * @return string
88
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
89
+ */
90
+ public function getTypeDdl(){
91
+ $entityAttribute = $this->_getEntityAttribute();
92
+ switch($entityAttribute->getBackendType()){
93
+ case 'int':
94
+ return 'TYPE_INTEGER';
95
+ break;
96
+ case 'varchar':
97
+ return 'TYPE_TEXT';
98
+ break;
99
+ case 'text':
100
+ return 'TYPE_TEXT';
101
+ case 'datetime':
102
+ return 'TYPE_DATETIME';
103
+ break;
104
+ case 'decimal':
105
+ return 'TYPE_DECIMAL';
106
+ break;
107
+ default:
108
+ return false;
109
+ break;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * get attribute setup type
115
+ * @access public
116
+ * @return string
117
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
118
+ */
119
+ public function getTypeSize(){
120
+ $entityAttribute = $this->_getEntityAttribute();
121
+ switch($entityAttribute->getBackendType()){
122
+ case 'int':
123
+ return 'null';
124
+ break;
125
+ case 'varchar':
126
+ return '255';
127
+ break;
128
+ case 'text':
129
+ return "'64k'";
130
+ break;
131
+ case 'datetime':
132
+ return "255";
133
+ break;
134
+ case 'decimal':
135
+ return "'12,4'";
136
+ break;
137
+ default:
138
+ return false;
139
+ break;
140
+ }
141
+ }
142
+
143
+ /**
144
+ * get the source model attribute
145
+ * @access public
146
+ * @return null|string
147
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
148
+ */
149
+ protected function _getEntityAttribute(){
150
+ if (is_null($this->_entityAttribute)){
151
+ $attrCode = $this->getTypeAttribute()->getAttribute()->getOptionsSourceAttribute();
152
+ $productAttribute = Mage::getModel('eav/config')->getAttribute($this->getEntityCode(), $attrCode);
153
+ $this->_entityAttribute = $productAttribute;
154
+ }
155
+ return $this->_entityAttribute;
156
+ }
157
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/File.php CHANGED
@@ -9,81 +9,113 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type file
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_File extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract{
25
- /**
26
- * get the type for the form
27
- * @access public
28
- * @return string
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function getFormType(){
32
- return 'file';
33
- }
34
- /**
35
- * check if an attribute is in the admin grid
36
- * @access public
37
- * @return bool
38
- * @author Marius Strajeru <marius.strajeru@gmail.com>
39
- */
40
- public function getAdminGrid(){
41
- return false;
42
- }
43
- /**
44
- * check if an attribute is required
45
- * @access public
46
- * @return bool
47
- * @author Marius Strajeru <marius.strajeru@gmail.com>
48
- */
49
- public function getRequired(){
50
- return false;
51
- }
52
- /**
53
- * get the html for frontend
54
- * @access public
55
- * @return string
56
- * @author Marius Strajeru <marius.strajeru@gmail.com>
57
- */
58
- public function getFrontendHtml(){
59
- $content = '';
60
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
61
- $ucEntity = ucfirst($entityName);
62
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
63
- $content .= ' <?php if ($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'()) :?>'."\n";
64
- $content .= ' <a href="<?php echo Mage::helper(\''.$module.'/'.$entityName.'\')->getFileBaseUrl().$_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'();?>">'."\n";
65
- $content .= ' '."\t".'<span><?php echo basename($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'())?></span>'."\n";
66
- $content .= ' </a>'."\n\t";
67
- $content .= ' <?php endif;?>'."\n";
68
- return $content;
69
- }
70
- /**
71
- * get the text for RSS
72
- * @access public
73
- * @return string
74
- * @author Marius Strajeru <marius.strajeru@gmail.com>
75
- */
76
- public function getRssText(){
77
- $content = '';
78
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
79
- $ucEntity = ucfirst($entityName);
80
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
81
- $content .= ' if ($item->get'.$this->getAttribute()->getMagicMethodCode().'()) {'."\n";
82
- $content .= ' $description .= \'<a href="\'.Mage::helper(\''.$module.'/'.$entityName.'\')->getFileBaseUrl().$item->get'.$this->getAttribute()->getMagicMethodCode().'().\'">\';'."\n";
83
- $content .= ' $description .= \' <span>\'. basename($item->get'.$this->getAttribute()->getMagicMethodCode().'()).\'</span>\';'."\n";
84
- $content .= ' $description .= \'</a>\';'."\n";
85
- $content .= ' }';
86
- return $content;
87
-
88
- }
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * file attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_File
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'file';
32
+ /**
33
+ * eav setup input
34
+ * @var string
35
+ */
36
+ protected $_setupInput = 'file';
37
+ /**
38
+ * don't show in admin grid
39
+ * @access public
40
+ * @return bool
41
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
42
+ */
43
+ public function getAdminGrid() {
44
+ return false;
45
+ }
46
+ /**
47
+ * check if attribute is required
48
+ * @access public
49
+ * @return mixed
50
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
51
+ */
52
+ public function getRequired(){
53
+ return false;
54
+ }
55
+ /**
56
+ * get the type for the form
57
+ * @access public
58
+ * @return string
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function getFormType() {
62
+ return 'file';
63
+ }
64
+ /**
65
+ * get text for rss
66
+ * @access public
67
+ * @return string
68
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
69
+ */
70
+ public function getRssText(){
71
+ $content = '';
72
+ $entityName = $this->getEntity()->getNameSingular(true);
73
+ $ucEntity = ucfirst($entityName);
74
+ $eol = $this->getEol();
75
+ $module = $this->getModule()->getLowerModuleName();
76
+ $namespace = $this->getNamespace(true);
77
+ $content .= $this->getPadding(3).'if ($item->get'.$this->getAttribute()->getMagicMethodCode().'()) {'.$eol;
78
+ $content .= $this->getPadding(4).'$description .= \'<div>\';'.$eol;
79
+ $content .= $this->getPadding(4).'$description .= Mage::helper(\''.$namespace.'_'.$module.'\')->__(\''.$this->getAttribute()->getLabel().'\');'.$eol;
80
+ $content .= $this->getPadding(4).'$description .= \' <a href="\'.Mage::helper(\''.$namespace.'_'.$module.'/'.$entityName.'\')->getFileBaseUrl().$item->get'.$this->getAttribute()->getMagicMethodCode().'().\'">\';'.$eol;
81
+ $content .= $this->getPadding(4).'$description .= \' <span>\'. basename($item->get'.$this->getAttribute()->getMagicMethodCode().'()).\'</span>\';'.$eol;
82
+ $content .= $this->getPadding(4).'$description .= \' </a>\';'.$eol;
83
+ $content .= $this->getPadding(4).'$description .= \'</div>\';'.$eol;
84
+ $content .= $this->getPadding(3).'}'.$eol;
85
+
86
+ return $content;
87
+ }
88
+
89
+ /**
90
+ * get the html for frontend
91
+ * @access public
92
+ * @return string
93
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
94
+ */
95
+ public function getFrontendHtml() {
96
+ $content = '';
97
+ $eol = $this->getEol();
98
+ $entityName = $this->getAttribute()->getEntity()->getNameSingular(true);
99
+ $ucEntity = ucfirst($entityName);
100
+ $module = $this->getModule()->getLowerModuleName();
101
+ $namespace = $this->getNamespace(true);
102
+ $content .= $this->getPadding().'<?php if ($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'()) :?>'.$eol;
103
+ $content .= $this->getPadding(2).'<a href="<?php echo Mage::helper(\''.$namespace.'_'.$module.'/'.$entityName.'\')->getFileBaseUrl().$_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'();?>">'.$eol;
104
+ $content .= $this->getPadding(3).'<span><?php echo basename($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'())?></span>'.$eol;
105
+ $content .= $this->getPadding(2).'</a>'.$eol;
106
+ $content .= $this->getPadding().'<?php endif;?>'.$eol;
107
+ return $content;
108
+ }
109
+ /**
110
+ * get the setup backend type
111
+ * @access public
112
+ * @return string
113
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
114
+ */
115
+ public function getSetupBackend(){
116
+ $attribute = $this->getAttribute();
117
+ $entity = $attribute->getEntity();
118
+ $module = $this->getModule();
119
+ return $this->getNamespace(true).'_'.$module->getLowerModuleName().'/'.$entity->getNameSingular(true).'_attribute_backend_file';
120
+ }
121
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Image.php CHANGED
@@ -9,77 +9,107 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type image
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Image extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract{
25
- /**
26
- * get the type for the form
27
- * @access public
28
- * @return string
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function getFormType(){
32
- return 'image';
33
- }
34
- /**
35
- * check if an attribute is in the admin grid
36
- * @access public
37
- * @return bool
38
- * @author Marius Strajeru <marius.strajeru@gmail.com>
39
- */
40
- public function getAdminGrid(){
41
- return false;
42
- }
43
- /**
44
- * check if an attribute is required
45
- * @access public
46
- * @return bool
47
- * @author Marius Strajeru <marius.strajeru@gmail.com>
48
- */
49
- public function getRequired(){
50
- return false;
51
- }
52
- /**
53
- * get the html for frontend
54
- * @access public
55
- * @return string
56
- * @author Marius Strajeru <marius.strajeru@gmail.com>
57
- */
58
- public function getFrontendHtml(){
59
- $content = '';
60
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
61
- $ucEntity = ucfirst($entityName);
62
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
63
- $content .= '<?php if ($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'()) :?>'."\n";
64
- $content .= ' <img src="<?php echo Mage::helper(\''.$module.'/'.$entityName.'_image\')->init($_'.$entityName.', \''.$this->getAttribute()->getCode().'\')->resize(75);?>" alt="<?php echo $this->htmlEscape($_'.$entityName.'->get'.$this->getAttribute()->getEntity()->getNameAttributeMagicCode().'());?>" />'."\n\t";
65
- $content .= ' <?php endif;?>'."\n";
66
- return $content;
67
- }
68
- /**
69
- * get the text for RSS
70
- * @access public
71
- * @return string
72
- * @author Marius Strajeru <marius.strajeru@gmail.com>
73
- */
74
- public function getRssText(){
75
- $content = '';
76
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
77
- $ucEntity = ucfirst($entityName);
78
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
79
- $content .= ' if ($item->get'.$this->getAttribute()->getMagicMethodCode().'()) {'."\n";
80
- $content .= ' $description .= \'<img src="\'.Mage::helper(\''.$module.'/'.$entityName.'_image\')->init($item, \''.$this->getAttribute()->getCode().'\')->resize(75).\'" alt="\'.$this->htmlEscape($item->get'.$this->getAttribute()->getEntity()->getNameAttributeMagicCode().'()).\'" />\';'."\n";
81
- $content .= ' }';
82
- return $content;
83
- }
84
-
85
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * image attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Image
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'image';
32
+ /**
33
+ * eav setup input
34
+ * @var string
35
+ */
36
+ protected $_setupInput = 'image';
37
+ /**
38
+ * don't show in admin grid
39
+ * @access public
40
+ * @return bool
41
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
42
+ */
43
+ public function getAdminGrid() {
44
+ return false;
45
+ }
46
+ /**
47
+ * check if attribute is required
48
+ * @access public
49
+ * @return mixed
50
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
51
+ */
52
+ public function getRequired(){
53
+ return false;
54
+ }
55
+ /**
56
+ * get the type for the form
57
+ * @access public
58
+ * @return string
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function getFormType() {
62
+ return 'image';
63
+ }
64
+ /**
65
+ * get text for rss
66
+ * @access public
67
+ * @return string
68
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
69
+ */
70
+ public function getRssText() {
71
+ $eol = $this->getEol();
72
+ $content = '';
73
+ $entityName = $this->getEntity()->getNameSingular(true);
74
+ $ucEntity = ucfirst($entityName);
75
+ $module = $this->getModule()->getLowerModuleName();
76
+ $namespace = $this->getNamespace(true);
77
+ $content .= $this->getPadding(3).'if ($item->get'.$this->getAttribute()->getMagicMethodCode().'()) {'.$eol;
78
+ $content .= $this->getPadding(4).'$description .= \'<div>\';'.$eol;
79
+ $content .= $this->getPadding(4).'$description .= Mage::helper(\''.$namespace.'_'.$module.'\')->__(\''.$this->getAttribute()->getLabel().'\');'.$eol;
80
+ $content .= $this->getPadding(4).'$description .= \'<img src="\'.Mage::helper(\''.$namespace.'_'.$module.'/'.$entityName.'_image\')->init($item, \''.$this->getAttribute()->getCode().'\')->resize(75).\'" alt="\'.$this->htmlEscape($item->get'.$this->getEntity()->getNameAttributeMagicCode().'()).\'" />\';'.$eol;
81
+ $content .= $this->getPadding(4).'$description .= \'</div>\';'.$eol;
82
+ $content .= $this->getPadding(3).'}'.$eol;
83
+ return $content;
84
+ }
85
+ /**
86
+ * get the html for frontend
87
+ * @access public
88
+ * @return string
89
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
90
+ */
91
+ public function getFrontendHtml() {
92
+ $eol = $this->getEol();
93
+ $content = '';
94
+ $entityName = $this->getEntity()->getNameSingular(true);
95
+ $ucEntity = ucfirst($entityName);
96
+ $module = $this->getModule()->getLowerModuleName();
97
+ $namespace = $this->getNamespace(true);
98
+ $content .= '<?php if ($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'()) :?>'.$eol;
99
+ $content .= $this->getHelper()->getPadding().'<img src="<?php echo Mage::helper(\''.$namespace.'_'.$module.'/'.$entityName.'_image\')->init($_'.$entityName.', \''.$this->getAttribute()->getCode().'\')->resize(75);?>" alt="<?php echo $this->htmlEscape($_'.$entityName.'->get'.$this->getAttribute()->getEntity()->getNameAttributeMagicCode().'());?>" />'.$eol;
100
+ $content .= '<?php endif;?>'.$eol;
101
+ return $content;
102
+ }
103
+ /**
104
+ * get the setup backend type
105
+ * @access public
106
+ * @return string
107
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
108
+ */
109
+ public function getSetupBackend(){
110
+ $attribute = $this->getAttribute();
111
+ $entity = $attribute->getEntity();
112
+ $module = $entity->getModule();
113
+ return $this->getNamespace(true).'_'.$module->getLowerModuleName().'/'.$entity->getNameSingular(true).'_attribute_backend_image';
114
+ }
115
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Int.php CHANGED
@@ -9,36 +9,50 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type int
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Int extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract{
25
- /**
26
- * sql colum ddl type
27
- * @var string
28
- */
29
- protected $_typeDdl = 'TYPE_INTEGER';
30
- /**
31
- * sql colum ddl size
32
- * @var string
33
- */
34
- protected $_sizeDdl = 'null';
35
- /**
36
- * get the sql column
37
- * @access public
38
- * @return string
39
- * @author Marius Strajeru <marius.strajeru@gmail.com>
40
- */
41
- public function getSqlColumn(){
42
- return '`'.$this->getAttribute()->getCode().'` int(10) '.$this->getNullSql().' default \'0\',';
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * int attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Int
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'int';
32
+ /**
33
+ * sql colum ddl type
34
+ * @var string
35
+ */
36
+ protected $_typeDdl = 'TYPE_INTEGER';
37
+ /**
38
+ * sql colum ddl size
39
+ * @var string
40
+ */
41
+ protected $_sizeDdl = 'null';
42
+ /**
43
+ * eav setup type
44
+ */
45
+ protected $_setupType = 'int';
46
+ /**
47
+ * get admin column options
48
+ * @access public
49
+ * @return string
50
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
51
+ */
52
+ public function getAdminColumnOptions() {
53
+ $options = $this->getEol();
54
+ $options .= $this->getPadding(3);
55
+ $options .= "'type'=> 'number',".$this->getEol();
56
+ return $options;
57
+ }
58
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Multiselect.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * multiselect attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Multiselect
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'multiselect';
32
+ /**
33
+ * sql column ddl type
34
+ * @var string
35
+ */
36
+ protected $_typeDdl = 'TYPE_TEXT';
37
+ /**
38
+ * sql column ddl size
39
+ * @var string
40
+ */
41
+ protected $_sizeDdl = "'64k'";
42
+ /**
43
+ * eav setup input
44
+ */
45
+ protected $_setupInput = 'multiselect';
46
+ /**
47
+ * eav setup type
48
+ */
49
+ protected $_setupType = 'text';
50
+ /**
51
+ * backend setup type
52
+ * @var string
53
+ */
54
+ protected $_setupBackend = 'eav/entity_attribute_backend_array';
55
+ /**
56
+ * don't show in admin grid
57
+ * @access public
58
+ * @return bool
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function getAdminGrid(){
62
+ return false;
63
+ }
64
+ /**
65
+ * get the type for the form
66
+ * @access public
67
+ * @return string
68
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
69
+ */
70
+ public function getFormType(){
71
+ return 'multiselect';
72
+ }
73
+ /**
74
+ * check if attribute is multiple select
75
+ * @access public
76
+ * @return bool
77
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
78
+ */
79
+ public function getIsMultipleSelect(){
80
+ return true;
81
+ }
82
+ /**
83
+ * get the setup type of the dropdown
84
+ * @access public
85
+ * @return string|void
86
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
87
+ */
88
+ public function getSetupType(){
89
+ return $this->_setupType;
90
+ }
91
+ /**
92
+ * get attribute setup type
93
+ * @access public
94
+ * @return string
95
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
96
+ */
97
+ public function getTypeDdl(){
98
+ return $this->_typeDdl;
99
+ }
100
+ /**
101
+ * check if options should be returned with empty
102
+ * @access public
103
+ * @return string
104
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
105
+ */
106
+ public function getOptionsFlag() {
107
+ return 'false';
108
+ }
109
+ /**
110
+ * get values for mass action
111
+ * @access public
112
+ * @return string
113
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
114
+ */
115
+ public function getMassActionValues() {
116
+ return '';
117
+ }
118
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Text.php CHANGED
@@ -9,18 +9,36 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type text
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Text extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract{
25
-
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * text attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Text
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'text';
32
+ /**
33
+ * get admin column options
34
+ * @access public
35
+ * @return string
36
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
37
+ */
38
+ public function getAdminColumnOptions() {
39
+ $options = $this->getEol();
40
+ $options .= $this->getPadding(3);
41
+ $options .= "'type'=> 'text',".$this->getEol();
42
+ return $options;
43
+ }
44
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Textarea.php CHANGED
@@ -9,76 +9,89 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type textarea
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Textarea extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract{
25
- /**
26
- * sql colum ddl size
27
- * @var string
28
- */
29
- protected $_sizeDdl = "'64k'";
30
- /**
31
- * the textarea attributes are not allowed in the admin grid
32
- * @access public
33
- * @return bool
34
- * @see Ultimate_ModuleCreator_Model_Attribute_Type_Abstract::getAdminGrid()
35
- * @author Marius Strajeru <marius.strajeru@gmail.com>
36
- */
37
- public function getAdminGrid(){
38
- return false;
39
- }
40
- /**
41
- * check if an attribute uses an editor
42
- * @access public
43
- * @return bool
44
- * @author Marius Strajeru <marius.strajeru@gmail.com>
45
- */
46
- public function getEditor(){
47
- return $this->getAttribute()->getData('editor');
48
- }
49
- /**
50
- * get the type for the form
51
- * @access public
52
- * @return string
53
- * @author Marius Strajeru <marius.strajeru@gmail.com>
54
- */
55
- public function getFormType(){
56
- if ($this->getEditor()){
57
- return 'editor';
58
- }
59
- return 'textarea';
60
- }
61
- /**
62
- * get the options for form input
63
- * @access public
64
- * @return string
65
- * @author Marius Strajeru <marius.strajeru@gmail.com>
66
- */
67
- public function getFormOptions(){
68
- $options = '';
69
- if ($this->getEditor() && !$this->getAttribute()->getEntity()->getIsTree()){
70
- $options = self::OPTION_SEPARATOR."'config' => "."$"."wysiwygConfig,\n";
71
- }
72
- $options .= parent::getFormOptions();
73
- return $options;
74
- }
75
- /**
76
- * get the sql column
77
- * @access public
78
- * @return string
79
- * @author Marius Strajeru <marius.strajeru@gmail.com>
80
- */
81
- public function getSqlColumn(){
82
- return '`'.$this->getAttribute()->getCode().'` TEXT '.$this->getNullSql().' default \'\',';
83
- }
84
- }
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * textarea attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Textarea
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'textarea';
32
+ /**
33
+ * sql column ddl type
34
+ * @var string
35
+ */
36
+ protected $_typeDdl = 'TYPE_TEXT';
37
+ /**
38
+ * sql column ddl size
39
+ * @var string
40
+ */
41
+ protected $_sizeDdl = "'64k'";
42
+ /**
43
+ * eav setup type
44
+ */
45
+ protected $_setupType = 'text';
46
+ /**
47
+ * eav setup input
48
+ * @var string
49
+ */
50
+ protected $_setupInput = 'textarea';
51
+
52
+ /**
53
+ * don't show in admin grid
54
+ * @access public
55
+ * @return bool
56
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
57
+ */
58
+ public function getAdminGrid() {
59
+ return false;
60
+ }
61
+ /**
62
+ * get the type for the form
63
+ * @access public
64
+ * @return string
65
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
66
+ */
67
+ public function getFormType() {
68
+ if ($this->getAttribute()->getEditor()) {
69
+ return 'editor';
70
+ }
71
+ return 'textarea';
72
+ }
73
+ /**
74
+ * can use editor
75
+ * @access public
76
+ * @return bool
77
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
78
+ */
79
+ public function getEditor() {
80
+ return $this->getAttribute()->getData('editor');
81
+ }
82
+ /**
83
+ * get the options for form input
84
+ * @access public
85
+ * @return string
86
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
87
+ */
88
+ public function getFormOptions(){
89
+ $options = '';
90
+ if ($this->getEditor() && !$this->getEntity()->getIsTree()){
91
+ $options = $this->getPadding(3)."'config' => "."$"."wysiwygConfig,".$this->getEol();
92
+ }
93
+ $options .= parent::getFormOptions();
94
+ return $options;
95
+ }
96
+
97
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Timestamp.php CHANGED
@@ -9,74 +9,104 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type timestamp
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Timestamp extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract{
25
- /**
26
- * sql colum ddl type
27
- * @var string
28
- */
29
- protected $_typeDdl = 'TYPE_DATETIME';
30
- /**
31
- * get the type for the form
32
- * @access public
33
- * @return string
34
- * @author Marius Strajeru <marius.strajeru@gmail.com>
35
- */
36
- public function getFormType(){
37
- return 'date';
38
- }
39
- /**
40
- * get sql column
41
- * @access public
42
- * @return string
43
- * @author Marius Strajeru <marius.strajeru@gmail.com>
44
- */
45
- public function getSqlColumn(){
46
- return '`'.$this->getAttribute()->getCode().'` datetime '.$this->getNullSql().' default \'0000-00-00\',';
47
- }
48
- /**
49
- * get the text before the element in the admin form
50
- * @access public
51
- * @return string
52
- * @author Marius Strajeru <marius.strajeru@gmail.com>
53
- */
54
- public function getPreElementText(){
55
- $text = '';
56
- $text .= ' $dateFormatIso = Mage::app()->getLocale()->getDateFormat('."\n";
57
- $text .= ' Mage_Core_Model_Locale::FORMAT_TYPE_SHORT'."\n";
58
- $text .= ' );'."\n";
59
- return $text;
60
- }
61
- /**
62
- * get options for admin form
63
- * @access public
64
- * @return string
65
- * @author Marius Strajeru <marius.strajeru@gmail.com>
66
- */
67
- public function getFormOptions(){
68
- $options = parent::getFormOptions();
69
- $options .= ' \'image\' => $this->getSkinUrl(\'images/grid-cal.gif\'),'."\n";
70
- $options .= ' \'format\' => $dateFormatIso,'."\n";
71
- return $options;
72
- }
73
- /**
74
- * get the grid column options
75
- * @access public
76
- * @return string
77
- * @author Marius Strajeru <marius.strajeru@gmail.com>
78
- */
79
- public function getColumnOptions(){
80
- return "'type' => 'date',"."\n";
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * timestamp attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Timestamp
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'timestamp';
32
+ /**
33
+ * sql column ddl type
34
+ * @var string
35
+ */
36
+ protected $_typeDdl = 'TYPE_DATETIME';
37
+ /**
38
+ * eav setup type
39
+ */
40
+ protected $_setupType = 'datetime';
41
+ /**
42
+ * eav setup input
43
+ * @var string
44
+ */
45
+ protected $_setupInput = 'date';
46
+ /**
47
+ * setup backend
48
+ * @var string
49
+ */
50
+ protected $_setupBackend = 'eav/entity_attribute_backend_datetime';
51
+
52
+ /**
53
+ * get admin column options
54
+ * @access public
55
+ * @return string
56
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
57
+ */
58
+ public function getAdminColumnOptions() {
59
+ $options = $this->getEol();
60
+ $options .= $this->getPadding(3);
61
+ $options .= "'type'=> 'date',".$this->getEol();
62
+ return $options;
63
+ }
64
+ /**
65
+ * get the type for the form
66
+ * @access public
67
+ * @return string
68
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
69
+ */
70
+ public function getFormType() {
71
+ return 'date';
72
+ }
73
+ /**
74
+ * get html for frontend
75
+ * @access public
76
+ * @return string
77
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
78
+ */
79
+ public function getFrontendHtml() {
80
+ $entityName = $this->getEntity()->getNameSingular(true);
81
+ $ucEntity = ucfirst($entityName);
82
+ $module = $this->getModule()->getLowerModuleName();
83
+ $namespace = $this->getNamespace(true);
84
+ return '<?php echo Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'");?>: <?php echo Mage::helper(\'core\')->formatDate($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'(), \'full\');?>'.$this->getEol();
85
+ }
86
+ /**
87
+ * get options for admin form
88
+ * @access public
89
+ * @return string
90
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
91
+ */
92
+ public function getFormOptions(){
93
+ $options = parent::getFormOptions();
94
+ $padding = $this->getPadding(3);
95
+ $eol = $this->getEol();
96
+ $options .= $padding.'\'image\' => $this->getSkinUrl(\'images/grid-cal.gif\'),'.$eol;;
97
+ $options .= $padding.'\'format\' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),'.$eol;
98
+ return $options;
99
+ }
100
+ /**
101
+ * get text for rss
102
+ * @access public
103
+ * @return string
104
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
105
+ */
106
+ public function getRssText() {
107
+ $attribute = $this->getAttribute();
108
+ $module = $this->getModule()->getLowerModuleName();
109
+ $namespace = $this->getNamespace(true);
110
+ return $this->getPadding(3).'$'.'description .= \'<div>\'.Mage::helper(\''.$namespace.'_'.$module.'\')->__(\''.$attribute->getLabel().'\').\': \'.Mage::helper(\'core\')->formatDate($item->get'.$this->getAttribute()->getMagicMethodCode().'(), \'full\').\'</div>\';'.$this->getEol();
111
+ }
112
+ }
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Website.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
- /**
3
- * Ultimate_ModuleCreator extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
8
- * that is bundled with this package in the file LICENSE_UMC.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/mit-license.php
11
- *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * attribute type website
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Website extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract{
25
- /**
26
- * sql colum ddl type
27
- * @var string
28
- */
29
- protected $_typeDdl = 'TYPE_INTEGER';
30
- /**
31
- * sql colum ddl size
32
- * @var string
33
- */
34
- protected $_sizeDdl = 'null';
35
- /**
36
- * get the type for the form
37
- * @access public
38
- * @return string
39
- * @author Marius Strajeru <marius.strajeru@gmail.com>
40
- */
41
- public function getFormType(){
42
- return 'select';
43
- }
44
- /**
45
- * get the options for form input
46
- * @access public
47
- * @return string
48
- * @author Marius Strajeru <marius.strajeru@gmail.com>
49
- */
50
- public function getFormOptions(){
51
- $options = parent::getFormOptions();
52
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
53
- $options .= self::OPTION_SEPARATOR."'values' => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm(),\n";
54
- return $options;
55
- }
56
- /**
57
- * get the sql column
58
- * @access public
59
- * @return string
60
- * @author Marius Strajeru <marius.strajeru@gmail.com>
61
- */
62
- public function getSqlColumn(){
63
- return '`'.$this->getAttribute()->getCode().'` INT(11) '.$this->getNullSql().' default \'0\',';
64
- }
65
- /**
66
- * get html for frontend
67
- * @access public
68
- * @return string
69
- * @author Marius Strajeru <marius.strajeru@gmail.com>
70
- */
71
- public function getFrontendHtml(){
72
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
73
- $ucEntity = ucfirst($entityName);
74
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
75
- return '<?php echo Mage::helper(\''.$module.'\')->__("'.$this->getAttribute()->getLabel().'");?>:<?php echo ($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'()) ? Mage::getModel(\'core/website\')->load($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'())->getName():Mage::helper(\''.$module.'\')->__(\'None\') ?>'."\n";
76
- }
77
- /**
78
- * get the grid column options
79
- * @access public
80
- * @return string
81
- * @author Marius Strajeru <marius.strajeru@gmail.com>
82
- */
83
- public function getColumnOptions(){
84
- $text = '';
85
- $text .= "'type' => 'options',\n";
86
- $text .= self::OPTION_SEPARATOR."'options' => Mage::getResourceSingleton('core/website_collection')->toOptionHash(),\n";
87
- return $text;
88
- }
89
- /**
90
- * get the RSS feed text
91
- * @access public
92
- * @return string
93
- * @author Marius Strajeru <marius.strajeru@gmail.com>
94
- */
95
- public function getRssText(){
96
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
97
- $ucEntity = ucfirst($entityName);
98
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
99
- return ' $description .= Mage::helper(\''.$module.'\')->__("'.$this->getAttribute()->getLabel().'").\':\'.(($item->get'.$this->getAttribute()->getMagicMethodCode().'()) ? Mage::getModel(\'core/website\')->load($item->get'.$this->getAttribute()->getMagicMethodCode().'())->getName():Mage::helper(\''.$module.'\')->__(\'None\'));';
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Yesno.php CHANGED
@@ -9,107 +9,151 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * attribute type yes/no
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Attribute_Type_Yesno extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract{
25
- /**
26
- * sql colum ddl type
27
- * @var string
28
- */
29
- protected $_typeDdl = 'TYPE_INTEGER';
30
- /**
31
- * sql colum ddl size
32
- * @var string
33
- */
34
- protected $_sizeDdl = 'null';
35
- /**
36
- * get the type for the form
37
- * @access public
38
- * @return string
39
- * @author Marius Strajeru <marius.strajeru@gmail.com>
40
- */
41
- public function getFormType(){
42
- return 'select';
43
- }
44
- /**
45
- * get the options for form input
46
- * @access public
47
- * @return string
48
- * @author Marius Strajeru <marius.strajeru@gmail.com>
49
- */
50
- public function getFormOptions(){
51
- $options = parent::getFormOptions();
52
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
53
- $options .= self::OPTION_SEPARATOR."'values'=> array(
54
- array(
55
- 'value' => 1,
56
- 'label' => Mage::helper('".$module."')->__('Yes'),
57
- ),
58
- array(
59
- 'value' => 0,
60
- 'label' => Mage::helper('".$module."')->__('No'),
61
- ),
62
- ),\n";
63
- return $options;
64
- }
65
- /**
66
- * get the sql column
67
- * @access public
68
- * @return string
69
- * @author Marius Strajeru <marius.strajeru@gmail.com>
70
- */
71
- public function getSqlColumn(){
72
- return '`'.$this->getAttribute()->getCode().'` tinyint(1) '.$this->getNullSql().' default \'1\',';
73
- }
74
- /**
75
- * get html for frontend
76
- * @access public
77
- * @return string
78
- * @author Marius Strajeru <marius.strajeru@gmail.com>
79
- */
80
- public function getFrontendHtml(){
81
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
82
- $ucEntity = ucfirst($entityName);
83
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
84
- return '<?php echo Mage::helper(\''.$module.'\')->__("'.$this->getAttribute()->getLabel().'");?>:<?php echo ($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'() == 1)?Mage::helper(\''.$module.'\')->__(\'Yes\'):Mage::helper(\''.$module.'\')->__(\'No\') ?>'."\n";
85
- }
86
- /**
87
- * get the grid column options
88
- * @access public
89
- * @return string
90
- * @author Marius Strajeru <marius.strajeru@gmail.com>
91
- */
92
- public function getColumnOptions(){
93
- $text = '';
94
- $text .= "'type' => 'options',\n";
95
- $text .= self::OPTION_SEPARATOR."'options' => array(\n";
96
- $text .= self::OPTION_SEPARATOR."\t'1' => Mage::helper('".strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName())."')->__('Yes'),\n";
97
- $text .= self::OPTION_SEPARATOR."\t'0' => Mage::helper('".strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName())."')->__('No'),\n";
98
- $text .= self::OPTION_SEPARATOR.")\n";
99
- return $text;
100
- }
101
- /**
102
- * get the RSS feed text
103
- * @access public
104
- * @return string
105
- * @author Marius Strajeru <marius.strajeru@gmail.com>
106
- */
107
- public function getRssText(){
108
- $entityName = strtolower($this->getAttribute()->getEntity()->getNameSingular());
109
- $ucEntity = ucfirst($entityName);
110
- $module = strtolower($this->getAttribute()->getEntity()->getModule()->getModuleName());
111
- return ' $description .= Mage::helper(\''.$module.'\')->__("'.$this->getAttribute()->getLabel().'").\':\'.($item->get'.$this->getAttribute()->getMagicMethodCode().'() == 1) ? Mage::helper(\''.$module.'\')->__(\'Yes\') : Mage::helper(\''.$module.'\')->__(\'No\');';
112
- }
113
-
114
-
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * yes/no attribute type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Attribute_Type_Yesno
26
+ extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract {
27
+ /**
28
+ * type code
29
+ * @var string
30
+ */
31
+ protected $_type = 'yesno';
32
+ /**
33
+ * sql colum ddl type
34
+ * @var string
35
+ */
36
+ protected $_typeDdl = 'TYPE_SMALLINT';
37
+ /**
38
+ * sql colum ddl size
39
+ * @var string
40
+ */
41
+ protected $_sizeDdl = 'null';
42
+ /**
43
+ * eav setup type
44
+ */
45
+ protected $_setupType = 'int';
46
+ /**
47
+ * eav setup input
48
+ */
49
+ protected $_setupInput = 'select';
50
+ /**
51
+ * eav setup source
52
+ */
53
+ protected $_setupSource = 'eav/entity_attribute_source_boolean';
54
+
55
+ /**
56
+ * get admin column options
57
+ * @access public
58
+ * @return string
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function getAdminColumnOptions() {
62
+ $eol = $this->getEol();
63
+ $options = $eol;
64
+ $extension = $this->getModule()->getExtensionName(true);
65
+ $options .= $this->getPadding(3)."'type' => 'options',".$eol;
66
+ $options .= $this->getPadding(3)."'options' => array(".$eol;
67
+ $options .= $this->getPadding(4)."'1' => Mage::helper('".$extension."')->__('Yes'),".$eol;
68
+ $options .= $this->getPadding(4)."'0' => Mage::helper('".$extension."')->__('No'),".$eol;
69
+ $options .= $this->getPadding(3).")".$eol;
70
+ return $options;
71
+ }
72
+ /**
73
+ * get the type for the form
74
+ * @access public
75
+ * @return string
76
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
77
+ */
78
+ public function getFormType() {
79
+ return 'select';
80
+ }
81
+ /**
82
+ * get text for rss
83
+ * @access public
84
+ * @return string
85
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
86
+ */
87
+ public function getRssText() {
88
+ $entityName = $this->getEntity()->getNameSingular(true);
89
+ $ucEntity = ucfirst($entityName);
90
+ $module = $this->getModule()->getLowerModuleName();
91
+ $namespace = $this->getNamespace(true);
92
+ return $this->getPadding(3).'$description .= \'<div>\'.Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'").\':\'.(($item->get'.$this->getAttribute()->getMagicMethodCode().'() == 1) ? Mage::helper(\''.$namespace.'_'.$module.'\')->__(\'Yes\') : Mage::helper(\''.$namespace.'_'.$module.'\')->__(\'No\')).\'</div>\';'.$this->getEol();
93
+ }
94
+ /**
95
+ * get html for frontend
96
+ * @access public
97
+ * @return string
98
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
99
+ */
100
+ public function getFrontendHtml() {
101
+ $entityName = $this->getEntity()->getNameSingular(true);
102
+ $ucEntity = ucfirst($entityName);
103
+ $module = $this->getModule()->getLowerModuleName();
104
+ $namespace = $this->getNamespace(true);
105
+ return '<?php echo Mage::helper(\''.$namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel().'");?>:<?php echo ($_'.$entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'() == 1)?Mage::helper(\''.$module.'\')->__(\'Yes\'):Mage::helper(\''.$module.'\')->__(\'No\') ?>'.$this->getEol();
106
+ }
107
+ /**
108
+ * check if attribute is yes/no
109
+ * @access public
110
+ * @return bool
111
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
112
+ */
113
+ public function getIsYesNo(){
114
+ return true;
115
+ }
116
+ /**
117
+ * get the options for form input
118
+ * @access public
119
+ * @return string
120
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
121
+ */
122
+ public function getFormOptions(){
123
+ $options = parent::getFormOptions();
124
+ $padding = $this->getPadding(3);
125
+ $tab = $this->getPadding();
126
+ $eol = $this->getEol();
127
+ $module = $this->getModule()->getLowerModuleName();
128
+ $namespace = $this->getNamespace(true);
129
+ $options .= $padding."'values'=> array(".$eol;
130
+ $options .= $padding.$tab.'array('.$eol;
131
+ $options .= $padding.$tab.$tab."'value' => 1,".$eol;
132
+ $options .= $padding.$tab.$tab."'label' => Mage::helper('".$namespace.'_'.$module."')->__('Yes'),".$eol;
133
+ $options .= $padding.$tab."),".$eol;
134
+ $options .= $padding.$tab.'array('.$eol;
135
+ $options .= $padding.$tab.$tab."'value' => 0,".$eol;
136
+ $options .= $padding.$tab.$tab."'label' => Mage::helper('".$namespace.'_'.$module."')->__('No'),".$eol;
137
+ $options .= $padding.$tab."),".$eol;
138
+ $options .= $padding."),".$eol;
139
+ return $options;
140
+ }
141
+ /**
142
+ * get values for mass action
143
+ * @access public
144
+ * @return string
145
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
146
+ */
147
+ public function getMassActionValues() {
148
+ $eol = $this->getEol();
149
+ $module = $this->getModule()->getLowerModuleName();
150
+ $namespace = $this->getNamespace(true);
151
+ $padding = $this->getPadding(7);
152
+ $tab = $this->getPadding();
153
+ $content = 'array('.$eol;
154
+ $content .= $padding.$tab."'1' => Mage::helper('".$namespace.'_'.$module."')->__('Yes'),".$eol;
155
+ $content .= $padding.$tab."'0' => Mage::helper('".$namespace.'_'.$module."')->__('No'),".$eol;
156
+ $content .= $padding.')'.$eol;
157
+ return $content;
158
+ }
159
+ }
app/code/community/Ultimate/ModuleCreator/Model/Config.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ class Ultimate_ModuleCreator_Model_Config extends Varien_Simplexml_Config {
19
+ /**
20
+ * cache key
21
+ */
22
+ const CACHE_ID = 'umc_config';
23
+ /**
24
+ * get DOM of the config
25
+ * @access public
26
+ * @return null|Varien_Simplexml_Element
27
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
28
+ */
29
+ public function getDom() {
30
+ if (is_null($this->_xml)){
31
+ $this->_xml = Mage::getConfig()->loadModulesConfiguration('umc.xml')
32
+ ->applyExtends();
33
+ }
34
+ return $this->_xml;
35
+ }
36
+
37
+ /**
38
+ * get default translation module
39
+ * @return string
40
+ * @access protected
41
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
42
+ */
43
+ protected function _getDefaultTranslateModule(){
44
+ return 'Ultimate_ModuleCreator';
45
+ }
46
+
47
+ /**
48
+ * translate node
49
+ * @access protected
50
+ * @param $node
51
+ * @return Ultimate_ModuleCreator_Model_Config
52
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
53
+ */
54
+ protected function _translateNode(&$node){
55
+ if ($node->getAttribute('translate')){
56
+ $fields = explode(' ', $node->getAttribute('translate'));
57
+ $module = ($node->getAttribute('module')) ? (string)$node->getAttribute('module') : $this->_getDefaultTranslateModule();
58
+ foreach ($fields as $field){
59
+ if ($node->$field){
60
+ $node->$field = Mage::helper($module)->__((string)$node->$field);
61
+ }
62
+ }
63
+ }
64
+ if ($node->hasChildren()){
65
+ foreach ($node->children() as $child){
66
+ $this->_translateNode($child);
67
+ }
68
+ }
69
+ return $this;
70
+ }
71
+ }
app/code/community/Ultimate/ModuleCreator/Model/Entity.php CHANGED
@@ -9,1657 +9,2746 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
  * entity model
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Model_Entity extends Ultimate_ModuleCreator_Model_Abstract{
25
- /**
26
- * entity attributes
27
- * @var array
28
- */
29
- protected $_attribtues = array();
30
- /**
31
- * entity module
32
- * @var Ultimate_ModuleCreator_Model_Module
33
- */
34
- protected $_module = null;
35
- /**
36
- * attribute that behaves as name
37
- * @var Ultimate_ModuleCreator_Model_Attribute
38
- */
39
- protected $_nameAttribute = null;
40
- /**
41
- * remember if attributes were prepared
42
- * @var bool
43
- */
44
- protected $_preparedAttributes = null;
45
- /**
46
- * related entities
47
- * @var array()
48
- */
49
- protected $_relatedEntities = array();
50
- /**
51
- * placeholders
52
- * @var array
53
- */
54
- protected $_placeholders = array();
55
- /**
56
- * set the entity module
57
- * @access public
58
- * @param Ultimate_ModuleCreator_Model_Module $module
59
- * @return Ultimate_ModuleCreator_Model_Entity
60
- * @author Marius Strajeru <marius.strajeru@gmail.com>
61
- */
62
- public function setModule(Ultimate_ModuleCreator_Model_Module $module){
63
- $this->_module = $module;
64
- return $this;
65
- }
66
- /**
67
- * get the entity module
68
- * @access public
69
- * @return mixed (Ultimate_ModuleCreator_Model_Module|null)
70
- * @author Marius Strajeru <marius.strajeru@gmail.com>
71
- */
72
- public function getModule(){
73
- return $this->_module;
74
- }
75
- /**
76
- * add new attribute
77
- * @access public
78
- * @param Ultimate_ModuleCreator_Model_Attribute $attribute
79
- * @return Ultimate_ModuleCreator_Model_Entity
80
- * @author Marius Strajeru <marius.strajeru@gmail.com>
81
- */
82
- public function addAttribute(Ultimate_ModuleCreator_Model_Attribute $attribute){
83
- $attribute->setEntity($this);
84
- if (isset($this->_attribtues[$attribute->getCode()])){
85
- throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('An attribute with the code "%s" already exists for entity "%s"', $attribute->getCode(), $this->getNameSingular()));
86
- }
87
- $this->_preparedAttributes = false;
88
- $this->_attribtues[$attribute->getCode()] = $attribute;
89
- $allowedTypes = array('text'=>'Text', 'int'=>'Integer', 'decimal'=>'Decimal');
90
- if ($attribute->getIsName()){
91
- if (!in_array($attribute->getType(), array_keys($allowedTypes))){
92
- throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('An attribute that acts as name must have the type %s.', implode(', ', array_values($allowedTypes))));
93
- }
94
- $this->_nameAttribute = $attribute;
95
- }
96
- if ($attribute->getEditor()){
97
- $this->setEditor(true);
98
- }
99
- $this->_placeholders = array();
100
- return $this;
101
- }
102
- /**
103
- * prepare attributes
104
- * @access protected
105
- * @return Ultimate_ModuleCreator_Model_Entity
106
- * @author Marius Strajeru <marius.strajeru@gmail.com>
107
- */
108
- protected function _prepareAttributes(){
109
- if ($this->_preparedAttributes){
110
- return $this;
111
- }
112
- $attributesByPosition = array();
113
- foreach ($this->_attribtues as $key=>$attribute){
114
- $attributesByPosition[$attribute->getPosition()][] = $attribute;
115
- }
116
- ksort($attributesByPosition);
117
- $attributes = array();
118
- foreach ($attributesByPosition as $position=>$attributeList){
119
- foreach ($attributeList as $attribute){
120
- $attributes[$attribute->getCode()] = $attribute;
121
- }
122
- }
123
- $this->_attribtues = $attributes;
124
- $this->_preparedAttributes = true;
125
- return $this;
126
- }
127
- /**
128
- * ge the entity attribtues
129
- * @access public
130
- * @return array()
131
- * @author Marius Strajeru <marius.strajeru@gmail.com>
132
- */
133
- public function getAttributes(){
134
- if (!$this->_preparedAttributes){
135
- $this->_prepareAttributes();
136
- }
137
- return $this->_attribtues;
138
- }
139
- /**
140
- * entity to xml
141
- * @access protected
142
- * @param array $arrAttributes
143
- * @param string $rootName
144
- * @param bool $addOpenTag
145
- * @param bool $addCdata
146
- * @return string
147
- * @author Marius Strajeru <marius.strajeru@gmail.com>
148
- */
149
- protected function __toXml(array $arrAttributes = array(), $rootName = 'entity', $addOpenTag=false, $addCdata=false){
150
- $xml = '';
151
- if ($addOpenTag) {
152
- $xml.= '<?xml version="1.0" encoding="UTF-8"?>'."\n";
153
- }
154
- if (!empty($rootName)) {
155
- $xml.= '<'.$rootName.'>'."\n";
156
- }
157
- $start = '';
158
- $end = '';
159
- if ($addCdata){
160
- $start = '<![CDATA[';
161
- $end = ']]>';
162
- }
163
- $xml .= parent::__toXml($this->getXmlAttributes(), '', false, $addCdata);
164
- $xml .= '<attributes>';
165
- foreach ($this->getAttributes() as $attribute){
166
- $xml .= $attribute->toXml(array(), 'attribute', false, $addCdata);
167
- }
168
- $xml .= '</attributes>';
169
- if (!empty($rootName)) {
170
- $xml.= '</'.$rootName.'>'."\n";
171
- }
172
- return $xml;
173
- }
174
- /**
175
- * get the attributes saved in the xml
176
- * @access public
177
- * @return array();
178
- * @author Marius Strajeru <marius.strajeru@gmail.com>
179
- */
180
- public function getXmlAttributes(){
181
- return array('label_singular', 'label_plural', 'name_singular', 'name_plural', 'created_to_grid',
182
- 'updated_to_grid', 'add_status', 'use_frontend', 'frontend_list',
183
- 'frontend_list_template', 'frontend_view', 'frontend_view_template', 'frontend_add_seo',
184
- 'rss', 'widget', 'link_product', 'show_on_product', 'show_products',
185
- 'is_tree', 'url_rewrite', 'admin_search', 'create_api'
186
- );
187
- }
188
- /**
189
- * get the placeholders for an entity
190
- * @access public
191
- * @return array
192
- * @author Marius Strajeru <marius.strajeru@gmail.com>
193
- */
194
- public function getPlaceholders(){
195
- if (!isset($this->_placeholders['entity'])){
196
- $placeholders = array();
197
- $placeholders['{{EntityLabel}}'] = ucfirst($this->getLabelSingular());
198
- $placeholders['{{entityLabel}}'] = strtolower($this->getLabelSingular());
199
- $placeholders['{{EntitiesLabel}}'] = ucfirst($this->getLabelPlural());
200
- $placeholders['{{entitiesLabel}}'] = strtolower($this->getLabelPlural());
201
- $placeholders['{{entity}}'] = strtolower($this->getNameSingular());
202
- $placeholders['{{Entity}}'] = ucfirst($this->getNameSingular());
203
- $placeholders['{{ENTITY}}'] = strtoupper($this->getNameSingular());
204
- $placeholders['{{Entities}}'] = ucfirst($this->getNamePlural());
205
- $placeholders['{{entities}}'] = $this->getNamePlural();
206
- $placeholders['{{listLayout}}'] = $this->getFrontendListTemplate();
207
- $placeholders['{{viewLayout}}'] = $this->getFrontendViewTemplate();
208
- $nameAttribute = $this->getNameAttribute();
209
- $placeholders['{{EntityNameMagicCode}}'] = $this->getNameAttributeMagicCode();
210
- $placeholders['{{nameAttribute}}'] = $nameAttribute->getCode();
211
- $placeholders['{{nameAttributeLabel}}'] = $nameAttribute->getLabel();
212
- $placeholders['{{firstImageField}}'] = $this->getFirstImageField();
213
- $placeholders['{{attributeSql}}'] = $this->getAttributesSql();
214
- $placeholders['{{attributeDdlSql}}'] = $this->getAttributesDdlSql();
215
-
216
- $placeholders['{{menu_sort}}'] = $this->getPosition();
217
- $placeholders['{{defaults}}'] = $this->getConfigDefaults();
218
- $placeholders['{{systemAttributes}}'] = $this->getSystemAttributes();
219
- $placeholders['{{EntityListItem}}'] = $this->getListItemHtml();
220
- $placeholders['{{EntityViewAttributes}}'] = $this->getViewAttributesHtml();
221
- $placeholders['{{EntityViewWidgetAttributes}}'] = $this->getViewWidgetAttributesHtml();
222
- $placeholders['{{EntityViewRelationLayout}}'] = $this->getRelationLayoutXml();
223
- $placeholders['{{fks}}'] = $this->getParentEntitiesFks("\t\t");
224
- $placeholders['{{fksDdl}}'] = $this->getParentEntitiesFksDdl("\t");
225
- $placeholders['{{referenceHead}}'] = $this->getReferenceHeadLayout();
226
- //$placeholders['{{entityApiRelations}}'] = $this->getApiRelations();
227
- $placeholders['{{entityApiAdditional}}'] = $this->getApiAdditional();
228
- $placeholders['{{entityAdditionalApiAcl}}'] = $this->getAdditionalApiAcl();
229
- $placeholders['{{entityApiFaults}}'] = $this->getApiFaults();
230
- $placeholders['{{entityApiSortOrder}}'] = 110 + $this->getPosition();
231
- $placeholders['{{entityWsdlAttributes}}'] = $this->getWsdlAttributes();
232
- $placeholders['{{entityWsdlRelationTypes}}'] = $this->getWsdlRelationTypes();
233
- $placeholders['{{entityWsdlPortTypeRelation}}'] = $this->getWsdlPortTypeRelation();
234
- $placeholders['{{entityWsdlRelationBinding}}'] = $this->getWsdlRelationBinding();
235
- $placeholders['{{entityWsiRelationParamTypes}}']= $this->getWsiRelationParamTypes();
236
- $placeholders['{{entityWsiRelationMessages}}'] = $this->getWsiRelationMessages();
237
- $placeholders['{{entityWsiPortTypeRelation}}'] = $this->getWsiPortTypeRelation();
238
- $placeholders['{{entityWsiRelationBinding}}'] = $this->getWsiRelationBinding();
239
- $placeholders['{{entityWsiAttributes}}'] = $this->getWsiAttributes();
240
- $placeholders['{{entityWsiRelationTypes}}'] = $this->getWsiRelationTypes();
241
- $placeholders['{{entityWsdlMessages}}'] = $this->getWsdlMessages();
242
- $this->_placeholders['entity'] = $placeholders;
243
- }
244
- return $this->_placeholders['entity'];
245
- }
246
- /**
247
- * get the placeholders for an entity as a sibling
248
- * @access public
249
- * @return array
250
- * @author Marius Strajeru <marius.strajeru@gmail.com>
251
- */
252
- public function getPlaceholdersAsSibling(){
253
- if (!isset($this->_placeholders['sibling'])){
254
- $placeholders = array();
255
- $placeholders['{{SiblingLabel}}'] = ucfirst($this->getLabelSingular());
256
- $placeholders['{{siblingLabel}}'] = strtolower($this->getLabelSingular());
257
- $placeholders['{{SiblingsLabel}}'] = ucfirst($this->getLabelPlural());
258
- $placeholders['{{siblingsLabel}}'] = strtolower($this->getLabelPlural());
259
- $placeholders['{{sibling}}'] = strtolower($this->getNameSingular());
260
- $placeholders['{{Sibling}}'] = ucfirst($this->getNameSingular());
261
- $placeholders['{{SIBLING}}'] = strtoupper($this->getNameSingular());
262
- $placeholders['{{Siblings}}'] = ucfirst($this->getNamePlural());
263
- $placeholders['{{siblings}}'] = $this->getNamePlural();
264
- $placeholders['{{siblingListLayout}}'] = $this->getFrontendListTemplate();
265
- $placeholders['{{siblingViewLayout}}'] = $this->getFrontendViewTemplate();
266
- $nameAttribute = $this->getNameAttribute();
267
- $placeholders['{{SiblingNameMagicCode}}'] = $this->getNameAttributeMagicCode();
268
- $placeholders['{{siblingNameAttribute}}'] = $nameAttribute->getCode();
269
- $placeholders['{{siblingNameAttributeLabel}}'] = $nameAttribute->getLabel();
270
- $placeholders['{{siblingFirstImageField}}'] = $this->getFirstImageField();
271
- $placeholders['{{siblingAttributeSql}}'] = $this->getAttributesSql();
272
- $placeholders['{{sibling_menu_sort}}'] = $this->getPosition();
273
- $placeholders['{{sibling_defaults}}'] = $this->getConfigDefaults();
274
- $placeholders['{{siblingSystemAttributes}}'] = $this->getSystemAttributes();
275
- $placeholders['{{SiblingListItem}}'] = $this->getListItemHtml();
276
- $placeholders['{{SiblingViewAttributes}}'] = $this->getViewAttributesHtml();
277
- $placeholders['{{SiblingViewWidgetAttributes}}'] = $this->getViewWidgetAttributesHtml();
278
- $placeholders['{{SiblingViewRelationLayout}}'] = $this->getRelationLayoutXml();
279
- $placeholders['{{siblingFks}}'] = $this->getParentEntitiesFks("\t\t");
280
-
281
- $this->_placeholders['sibling'] = $placeholders;
282
- }
283
- return $this->_placeholders['sibling'];
284
- }
285
- /**
286
- * get magic function code for the name attribute
287
- * @access public
288
- * @return string
289
- * @author Marius Strajeru <marius.strajeru@gmail.com>
290
- */
291
- public function getNameAttributeMagicCode(){
292
- $nameAttribute = $this->getNameAttribute();
293
- if ($nameAttribute){
294
- $entityNameMagicCode = $nameAttribute->getMagicMethodCode();
295
- }
296
- else{
297
- $entityNameMagicCode = 'Name';
298
- }
299
- return $entityNameMagicCode;
300
- }
301
- /**
302
- * get the name attribute
303
- * @access public
304
- * @return mixed(null|Ultimate_ModuleCreator_Model_Attribute)
305
- * @author Marius Strajeru <marius.strajeru@gmail.com>
306
- */
307
- public function getNameAttribute(){
308
- return $this->_nameAttribute;
309
- }
310
- /**
311
- * check if the entity has file attributes
312
- * @access public
313
- * @return bool
314
- * @author Marius Strajeru <marius.strajeru@gmail.com>
315
- */
316
- public function getHasFile(){
317
- foreach ($this->getAttributes() as $attribute){
318
- if ($attribute->getType() == 'file'){
319
- return true;
320
- }
321
- }
322
- return false;
323
- }
324
- /**
325
- * check if the entity has image attributes
326
- * @access public
327
- * @return bool
328
- * @author Marius Strajeru <marius.strajeru@gmail.com>
329
- */
330
- public function getHasImage(){
331
- foreach ($this->getAttributes() as $attribute){
332
- if ($attribute->getType() == 'image'){
333
- return true;
334
- }
335
- }
336
- return false;
337
- }
338
- /**
339
- * check if the entity has upload attributes
340
- * @access public
341
- * @return bool
342
- * @author Marius Strajeru <marius.strajeru@gmail.com>
343
- */
344
- public function getHasUpload(){
345
- return $this->getHasFile() || $this->getHasImage();
346
- }
347
- /**
348
- * get the first image attribute code
349
- * @access public
350
- * @return string
351
- * @author Marius Strajeru <marius.strajeru@gmail.com>
352
- */
353
- public function getFirstImageField(){
354
- foreach ($this->getAttributes() as $attribute){
355
- if ($attribute->getType() == 'image'){
356
- return $attribute->getCode();
357
- }
358
- }
359
- return '';
360
- }
361
- /**
362
- * get the sql for attributes
363
- * @access public
364
- * @return string
365
- * @author Marius Strajeru <marius.strajeru@gmail.com>
366
- */
367
- public function getAttributesSql(){
368
- $padding = "\t\t";
369
- $content = '';
370
- $content.= $this->getParentEntitiesFkAttributes($padding);
371
- foreach ($this->getAttributes() as $attribute){
372
- $content .= $padding.$attribute->getSqlColumn()."\n";
373
- }
374
- $simulated = $this->_getSimulatedAttributes(null, false);
375
- foreach ($simulated as $attr){
376
- $content .= $padding.$attr->getSqlColumn()."\n";
377
- }
378
- return substr($content,0, strlen($content) - strlen("\n"));
379
- }
380
- /**
381
- * get the ddl sql for attributes
382
- * @access public
383
- * @return string
384
- * @author Marius Strajeru <marius.strajeru@gmail.com>
385
- */
386
- public function getAttributesDdlSql(){
387
- $padding = "\t";
388
- $content = '';
389
- $content.= $this->getParentEntitiesFkAttributes($padding, true);
390
- foreach ($this->getAttributes() as $attribute){
391
- $content .= $padding.$attribute->getDdlSqlColumn()."\n";
392
- }
393
- $simulated = $this->_getSimulatedAttributes(null, false);
394
- foreach ($simulated as $attr){
395
- $content .= $padding.$attr->getDdlSqlColumn()."\n";
396
- }
397
- return substr($content,0, strlen($content) - strlen("\n"));
398
- }
399
- /**
400
- * get the default settings for config
401
- * @access public
402
- * @return string
403
- * @author Marius Strajeru <marius.strajeru@gmail.com>
404
- */
405
- public function getConfigDefaults(){
406
- $content = '';
407
- $padding = str_repeat("\t", 4);
408
- if ($this->getRss()){
409
- $content .= $padding.'<rss>1</rss>'."\n";
410
- }
411
- if ($this->getFrontendAddSeo() && $this->getFrontendList()){
412
- $content .= $padding.'<meta_title>'.ucfirst($this->getLabelPlural()).'</meta_title>'."\n";
413
- }
414
- if ($this->getIsTree()){
415
- $content .= $padding.'<tree>1</tree>'."\n";
416
- $content .= $padding.'<recursion>0</recursion>'."\n";
417
- }
418
- return substr($content,0, strlen($content) - strlen("\n"));
419
- }
420
- /**
421
- * get the system attributes
422
- * @access public
423
- * @return string
424
- * @author Marius Strajeru <marius.strajeru@gmail.com>
425
- */
426
- public function getSystemAttributes(){
427
- $position = 20;
428
- $content = '';
429
- $tab = "\t";
430
- $padding = str_repeat($tab, 6);
431
- if ($this->getRss()){
432
- $content .= $padding.'<rss translate="label" module="'.strtolower($this->getModule()->getModuleName()).'">'."\n";
433
- $content .= $padding.$tab.'<label>Enable rss</label>'."\n";
434
- $content .= $padding.$tab.'<frontend_type>select</frontend_type>'."\n";
435
- $content .= $padding.$tab.'<source_model>adminhtml/system_config_source_yesno</source_model>'."\n";
436
- $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'."\n";
437
- $content .= $padding.$tab.'<show_in_default>1</show_in_default>'."\n";
438
- $content .= $padding.$tab.'<show_in_website>1</show_in_website>'."\n";
439
- $content .= $padding.$tab.'<show_in_store>1</show_in_store>'."\n";
440
- $content .= $padding.'</rss>'."\n";
441
- $position += 10;
442
- }
443
- if ($this->getIsTree() && $this->getFrontendList()){
444
- $content .= $padding.'<tree translate="label" module="'.strtolower($this->getModule()->getModuleName()).'">'."\n";
445
- $content .= $padding.$tab.'<label>Display as tree</label>'."\n";
446
- $content .= $padding.$tab.'<frontend_type>select</frontend_type>'."\n";
447
- $content .= $padding.$tab.'<source_model>adminhtml/system_config_source_yesno</source_model>'."\n";
448
- $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'."\n";
449
- $content .= $padding.$tab.'<show_in_default>1</show_in_default>'."\n";
450
- $content .= $padding.$tab.'<show_in_website>1</show_in_website>'."\n";
451
- $content .= $padding.$tab.'<show_in_store>1</show_in_store>'."\n";
452
- $content .= $padding.'</tree>'."\n";
453
- $position += 10;
454
- }
455
- if ($this->getIsTree() && $this->getWidget()){
456
- $content .= $padding.'<recursion translate="label" module="'.strtolower($this->getModule()->getModuleName()).'">'."\n";
457
- $content .= $padding.$tab.'<label>Recursion level</label>'."\n";
458
- $content .= $padding.$tab.'<frontend_type>text</frontend_type>'."\n";
459
- $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'."\n";
460
- $content .= $padding.$tab.'<show_in_default>1</show_in_default>'."\n";
461
- $content .= $padding.$tab.'<show_in_website>1</show_in_website>'."\n";
462
- $content .= $padding.$tab.'<show_in_store>1</show_in_store>'."\n";
463
- $content .= $padding.'</recursion>'."\n";
464
- $position += 10;
465
- }
466
-
467
- if ($this->getFrontendAddSeo() && $this->getFrontendList()){
468
- $content .= $padding.'<meta_title translate="label" module="'.strtolower($this->getModule()->getModuleName()).'">'."\n";
469
- $content .= $padding.$tab.'<label>Meta title for '.strtolower($this->getLabelPlural()).' list page</label>'."\n";
470
- $content .= $padding.$tab.'<frontend_type>text</frontend_type>'."\n";
471
- $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'."\n";
472
- $content .= $padding.$tab.'<show_in_default>1</show_in_default>'."\n";
473
- $content .= $padding.$tab.'<show_in_website>1</show_in_website>'."\n";
474
- $content .= $padding.$tab.'<show_in_store>1</show_in_store>'."\n";
475
- $content .= $padding.'</meta_title>'."\n";
476
- $position += 10;
477
-
478
- $content .= $padding.'<meta_description translate="label" module="'.strtolower($this->getModule()->getModuleName()).'">'."\n";
479
- $content .= $padding.$tab.'<label>Meta description for '.strtolower($this->getLabelPlural()).' list page</label>'."\n";
480
- $content .= $padding.$tab.'<frontend_type>textarea</frontend_type>'."\n";
481
- $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'."\n";
482
- $content .= $padding.$tab.'<show_in_default>1</show_in_default>'."\n";
483
- $content .= $padding.$tab.'<show_in_website>1</show_in_website>'."\n";
484
- $content .= $padding.$tab.'<show_in_store>1</show_in_store>'."\n";
485
- $content .= $padding.'</meta_description>'."\n";
486
- $position += 10;
487
-
488
- $content .= $padding.'<meta_keywords translate="label" module="'.strtolower($this->getModule()->getModuleName()).'">'."\n";
489
- $content .= $padding.$tab.'<label>Meta keywords for '.strtolower($this->getLabelPlural()).' list page</label>'."\n";
490
- $content .= $padding.$tab.'<frontend_type>textarea</frontend_type>'."\n";
491
- $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'."\n";
492
- $content .= $padding.$tab.'<show_in_default>1</show_in_default>'."\n";
493
- $content .= $padding.$tab.'<show_in_website>1</show_in_website>'."\n";
494
- $content .= $padding.$tab.'<show_in_store>1</show_in_store>'."\n";
495
- $content .= $padding.'</meta_keywords>'."\n";
496
- }
497
- return substr($content,0, strlen($content) - strlen("\n"));
498
- }
499
- /**
500
- * get the html for list view
501
- * @access public
502
- * @return string
503
- * @author Marius Strajeru <marius.strajeru@gmail.com>
504
- */
505
- public function getListItemHtml(){
506
- $tab = "\t";
507
- $padding = str_repeat($tab, 3);
508
- $content = '';
509
- $start = '';
510
- if ($this->getFrontendView()){
511
- $content.= $padding.'<a href="<?php echo $'.'_'.$this->getNameSingular().'->get'.ucfirst($this->getNameSingular()).'Url();?>" title="<?php echo $this->htmlEscape($_'.$this->getNameSingular().'->get'.$this->getNameAttributeMagicCode().'()) ?>">'."\n";
512
- $start = $tab;
513
- }
514
- $content .= $padding.$start.'<?php echo $_'.$this->getNameSingular().'->get'.$this->getNameAttributeMagicCode().'(); ?>'. "\n";
515
- if ($this->getFrontendView()){
516
- $content.= $padding.'</a>'."\n";
517
- }
518
- return $content;
519
- }
520
- /**
521
- * get the html for attributes in view page
522
- * @access public
523
- * @return string
524
- * @author Marius Strajeru <marius.strajeru@gmail.com>
525
- */
526
- public function getViewAttributesHtml(){
527
- $content = '';
528
- $padding = "\t";
529
- foreach ($this->getAttributes() as $attribute){
530
- if ($attribute->getFrontend()){
531
- $content .= $padding.'<div class="'.$this->getNameSingular().'-'.$attribute->getCode().'">'."\n";
532
- $content .= "\t".$padding.$attribute->getFrontendHtml();
533
- $content .= $padding.'</div>'."\n";
534
- }
535
- }
536
- return $content;
537
- }
538
- /**
539
- * get the html for attributes for the view widget
540
- * @access public
541
- * @return string
542
- * @author Marius Strajeru <marius.strajeru@gmail.com>
543
- */
544
- public function getViewWidgetAttributesHtml(){
545
- $content = '';
546
- $padding = "\t\t\t";
547
- $tab = "\t";
548
- foreach ($this->getAttributes() as $attribute){
549
- if ($attribute->getWidget()){
550
- $content .= $padding.$attribute->getFrontendHtml();
551
- }
552
- }
553
- return $content;
554
- }
555
- /**
556
- * get the attribute name for plural
557
- * @access public
558
- * @return string
559
- * @author Marius Strajeru <marius.strajeru@gmail.com>
560
- */
561
- public function getNamePlural(){
562
- $plural = $this->getData('name_plural');
563
- if ($plural == $this->getNameSingular()){
564
- if ($plural == ""){
565
- return "";
566
- }
567
- $plural = $this->getNameSingular().'s';
568
- }
569
- return $plural;
570
- }
571
- /**
572
- * check if frontend list files must be created
573
- * @access public
574
- * @return bool
575
- * @author Marius Strajeru <marius.strajeru@gmail.com>
576
- */
577
- public function getFrontendList(){
578
- return $this->getUseFrontend() && $this->getData('frontend_list');
579
- }
580
- /**
581
- * check if frontend view files must be created
582
- * @access public
583
- * @return bool
584
- * @author Marius Strajeru <marius.strajeru@gmail.com>
585
- */
586
- public function getFrontendView(){
587
- return $this->getUseFrontend() && $this->getData('frontend_view');
588
- }
589
- /**
590
- * check if widget list files must be created
591
- * @access public
592
- * @return bool
593
- * @author Marius Strajeru <marius.strajeru@gmail.com>
594
- */
595
- public function getWidget(){
596
- return $this->getUseFrontend() && $this->getData('widget');
597
- }
598
- /**
599
- * check if SEO attributes should be added
600
- * @access public
601
- * @return bool
602
- * @author Marius Strajeru <marius.strajeru@gmail.com>
603
- */
604
- public function getFrontendAddSeo(){
605
- return $this->getUseFrontend() && $this->getData('frontend_add_seo');
606
- }
607
- /**
608
- * check if the frontend list block can be created
609
- * @access public
610
- * @return bool
611
- * @author Marius Strajeru <marius.strajeru@gmail.com>
612
- */
613
- public function getCanCreateListBlock(){
614
- if ($this->getFrontendList()){
615
- return true;
616
- }
617
- //check for sibligns with frontend view
618
- $related = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
619
- foreach ($related as $r){
620
- if ($r->getFrontendView()){
621
- return true;
622
- }
623
- }
624
- //check for parents with frontend view
625
- $related = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD);
626
- foreach ($related as $r){
627
- if ($r->getFrontendView()){
628
- return true;
629
- }
630
- }
631
- return false;
632
- }
633
- /**
634
- * check if SEO attributes should be added
635
- * @access public
636
- * @return bool
637
- * @author Marius Strajeru <marius.strajeru@gmail.com>
638
- */
639
- public function getRss(){
640
- return $this->getUseFrontend() && $this->getData('rss');
641
- }
642
- /**
643
- * check if products are listed in the entity view page
644
- * @access public
645
- * @return bool
646
- * @author Marius Strajeru <marius.strajeru@gmail.com>
647
- */
648
- public function getShowProducts(){
649
- return $this->getLinkProduct() && $this->getData('show_products');
650
- }
651
- /**
652
- * check if url rewrites are added
653
- * @access public
654
- * @return bool
655
- * @author Marius Strajeru <marius.strajeru@gmail.com>
656
- */
657
- public function getUrlRewrite(){
658
- return $this->getFrontendView() && $this->getData('url_rewrite');
659
- }
660
- /**
661
- * check if url rewrites are not
662
- * @access public
663
- * @return bool
664
- * @author Marius Strajeru <marius.strajeru@gmail.com>
665
- */
666
- public function getNotUrlRewrite(){
667
- return !$this->getUrlRewrite();
668
- }
669
- /**
670
- * get layout xml for relation to product
671
- * @access public
672
- * @return string
673
- * @author Marius Strajeru <marius.strajeru@gmail.com>
674
- */
675
- public function getRelationLayoutXml(){
676
- $content = "\t\t";
677
- if ($this->getShowProducts()){
678
- $content .= "\t".'<block type="'.strtolower($this->getModule()->getModuleName()).'/'.strtolower($this->getNameSingular()).'_catalog_product_list" name="'.strtolower($this->getNameSingular()).'.info.products" as="'.strtolower($this->getNameSingular()).'_products" template="'.strtolower($this->getModule()->getNamespace()).'_'.strtolower($this->getModule()->getModuleName()).'/'.strtolower($this->getNameSingular()).'/catalog/product/list.phtml" />'."\n\t\t";
679
- }
680
- if ($this->getIsTree()){
681
- $content .= "\t".'<block type="'.strtolower($this->getModule()->getModuleName()).'/'.strtolower($this->getNameSingular()).'_children" name="'.strtolower($this->getNameSingular()).'_children" template="'.strtolower($this->getModule()->getNamespace()).'_'.strtolower($this->getModule()->getModuleName()).'/'.strtolower($this->getNameSingular()).'/children.phtml" />'."\n\t\t";
682
- }
683
- $childred = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_PARENT);
684
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
685
- foreach (array_merge($childred, $siblings) as $entity){
686
- $content .= "\t".'<block type="'.strtolower($this->getModule()->getModuleName()).'/'.strtolower($this->getNameSingular()).'_'.strtolower($entity->getNameSingular()).'_list" name="'.strtolower($this->getNameSingular()).'.'.strtolower($entity->getNameSingular()).'_list" as="'.strtolower($this->getNameSingular()).'_'.strtolower($this->getNamePlural()).'" template="'.strtolower($this->getModule()->getNamespace()).'_'.strtolower($this->getModule()->getModuleName()).'/'.strtolower($this->getNameSingular()).'/'.strtolower($entity->getNameSingular()).'/list.phtml" />'."\n\t\t";
687
- }
688
- return $content;
689
- }
690
- /**
691
- * get layout xml head reference
692
- * @access public
693
- * @return string
694
- * @author Marius Strajeru <marius.strajeru@gmail.com>
695
- */
696
- public function getReferenceHeadLayout(){
697
- $content = "\t\t";
698
- if ($this->getIsTree()){
699
- $content .= '<reference name="head">'."\n";
700
- $content .= "\t\t\t".'<action method="addItem" ifconfig="'.strtolower($this->getModule()->getModuleName()).'/'.strtolower($this->getNameSingular()).'/tree"><type>skin_js</type><js>js/'.strtolower($this->getModule()->getNamespace()).'_'.strtolower($this->getModule()->getModuleName()).'/tree.js</js></action>'."\n";
701
- $content .= "\t\t".'</reference>'."\n";
702
- $content .= "\t\t";
703
- }
704
- return $content;
705
- }
706
- /**
707
- * check if entity list is shown on product page
708
- * @access public
709
- * @return bool
710
- * @author Marius Strajeru <marius.strajeru@gmail.com>
711
- */
712
- public function getShowOnProduct(){
713
- return $this->getLinkProduct() && $this->getData('show_on_product');
714
- }
715
- /**
716
- * add related entities
717
- * @access public
718
- * @param string $type
719
- * @param Ultimate_ModuleCreator_Model_Entity $entity
720
- * @return Ultimate_ModuleCreator_Model_Entity
721
- * @author Marius Strajeru <marius.strajeru@gmail.com>
722
- */
723
- public function addRelatedEntity($type, $entity){
724
- $this->_relatedEntities[$type][] = $entity;
725
- return $this;
726
- }
727
- /**
728
- * get the related entities
729
- * @access public
730
- * @param mixed $type
731
- * @return array()
732
- * @author Marius Strajeru <marius.strajeru@gmail.com>
733
- */
734
- public function getRelatedEntities($type = null){
735
- if (is_null($type)){
736
- return $this->_relatedEntities;
737
- }
738
- if (isset($this->_relatedEntities[$type])){
739
- return $this->_relatedEntities[$type];
740
- }
741
- return array();
742
- }
743
- /**
744
- * get foreign keys for parents
745
- * @access public
746
- * @param string $padding
747
- * @return string
748
- * @author Marius Strajeru <marius.strajeru@gmail.com>
749
- */
750
- public function getParentEntitiesFkAttributes($padding, $ddl = false){
751
- $parents = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD);
752
- $content = '';
753
- foreach ($parents as $parent){
754
- $attr = Mage::getModel('modulecreator/attribute');
755
- $attr->setCode($parent->getNameSingular().'_id');
756
- $attr->setLabel($parent->getLabelSingular());
757
- $attr->setType('int');
758
- if ($ddl){
759
- $content .= $padding.$attr->getDdlSqlColumn()."\n";
760
- }
761
- else{
762
- $content .= $padding.$attr->getSqlColumn()."\n";
763
- }
764
- }
765
- return $content;
766
- }
767
- /**
768
- * get foreign keys for sql
769
- * @access public
770
- * @param string $padding
771
- * @return string
772
- * @author Marius Strajeru <marius.strajeru@gmail.com>
773
- */
774
- public function getParentEntitiesFks($padding){
775
- $parents = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD);
776
- $content = '';
777
- foreach ($parents as $parent){
778
- $content .= ', '."\n".$padding."KEY `FK_".strtoupper($this->getModule()->getModuleName())."_".strtoupper($this->getNameSingular())."_".strtoupper($parent->getNameSingular())."` (`".$parent->getNameSingular()."_id`)\n";
779
- }
780
- return $content;
781
- }
782
- /**
783
- * get foreign keys for sql (Ddl)
784
- * @access public
785
- * @param string $padding
786
- * @return string
787
- * @author Marius Strajeru <marius.strajeru@gmail.com>
788
- */
789
- public function getParentEntitiesFksDdl($padding){
790
- $parents = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD);
791
- $content = '';
792
-
793
- $module = strtolower($this->getModule()->getModuleName());
794
- foreach ($parents as $parent){
795
- $parentName = strtolower($parent->getNameSingular());
796
- $content .= "\n".$padding."->addIndex($"."this->getIdxName('".$module.'/'.$parentName."', array('".$parentName."_id')), array('".$parentName."_id'))";
797
- }
798
- return $content;
799
- }
800
- /**
801
- * check if entity does not behave as tree
802
- * @access public
803
- * @return bool
804
- * @author Marius Strajeru <marius.strajeru@gmail.com>
805
- */
806
- public function getNotIsTree(){
807
- return !$this->getIsTree();
808
- }
809
- /**
810
- * check if there is no status attribute
811
- * @access public
812
- * @return bool
813
- * @author Marius Strajeru <marius.strajeru@gmail.com>
814
- */
815
- public function getNotAddStatus(){
816
- return !$this->getAddStatus();
817
- }
818
- /**
819
- * check if admin search is set
820
- * @access public
821
- * @return bool
822
- * @author Marius Strajeru <marius.strajeru@gmail.com>
823
- */
824
- public function getAdminSearch(){
825
- return !$this->getIsTree() && $this->getData('admin_search');
826
- }
827
- /**
828
- * get API xml for entity relations
829
- * @access public
830
- * @return string
831
- * @author Marius Strajeru <marius.strajeru@gmail.com>
832
- */
833
- public function getApiRelations(){
834
- $string = '';
835
- $prefix = "\t\t\t\t\t";
836
- $eol = "\n";
837
- $module = strtolower($this->getModule()->getModuleName());
838
- $entity = strtolower($this->getNameSingular());
839
- $entityLabelUc = ucfirst($this->getLabelSingular());
840
- $entityLabel = strtolower($this->getLabelSingular());
841
- if ($this->getLinkProduct()){
842
- $string .= $prefix. '<assignProduct translate="title" module="'.$module.'">'.$eol;
843
- $string .= $prefix."\t". '<title>Assign product to '.$entityLabelUc.'</title>'.$eol;
844
- $string .= $prefix."\t". '<acl>'.$module.'/'.$entity.'/update</acl>'.$eol;
845
- $string .= $prefix. '</assignProduct>'.$eol;
846
-
847
- $string .= $prefix. '<unassignProduct translate="title" module="'.$module.'">'.$eol;
848
- $string .= $prefix."\t". '<title>Remove product from '.$entityLabel.'}</title>'.$eol;
849
- $string .= $prefix."\t". '<acl>'.$module.'/'.$entity.'/update</acl>'.$eol;
850
- $string .= $prefix. '</unassignProduct>'.$eol;
851
- }
852
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
853
- foreach ($siblings as $sibling){
854
- $siblingName = strtolower($sibling->getNameSingular());
855
- $siblingNameUc = ucfirst($sibling->getNameSingular());
856
- $siblingLabel = strtolower($sibling->getLabelSingular());
857
-
858
- $string .= $prefix.'<assign'.$siblingNameUc.' translate="title" module="'.$module.'">'.$eol;
859
- $string .= $prefix."\t".'<title>Assign '.$siblingLabel.' to '.$entityLabel.'</title>'.$eol;
860
- $string .= $prefix."\t".'<acl>'.$module.'/'.$entity.'/update</acl>'.$eol;
861
- $string .= $prefix.'</assign'.$siblingNameUc.'>'.$eol;
862
-
863
- $string .= $prefix.'<unassign'.$siblingNameUc.' translate="title" module="'.$module.'">'.$eol;
864
- $string .= $prefix."\t".'<title>Remove '.$siblingLabel.' from '.$entityLabel.'</title>'.$eol;
865
- $string .= $prefix."\t".'<acl>'.$module.'/'.$entity.'/update</acl>'.$eol;
866
- $string .= $prefix.'</unassign'.$siblingNameUc.'>'.$eol;
867
- }
868
- $string .= "\t\t\t\t";
869
- return $string;
870
- }
871
- /**
872
- * get list of faults for API
873
- * @access public
874
- * @return string
875
- * @author Marius Strajeru <marius.strajeru@gmail.com>
876
- */
877
- public function getApiFaults(){
878
- $string = '';
879
- $prefix = "\t\t\t\t\t";
880
- $eol = "\n";
881
- $code = 105;
882
- $entity = strtolower($this->getNameSingular());
883
- $entityLabelUc = ucfirst($this->getLabelSingular());
884
- $entityLabel = strtolower($this->getLabelSingular());
885
- if ($this->getIsTree()){
886
- $string .= $prefix.'<not_moved>'.$eol;
887
- $string .= $prefix."\t".'<code>'.$code.'</code>'.$eol;
888
- $string .= $prefix."\t".'<message>'.$entityLabelUc.' not moved. Details in error message.</message>'.$eol;
889
- $string .= $prefix.'</not_moved>'.$eol;
890
- $code++;
891
- }
892
- if ($this->getLinkProduct()){
893
- $string .= $prefix.'<product_not_exists>'.$eol;
894
- $string .= $prefix."\t".'<code>'.$code.'</code>'.$eol;
895
- $string .= $prefix."\t".'<message>Product does not exist.</message>'.$eol;
896
- $string .= $prefix.'</product_not_exists>'.$eol;
897
- $code++;
898
- }
899
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
900
- foreach ($siblings as $sibling){
901
- $siblingName = strtolower($sibling->getNameSingular());
902
- $siblingNameUc = ucfirst($sibling->getNameSingular());
903
- $siblingLabel = strtolower($sibling->getLabelSingular());
904
- $siblingLabelUc = ucfirst($sibling->getLabelSingular());
905
-
906
- $string .= $prefix.'<'.$entity.'_'.$siblingName.'_not_exists>'.$eol;
907
- $string .= $prefix."\t".'<code>'.$code.'</code>'.$eol;
908
- $string .= $prefix."\t".'<message>'.$siblingLabelUc.' does not exist.</message>'.$eol;
909
- $string .= $prefix.'</'.$entity.'_'.$siblingName.'_not_exists>'.$eol;
910
- $code++;
911
- }
912
- $string .= "\t\t\t\t";
913
- return $string;
914
- }
915
- /**
916
- * get attributes format for wsdl
917
- * @access public
918
- * @param bool $wsi
919
- * @return string
920
- * @author Marius Strajeru <marius.strajeru@gmail.com>
921
- */
922
- public function getWsdlAttributes($wsi = false){
923
- $parents = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD);
924
- $padding = "\t\t\t\t\t";
925
- $content = '';
926
- foreach ($parents as $parent){
927
- $attr = Mage::getModel('modulecreator/attribute');
928
- $attr->setCode($parent->getNameSingular().'_id');
929
- $attr->setLabel($parent->getLabelSingular());
930
- $attr->setType('int');
931
- $content .= $padding.$attr->getWsdlFormat($wsi)."\n";
932
- }
933
- foreach ($this->getAttributes() as $attribute){
934
- $content .= $padding.$attribute->getWsdlFormat($wsi)."\n";
935
- }
936
- $simulated = $this->_getSimulatedAttributes(null, false);
937
- foreach ($simulated as $attr){
938
- if (!$attr->getIgnoreApi()){
939
- $content .= $padding.$attr->getWsdlFormat($wsi)."\n";
940
- }
941
- }
942
- return $content;
943
- }
944
- /**
945
- * get attributes format for wsi
946
- * @access public
947
- * @return string
948
- * @author Marius Strajeru <marius.strajeru@gmail.com>
949
- */
950
- public function getWsiAttributes(){
951
- return $this->getWsdlAttributes(true);
952
- }
953
- /**
954
- * get simulated attribtues
955
- * @access public
956
- * @param mixed $type
957
- * @param bool $ignoreSettings
958
- * @return array()
959
- * @author Marius Strajeru <marius.strajeru@gmail.com>
960
- */
961
- protected function _getSimulatedAttributes($type = null, $ignoreSettings = false){
962
- $attributes = array();
963
- if (is_null($type)){
964
- return array_merge(
965
- $this->_getSimulatedAttributes('url_rewrite', $ignoreSettings),
966
- $this->_getSimulatedAttributes('status', $ignoreSettings),
967
- $this->_getSimulatedAttributes('tree', $ignoreSettings),
968
- $this->_getSimulatedAttributes('rss', $ignoreSettings),
969
- $this->_getSimulatedAttributes('seo', $ignoreSettings)
970
- );
971
- }
972
- switch ($type){
973
- case 'url_rewrite':
974
- if ($this->getUrlRewrite() || $ignoreSettings){
975
- $attr = Mage::getModel('modulecreator/attribute');
976
- $attr->setCode('url_key');
977
- $attr->setLabel('URL key');
978
- $attr->setType('text');
979
- $attributes[] = $attr;
980
- }
981
- break;
982
- case 'status' :
983
- if($this->getAddStatus() || $ignoreSettings){
984
- $attr = Mage::getModel('modulecreator/attribute');
985
- $attr->setCode('status');
986
- $attr->setLabel('Status');
987
- $attr->setType('yesno');
988
- $attributes[] = $attr;
989
- }
990
- break;
991
- case 'tree' :
992
- if ($this->getIsTree() || $ignoreSettings){
993
- $attr = Mage::getModel('modulecreator/attribute');
994
- $attr->setCode('parent_id');
995
- $attr->setLabel('Parent id');
996
- $attr->setType('int');
997
- $attributes[] = $attr;
998
-
999
- $attr = Mage::getModel('modulecreator/attribute');
1000
- $attr->setCode('path');
1001
- $attr->setLabel('Path');
1002
- $attr->setType('text');
1003
- $attr->setIgnoreApi(true);
1004
- $attributes[] = $attr;
1005
-
1006
- $attr = Mage::getModel('modulecreator/attribute');
1007
- $attr->setCode('position');
1008
- $attr->setLabel('Position');
1009
- $attr->setType('int');
1010
- $attr->setIgnoreApi(true);
1011
- $attributes[] = $attr;
1012
-
1013
- $attr = Mage::getModel('modulecreator/attribute');
1014
- $attr->setCode('level');
1015
- $attr->setLabel('Level');
1016
- $attr->setType('int');
1017
- $attr->setIgnoreApi(true);
1018
- $attributes[] = $attr;
1019
-
1020
- $attr = Mage::getModel('modulecreator/attribute');
1021
- $attr->setCode('children_count');
1022
- $attr->setLabel('Children count');
1023
- $attr->setType('int');
1024
- $attr->setIgnoreApi(true);
1025
- $attributes[] = $attr;
1026
- }
1027
- break;
1028
- case 'rss':
1029
- if($this->getRss() || $ignoreSettings){
1030
- $attr = Mage::getModel('modulecreator/attribute');
1031
- $attr->setCode('in_rss');
1032
- $attr->setLabel('In RSS');
1033
- $attr->setType('yesno');
1034
- $attributes[] = $attr;
1035
- }
1036
- break;
1037
- case 'seo':
1038
- if ($this->getFrontendAddSeo() || $ignoreSettings){
1039
- $attr = Mage::getModel('modulecreator/attribute');
1040
- $attr->setCode('meta_title');
1041
- $attr->setLabel('Meta title');
1042
- $attr->setType('text');
1043
- $attributes[] = $attr;
1044
-
1045
- $attr = Mage::getModel('modulecreator/attribute');
1046
- $attr->setCode('meta_keywords');
1047
- $attr->setLabel('Meta keywords');
1048
- $attr->setType('textarea');
1049
- $attributes[] = $attr;
1050
-
1051
- $attr = Mage::getModel('modulecreator/attribute');
1052
- $attr->setCode('meta_description');
1053
- $attr->setLabel('Meta description');
1054
- $attr->setType('textarea');
1055
- $attributes[] = $attr;
1056
- }
1057
- break;
1058
- default:
1059
- break;
1060
- }
1061
- return $attributes;
1062
- }
1063
- /**
1064
- * get entity WSDL relation types
1065
- * @access public
1066
- * @param bool $wsi
1067
- * @return string
1068
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1069
- */
1070
- public function getWsdlRelationTypes($wsi = false){
1071
- $content = '';
1072
- $padding = "\t\t\t";
1073
- $mainTag = ($wsi) ? 'xsd:complexType':'complexType';
1074
- $subtag = ($wsi) ? 'xsd:sequence' : 'all';
1075
- $element = ($wsi) ? 'xsd:element' : 'element';
1076
- $eol = "\n";
1077
- $module = strtolower($this->getModule()->getModuleName());
1078
- $entity = $this->getNameSingular();
1079
- $entityUc = ucfirst($this->getNameSingular());
1080
- if ($this->getIsTree()){
1081
- $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'MoveEntity">'.$eol;
1082
- $content .= $padding."\t".'<'.$subtag.'>'.$eol;
1083
- $content .= $padding."\t".'<'.$element.' name="'.$entity.'_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1084
- $content .= $padding."\t".'<'.$element.' name="parent_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1085
- $content .= $padding."\t".'<'.$element.' name="after_id" type="xsd:string"'.((!$wsi)?' minOccurs="0"':'').' />'.$eol;
1086
- $content .= $padding."\t".'</'.$subtag.'>'.$eol;
1087
- $content .= $padding.'</'.$mainTag.'>'.$eol;
1088
- }
1089
-
1090
- if ($this->getLinkProduct()){
1091
- $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'AssignProductEntity">'.$eol;
1092
- $content .= $padding."\t".'<'.$subtag.'>'.$eol;
1093
- $content .= $padding."\t".'<'.$element.' name="'.$entity.'_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1094
- $content .= $padding."\t".'<'.$element.' name="product_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1095
- $content .= $padding."\t".'<'.$element.' name="position" type="xsd:string"'.((!$wsi)?' minOccurs="0"':'').' />'.$eol;
1096
- $content .= $padding."\t".'</'.$subtag.'>'.$eol;
1097
- $content .= $padding.'</'.$mainTag.'>'.$eol;
1098
-
1099
- $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'UnassignProductEntity">'.$eol;
1100
- $content .= $padding."\t".'<'.$subtag.'>'.$eol;
1101
- $content .= $padding."\t".'<'.$element.' name="'.$entity.'_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1102
- $content .= $padding."\t".'<'.$element.' name="product_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1103
- $content .= $padding."\t".'</'.$subtag.'>'.$eol;
1104
- $content .= $padding.'</'.$mainTag.'>'.$eol;
1105
- }
1106
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
1107
- foreach ($siblings as $sibling){
1108
- $siblingName = strtolower($sibling->getNameSingular());
1109
- $siblingNameUc = ucfirst($sibling->getNameSingular());
1110
- $siblingLabel = strtolower($sibling->getLabelSingular());
1111
-
1112
- $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'Assign'.$siblingNameUc.'Entity">'.$eol;
1113
- $content .= $padding."\t".'<'.$subtag.'>'.$eol;
1114
- $content .= $padding."\t".'<'.$element.' name="'.$entity.'_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1115
- $content .= $padding."\t".'<'.$element.' name="'.$siblingName.'_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1116
- $content .= $padding."\t".'<'.$element.' name="position" type="xsd:string"'.((!$wsi)?' minOccurs="0"':'').' />'.$eol;
1117
- $content .= $padding."\t".'</'.$subtag.'>'.$eol;
1118
- $content .= $padding.'</'.$mainTag.'>'.$eol;
1119
-
1120
- $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'Unassign'.$siblingNameUc.'Entity">'.$eol;
1121
- $content .= $padding."\t".'<'.$subtag.'>'.$eol;
1122
- $content .= $padding."\t".'<'.$element.' name="'.$entity.'_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1123
- $content .= $padding."\t".'<'.$element.' name="'.$siblingName.'_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1124
- $content .= $padding."\t".'</'.$subtag.'>'.$eol;
1125
- $content .= $padding.'</'.$mainTag.'>'.$eol;
1126
- }
1127
- $content .= "\t\t";
1128
- return $content;
1129
- }
1130
- /**
1131
- * get entity WSI relation types
1132
- * @access public
1133
- * @return string
1134
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1135
- */
1136
- public function getWsiRelationTypes(){
1137
- return $this->getWsdlRelationTypes(true);
1138
- }
1139
-
1140
- /**
1141
- * get entity WSDL messages for relations
1142
- * @access public
1143
- * @return string
1144
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1145
- */
1146
- public function getWsdlMessages(){
1147
- $content = '';
1148
- $padding = "\t\t";
1149
- $eol = "\n";
1150
- $module = strtolower($this->getModule()->getModuleName());
1151
- $entity = $this->getNameSingular();
1152
- $entityUc = ucfirst($this->getNameSingular());
1153
- if ($this->getIsTree()){
1154
- $content .= $padding.'<message name="'.$module.$entityUc.'MoveRequest">'.$eol;
1155
- $content .= $padding."\t".'<part name="sessionId" type="xsd:string" />'.$eol;
1156
- $content .= $padding."\t".'<part name="'.$entity.'Id" type="xsd:string" />'.$eol;
1157
- $content .= $padding."\t".'<part name="parentId" type="xsd:string" />'.$eol;
1158
- $content .= $padding."\t".'<part name="afterId" type="xsd:string" />'.$eol;
1159
- $content .= $padding.'</message>'.$eol;
1160
-
1161
- $content .= $padding.'<message name="'.$module.$entityUc.'MoveResponse">'.$eol;
1162
- $content .= $padding."\t".'<part name="id" type="xsd:boolean"/>'.$eol;
1163
- $content .= $padding.'</message>'.$eol;
1164
- }
1165
- if ($this->getLinkProduct()){
1166
- $content .= $padding.'<message name="'.$module.$entityUc.'AssignProductRequest">'.$eol;
1167
- $content .= $padding."\t".'<part name="sessionId" type="xsd:string" />'.$eol;
1168
- $content .= $padding."\t".'<part name="'.$entity.'Id" type="xsd:string" />'.$eol;
1169
- $content .= $padding."\t".'<part name="productId" type="xsd:string" />'.$eol;
1170
- $content .= $padding."\t".'<part name="position" type="xsd:string" />'.$eol;
1171
- $content .= $padding.'</message>'.$eol;
1172
- $content .= $padding.'<message name="'.$module.$entityUc.'AssignProductResponse">'.$eol;
1173
- $content .= $padding."\t".'<part name="result" type="xsd:boolean" />'.$eol;
1174
- $content .= $padding.'</message>'.$eol;
1175
- $content .= $padding.'<message name="'.$module.$entityUc.'UnassignProductRequest">'.$eol;
1176
- $content .= $padding."\t".'<part name="sessionId" type="xsd:string" />'.$eol;
1177
- $content .= $padding."\t".'<part name="'.$entity.'Id" type="xsd:string" />'.$eol;
1178
- $content .= $padding."\t".'<part name="productId" type="xsd:string" />'.$eol;
1179
- $content .= $padding.'</message>'.$eol;
1180
- $content .= $padding.'<message name="'.$module.$entityUc.'UnassignProductResponse">'.$eol;
1181
- $content .= $padding."\t".'<part name="result" type="xsd:boolean" />'.$eol;
1182
- $content .= $padding.'</message>'.$eol;
1183
- }
1184
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
1185
- foreach ($siblings as $sibling){
1186
- $siblingName = strtolower($sibling->getNameSingular());
1187
- $siblingNameUc = ucfirst($sibling->getNameSingular());
1188
- $siblingLabel = strtolower($sibling->getLabelSingular());
1189
-
1190
- $content .= $padding.'<message name="'.$module.$entityUc.'Assign'.$siblingNameUc.'Request">'.$eol;
1191
- $content .= $padding."\t".'<part name="sessionId" type="xsd:string" />'.$eol;
1192
- $content .= $padding."\t".'<part name="'.$entity.'Id" type="xsd:string" />'.$eol;
1193
- $content .= $padding."\t".'<part name="'.$siblingName.'Id" type="xsd:string" />'.$eol;
1194
- $content .= $padding."\t".'<part name="position" type="xsd:string" />'.$eol;
1195
- $content .= $padding.'</message>'.$eol;
1196
- $content .= $padding.'<message name="'.$module.$entityUc.'Assign'.$siblingNameUc.'Response">'.$eol;
1197
- $content .= $padding."\t".'<part name="result" type="xsd:boolean" />'.$eol;
1198
- $content .= $padding.'</message>'.$eol;
1199
- $content .= $padding.'<message name="'.$module.$entityUc.'Unassign'.$siblingNameUc.'Request">'.$eol;
1200
- $content .= $padding."\t".'<part name="sessionId" type="xsd:string" />'.$eol;
1201
- $content .= $padding."\t".'<part name="'.$entity.'Id" type="xsd:string" />'.$eol;
1202
- $content .= $padding."\t".'<part name="'.$siblingName.'Id" type="xsd:string" />'.$eol;
1203
- $content .= $padding.'</message>'.$eol;
1204
- $content .= $padding.'<message name="'.$module.$entityUc.'Unassign'.$siblingNameUc.'Response">'.$eol;
1205
- $content .= $padding."\t".'<part name="result" type="xsd:boolean" />'.$eol;
1206
- $content .= $padding.'</message>'.$eol;
1207
- }
1208
- $content .= "\t";
1209
- return $content;
1210
- }
1211
- /**
1212
- * get entity WSDL port type for relations
1213
- * @access public
1214
- * @param bool $wsi
1215
- * @return string
1216
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1217
- */
1218
- public function getWsdlPortTypeRelation($wsi = false){
1219
- $content = '';
1220
- $padding = "\t\t";
1221
- $eol = "\n";
1222
- $module = strtolower($this->getModule()->getModuleName());
1223
- $entity = $this->getNameSingular();
1224
- $entityUc = ucfirst($this->getNameSingular());
1225
- $label = strtolower($this->getLabelSingular());
1226
-
1227
- $tagPrefix = ($wsi) ? 'wsdl:':'';
1228
-
1229
- if ($this->getIsTree()){
1230
- $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'Move">'.$eol;
1231
- $content .= $padding."\t".'<'.$tagPrefix.'documentation>Move '.$label.' in tree</'.$tagPrefix.'documentation>'.$eol;
1232
- $content .= $padding."\t".'<'.$tagPrefix.'input message="typens:'.$module.$entityUc.'MoveRequest" />'.$eol;
1233
- $content .= $padding."\t".'<'.$tagPrefix.'output message="typens:'.$module.$entityUc.'MoveResponse" />'.$eol;
1234
- $content .= $padding.'</'.$tagPrefix.'operation>'.$eol;
1235
-
1236
- }
1237
-
1238
- if ($this->getLinkProduct()){
1239
- $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'AssignProduct">'.$eol;
1240
- $content .= $padding."\t".'<'.$tagPrefix.'documentation>Assign product to '.$label.'</'.$tagPrefix.'documentation>'.$eol;
1241
- $content .= $padding."\t".'<'.$tagPrefix.'input message="typens:'.$module.$entityUc.'AssignProductRequest" />'.$eol;
1242
- $content .= $padding."\t".'<'.$tagPrefix.'output message="typens:'.$module.$entityUc.'AssignProductResponse" />'.$eol;
1243
- $content .= $padding.'</'.$tagPrefix.'operation>'.$eol;
1244
- $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'UnassignProduct">'.$eol;
1245
- $content .= $padding."\t".'<'.$tagPrefix.'documentation>Remove product from '.$label.'</'.$tagPrefix.'documentation>'.$eol;
1246
- $content .= $padding."\t".'<'.$tagPrefix.'input message="typens:'.$module.$entityUc.'UnassignProductRequest" />'.$eol;
1247
- $content .= $padding."\t".'<'.$tagPrefix.'output message="typens:'.$module.$entityUc.'UnassignProductResponse" />'.$eol;
1248
- $content .= $padding.'</'.$tagPrefix.'operation>'.$eol;
1249
- }
1250
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
1251
- foreach ($siblings as $sibling){
1252
- $siblingName = strtolower($sibling->getNameSingular());
1253
- $siblingNameUc = ucfirst($sibling->getNameSingular());
1254
- $siblingLabel = strtolower($sibling->getLabelSingular());
1255
-
1256
- $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'Assign'.$siblingNameUc.'">'.$eol;
1257
- $content .= $padding."\t".'<'.$tagPrefix.'documentation>Assign '.$siblingLabel.' to '.$label.'</'.$tagPrefix.'documentation>'.$eol;
1258
- $content .= $padding."\t".'<'.$tagPrefix.'input message="typens:'.$module.$entityUc.'Assign'.$siblingNameUc.'Request" />'.$eol;
1259
- $content .= $padding."\t".'<'.$tagPrefix.'output message="typens:'.$module.$entityUc.'Assign'.$siblingNameUc.'Response" />'.$eol;
1260
- $content .= $padding.'</'.$tagPrefix.'operation>'.$eol;
1261
- $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'Unassign'.$siblingNameUc.'">'.$eol;
1262
- $content .= $padding."\t".'<'.$tagPrefix.'documentation>Remove '.$siblingLabel.' from '.$label.'</'.$tagPrefix.'documentation>'.$eol;
1263
- $content .= $padding."\t".'<'.$tagPrefix.'input message="typens:'.$module.$entityUc.'Unassign'.$siblingNameUc.'Request" />'.$eol;
1264
- $content .= $padding."\t".'<'.$tagPrefix.'output message="typens:'.$module.$entityUc.'Unassign'.$siblingNameUc.'Response" />'.$eol;
1265
- $content .= $padding.'</'.$tagPrefix.'operation>'.$eol;
1266
-
1267
- }
1268
- $content .="\t";
1269
- return $content;
1270
- }
1271
- /**
1272
- * get entity WSI port type for relations
1273
- * @access public
1274
- * @return string
1275
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1276
- */
1277
- public function getWsiPortTypeRelation(){
1278
- return $this->getWsdlPortTypeRelation(true);
1279
- }
1280
- /**
1281
- * get WSDL relation binding
1282
- * @access public
1283
- * @return string
1284
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1285
- */
1286
- public function getWsdlRelationBinding(){
1287
- $content = '';
1288
- $padding = "\t\t";
1289
- $eol = "\n";
1290
- $module = strtolower($this->getModule()->getModuleName());
1291
- $entity = $this->getNameSingular();
1292
- $entityUc = ucfirst($this->getNameSingular());
1293
- $label = strtolower($this->getLabelSingular());
1294
- if ($this->getIsTree()){
1295
- $content .= $padding.'<operation name="'.$module.$entityUc.'Move">'.$eol;
1296
- $content .= $padding."\t".'<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />'.$eol;
1297
- $content .= $padding."\t".'<input>'.$eol;
1298
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1299
- $content .= $padding."\t".'</input>'.$eol;
1300
- $content .= $padding."\t".'<output>'.$eol;
1301
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1302
- $content .= $padding."\t".'</output>'.$eol;
1303
- $content .= $padding.'</operation>'.$eol;
1304
- }
1305
- if ($this->getLinkProduct()){
1306
- $content .= $padding.'<operation name="'.$module.$entityUc.'AssignProduct">'.$eol;
1307
- $content .= $padding."\t".'<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />'.$eol;
1308
- $content .= $padding."\t".'<input>'.$eol;
1309
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1310
- $content .= $padding."\t".'</input>'.$eol;
1311
- $content .= $padding."\t".'<output>'.$eol;
1312
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1313
- $content .= $padding."\t".'</output>'.$eol;
1314
- $content .= $padding.'</operation>'.$eol;
1315
-
1316
- $content .= $padding.'<operation name="'.$module.$entityUc.'UnassignProduct">'.$eol;
1317
- $content .= $padding."\t".'<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />'.$eol;
1318
- $content .= $padding."\t".'<input>'.$eol;
1319
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1320
- $content .= $padding."\t".'</input>'.$eol;
1321
- $content .= $padding."\t".'<output>'.$eol;
1322
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1323
- $content .= $padding."\t".'</output>'.$eol;
1324
- $content .= $padding.'</operation>'.$eol;
1325
- }
1326
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
1327
- foreach ($siblings as $sibling){
1328
- $siblingName = strtolower($sibling->getNameSingular());
1329
- $siblingNameUc = ucfirst($sibling->getNameSingular());
1330
- $siblingLabel = strtolower($sibling->getLabelSingular());
1331
-
1332
- $content .= $padding.'<operation name="'.$module.$entityUc.'Assign'.$siblingNameUc.'">'.$eol;
1333
- $content .= $padding."\t".'<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />'.$eol;
1334
- $content .= $padding."\t".'<input>'.$eol;
1335
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1336
- $content .= $padding."\t".'</input>'.$eol;
1337
- $content .= $padding."\t".'<output>'.$eol;
1338
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1339
- $content .= $padding."\t".'</output>'.$eol;
1340
- $content .= $padding.'</operation>'.$eol;
1341
-
1342
- $content .= $padding.'<operation name="'.$module.$entityUc.'Unassign'.$siblingNameUc.'">'.$eol;
1343
- $content .= $padding."\t".'<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />'.$eol;
1344
- $content .= $padding."\t".'<input>'.$eol;
1345
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1346
- $content .= $padding."\t".'</input>'.$eol;
1347
- $content .= $padding."\t".'<output>'.$eol;
1348
- $content .= $padding."\t\t".'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1349
- $content .= $padding."\t".'</output>'.$eol;
1350
- $content .= $padding.'</operation>'.$eol;
1351
- }
1352
- $content .= "\t";
1353
- return $content;
1354
- }
1355
- /**
1356
- * get WSI relation binding
1357
- * @access public
1358
- * @return string
1359
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1360
- */
1361
- public function getWsiRelationBinding(){
1362
- $content = '';
1363
- $padding = "\t\t";
1364
- $eol = "\n";
1365
- $module = strtolower($this->getModule()->getModuleName());
1366
- $entity = $this->getNameSingular();
1367
- $entityUc = ucfirst($this->getNameSingular());
1368
- $label = strtolower($this->getLabelSingular());
1369
-
1370
- if ($this->getIsTree()){
1371
- $content .= $padding.'<wsdl:operation name="'.$module.$entityUc.'Move">'.$eol;
1372
- $content .= $padding."\t".'<soap:operation soapAction="" />'.$eol;
1373
- $content .= $padding."\t".'<wsdl:input>'.$eol;
1374
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1375
- $content .= $padding."\t".'</wsdl:input>'.$eol;
1376
- $content .= $padding."\t".'<wsdl:output>'.$eol;
1377
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1378
- $content .= $padding."\t".'</wsdl:output>'.$eol;
1379
- $content .= $padding.'</wsdl:operation>'.$eol;
1380
- }
1381
-
1382
- if ($this->getLinkProduct()){
1383
- $content .= $padding.'<wsdl:operation name="'.$module.$entityUc.'AssignProduct">'.$eol;
1384
- $content .= $padding."\t".'<soap:operation soapAction="" />'.$eol;
1385
- $content .= $padding."\t".'<wsdl:input>'.$eol;
1386
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1387
- $content .= $padding."\t".'</wsdl:input>'.$eol;
1388
- $content .= $padding."\t".'<wsdl:output>'.$eol;
1389
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1390
- $content .= $padding."\t".'</wsdl:output>'.$eol;
1391
- $content .= $padding.'</wsdl:operation>'.$eol;
1392
-
1393
- $content .= $padding.'<wsdl:operation name="'.$module.$entityUc.'UnassignProduct">'.$eol;
1394
- $content .= $padding."\t".'<soap:operation soapAction="" />'.$eol;
1395
- $content .= $padding."\t".'<wsdl:input>'.$eol;
1396
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1397
- $content .= $padding."\t".'</wsdl:input>'.$eol;
1398
- $content .= $padding."\t".'<wsdl:output>'.$eol;
1399
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1400
- $content .= $padding."\t".'</wsdl:output>'.$eol;
1401
- $content .= $padding.'</wsdl:operation>'.$eol;
1402
- }
1403
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
1404
- foreach ($siblings as $sibling){
1405
- $siblingName = strtolower($sibling->getNameSingular());
1406
- $siblingNameUc = ucfirst($sibling->getNameSingular());
1407
- $siblingLabel = strtolower($sibling->getLabelSingular());
1408
-
1409
- $content .= $padding.'<wsdl:operation name="'.$module.$entityUc.'Assign'.$siblingNameUc.'">'.$eol;
1410
- $content .= $padding."\t".'<soap:operation soapAction="" />'.$eol;
1411
- $content .= $padding."\t".'<wsdl:input>'.$eol;
1412
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1413
- $content .= $padding."\t".'</wsdl:input>'.$eol;
1414
- $content .= $padding."\t".'<wsdl:output>'.$eol;
1415
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1416
- $content .= $padding."\t".'</wsdl:output>'.$eol;
1417
- $content .= $padding.'</wsdl:operation>'.$eol;
1418
-
1419
- $content .= $padding.'<wsdl:operation name="'.$module.$entityUc.'Unssign'.$siblingNameUc.'">'.$eol;
1420
- $content .= $padding."\t".'<soap:operation soapAction="" />'.$eol;
1421
- $content .= $padding."\t".'<wsdl:input>'.$eol;
1422
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1423
- $content .= $padding."\t".'</wsdl:input>'.$eol;
1424
- $content .= $padding."\t".'<wsdl:output>'.$eol;
1425
- $content .= $padding."\t\t".'<soap:body use="literal" />'.$eol;
1426
- $content .= $padding."\t".'</wsdl:output>'.$eol;
1427
- $content .= $padding.'</wsdl:operation>'.$eol;
1428
- }
1429
- $content .= "\t";
1430
- return $content;
1431
- }
1432
- /**
1433
- * get entity WSI relation param types
1434
- * @access public
1435
- * @return string
1436
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1437
- */
1438
- public function getWsiRelationParamTypes(){
1439
- $content = '';
1440
- $padding = "\t\t\t";
1441
- $eol = "\n";
1442
- $module = strtolower($this->getModule()->getModuleName());
1443
- $entity = $this->getNameSingular();
1444
- $entityUc = ucfirst($this->getNameSingular());
1445
- $label = strtolower($this->getLabelSingular());
1446
-
1447
- if ($this->getIsTree()){
1448
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'MoveRequestParam">'.$eol;
1449
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1450
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1451
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />'.$eol;
1452
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="'.$entity.'Id" type="xsd:string" />'.$eol;
1453
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="parent_d" type="xsd:string" />'.$eol;
1454
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="0" maxOccurs="1" name="after_id" type="xsd:string" />'.$eol;
1455
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1456
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1457
- $content .= $padding.'</xsd:element>'.$eol;
1458
-
1459
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'AssignProductResponseParam">'.$eol;
1460
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1461
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1462
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />'.$eol;
1463
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1464
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1465
- $content .= $padding.'</xsd:element>'.$eol;
1466
- }
1467
-
1468
- if ($this->getLinkProduct()){
1469
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'AssignProductRequestParam">'.$eol;
1470
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1471
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1472
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />'.$eol;
1473
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="'.$entity.'Id" type="xsd:string" />'.$eol;
1474
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="productId" type="xsd:string" />'.$eol;
1475
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="0" maxOccurs="1" name="position" type="xsd:string" />'.$eol;
1476
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1477
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1478
- $content .= $padding.'</xsd:element>'.$eol;
1479
-
1480
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'AssignProductResponseParam">'.$eol;
1481
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1482
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1483
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />'.$eol;
1484
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1485
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1486
- $content .= $padding.'</xsd:element>'.$eol;
1487
-
1488
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'UnassignProductRequestParam">'.$eol;
1489
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1490
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1491
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />'.$eol;
1492
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="'.$entity.'Id" type="xsd:string" />'.$eol;
1493
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="productId" type="xsd:string" />'.$eol;
1494
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1495
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1496
- $content .= $padding.'</xsd:element>'.$eol;
1497
-
1498
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'UnassignProductResponseParam">'.$eol;
1499
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1500
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1501
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />'.$eol;
1502
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1503
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1504
- $content .= $padding.'</xsd:element>'.$eol;
1505
- }
1506
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
1507
- foreach ($siblings as $sibling){
1508
- $siblingName = strtolower($sibling->getNameSingular());
1509
- $siblingNameUc = ucfirst($sibling->getNameSingular());
1510
- $siblingLabel = strtolower($sibling->getLabelSingular());
1511
-
1512
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'Assign'.$siblingNameUc.'RequestParam">'.$eol;
1513
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1514
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1515
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />'.$eol;
1516
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="'.$entity.'Id" type="xsd:string" />'.$eol;
1517
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="'.$siblingName.'Id" type="xsd:string" />'.$eol;
1518
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="0" maxOccurs="1" name="position" type="xsd:string" />'.$eol;
1519
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1520
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1521
- $content .= $padding.'</xsd:element>'.$eol;
1522
-
1523
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'Assign'.$siblingNameUc.'ResponseParam">'.$eol;
1524
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1525
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1526
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />'.$eol;
1527
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1528
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1529
- $content .= $padding.'</xsd:element>'.$eol;
1530
-
1531
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'Unassign'.$siblingNameUc.'RequestParam">'.$eol;
1532
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1533
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1534
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />'.$eol;
1535
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="'.$entity.'Id" type="xsd:string" />'.$eol;
1536
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="'.$siblingName.'Id" type="xsd:string" />'.$eol;
1537
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1538
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1539
- $content .= $padding.'</xsd:element>'.$eol;
1540
-
1541
- $content .= $padding.'<xsd:element name="'.$module.$entityUc.'Unassign'.$siblingNameUc.'ResponseParam">'.$eol;
1542
- $content .= $padding."\t".'<xsd:complexType>'.$eol;
1543
- $content .= $padding."\t\t".'<xsd:sequence>'.$eol;
1544
- $content .= $padding."\t\t\t".'<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />'.$eol;
1545
- $content .= $padding."\t\t".'</xsd:sequence>'.$eol;
1546
- $content .= $padding."\t".'</xsd:complexType>'.$eol;
1547
- $content .= $padding.'</xsd:element>'.$eol;
1548
- }
1549
- $content .= "\t\t";
1550
- return $content;
1551
- }
1552
- /**
1553
- * get entity WSI relation messages
1554
- * @access public
1555
- * @return string
1556
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1557
- */
1558
- public function getWsiRelationMessages(){
1559
- $content = '';
1560
- $padding = "\t";
1561
- $eol = "\n";
1562
- $module = strtolower($this->getModule()->getModuleName());
1563
- $entity = $this->getNameSingular();
1564
- $entityUc = ucfirst($this->getNameSingular());
1565
- $label = strtolower($this->getLabelSingular());
1566
-
1567
- if ($this->getIsTree()){
1568
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'MoveRequest">'.$eol;
1569
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'MoveRequestParam" />'.$eol;
1570
- $content .= $padding.'</wsdl:message>'.$eol;
1571
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'MoveResponse">'.$eol;
1572
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'MoveResponseParam" />'.$eol;
1573
- $content .= $padding.'</wsdl:message>'.$eol;
1574
- }
1575
-
1576
- if ($this->getLinkProduct()){
1577
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'AssignProductRequest">'.$eol;
1578
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'AssignProductRequestParam" />'.$eol;
1579
- $content .= $padding.'</wsdl:message>'.$eol;
1580
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'AssignProductResponse">'.$eol;
1581
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'AssignProductResponseParam" />'.$eol;
1582
- $content .= $padding.'</wsdl:message>'.$eol;
1583
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'UnassignProductRequest">'.$eol;
1584
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'UnassignProductRequestParam" />'.$eol;
1585
- $content .= $padding.'</wsdl:message>'.$eol;
1586
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'UnassignProductResponse">'.$eol;
1587
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'UnassignProductResponseParam" />'.$eol;
1588
- $content .= $padding.'</wsdl:message>'.$eol;
1589
- }
1590
- $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING);
1591
- foreach ($siblings as $sibling){
1592
- $siblingName = strtolower($sibling->getNameSingular());
1593
- $siblingNameUc = ucfirst($sibling->getNameSingular());
1594
- $siblingLabel = strtolower($sibling->getLabelSingular());
1595
-
1596
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'Assign'.$siblingNameUc.'Request">'.$eol;
1597
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'Assign'.$siblingNameUc.'RequestParam" />'.$eol;
1598
- $content .= $padding.'</wsdl:message>'.$eol;
1599
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'Assign'.$siblingNameUc.'Response">'.$eol;
1600
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'Assign'.$siblingNameUc.'ResponseParam" />'.$eol;
1601
- $content .= $padding.'</wsdl:message>'.$eol;
1602
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'Unassign'.$siblingNameUc.'Request">'.$eol;
1603
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'Unassign'.$siblingNameUc.'RequestParam" />'.$eol;
1604
- $content .= $padding.'</wsdl:message>'.$eol;
1605
- $content .= $padding.'<wsdl:message name="'.$module.$entityUc.'Unassign'.$siblingNameUc.'Response">'.$eol;
1606
- $content .= $padding."\t".'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.'Unassign'.$siblingNameUc.'ResponseParam" />'.$eol;
1607
- $content .= $padding.'</wsdl:message>'.$eol;
1608
- }
1609
- return $content;
1610
- }
1611
- /**
1612
- * get additional api xml
1613
- * @access public
1614
- * @return string
1615
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1616
- */
1617
- public function getApiAdditional(){
1618
- $content = $this->getApiTree();
1619
- $content .= $this->getApiRelations();
1620
- return $content;
1621
- }
1622
- /**
1623
- * get additional api xml for tree entities
1624
- * @access public
1625
- * @return string
1626
- * @author Marius Strajeru <marius.strajeru@gmail.com>
1627
- */
1628
- public function getApiTree(){
1629
- $content = '';
1630
- $prefix = "\t\t\t\t\t";
1631
- $eol = "\n";
1632
- if ($this->getIsTree()){
1633
- $module = strtolower($this->getModule()->getModuleName());
1634
- $entity = strtolower($this->getNameSingular());
1635
- $entityLabelUc = ucfirst($this->getLabelSingular());
1636
- $entityLabel = strtolower($this->getLabelSingular());
1637
- $entitiesLabel = strtolower($this->getLabelPlural());
1638
- $content = $prefix.'<level translate="title" module="'.$entity.'">'.$eol;
1639
- $content .= $prefix."\t".'<title>Retrieve one level of '.$entitiesLabel.'</title>'.$eol;
1640
- $content .= $prefix."\t".'<acl>'.$module.'/'.$entity.'/info</acl>'.$eol;
1641
- $content .= $prefix.'</level>'.$eol;
1642
- $content .= $prefix.'<move translate="title" module="catalog">'.$eol;
1643
- $content .= $prefix."\t".'<title>Move '.$entityLabel.' in tree</title>'.$eol;
1644
- $content .= $prefix."\t".'<acl>'.$module.'/'.$entity.'/move</acl>'.$eol;
1645
- $content .= $prefix.'</move>'.$eol;
1646
- }
1647
- return $content;
1648
- }
1649
- public function getAdditionalApiAcl(){
1650
- $content = '';
1651
- $prefix = "\t\t\t\t\t\t";
1652
- $eol = "\n";
1653
- if ($this->getIsTree()){
1654
- $module = strtolower($this->getModule()->getModuleName());
1655
- $entity = strtolower($this->getNameSingular());
1656
- $entityLabelUc = ucfirst($this->getLabelSingular());
1657
- $entityLabel = strtolower($this->getLabelSingular());
1658
- $content .= $prefix.'<move translate="title" module="'.$module.'">'.$eol;
1659
- $content .= $prefix."\t".'<title>Move</title>'.$eol;
1660
- $content .= $prefix.'</move>'.$eol;
1661
- }
1662
- $content .= "\t\t\t\t\t";
1663
- return $content;
1664
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1665
  }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
  * entity model
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Entity
26
+ extends Ultimate_ModuleCreator_Model_Abstract {
27
+ /**
28
+ * reference to type instance
29
+ * @var null
30
+ */
31
+ protected $_typeInstance = null;
32
+ /**
33
+ * entity code
34
+ * @var string
35
+ */
36
+ protected $_entityCode = 'umc_entity';
37
+ /**
38
+ * entity attributes
39
+ * @var array
40
+ */
41
+ protected $_attributes = array();
42
+ /**
43
+ * entity module
44
+ * @var Ultimate_ModuleCreator_Model_Module
45
+ */
46
+ protected $_module = null;
47
+ /**
48
+ * attribute that behaves as name
49
+ * @var Ultimate_ModuleCreator_Model_Attribute
50
+ */
51
+ protected $_nameAttribute = null;
52
+ /**
53
+ * remember if attributes were prepared
54
+ * @var bool
55
+ */
56
+ protected $_preparedAttributes = null;
57
+ /**
58
+ * related entities
59
+ * @var array()
60
+ */
61
+ protected $_relatedEntities = array();
62
+ /**
63
+ * placeholders for replacing in source files
64
+ * @var mixed
65
+ */
66
+ protected $_placeholders = null;
67
+ /**
68
+ * placeholders for sibling entities
69
+ * @var mixed
70
+ */
71
+ protected $_placeholdersAsSibling = null;
72
+ /**
73
+ * set the entity module
74
+ * @access public
75
+ * @param Ultimate_ModuleCreator_Model_Module $module
76
+ * @return Ultimate_ModuleCreator_Model_Entity
77
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
78
+ */
79
+ public function setModule(Ultimate_ModuleCreator_Model_Module $module){
80
+ $this->_module = $module;
81
+ return $this;
82
+ }
83
+ /**
84
+ * get the entity module
85
+ * @access public
86
+ * @return Ultimate_ModuleCreator_Model_Module
87
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
88
+ */
89
+ public function getModule(){
90
+ return $this->_module;
91
+ }
92
+ /**
93
+ * add new attribute
94
+ * @access public
95
+ * @param Ultimate_ModuleCreator_Model_Attribute $attribute
96
+ * @return Ultimate_ModuleCreator_Model_Entity
97
+ * @throws Ultimate_ModuleCreator_Exception
98
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
99
+ */
100
+ public function addAttribute(Ultimate_ModuleCreator_Model_Attribute $attribute){
101
+ Mage::dispatchEvent('umc_entity_add_attribute_before', array('attribute'=>$attribute, 'entity'=>$this));
102
+ $attribute->setEntity($this);
103
+ if (isset($this->_attributes[$attribute->getCode()])){
104
+ throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('An attribute with the code "%s" already exists for entity "%s"', $attribute->getCode(), $this->getNameSingular()));
105
+ }
106
+ $this->_preparedAttributes = false;
107
+ $this->_attributes[$attribute->getCode()] = $attribute;
108
+ if ($attribute->getIsName()){
109
+ if (!$attribute->getIsAllowedAsName()){
110
+ $attributeTypes = Mage::helper('modulecreator')->getNameAttributeTypes(true);
111
+ throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('An attribute that acts as name must have one of the types "%s".', implode(', ', $attributeTypes)));
112
+ }
113
+ $attribute->setUserDefined(false);
114
+ $this->_nameAttribute = $attribute;
115
+ }
116
+ if ($attribute->getEditor()){
117
+ $this->setEditor(true);
118
+ }
119
+ if ($attribute->getType() == 'image'){
120
+ $this->setHasImage(true);
121
+ }
122
+ if ($attribute->getType() == 'file'){
123
+ $this->setHasFile(true);
124
+ }
125
+ if ($attribute->getType() == 'country'){
126
+ $this->setHasCountry(true);
127
+ }
128
+ if ($attribute->getIsMultipleSelect()) {
129
+ $this->setHasMultipleSelect(true);
130
+ }
131
+ Mage::dispatchEvent('umc_entity_add_attribute_after', array('attribute'=>$attribute, 'entity'=>$this));
132
+ return $this;
133
+ }
134
+ /**
135
+ * prepare attributes
136
+ * @access protected
137
+ * @return Ultimate_ModuleCreator_Model_Entity
138
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
139
+ */
140
+ protected function _prepareAttributes(){
141
+ if ($this->_preparedAttributes){
142
+ return $this;
143
+ }
144
+ $attributesByPosition = array();
145
+ foreach ($this->_attributes as $key=>$attribute){
146
+ $attributesByPosition[$attribute->getPosition()][] = $attribute;
147
+ }
148
+ ksort($attributesByPosition);
149
+ $attributes = array();
150
+ foreach ($attributesByPosition as $position=>$attributeList){
151
+ foreach ($attributeList as $attribute){
152
+ $attributes[$attribute->getCode()] = $attribute;
153
+ }
154
+ }
155
+ $this->_attributes = $attributes;
156
+ Mage::dispatchEvent('umc_entity_prepare_attributes', array('entity'=>$this));
157
+ $this->_preparedAttributes = true;
158
+ return $this;
159
+ }
160
+ /**
161
+ * ge the entity attributes
162
+ * @access public
163
+ * @return Ultimate_ModuleCreator_Model_Attribute[]
164
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
165
+ */
166
+ public function getAttributes(){
167
+ if (!$this->_preparedAttributes){
168
+ $this->_prepareAttributes();
169
+ }
170
+ return $this->_attributes;
171
+ }
172
+ /**
173
+ * entity to xml
174
+ * @access public
175
+ * @param array $arrAttributes
176
+ * @param string $rootName
177
+ * @param bool $addOpenTag
178
+ * @param bool $addCdata
179
+ * @return string
180
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
181
+ */
182
+ public function toXml(array $arrAttributes = array(), $rootName = 'entity', $addOpenTag=false, $addCdata=false){
183
+ $xml = '';
184
+ if ($addOpenTag) {
185
+ $xml.= '<?xml version="1.0" encoding="UTF-8"?>'.$this->getEol();
186
+ }
187
+ if (!empty($rootName)) {
188
+ $xml.= '<'.$rootName.'>'.$this->getEol();
189
+ }
190
+ $start = '';
191
+ $end = '';
192
+ if ($addCdata){
193
+ $start = '<![CDATA[';
194
+ $end = ']]>';
195
+ }
196
+ $xml .= parent::toXml($this->getXmlAttributes(), '', false, $addCdata);
197
+ $xml .= '<attributes>'.$this->getEol();
198
+ foreach ($this->getAttributes() as $attribute){
199
+ $xml .= $attribute->toXml(array(), 'attribute', false, $addCdata);
200
+ }
201
+ $xml .= '</attributes>'.$this->getEol();
202
+ if (!empty($rootName)) {
203
+ $xml.= '</'.$rootName.'>'.$this->getEol();
204
+ }
205
+ return $xml;
206
+ }
207
+ /**
208
+ * get magic function code for the name attribute
209
+ * @access public
210
+ * @return string
211
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
212
+ */
213
+ public function getNameAttributeMagicCode(){
214
+ $nameAttribute = $this->getNameAttribute();
215
+ if ($nameAttribute){
216
+ $entityNameMagicCode = $nameAttribute->getMagicMethodCode();
217
+ }
218
+ else{
219
+ $entityNameMagicCode = 'Name';
220
+ }
221
+ return $entityNameMagicCode;
222
+ }
223
+ /**
224
+ * get the name attribute
225
+ * @access public
226
+ * @return mixed(null|Ultimate_ModuleCreator_Model_Attribute)
227
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
228
+ */
229
+ public function getNameAttribute(){
230
+ return $this->_nameAttribute;
231
+ }
232
+
233
+ /**
234
+ * get the attribute code for the name attribute
235
+ * @access public
236
+ * @return string
237
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
238
+ */
239
+ public function getNameAttributeCode(){
240
+ return $this->_nameAttribute->getCode();
241
+ }
242
+ /**
243
+ * get the attribute label for the name attribute
244
+ * @access public
245
+ * @return string
246
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
247
+ */
248
+ public function getNameAttributeLabel(){
249
+ return $this->getNameAttribute()->getLabel();
250
+ }
251
+ /**
252
+ * check if the entity has file attributes
253
+ * @access public
254
+ * @return bool
255
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
256
+ */
257
+ public function getHasFile(){
258
+ return $this->getTypeInstance()->getHasFile();
259
+ }
260
+ /**
261
+ * check if the entity has image attributes
262
+ * @access public
263
+ * @return bool
264
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
265
+ */
266
+ public function getHasImage(){
267
+ return $this->getTypeInstance()->getHasImage();
268
+ }
269
+ /**
270
+ * check if the entity has upload attributes
271
+ * @access public
272
+ * @return bool
273
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
274
+ */
275
+ public function getHasUpload(){
276
+ return $this->getHasFile() || $this->getHasImage();
277
+ }
278
+ /**
279
+ * get the first image attribute code
280
+ * @access public
281
+ * @return string
282
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
283
+ */
284
+ public function getFirstImageField(){
285
+ foreach ($this->getAttributes() as $attribute){
286
+ if ($attribute->getType() == 'image'){
287
+ return $attribute->getCode();
288
+ }
289
+ }
290
+ return '';
291
+ }
292
+ /**
293
+ * get the attribute name for plural
294
+ * @access public
295
+ * @param bool $lower
296
+ * @return string
297
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
298
+ */
299
+ public function getNamePlural($lower = false){
300
+ $plural = $this->getData('name_plural');
301
+ if ($plural == $this->getNameSingular()){
302
+ if ($plural == ""){
303
+ return "";
304
+ }
305
+ $plural = $this->getNameSingular().'s';
306
+ }
307
+ if ($lower){
308
+ $plural = strtolower($plural);
309
+ }
310
+ return $plural;
311
+ }
312
+ /**
313
+ * check if frontend list files must be created
314
+ * @access public
315
+ * @return bool
316
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
317
+ */
318
+ public function getCreateList(){
319
+ return $this->getCreateFrontend() && $this->getData('create_list');
320
+ }
321
+ /**
322
+ * get list template
323
+ * @access public
324
+ * @return stromg
325
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
326
+ */
327
+ public function getListTemplate(){
328
+ if ($this->getCreateList()){
329
+ return $this->getData('list_template');
330
+ }
331
+ return '';
332
+ }
333
+ /**
334
+ * check if frontend view files must be created
335
+ * @access public
336
+ * @return bool
337
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
338
+ */
339
+ public function getCreateView(){
340
+ return $this->getCreateFrontend() && $this->getData('create_view');
341
+ }
342
+ /**
343
+ * get list template
344
+ * @access public
345
+ * @return stromg
346
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
347
+ */
348
+ public function getViewTemplate(){
349
+ if ($this->getCreateView()){
350
+ return $this->getData('view_template');
351
+ }
352
+ return '';
353
+ }
354
+ /**
355
+ * check if widget list files must be created
356
+ * @access public
357
+ * @return bool
358
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
359
+ */
360
+ public function getWidget(){
361
+ return $this->getCreateFrontend() && $this->getData('widget');
362
+ }
363
+ /**
364
+ * check if SEO attributes should be added
365
+ * @access public
366
+ * @return bool
367
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
368
+ */
369
+ public function getAddSeo(){
370
+ return $this->getCreateView() && $this->getData('add_seo');
371
+ }
372
+ /**
373
+ * check if SEO attributes should be added
374
+ * @access public
375
+ * @return bool
376
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
377
+ */
378
+ public function getRss(){
379
+ return $this->getCreateFrontend() && $this->getData('rss');
380
+ }
381
+ /**
382
+ * check if url rewrite shoul be added
383
+ * @access public
384
+ * @return bool
385
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
386
+ */
387
+ public function getUrlRewrite(){
388
+ return $this->getCreateView() && $this->getData('url_rewrite');
389
+ }
390
+ /**
391
+ * get url prefix
392
+ * @access public
393
+ * @return string
394
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
395
+ */
396
+ public function getUrlPrefix(){
397
+ if ($this->getUrlRewrite()){
398
+ return $this->getData('url_prefix');
399
+ }
400
+ return '';
401
+ }
402
+ /**
403
+ * get url suffix
404
+ * @access public
405
+ * @return string
406
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
407
+ */
408
+ public function getUrlSuffix(){
409
+ if ($this->getUrlRewrite()){
410
+ return $this->getData('url_suffix');
411
+ }
412
+ return '';
413
+ }
414
+ /**
415
+ * check if products are listed in the entity view page
416
+ * @access public
417
+ * @return bool
418
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
419
+ */
420
+ public function getShowProducts(){
421
+ return $this->getLinkProduct() && $this->getCreateFrontend() && $this->getData('show_products');
422
+ }
423
+ /**
424
+ * check if entity list is shown on product page
425
+ * @access public
426
+ * @return bool
427
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
428
+ */
429
+ public function getShowOnProduct(){
430
+ return $this->getLinkProduct() && $this->getData('show_on_product');
431
+ }
432
+ /**
433
+ * check if entity list is shown on category page
434
+ * @access public
435
+ * @return bool
436
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
437
+ */
438
+ public function getShowOnCategory(){
439
+ return $this->getLinkCategory() && $this->getData('show_on_category');
440
+ }
441
+ /**
442
+ * add related entities
443
+ * @access public
444
+ * @param string $type
445
+ * @param Ultimate_ModuleCreator_Model_Entity $entity
446
+ * @return Ultimate_ModuleCreator_Model_Entity
447
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
448
+ */
449
+ public function addRelatedEntity($type, $entity){
450
+ $this->_relatedEntities[$type][] = $entity;
451
+ return $this;
452
+ }
453
+ /**
454
+ * get the related entities
455
+ * @access public
456
+ * @param mixed $type
457
+ * @return array()
458
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
459
+ */
460
+ public function getRelatedEntities($type = null){
461
+ if (is_null($type)){
462
+ return $this->_relatedEntities;
463
+ }
464
+ if (isset($this->_relatedEntities[$type])){
465
+ return $this->_relatedEntities[$type];
466
+ }
467
+ return array();
468
+ }
469
+ /**
470
+ * check if entity does not behave as tree
471
+ * @access public
472
+ * @return bool
473
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
474
+ */
475
+ public function getNotIsTree(){
476
+ return !$this->getIsTree();
477
+ }
478
+ /**
479
+ * check if entity does not have url rewrites
480
+ * @access public
481
+ * @return bool
482
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
483
+ */
484
+ public function getNotUrlRewrite(){
485
+ return !$this->getUrlRewrite();
486
+ }
487
+ /**
488
+ * check if entity is EAV
489
+ * @access public
490
+ * @return bool
491
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
492
+ */
493
+ public function getIsEav(){
494
+ return $this->getType() == Ultimate_ModuleCreator_Model_Entity_Type_Abstract::TYPE_EAV;
495
+ }
496
+ /**
497
+ * check if entity is Flat
498
+ * @access public
499
+ * @return bool
500
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
501
+ */
502
+ public function getIsFlat(){
503
+ return $this->getType() == Ultimate_ModuleCreator_Model_Entity_Type_Abstract::TYPE_FLAT;
504
+ }
505
+
506
+ /**
507
+ * get the entity type instance
508
+ * @access public
509
+ * @return Ultimate_ModuleCreator_Model_Entity_Type_Abstract
510
+ * @throws Ultimate_ModuleCreator_Exception
511
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
512
+ */
513
+ public function getTypeInstance(){
514
+ if (is_null($this->_typeInstance)) {
515
+ $type = $this->getType();
516
+ $types = Mage::helper('modulecreator')->getEntityTypes(false);
517
+ if (isset($types[$type])) {
518
+ $this->_typeInstance = Mage::getModel((string)$types[$type]->type_model);
519
+ }
520
+ else {
521
+ throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('Entity "%s" type is not valid', $type));
522
+ }
523
+ $this->_typeInstance->setEntity($this);
524
+ }
525
+ return $this->_typeInstance;
526
+ }
527
+
528
+ /**
529
+ * check if entity has default config settings
530
+ * @access public
531
+ * @return bool
532
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
533
+ */
534
+ public function getHasConfigDefaults(){
535
+ return $this->getCreateFrontend();
536
+ }
537
+ /**
538
+ * check if entity is linked to core entities (product, category)
539
+ * @access public
540
+ * @return bool
541
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
542
+ */
543
+ public function getLinkCore(){
544
+ return $this->getLinkProduct() || $this->getLinkCategory();
545
+ }
546
+
547
+ /**
548
+ * get entity placeholders
549
+ * @access public
550
+ * @param null $param
551
+ * @return array|mixed|null|string
552
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
553
+ */
554
+ public function getPlaceholders($param = null){
555
+ if (is_null($this->_placeholders)){
556
+ $this->_placeholders = array();
557
+ $this->_placeholders['{{entity_default_config}}'] = $this->getDefaultConfig();
558
+ $this->_placeholders['{{entity}}'] = $this->getNameSingular(true);
559
+ $this->_placeholders['{{Entity}}'] = ucfirst($this->getNameSingular(true));
560
+ $this->_placeholders['{{ENTITY}}'] = strtoupper($this->getNameSingular());
561
+ $this->_placeholders['{{EntityLabel}}'] = ucfirst($this->getLabelSingular());
562
+ $this->_placeholders['{{entityLabel}}'] = strtolower($this->getLabelSingular());
563
+ $this->_placeholders['{{EntitiesLabel}}'] = ucfirst($this->getLabelPlural());
564
+ $this->_placeholders['{{entitiesLabel}}'] = strtolower($this->getLabelPlural());
565
+ $this->_placeholders['{{entityCollectionAttributes}}'] = $this->getCollectionAttributes();
566
+ $this->_placeholders['{{entityAdminJoin}}'] = $this->getAdminJoin();
567
+ $this->_placeholders['{{prepareColumnsHeader}}'] = $this->getPrepareColumnsHeader();
568
+ $this->_placeholders['{{nameAttributeGridEav}}'] = $this->getNameAttributeGridEav();
569
+ $this->_placeholders['{{nameAttributeCode}}'] = $this->getNameAttributeCode();
570
+ $this->_placeholders['{{nameAttributeLabel}}'] = $this->getNameAttributeLabel();
571
+ $this->_placeholders['{{entities}}'] = $this->getNamePlural(true);
572
+ $this->_placeholders['{{Entities}}'] = ucfirst($this->getNamePlural(true));
573
+ $this->_placeholders['{{EntityNameMagicCode}}'] = $this->getNameAttributeMagicCode();
574
+ $this->_placeholders['{{attributeDdlSql}}'] = $this->getAttributesDdlSql();
575
+ $this->_placeholders['{{referenceHead}}'] = $this->getReferenceHeadLayout();
576
+ $this->_placeholders['{{EntityViewRelationLayout}}'] = $this->getRelationLayoutXml();
577
+ $this->_placeholders['{{listLayout}}'] = $this->getListTemplate();
578
+ $this->_placeholders['{{viewLayout}}'] = $this->getViewTemplate();
579
+ $this->_placeholders['{{entityHtmlLink}}'] = $this->getHtmlLink();
580
+ $this->_placeholders['{{EntityViewAttributes}}'] = $this->getViewAttributesHtml();
581
+ $this->_placeholders['{{EntityViewWidgetAttributes}}'] = $this->getViewWidgetAttributesHtml();
582
+ $this->_placeholders['{{systemAttributes}}'] = $this->getSystemAttributes();
583
+ $this->_placeholders['{{entityApiAdditional}}'] = $this->getApiAdditional();
584
+ $this->_placeholders['{{entityApiFaults}}'] = $this->getApiFaults();
585
+ $this->_placeholders['{{entityAdditionalApiAcl}}'] = $this->getAdditionalApiAcl();
586
+ $this->_placeholders['{{entityWsdlAttributes}}'] = $this->getWsdlAttributes();
587
+ $this->_placeholders['{{entityWsdlAttributesForAdd}}'] = $this->getWsdlAttributes(false, true);
588
+ $this->_placeholders['{{entityWsdlRelationTypes}}'] = $this->getWsdlRelationTypes();
589
+ $this->_placeholders['{{entityWsdlPortTypeRelation}}'] = $this->getWsdlPortTypeRelation();
590
+ $this->_placeholders['{{entityWsdlRelationBinding}}'] = $this->getWsdlRelationBinding();
591
+ $this->_placeholders['{{entityWsiRelationParamTypes}}'] = $this->getWsiRelationParamTypes();
592
+ $this->_placeholders['{{entityWsiRelationMessages}}'] = $this->getWsiRelationMessages();
593
+ $this->_placeholders['{{entityWsiPortTypeRelation}}'] = $this->getWsiPortTypeRelation();
594
+ $this->_placeholders['{{entityWsiRelationBinding}}'] = $this->getWsiRelationBinding();
595
+ $this->_placeholders['{{entityWsiAttributes}}'] = $this->getWsiAttributes();
596
+ $this->_placeholders['{{entityWsiAttributesForAdd}}'] = $this->getWsiAttributes(true);
597
+ $this->_placeholders['{{entityWsiRelationTypes}}'] = $this->getWsiRelationTypes();
598
+ $this->_placeholders['{{entityWsdlMessages}}'] = $this->getWsdlMessages();
599
+ $this->_placeholders['{{fksDdl}}'] = $this->getParentEntitiesFksDdl();
600
+ $this->_placeholders['{{selectedMenuPath}}'] = $this->getSelectedMenuPath();
601
+ $this->_placeholders['{{entityAttributesSetup}}'] = $this->getAttributesSetup();
602
+ $this->_placeholders['{{ResourceModelParent}}'] = $this->getResourceModelParent();
603
+ $this->_placeholders['{{ResourceCollectionParent}}'] = $this->getResourceCollectionModelParent();
604
+ $this->_placeholders['{{RelationsResourceTables}}'] = $this->getResourceRelationsTables();
605
+ $this->_placeholders['{{RelationsResourceTablesDeclare}}'] = $this->getResourceRelationsTablesDeclare();
606
+ $this->_placeholders['{{adminIndexContent}}'] = $this->getAdminIndexLayoutContent();
607
+ $this->_placeholders['{{EntityParentModel}}'] = $this->getEntityParentModel();
608
+ $this->_placeholders['{{entityTableAlias}}'] = $this->getEntityTableAlias();
609
+ $this->_placeholders['{{additionalPrepareCollection}}'] = $this->getAdditionalPrepareCollection();
610
+ $this->_placeholders['{{entityEditLayoutLeft}}'] = $this->getEditLayoutLeft();
611
+ $this->_placeholders['{{entityLayoutAdditional}}'] = $this->getEditLayoutAdditional();
612
+ $this->_placeholders['{{productAttributeCode}}'] = $this->getProductAttributeCode();
613
+ $this->_placeholders['{{categoryAttributeCode}}'] = $this->getCategoryAttributeCode();
614
+ $this->_placeholders['{{entityProductAttributeScope}}'] = $this->getProductAttributeScopeLabel();
615
+ $this->_placeholders['{{entityCategoryAttributeScope}}']= $this->getCategoryAttributeScopeLabel();
616
+ $this->_placeholders['{{productAttributeGroup}}'] = $this->getProductAttributeGroupLabel();
617
+ $this->_placeholders['{{categoryAttributeGroup}}'] = $this->getCategoryAttributeGroupLabel();
618
+ $this->_placeholders['{{beforeSaveParam}}'] = $this->getBeforeSaveParam();
619
+ $this->_placeholders['{{EntityAttributeSetId}}'] = $this->getEntityAttributeSetId();
620
+ $this->_placeholders['{{filterMethod}}'] = $this->getFilterMethod();
621
+ $this->_placeholders['{{multipleSelectConvert}}'] = $this->getMultipleSelectConvert();
622
+ $this->_placeholders['{{toOptionAddition}}'] = $this->getToOptionAddition();
623
+ $this->_placeholders['{{multiselectMethods}}'] = $this->getMultiselectMethods();
624
+ $this->_placeholders['{{nameHtml}}'] = $this->getNameHtml();
625
+ $this->_placeholders['{{isTree}}'] = (int)$this->getIsTree();
626
+ $this->_placeholders['{{commentFilterIndexPrefix}}'] = $this->getCommentFilterIndexPrefix();
627
+ $this->_placeholders['{{entityApiAdditionalSettings}}'] = $this->getApiAdditionalSettings();
628
+ $this->_placeholders['{{subEntitiesAcl}}'] = $this->getSubEntitiesAcl();
629
+ $this->_placeholders['{{position}}'] = $this->getPosition();
630
+ $this->_placeholders['{{entityApiResourcesAlias}}'] = $this->getApiResourcesAlias();
631
+ $this->_placeholders['{{entityApiResourcesAliasV2}}'] = $this->getApiResourcesAliasV2();
632
+ $this->_placeholders['{{defaultApiAttributes}}'] = $this->getDefaultApiAttributes();
633
+ $this->_placeholders['{{filterEntityDates}}'] = $this->getFilterDates();
634
+ $this->_placeholders['{{filterEntityDates3}}'] = $this->getFilterDates(3);
635
+
636
+ $eventObject = new Varien_Object(
637
+ array(
638
+ 'placeholders' => $this->_placeholders
639
+ )
640
+ );
641
+ Mage::dispatchEvent('umc_entity_placeholdrers', array('event_object'=>$eventObject));
642
+ $this->_placeholders = $eventObject->getPlaceholders();
643
+ }
644
+ if (is_null($param)){
645
+ return $this->_placeholders;
646
+ }
647
+ if (isset($this->_placeholders[$param])){
648
+ return $this->_placeholders[$param];
649
+ }
650
+ return '';
651
+ }
652
+
653
+ /**
654
+ * get placeholders as sibling
655
+ * @access public
656
+ * @param null $param
657
+ * @return array|mixed|null|string
658
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
659
+ */
660
+ public function getPlaceholdersAsSibling($param = null){
661
+ if (is_null($this->_placeholdersAsSibling)){
662
+ $this->_placeholdersAsSibling = array();
663
+ $this->_placeholdersAsSibling['{{sibling_default_config}}'] = $this->getDefaultConfig();
664
+ $this->_placeholdersAsSibling['{{sibling}}'] = $this->getNameSingular(true);
665
+ $this->_placeholdersAsSibling['{{Sibling}}'] = ucfirst($this->getNameSingular(true));
666
+ $this->_placeholdersAsSibling['{{SIBLING}}'] = strtoupper($this->getNameSingular());
667
+ $this->_placeholdersAsSibling['{{SiblingLabel}}'] = ucfirst($this->getLabelSingular());
668
+ $this->_placeholdersAsSibling['{{siblingLabel}}'] = strtolower($this->getLabelSingular());
669
+ $this->_placeholdersAsSibling['{{SiblingsLabel}}'] = ucfirst($this->getLabelPlural());
670
+ $this->_placeholdersAsSibling['{{siblingsLabel}}'] = $this->getLabelPlural(true);
671
+ $this->_placeholdersAsSibling['{{siblingCollectionAttributes}}'] = $this->getCollectionAttributes();
672
+ $this->_placeholdersAsSibling['{{siblingAdminJoin}}'] = $this->getAdminJoin();
673
+ $this->_placeholdersAsSibling['{{siblingColumnsHeader}}'] = $this->getPrepareColumnsHeader();
674
+ $this->_placeholdersAsSibling['{{siblingNameAttributeGridEav}}'] = $this->getNameAttributeGridEav();
675
+ $this->_placeholdersAsSibling['{{siblingNameAttributeCode}}'] = $this->getNameAttributeCode();
676
+ $this->_placeholdersAsSibling['{{siblingNameAttributeLabel}}'] = $this->getNameAttributeLabel();
677
+ $this->_placeholdersAsSibling['{{siblings}}'] = strtolower($this->getNamePlural());
678
+ $this->_placeholdersAsSibling['{{Siblings}}'] = ucfirst($this->getNamePlural(true));
679
+ $this->_placeholdersAsSibling['{{SiblingNameMagicCode}}'] = $this->getNameAttributeMagicCode();
680
+ $this->_placeholdersAsSibling['{{SiblingViewRelationLayout}}'] = $this->getRelationLayoutXml();
681
+ $this->_placeholdersAsSibling['{{siblingListLayout}}'] = $this->getListTemplate();
682
+ $this->_placeholdersAsSibling['{{siblingViewLayout}}'] = $this->getViewTemplate();
683
+ $this->_placeholdersAsSibling['{{SiblingListItem}}'] = $this->getHtmlLink();
684
+ $this->_placeholdersAsSibling['{{siblingNameAttribute}}'] = $this->getNameAttributeCode();
685
+ $this->_placeholdersAsSibling['{{siblingAdditionalPrepareCollection}}'] = $this->getAdditionalPrepareCollection();
686
+ $this->_placeholdersAsSibling['{{siblingTableAlias}}'] = $this->getEntityTableAlias();
687
+
688
+ $eventObject = new Varien_Object(
689
+ array(
690
+ 'placeholders' => $this->_placeholdersAsSibling
691
+ )
692
+ );
693
+ Mage::dispatchEvent('umc_entity_placeholdrers_as_sibling', array('event_object'=>$eventObject));
694
+ $this->_placeholdersAsSibling = $eventObject->getPlaceholders();
695
+ }
696
+ if (is_null($param)){
697
+ return $this->_placeholdersAsSibling;
698
+ }
699
+ if (isset($this->_placeholdersAsSibling[$param])){
700
+ return $this->_placeholdersAsSibling[$param];
701
+ }
702
+ return '';
703
+ }
704
+
705
+ /**
706
+ * get default config settings
707
+ * @access public
708
+ * @return string
709
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
710
+ */
711
+ public function getDefaultConfig(){
712
+ if (!$this->getHasConfigDefaults()){
713
+ return '';
714
+ }
715
+ $padding3 = $this->getPadding(3);
716
+ $padding = $this->getPadding();
717
+ $eol = $this->getEol();
718
+
719
+ $text = '<'.$this->getNameSingular().'>'.$eol;
720
+ if ($this->getCreateFrontend()){
721
+ $text.= $padding3.$padding.'<breadcrumbs>1</breadcrumbs>'.$eol;
722
+ }
723
+ if ($this->getUrlRewrite() && $this->getUrlPrefix()){
724
+ $text.= $padding3.$padding.'<url_prefix>'.$this->getUrlPrefix().'</url_prefix>'.$eol;
725
+ }
726
+ if ($this->getUrlRewrite() && $this->getUrlSuffix()){
727
+ $text.= $padding3.$padding.'<url_suffix>'.$this->getUrlSuffix().'</url_suffix>'.$eol;
728
+ }
729
+ if ($this->getAllowComment()){
730
+ $text.= $padding3.$padding.'<allow_comment>1</allow_comment>'.$eol;
731
+ }
732
+ if ($this->getRss()){
733
+ $text.= $padding3.$padding.'<rss>1</rss>'.$eol;
734
+ }
735
+ if ($this->getAddSeo()){
736
+ $text.= $padding3.$padding.'<meta_title>'.$this->getLabelPlural().'</meta_title>'.$eol;
737
+ }
738
+ if ($this->getIsTree() && $this->getCreateFrontend()){
739
+ $text.= $padding3.$padding.'<tree>1</tree>'.$eol;
740
+ $text.= $padding3.$padding.'<recursion>0</recursion>'.$eol;
741
+ }
742
+ $text .= $padding3.'</'.$this->getNameSingular().'>'.$eol;
743
+ return $text;
744
+ }
745
+
746
+ /**
747
+ * get xml for add product event
748
+ * @access public
749
+ * @return string
750
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
751
+ */
752
+ public function getAddBlockToProductEvent(){
753
+ $text = '';
754
+ if ($this->getLinkProduct()){
755
+ $ns = $this->getNamespace(true);
756
+ $eol = $this->getEol();
757
+ $text = $this->getPadding(5).'<'.$ns.'_'.$this->getModule()->getLowerModuleName().'_'.$this->getNameSingular(true).'>'.$eol;
758
+ $text .= $this->getPadding(6).'<type>singleton</type>'.$eol;
759
+ $text .= $this->getPadding(6).'<class>'.$ns.'_'.$this->getModule()->getLowerModuleName().'/adminhtml_observer</class>'.$eol;
760
+ $text .= $this->getPadding(6).'<method>add'.ucfirst(strtolower($this->getNameSingular())).'Block</method>'.$eol;
761
+ $text .= $this->getPadding(5).'</'.$ns.'_'.$this->getModule()->getLowerModuleName().'_'.$this->getNameSingular(true).'>'.$eol;
762
+ }
763
+ return $text;
764
+ }
765
+ /**
766
+ * get xml for add product save after event
767
+ * @access public
768
+ * @return string
769
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
770
+ */
771
+ public function getProductSaveAfterEvent(){
772
+ $text = '';
773
+ if ($this->getLinkProduct()){
774
+ $ns = strtolower($this->getModule()->getNamespace());
775
+ $eol = $this->getEol();
776
+ $text = $this->getPadding(5).'<'.$ns.'_'.$this->getModule()->getLowerModuleName().'_'.$this->getNameSingular(true).'>'.$eol;
777
+ $text .= $this->getPadding(6).'<type>singleton</type>'.$eol;
778
+ $text .= $this->getPadding(6).'<class>'.$ns.'_'.$this->getModule()->getLowerModuleName().'/adminhtml_observer</class>'.$eol;
779
+ $text .= $this->getPadding(6).'<method>save'.ucfirst(strtolower($this->getNameSingular())).'Data</method>'.$eol;
780
+ $text .= $this->getPadding(5).'</'.$ns.'_'.$this->getModule()->getLowerModuleName().'_'.$this->getNameSingular(true).'>'.$eol;
781
+ }
782
+ return $text;
783
+ }
784
+ /**
785
+ * get xml for add can load ext js
786
+ * @access public
787
+ * @return string
788
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
789
+ */
790
+ public function getCanLoadExtJsEvent(){
791
+ $text = '';
792
+ if ($this->getLinkProduct() && $this->getIsTree()){
793
+ $eol = $this->getEol();
794
+ $ns = strtolower($this->getModule()->getNamespace());
795
+ $text = $this->getPadding(5).'<'.$ns.'_'.$this->getModule()->getLowerModuleName().'_'.$this->getNameSingular(true).'>'.$eol;
796
+ $text .= $this->getPadding(6).'<type>singleton</type>'.$eol;
797
+ $text .= $this->getPadding(6).'<class>'.$ns.'_'.$this->getModule()->getLowerModuleName().'/adminhtml_observer</class>'.$eol;
798
+ $text .= $this->getPadding(6).'<method>setCanLoadExtJs</method>'.$eol;
799
+ $text .= $this->getPadding(5).'</'.$ns.'_'.$this->getModule()->getLowerModuleName().'_'.$this->getNameSingular(true).'>'.$eol;
800
+ }
801
+ return $text;
802
+ }
803
+
804
+ /**
805
+ * get xml for admin menu
806
+ * @access public
807
+ * @param $padding
808
+ * @return string
809
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
810
+ */
811
+ public function getMenu($padding){
812
+ $extension = $this->getModule()->getExtensionName(true);
813
+ $module = $this->getModule()->getLowerModuleName();
814
+ $title = ucwords($this->getLabelSingular());
815
+ $entity = strtolower($this->getNameSingular());
816
+ $action = $module.'_'.$entity;
817
+ $sortOrder = $this->getPosition();
818
+ $eol = $this->getEol();
819
+
820
+ $text = $this->getPadding($padding).'<'.$entity.' translate="title" module="'.$extension.'">'.$eol;
821
+ $text .= $this->getPadding($padding + 1).'<title>'.$title.'</title>'.$eol;
822
+ $text .= $this->getPadding($padding + 1).'<action>adminhtml/'.$action.'</action>'.$eol;
823
+ $text .= $this->getPadding($padding + 1).'<sort_order>'.$this->getPosition().'</sort_order>'.$eol;
824
+ $text .= $this->getPadding($padding).'</'.$entity.'>'.$eol;
825
+ if ($this->getAllowComment()){
826
+ $text .= $this->getPadding($padding).'<'.$entity.'_comments translate="title" module="'.$extension.'">'.$eol;
827
+ $text .= $this->getPadding($padding + 1).'<title>Manage '.$title.' Comments</title>'.$eol;
828
+ $text .= $this->getPadding($padding + 1).'<action>adminhtml/'.$action.'_comment</action>'.$eol;
829
+ $text .= $this->getPadding($padding + 1).'<sort_order>'.($this->getPosition() + 4).'</sort_order>'.$eol;
830
+ $text .= $this->getPadding($padding).'</'.$entity.'_comments>'.$eol;
831
+ }
832
+
833
+ $text .= $this->getTypeInstance()->getAdditionalMenu($padding);
834
+ return $text;
835
+
836
+ }
837
+
838
+ /**
839
+ * get xml for acl
840
+ * @access public
841
+ * @param $padding
842
+ * @return string
843
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
844
+ */
845
+ public function getMenuAcl($padding){
846
+ $extension = $this->getModule()->getExtensionName(true);
847
+ $module = $this->getModule()->getLowerModuleName();
848
+ $title = ucwords($this->getLabelSingular());
849
+ $entity = $this->getNameSingular(true);
850
+ $action = $module.'_'.$entity;
851
+ $sortOrder = $this->getPosition();
852
+ $eol = $this->getEol();
853
+
854
+ $text = $this->getPadding($padding).'<'.$entity.' translate="title" module="'.$extension.'">'.$eol;
855
+ $text .= $this->getPadding($padding + 1).'<title>'.$title.'</title>'.$eol;
856
+ $text .= $this->getPadding($padding + 1).'<sort_order>'.$this->getPosition().'</sort_order>'.$eol;
857
+ $text .= $this->getPadding($padding).'</'.$entity.'>'.$eol;
858
+
859
+ if ($this->getAllowComment()){
860
+ $text .= $this->getPadding($padding).'<'.$entity.'_comments translate="title" module="'.$extension.'">'.$eol;
861
+ $text .= $this->getPadding($padding + 1).'<title>Manage '.$title.' Comments</title>'.$eol;
862
+ $text .= $this->getPadding($padding + 1).'<sort_order>'.($this->getPosition() + 5).'</sort_order>'.$eol;
863
+ $text .= $this->getPadding($padding).'</'.$entity.'_comments>'.$eol;
864
+ }
865
+ $text .= $this->getTypeInstance()->getAdditionalMenuAcl($padding);
866
+ return $text;
867
+
868
+ }
869
+
870
+ /**
871
+ * get attributes that need to be added in the admin grid collection
872
+ * @access public
873
+ * @return string
874
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
875
+ */
876
+ public function getCollectionAttributes(){
877
+ return $this->getTypeInstance()->getCollectionAttributes();
878
+ }
879
+ /**
880
+ * get join with admin - for the admin grid
881
+ * @access public
882
+ * @return string
883
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
884
+ */
885
+ public function getAdminJoin(){
886
+ return $this->getTypeInstance()->getAdminJoin();
887
+ }
888
+ /**
889
+ * code above the prepare columns
890
+ * @access public
891
+ * @return string
892
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
893
+ */
894
+ public function getPrepareColumnsHeader(){
895
+ return $this->getTypeInstance()->getPrepareColumnsHeader();
896
+ }
897
+ /**
898
+ * name attribute in grid
899
+ * @access public
900
+ * @return string
901
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
902
+ */
903
+ public function getNameAttributeGridEav(){
904
+ return $this->getTypeInstance()->getNameAttributeGridEav();
905
+ }
906
+
907
+ /**
908
+ * check if the frontend list block can be created
909
+ * @access public
910
+ * @return bool
911
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
912
+ */
913
+ public function getCanCreateListBlock(){
914
+ if ($this->getCreateList()){
915
+ return true;
916
+ }
917
+ if ($this->getShowOnProduct()){
918
+ return true;
919
+ }
920
+ if ($this->getShowOnCategory()){
921
+ return true;
922
+ }
923
+ //check for siblings with frontend view
924
+ $related = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
925
+ foreach ($related as $r){
926
+ if ($r->getCreateView()){
927
+ return true;
928
+ }
929
+ }
930
+ //check for parents with frontend view
931
+ $related = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD);
932
+ foreach ($related as $r){
933
+ if ($r->getCreateView()){
934
+ return true;
935
+ }
936
+ }
937
+ return false;
938
+ }
939
+ /**
940
+ * get ddl text for attributes
941
+ * @access public
942
+ * @return bool
943
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
944
+ */
945
+ public function getAttributesDdlSql(){
946
+ $padding = $this->getPadding();
947
+ $eol = $this->getEol();
948
+ $content = '';
949
+ $content .= $this->getParentEntitiesFkAttributes($padding, true);
950
+ if ($this->getIsFlat()){
951
+ foreach ($this->getAttributes() as $attribute){
952
+ $content .= $padding.$attribute->getDdlSqlColumn().$eol;
953
+ }
954
+ }
955
+ if ($this->getIsFlat()) {
956
+ $simulated = $this->getSimulatedAttributes(null, false);
957
+ }
958
+ elseif ($this->getIsTree()) {
959
+ $simulated = $this->getSimulatedAttributes('tree', false);
960
+ }
961
+ else {
962
+ $simulated = array();
963
+ }
964
+ foreach ($simulated as $attr){
965
+ $content .= $padding.$attr->getDdlSqlColumn().$eol;
966
+ }
967
+ return substr($content,0, strlen($content) - strlen($eol));
968
+ }
969
+
970
+ /**
971
+ * get foreign key columns
972
+ * @access public
973
+ * @param $padding
974
+ * @return string
975
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
976
+ */
977
+ public function getParentEntitiesFkAttributes($padding){
978
+ if ($this->getIsEav()) {
979
+ return '';
980
+ }
981
+ $parents = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD);
982
+ $content = '';
983
+ foreach ($parents as $parent){
984
+ $attr = Mage::getModel('modulecreator/attribute');
985
+ $attr->setCode($parent->getPlaceholders('{{entity}}').'_id');
986
+ $attr->setLabel($parent->getPlaceholders('{{EntityLabel}}'). ' ID');
987
+ $attr->setType('int');
988
+ $content .= $padding.$attr->getDdlSqlColumn()."\n";
989
+ }
990
+ return $content;
991
+ }
992
+
993
+ /**
994
+ * get simulated attributes
995
+ * @access public
996
+ * @param mixed $type
997
+ * @param bool $ignoreSettings
998
+ * @param array $except
999
+ * @return array()
1000
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1001
+ */
1002
+ public function getSimulatedAttributes($type = null, $ignoreSettings = false, $except = array()){
1003
+ $attributes = array();
1004
+ $namespace = $this->getNamespace(true);
1005
+ if (is_null($type)){
1006
+ $types = array('status', 'url_rewrite', 'tree', 'rss', 'seo', 'comment');
1007
+ $attributes = array();
1008
+ foreach ($types as $type){
1009
+ if (!in_array($type, $except)){
1010
+ $attributes = array_merge($attributes, $this->getSimulatedAttributes($type, $ignoreSettings));
1011
+ }
1012
+ }
1013
+ return $attributes;
1014
+ }
1015
+ switch ($type){
1016
+ case 'status':
1017
+ $attr = Mage::getModel('modulecreator/attribute');
1018
+ $attr->setCode('status');
1019
+ $attr->setLabel('Enabled');
1020
+ $attr->setType('yesno');
1021
+ $attributes[] = $attr;
1022
+ break;
1023
+ case 'url_rewrite':
1024
+ if ($this->getUrlRewrite() || $ignoreSettings){
1025
+ $attr = Mage::getModel('modulecreator/attribute');
1026
+ $attr->setCode('url_key');
1027
+ $attr->setLabel('URL key');
1028
+ $attr->setType('text');
1029
+ $module = $this->getModule()->getLowerModuleName();
1030
+ $entity = $this->getNameSingular(true);
1031
+ $attr->setForcedSetupBackend($namespace.'_'.$module.'/'.$entity.'_attribute_backend_urlkey');
1032
+ $attributes[] = $attr;
1033
+ }
1034
+ break;
1035
+ case 'tree' :
1036
+ if ($this->getIsTree() || $ignoreSettings){
1037
+ $attr = Mage::getModel('modulecreator/attribute');
1038
+ $attr->setCode('parent_id');
1039
+ $attr->setLabel('Parent id');
1040
+ $attr->setType('int');
1041
+ $attributes[] = $attr;
1042
+
1043
+ $attr = Mage::getModel('modulecreator/attribute');
1044
+ $attr->setCode('path');
1045
+ $attr->setLabel('Path');
1046
+ $attr->setType('text');
1047
+ $attr->setIgnoreApi(true);
1048
+ $attributes[] = $attr;
1049
+
1050
+ $attr = Mage::getModel('modulecreator/attribute');
1051
+ $attr->setCode('position');
1052
+ $attr->setLabel('Position');
1053
+ $attr->setType('int');
1054
+ $attr->setIgnoreApi(true);
1055
+ $attributes[] = $attr;
1056
+
1057
+ $attr = Mage::getModel('modulecreator/attribute');
1058
+ $attr->setCode('level');
1059
+ $attr->setLabel('Level');
1060
+ $attr->setType('int');
1061
+ $attr->setIgnoreApi(true);
1062
+ $attributes[] = $attr;
1063
+
1064
+ $attr = Mage::getModel('modulecreator/attribute');
1065
+ $attr->setCode('children_count');
1066
+ $attr->setLabel('Children count');
1067
+ $attr->setType('int');
1068
+ $attr->setIgnoreApi(true);
1069
+ $attributes[] = $attr;
1070
+ }
1071
+ break;
1072
+ case 'rss':
1073
+ if($this->getRss() || $ignoreSettings){
1074
+ $attr = Mage::getModel('modulecreator/attribute');
1075
+ $attr->setCode('in_rss');
1076
+ $attr->setLabel('In RSS');
1077
+ $attr->setType('yesno');
1078
+ $attributes[] = $attr;
1079
+ }
1080
+ break;
1081
+ case 'seo':
1082
+ if ($this->getAddSeo() || $ignoreSettings){
1083
+ $attr = Mage::getModel('modulecreator/attribute');
1084
+ $attr->setCode('meta_title');
1085
+ $attr->setLabel('Meta title');
1086
+ $attr->setType('text');
1087
+ $attributes[] = $attr;
1088
+
1089
+ $attr = Mage::getModel('modulecreator/attribute');
1090
+ $attr->setCode('meta_keywords');
1091
+ $attr->setLabel('Meta keywords');
1092
+ $attr->setType('textarea');
1093
+ $attributes[] = $attr;
1094
+
1095
+ $attr = Mage::getModel('modulecreator/attribute');
1096
+ $attr->setCode('meta_description');
1097
+ $attr->setLabel('Meta description');
1098
+ $attr->setType('textarea');
1099
+ $attributes[] = $attr;
1100
+ }
1101
+ break;
1102
+ case 'comment':
1103
+ if ($this->getAllowComment() || $ignoreSettings){
1104
+ $attr = Mage::getModel('modulecreator/attribute');
1105
+ $attr->setCode('allow_comment');
1106
+ $attr->setLabel('Allow Comment');
1107
+ $attr->setType('dropdown');
1108
+ $attr->setOptionsSource('custom');
1109
+ $attr->setOptions(false);
1110
+ $attr->setEntity($this);
1111
+ $attr->setForcedSource($namespace.'_'.$this->getModule()->getLowerModuleName().'/adminhtml_source_yesnodefault');
1112
+ $attributes[] = $attr;
1113
+ }
1114
+ break;
1115
+ default:
1116
+ break;
1117
+ }
1118
+ foreach ($attributes as $attribute) {
1119
+ $attribute->setUserDefined(false);
1120
+ }
1121
+ return $attributes;
1122
+ }
1123
+ /**
1124
+ * get layout xml head reference
1125
+ * @access public
1126
+ * @return string
1127
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1128
+ */
1129
+ public function getReferenceHeadLayout(){
1130
+ $eol = $this->getEol();
1131
+ $content = $this->getPadding(2);
1132
+ if ($this->getIsTree()){
1133
+ $namespace = $this->getNamespace(true);
1134
+ $module = $this->getModule()->getLowerModuleName();
1135
+ $entity = $this->getNameSingular(true);
1136
+ $content .= '<reference name="head">'.$eol;
1137
+ $content .= $this->getPadding(3).'<action method="addItem" ifconfig="'.$namespace.'_'.$module.'/'.$entity.'/tree"><type>skin_js</type><js>js/'.$namespace.'_'.$module.'/tree.js</js></action>'.$eol;
1138
+ $content .= $this->getPadding(2).'</reference>'.$eol;
1139
+ $content .= $this->getPadding(2);
1140
+ }
1141
+ return $content;
1142
+ }
1143
+ /**
1144
+ * get layout xml for relation to product
1145
+ * @access public
1146
+ * @return string
1147
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1148
+ */
1149
+ public function getRelationLayoutXml(){
1150
+ $eol = $this->getEol();
1151
+ $content = $this->getPadding(2);
1152
+ $module = $this->getModule()->getLowerModuleName();
1153
+ $entityName = $this->getNameSingular(true);
1154
+ $namespace = $this->getNamespace(true);
1155
+ if ($this->getIsTree()){
1156
+ $content .= $this->getPadding().'<block type="'.$namespace.'_'.$module.'/'.$entityName.'_children" name="'.$entityName.'_children" template="'.$namespace.'_'.$module.'/'.$entityName.'/children.phtml" />'.$eol.$this->getPadding(2);
1157
+ }
1158
+ if ($this->getShowProducts()){
1159
+ $content .= $this->getPadding().'<block type="'.$namespace.'_'.$module.'/'.$entityName.'_catalog_product_list" name="'.$entityName.'.info.products" as="'.$entityName.'_products" template="'.$namespace.'_'.$module.'/'.$entityName.'/catalog/product/list.phtml" />'.$eol.$this->getPadding(2);
1160
+ }
1161
+ if ($this->getShowCategory()){
1162
+ $content .= $this->getPadding().'<block type="'.$namespace.'_'.$module.'/'.$entityName.'_catalog_category_list" name="'.$entityName.'.info.categories" as="'.$entityName.'_categories" template="'.$namespace.'_'.$module.'/'.$entityName.'/catalog/category/list.phtml" />'.$eol.$this->getPadding(2);
1163
+ }
1164
+ $children = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT);
1165
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
1166
+ foreach (array_merge($children, $siblings) as $entity){
1167
+ $content .= $this->getPadding().'<block type="'.$namespace.'_'.$module.'/'.$entityName.'_'.strtolower($entity->getNameSingular()).'_list" name="'.$entityName.'.'.strtolower($entity->getNameSingular()).'_list" as="'.$entityName.'_'.strtolower($this->getNamePlural()).'" template="'.$namespace.'_'.$module.'/'.$entityName.'/'.strtolower($entity->getNameSingular()).'/list.phtml" />'.$eol.$this->getPadding(2);
1168
+ }
1169
+ if ($this->getAllowComment()) {
1170
+ $content .= $this->getPadding().'<block type="'.$namespace.'_'.$module.'/'.$entityName.'_comment_list" name="'.$entityName.'.comments_list" as="'.$entityName.'_comment_list" template="'.$namespace.'_'.$module.'/'.$entityName.'/comment/list.phtml">'.$eol.$this->getPadding(2);
1171
+ $content .= $this->getPadding(2).'<block type="'.$namespace.'_'.$module.'/'.$entityName.'_comment_form" name="comment_form" as="comment_form" template="'.$namespace.'_'.$module.'/'.$entityName.'/comment/form.phtml" />'.$eol.$this->getPadding(2);
1172
+ $content .= $this->getPadding().'</block>'.$eol.$this->getPadding(2);
1173
+ }
1174
+ return $content;
1175
+ }
1176
+ /**
1177
+ * get html link to entity
1178
+ * @access public
1179
+ * @return string
1180
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1181
+ */
1182
+ public function getHtmlLink(){
1183
+ $eol = $this->getEol();
1184
+ $entity = $this->getNameSingular(true);
1185
+ $entityUc = ucfirst($this->getNameSingular());
1186
+ $nameCode = $this->getNameAttributeMagicCode();
1187
+ $content = '';
1188
+ $padd = 3;
1189
+ if ($this->getCreateView()){
1190
+ $padd = 4;
1191
+ $content .= $this->getPadding(3).'<a href="<?php echo $_'.$entity.'->get'.$entityUc.'Url()?>">'.$eol;
1192
+ }
1193
+ $content .= $this->getPadding($padd).'<?php echo $_'.$entity.'->get'.$nameCode.'();?>'.$eol;
1194
+ if ($this->getCreateView()){
1195
+ $content .= $this->getPadding(3).'</a>';
1196
+ }
1197
+ $content .= '<br />';
1198
+ return $content;
1199
+ }
1200
+
1201
+ /**
1202
+ * get the html for attributes in view page
1203
+ * @access public
1204
+ * @return string
1205
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1206
+ */
1207
+ public function getViewAttributesHtml(){
1208
+ $eol = $this->getEol();
1209
+ $content = '';
1210
+ foreach ($this->getAttributes() as $attribute){
1211
+ if ($attribute->getFrontend()){
1212
+ $content .= $this->getPadding().'<div class="'.$this->getNameSingular().'-'.$attribute->getCode().'">'.$eol;
1213
+ $content .= $this->getPadding(2).$attribute->getFrontendHtml().$eol;
1214
+ $content .= $this->getPadding().'</div>'.$eol;
1215
+ }
1216
+ }
1217
+ return $content;
1218
+ }
1219
+
1220
+ /**
1221
+ * check if comments should be split by store
1222
+ * @access public
1223
+ * @return bool
1224
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1225
+ */
1226
+ public function getAllowCommentByStore(){
1227
+ return $this->getTypeInstance()->getAllowCommentByStore();
1228
+ }
1229
+
1230
+ /**
1231
+ * get view widget attributes
1232
+ * @access public
1233
+ * @return string
1234
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1235
+ */
1236
+ public function getViewWidgetAttributesHtml(){
1237
+ $content = '';
1238
+ $padding = $this->getPadding(3);
1239
+ $tab = $this->getPadding();
1240
+ $eol = $this->getEol();
1241
+ foreach ($this->getAttributes() as $attribute){
1242
+ if ($attribute->getWidget()){
1243
+ $content .= $padding.'<div class="'.$attribute->getCode().'-widget">'.$eol.$padding.$tab.$attribute->getFrontendHtml().$padding.'</div>'.$eol;
1244
+ }
1245
+ }
1246
+ return $content;
1247
+ }
1248
+ /**
1249
+ * get the system attributes
1250
+ * @access public
1251
+ * @return string
1252
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1253
+ */
1254
+ public function getSystemAttributes(){
1255
+ $position = 10;
1256
+ $content = '';
1257
+ $tab = $this->getPadding();
1258
+ $eol = $this->getEol();
1259
+ $padding = str_repeat($tab, 6);
1260
+ if ($this->getCreateFrontend()) {
1261
+ $content .= $padding.'<breadcrumbs translate="label">'.$eol;
1262
+ $content .= $padding.$tab.'<label>Use Breadcrumbs</label>'.$eol;
1263
+ $content .= $padding.$tab.'<frontend_type>select</frontend_type>'.$eol;
1264
+ $content .= $padding.$tab.'<source_model>adminhtml/system_config_source_yesno</source_model>'.$eol;
1265
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1266
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1267
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1268
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1269
+ $content .= $padding.'</breadcrumbs>'.$eol;
1270
+ $position += 10;
1271
+ }
1272
+ if ($this->getUrlRewrite()){
1273
+ $content .= $padding.'<url_prefix translate="label comment">'.$eol;
1274
+ $content .= $padding.$tab.'<label>URL prefix</label>'.$eol;
1275
+ $content .= $padding.$tab.'<frontend_type>text</frontend_type>'.$eol;
1276
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1277
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1278
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1279
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1280
+ $content .= $padding.$tab.'<comment>Leave empty for no prefix</comment>'.$eol;
1281
+ $content .= $padding.'</url_prefix>'.$eol;
1282
+ $position += 10;
1283
+
1284
+ $content .= $padding.'<url_suffix translate="label comment">'.$eol;
1285
+ $content .= $padding.$tab.'<label>Url suffix</label>'.$eol;
1286
+ $content .= $padding.$tab.'<frontend_type>text</frontend_type>'.$eol;
1287
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1288
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1289
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1290
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1291
+ $content .= $padding.$tab.'<comment>What goes after the dot. Leave empty for no suffix.</comment>'.$eol;
1292
+ $content .= $padding.'</url_suffix>'.$eol;
1293
+ $position += 10;
1294
+ }
1295
+ if ($this->getAllowComment()) {
1296
+ $content .= $padding.'<allow_comment translate="label">'.$eol;
1297
+ $content .= $padding.$tab.'<label>Allow comments</label>'.$eol;
1298
+ $content .= $padding.$tab.'<frontend_type>select</frontend_type>'.$eol;
1299
+ $content .= $padding.$tab.'<source_model>adminhtml/system_config_source_yesno</source_model>'.$eol;
1300
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1301
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1302
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1303
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1304
+ $content .= $padding.'</allow_comment>'.$eol;
1305
+ $position += 10;
1306
+
1307
+ $content .= $padding.'<allow_guest_comment translate="label">'.$eol;
1308
+ $content .= $padding.$tab.'<label>Allow guest comments</label>'.$eol;
1309
+ $content .= $padding.$tab.'<frontend_type>select</frontend_type>'.$eol;
1310
+ $content .= $padding.$tab.'<source_model>adminhtml/system_config_source_yesno</source_model>'.$eol;
1311
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1312
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1313
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1314
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1315
+ $content .= $padding.$tab.'<depends>'.$eol;
1316
+ $content .= $padding.$tab.$tab.'<allow_comment>1</allow_comment>'.$eol;
1317
+ $content .= $padding.$tab.'</depends>'.$eol;
1318
+ $content .= $padding.'</allow_guest_comment>'.$eol;
1319
+ $position += 10;
1320
+ }
1321
+ if ($this->getRss()){
1322
+ $content .= $padding.'<rss translate="label">'.$eol;
1323
+ $content .= $padding.$tab.'<label>Enable rss</label>'.$eol;
1324
+ $content .= $padding.$tab.'<frontend_type>select</frontend_type>'.$eol;
1325
+ $content .= $padding.$tab.'<source_model>adminhtml/system_config_source_yesno</source_model>'.$eol;
1326
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1327
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1328
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1329
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1330
+ $content .= $padding.'</rss>'.$eol;
1331
+ $position += 10;
1332
+ }
1333
+ if ($this->getIsTree() && $this->getCreateList()){
1334
+ $content .= $padding.'<tree translate="label">'.$eol;
1335
+ $content .= $padding.$tab.'<label>Display as tree</label>'.$eol;
1336
+ $content .= $padding.$tab.'<frontend_type>select</frontend_type>'.$eol;
1337
+ $content .= $padding.$tab.'<source_model>adminhtml/system_config_source_yesno</source_model>'.$eol;
1338
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1339
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1340
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1341
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1342
+ $content .= $padding.'</tree>'.$eol;
1343
+ $position += 10;
1344
+ }
1345
+ if ($this->getIsTree() && ($this->getCreateList() || $this->getWidget())){
1346
+ $content .= $padding.'<recursion translate="label">'.$eol;
1347
+ $content .= $padding.$tab.'<label>Recursion level</label>'.$eol;
1348
+ $content .= $padding.$tab.'<frontend_type>text</frontend_type>'.$eol;
1349
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1350
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1351
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1352
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1353
+ $content .= $padding.'</recursion>'.$eol;
1354
+ $position += 10;
1355
+ }
1356
+
1357
+ if ($this->getAddSeo() && $this->getCreateList()){
1358
+ $content .= $padding.'<meta_title translate="label">'.$eol;
1359
+ $content .= $padding.$tab.'<label>Meta title for '.strtolower($this->getLabelPlural()).' list page</label>'.$eol;
1360
+ $content .= $padding.$tab.'<frontend_type>text</frontend_type>'.$eol;
1361
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1362
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1363
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1364
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1365
+ $content .= $padding.'</meta_title>'.$eol;
1366
+ $position += 10;
1367
+
1368
+ $content .= $padding.'<meta_description translate="label">'.$eol;
1369
+ $content .= $padding.$tab.'<label>Meta description for '.strtolower($this->getLabelPlural()).' list page</label>'.$eol;
1370
+ $content .= $padding.$tab.'<frontend_type>textarea</frontend_type>'.$eol;
1371
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1372
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1373
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1374
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1375
+ $content .= $padding.'</meta_description>'.$eol;
1376
+ $position += 10;
1377
+
1378
+ $content .= $padding.'<meta_keywords translate="label">'.$eol;
1379
+ $content .= $padding.$tab.'<label>Meta keywords for '.strtolower($this->getLabelPlural()).' list page</label>'.$eol;
1380
+ $content .= $padding.$tab.'<frontend_type>textarea</frontend_type>'.$eol;
1381
+ $content .= $padding.$tab.'<sort_order>'.$position.'</sort_order>'.$eol;
1382
+ $content .= $padding.$tab.'<show_in_default>1</show_in_default>'.$eol;
1383
+ $content .= $padding.$tab.'<show_in_website>1</show_in_website>'.$eol;
1384
+ $content .= $padding.$tab.'<show_in_store>1</show_in_store>'.$eol;
1385
+ $content .= $padding.'</meta_keywords>'.$eol;
1386
+ }
1387
+ return substr($content,0, strlen($content) - strlen($eol));
1388
+ }
1389
+ /**
1390
+ * get additional api xml
1391
+ * @access public
1392
+ * @return string
1393
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1394
+ */
1395
+ public function getApiAdditional(){
1396
+ $content = $this->getApiTree();
1397
+ $content .= $this->getTypeInstance()->getApiAdditional();
1398
+ $content .= $this->getApiRelations();
1399
+ return $content;
1400
+ }
1401
+ /**
1402
+ * get additional api xml for tree entities
1403
+ * @access public
1404
+ * @return string
1405
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1406
+ */
1407
+ public function getApiTree(){
1408
+ $content = '';
1409
+ $padding = $this->getPadding();
1410
+ $prefix = str_repeat($padding, 5);
1411
+ $eol = $this->getEol();
1412
+ $extension = $this->getModule()->getExtensionName(true);
1413
+ if ($this->getIsTree()){
1414
+ $module = $this->getModule()->getLowerModuleName();
1415
+ $entity = $this->getNameSingular(true);
1416
+ $entityLabelUc = ucfirst($this->getLabelSingular());
1417
+ $entityLabel = strtolower($this->getLabelSingular());
1418
+ $entitiesLabel = strtolower($this->getLabelPlural());
1419
+ $content = $prefix.'<level translate="title" module="'.$extension.'">'.$eol;
1420
+ $content .= $prefix.$padding.'<title>Retrieve one level of '.$entitiesLabel.'</title>'.$eol;
1421
+ $content .= $prefix.$padding.'<acl>'.$module.'/'.$entity.'/info</acl>'.$eol;
1422
+ $content .= $prefix.'</level>'.$eol;
1423
+ $content .= $prefix.'<move translate="title" module="'.$extension.'">'.$eol;
1424
+ $content .= $prefix.$padding.'<title>Move '.$entityLabel.' in tree</title>'.$eol;
1425
+ $content .= $prefix.$padding.'<acl>'.$module.'/'.$entity.'/move</acl>'.$eol;
1426
+ $content .= $prefix.'</move>'.$eol;
1427
+ }
1428
+ return $content;
1429
+ }
1430
+
1431
+ /**
1432
+ * get api relations for a section
1433
+ * @access public
1434
+ * @param $relatedCode
1435
+ * @param $relatedLabel
1436
+ * @return string
1437
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1438
+ */
1439
+ public function getApiRelationsSection($relatedCode, $relatedLabel){
1440
+ $eol = $this->getEol();
1441
+ $padding = $this->getPadding();
1442
+ $prefix = $this->getPadding(5);
1443
+ $module = $this->getModule()->getLowerModuleName();
1444
+ $entity = $this->getNameSingular(true);
1445
+ $entityLabelUc = ucfirst($this->getLabelSingular());
1446
+ $entityLabel = strtolower($this->getLabelSingular());
1447
+ $extension = $this->getModule()->getExtensionName(true);
1448
+ $string = '';
1449
+ $string .= $prefix. '<assign'.$relatedCode.' translate="title" module="'.$extension.'">'.$eol;
1450
+ $string .= $prefix.$padding. '<title>Assign '.$relatedLabel.' to '.$entityLabelUc.'</title>'.$eol;
1451
+ $string .= $prefix.$padding. '<acl>'.$module.'/'.$entity.'/update</acl>'.$eol;
1452
+ $string .= $prefix. '</assign'.$relatedCode.'>'.$eol;
1453
+
1454
+ $string .= $prefix. '<unassign'.$relatedCode.' translate="title" module="'.$extension.'">'.$eol;
1455
+ $string .= $prefix.$padding. '<title>Remove '.$relatedLabel.' from '.$entityLabel.'</title>'.$eol;
1456
+ $string .= $prefix.$padding. '<acl>'.$module.'/'.$entity.'/update</acl>'.$eol;
1457
+ $string .= $prefix. '</unassign'.$relatedCode.'>'.$eol;
1458
+ return $string;
1459
+ }
1460
+
1461
+ /**
1462
+ * get API xml for entity relations
1463
+ * @access public
1464
+ * @return string
1465
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1466
+ */
1467
+ public function getApiRelations(){
1468
+ $string = '';
1469
+ if ($this->getLinkProduct()){
1470
+ $string .= $this->getApiRelationsSection('Product', 'product');
1471
+ }
1472
+ if ($this->getLinkCategory()){
1473
+ $string .= $this->getApiRelationsSection('Category', 'category');
1474
+ }
1475
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
1476
+ foreach ($siblings as $sibling){
1477
+ $siblingName = $sibling->getNameSingular(true);
1478
+ $siblingNameUc = ucfirst($sibling->getNameSingular());
1479
+ $siblingLabel = strtolower($sibling->getLabelSingular());
1480
+ $string .= $this->getApiRelationsSection($siblingNameUc, $siblingLabel);
1481
+ }
1482
+ $string .= $this->getPadding(4);
1483
+ return $string;
1484
+ }
1485
+
1486
+ /**
1487
+ * get API faults for a section
1488
+ * @access public
1489
+ * @param $relatedCode
1490
+ * @param $relatedLabel
1491
+ * @param $code
1492
+ * @return string
1493
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1494
+ */
1495
+ public function getApiFaultsSection($relatedCode, $relatedLabel, $code){
1496
+ $string = '';
1497
+ $padding = $this->getPadding();
1498
+ $prefix = str_repeat($padding, 5);
1499
+ $eol = $this->getEol();
1500
+ $entity = $this->getNameSingular(true);
1501
+ $entityLabelUc = ucfirst($this->getLabelSingular());
1502
+ $entityLabel = strtolower($this->getLabelSingular());
1503
+ $string = '';
1504
+ $string .= $prefix.'<'.$relatedCode.'_not_exists>'.$eol;
1505
+ $string .= $prefix.$padding.'<code>'.$code.'</code>'.$eol;
1506
+ $string .= $prefix.$padding.'<message>'.$relatedLabel.' does not exist.</message>'.$eol;
1507
+ $string .= $prefix.'</'.$relatedCode.'_not_exists>'.$eol;
1508
+
1509
+ return $string;
1510
+ }
1511
+
1512
+ /**
1513
+ * get list of faults for API
1514
+ * @access public
1515
+ * @return string
1516
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1517
+ */
1518
+ public function getApiFaults(){
1519
+ $string = '';
1520
+ $padding = $this->getPadding();
1521
+ $prefix = str_repeat($padding, 5);
1522
+ $eol = $this->getEol();
1523
+ $code = 105;
1524
+ $entity = $this->getNameSingular(true);
1525
+ $entityLabelUc = ucfirst($this->getLabelSingular());
1526
+ $entityLabel = strtolower($this->getLabelSingular());
1527
+ if ($this->getIsTree()){
1528
+ $string .= $prefix.'<not_moved>'.$eol;
1529
+ $string .= $prefix.$padding.'<code>'.$code.'</code>'.$eol;
1530
+ $string .= $prefix.$padding.'<message>'.$entityLabelUc.' not moved. Details in error message.</message>'.$eol;
1531
+ $string .= $prefix.'</not_moved>'.$eol;
1532
+ $code++;
1533
+ }
1534
+ if ($this->getLinkProduct()){
1535
+ $string .= $this->getApiFaultsSection('product', 'Product', $code);
1536
+ $code++;
1537
+ }
1538
+ if ($this->getLinkCategory()){
1539
+ $string .= $this->getApiFaultsSection('category', 'Category', $code);
1540
+ $code++;
1541
+ }
1542
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
1543
+ foreach ($siblings as $sibling){
1544
+ $siblingName = $sibling->getNameSingular(true);
1545
+ $siblingNameUc = ucfirst($sibling->getNameSingular());
1546
+ $siblingLabel = strtolower($sibling->getLabelSingular());
1547
+ $siblingLabelUc = ucfirst($sibling->getLabelSingular());
1548
+
1549
+ $string .= $this->getApiFaultsSection($entity.'_'.$siblingName, $siblingLabelUc, $code);
1550
+ $code++;
1551
+ }
1552
+ $string .= $this->getTypeInstance()->getApiFaults();
1553
+ $string .= str_repeat($padding, 4);
1554
+ return $string;
1555
+ }
1556
+
1557
+ /**
1558
+ * get additional api acl
1559
+ * @access public
1560
+ * @return string
1561
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1562
+ */
1563
+ public function getAdditionalApiAcl(){
1564
+ $content = '';
1565
+ $padding = $this->getPadding();
1566
+ $prefix = str_repeat($padding, 6);
1567
+ $eol = $this->getEol();
1568
+ $extension = $this->getModule()->getExtensionName(true);
1569
+ if ($this->getIsTree()){
1570
+ $module = $this->getModule()->getLowerModuleName();
1571
+ $entity = $this->getNameSingular(true);
1572
+ $entityLabelUc = ucfirst($this->getLabelSingular());
1573
+ $entityLabel = strtolower($this->getLabelSingular());
1574
+ $content .= $prefix.'<move translate="title" module="'.$extension.'">'.$eol;
1575
+ $content .= $prefix.$padding.'<title>Move</title>'.$eol;
1576
+ $content .= $prefix.'</move>'.$eol;
1577
+ }
1578
+ $content .= str_repeat($padding, 5);
1579
+ return $content;
1580
+ }
1581
+ /**
1582
+ * get attributes format for wsdl
1583
+ * @access public
1584
+ * @param bool $wsi
1585
+ * @param bool $forAdd
1586
+ * @return string
1587
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1588
+ */
1589
+ public function getWsdlAttributes($wsi = false, $forAdd = false){
1590
+ $parents = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD);
1591
+ $tab = $this->getPadding();
1592
+ $padding = str_repeat($tab, 5);
1593
+ $eol = $this->getEol();
1594
+ $content = '';
1595
+ foreach ($parents as $parent){
1596
+ $attr = Mage::getModel('modulecreator/attribute');
1597
+ $attr->setCode($parent->getNameSingular().'_id');
1598
+ $attr->setLabel($parent->getLabelSingular());
1599
+ $attr->setType('int');
1600
+ $content .= $padding.$attr->getWsdlFormat($wsi).$eol;
1601
+ }
1602
+ foreach ($this->getAttributes() as $attribute){
1603
+ $content .= $padding.$attribute->getWsdlFormat($wsi).$eol;
1604
+ }
1605
+ $simulated = $this->getSimulatedAttributes(null, false);
1606
+ foreach ($simulated as $attr){
1607
+ if (!$forAdd || !$attr->getIgnoreApi()){
1608
+ $content .= $padding.$attr->getWsdlFormat($wsi).$eol;
1609
+ }
1610
+ }
1611
+ $content .= $this->getTypeInstance()->getWsdlAttributes($wsi);
1612
+ return $content;
1613
+ }
1614
+ /**
1615
+ * get attributes format for wsi
1616
+ * @access public
1617
+ * @param bool $forAdd
1618
+ * @return string
1619
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1620
+ */
1621
+ public function getWsiAttributes($forAdd = false){
1622
+ return $this->getWsdlAttributes(true, $forAdd);
1623
+ }
1624
+
1625
+ /**
1626
+ * get wsdl relation type for a section
1627
+ * @param $relatedCode
1628
+ * @param $relatedId
1629
+ * @param bool $wsi
1630
+ * @return string
1631
+ */
1632
+ public function getWsdlRelationTypesSection($relatedCode, $relatedId, $wsi = false){
1633
+ $content = '';
1634
+ $tab = $this->getPadding();
1635
+ $padding = str_repeat($tab, 3);
1636
+ $mainTag = ($wsi) ? 'xsd:complexType':'complexType';
1637
+ $subtag = ($wsi) ? 'xsd:sequence' : 'all';
1638
+ $element = ($wsi) ? 'xsd:element' : 'element';
1639
+ $eol = $this->getEol();
1640
+ $module = $this->getModule()->getLowerModuleName();
1641
+ $entity = $this->getNameSingular(true);
1642
+ $entityUc = ucfirst($this->getNameSingular());
1643
+
1644
+ $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'Assign'.$relatedCode.'Entity">'.$eol;
1645
+ $content .= $padding.$tab.'<'.$subtag.'>'.$eol;
1646
+ $content .= $padding.$tab.'<'.$element.' name="'.$entity.'Id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1647
+ $content .= $padding.$tab.'<'.$element.' name="'.$relatedId.'Id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1648
+ $content .= $padding.$tab.'<'.$element.' name="position" type="xsd:string"'.((!$wsi)?' minOccurs="0"':'').' />'.$eol;
1649
+ $content .= $padding.$tab.'</'.$subtag.'>'.$eol;
1650
+ $content .= $padding.'</'.$mainTag.'>'.$eol;
1651
+
1652
+ $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'Unassign'.$relatedCode.'Entity">'.$eol;
1653
+ $content .= $padding.$tab.'<'.$subtag.'>'.$eol;
1654
+ $content .= $padding.$tab.'<'.$element.' name="'.$entity.'Id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1655
+ $content .= $padding.$tab.'<'.$element.' name="'.$relatedId.'Id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1656
+ $content .= $padding.$tab.'</'.$subtag.'>'.$eol;
1657
+ $content .= $padding.'</'.$mainTag.'>'.$eol;
1658
+
1659
+ return $content;
1660
+ }
1661
+
1662
+ /**
1663
+ * get entity WSDL relation types
1664
+ * @access public
1665
+ * @param bool $wsi
1666
+ * @return string
1667
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1668
+ */
1669
+ public function getWsdlRelationTypes($wsi = false){
1670
+ $content = '';
1671
+ $tab = $this->getPadding();
1672
+ $padding = str_repeat($tab, 3);
1673
+ $mainTag = ($wsi) ? 'xsd:complexType':'complexType';
1674
+ $subtag = ($wsi) ? 'xsd:sequence' : 'all';
1675
+ $element = ($wsi) ? 'xsd:element' : 'element';
1676
+ $eol = $this->getEol();
1677
+ $module = $this->getModule()->getLowerModuleName();
1678
+ $entity = $this->getNameSingular(true);
1679
+ $entityUc = ucfirst($this->getNameSingular());
1680
+ if ($this->getIsTree()){
1681
+ $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'MoveEntity">'.$eol;
1682
+ $content .= $padding.$tab.'<'.$subtag.'>'.$eol;
1683
+ $content .= $padding.$tab.'<'.$element.' name="'.$entity.'_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1684
+ $content .= $padding.$tab.'<'.$element.' name="parent_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol;
1685
+ $content .= $padding.$tab.'<'.$element.' name="after_id" type="xsd:string"'.((!$wsi)?' minOccurs="0"':'').' />'.$eol;
1686
+ $content .= $padding.$tab.'</'.$subtag.'>'.$eol;
1687
+ $content .= $padding.'</'.$mainTag.'>'.$eol;
1688
+ }
1689
+ if ($this->getLinkProduct()){
1690
+ $content .= $this->getWsdlRelationTypesSection('Product', 'product', $wsi);
1691
+ }
1692
+ if ($this->getLinkCategory()){
1693
+ $content .= $this->getWsdlRelationTypesSection('Category', 'category', $wsi);
1694
+ }
1695
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
1696
+ foreach ($siblings as $sibling){
1697
+ $siblingName = $sibling->getNameSingular(true);
1698
+ $siblingNameUc = ucfirst($sibling->getNameSingular());
1699
+ $siblingLabel = strtolower($sibling->getLabelSingular());
1700
+
1701
+ $content .= $this->getWsdlRelationTypesSection($siblingNameUc, $siblingName, $wsi);
1702
+
1703
+ }
1704
+ $content .= $tab.$tab;
1705
+ return $content;
1706
+ }
1707
+ /**
1708
+ * get entity WSI relation types
1709
+ * @access public
1710
+ * @return string
1711
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1712
+ */
1713
+ public function getWsiRelationTypes(){
1714
+ return $this->getWsdlRelationTypes(true);
1715
+ }
1716
+
1717
+ /**
1718
+ * get wsdl port type relations for a section
1719
+ * @access public
1720
+ * @param $relatedLabel
1721
+ * @param $relatedText
1722
+ * @param $wsi
1723
+ * @return string
1724
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1725
+ */
1726
+ public function getWsdlPortTypeRelationSection($relatedLabel, $relatedText, $wsi){
1727
+ $content = '';
1728
+ $tab = $this->getPadding();
1729
+ $padding = $tab.$tab;
1730
+ $eol = $this->getEol();
1731
+ $module = $this->getModule()->getLowerModuleName();
1732
+ $entity = $this->getNameSingular(true);
1733
+ $entityUc = ucfirst($this->getNameSingular());
1734
+ $label = strtolower($this->getLabelSingular());
1735
+ $tagPrefix = ($wsi) ? 'wsdl:':'';
1736
+
1737
+ $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'Assign'.$relatedLabel.'">'.$eol;
1738
+ $content .= $padding.$tab.'<'.$tagPrefix.'documentation>Assign '.$relatedText.' to '.$label.'</'.$tagPrefix.'documentation>'.$eol;
1739
+ $content .= $padding.$tab.'<'.$tagPrefix.'input message="typens:'.$module.$entityUc.'Assign'.$relatedLabel.'Request" />'.$eol;
1740
+ $content .= $padding.$tab.'<'.$tagPrefix.'output message="typens:'.$module.$entityUc.'Assign'.$relatedLabel.'Response" />'.$eol;
1741
+ $content .= $padding.'</'.$tagPrefix.'operation>'.$eol;
1742
+ $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'Unassign'.$relatedLabel.'">'.$eol;
1743
+ $content .= $padding.$tab.'<'.$tagPrefix.'documentation>Remove '.$relatedText.' from '.$label.'</'.$tagPrefix.'documentation>'.$eol;
1744
+ $content .= $padding.$tab.'<'.$tagPrefix.'input message="typens:'.$module.$entityUc.'Unassign'.$relatedLabel.'Request" />'.$eol;
1745
+ $content .= $padding.$tab.'<'.$tagPrefix.'output message="typens:'.$module.$entityUc.'Unassign'.$relatedLabel.'Response" />'.$eol;
1746
+ $content .= $padding.'</'.$tagPrefix.'operation>'.$eol;
1747
+
1748
+ return $content;
1749
+ }
1750
+
1751
+ /**
1752
+ * get entity WSDL port type for relations
1753
+ * @access public
1754
+ * @param bool $wsi
1755
+ * @return string
1756
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1757
+ */
1758
+ public function getWsdlPortTypeRelation($wsi = false){
1759
+ $content = '';
1760
+ $tab = $this->getPadding();
1761
+ $padding = $tab.$tab;
1762
+ $eol = $this->getEol();
1763
+ $module = $this->getModule()->getLowerModuleName();
1764
+ $entity = $this->getNameSingular(true);
1765
+ $entityUc = ucfirst($entity);
1766
+ $label = strtolower($this->getLabelSingular());
1767
+
1768
+ $tagPrefix = ($wsi) ? 'wsdl:':'';
1769
+
1770
+ if ($this->getIsTree()){
1771
+ $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'Move">'.$eol;
1772
+ $content .= $padding.$tab.'<'.$tagPrefix.'documentation>Move '.$label.' in tree</'.$tagPrefix.'documentation>'.$eol;
1773
+ $content .= $padding.$tab.'<'.$tagPrefix.'input message="typens:'.$module.$entityUc.'MoveRequest" />'.$eol;
1774
+ $content .= $padding.$tab.'<'.$tagPrefix.'output message="typens:'.$module.$entityUc.'MoveResponse" />'.$eol;
1775
+ $content .= $padding.'</'.$tagPrefix.'operation>'.$eol;
1776
+
1777
+ }
1778
+
1779
+ if ($this->getLinkProduct()){
1780
+ $content .= $this->getWsdlPortTypeRelationSection('Product', 'product', $wsi);
1781
+ }
1782
+
1783
+ if ($this->getLinkCategory()){
1784
+ $content .= $this->getWsdlPortTypeRelationSection('Category', 'category', $wsi);
1785
+ }
1786
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
1787
+ foreach ($siblings as $sibling){
1788
+ $siblingName = strtolower($sibling->getNameSingular());
1789
+ $siblingNameUc = ucfirst($sibling->getNameSingular());
1790
+ $siblingLabel = strtolower($sibling->getLabelSingular());
1791
+
1792
+ $content .= $this->getWsdlPortTypeRelationSection($siblingNameUc, $siblingLabel, $wsi);
1793
+
1794
+ }
1795
+ $content .= $tab;
1796
+ return $content;
1797
+ }
1798
+ /**
1799
+ * get entity WSI port type for relations
1800
+ * @access public
1801
+ * @return string
1802
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1803
+ */
1804
+ public function getWsiPortTypeRelation(){
1805
+ return $this->getWsdlPortTypeRelation(true);
1806
+ }
1807
+
1808
+ /**
1809
+ * get wsld relation binding for a section
1810
+ * @access public
1811
+ * @param $sectionName
1812
+ * @return string
1813
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1814
+ */
1815
+ public function getWsdlRelationBindingSection($sectionName){
1816
+ $content = '';
1817
+ $tab = $this->getPadding();
1818
+ $doubleTab = $tab.$tab;
1819
+ $padding = $doubleTab;
1820
+ $eol = $this->getEol();
1821
+ $module = $this->getModule()->getLowerModuleName();
1822
+ $entity = $this->getNameSingular(true);
1823
+ $entityUc = ucfirst($entity);
1824
+ $label = strtolower($this->getLabelSingular());
1825
+
1826
+ $content .= $padding.'<operation name="'.$module.$entityUc.$sectionName.'">'.$eol;
1827
+ $content .= $padding.$tab.'<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />'.$eol;
1828
+ $content .= $padding.$tab.'<input>'.$eol;
1829
+ $content .= $padding.$doubleTab.'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1830
+ $content .= $padding.$tab.'</input>'.$eol;
1831
+ $content .= $padding.$tab.'<output>'.$eol;
1832
+ $content .= $padding.$doubleTab.'<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />'.$eol;
1833
+ $content .= $padding.$tab.'</output>'.$eol;
1834
+ $content .= $padding.'</operation>'.$eol;
1835
+ return $content;
1836
+ }
1837
+ /**
1838
+ * get WSDL relation binding
1839
+ * @access public
1840
+ * @return string
1841
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1842
+ */
1843
+ public function getWsdlRelationBinding(){
1844
+ $content = '';
1845
+ $module = $this->getModule()->getLowerModuleName();
1846
+ $entity = $this->getNameSingular(true);
1847
+ $entityUc = ucfirst($this->getNameSingular());
1848
+ $label = strtolower($this->getLabelSingular());
1849
+
1850
+ if ($this->getIsTree()){
1851
+ $content .= $this->getWsdlRelationBindingSection('Move');
1852
+ }
1853
+ if ($this->getLinkProduct()){
1854
+ $content .= $this->getWsdlRelationBindingSection('AssignProduct');
1855
+ $content .= $this->getWsdlRelationBindingSection('UnassignProduct');
1856
+ }
1857
+ if ($this->getLinkCategory()){
1858
+ $content .= $this->getWsdlRelationBindingSection('AssignCategory');
1859
+ $content .= $this->getWsdlRelationBindingSection('UnassignCategory');
1860
+ }
1861
+
1862
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
1863
+ foreach ($siblings as $sibling){
1864
+ $siblingName = $sibling->getNameSingular(true);
1865
+ $siblingNameUc = ucfirst($siblingName);
1866
+ $siblingLabel = strtolower($sibling->getLabelSingular());
1867
+
1868
+ $content .= $this->getWsdlRelationBindingSection('Assign'.$siblingNameUc);
1869
+ $content .= $this->getWsdlRelationBindingSection('Unassign'.$siblingNameUc);
1870
+ }
1871
+ $content .= $this->getPadding();
1872
+ return $content;
1873
+ }
1874
+
1875
+ /**
1876
+ * get wsld relation binding for a section
1877
+ * @access public
1878
+ * @param $sectionName
1879
+ * @return string
1880
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1881
+ */
1882
+ public function getWsiRelationBindingSection($sectionName){
1883
+ $content = '';
1884
+ $tab = $this->getPadding();
1885
+ $doubleTab = $tab.$tab;
1886
+ $padding = $doubleTab;
1887
+ $eol = $this->getEol();
1888
+ $module = $this->getModule()->getLowerModuleName();
1889
+ $entity = $this->getNameSingular(true);
1890
+ $entityUc = ucfirst($entity);
1891
+ $label = strtolower($this->getLabelSingular());
1892
+
1893
+ $content .= $padding.'<wsdl:operation name="'.$module.$entityUc.$sectionName.'">'.$eol;
1894
+ $content .= $padding.$tab.'<soap:operation soapAction="" />'.$eol;
1895
+ $content .= $padding.$tab.'<wsdl:input>'.$eol;
1896
+ $content .= $padding.$doubleTab.'<soap:body use="literal" />'.$eol;
1897
+ $content .= $padding.$tab.'</wsdl:input>'.$eol;
1898
+ $content .= $padding.$tab.'<wsdl:output>'.$eol;
1899
+ $content .= $padding.$doubleTab.'<soap:body use="literal" />'.$eol;
1900
+ $content .= $padding.$tab.'</wsdl:output>'.$eol;
1901
+ $content .= $padding.'</wsdl:operation>'.$eol;
1902
+ return $content;
1903
+ }
1904
+
1905
+ /**
1906
+ * get WSI relation binding
1907
+ * @access public
1908
+ * @return string
1909
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1910
+ */
1911
+ public function getWsiRelationBinding(){
1912
+ $content = '';
1913
+ $module = $this->getModule()->getLowerModuleName();
1914
+ $entity = $this->getNameSingular(true);
1915
+ $entityUc = ucfirst($entity);
1916
+ $label = strtolower($this->getLabelSingular());
1917
+
1918
+ if ($this->getIsTree()){
1919
+ $content .= $this->getWsiRelationBindingSection('Move');
1920
+ }
1921
+ if ($this->getLinkProduct()){
1922
+ $content .= $this->getWsiRelationBindingSection('AssignProduct');
1923
+ $content .= $this->getWsiRelationBindingSection('UnassignProduct');
1924
+ }
1925
+ if ($this->getLinkCategory()){
1926
+ $content .= $this->getWsiRelationBindingSection('AssignCategory');
1927
+ $content .= $this->getWsiRelationBindingSection('UnassignCategory');
1928
+ }
1929
+
1930
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
1931
+ foreach ($siblings as $sibling){
1932
+ $siblingName = $sibling->getNameSingular(true);
1933
+ $siblingNameUc = ucfirst($siblingName);
1934
+ $siblingLabel = strtolower($sibling->getLabelSingular());
1935
+
1936
+ $content .= $this->getWsiRelationBindingSection('Assign'.$siblingNameUc);
1937
+ $content .= $this->getWsiRelationBindingSection('Unassign'.$siblingNameUc);
1938
+ }
1939
+ $content .= $this->getPadding();
1940
+ return $content;
1941
+ }
1942
+
1943
+ /**
1944
+ * get wsi relation param types for a section
1945
+ * @access public
1946
+ * @param $sectionName
1947
+ * @param $sectionParam
1948
+ * @return string
1949
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1950
+ */
1951
+ public function getWsiRelationParamTypesSection($sectionName, $sectionParam){
1952
+ $content = '';
1953
+ $tab = $this->getPadding();
1954
+ $padding = $this->getPadding(3);
1955
+ $eol = $this->getEol();
1956
+ $module = $this->getModule()->getLowerModuleName();
1957
+ $entity = $this->getNameSingular(true);
1958
+ $entityUc = ucfirst($entity);
1959
+ $label = strtolower($this->getLabelSingular());
1960
+ $content .= $padding.'<xsd:element name="'.$module.$entityUc.'Assign'.$sectionName.'RequestParam">'.$eol;
1961
+ $content .= $padding.$tab.'<xsd:complexType>'.$eol;
1962
+ $content .= $padding.str_repeat($tab, 2).'<xsd:sequence>'.$eol;
1963
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />'.$eol;
1964
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="'.$entity.'Id" type="xsd:string" />'.$eol;
1965
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="'.$sectionParam.'Id" type="xsd:string" />'.$eol;
1966
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="0" maxOccurs="1" name="position" type="xsd:string" />'.$eol;
1967
+ $content .= $padding.str_repeat($tab, 2).'</xsd:sequence>'.$eol;
1968
+ $content .= $padding.$tab.'</xsd:complexType>'.$eol;
1969
+ $content .= $padding.'</xsd:element>'.$eol;
1970
+
1971
+ $content .= $padding.'<xsd:element name="'.$module.$entityUc.'Assign'.$sectionName.'ResponseParam">'.$eol;
1972
+ $content .= $padding.$tab.'<xsd:complexType>'.$eol;
1973
+ $content .= $padding.str_repeat($tab, 2).'<xsd:sequence>'.$eol;
1974
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />'.$eol;
1975
+ $content .= $padding.str_repeat($tab, 2).'</xsd:sequence>'.$eol;
1976
+ $content .= $padding.$tab.'</xsd:complexType>'.$eol;
1977
+ $content .= $padding.'</xsd:element>'.$eol;
1978
+
1979
+ $content .= $padding.'<xsd:element name="'.$module.$entityUc.'Unassign'.$sectionName.'RequestParam">'.$eol;
1980
+ $content .= $padding.$tab.'<xsd:complexType>'.$eol;
1981
+ $content .= $padding.str_repeat($tab, 2).'<xsd:sequence>'.$eol;
1982
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />'.$eol;
1983
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="'.$entity.'Id" type="xsd:string" />'.$eol;
1984
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="'.$sectionParam.'Id" type="xsd:string" />'.$eol;
1985
+ $content .= $padding.str_repeat($tab, 2).'</xsd:sequence>'.$eol;
1986
+ $content .= $padding.$tab.'</xsd:complexType>'.$eol;
1987
+ $content .= $padding.'</xsd:element>'.$eol;
1988
+
1989
+ $content .= $padding.'<xsd:element name="'.$module.$entityUc.'Unassign'.$sectionName.'ResponseParam">'.$eol;
1990
+ $content .= $padding.$tab.'<xsd:complexType>'.$eol;
1991
+ $content .= $padding.str_repeat($tab, 2).'<xsd:sequence>'.$eol;
1992
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />'.$eol;
1993
+ $content .= $padding.str_repeat($tab, 2).'</xsd:sequence>'.$eol;
1994
+ $content .= $padding.$tab.'</xsd:complexType>'.$eol;
1995
+ $content .= $padding.'</xsd:element>'.$eol;
1996
+
1997
+ return $content;
1998
+ }
1999
+ /**
2000
+ * get entity WSI relation param types
2001
+ * @access public
2002
+ * @return string
2003
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2004
+ */
2005
+ public function getWsiRelationParamTypes(){
2006
+ $content = '';
2007
+ $tab = $this->getPadding();
2008
+ $padding = str_repeat($tab, 3);
2009
+ $eol = $this->getEol();
2010
+ $module = $this->getModule()->getLowerModuleName();
2011
+ $entity = $this->getNameSingular(true);
2012
+ $entityUc = ucfirst($entity);
2013
+ $label = strtolower($this->getLabelSingular());
2014
+
2015
+ if ($this->getIsTree()){
2016
+ $content .= $padding.'<xsd:element name="'.$module.$entityUc.'MoveRequestParam">'.$eol;
2017
+ $content .= $padding.$tab.'<xsd:complexType>'.$eol;
2018
+ $content .= $padding.str_repeat($tab, 2).'<xsd:sequence>'.$eol;
2019
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="session_id" type="xsd:string" />'.$eol;
2020
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="'.$entity.'Id" type="xsd:string" />'.$eol;
2021
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="parentId" type="xsd:string" />'.$eol;
2022
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="0" maxOccurs="1" name="afterId" type="xsd:string" />'.$eol;
2023
+ $content .= $padding.str_repeat($tab, 2).'</xsd:sequence>'.$eol;
2024
+ $content .= $padding.$tab.'</xsd:complexType>'.$eol;
2025
+ $content .= $padding.'</xsd:element>'.$eol;
2026
+
2027
+ $content .= $padding.'<xsd:element name="'.$module.$entityUc.'AssignProductResponseParam">'.$eol;
2028
+ $content .= $padding.$tab.'<xsd:complexType>'.$eol;
2029
+ $content .= $padding.str_repeat($tab, 2).'<xsd:sequence>'.$eol;
2030
+ $content .= $padding.str_repeat($tab, 3).'<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />'.$eol;
2031
+ $content .= $padding.str_repeat($tab, 2).'</xsd:sequence>'.$eol;
2032
+ $content .= $padding.$tab.'</xsd:complexType>'.$eol;
2033
+ $content .= $padding.'</xsd:element>'.$eol;
2034
+ }
2035
+
2036
+ if ($this->getLinkProduct()){
2037
+ $content .= $this->getWsiRelationParamTypesSection('Product', 'product');
2038
+ }
2039
+
2040
+ if ($this->getLinkCategory()){
2041
+ $content .= $this->getWsiRelationParamTypesSection('Category', 'category');
2042
+ }
2043
+
2044
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
2045
+ foreach ($siblings as $sibling){
2046
+ $siblingName = $sibling->getNameSingular(true);
2047
+ $siblingNameUc = ucfirst($siblingName);
2048
+ $siblingLabel = strtolower($sibling->getLabelSingular());
2049
+
2050
+ $content .= $this->getWsiRelationParamTypesSection($siblingNameUc, $siblingName);
2051
+ }
2052
+ $content .= $tab.$tab;
2053
+ return $content;
2054
+ }
2055
+
2056
+ /**
2057
+ * get wsi relation messaged for a section
2058
+ * @param $sectionName
2059
+ * @return string
2060
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2061
+ */
2062
+ public function getWsiRelationMessagesSection($sectionName){
2063
+ $content = '';
2064
+ $padding = $this->getPadding();
2065
+ $tab = $padding;
2066
+ $eol = $this->getEol();
2067
+ $module = $this->getModule()->getLowerModuleName();
2068
+ $entity = $this->getNameSingular(true);
2069
+ $entityUc = ucfirst($entity);
2070
+ $label = strtolower($this->getLabelSingular());
2071
+
2072
+ $content .= $padding.'<wsdl:message name="'.$module.$entityUc.$sectionName.'Request">'.$eol;
2073
+ $content .= $padding.$tab.'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.$sectionName.'RequestParam" />'.$eol;
2074
+ $content .= $padding.'</wsdl:message>'.$eol;
2075
+ $content .= $padding.'<wsdl:message name="'.$module.$entityUc.$sectionName.'Response">'.$eol;
2076
+ $content .= $padding.$tab.'<wsdl:part name="parameters" element="typens:'.$module.$entityUc.$sectionName.'ResponseParam" />'.$eol;
2077
+ $content .= $padding.'</wsdl:message>'.$eol;
2078
+
2079
+ return $content;
2080
+ }
2081
+
2082
+ /**
2083
+ * get entity WSI relation messages
2084
+ * @access public
2085
+ * @return string
2086
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2087
+ */
2088
+ public function getWsiRelationMessages(){
2089
+ $content = '';
2090
+ if ($this->getIsTree()){
2091
+ $content .= $this->getWsiRelationMessagesSection('Move');
2092
+ }
2093
+
2094
+ if ($this->getLinkProduct()){
2095
+ $content .= $this->getWsiRelationMessagesSection('AssignProduct');
2096
+ $content .= $this->getWsiRelationMessagesSection('UnassignProduct');
2097
+ }
2098
+
2099
+ if ($this->getLinkCategory()){
2100
+ $content .= $this->getWsiRelationMessagesSection('AssignCategory');
2101
+ $content .= $this->getWsiRelationMessagesSection('UnassignCategory');
2102
+ }
2103
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
2104
+ foreach ($siblings as $sibling){
2105
+ $siblingName = $sibling->getNameSingular(true);
2106
+ $siblingNameUc = ucfirst($siblingName);
2107
+ $siblingLabel = strtolower($sibling->getLabelSingular());
2108
+
2109
+ $content .= $this->getWsiRelationMessagesSection('Assign'.$siblingNameUc);
2110
+ $content .= $this->getWsiRelationMessagesSection('Unassign'.$siblingNameUc);
2111
+ }
2112
+ return $content;
2113
+ }
2114
+
2115
+ /**
2116
+ * get wsdl messages for a section
2117
+ * @param $sectionName
2118
+ * @param $sectionParam
2119
+ * @return string
2120
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2121
+ */
2122
+ public function getWsdlMessagesSection($sectionName, $sectionParam){
2123
+ $content = '';
2124
+ $tab = $this->getPadding();
2125
+ $padding = $tab.$tab;
2126
+ $eol = $this->getEol();
2127
+ $module = $this->getModule()->getLowerModuleName();
2128
+ $entity = $this->getNameSingular(true);
2129
+ $entityUc = ucfirst($entity);
2130
+
2131
+ $content .= $padding.'<message name="'.$module.$entityUc.'Assign'.$sectionName.'Request">'.$eol;
2132
+ $content .= $padding.$tab.'<part name="sessionId" type="xsd:string" />'.$eol;
2133
+ $content .= $padding.$tab.'<part name="'.$entity.'_id" type="xsd:string" />'.$eol;
2134
+ $content .= $padding.$tab.'<part name="'.$sectionParam.'_id" type="xsd:string" />'.$eol;
2135
+ $content .= $padding.$tab.'<part name="position" type="xsd:string" />'.$eol;
2136
+ $content .= $padding.'</message>'.$eol;
2137
+ $content .= $padding.'<message name="'.$module.$entityUc.'Assign'.$sectionName.'Response">'.$eol;
2138
+ $content .= $padding.$tab.'<part name="result" type="xsd:boolean" />'.$eol;
2139
+ $content .= $padding.'</message>'.$eol;
2140
+ $content .= $padding.'<message name="'.$module.$entityUc.'Unassign'.$sectionName.'Request">'.$eol;
2141
+ $content .= $padding.$tab.'<part name="session_id" type="xsd:string" />'.$eol;
2142
+ $content .= $padding.$tab.'<part name="'.$entity.'_id" type="xsd:string" />'.$eol;
2143
+ $content .= $padding.$tab.'<part name="'.$sectionParam.'_id" type="xsd:string" />'.$eol;
2144
+ $content .= $padding.'</message>'.$eol;
2145
+ $content .= $padding.'<message name="'.$module.$entityUc.'Unassign'.$sectionName.'Response">'.$eol;
2146
+ $content .= $padding.$tab.'<part name="result" type="xsd:boolean" />'.$eol;
2147
+ $content .= $padding.'</message>'.$eol;
2148
+
2149
+ return $content;
2150
+ }
2151
+
2152
+ /**
2153
+ * get entity WSDL messages for relations
2154
+ * @access public
2155
+ * @return string
2156
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2157
+ */
2158
+ public function getWsdlMessages(){
2159
+ $content = '';
2160
+ $tab = $this->getPadding();
2161
+ $padding = $tab.$tab;
2162
+ $eol = $this->getEol();
2163
+ $module = $this->getModule()->getLowerModuleName();
2164
+ $entity = $this->getNameSingular(true);
2165
+ $entityUc = ucfirst($entity);
2166
+
2167
+ if ($this->getIsTree()){
2168
+ $content .= $padding.'<message name="'.$module.$entityUc.'MoveRequest">'.$eol;
2169
+ $content .= $padding.$tab.'<part name="session_id" type="xsd:string" />'.$eol;
2170
+ $content .= $padding.$tab.'<part name="'.$entity.'_id" type="xsd:string" />'.$eol;
2171
+ $content .= $padding.$tab.'<part name="parent_id" type="xsd:string" />'.$eol;
2172
+ $content .= $padding.$tab.'<part name="after_id" type="xsd:string" />'.$eol;
2173
+ $content .= $padding.'</message>'.$eol;
2174
+
2175
+ $content .= $padding.'<message name="'.$module.$entityUc.'MoveResponse">'.$eol;
2176
+ $content .= $padding.$tab.'<part name="id" type="xsd:boolean"/>'.$eol;
2177
+ $content .= $padding.'</message>'.$eol;
2178
+ }
2179
+ if ($this->getLinkProduct()){
2180
+ $content .= $this->getWsdlMessagesSection('Product', 'product');
2181
+ }
2182
+
2183
+ if ($this->getLinkCategory()){
2184
+ $content .= $this->getWsdlMessagesSection('Category', 'category');
2185
+ }
2186
+
2187
+ $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
2188
+ foreach ($siblings as $sibling){
2189
+ $siblingName = $sibling->getNameSingular(true);
2190
+ $siblingNameUc = ucfirst($siblingName);
2191
+ $siblingLabel = strtolower($sibling->getLabelSingular());
2192
+
2193
+ $content .= $this->getWsdlMessagesSection($siblingNameUc, $siblingName);
2194
+ }
2195
+ $content .= $tab;
2196
+ return $content;
2197
+ }
2198
+ /**
2199
+ * get foreign keys for sql (Ddl)
2200
+ * @access public
2201
+ * @return string
2202
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2203
+ */
2204
+ public function getParentEntitiesFksDdl(){
2205
+ $padding = $this->getPadding();
2206
+ $eol = $this->getEol();
2207
+ $parents = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD);
2208
+ $content = '';
2209
+
2210
+ $module = $this->getModule()->getLowerModuleName();
2211
+ $namespace = $this->getNamespace(true);
2212
+ foreach ($parents as $parent){
2213
+ $parentName = $parent->getNameSingular(true);
2214
+ $content .= $eol.$padding."->addIndex($"."this->getIdxName('".$namespace.'_'.$module.'/'.$parentName."', array('".$parentName."_id')), array('".$parentName."_id'))";
2215
+ }
2216
+ return $content;
2217
+ }
2218
+
2219
+ /**
2220
+ * get selected menu path
2221
+ * @access public
2222
+ * @param string $suffix
2223
+ * @return string
2224
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2225
+ */
2226
+ public function getSelectedMenuPath($suffix = ''){
2227
+ $path = $this->getModule()->getMenuParent();
2228
+ if (!empty($path)){
2229
+ $path .= '/';
2230
+ }
2231
+ $path .= $this->getModule()->getExtensionName(true).'/';
2232
+ $path .= $this->getNameSingular(true);
2233
+
2234
+ return $path . $suffix;
2235
+ }
2236
+
2237
+ /**
2238
+ * get attributes content for setup
2239
+ * @access public
2240
+ * @return string
2241
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2242
+ */
2243
+ public function getAttributesSetup(){
2244
+ return $this->getTypeInstance()->getAttributesSetup();
2245
+ }
2246
+
2247
+ /**
2248
+ * get parent class for the entity resource model
2249
+ * @access public
2250
+ * @return string
2251
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2252
+ */
2253
+ public function getResourceModelParent(){
2254
+ return $this->getTypeInstance()->getResourceModelParent();
2255
+ }
2256
+ /**
2257
+ * get parent class for the entity resource model
2258
+ * @access public
2259
+ * @return string
2260
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2261
+ */
2262
+ public function getResourceCollectionModelParent(){
2263
+ return $this->getTypeInstance()->getResourceCollectionModelParent();
2264
+ }
2265
+ /**
2266
+ * get related entities relations table
2267
+ * @access public
2268
+ * @return string
2269
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2270
+ */
2271
+ public function getResourceRelationsTables(){
2272
+ return $this->getTypeInstance()->getResourceRelationsTables();
2273
+ }
2274
+ /**
2275
+ * get related entities relations table declaration
2276
+ * @access public
2277
+ * @return string
2278
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2279
+ */
2280
+ public function getResourceRelationsTablesDeclare(){
2281
+ return $this->getTypeInstance()->getResourceRelationsTablesDeclare();
2282
+ }
2283
+ /**
2284
+ * get admin layout content for index page
2285
+ * @access public
2286
+ * @return string
2287
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2288
+ */
2289
+ public function getAdminIndexLayoutContent(){
2290
+ return $this->getTypeInstance()->getAdminIndexLayoutContent();
2291
+ }
2292
+
2293
+ /**
2294
+ * get the parent model class
2295
+ * @access public
2296
+ * @return mixed
2297
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2298
+ */
2299
+ public function getEntityParentModel() {
2300
+ return $this->getTypeInstance()->getEntityParentModel();
2301
+ }
2302
+ /**
2303
+ * get entity table alias
2304
+ * @access public
2305
+ * @return mixed
2306
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2307
+ */
2308
+ public function getEntityTableAlias() {
2309
+ return $this->getTypeInstance()->getEntityTableAlias();
2310
+ }
2311
+ /**
2312
+ * get additional prepare collection
2313
+ * @access public
2314
+ * @return mixed
2315
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2316
+ */
2317
+ public function getAdditionalPrepareCollection(){
2318
+ return $this->getTypeInstance()->getAdditionalPrepareCollection();
2319
+ }
2320
+
2321
+ /**
2322
+ * additional layout block for left section
2323
+ * @access public
2324
+ * @return mixed
2325
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2326
+ */
2327
+ public function getEditLayoutLeft() {
2328
+ return $this->getTypeInstance()->getEditLayoutLeft();
2329
+ }
2330
+ /**
2331
+ * additional layout block edit
2332
+ * @access public
2333
+ * @return mixed
2334
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2335
+ */
2336
+ public function getEditLayoutAdditional(){
2337
+ return $this->getTypeInstance()->getEditLayoutAdditional();
2338
+ }
2339
+
2340
+ /**
2341
+ * get the label for product attribute scope
2342
+ * @access public
2343
+ * @return string
2344
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2345
+ */
2346
+ public function getProductAttributeScopeLabel(){
2347
+ return $this->_getScopeLabel($this->getProductAttributeScope());
2348
+ }
2349
+ /**
2350
+ * get the label for category attribute scope
2351
+ * @access public
2352
+ * @return string
2353
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2354
+ */
2355
+ public function getCategoryAttributeScopeLabel(){
2356
+ return $this->_getScopeLabel($this->getCategoryAttributeScope());
2357
+ }
2358
+
2359
+ /**
2360
+ * get scope label for install scripts
2361
+ * @param $value
2362
+ * @return string
2363
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2364
+ */
2365
+ protected function _getScopeLabel($value){
2366
+ $values = array(
2367
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE',
2368
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE',
2369
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL'
2370
+ );
2371
+ if (!isset($values[$value])) {
2372
+ $value = Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL;
2373
+ }
2374
+ return $values[$value];
2375
+ }
2376
+
2377
+ /**
2378
+ * check if the entity is used as an attribute
2379
+ * @access public
2380
+ * @return bool
2381
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2382
+ */
2383
+ public function getIsAttribute() {
2384
+ return $this->getProductAttribute() || $this->getCategoryAttribute();
2385
+ }
2386
+
2387
+ /**
2388
+ * check if source model can be created
2389
+ * @access public
2390
+ * @return bool
2391
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2392
+ */
2393
+ public function getCanCreateSourceModel() {
2394
+ return $this->getIsAttribute() || $this->getIsParent();
2395
+ }
2396
+
2397
+ /**
2398
+ * check if entity has children
2399
+ * @access public
2400
+ * @return bool
2401
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2402
+ */
2403
+ public function getIsParent() {
2404
+ $children = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT);
2405
+ return count($children) > 0;
2406
+ }
2407
+
2408
+ /**
2409
+ * get product attribute group
2410
+ * @access public
2411
+ * @return string
2412
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2413
+ */
2414
+ public function getProductAttributeGroupLabel() {
2415
+ if ($this->getProductAttributeGroup()) {
2416
+ return "'group' => '".$this->getProductAttributeGroup()."',".$this->getEol().$this->getPadding();
2417
+ }
2418
+ return '';
2419
+ }
2420
+ /**
2421
+ * get category attribute group
2422
+ * @access public
2423
+ * @return string
2424
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2425
+ */
2426
+ public function getCategoryAttributeGroupLabel() {
2427
+ if ($this->getCategoryAttributeGroup()) {
2428
+ return "'group' => '".$this->getCategoryAttributeGroup()."',".$this->getEol().$this->getPadding();
2429
+ }
2430
+ return '';
2431
+ }
2432
+
2433
+ /**
2434
+ * get param name for before save
2435
+ * @access public
2436
+ * @return mixed
2437
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2438
+ */
2439
+ public function getBeforeSaveParam() {
2440
+ return $this->getTypeInstance()->getBeforeSaveParam();
2441
+ }
2442
+
2443
+ /**
2444
+ * entity attribute set string
2445
+ * @access public
2446
+ * @return string
2447
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2448
+ */
2449
+ public function getEntityAttributeSetId() {
2450
+ return $this->getTypeInstance()->getEntityAttributeSetId();
2451
+ }
2452
+ /**
2453
+ * filter method name
2454
+ * @access public
2455
+ * @return string
2456
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2457
+ */
2458
+ public function getFilterMethod() {
2459
+ return $this->getTypeInstance()->getFilterMethod();
2460
+ }
2461
+
2462
+ /**
2463
+ * convert multiple select fields to strings
2464
+ * @access public
2465
+ * @return mixed
2466
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2467
+ */
2468
+ public function getMultipleSelectConvert(){
2469
+ return $this->getTypeInstance()->getMultipleSelectConvert();
2470
+ }
2471
+
2472
+ /**
2473
+ * check if the entity helper can be created
2474
+ * @access public
2475
+ * @return bool
2476
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2477
+ */
2478
+ public function getCanCreateEntityHelper(){
2479
+ if ($this->getIsTree()) {
2480
+ return true;
2481
+ }
2482
+ if ($this->getHasFile()) {
2483
+ return true;
2484
+ }
2485
+ if ($this->getCreateFrontend()) {
2486
+ return true;
2487
+ }
2488
+ return $this->getTypeInstance()->getCanCreateEntityHelper();
2489
+ }
2490
+
2491
+ /**
2492
+ * get additional code for toOptionArray()
2493
+ * @access public
2494
+ * @return string
2495
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2496
+ */
2497
+ public function getToOptionAddition(){
2498
+ return $this->getTypeInstance()->getToOptionAddition();
2499
+ }
2500
+
2501
+ /**
2502
+ * check if entity should be included in the category menu
2503
+ * @access public
2504
+ * @return bool
2505
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2506
+ */
2507
+ public function getShowInCategoryMenu() {
2508
+ return $this->getListMenu() == Ultimate_ModuleCreator_Model_Source_Entity_Menu::CATEGORY_MENU;
2509
+ }
2510
+
2511
+ /**
2512
+ * get multiselect methods
2513
+ * @access public
2514
+ * @return string
2515
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2516
+ */
2517
+ public function getMultiselectMethods() {
2518
+ $content = '';
2519
+ $padding = $this->getPadding();
2520
+ $tab = $this->getPadding();
2521
+ $eol = $this->getEol();
2522
+ foreach ($this->getAttributes() as $attribute) {
2523
+ $magicCode = $attribute->getMagicMethodCode();
2524
+ $code = $attribute->getCode();
2525
+ if ($attribute->getTypeInstance() instanceof Ultimate_ModuleCreator_Model_Attribute_Type_Multiselect) {
2526
+ $content .= $eol.$padding.'/**'.$eol;
2527
+ $content .= $padding.' * get '.$attribute->getLabel().$eol;
2528
+ $content .= $padding.' * @access public'.$eol;
2529
+ $content .= $padding.' * @return array'.$eol;
2530
+ $content .= $padding.' * '.$this->getModule()->getQwertyuiop().$eol;
2531
+ $content .= $padding.' */'.$eol;
2532
+ $content .= $padding.'public function get'.$magicCode.'() {'.$eol;
2533
+ $content .= $padding.$tab.'if (!$this->getData(\''.$code.'\')) {'.$eol;
2534
+ $content .= $padding.$tab.$tab.'return explode(\',\',$this->getData(\''.$code.'\'));'.$eol;
2535
+ $content .= $padding.$tab.'}'.$eol;
2536
+ $content .= $padding.$tab.'return $this->getData(\''.$code.'\');'.$eol;
2537
+ $content .= $padding.'}';
2538
+ }
2539
+ }
2540
+ return $content;
2541
+ }
2542
+
2543
+ /**
2544
+ * get html for displaying the name
2545
+ * @access public
2546
+ * @return string
2547
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2548
+ */
2549
+ public function getNameHtml() {
2550
+ $content = '';
2551
+ $lower = $this->getNameSingular(true);
2552
+ $ucFirst = ucfirst($lower);
2553
+ $name = $this->getNameAttributeMagicCode();
2554
+ if ($this->getCreateView()) {
2555
+ $content .= '\'<a href="\'.$'.$lower.'->get'.$ucFirst.'Url().\'">\'.$'.$lower.'->get'.$name.'().\'</a>\'';
2556
+ }
2557
+ else {
2558
+ $content .= '\'<a href="#">\'.$'.$lower.'->get'.$name.'().\'</a>\'';
2559
+ }
2560
+ return $content;
2561
+ }
2562
+
2563
+ /**
2564
+ * check if the entity is not store related
2565
+ * @access public
2566
+ * @return bool
2567
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2568
+ */
2569
+ public function getNoStore() {
2570
+ return !$this->getStore();
2571
+ }
2572
+ /**
2573
+ * get comment name field filter index
2574
+ * @access public
2575
+ * @return string
2576
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2577
+ */
2578
+ public function getCommentFilterIndexPrefix() {
2579
+ return $this->getTypeInstance()->getCommentFilterIndexPrefix();
2580
+ }
2581
+ /**
2582
+ * additional API subentities.
2583
+ * @access public
2584
+ * @return string
2585
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2586
+ */
2587
+ public function getApiAdditionalSettings() {
2588
+ $content = '';
2589
+
2590
+ if ($this->getAllowComment()) {
2591
+ $padding = $this->getPadding(3);
2592
+ $tab = $this->getPadding();
2593
+ $module = $this->getModule()->getLowerModuleName();
2594
+ $entity = $this->getNameSingular(true);
2595
+ $eol = $this->getEol();
2596
+ $title = $this->getLabelSingular().' Comments';
2597
+ $ns = $this->getNamespace(true);
2598
+
2599
+ $content .= $eol;
2600
+ $content .= $padding.'<'.$module.'_'.$entity.'_comment translate="title" module="'.$ns.'_'.$module.'">'.$eol;
2601
+ $content .= $padding.$tab.'<title>'.$title.'</title>'.$eol;
2602
+ $content .= $padding.$tab.'<model>'.$ns.'_'.$module.'/'.$entity.'_comment_api</model>'.$eol;
2603
+ $content .= $padding.$tab.'<acl>'.$module.'/'.$entity.'/comment</acl>'.$eol;
2604
+ $content .= $padding.$tab.'<methods>'.$eol;
2605
+ $content .= $padding.$tab.$tab.'<list translate="title" module="'.$ns.'_'.$module.'">'.$eol;
2606
+ $content .= $padding.$tab.$tab.$tab.'<title>Retrieve '.$title.'</title>'.$eol;
2607
+ $content .= $padding.$tab.$tab.$tab.'<method>items</method>'.$eol;
2608
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_comment/list</acl>'.$eol;
2609
+ $content .= $padding.$tab.$tab.'</list>'.$eol;
2610
+ $content .= $padding.$tab.$tab.'<updateStatus translate="title" module="'.$ns.'_'.$module.'">'.$eol;
2611
+ $content .= $padding.$tab.$tab.$tab.'<title>Update '.$this->getLabelSingular().' Status</title>'.$eol;
2612
+ $content .= $padding.$tab.$tab.$tab.'<method>updateStatus</method>'.$eol;
2613
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_comment/updateStatus</acl>'.$eol;
2614
+ $content .= $padding.$tab.$tab.'</updateStatus>'.$eol;
2615
+ $content .= $padding.$tab.'</methods>'.$eol;
2616
+ $content .= $padding.$tab.'<faults module="'.$ns.'_'.$module.'">'.$eol;
2617
+ $content .= $padding.$tab.$tab.'<not_exists>'.$eol;
2618
+ $content .= $padding.$tab.$tab.$tab.'<code>101</code>'.$eol;
2619
+ $content .= $padding.$tab.$tab.$tab.'<message>Requested comment not found.</message>'.$eol;
2620
+ $content .= $padding.$tab.$tab.'</not_exists>'.$eol;
2621
+ $content .= $padding.$tab.'</faults>'.$eol;
2622
+ $content .= $padding.'</'.$module.'_'.$entity.'_comment>'.$eol;
2623
+ }
2624
+ $content .= $this->getTypeInstance()->getApiAdditionalSettings();
2625
+ return $content;
2626
+ }
2627
+ /**
2628
+ * get subentities acl
2629
+ * @access public
2630
+ * @return string
2631
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2632
+ */
2633
+ public function getSubEntitiesAcl(){
2634
+ $content = '';
2635
+ if ($this->getAllowComment()) {
2636
+ $padding = $this->getPadding(5);
2637
+ $tab = $this->getPadding();
2638
+ $module = $this->getModule()->getLowerModuleName();
2639
+ $entity = $this->getNameSingular(true);
2640
+ $eol = $this->getEol();
2641
+ $title = $this->getLabelSingular().' Comments';
2642
+ $content .= $eol;
2643
+ $ns = $this->getModule()->getNamespace(true);
2644
+
2645
+ $content .= $padding.'<'.$entity.'_comment translate="title" module="'.$ns.'_'.$module.'">'.$eol;
2646
+ $content .= $padding.$tab.'<title>'.$title.'</title>'.$eol;
2647
+ $content .= $padding.$tab.'<sort_order>'.($this->getPosition() + 3).'</sort_order>'.$eol;
2648
+ $content .= $padding.$tab.'<list translate="title" module="'.$ns.'_'.$module.'">'.$eol;
2649
+ $content .= $padding.$tab.$tab.'<title>List</title>'.$eol;
2650
+ $content .= $padding.$tab.'</list>'.$eol;
2651
+ $content .= $padding.$tab.'<updateStatus translate="title" module="'.$ns.'_'.$module.'">'.$eol;
2652
+ $content .= $padding.$tab.$tab.'<title>Update Status</title>'.$eol;
2653
+ $content .= $padding.$tab.'</updateStatus>'.$eol;
2654
+ $content .= $padding.'</'.$entity.'_comment>'.$eol;
2655
+ }
2656
+ $content .= $this->getTypeInstance()->getSubEntitiesAcl();
2657
+ return $content;
2658
+ }
2659
+ /**
2660
+ * get api aliases
2661
+ * @access public
2662
+ * @return string
2663
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2664
+ */
2665
+ public function getApiResourcesAlias() {
2666
+ $content = '';
2667
+ if ($this->getAllowComment()) {
2668
+ $padding = $this->getPadding(3);
2669
+ $tab = $this->getPadding();
2670
+ $module = $this->getModule()->getLowerModuleName();
2671
+ $entity = $this->getNameSingular(true);
2672
+ $eol = $this->getEol();
2673
+ $ns = $this->getNamespace(true);
2674
+ $content .= $eol;
2675
+ $content .= $padding.'<'.$entity.'_comment>'.$module.'_'.$entity.'_comment</'.$entity.'_comment>';
2676
+ }
2677
+ $content .= $this->getTypeInstance()->getApiResourcesAlias();
2678
+ return $content;
2679
+ }
2680
+ /**
2681
+ * get api V2 aliases
2682
+ * @access public
2683
+ * @return string
2684
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2685
+ */
2686
+ public function getApiResourcesAliasV2() {
2687
+ $content = '';
2688
+ if ($this->getAllowComment()) {
2689
+ $padding = $this->getPadding(4);
2690
+ $tab = $this->getPadding();
2691
+ $module = $this->getModule()->getLowerModuleName();
2692
+ $entity = strtolower($this->getNameSingular());
2693
+ $eol = $this->getEol();
2694
+ $content .= $eol;
2695
+ $content .= $padding.'<'.$entity.'_comment>'.$module.ucfirst($entity).'Comment</'.$entity.'_comment>';
2696
+ }
2697
+ $content .= $this->getTypeInstance()->getApiResourcesAliasV2();
2698
+ return $content;
2699
+ }
2700
+
2701
+ /**
2702
+ * get default api attributes
2703
+ * @access public
2704
+ * @return string
2705
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2706
+ */
2707
+ public function getDefaultApiAttributes(){
2708
+ return $this->getTypeInstance()->getDefaultApiAttributes();
2709
+ }
2710
+ /**
2711
+ * get the module namespace
2712
+ * @access public
2713
+ * @param bool $lower
2714
+ * @return mixed|string
2715
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2716
+ */
2717
+ public function getNamespace($lower = false){
2718
+ return $this->getModule()->getNamespace($lower);
2719
+ }
2720
+ /**
2721
+ * get entity name
2722
+ * @access public
2723
+ * @param bool $lower
2724
+ * @return mixed|string
2725
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2726
+ */
2727
+ public function getNameSingular($lower = false){
2728
+ $name = $this->getData('name_singular');
2729
+ if ($lower){
2730
+ $name = strtolower($name);
2731
+ }
2732
+ return $name;
2733
+ }
2734
+
2735
+ /**
2736
+ * get code that filters dates
2737
+ * @access public
2738
+ * @param int $padding
2739
+ * @return string
2740
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
2741
+ */
2742
+ public function getFilterDates($padding = 4) {
2743
+ $dateAttributes = array();
2744
+ foreach ($this->getAttributes() as $attribute) {
2745
+ if ($attribute->getTypeInstance() instanceof Ultimate_ModuleCreator_Model_Attribute_Type_Timestamp) {
2746
+ $dateAttributes[] = $attribute->getCode();
2747
+ }
2748
+ }
2749
+ if (count($dateAttributes) == 0) {
2750
+ return '';
2751
+ }
2752
+ return $this->getEol().$this->getPadding($padding).'$data = $this->_filterDates($data, array(\''.implode("' ,", $dateAttributes).'\'));';
2753
+ }
2754
  }
app/code/community/Ultimate/ModuleCreator/Model/Entity/Type/Abstract.php ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * abstract entity type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ abstract class Ultimate_ModuleCreator_Model_Entity_Type_Abstract
26
+ extends Ultimate_ModuleCreator_Model_Abstract {
27
+ /**
28
+ * constant for eav type
29
+ */
30
+ const TYPE_EAV = 'eav';
31
+ /**
32
+ * constant for flat type
33
+ */
34
+ const TYPE_FLAT = 'flat';
35
+ /**
36
+ * current entity
37
+ * @var mixed
38
+ */
39
+ protected $_entity = null;
40
+ /**
41
+ * set the entity
42
+ * @access public
43
+ * @param Ultimate_ModuleCreator_Model_Entity $entity
44
+ * @return Ultimate_ModuleCreator_Model_Entity_Type_Abstract
45
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
46
+ */
47
+ public function setEntity(Ultimate_ModuleCreator_Model_Entity $entity) {
48
+ $this->_entity = $entity;
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * get the entity object
54
+ * @access public
55
+ * @return Ultimate_ModuleCreator_Model_Entity|null
56
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
57
+ */
58
+ public function getEntity() {
59
+ return $this->_entity;
60
+ }
61
+ /**
62
+ * get the module object
63
+ * @access public
64
+ * @return Ultimate_ModuleCreator_Model_Module|null
65
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
66
+ */
67
+ public function getModule(){
68
+ return $this->getEntity()->getModule();
69
+ }
70
+ /**
71
+ * get the namespace
72
+ * @access public
73
+ * @param bool $lower
74
+ * @return string
75
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
76
+ */
77
+ public function getNamespace($lower = false) {
78
+ return $this->getModule()->getNamespace($lower);
79
+ }
80
+ /**
81
+ * get lower module name
82
+ * @access public
83
+ * @return string
84
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
85
+ */
86
+ public function getLowerModuleName() {
87
+ return $this->getModule()->getLowerModuleName();
88
+ }
89
+ /**
90
+ * get collection attributes
91
+ * @access public
92
+ * @return string
93
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
94
+ */
95
+ public function getCollectionAttributes() {
96
+ return '';
97
+ }
98
+ /**
99
+ * get admin join
100
+ * @access public
101
+ * @return string
102
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
103
+ */
104
+ public function getAdminJoin() {
105
+ return '';
106
+ }
107
+ /**
108
+ * prepare columns text
109
+ * @access public
110
+ * @return string
111
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
112
+ */
113
+ public function getPrepareColumnsHeader() {
114
+ return '';
115
+ }
116
+ /**
117
+ * get name attribute grid eav
118
+ * @access public
119
+ * @return string
120
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
121
+ */
122
+ public function getNameAttributeGridEav() {
123
+ return '';
124
+ }
125
+ /**
126
+ * check if entity has images
127
+ * @access public
128
+ * @return bool
129
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
130
+ */
131
+ public function getHasImage() {
132
+ return $this->getEntity()->getData('has_image');
133
+ }
134
+ /**
135
+ * check if entity has files
136
+ * @access public
137
+ * @return bool
138
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
139
+ */
140
+ public function getHasFile() {
141
+ return $this->getEntity()->getData('has_file');
142
+ }
143
+ /**
144
+ * check if submenu should exist
145
+ * @access public
146
+ * @return bool
147
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
148
+ */
149
+ public function getHasSubmenu() {
150
+ return false;
151
+ }
152
+ /**
153
+ * get Additional submenu
154
+ * @access public
155
+ * @param $padding
156
+ * @return string
157
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
158
+ */
159
+ public function getAdditionalMenu($padding) {
160
+ return '';
161
+ }
162
+ /**
163
+ * get Additional menu acl
164
+ * @access public
165
+ * @param $padding
166
+ * @return string
167
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
168
+ */
169
+ public function getAdditionalMenuAcl($padding) {
170
+ return '';
171
+ }
172
+ /**
173
+ * check if comments are allowed by store
174
+ * @access public
175
+ * @return string
176
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
177
+ */
178
+ public function getAllowCommentByStore() {
179
+ return $this->getEntity()->getAllowComment() && $this->getEntity()->getStore();
180
+ }
181
+ /**
182
+ * get attributes content for setup
183
+ * @access public
184
+ * @return string
185
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
186
+ */
187
+ public function getAttributesSetup(){
188
+ return '';
189
+ }
190
+ /**
191
+ * get parent class for the entity resource model
192
+ * @access public
193
+ * @return string
194
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
195
+ */
196
+ public function getResourceModelParent(){
197
+ return 'Mage_Core_Model_Resource_Db_Abstract';
198
+ }
199
+ /**
200
+ * get parent class for the entity resource collection model
201
+ * @access public
202
+ * @return string
203
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
204
+ */
205
+ public function getResourceCollectionModelParent(){
206
+ return 'Mage_Core_Model_Resource_Db_Collection_Abstract';
207
+ }
208
+
209
+ /**
210
+ * get related entities relations table
211
+ * @access public
212
+ * @return string
213
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
214
+ */
215
+ public function getResourceRelationsTables(){
216
+ return '';
217
+ }
218
+ /**
219
+ * get related entities relations table declaration
220
+ * @access public
221
+ * @return string
222
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
223
+ */
224
+ public function getResourceRelationsTablesDeclare(){
225
+ return '';
226
+ }
227
+ /**
228
+ * get admin layout content for index page
229
+ * @access public
230
+ * @return string
231
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
232
+ */
233
+ public function getAdminIndexLayoutContent(){
234
+ $entity = $this->getEntity()->getNameSingular(true);
235
+ $module = $this->getLowerModuleName();
236
+ $namespace = $this->getNamespace(true);
237
+ return $this->getPadding(3).'<block type="'.$namespace.'_'.$module.'/adminhtml_'.$entity.'" name="'.$entity.'" />'.$this->getEol();
238
+ }
239
+ /**
240
+ * get the parent model class
241
+ * @access public
242
+ * @return mixed
243
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
244
+ */
245
+ public function getEntityParentModel(){
246
+ return 'Mage_Core_Model_Abstract';
247
+ }
248
+ /**
249
+ * get entity table alias
250
+ * @access public
251
+ * @return mixed
252
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
253
+ */
254
+ public function getEntityTableAlias() {
255
+ return 'main_table';
256
+ }
257
+ /**
258
+ * get additional prepare collection
259
+ * @access public
260
+ * @return mixed
261
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
262
+ */
263
+ public function getAdditionalPrepareCollection(){
264
+ return '';
265
+ }
266
+ /**
267
+ * additional layout block for left section
268
+ * @access public
269
+ * @return mixed
270
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
271
+ */
272
+ public function getEditLayoutLeft() {
273
+ return '';
274
+ }
275
+ /**
276
+ * additional layout block edit
277
+ * @access public
278
+ * @return mixed
279
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
280
+ */
281
+ public function getEditLayoutAdditional() {
282
+ return '';
283
+ }
284
+ /**
285
+ * get param name for before save
286
+ * @access public
287
+ * @return mixed
288
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
289
+ */
290
+ public function getBeforeSaveParam() {
291
+ return 'Mage_Core_Model_Abstract';
292
+ }
293
+ /**
294
+ * entity attribute set string
295
+ * @access public
296
+ * @return string
297
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
298
+ */
299
+ public function getEntityAttributeSetId() {
300
+ return '';
301
+ }
302
+ /**
303
+ * filter method name
304
+ * @access public
305
+ * @return string
306
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
307
+ */
308
+ public function getFilterMethod() {
309
+ return 'addFieldToFilter';
310
+ }
311
+ /**
312
+ * convert multiple select fields to strings
313
+ * @access public
314
+ * @return mixed
315
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
316
+ */
317
+ public function getMultipleSelectConvert(){
318
+ $padding = $this->getPadding(2);
319
+ $tab = $this->getPadding();
320
+ $eol = $this->getEol();
321
+ $content = '';
322
+ foreach ($this->getEntity()->getAttributes() as $attribute){
323
+ if ($attribute->getIsMultipleSelect()){
324
+ $ucCode = $attribute->getMagicMethodCode();
325
+ $lcCode = $attribute->getCodeForFileName(false);
326
+ $content .= '$'.$attribute->getCodeForFileName(false).' = $object->get'.$ucCode.'();'.$eol;
327
+ $content .= $padding.'if (is_array($'.$lcCode.')) {'.$eol;
328
+ $content .= $padding.$tab.'$object->set'.$ucCode."(implode(',', $".$lcCode.'));'.$eol;
329
+ $content .= $padding.'}'.$eol.$padding;
330
+ }
331
+ }
332
+ return $content;
333
+ }
334
+ /**
335
+ * check if the entity helper can be created
336
+ * @access public
337
+ * @return bool
338
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
339
+ */
340
+ public function getCanCreateEntityHelper(){
341
+ return false;
342
+ }
343
+ /**
344
+ * get additional code for toOptionArray()
345
+ * @access public
346
+ * @return string
347
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
348
+ */
349
+ public function getToOptionAddition(){
350
+ return '';
351
+ }
352
+ /**
353
+ * get comment name field filter index
354
+ * @access public
355
+ * @return string
356
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
357
+ */
358
+ public function getCommentFilterIndexPrefix() {
359
+ return $this->getEntityTableAlias().'.';
360
+ }
361
+ /**
362
+ * get additional api xml
363
+ * @access public
364
+ * @return string
365
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
366
+ */
367
+ public function getApiAdditional(){
368
+ return '';
369
+ }
370
+ /**
371
+ * get additional api faults
372
+ * @access public
373
+ * @return string
374
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
375
+ */
376
+ public function getApiFaults(){
377
+ return '';
378
+ }
379
+ /**
380
+ * additional API subentities.
381
+ * @access public
382
+ * @return string
383
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
384
+ */
385
+ public function getApiAdditionalSettings() {
386
+ return '';
387
+ }
388
+ /**
389
+ * get subentities acl
390
+ * @access public
391
+ * @return string
392
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
393
+ */
394
+ public function getSubEntitiesAcl(){
395
+ return '';
396
+ }
397
+ /**
398
+ * get api aliases
399
+ * @access public
400
+ * @return string
401
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
402
+ */
403
+ public function getApiResourcesAlias() {
404
+ return '';
405
+ }
406
+ /**
407
+ * get api V2 aliases
408
+ * @access public
409
+ * @return string
410
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
411
+ */
412
+ public function getApiResourcesAliasV2() {
413
+ return '';
414
+ }
415
+ /**
416
+ * get attributes format for wsdl
417
+ * @access public
418
+ * @param bool $wsi
419
+ * @return string
420
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
421
+ */
422
+ public function getWsdlAttributes($wsi = false){
423
+ return '';
424
+ }
425
+ /**
426
+ * get default api attributes
427
+ * @access public
428
+ * @return string
429
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
430
+ */
431
+ public function getDefaultApiAttributes(){
432
+ return '';
433
+ }
434
+ }
app/code/community/Ultimate/ModuleCreator/Model/Entity/Type/Eav.php ADDED
@@ -0,0 +1,737 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ class Ultimate_ModuleCreator_Model_Entity_Type_Eav extends Ultimate_ModuleCreator_Model_Entity_Type_Abstract{
19
+ protected $_parentAttributes = null;
20
+ /**
21
+ * get collection attributes
22
+ * @access public
23
+ * @return string
24
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
25
+ */
26
+ public function getCollectionAttributes(){
27
+ $result = '';
28
+ $eol = $this->getEol();
29
+ $padding = $this->getPadding(3);
30
+ foreach ($this->_getParentAttributes() as $attribute) {
31
+ $result .= $eol;
32
+ $result .= $padding;
33
+ $result .= '->addAttributeToSelect(\''.$attribute->getCode().'\')';
34
+ }
35
+ foreach ($this->getEntity()->getAttributes() as $attribute){
36
+ if ($attribute->getAdminGrid() && $attribute->getCode() != $this->getEntity()->getNameAttributeCode()){
37
+ $result .= $eol;
38
+ $result .= $padding;
39
+ $result .= '->addAttributeToSelect(\''.$attribute->getCode().'\')';
40
+ }
41
+ }
42
+ foreach ($this->getEntity()->getSimulatedAttributes('status') as $attribute){
43
+ $result .= $eol;
44
+ $result .= $padding;
45
+ $result .= '->addAttributeToSelect(\''.$attribute->getCode().'\')';
46
+ }
47
+ if ($this->getEntity()->getUrlRewrite()){
48
+ foreach ($this->getEntity()->getSimulatedAttributes('url_rewrite') as $attribute){
49
+ $result .= $eol;
50
+ $result .= $padding;
51
+ $result .= '->addAttributeToSelect(\''.$attribute->getCode().'\')';
52
+ }
53
+ }
54
+ return $result;
55
+ }
56
+ /**
57
+ * get admin join
58
+ * @access public
59
+ * @return string
60
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
61
+ */
62
+ public function getAdminJoin(){
63
+ $eol = $this->getEol();
64
+ $result = $eol;
65
+ $result .= $this->getPadding(2).'$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;'.$eol;
66
+ $result .= $this->getPadding(2).'$store = $this->_getStore();'.$eol;
67
+ $result .= $this->getPadding(2).'$collection->joinAttribute(\''.$this->getEntity()->getNameAttributeCode().'\', \''.strtolower($this->getEntity()->getModule()->getNamespace()).'_'.$this->getEntity()->getModule()->getLowerModuleName().'_'.$this->getEntity()->getNameSingular().'/'.$this->getEntity()->getNameAttributeCode().'\', \'entity_id\', null, \'inner\', $adminStore);'.$eol;
68
+ $result .= $this->getPadding(2).'if ($store->getId()) {'.$eol;
69
+ $result .= $this->getPadding(3). '$collection->joinAttribute(\''.$this->getModule()->getNamespace(true).'_'.$this->getModule()->getLowerModuleName().'_'.$this->getEntity()->getNameSingular().'_'.$this->getEntity()->getNameAttributeCode().'\', \''.$this->getModule()->getNamespace(true).'_'.$this->getModule()->getLowerModuleName().'_'.$this->getEntity()->getNameSingular().'/'.$this->getEntity()->getNameAttributeCode().'\', \'entity_id\', null, \'inner\', $store->getId());'.$eol;
70
+ $result .= $this->getPadding(2).'}'.$eol;
71
+ return $result;
72
+ }
73
+
74
+ /**
75
+ * prepare columns header
76
+ * @access public
77
+ * @return string
78
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
79
+ */
80
+ public function getPrepareColumnsHeader(){
81
+ return '$store = $this->_getStore();'.$this->getEol().$this->getPadding(2);
82
+ }
83
+
84
+ /**
85
+ * get name attribute for grid
86
+ * @access public
87
+ * @return string
88
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
89
+ */
90
+ public function getNameAttributeGridEav(){
91
+ $eol = $this->getEol();
92
+ $result = $eol;
93
+ $result .= $this->getPadding(2).'if ($this->_getStore()->getId()){'.$eol;
94
+ $result .= $this->getPadding(3). '$this->addColumn(\''.$this->getNamespace(true).'_'.$this->getLowerModuleName().'_'.$this->getEntity()->getNameSingular().'_'.$this->getEntity()->getNameAttributeCode().'\', array('.$eol;
95
+ $result .= $this->getPadding(4). '\'header\' => Mage::helper(\''.$this->getNamespace(true).'_'.$this->getLowerModuleName().'\')->__(\''.$this->getEntity()->getNameAttributeLabel().' in %s\', $this->_getStore()->getName()),'.$eol;
96
+ $result .= $this->getPadding(4). '\'align\' => \'left\','.$eol;
97
+ $result .= $this->getPadding(4). '\'index\' => \''.$this->getNamespace(true).'_'.$this->getLowerModuleName().'_'.$this->getEntity()->getNameSingular().'_'.$this->getEntity()->getNameAttributeCode().'\','.$eol;
98
+ $result .= $this->getPadding(3). '));'.$eol;
99
+ $result .= $this->getPadding(2).'}'.$eol;
100
+ return $result;
101
+ }
102
+
103
+ /**
104
+ * eav always has image
105
+ * @access public
106
+ * @return bool
107
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
108
+ */
109
+ public function getHasImage(){
110
+ return true;
111
+ }
112
+ /**
113
+ * eav always has files
114
+ * @access public
115
+ * @return bool
116
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
117
+ */
118
+ public function getHasFile(){
119
+ return true;
120
+ }
121
+ /**
122
+ * eav always has submenu
123
+ * @access public
124
+ * @return bool
125
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
126
+ */
127
+ public function getHasSubmenu(){
128
+ return true;
129
+ }
130
+ /**
131
+ * get additional menu
132
+ * @access public
133
+ * @param $padding
134
+ * @return bool
135
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
136
+ */
137
+ public function getAdditionalMenu($padding) {
138
+ $extension = $this->getModule()->getExtensionName(true);
139
+ $module = $this->getLowerModuleName();
140
+ $entity = $this->getEntity()->getNameSingular(true);
141
+ $entityTitle = $this->getEntity()->getLabelSingular();
142
+ $action = $module.'_'.$entity;
143
+ $eol = $this->getEol();
144
+
145
+ $text = $this->getPadding($padding).'<'.$entity.'_attributes translate="title" module="'.$extension.'">'.$eol;
146
+ $text .= $this->getPadding($padding + 1).'<title>Manage '.$entityTitle.' Attributes</title>'.$eol;
147
+ $text .= $this->getPadding($padding + 1).'<action>adminhtml/'.$action.'_attribute</action>'.$eol;
148
+ $text .= $this->getPadding($padding + 1).'<sort_order>'.($this->getEntity()->getPosition() + 7).'</sort_order>'.$eol;
149
+ $text .= $this->getPadding($padding).'</'.$entity.'_attributes>'.$eol;
150
+ return $text;
151
+ }
152
+
153
+ /**
154
+ * get additional menu acl
155
+ * @access public
156
+ * @param $padding
157
+ * @return string
158
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
159
+ */
160
+ public function getAdditionalMenuAcl($padding) {
161
+ $extension = $this->getModule()->getExtensionName(true);
162
+ $module = $this->getLowerModuleName();
163
+ $entity = $this->getEntity()->getNameSingular(true);
164
+ $entityTitle = $this->getEntity()->getLabelSingular();
165
+ $action = $module.'_'.$entity;
166
+ $eol = $this->getEol();
167
+
168
+ $text = $this->getPadding($padding).'<'.$entity.'_attributes translate="title" module="'.$extension.'">'.$eol;
169
+ $text .= $this->getPadding($padding + 1).'<title>Manage '.$entityTitle.' attributes</title>'.$eol;
170
+ $text .= $this->getPadding($padding + 1).'<sort_order>'.($this->getEntity()->getPosition() + 7).'</sort_order>'.$eol;
171
+ $text .= $this->getPadding($padding).'</'.$entity.'_attributes>'.$eol;
172
+ return $text;
173
+ }
174
+ /**
175
+ * allow comments by store
176
+ * @access public
177
+ * @return string
178
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
179
+ */
180
+ public function getAllowCommentByStore() {
181
+ return $this->getEntity()->getAllowComment();
182
+ }
183
+
184
+ /**
185
+ * get parent attributes
186
+ * @access protected
187
+ * @return array
188
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
189
+ */
190
+ protected function _getParentAttributes(){
191
+ if (is_null($this->_parentAttributes)) {
192
+ $parents = $this->getEntity()->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD);
193
+ $this->_parentAttributes = array();
194
+ foreach ($parents as $parent) {
195
+ $module = $parent->getModule()->getLowerModuleName();
196
+ $namespace = $parent->getModule()->getNamespace(true);
197
+ $name = $parent->getNameSingular();
198
+ $attr = Mage::getModel('modulecreator/attribute');
199
+ $attr->setCode($name.'_id');
200
+ $attr->setLabel($parent->getLabelSingular());
201
+ $attr->setType('dropdown');
202
+ $attr->setOptionsSource('custom');
203
+ $attr->setForcedSource($namespace.'_'.$module.'/'.$name.'_source');
204
+ $attr->setScope(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL);
205
+ $attr->setEntity($this->getEntity());
206
+ $attr->setUseFilterIndex(true);
207
+ $this->_parentAttributes[] = $attr;
208
+ }
209
+ }
210
+ return $this->_parentAttributes;
211
+ }
212
+
213
+ /**
214
+ * get attributes content for setup
215
+ * @access public
216
+ * @return string
217
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
218
+ */
219
+ public function getAttributesSetup() {
220
+ $content = '';
221
+ $position = 0;
222
+ //all parent attributes
223
+ foreach ($this->_getParentAttributes() as $attribute) {
224
+ $content .= $attribute->getSetupContent();
225
+ }
226
+ foreach ($this->getEntity()->getAttributes() as $attribute){
227
+ $content .= $attribute->getSetupContent();
228
+ $position = $attribute->getPosition();
229
+ }
230
+ $position += 10;
231
+ foreach ($this->getEntity()->getSimulatedAttributes(null, false, array('tree')) as $attribute) {
232
+ $attribute->setPosition($position);
233
+ $content .= $attribute->getSetupContent();
234
+ $position += 10;
235
+ }
236
+ foreach ($this->getEntity()->getSimulatedAttributes('tree', false) as $attribute){
237
+ $attribute->setForcedSetupType('static');
238
+ $attribute->setForcedVisible(0);
239
+ $content .= $attribute->getSetupContent();
240
+ $position += 10;
241
+ }
242
+ return $content;
243
+ }
244
+ /**
245
+ * get parent class for the entity resource model
246
+ * @access public
247
+ * @return string
248
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
249
+ */
250
+ public function getResourceModelParent(){
251
+ return 'Mage_Catalog_Model_Resource_Abstract';
252
+ }
253
+ /**
254
+ * get parent class for the entity resource collection model
255
+ * @access public
256
+ * @return string
257
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
258
+ */
259
+ public function getResourceCollectionModelParent(){
260
+ return 'Mage_Catalog_Model_Resource_Collection_Abstract';
261
+ }
262
+ /**
263
+ * get related entities relations table
264
+ * @access public
265
+ * @return string
266
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
267
+ */
268
+ public function getResourceRelationsTables() {
269
+ $padding = $this->getPadding(2);
270
+ $content = '';
271
+ $eol = $this->getEol();
272
+ $entity = $this->getEntity()->getNameSingular(true);
273
+ $module = $this->getLowerModuleName();
274
+ $namespace = $this->getNamespace(true);
275
+ if ($this->getEntity()->getLinkProduct()){
276
+ $content .= $padding.'$'.'this->_'.$entity.'ProductTable = $'."this->getTable('".$namespace.'_'.$module."/".$entity."_product');".$eol;
277
+ }
278
+ if ($this->getEntity()->getLinkCategory()){
279
+ $content .= $padding.'$'.'this->_'.$entity.'CategoryTable = $'."this->getTable('".$namespace.'_'.$module."/".$entity."_category');".$eol;
280
+ }
281
+ $related = $this->getEntity()->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
282
+ foreach ($related as $_entity){
283
+ $_entityUc = ucfirst($_entity->getNameSingular());
284
+ $_entityLower = $_entity->getNameSingular(true);
285
+ $content .= $padding.'$'.'this->_'.$entity.$_entityUc.'Table = $'."this->getTable('".$namespace.'_'.$module."/".$entity."_".$_entityLower."');".$eol;
286
+ }
287
+ return $content;
288
+ }
289
+ /**
290
+ * get related entities relations table declaration
291
+ * @access public
292
+ * @return string
293
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
294
+ */
295
+ public function getResourceRelationsTablesDeclare() {
296
+ $padding = $this->getPadding();
297
+ $content = '';
298
+ $eol = $this->getEol();
299
+ $entity = $this->getEntity()->getNameSingular(true);
300
+ $module = $this->getLowerModuleName();
301
+ if ($this->getEntity()->getLinkProduct()) {
302
+ $content .= $padding.'protected $'.'_'.$entity.'ProductTable = null;'.$eol;
303
+ }
304
+ if ($this->getEntity()->getLinkCategory()) {
305
+ $content .= $padding.'protected $'.'_'.$entity.'CategoryTable = null;'.$eol;
306
+ }
307
+ $related = $this->getEntity()->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING);
308
+ foreach ($related as $_entity) {
309
+ $_entityUc = ucfirst($_entity->getNameSingular());
310
+ $_entityLower = $_entity->getNameSingular(true);
311
+ $content .= $padding.'protected $'.'_'.$entity.$_entityUc.'Table = null;'.$eol;
312
+ }
313
+ return $content;
314
+ }
315
+ /**
316
+ * get admin layout content for index page
317
+ * @access public
318
+ * @return string
319
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
320
+ */
321
+ public function getAdminIndexLayoutContent() {
322
+ $entity = $this->getEntity()->getNameSingular(true);
323
+ $module = $this->getLowerModuleName();
324
+ $namespace = $this->getNamespace(true);
325
+ $eol = $this->getEol();
326
+ $content = $this->getPadding(3).'<block type="'.$namespace.'_'.$module.'/adminhtml_'.$entity.'" name="'.$entity.'">'.$eol;
327
+ $content .= $this->getPadding(4).'<block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher">'.$eol;
328
+ $content .= $this->getPadding(5).'<action method="setUseConfirm"><params>0</params></action>'.$eol;
329
+ $content .= $this->getPadding(4).'</block>'.$eol;
330
+ $content .= $this->getPadding(3).'</block>'.$eol;
331
+ return $content;
332
+ }
333
+ /**
334
+ * get the parent model class
335
+ * @access public
336
+ * @return mixed
337
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
338
+ */
339
+ public function getEntityParentModel() {
340
+ return 'Mage_Catalog_Model_Abstract';
341
+ }
342
+ /**
343
+ * get entity table alias
344
+ * @access public
345
+ * @return mixed
346
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
347
+ */
348
+ public function getEntityTableAlias() {
349
+ return 'e';
350
+ }
351
+ /**
352
+ * get additional prepare collection
353
+ * @access public
354
+ * @return mixed
355
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
356
+ */
357
+ public function getAdditionalPrepareCollection(){
358
+ return "->addAttributeToSelect('".$this->getEntity()->getNameAttributeCode()."')";
359
+ }
360
+ /**
361
+ * additional layout block for left section
362
+ * @access public
363
+ * @return mixed
364
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
365
+ */
366
+ public function getEditLayoutLeft() {
367
+ return '<block type="adminhtml/store_switcher" name="store_switcher" before="-"></block>'.$this->getEol().$this->getPadding(3);
368
+ }
369
+ /**
370
+ * additional layout block edit
371
+ * @access public
372
+ * @return mixed
373
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
374
+ */
375
+ public function getEditLayoutAdditional(){
376
+ $content = '';
377
+ $eol = $this->getEol();
378
+ $content .= $eol.$this->getPadding(2).'<reference name="head">'.$eol;
379
+ $content .= $this->getPadding(3).'<action method="setCanLoadTinyMce"><load>1</load></action>'.$eol;
380
+ $content .= $this->getPadding(2).'</reference>'.$eol;
381
+ $content .= $this->getPadding(2).'<reference name="js">'.$eol;
382
+ $content .= $this->getPadding(3).'<block type="core/template" name="catalog.wysiwyg.js" template="catalog/wysiwyg/js.phtml"/>'.$eol;
383
+ $content .= $this->getPadding(2).'</reference>';
384
+ return $content;
385
+ }
386
+ /**
387
+ * get param name for before save
388
+ * @access public
389
+ * @return mixed
390
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
391
+ */
392
+ public function getBeforeSaveParam() {
393
+ return 'Varien_Object';
394
+ }
395
+ /**
396
+ * entity attribute set string
397
+ * @access public
398
+ * @return string
399
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
400
+ */
401
+ public function getEntityAttributeSetId() {
402
+ $namespace = $this->getNamespace(true);
403
+ $module = $this->getLowerModuleName();
404
+ $entity = $this->getEntity()->getNameSingular(true);
405
+ return $this->getEol().$this->getPadding()."->setAttributeSetId(Mage::getModel('".$namespace.'_'.$module.'/'.$entity."')->getDefaultAttributeSetId())";
406
+ }
407
+ /**
408
+ * filter method name
409
+ * @access public
410
+ * @return string
411
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
412
+ */
413
+ public function getFilterMethod() {
414
+ return 'addAttributeToFilter';
415
+ }
416
+ /**
417
+ * convert multiple select fields to strings
418
+ * @access public
419
+ * @return mixed
420
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
421
+ */
422
+ public function getMultipleSelectConvert(){
423
+ return $this->getEol();
424
+ }
425
+ /**
426
+ * check if the entity helper can be created
427
+ * @access public
428
+ * @return bool
429
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
430
+ */
431
+ public function getCanCreateEntityHelper(){
432
+ return true;
433
+ }
434
+ /**
435
+ * get additional code for toOptionArray()
436
+ * @access public
437
+ * @return string
438
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
439
+ */
440
+ public function getToOptionAddition(){
441
+ $attribute = $this->getEntity()->getNameAttributeCode();
442
+ return '$this->addAttributeToSelect(\''.$attribute.'\');'.$this->getEol().$this->getPadding(2);
443
+ }
444
+ /**
445
+ * get comment name field filter index
446
+ * @access public
447
+ * @return string
448
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
449
+ */
450
+ public function getCommentFilterIndexPrefix() {
451
+ return '';
452
+ }
453
+ /**
454
+ * get additional api xml
455
+ * @access public
456
+ * @return string
457
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
458
+ */
459
+ public function getApiAdditional(){
460
+ $eol = $this->getEol();
461
+ $padding = $this->getPadding(5);
462
+ $tab = $this->getPadding();
463
+ $content = '';
464
+ $content .= $padding.'<currentStore>'.$eol;
465
+ $content .= $padding.$tab.'<title>Set/Get current store view</title>'.$eol;
466
+ $content .= $padding.'</currentStore>'.$eol;
467
+ $content .= $padding.'<listOfAdditionalAttributes translate="title" module="'.$this->getNamespace(true).'_'.$this->getLowerModuleName().'">'.$eol;
468
+ $content .= $padding.$tab.'<title>Get list of non-default attributes</title>'.$eol;
469
+ $content .= $padding.$tab.'<method>getAdditionalAttributes</method>'.$eol;
470
+ $content .= $padding.'</listOfAdditionalAttributes>'.$eol;
471
+ return $content;
472
+ }
473
+ /**
474
+ * get additional api faults
475
+ * @access public
476
+ * @return string
477
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
478
+ */
479
+ public function getApiFaults(){
480
+ $eol = $this->getEol();
481
+ $padding = $this->getPadding(5);
482
+ $tab = $this->getPadding();
483
+ $content = '';
484
+ $content .= $padding.'<store_not_exists>'.$eol;
485
+ $content .= $padding.$tab.'<code>100</code>'.$eol;
486
+ $content .= $padding.$tab.'<message>Requested store view not found.</message>'.$eol;
487
+ $content .= $padding.'</store_not_exists>'.$eol;
488
+ return $content;
489
+ }
490
+ /**
491
+ * additional API subentities.
492
+ * @access public
493
+ * @return string
494
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
495
+ */
496
+ public function getApiAdditionalSettings() {
497
+ $content = '';
498
+ $padding = $this->getPadding(3);
499
+ $tab = $this->getPadding();
500
+ $module = $this->getLowerModuleName();
501
+ $entity = $this->getEntity()->getNameSingular(true);
502
+ $eol = $this->getEol();
503
+ $content .= $eol;
504
+ $extension = $this->getModule()->getExtensionName(true);
505
+ $content .= $padding.'<'.$module.'_'.$entity.'_attribute translate="title" module="'.$extension.'">'.$eol;
506
+ $content .= $padding.$tab.'<title>Product attributes API</title>'.$eol;
507
+ $content .= $padding.$tab.'<model>'.$extension.'/'.$entity.'_attribute_api</model>'.$eol;
508
+ $content .= $padding.$tab.'<acl>'.$module.'/'.$entity.'</acl>'.$eol;
509
+ $content .= $padding.$tab.'<methods>'.$eol;
510
+ $content .= $padding.$tab.$tab.'<currentStore translate="title" module="'.$extension.'">'.$eol;
511
+ $content .= $padding.$tab.$tab.$tab.'<title>Set/Get current store view</title>'.$eol;
512
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/write</acl>'.$eol;
513
+ $content .= $padding.$tab.$tab.'</currentStore>'.$eol;
514
+ $content .= $padding.$tab.$tab.'<list translate="title" module="'.$extension.'">'.$eol;
515
+ $content .= $padding.$tab.$tab.$tab.'<title>Retrieve attribute list</title>'.$eol;
516
+ $content .= $padding.$tab.$tab.$tab.'<method>items</method>'.$eol;
517
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/read</acl>'.$eol;
518
+ $content .= $padding.$tab.$tab.'</list>'.$eol;
519
+ $content .= $padding.$tab.$tab.'<options translate="title" module="'.$extension.'">'.$eol;
520
+ $content .= $padding.$tab.$tab.$tab.'<title>Retrieve attribute options</title>'.$eol;
521
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/read</acl>'.$eol;
522
+ $content .= $padding.$tab.$tab.'</options>'.$eol;
523
+ $content .= $padding.$tab.$tab.'<types translate="title" module="'.$extension.'">'.$eol;
524
+ $content .= $padding.$tab.$tab.$tab.'<title>Get list of possible attribute types</title>'.$eol;
525
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/types</acl>'.$eol;
526
+ $content .= $padding.$tab.$tab.'</types>'.$eol;
527
+ $content .= $padding.$tab.$tab.'<create translate="title" module="'.$extension.'">'.$eol;
528
+ $content .= $padding.$tab.$tab.$tab.'<title>Create new attribute</title>'.$eol;
529
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/create</acl>'.$eol;
530
+ $content .= $padding.$tab.$tab.'</create>'.$eol;
531
+ $content .= $padding.$tab.$tab.'<update translate="title" module="'.$extension.'">'.$eol;
532
+ $content .= $padding.$tab.$tab.$tab.'<title>Update attribute</title>'.$eol;
533
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/update</acl>'.$eol;
534
+ $content .= $padding.$tab.$tab.'</update>'.$eol;
535
+ $content .= $padding.$tab.$tab.'<remove translate="title" module="'.$extension.'">'.$eol;
536
+ $content .= $padding.$tab.$tab.$tab.'<title>Delete attribute</title>'.$eol;
537
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/remove</acl>'.$eol;
538
+ $content .= $padding.$tab.$tab.'</remove>'.$eol;
539
+ $content .= $padding.$tab.$tab.'<info translate="title" module="'.$extension.'">'.$eol;
540
+ $content .= $padding.$tab.$tab.$tab.'<title>Get full information about attribute with list of options</title>'.$eol;
541
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/info</acl>'.$eol;
542
+ $content .= $padding.$tab.$tab.'</info>'.$eol;
543
+ $content .= $padding.$tab.$tab.'<addOption translate="title" module="'.$extension.'">'.$eol;
544
+ $content .= $padding.$tab.$tab.$tab.'<title>Add option</title>'.$eol;
545
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/option/add</acl>'.$eol;
546
+ $content .= $padding.$tab.$tab.'</addOption>'.$eol;
547
+ $content .= $padding.$tab.$tab.'<removeOption translate="title" module="'.$extension.'">'.$eol;
548
+ $content .= $padding.$tab.$tab.$tab.'<title>Remove option</title>'.$eol;
549
+ $content .= $padding.$tab.$tab.$tab.'<acl>'.$module.'/'.$entity.'_attribute/option/remove</acl>'.$eol;
550
+ $content .= $padding.$tab.$tab.'</removeOption>'.$eol;
551
+ $content .= $padding.$tab.'</methods>'.$eol;
552
+ $content .= $padding.$tab.'<faults module="'.$extension.'">'.$eol;
553
+ $content .= $padding.$tab.$tab.'<store_not_exists>'.$eol;
554
+ $content .= $padding.$tab.$tab.$tab.'<code>100</code>'.$eol;
555
+ $content .= $padding.$tab.$tab.$tab.'<message>Requested store view not found.</message>'.$eol;
556
+ $content .= $padding.$tab.$tab.'</store_not_exists>'.$eol;
557
+ $content .= $padding.$tab.$tab.'<not_exists>'.$eol;
558
+ $content .= $padding.$tab.$tab.$tab.'<code>101</code>'.$eol;
559
+ $content .= $padding.$tab.$tab.$tab.'<message>Requested attribute not found.</message>'.$eol;
560
+ $content .= $padding.$tab.$tab.'</not_exists>'.$eol;
561
+ $content .= $padding.$tab.$tab.'<invalid_parameters>'.$eol;
562
+ $content .= $padding.$tab.$tab.$tab.'<code>102</code>'.$eol;
563
+ $content .= $padding.$tab.$tab.$tab.'<message>Invalid request parameters.</message>'.$eol;
564
+ $content .= $padding.$tab.$tab.'</invalid_parameters>'.$eol;
565
+ $content .= $padding.$tab.$tab.'<invalid_code>'.$eol;
566
+ $content .= $padding.$tab.$tab.$tab.'<code>103</code>'.$eol;
567
+ $content .= $padding.$tab.$tab.$tab.'<message>Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.</message>'.$eol;
568
+ $content .= $padding.$tab.$tab.'</invalid_code>'.$eol;
569
+ $content .= $padding.$tab.$tab.'<invalid_frontend_input>'.$eol;
570
+ $content .= $padding.$tab.$tab.$tab.'<code>104</code>'.$eol;
571
+ $content .= $padding.$tab.$tab.$tab.'<message>Incorrect attribute type.</message>'.$eol;
572
+ $content .= $padding.$tab.$tab.'</invalid_frontend_input>'.$eol;
573
+ $content .= $padding.$tab.$tab.'<unable_to_save>'.$eol;
574
+ $content .= $padding.$tab.$tab.$tab.'<code>105</code>'.$eol;
575
+ $content .= $padding.$tab.$tab.$tab.'<message>Unable to save attribute.</message>'.$eol;
576
+ $content .= $padding.$tab.$tab.'</unable_to_save>'.$eol;
577
+ $content .= $padding.$tab.$tab.'<can_not_delete>'.$eol;
578
+ $content .= $padding.$tab.$tab.$tab.'<code>106</code>'.$eol;
579
+ $content .= $padding.$tab.$tab.$tab.'<message>This attribute cannot be deleted.</message>'.$eol;
580
+ $content .= $padding.$tab.$tab.'</can_not_delete>'.$eol;
581
+ $content .= $padding.$tab.$tab.'<can_not_edit>'.$eol;
582
+ $content .= $padding.$tab.$tab.$tab.'<code>107</code>'.$eol;
583
+ $content .= $padding.$tab.$tab.$tab.'<message>This attribute cannot be edited.</message>'.$eol;
584
+ $content .= $padding.$tab.$tab.'</can_not_edit>'.$eol;
585
+ $content .= $padding.$tab.$tab.'<unable_to_add_option>'.$eol;
586
+ $content .= $padding.$tab.$tab.$tab.'<code>108</code>'.$eol;
587
+ $content .= $padding.$tab.$tab.$tab.'<message>Unable to add option.</message>'.$eol;
588
+ $content .= $padding.$tab.$tab.'</unable_to_add_option>'.$eol;
589
+ $content .= $padding.$tab.$tab.'<unable_to_remove_option>'.$eol;
590
+ $content .= $padding.$tab.$tab.$tab.'<code>109</code>'.$eol;
591
+ $content .= $padding.$tab.$tab.$tab.'<message>Unable to remove option.</message>'.$eol;
592
+ $content .= $padding.$tab.$tab.'</unable_to_remove_option>'.$eol;
593
+ $content .= $padding.$tab.'</faults>'.$eol;
594
+ $content .= $padding.'</'.$module.'_'.$entity.'_attribute>'.$eol;
595
+ return $content;
596
+ }
597
+
598
+ /**
599
+ * get subentities acl
600
+ * @access public
601
+ * @return string
602
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
603
+ */
604
+ public function getSubEntitiesAcl(){
605
+ $content = '';
606
+ $padding = $this->getPadding(5);
607
+ $tab = $this->getPadding();
608
+ $module = $this->getLowerModuleName();
609
+ $entity = $this->getEntity()->getNameSingular(true);
610
+ $eol = $this->getEol();
611
+ $title = $this->getEntity()->getLabelSingular().' Attributes';
612
+ $extension = $this->getModule()->getExtensionName(true);
613
+ $content .= $eol;
614
+
615
+ $content .= $padding.'<'.$entity.'_attribute translate="title" module="'.$extension.'">'.$eol;
616
+ $content .= $padding.$tab.'<title>'.$title.'</title>'.$eol;
617
+ $content .= $padding.$tab.'<sort_order>'.($this->getEntity()->getPosition() + 6).'</sort_order>'.$eol;
618
+ $content .= $padding.$tab.'<currentStore translate="title" module="'.$extension.'">'.$eol;
619
+ $content .= $padding.$tab.$tab.'<title>Set/Get current store view</title>'.$eol;
620
+ $content .= $padding.$tab.'</currentStore>'.$eol;
621
+ $content .= $padding.$tab.'<list translate="title" module="'.$extension.'">'.$eol;
622
+ $content .= $padding.$tab.$tab.'<title>Retrieve attribute list</title>'.$eol;
623
+ $content .= $padding.$tab.'</list>'.$eol;
624
+ $content .= $padding.$tab.'<options translate="title" module="'.$extension.'">'.$eol;
625
+ $content .= $padding.$tab.$tab.'<title>Retrieve attribute options</title>'.$eol;
626
+ $content .= $padding.$tab.'</options>'.$eol;
627
+ $content .= $padding.$tab.'<types translate="title" module="'.$extension.'">'.$eol;
628
+ $content .= $padding.$tab.$tab.'<title>Get list of possible attribute types</title>'.$eol;
629
+ $content .= $padding.$tab.'</types>'.$eol;
630
+ $content .= $padding.$tab.'<create translate="title" module="'.$extension.'">'.$eol;
631
+ $content .= $padding.$tab.$tab.'<title>Create new attribute</title>'.$eol;
632
+ $content .= $padding.$tab.'</create>'.$eol;
633
+ $content .= $padding.$tab.'<update translate="title" module="'.$extension.'">'.$eol;
634
+ $content .= $padding.$tab.$tab.'<title>Update attribute</title>'.$eol;
635
+ $content .= $padding.$tab.'</update>'.$eol;
636
+ $content .= $padding.$tab.'<remove translate="title" module="'.$extension.'">'.$eol;
637
+ $content .= $padding.$tab.$tab.'<title>Remove attribute</title>'.$eol;
638
+ $content .= $padding.$tab.'</remove>'.$eol;
639
+ $content .= $padding.$tab.'<info translate="title" module="'.$extension.'">'.$eol;
640
+ $content .= $padding.$tab.$tab.'<title>Get full information about attribute with list of options</title>'.$eol;
641
+ $content .= $padding.$tab.'</info>'.$eol;
642
+ $content .= $padding.$tab.'<addOption translate="title" module="'.$extension.'">'.$eol;
643
+ $content .= $padding.$tab.$tab.'<title>Add option</title>'.$eol;
644
+ $content .= $padding.$tab.'</addOption>'.$eol;
645
+ $content .= $padding.$tab.'<removeOption translate="title" module="'.$extension.'">'.$eol;
646
+ $content .= $padding.$tab.$tab.'<title>Remove option</title>'.$eol;
647
+ $content .= $padding.$tab.'</removeOption>'.$eol;
648
+ $content .= $padding.'</'.$entity.'_attribute>'.$eol;
649
+ return $content;
650
+ }
651
+ /**
652
+ * get api aliases
653
+ * @access public
654
+ * @return string
655
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
656
+ */
657
+ public function getApiResourcesAlias() {
658
+ $content = '';
659
+ $padding = $this->getPadding(3);
660
+ $tab = $this->getPadding();
661
+ $module = $this->getLowerModuleName();
662
+ $entity = $this->getEntity()->getNameSingular(true);
663
+ $eol = $this->getEol();
664
+ $content .= $eol;
665
+ $content .= $padding.'<'.$entity.'_attribute>'.$module.'_'.$entity.'_attribute</'.$entity.'_attribute>';
666
+ return $content;
667
+ }
668
+ /**
669
+ * get api V2 aliases
670
+ * @access public
671
+ * @return string
672
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
673
+ */
674
+ public function getApiResourcesAliasV2() {
675
+ $content = '';
676
+ $padding = $this->getPadding(4);
677
+ $tab = $this->getPadding();
678
+ $module = $this->getLowerModuleName();
679
+ $entity = $this->getEntity()->getNameSingular(true);
680
+ $eol = $this->getEol();
681
+ $content .= $eol;
682
+ $content .= $padding.'<'.$entity.'_attribute>'.$module.ucfirst($entity).'Attribute</'.$entity.'_attribute>';
683
+ return $content;
684
+ }
685
+ /**
686
+ * get attributes format for wsdl
687
+ * @access public
688
+ * @param bool $wsi
689
+ * @return string
690
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
691
+ */
692
+ public function getWsdlAttributes($wsi = false){
693
+ $tab = $this->getPadding();
694
+ $padding = str_repeat($tab, 5);
695
+ $eol = $this->getEol();
696
+ $content = '';
697
+ $module = $this->getLowerModuleName();
698
+ $entity = ucfirst($this->getEntity()->getNameSingular(true));
699
+ if (!$wsi) {
700
+ $content .= $padding.'<element name="additional_attributes" type="typens:'.$module.$entity.'AdditionalAttributesEntity" minOccurs="0"/>'.$eol;
701
+ }
702
+ else {
703
+ $content .= $padding.'<xsd:element name="additional_attributes" type="typens:associativeArray" minOccurs="0" />'.$eol;
704
+ }
705
+ return $content;
706
+ }
707
+ /**
708
+ * get default api attributes
709
+ * @access public
710
+ * @return string
711
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
712
+ */
713
+ public function getDefaultApiAttributes(){
714
+ $padding = $this->getPadding();
715
+ $tab = $padding;
716
+ $eol = $this->getEol();
717
+ $entity = $this->getEntity();
718
+ $content = $padding.'protected $_defaultAttributeList = array('.$eol;
719
+ $parents = $entity->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD);
720
+ foreach ($parents as $parent){
721
+ $content .= $padding.$tab."'".$parent->getNameSingular(true).'_id'."', ".$eol;
722
+ }
723
+ foreach ($entity->getAttributes() as $attribute){
724
+ $content .= $padding.$tab."'".$attribute->getCode()."'".', '.$eol;
725
+ }
726
+ $simulated = $entity->getSimulatedAttributes(null, false);
727
+ foreach ($simulated as $attr){
728
+ //if (!$attr->getIgnoreApi()){
729
+ $content .= $padding.$tab."'".$attr->getCode()."'".', '.$eol;
730
+ //}
731
+ }
732
+ $content .= $padding.$tab."'created_at', ".$eol;
733
+ $content .= $padding.$tab."'updated_at', ".$eol;
734
+ $content .= $padding.');'.$eol;
735
+ return $content;
736
+ }
737
+ }
app/code/community/Ultimate/ModuleCreator/Model/Entity/Type/Flat.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * flat entity type
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Entity_Type_Flat
26
+ extends Ultimate_ModuleCreator_Model_Entity_Type_Abstract {
27
+
28
+ }
app/code/community/Ultimate/ModuleCreator/Model/Module.php CHANGED
@@ -9,991 +9,1740 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * module model
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
  class Ultimate_ModuleCreator_Model_Module extends Ultimate_ModuleCreator_Model_Abstract{
25
- /**
26
- * module entities
27
- * @var array()
28
- */
29
- protected $_entities = array();
30
- /**
31
- * module config
32
- * @var mixed (null|Varien_Simplexml_Element)
33
- */
34
- protected $_config = null;
35
- /**
36
- * entity relations
37
- * @var array
38
- */
39
- protected $_relations = array();
40
- /**
41
- * no comment
42
- */
43
- protected $_qwertyuiop = 'UUdGMWRHaHZjaUJWYkhScGJXRjBaU0JOYjJSMWJHVWdRM0psWVhSdmNnPT0=';
44
- /**
45
- * module files
46
- * @var array()
47
- */
48
- protected $_files = array();
49
- /**
50
- * add entity to module
51
- * @access public
52
- * @param Ultimate_ModuleCreator_Model_Entity $entity
53
- * @return Ultimate_ModuleCreator_Model_Module
54
- * @author Marius Strajeru <marius.strajeru@gmail.com>
55
- */
56
- public function addEntity(Ultimate_ModuleCreator_Model_Entity $entity){
57
- if (isset($this->_entities[$entity->getNameSingular()])){
58
- throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('An entity with the code "%s" already exists', $entity->getNameSingular()));
59
- }
60
- $entity->setModule($this);
61
- $position = 10 * (count($this->_entities));
62
- $entity->setPosition($position);
63
- $this->_entities[$entity->getNameSingular()] = $entity;
64
- if ($entity->getRss()){
65
- $this->setRss(true);
66
- }
67
- if ($entity->getAddStatus()){
68
- $this->setAddStatus(true);
69
- }
70
- if ($entity->getHasFile()){
71
- $this->setHasFile(true);
72
- }
73
- if ($entity->getHasImage()){
74
- $this->setHasImage(true);
75
- }
76
- if ($entity->getFrontendAddSeo()){
77
- $this->setFrontendAddSeo(true);
78
- }
79
- if ($entity->getWidget()){
80
- $this->setWidget(true);
81
- }
82
- if ($entity->getUseFrontend()){
83
- $this->setUseFrontend(true);
84
- }
85
- if ($entity->getFrontendList()){
86
- $this->setFrontendList(true);
87
- }
88
- if ($entity->getLinkProduct()){
89
- $this->setHasObserver(true);
90
- $this->setLinkProduct(true);
91
- }
92
- if ($entity->getIsTree()){
93
- $this->setHasTree(true);
94
- }
95
- if ($entity->getEditor()){
96
- $this->setEditor(true);
97
- }
98
- if ($entity->getUrlRewrite()){
99
- $this->setUrlRewrite(true);
100
- }
101
- if ($entity->getAdminSearch()){
102
- $this->setAdminSearch(true);
103
- }
104
- if ($entity->getCreateApi()){
105
- $this->setCreateApi(true);
106
- }
107
- return $this;
108
- }
109
- /**
110
- * get a module entity
111
- * @access public
112
- * @param string $code
113
- * @return mixed(Ultimate_ModuleCreator_Model_Entity|null)
114
- * @author Marius Strajeru <marius.strajeru@gmail.com>
115
- */
116
- public function getEntity($code){
117
- if (isset($this->_entities[$code])){
118
- return $this->_entities[$code];
119
- }
120
- return null;
121
- }
122
- /**
123
- * it does something I don't want to tell you what
124
- * @access public
125
- * @return string
126
- * @author Marius Strajeru <marius.strajeru@gmail.com>
127
- */
128
- public function getQwertyuiop(){
129
- $qwertyuiop = base64_decode('WW1GelpUWTBYMlJsWTI5a1pRPT0=');
130
- $qwertyuiop = base64_decode($qwertyuiop);
131
- return $qwertyuiop($qwertyuiop($this->_qwertyuiop));
132
- }
133
- /**
134
- * module to xml
135
- * @access protected
136
- * @param array $arrAttributes
137
- * @param string $rootName
138
- * @param bool $addOpenTag
139
- * @param bool $addCdata
140
- * @return string
141
- * @author Marius Strajeru <marius.strajeru@gmail.com>
142
- */
143
- protected function __toXml(array $arrAttributes = array(), $rootName = 'module', $addOpenTag=false, $addCdata=false){
144
- $xml = '';
145
- if ($addOpenTag) {
146
- $xml.= '<?xml version="1.0" encoding="UTF-8"?>'."\n";
147
- }
148
- if (!empty($rootName)) {
149
- $xml.= '<'.$rootName.'>'."\n";
150
- }
151
- $start = '';
152
- $end = '';
153
- if ($addCdata){
154
- $start = '<![CDATA[';
155
- $end = ']]>';
156
- }
157
- $xml .= parent::__toXml($this->getXmlAttributes(), '', false, $addCdata);
158
- $xml .= '<entities>';
159
- foreach ($this->getEntities() as $entity){
160
- $xml .= $entity->toXml(array(), 'entity', false, $addCdata);
161
- }
162
- $xml .= '</entities>';
163
- $xml .= '<relations>';
164
- foreach ($this->getRelations() as $relation){
165
- $xml .= $relation->toXml(array(), 'relation', false, $addCdata);
166
- }
167
- $xml .= '</relations>';
168
- if (!empty($rootName)) {
169
- $xml.= '</'.$rootName.'>'."\n";
170
- }
171
- return $xml;
172
- }
173
- /**
174
- * get the data attributes saved in the xml
175
- * @access public
176
- * @return array();
177
- * @author Marius Strajeru <marius.strajeru@gmail.com>
178
- */
179
- public function getXmlAttributes(){
180
- return array('extension', 'namespace', 'module_name', 'codepool', 'install',
181
- 'version', 'front_package', 'front_templates', 'front_layout', 'license', 'sort_order');
182
- }
183
- /**
184
- * get the module entities
185
- * @access public
186
- * @return array()
187
- * @author Marius Strajeru <marius.strajeru@gmail.com>
188
- */
189
- public function getEntities(){
190
- $this->_prepareEntities();
191
- return $this->_entities;
192
- }
193
- /**
194
- * prepare the entities before saving
195
- * @access protected
196
- * @return Ultimate_ModuleCreator_Model_Module
197
- * @author Marius Strajeru <marius.strajeru@gmail.com>
198
- */
199
- protected function _prepareEntities(){
200
- foreach ($this->_entities as $entity){
201
- $entity->setFlat(true);//just flat entities for now - EAV will follow
202
- }
203
- return $this;
204
- }
205
- /**
206
- * get the extensions xml path
207
- * @access public
208
- * @return string
209
- * @author Marius Strajeru <marius.strajeru@gmail.com>
210
- */
211
- public function getXmlPath(){
212
- return Mage::helper('modulecreator')->getLocalPackagesPath().$this->getNamespace()."_".$this->getModuleName().'.xml';
213
- }
214
- /**
215
- * get the log file path
216
- * @access public
217
- * @return string
218
- * @author Marius Strajeru <marius.strajeru@gmail.com>
219
- */
220
- public function getLogPath(){
221
- return Mage::helper('modulecreator')->getLocalPackagesPath().$this->getNamespace()."_".$this->getModuleName().'.log';
222
- }
223
- /**
224
- * save the module as xml
225
- * @access public
226
- * @return Ultimate_ModuleCreator_Model_Module
227
- * @author Marius Strajeru <marius.strajeru@gmail.com>
228
- */
229
- public function save(){
230
- $destination = $this->getXmlPath();
231
- $xml = $this->toXml(array(), 'module', true, false);
232
- $this->_writeFile($destination, $xml);
233
- return $this;
234
- }
235
- /**
236
- * write a file
237
- * @access protected
238
- * @param string $destinationFile
239
- * @param string $contents
240
- * @return Ultimate_ModuleCreator_Model_Module
241
- * @author Marius Strajeru <marius.strajeru@gmail.com>
242
- */
243
- protected function _writeFile($destinationFile, $contents){
244
- try{
245
- $io = $this->getIo();
246
- $io->mkdir(dirname($destinationFile));
247
- $io->write($destinationFile, $contents, 0777);
248
- }
249
- catch (Exception $e){
250
- if ($e->getCode() != 0){
251
- throw $e;
252
- }
253
- }
254
- return $this;
255
- }
256
- /**
257
- * get the IO - class
258
- * @access public
259
- * @return Varien_Io_File
260
- * @author Marius Strajeru <marius.strajeru@gmail.com>
261
- */
262
- public function getIo(){
263
- if (!$this->_io){
264
- $this->_io = new Varien_Io_File();
265
- $this->_io->setAllowCreateFolders(true);
266
- }
267
- return $this->_io;
268
- }
269
- /**
270
- * write module on disc
271
- * @access public
272
- * @return array()
273
- * @author Marius Strajeru <marius.strajeru@gmail.com>
274
- */
275
- public function buildModule(){
276
- $messages = array();
277
- $config = $this->getConfig();
278
- $files = $config->descend('files/file');
279
- foreach ($files as $file){
280
- $this->_createFile($file);
281
- }
282
- if ($this->getInstall()){
283
- $existingFiles = $this->_checkExistingFiles();
284
- if (count($existingFiles) > 0){
285
- $this->setInstall(false);
286
- $messages[] = Mage::helper('modulecreator')->__('The following files already exist. They were NOT overwritten. The extension was not installed. You can download it from the list of extensions and install it manually: %s', implode('<br />', $existingFiles));
287
- }
288
- }
289
- $this->_writeFiles();
290
- if (!$this->getInstall()){
291
- $contents = array();
292
- foreach ($this->_files as $filename=>$file){
293
- $contents[] = $this->getRelativeBasePath().$filename;
294
- }
295
- $_writer = Mage::getModel('modulecreator/writer',$contents);
296
- $_writer->setNamePackage(Mage::getBaseDir('var').DS.'modulecreator'.DS.$this->getNamespace().'_'.$this->getModuleName());
297
- $_writer->composePackage()->archivePackage();
298
- $this->_io->rmdir($this->getBasePath(), true);
299
- }
300
- return $messages;
301
- }
302
- /**
303
- * check if some files already exist so it won't be overwritten
304
- * @access protected
305
- * @return array()
306
- * @author Marius Strajeru <marius.strajeru@gmail.com>
307
- */
308
- protected function _checkExistingFiles(){
309
- $existingFiles = array();
310
- $io = $this->getIo();
311
- $basePath = $this->getBasePath();
312
- foreach ($this->_files as $name=>$content){
313
- if ($io->fileExists($basePath.$name)){
314
- $existingFiles[] = $basePath.$name;
315
- }
316
- }
317
- return $existingFiles;
318
- }
319
- /**
320
- * get module base path
321
- * @access public
322
- * @return string
323
- * @author Marius Strajeru <marius.strajeru@gmail.com>
324
- */
325
- public function getBasePath(){
326
- if (!$this->getInstall()){
327
- return Mage::getBaseDir('var').DS.'modulecreator'.DS.$this->getNamespace()."_".$this->getModuleName().DS;
328
- }
329
- return Mage::getBaseDir().DS;
330
- }
331
- /**
332
- * get relative path ro the module
333
- * @access public
334
- * @return string
335
- * @author Marius Strajeru <marius.strajeru@gmail.com>
336
- */
337
- public function getRelativeBasePath(){
338
- $basePath = $this->getBasePath();
339
- $remove = Mage::getBaseDir().DS;
340
- $relativePath = substr($basePath, strlen($remove));
341
- return $relativePath;
342
- }
343
- /**
344
- * check if module can be installed
345
- * @access public
346
- * @return bool
347
- * @author Marius Strajeru <marius.strajeru@gmail.com>
348
- */
349
- public function getInstall(){
350
- if (!Mage::helper('modulecreator')->canInstall()){
351
- return false;
352
- }
353
- return $this->getData('install');
354
- }
355
- /**
356
- * write files on disk
357
- * @access protected
358
- * @return Ultimate_ModuleCreator_Model_Module
359
- * @author Marius Strajeru <marius.strajeru@gmail.com>
360
- */
361
- protected function _writeFiles(){
362
- $basePath = $this->getBasePath();
363
- foreach ($this->_files as $name=>$file){
364
- $destinationFile = $basePath.$name;
365
- $this->_writeFile($destinationFile, $file);
366
- }
367
- $this->_writeLog();
368
- return $this;
369
- }
370
- /**
371
- * write a log with the files that were created
372
- * @access protected
373
- * @return Ultimate_ModuleCreator_Model_Module
374
- * @author Marius Strajeru <marius.strajeru@gmail.com>
375
- */
376
- protected function _writeLog(){
377
- $filesToWrite = array_keys($this->_files);
378
- asort($filesToWrite);
379
- $filesToWrite = array_values($filesToWrite);
380
- $text = implode("\n", $filesToWrite);
381
- $this->_writeFile($this->getLogPath(), $text);
382
- return $this;
383
- }
384
- /**
385
- * get the module config
386
- * @access public
387
- * @return Varien_Simplexml_Element
388
- * @author Marius Strajeru <marius.strajeru@gmail.com>
389
- */
390
- public function getConfig(){
391
- if (is_null($this->_config)){
392
- $configFile = Mage::getConfig()->getModuleDir('etc', 'Ultimate_ModuleCreator').DS.'modulecreator.xml';
393
- $string = file_get_contents($configFile);
394
- $xml = simplexml_load_string($string, 'Varien_Simplexml_Element');
395
- $this->_config = $xml;
396
- }
397
- return $this->_config;
398
-
399
- }
400
- /**
401
- * create a file
402
- * @access protected
403
- * @param Varien_Simplexml_Element
404
- * @return Ultimate_ModuleCreator_Model_Module
405
- * @author Marius Strajeru <marius.strajeru@gmail.com>
406
- */
407
- protected function _createFile($config){
408
- switch ($config->scope){
409
- case 'entity' :
410
- $this->_buildEntityFile($config);
411
- break;
412
- case 'siblings' :
413
- $this->_buildSiblingFile($config);
414
- break;
415
- case 'children' :
416
- $this->_buildChildrenFile($config);
417
- break;
418
- case 'global':
419
- default:
420
- $this->_buildGlobalFile($config);
421
- break;
422
- }
423
- return $this;
424
- }
425
- /**
426
- * create a file with global scope
427
- * @access protected
428
- * @param Varien_Simplexml_Element
429
- * @return Ultimate_ModuleCreator_Model_Module
430
- * @author Marius Strajeru <marius.strajeru@gmail.com>
431
- */
432
- public function _buildGlobalFile($config){
433
- $filetype = $config->filetype;
434
- $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->from, $filetype);
435
- $destinationFile = $this->_filterString((string)$config->to, $filetype);
436
- $content = '';
437
- $depend = $config->depend;
438
- $build = true;
439
- if ($depend){
440
- foreach ($depend->asArray() as $condition=>$value){
441
- if (!$this->getDataUsingMethod($condition)){
442
- $build = false;
443
- break;
444
- }
445
- }
446
- }
447
- if (!$build){
448
- return '';
449
- }
450
- $content = '';
451
- if ($config->method){
452
- $method = (string)$config->method;
453
- $content = $this->$method();
454
- }
455
- else{
456
- foreach ($config->descend('content/file') as $file){
457
- $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name);
458
- $scope = (string)$file->scope;
459
- $depend = $file->depend;
460
- $scope = $file->scope;
461
- if ($scope == 'entity'){
462
- foreach ($this->getEntities() as $entity){
463
- $valid = true;
464
- if ($depend){
465
- foreach ($depend->asArray() as $condition=>$value){
466
- if (!$entity->getDataUsingMethod($condition)){
467
- $valid = false;
468
- break;
469
- }
470
- }
471
- }
472
- if ($valid){
473
- $replace = $entity->getPlaceholders();
474
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
475
- }
476
- }
477
- }
478
- elseif($scope == 'attribute'){
479
- $depend = $file->depend;
480
- $dependType = $file->depend_type;
481
- foreach ($this->getEntities() as $entity){
482
- foreach ($entity->getAttributes() as $attribute){
483
- $valid = true;
484
- if ($depend){
485
- foreach ($depend->asArray() as $condition=>$value){
486
- if (!$attribute->getDataUsingMethod($condition)){
487
- $valid = false;
488
- break;
489
- }
490
- }
491
- }
492
- $typeValid = true;
493
- if ($dependType){
494
- $typeValid = false;
495
- foreach ($dependType->asArray() as $condition=>$value){
496
- if ($attribute->getType() == $condition){
497
- $typeValid = true;
498
- break;
499
- }
500
- }
501
- }
502
- if ($valid && $typeValid){
503
- $replace = $entity->getPlaceholders();
504
- $attributeReplace = $attribute->getPlaceholders();
505
- $replace = array_merge($replace, $attributeReplace);
506
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
507
- }
508
- }
509
- }
510
- }
511
- elseif($scope == 'siblings'){
512
- foreach ($this->getRelations(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING) as $relation){
513
- $entities = $relation->getEntities();
514
- $replaceEntity = $entities[0]->getPlaceholders();
515
- $replaceSibling = $entities[1]->getPlaceholdersAsSibling();
516
- $replace = array_merge($replaceEntity, $replaceSibling);
517
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
518
- }
519
- }
520
- elseif($scope == 'siblings_both_tree'){
521
- foreach ($this->getRelations(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING) as $relation){
522
- $entities = $relation->getEntities();
523
- if ($entities[0]->getIsTree() || $entities[1]->getIsTree()){
524
- if ($entities[0]->getIsTree()){
525
- $tree = $entities[0];
526
- $sibling = $entities[1];
527
- }
528
- else{
529
- $tree = $entities[1];
530
- $sibling = $entities[0];
531
- }
532
- $replaceEntity = $tree->getPlaceholders();
533
- $replaceSibling = $sibling->getPlaceholdersAsSibling();
534
- $replace = array_merge($replaceEntity, $replaceSibling);
535
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
536
- }
537
- }
538
- }
539
- elseif($scope == 'siblings_both_not_tree'){
540
- foreach ($this->getRelations(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING) as $relation){
541
- $entities = $relation->getEntities();
542
- if ($entities[0]->getIsTree() || $entities[1]->getIsTree()){
543
- continue;
544
- }
545
- $replaceEntity = $entities[0]->getPlaceholders();
546
- $replaceSibling = $entities[1]->getPlaceholdersAsSibling();
547
- $replace = array_merge($replaceEntity, $replaceSibling);
548
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
549
-
550
- $replaceEntity = $entities[1]->getPlaceholders();
551
- $replaceSibling = $entities[0]->getPlaceholdersAsSibling();
552
- $replace = array_merge($replaceEntity, $replaceSibling);
553
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
554
- }
555
- }
556
- elseif ($scope == 'children'){
557
- foreach ($this->getRelations(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD) as $relation){
558
- $entities = $relation->getEntities();
559
- $replaceEntity = $entities[0]->getPlaceholders();
560
- $replaceSibling = $entities[1]->getPlaceholdersAsSibling();
561
- $replace = array_merge($replaceEntity, $replaceSibling);
562
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
563
- }
564
- foreach ($this->getRelations(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_PARENT) as $relation){
565
- $entities = $relation->getEntities();
566
- $replaceEntity = $entities[1]->getPlaceholders();
567
- $replaceSibling = $entities[0]->getPlaceholdersAsSibling();
568
- $replace = array_merge($replaceEntity, $replaceSibling);
569
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
570
- }
571
- }
572
- else{
573
- $valid = true;
574
- $depend = $file->depend;
575
- if ($depend){
576
- foreach ($depend->asArray() as $condition=>$value){
577
- if (!$this->getDataUsingMethod($condition)){
578
- $valid = false;
579
- break;
580
- }
581
- }
582
- }
583
- if ($valid){
584
- $content .= $this->_filterString($sourceContent, $filetype);
585
- }
586
- }
587
- }
588
- }
589
- if ($config->after_build){
590
- $function = (string)$config->after_build;
591
- $content = $this->$function($content);
592
- }
593
- $this->_addFile($destinationFile, $content);
594
- return $this;
595
- }
596
- /**
597
- * create a file with entity scope
598
- * @access protected
599
- * @param Varien_Simplexml_Element
600
- * @return Ultimate_ModuleCreator_Model_Module
601
- * @author Marius Strajeru <marius.strajeru@gmail.com>
602
- */
603
- protected function _buildEntityFile($config){
604
- foreach ($this->getEntities() as $entity){
605
- $filetype = $config->filetype;
606
- $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->from, $filetype);
607
- $destinationFile = $this->_filterString((string)$config->to, $filetype, $entity->getPlaceholders(), true);
608
- $content = '';
609
- $depend = $config->depend;
610
- $build = true;
611
- if ($depend){
612
- foreach ($depend->asArray() as $condition=>$value){
613
- if (!$entity->getDataUsingMethod($condition)){
614
- $build = false;
615
- break;
616
- }
617
- }
618
- }
619
- if (!$build){
620
- continue;
621
- }
622
- foreach ($config->descend('content/file') as $file){
623
- $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name);
624
- $scope = (string)$file->scope;
625
- $depend = $file->depend;
626
- $dependType = $file->depend_type;
627
- if ($scope == 'attribute'){
628
- foreach ($entity->getAttributes() as $attribute){
629
- $valid = true;
630
- if ($depend){
631
- foreach ($depend->asArray() as $condition=>$value){
632
- if (!$attribute->getDataUsingMethod($condition)){
633
- $valid = false;
634
- break;
635
- }
636
- }
637
- }
638
- $typeValid = true;
639
- if ($dependType){
640
- $typeValid = false;
641
- foreach ($dependType->asArray() as $condition=>$value){
642
- if ($attribute->getType() == $condition){
643
- $typeValid = true;
644
- break;
645
- }
646
- }
647
- }
648
- if ($valid && $typeValid){
649
- $replace = $entity->getPlaceholders();
650
- $attributeReplace = $attribute->getPlaceholders();
651
- $replace = array_merge($replace, $attributeReplace);
652
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
653
- }
654
- }
655
- }
656
- elseif($scope == 'siblings'){
657
- foreach ($entity->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING) as $related){
658
- $placeholders = $entity->getPlaceholders();
659
- $replaceSibling = $related->getPlaceholdersAsSibling();
660
- $replace = array_merge($placeholders, $replaceSibling);
661
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
662
- }
663
- }
664
- elseif($scope == 'siblings_not_tree'){
665
- foreach ($entity->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING) as $related){
666
- if ($related->getNotIsTree()){
667
- $placeholders = $entity->getPlaceholders();
668
- $replaceSibling = $related->getPlaceholdersAsSibling();
669
- $replace = array_merge($placeholders, $replaceSibling);
670
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
671
- }
672
- }
673
- }
674
- elseif($scope == 'siblings_tree'){
675
- foreach ($entity->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING) as $related){
676
- if ($related->getIsTree()){
677
- $placeholders = $entity->getPlaceholders();
678
- $replaceSibling = $related->getPlaceholdersAsSibling();
679
- $replace = array_merge($placeholders, $replaceSibling);
680
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
681
- }
682
- }
683
- }
684
- elseif($scope == 'parents'){
685
- foreach ($entity->getRelatedEntities(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD) as $related){
686
- $placeholders = $entity->getPlaceholders();
687
- $replaceSibling = $related->getPlaceholdersAsSibling();
688
- $replace = array_merge($placeholders, $replaceSibling);
689
- $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
690
- }
691
- }
692
- elseif ($depend){
693
- $valid = true;
694
- foreach ($depend->asArray() as $condition=>$value){
695
- if (!$entity->getDataUsingMethod($condition)){
696
- $valid = false;
697
- break;
698
- }
699
- }
700
- if ($valid){
701
- $content .= $this->_filterString($sourceContent, $filetype, $entity->getPlaceholders(), true);
702
- }
703
- }
704
- else{
705
- $content .= $this->_filterString($sourceContent, $filetype, $entity->getPlaceholders(), true);
706
- }
707
- $this->_addFile($destinationFile, $content);
708
- }
709
- }
710
- return $this;
711
- }
712
- /**
713
- * create files for sibling relations
714
- * @access protected
715
- * @param Varien_Simplexml_Element
716
- * @return Ultimate_ModuleCreator_Model_Module
717
- * @author Marius Strajeru <marius.strajeru@gmail.com>
718
- */
719
- protected function _buildSiblingFile($config){
720
- foreach ($this->getRelations(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING) as $relation){
721
- $entities = $relation->getEntities();
722
- foreach ($entities as $index=>$entity){
723
- $depend = $config->depend;
724
- $build = true;
725
- if ($depend){
726
- foreach ($depend->asArray() as $condition=>$value){
727
- if (!$relation->getDataUsingMethod($condition, $index)){
728
- $build = false;
729
- break;
730
- }
731
- }
732
- }
733
- if (!$build){
734
- continue;
735
- }
736
- $placeholders = array_merge($entities[$index]->getPlaceholders(), $entities[1 - $index]->getPlaceholdersAsSibling());
737
- $filetype = $config->filetype;
738
- $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->from, $filetype);
739
- $destinationFile = $this->_filterString((string)$config->to, $filetype, $placeholders, true);
740
- $content = '';
741
- foreach ($config->descend('content/file') as $file){
742
- $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name);
743
- $content .= $this->_filterString($sourceContent, $filetype, $placeholders, true);
744
- }
745
- $this->_addFile($destinationFile, $content);
746
- }
747
- }
748
- return $this;
749
- }
750
-
751
- /**
752
- * create files for children relations
753
- * @access protected
754
- * @param Varien_Simplexml_Element
755
- * @return Ultimate_ModuleCreator_Model_Module
756
- * @author Marius Strajeru <marius.strajeru@gmail.com>
757
- */
758
- protected function _buildChildrenFile($config){
759
- foreach ($this->getRelations() as $relation){
760
- $type = $relation->getType();
761
- $entities = $relation->getEntities();
762
- $parent = false;
763
- $child = false;
764
- if ($type == Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_PARENT){
765
- $parent = $entities[0];
766
- $child = $entities[1];
767
- }
768
- elseif ($type == Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD){
769
- $parent = $entities[1];
770
- $child = $entities[0];
771
- }
772
- if ($parent && $child){
773
-
774
- $depend = $config->depend;
775
- $build = true;
776
- if ($depend){
777
- foreach ($depend->asArray() as $condition=>$value){
778
- if (!$relation->getDataUsingMethod($condition)){
779
- $build = false;
780
- break;
781
- }
782
- }
783
- }
784
- if (!$build){
785
- continue;
786
- }
787
- $placeholders = array_merge($parent->getPlaceholders(), $child->getPlaceholdersAsSibling());
788
- $filetype = $config->filetype;
789
- $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->from, $filetype);
790
- $destinationFile = $this->_filterString((string)$config->to, $filetype, $placeholders, true);
791
- $content = '';
792
- foreach ($config->descend('content/file') as $file){
793
- $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name);
794
- $content .= $this->_filterString($sourceContent, $filetype, $placeholders, true);
795
- }
796
- $this->_addFile($destinationFile, $content);
797
- }
798
- }
799
- return $this;
800
- }
801
-
802
- /**
803
- * add file
804
- * @access protected
805
- * @param string $destinationFile
806
- * @param string $content
807
- * @return Ultimate_ModuleCreator_Model_Module
808
- * @author Marius Strajeru <marius.strajeru@gmail.com>
809
- */
810
- protected function _addFile($destinationFile, $content){
811
- if (trim($content)){
812
- $this->_files[$destinationFile] = $content;
813
- }
814
- return $this;
815
- }
816
- /**
817
- * get contents of a file
818
- * @access public
819
- * @param string $file
820
- * @return string
821
- * @author Marius Strajeru <marius.strajeru@gmail.com>
822
- */
823
- public function getFileContents($file){
824
- return file_get_contents($file);
825
- }
826
- /**
827
- * filter placeholders
828
- * @access protected
829
- * @param string $string
830
- * @param string $fileType
831
- * @param mixed (null|array()) $replaceArray
832
- * @param bool $mergeReplace
833
- * @param bool $forLicence
834
- * @return string
835
- * @author Marius Strajeru <marius.strajeru@gmail.com>
836
- */
837
- protected function _filterString($string, $fileType, $replaceArray = null, $mergeReplace = false, $forLicence = false){
838
- $replace = array();
839
- $replace['{{DS}}'] = DS;
840
- $replace['{{namespace}}'] = strtolower($this->getNamespace());
841
- $replace['{{sort_order}}'] = (int)$this->getSortOrder();
842
- $replace['{{module}}'] = strtolower($this->getModuleName());
843
- $replace['{{Namespace}}'] = $this->getNamespace();
844
- $replace['{{Module}}'] = $this->getModuleName();
845
- $replace['{{NAMESPACE}}'] = strtoupper($this->getNamespace());
846
- $replace['{{MODULE}}'] = strtoupper($this->getModuleName());
847
- if (!$forLicence) {
848
- $replace['{{License}}'] = $this->getLicenseText($fileType);
849
- }
850
- $replace['{{codepool}}'] = $this->getCodepool();
851
- $replace['{{qwertyuiop}}'] = $this->getQwertyuiop();
852
- $replace['{{package}}'] = $this->getFrontPackage();
853
- $replace['{{theme_layout}}'] = $this->getFrontTemplates();
854
- $replace['{{theme_template}}'] = $this->getFrontTemplates();
855
- $replace['{{Y}}'] = date('Y');
856
- if (!is_null($replaceArray)){
857
- if ($mergeReplace){
858
- $replace = array_merge($replace, $replaceArray);
859
- }
860
- else{
861
- $replace = $replaceArray;
862
- }
863
- }
864
- return str_replace(array_keys($replace), array_values($replace), $string);
865
- }
866
- /**
867
- * get text for licence
868
- * @access public
869
- * @param string $fileType
870
- * @return string
871
- * @author Marius Strajeru <marius.strajeru@gmail.com>
872
- */
873
- public function getLicenseText($fileType){
874
- if (!$this->getData('processed_license_'.$fileType)){
875
- $license = trim($this->getData('license'));
876
- if (!$license){
877
- return '';
878
- }
879
- while(strpos($license, '*/') !== false){
880
- $license = str_replace('*/', '', $license);
881
- }
882
- while(strpos($license, '/*') !== false){
883
- $license = str_replace('/*', '', $license);
884
- }
885
- while(strpos($license, '<!--') !== false){
886
- $license = str_replace('<!--', '', $license);
887
- }
888
- while(strpos($license, '-->') !== false){
889
- $license = str_replace('-->', '', $license);
890
- }
891
- $lines = explode("\n", $license);
892
- $top = '';
893
- $footer = '';
894
- if ($fileType == 'xml'){
895
- $top = '<!--'."\n";
896
- $footer = "\n".'-->';
897
- }
898
- $processed = $top.'/**'."\n";
899
- foreach ($lines as $line){
900
- $processed .= ' * '.$line."\n";
901
- }
902
- $processed .= ' */'.$footer;
903
- $this->setData('processed_license_'.$fileType, $this->_filterString($processed, $fileType, array(), true, true));
904
- }
905
- return $this->getData('processed_license_'.$fileType);
906
- }
907
- /**
908
- * get sample files source folder
909
- * @access public
910
- * @return string
911
- * @author Marius Strajeru <marius.strajeru@gmail.com>
912
- */
913
- public function getSourceFolder(){
914
- if (!$this->_sourceFolder){
915
- $this->_sourceFolder = Mage::getConfig()->getModuleDir('etc', 'Ultimate_ModuleCreator').DS.'m'.DS;
916
- }
917
- return $this->_sourceFolder;
918
- }
919
- /**
920
- * sort the translation file
921
- * @access protected
922
- * @param string $content
923
- * @return string
924
- * @author Marius Strajeru <marius.strajeru@gmail.com>
925
- */
926
- protected function _sortTranslationFile($content){
927
- $lines = explode(PHP_EOL, $content);
928
- $distinct = array();
929
- foreach ($lines as $line){
930
- if (trim($line)){
931
- $distinct[$line] = 1;
932
- }
933
- }
934
- //remove blank line
935
- if (isset($distinct['"",""'])){
936
- unset($distinct['"",""']);
937
- }
938
- ksort($distinct);
939
- $content = implode(PHP_EOL, array_keys($distinct));
940
- return $content;
941
- }
942
- /**
943
- * get extension name
944
- * @access public
945
- * @return string
946
- * @author Marius Strajeru <marius.strajeru@gmail.com>
947
- */
948
- public function getExtension(){
949
- return $this->getNamespace().'_'.$this->getModuleName();
950
- }
951
- /**
952
- * add relation to module
953
- * @access public
954
- * @param Ultimate_ModuleCreator_Model_Relation $relation
955
- * @return Ultimate_ModuleCreator_Model_Module
956
- * @author Marius Strajeru <marius.strajeru@gmail.com>
957
- */
958
- public function addRelation(Ultimate_ModuleCreator_Model_Relation $relation){
959
- $this->_relations[] = $relation;
960
- return $this;
961
- }
962
- /**
963
- * get module relations
964
- * @access public
965
- * @param mixed $type
966
- * @return array()
967
- * @author Marius Strajeru <marius.strajeru@gmail.com>
968
- */
969
- public function getRelations($type = null){
970
- if (is_null($type)){
971
- return $this->_relations;
972
- }
973
- $relations = array();
974
- foreach ($this->_relations as $relation){
975
- if ($relation->getType() == $type){
976
- $relations[] = $relation;
977
- }
978
- }
979
- return $relations;
980
- }
981
- /**
982
- * get use ddl
983
- * @access public
984
- * @return bool
985
- * @author Marius Strajeru <marius.strajeru@gmail.com>
986
- */
987
- public function getUseDdl(){
988
- return Mage::getStoreConfigFlag('modulecreator/settings/use_ddl');
989
- }
990
- /**
991
- * get not use ddl
992
- * @access public
993
- * @return bool
994
- * @author Marius Strajeru <marius.strajeru@gmail.com>
995
- */
996
- public function getNotUseDdl(){
997
- return !$this->getUseDdl();
998
- }
999
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
 
 
 
 
 
 
18
  class Ultimate_ModuleCreator_Model_Module extends Ultimate_ModuleCreator_Model_Abstract{
19
+ /**
20
+ * entity code
21
+ * @var string
22
+ */
23
+ protected $_entityCode = 'umc_module';
24
+ /**
25
+ * module entities
26
+ * @var array()
27
+ */
28
+ protected $_entities = array();
29
+ /**
30
+ * module config
31
+ * @var mixed (null|Varien_Simplexml_Element)
32
+ */
33
+ protected $_config = null;
34
+ /**
35
+ * entity relations
36
+ * @var array
37
+ */
38
+ protected $_relations = array();
39
+ /**
40
+ * io member
41
+ * @var null|Varien_Io_File
42
+ */
43
+ protected $_io = null;
44
+ /**
45
+ * error log
46
+ * @var array
47
+ */
48
+ protected $_errors = array();
49
+ /**
50
+ * source folder
51
+ * @var null
52
+ */
53
+ protected $_sourceFolder = null;
54
+ /**
55
+ * placeholders
56
+ * @var null
57
+ */
58
+ protected $_placeholders = null;
59
+ /**
60
+ * base placeholders
61
+ * @var array
62
+ */
63
+ protected $_basePlaceholders = array();
64
+ /**
65
+ * generated files
66
+ * @var array
67
+ */
68
+ protected $_files = array();
69
+ /**
70
+ * add entity to module
71
+ * @access public
72
+ * @param Ultimate_ModuleCreator_Model_Entity $entity
73
+ * @return Ultimate_ModuleCreator_Model_Module
74
+ * @throws Ultimate_ModuleCreator_Exception
75
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
76
+ */
77
+ public function addEntity(Ultimate_ModuleCreator_Model_Entity $entity){
78
+ Mage::dispatchEvent('umc_module_add_entity_before', array('entity'=>$entity, 'module'=>$this));
79
+ if (isset($this->_entities[$entity->getNameSingular()])){
80
+ throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('An entity with the code "%s" already exists', $entity->getNameSingular()));
81
+ }
82
+ $entity->setModule($this);
83
+ $entity->setIndex(count($this->_entities));
84
+ $position = 10 * (count($this->_entities));
85
+ $entity->setPosition($position);
86
+ $this->_entities[$entity->getNameSingular()] = $entity;
87
+ if ($entity->getRss()){
88
+ $this->setRss(true);
89
+ }
90
+ if ($entity->getHasFile()){
91
+ $this->setHasFile(true);
92
+ }
93
+ if ($entity->getHasImage()){
94
+ $this->setHasImage(true);
95
+ }
96
+ if ($entity->getAddSeo()){
97
+ $this->setAddSeo(true);
98
+ }
99
+ if ($entity->getWidget()){
100
+ $this->setWidget(true);
101
+ }
102
+ if ($entity->getCreateFrontend()){
103
+ $this->setCreateFrontend(true);
104
+ $this->setCanCreateRouter(true);
105
+ }
106
+ if ($entity->getCreateList()){
107
+ $this->setCreateList(true);
108
+ }
109
+ if ($entity->getIsTree()){
110
+ $this->setHasTree(true);
111
+ }
112
+ if ($entity->getEditor()){
113
+ $this->setEditor(true);
114
+ }
115
+ if ($entity->getHasConfigDefaults()){
116
+ $this->setHasConfigDefaults(true);
117
+ }
118
+ if ($entity->getLinkProduct()){
119
+ $this->setLinkProduct(true);
120
+ $this->setHasObserver(true);
121
+ }
122
+ if ($entity->getLinkCategory()){
123
+ $this->setLinkCategory(true);
124
+ $this->setHasObserver(true);
125
+ }
126
+ if ($entity->getLinkCore()){
127
+ $this->setLinkCore(true);
128
+ }
129
+ if ($entity->getUrlRewrite()){
130
+ $this->setUrlRewrite(true);
131
+ }
132
+ if ($entity->getIsEav()) {
133
+ $this->setHasEav(true);
134
+ }
135
+ if ($entity->getIsFlat()) {
136
+ $this->setHasFlat(true);
137
+ }
138
+ if ($entity->getApi()){
139
+ $this->setApi(true);
140
+ }
141
+ if ($entity->getAllowComment()){
142
+ $this->setAllowComment(true);
143
+ }
144
+ if ($entity->getAllowCommentByStore()){
145
+ $this->setAllowCommentByStore(true);
146
+ }
147
+ if ($entity->getHasCountry()){
148
+ $this->setHasCountry(true);
149
+ }
150
+ if ($entity->getAddSeo()){
151
+ $this->setHasSeo(true);
152
+ }
153
+ if ($entity->getCanCreateListBlock()){
154
+ $this->setCreateFrontend(true);
155
+ }
156
+ if ($entity->getShowOnProduct()) {
157
+ $this->setShowOnProduct(true);
158
+ }
159
+ if ($entity->getShowOnCategory()) {
160
+ $this->setShowOnCategory(true);
161
+ }
162
+ if ($entity->getShowInCategoryMenu()) {
163
+ $this->setShowInCategoryMenu(true);
164
+ }
165
+ if ($entity->getSearch()) {
166
+ $this->setSearch(true);
167
+ }
168
+ Mage::dispatchEvent('umc_module_add_entity_after', array('entity'=>$entity, 'module'=>$this));
169
+ return $this;
170
+ }
171
+ /**
172
+ * get a module entity
173
+ * @access public
174
+ * @param string $code
175
+ * @return mixed(Ultimate_ModuleCreator_Model_Entity|null)
176
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
177
+ */
178
+ public function getEntity($code){
179
+ if (isset($this->_entities[$code])){
180
+ return $this->_entities[$code];
181
+ }
182
+ return null;
183
+ }
184
+ /**
185
+ * module to xml
186
+ * @access public
187
+ * @param array $arrAttributes
188
+ * @param string $rootName
189
+ * @param bool $addOpenTag
190
+ * @param bool $addCdata
191
+ * @return string
192
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
193
+ */
194
+ public function toXml(array $arrAttributes = array(), $rootName = 'module', $addOpenTag=false, $addCdata=false){
195
+ $xml = '';
196
+ $eol = $this->getEol();
197
+ if ($addOpenTag) {
198
+ $xml.= '<?xml version="1.0" encoding="UTF-8"?>'.$eol;
199
+ }
200
+ if (!empty($rootName)) {
201
+ $xml.= '<'.$rootName.'>'.$eol;
202
+ }
203
+ $start = '';
204
+ $end = '';
205
+ if ($addCdata){
206
+ $start = '<![CDATA[';
207
+ $end = ']]>';
208
+ }
209
+ $xml .= parent::toXml($this->getXmlAttributes(), '', false, $addCdata);
210
+ $xml .= '<entities>'.$eol;
211
+ foreach ($this->getEntities() as $entity){
212
+ $xml .= $entity->toXml(array(), 'entity', false, $addCdata);
213
+ }
214
+ $xml .= '</entities>'.$eol;
215
+ $xml .= '<relations>'.$eol;
216
+ foreach ($this->getRelations() as $relation){
217
+ $xml .= $relation->toXml(array(), '', false, $addCdata);
218
+ }
219
+ $xml .= '</relations>'.$eol;
220
+ if (!empty($rootName)) {
221
+ $xml.= '</'.$rootName.'>'.$eol;
222
+ }
223
+ return $xml;
224
+ }
225
+ /**
226
+ * get the module entities
227
+ * @access public
228
+ * @return Ultimate_ModuleCreator_Model_Entity[]
229
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
230
+ */
231
+ public function getEntities(){
232
+ $this->_prepareEntities();
233
+ return $this->_entities;
234
+ }
235
+ /**
236
+ * prepare the entities before saving
237
+ * @access protected
238
+ * @return Ultimate_ModuleCreator_Model_Module
239
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
240
+ */
241
+ protected function _prepareEntities(){
242
+ Mage::dispatchEvent('umc_module_prepare_entities', array('module'=>$this));
243
+ return $this;
244
+ }
245
+ /**
246
+ * add relation to module
247
+ * @access public
248
+ * @param Ultimate_ModuleCreator_Model_Relation $relation
249
+ * @return Ultimate_ModuleCreator_Model_Module
250
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
251
+ */
252
+ public function addRelation(Ultimate_ModuleCreator_Model_Relation $relation){
253
+ Mage::dispatchEvent('umc_module_add_relation_before', array('relation'=>$relation, 'module'=>$this));
254
+ $this->_relations[] = $relation;
255
+ Mage::dispatchEvent('umc_module_add_relation_after', array('relation'=>$relation, 'module'=>$this));
256
+ return $this;
257
+ }
258
+ /**
259
+ * get module relations
260
+ * @access public
261
+ * @param mixed $type
262
+ * @return array()
263
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
264
+ */
265
+ public function getRelations($type = null){
266
+ if (is_null($type)){
267
+ return $this->_relations;
268
+ }
269
+ $relations = array();
270
+ foreach ($this->_relations as $relation){
271
+ if ($relation->getType() == $type){
272
+ $relations[] = $relation;
273
+ }
274
+ }
275
+ return $relations;
276
+ }
277
+ /**
278
+ * get the extensions xml path
279
+ * @access public
280
+ * @return string
281
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
282
+ */
283
+ public function getXmlPath(){
284
+ return Mage::helper('modulecreator')->getLocalPackagesPath().$this->getNamespace()."_".$this->getModuleName().'.xml';
285
+ }
286
+ /**
287
+ * save the module as xml
288
+ * @access public
289
+ * @return Ultimate_ModuleCreator_Model_Module
290
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
291
+ */
292
+ public function save(){
293
+ $destination = $this->getXmlPath();
294
+ $xml = $this->toXml(array(), 'module', true, true);
295
+ $this->_writeFile($destination, $xml);
296
+ return $this;
297
+ }
298
+
299
+ /**
300
+ * validate the module
301
+ * @access public
302
+ * @return array
303
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
304
+ */
305
+ public function validate(){
306
+ $errors = array();
307
+ $config = Mage::helper('modulecreator')->getConfig();
308
+ $settings = $config->getNode('forms/settings/fieldsets');
309
+ foreach ($settings->fieldset as $k => $set){
310
+ foreach ($set->fields->children() as $key => $values){
311
+ $v = $this->getData($key);
312
+ if ((string)$values->required == 1 && (!$this->hasData($key) || $v === "")) {
313
+ $this->_addError(Mage::helper("modulecreator")->__('This is a required field.'), 'settings_'.$key);
314
+ }
315
+ }
316
+ }
317
+ //validate namespace
318
+ if (strtolower($this->getNamespace()) == 'mage'){
319
+ $this->_addError(Mage::helper('modulecreator')->__("You shouldn't use the namespace Mage. Be Creative"), 'settings_namespace');
320
+ }
321
+ //validate module name
322
+ $routers = Mage::getConfig()->getNode('frontend/routers');
323
+ $moduleName = $this->getModuleName();
324
+ $lower = strtolower($moduleName);
325
+ $extension = $this->getExtensionName();
326
+ if ($routers->$lower){
327
+ if ((string)$routers->$lower->args->module != $extension) {
328
+ $this->_addError(Mage::helper('modulecreator')->__('You cannot use the module name %s', $this->getModuleName()), 'settings_module_name');
329
+ }
330
+ }
331
+ //validate front key
332
+ foreach ((array)$routers as $router) {
333
+ if ((string)$router->args->frontName == $this->getFrontKey() && $router->args->module != $extension){
334
+ $this->_addError(Mage::helper('modulecreator')->__('You cannot use the front key %s. It is used by the module %s', $this->getFrontKey(), (string)$router->args->module), 'settings_front_key');
335
+ break;
336
+ }
337
+ }
338
+ //validate entity count
339
+ if (count($this->getEntities()) == 0){
340
+ $this->_addError(Mage::helper('modulecreator')->__('Add at least an entity'));
341
+ }
342
+ else {
343
+ //validate entities
344
+ foreach ($this->getEntities() as $entity){
345
+ $entityCode = $entity->getNameSingular(true);
346
+ if (in_array($entityCode, $this->getRestrictedEntityNames())){
347
+ $this->_addError(Mage::helper('modulecreator')->__('The entity code "%s" is restricted', $entityCode), 'entity_'.$entity->getIndex().'_name_singular');
348
+ }
349
+ if (count($entity->getAttributes()) == 0){
350
+ $this->_addError(Mage::helper('modulecreator')->__('The entity "%s" must have at least one attribute.', $entity->getLabelSingular()));
351
+ }
352
+ else{
353
+ //validate name attribute
354
+ if (is_null($entity->getNameAttribute())){
355
+ $this->_addError(Mage::helper('modulecreator')->__('The entity "%s" must have an attribute that behaves as a name.', $entity->getLabelSingular()));
356
+ }
357
+ $restrictedAttributes = $this->getRestrictedAttributeCodes();
358
+ //validate attributes
359
+ foreach ($entity->getAttributes() as $key=>$attribute){
360
+ $code = $attribute->getCode();
361
+ if (isset($restrictedAttributes[$code])){
362
+ //presume "not guilty"
363
+ $valid = true;
364
+ if (!isset($restrictedAttributes[$code]->depend_entity)){//if general restriction.
365
+ $valid = false;
366
+ }
367
+ else{//if depends on entity setting.
368
+ foreach ((array)$restrictedAttributes[$code]->depend_entity as $prop=>$value){
369
+ if ($entity->getDataUsingMethod($prop) == $value){
370
+ //"found guilty"
371
+ $valid = false;
372
+ break;
373
+ }
374
+ }
375
+ }
376
+ if (!$valid){
377
+ $this->_addError($restrictedAttributes[$code]->message, 'attribute_'.$entity->getIndex().'_'.$attribute->getIndex().'_code');
378
+ }
379
+ }
380
+ //validate attributes against getters ("getData", "getCollection", ,....)
381
+ $methodCodes = $this->getMethodAttributeCodes();
382
+ if (in_array($code, $methodCodes)){
383
+ $method = $method = str_replace(' ', '', ucwords(str_replace('_', ' ', $code)));
384
+ $this->_addError(Mage::helper('modulecreator')->__('Attribute code %s is restricted because a method similar to "set%s()" or "get%s()" exists in parent model class', $code, $method, $method), 'attribute_'.$entity->getIndex().'_'.$attribute->getIndex().'_code');
385
+ }
386
+ }
387
+ }
388
+ }
389
+ }
390
+
391
+ return $this->_errors;
392
+ }
393
+
394
+ /**
395
+ * add an error to the error list
396
+ * @access protected
397
+ * @param $message
398
+ * @param null $attribute
399
+ * @param string $separator
400
+ * @return Ultimate_ModuleCreator_Model_Module
401
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
402
+ */
403
+ protected function _addError($message, $attribute = null, $separator = '<br />'){
404
+ if (empty($attribute)){
405
+ $this->_errors[''][] = $message;
406
+ }
407
+ else{
408
+ if (!isset($this->_errors[$attribute])){
409
+ $this->_errors[$attribute] = '';
410
+ }
411
+ else{
412
+ $this->_errors[$attribute] .= '<br />';
413
+ }
414
+ $this->_errors[$attribute] .= $message;
415
+ }
416
+ return $this;
417
+ }
418
+ /**
419
+ * write a file
420
+ * @access protected
421
+ * @param string $destinationFile
422
+ * @param string $contents
423
+ * @throws Exception
424
+ * @return Ultimate_ModuleCreator_Model_Module
425
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
426
+ */
427
+ protected function _writeFile($destinationFile, $contents){
428
+ try{
429
+ $io = $this->getIo();
430
+ $io->mkdir(dirname($destinationFile));
431
+ $io->write($destinationFile, $contents, 0777);
432
+ }
433
+ catch (Exception $e){
434
+ if ($e->getCode() != 0){
435
+ throw $e;
436
+ }
437
+ }
438
+ return $this;
439
+ }
440
+ /**
441
+ * get the IO - class
442
+ * @access public
443
+ * @return Varien_Io_File
444
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
445
+ */
446
+ public function getIo(){
447
+ if (!$this->_io){
448
+ $this->_io = new Varien_Io_File();
449
+ $this->_io->setAllowCreateFolders(true);
450
+ }
451
+ return $this->_io;
452
+ }
453
+
454
+ /**
455
+ * get module relations as json
456
+ * @access public
457
+ * @return string
458
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
459
+ */
460
+ public function getRelationsAsJson(){
461
+ $json = array();
462
+ $relations = $this->getRelations();
463
+ foreach ($relations as $relation){
464
+ $entities = $relation->getEntities();
465
+ $json[$entities[0]->getIndex().'_'.$entities[1]->getIndex()] = $relation->getType();
466
+ }
467
+ return json_encode($json);
468
+ }
469
+
470
+ /**
471
+ * get the extension name
472
+ * @param bool $lower
473
+ * @return string
474
+ * @access public
475
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
476
+ */
477
+ public function getExtensionName($lower = false){
478
+ $name = $this->getNamespace().'_'.$this->getModuleName();
479
+ if ($lower) {
480
+ $name = strtolower($name);
481
+ }
482
+ return $name;
483
+ }
484
+
485
+ /**
486
+ * get the restricted entity name
487
+ * @access public
488
+ * @return array
489
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
490
+ */
491
+ public function getRestrictedEntityNames(){
492
+ return $this->getDataSetDefault('restricted_entity_names', array_keys((array)Mage::helper('modulecreator')->getConfig()->getNode('restricted/entity')));
493
+ }
494
+ /**
495
+ * get the restricted attribute codes
496
+ * @access public
497
+ * @return array
498
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
499
+ */
500
+ public function getRestrictedAttributeCodes(){
501
+ return $this->getDataSetDefault('restricted_attribute_codes', (array)Mage::helper('modulecreator')->getConfig()->getNode('restricted/attribute'));
502
+ }
503
+ /**
504
+ * get the restricted attribute codes because of the method names
505
+ * @access public
506
+ * @return array
507
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
508
+ */
509
+ public function getMethodAttributeCodes(){
510
+ if (!$this->hasData('method_attribute_codes')){
511
+ $attributes = array();
512
+ $methods = get_class_methods('Mage_Catalog_Model_Abstract');
513
+ $start = array('get', 'set', 'has', 'uns');
514
+ foreach ($methods as $method){
515
+ if (in_array(substr($method, 0, 3), $start)){
516
+ $attribute = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", substr($method,3)));
517
+ $attributes[$attribute] = 1;
518
+ }
519
+ }
520
+ $this->setData('method_attribute_codes', array_keys($attributes));
521
+ }
522
+ return $this->getData('method_attribute_codes');
523
+ }
524
+
525
+ /**
526
+ * build the module
527
+ * @access public
528
+ * @return array
529
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
530
+ */
531
+ public function buildModule(){
532
+ $config = $this->getConfig();
533
+ $files = $config->getNode('files');
534
+ $messages = array();
535
+ foreach ((array)$files as $key=>$file){
536
+ if ($file->scope == 'disabled'){
537
+ continue;
538
+ }
539
+ $this->_createFile($file);
540
+ }
541
+ if ($this->getInstall()){
542
+ $existingFiles = $this->_checkExistingFiles();
543
+ if (count($existingFiles) > 0){
544
+ $this->setInstall(false);
545
+ $messages[] = Mage::helper('modulecreator')->__('The following files already exist. They were NOT overwritten. The extension was not installed. You can download it from the list of extensions and install it manually: %s', implode('<br />', $existingFiles));
546
+ }
547
+ }
548
+ $this->_writeFiles();
549
+ if (!$this->getInstall()){
550
+ $contents = array();
551
+ foreach ($this->_files as $filename=>$file){
552
+ $contents[] = $this->getRelativeBasePath().$filename;
553
+ }
554
+ $_writer = Mage::getModel('modulecreator/writer', $contents);
555
+ $_writer->setNamePackage(Mage::getBaseDir('var').DS.'modulecreator'.DS.$this->getExtensionName());
556
+ $_writer->composePackage()->archivePackage();
557
+ $this->_io->rmdir($this->getBasePath(), true);
558
+ }
559
+ return $messages;
560
+ }
561
+
562
+ /**
563
+ * write files to disk
564
+ * @access protected
565
+ * @return Ultimate_ModuleCreator_Model_Module
566
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
567
+ */
568
+ protected function _writeFiles(){
569
+ $basePath = $this->getBasePath();
570
+ foreach ($this->_files as $name=>$file){
571
+ $destinationFile = $basePath.$name;
572
+ $this->_writeFile($destinationFile, $file);
573
+ }
574
+ $this->_writeLog();
575
+ $this->_writeUninstall();
576
+ return $this;
577
+ }
578
+
579
+ /**
580
+ * write log with generated files
581
+ * can be used for uninstall
582
+ * @access protected
583
+ * @return Ultimate_ModuleCreator_Model_Module
584
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
585
+ */
586
+ protected function _writeLog(){
587
+ $filesToWrite = array_keys($this->_files);
588
+ asort($filesToWrite);
589
+ $filesToWrite = array_values($filesToWrite);
590
+ $text = implode($this->getEol(), $filesToWrite);
591
+ $this->_writeFile($this->getLogPath(), $text);
592
+ return $this;
593
+ }
594
+ /**
595
+ * write sql uninstall script
596
+ * @access protected
597
+ * @return Ultimate_ModuleCreator_Model_Module
598
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
599
+ */
600
+ protected function _writeUninstall(){
601
+ $lines = array();
602
+ $module = $this->getPlaceholder('{{module}}');
603
+ $namespace = $this->getNamespace(true);
604
+ $lines[] = '-- add table prefix if you have one';
605
+ foreach ($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $relation){
606
+ $entities = $relation->getEntities();
607
+ $tableName = $namespace.'_'.$module.'_'.$entities[0]->getPlaceholders('{{entity}}').'_'.$entities[1]->getPlaceholders('{{entity}}');
608
+ $lines[] = 'DROP TABLE '.$tableName.';';
609
+ }
610
+ foreach ($this->getEntities() as $entity){
611
+ if ($entity->getIsEav()){
612
+ $entityTypeCode = $namespace.'_'.$this->getLowerModuleName().'_'.$entity->getPlaceholders('{{entity}}');
613
+ $lines[] = "DELETE FROM eav_attribute WHERE entity_type_id IN (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = '{$entityTypeCode}');";
614
+ $lines[] = "DELETE FROM eav_entity_type WHERE entity_type_code = '{$entityTypeCode}';";
615
+ }
616
+ if ($entity->getProductAttribute()){
617
+ $lines[] = "DELETE FROM eav_attribute WHERE attribute_code = '".$entity->getProductAttributeCode()."' AND entity_type_id IN (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'catalog_product');";
618
+ }
619
+ if ($entity->getCategoryAttribute()){
620
+ $lines[] = "DELETE FROM eav_attribute WHERE attribute_code = '".$entity->getCategoryAttributeCode()."' AND entity_type_id IN (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'catalog_category');";
621
+ }
622
+ if ($entity->getAllowCommentByStore()){
623
+ $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_comment_store';
624
+ $lines[] = 'DROP TABLE '.$tableName.';';
625
+ }
626
+ if ($entity->getAllowComment()){
627
+ $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_comment';
628
+ $lines[] = 'DROP TABLE '.$tableName.';';
629
+ }
630
+ if ($entity->getLinkProduct()){
631
+ $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_product';
632
+ $lines[] = 'DROP TABLE '.$tableName.';';
633
+ }
634
+ if ($entity->getLinkCategory()){
635
+ $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_category';
636
+ $lines[] = 'DROP TABLE '.$tableName.';';
637
+ }
638
+ if ($entity->getStore()){
639
+ $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_store';
640
+ $lines[] = 'DROP TABLE '.$tableName.';';
641
+ }
642
+ if ($entity->getIsEav()){
643
+ foreach (array('int', 'decimal','datetime', 'varchar', 'text') as $type){
644
+ $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_'.$type;
645
+ $lines[] = 'DROP TABLE '.$tableName.';';
646
+ }
647
+ }
648
+ $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}');
649
+ $lines[] = 'DROP TABLE '.$tableName.';';
650
+ }
651
+ if ($this->getHasEav()){
652
+ $tableName = $namespace.'_'.$module.'_eav_attribute';
653
+ $lines[] = 'DROP TABLE '.$tableName.';';
654
+ }
655
+ $lines[] = "DELETE FROM core_resource WHERE code = '".$namespace.'_'.$module."_setup';";
656
+ $lines[] = "DELETE FROM core_config_data WHERE path like '".$namespace.'_'.$module."/%';";
657
+ $text = implode(Mage::helper('modulecreator')->getEol(), $lines);
658
+ $this->_writeFile($this->getUninstallPath(),$text);
659
+ return $this;
660
+ }
661
+ /**
662
+ * check if some files already exist so it won't be overwritten
663
+ * @access protected
664
+ * @return array()
665
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
666
+ */
667
+ protected function _checkExistingFiles(){
668
+ $existingFiles = array();
669
+ $io = $this->getIo();
670
+ $basePath = $this->getBasePath();
671
+ foreach ($this->_files as $name=>$content){
672
+ if ($io->fileExists($basePath.$name)){
673
+ $existingFiles[] = $basePath.$name;
674
+ }
675
+ }
676
+ return $existingFiles;
677
+ }
678
+
679
+ /**
680
+ * get path for log file
681
+ * @access public
682
+ * @return string
683
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
684
+ */
685
+ public function getLogPath(){
686
+ return Mage::helper('modulecreator')->getLocalPackagesPath().$this->getExtensionName().'/files.log';
687
+ }
688
+ /**
689
+ * get path for uninstall sql file
690
+ * @access public
691
+ * @return string
692
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
693
+ */
694
+ public function getUninstallPath(){
695
+ return Mage::helper('modulecreator')->getLocalPackagesPath().$this->getExtensionName().'/uninstall.sql';
696
+ }
697
+
698
+ /**
699
+ * get module base path
700
+ * @access public
701
+ * @return string
702
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
703
+ */
704
+ public function getBasePath(){
705
+ if (!$this->getInstall()){
706
+ return Mage::getBaseDir('var').DS.'modulecreator'.DS.$this->getExtensionName().DS;
707
+ }
708
+ return Mage::getBaseDir().DS;
709
+ }
710
+ /**
711
+ * get relative path ro the module
712
+ * @access public
713
+ * @return string
714
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
715
+ */
716
+ public function getRelativeBasePath(){
717
+ $basePath = $this->getBasePath();
718
+ $remove = Mage::getBaseDir().DS;
719
+ $relativePath = substr($basePath, strlen($remove));
720
+ return $relativePath;
721
+ }
722
+ /**
723
+ * get the module config
724
+ * @access public
725
+ * @return Varien_Simplexml_Element
726
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
727
+ */
728
+ public function getConfig(){
729
+ if (is_null($this->_config)){
730
+ $this->_config = Mage::getConfig()->loadModulesConfiguration('umc_source.xml')->applyExtends();
731
+ }
732
+ return $this->_config;
733
+ }
734
+ /**
735
+ * get contents of a file
736
+ * @access public
737
+ * @param string $file
738
+ * @return string
739
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
740
+ */
741
+ public function getFileContents($file){
742
+ return file_get_contents($file);
743
+ }
744
+
745
+ /**
746
+ * create a file
747
+ * @access protected
748
+ * @param Varien_Simplexml_Element
749
+ * @return Ultimate_ModuleCreator_Model_Module
750
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
751
+ */
752
+ protected function _createFile($config){
753
+ switch ($config->scope){
754
+ case 'entity' :
755
+ $this->_buildEntityFile($config);
756
+ break;
757
+ case 'siblings':
758
+ $this->_buildSiblingFile($config);
759
+ break;
760
+ case 'children' :
761
+ $this->_buildChildrenFile($config);
762
+ break;
763
+ case 'attribute' :
764
+ $this->_buildAttributeFile($config);
765
+ break;
766
+ case 'global':
767
+ default:
768
+ $this->_buildGlobalFile($config);
769
+ break;
770
+ }
771
+ return $this;
772
+ }
773
+
774
+ /**
775
+ * validate xml condition
776
+ * @access protected
777
+ * @param $entity
778
+ * @param $conditions
779
+ * @return bool
780
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
781
+ */
782
+ protected function _validateDepend($entity, $conditions, $params = null){
783
+ if (!$conditions){
784
+ return true;
785
+ }
786
+ if (!is_array($conditions)){
787
+ $conditions = $conditions->asArray();
788
+ }
789
+ foreach ($conditions as $condition=>$value){
790
+ if (!$entity->getDataUsingMethod($condition, $params)){
791
+ return false;
792
+ }
793
+ }
794
+ return true;
795
+ }
796
+
797
+ /** create a file with global scope
798
+ * @access protected
799
+ * @param Varien_Simplexml_Element
800
+ * @return Ultimate_ModuleCreator_Model_Module
801
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
802
+ */
803
+ public function _buildGlobalFile($config) {
804
+ $filetype = $config->filetype;
805
+ $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->source, $filetype);
806
+ $destination = $this->_filterString((string)$config->destination, $filetype);
807
+ $content = '';
808
+ $depend = $config->depend;
809
+ if (!$this->_validateDepend($this, $depend)){
810
+ return '';
811
+ }
812
+ if ($config->method){
813
+ $method = (string)$config->method;
814
+ $content = $this->$method();
815
+ }
816
+ else{
817
+ $code = $this->_sortCodeFiles((array)$config->code);
818
+ foreach ($code as $key => $file){
819
+ $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name);
820
+ $scope = (string)$file->scope;
821
+ $depend = $file->depend;
822
+ $scope = $file->scope;
823
+ if ($scope == 'entity'){
824
+ foreach ($this->getEntities() as $entity){
825
+ if ($this->_validateDepend($entity, $depend)){
826
+ $replace = $entity->getPlaceholders();
827
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
828
+ }
829
+ }
830
+ }
831
+ elseif($scope == 'attribute'){
832
+ $depend = $file->depend;
833
+ $dependType = $file->depend_type;
834
+ foreach ($this->getEntities() as $entity){
835
+ foreach ($entity->getAttributes() as $attribute){
836
+ $valid = $this->_validateDepend($attribute, $depend);
837
+ $typeValid = true;
838
+ if ($dependType){
839
+ $typeValid = false;
840
+ foreach ($dependType->asArray() as $condition=>$value){
841
+ if ($attribute->getType() == $condition){
842
+ $typeValid = true;
843
+ break;
844
+ }
845
+ }
846
+ }
847
+ if ($valid && $typeValid){
848
+ $replace = $entity->getPlaceholders();
849
+ $attributeReplace = $attribute->getPlaceholders();
850
+ $replace = array_merge($replace, $attributeReplace);
851
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
852
+ }
853
+ }
854
+ }
855
+ }
856
+ elseif($scope == 'siblings'){
857
+ foreach ($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $relation){
858
+ $entities = $relation->getEntities();
859
+ $replaceEntity = $entities[0]->getPlaceholders();
860
+ $replaceSibling = $entities[1]->getPlaceholdersAsSibling();
861
+ $replace = array_merge($replaceEntity, $replaceSibling);
862
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
863
+ }
864
+ }
865
+ elseif($scope == 'siblings_both_tree'){
866
+ foreach ($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $relation){
867
+ $entities = $relation->getEntities();
868
+ if ($entities[0]->getIsTree() || $entities[1]->getIsTree()){
869
+ if ($entities[0]->getIsTree()){
870
+ $tree = $entities[0];
871
+ $sibling = $entities[1];
872
+ }
873
+ else{
874
+ $tree = $entities[1];
875
+ $sibling = $entities[0];
876
+ }
877
+ $replaceEntity = $tree->getPlaceholders();
878
+ $replaceSibling = $sibling->getPlaceholdersAsSibling();
879
+ $replace = array_merge($replaceEntity, $replaceSibling);
880
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
881
+ }
882
+ }
883
+ }
884
+ elseif($scope == 'siblings_both_not_tree'){
885
+ foreach ($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $relation){
886
+ $entities = $relation->getEntities();
887
+ if ($entities[0]->getIsTree() || $entities[1]->getIsTree()){
888
+ continue;
889
+ }
890
+ $replaceEntity = $entities[0]->getPlaceholders();
891
+ $replaceSibling = $entities[1]->getPlaceholdersAsSibling();
892
+ $replace = array_merge($replaceEntity, $replaceSibling);
893
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
894
+
895
+ $replaceEntity = $entities[1]->getPlaceholders();
896
+ $replaceSibling = $entities[0]->getPlaceholdersAsSibling();
897
+ $replace = array_merge($replaceEntity, $replaceSibling);
898
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
899
+ }
900
+ }
901
+ elseif ($scope == 'children'){
902
+ foreach ($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD) as $relation){
903
+ $entities = $relation->getEntities();
904
+ $replaceEntity = $entities[0]->getPlaceholders();
905
+ $replaceSibling = $entities[1]->getPlaceholdersAsSibling();
906
+ $replace = array_merge($replaceEntity, $replaceSibling);
907
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
908
+ }
909
+ foreach ($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT) as $relation){
910
+ $entities = $relation->getEntities();
911
+ $replaceEntity = $entities[1]->getPlaceholders();
912
+ $replaceSibling = $entities[0]->getPlaceholdersAsSibling();
913
+ $replace = array_merge($replaceEntity, $replaceSibling);
914
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
915
+ }
916
+ }
917
+ else{
918
+ if ($this->_validateDepend($this, $depend)){
919
+ $content .= $this->_filterString($sourceContent, $filetype);
920
+ }
921
+ }
922
+ }
923
+ }
924
+ if ($config->after_build){
925
+ $function = (string)$config->after_build;
926
+ $content = $this->$function($content);
927
+ }
928
+
929
+ $content = $this->_filterString($content, $config->type);
930
+ $this->_addFile($destination, $content);
931
+ return $this;
932
+ }
933
+
934
+ public function _buildEntityFile($config) {
935
+ foreach ($this->getEntities() as $entity){
936
+ $filetype = $config->filetype;
937
+ $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->source, $filetype);
938
+ $destinationFile = $this->_filterString((string)$config->destination, $filetype, $entity->getPlaceholders(), true);
939
+ $content = '';
940
+ $depend = $config->depend;
941
+ if (!$this->_validateDepend($entity, $depend)){
942
+ continue;
943
+ }
944
+ $code = $this->_sortCodeFiles((array)$config->code);
945
+ foreach ($code as $key=>$file){
946
+ $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name);
947
+ $scope = (string)$file->scope;
948
+ $depend = $file->depend;
949
+ $dependType = $file->depend_type;
950
+ if ($scope == 'attribute'){
951
+ foreach ($entity->getAttributes() as $attribute){
952
+ $valid = $this->_validateDepend($attribute, $depend);
953
+ $typeValid = true;
954
+ if ($dependType){
955
+ $typeValid = false;
956
+ foreach ($dependType->asArray() as $condition=>$value){
957
+ if ($attribute->getType() == $condition){
958
+ $typeValid = true;
959
+ break;
960
+ }
961
+ }
962
+ }
963
+ if ($valid && $typeValid){
964
+ $replace = $entity->getPlaceholders();
965
+ $attributeReplace = $attribute->getPlaceholders();
966
+ $replace = array_merge($replace, $attributeReplace);
967
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
968
+ }
969
+ }
970
+ }
971
+ elseif($scope == 'siblings'){
972
+ foreach ($entity->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $related){
973
+ if ($this->_validateDepend($entity, $depend)){
974
+ $placeholders = $entity->getPlaceholders();
975
+ $replaceSibling = $related->getPlaceholdersAsSibling();
976
+ $replace = array_merge($placeholders, $replaceSibling);
977
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
978
+ }
979
+ }
980
+ }
981
+ elseif($scope == 'siblings_not_tree'){
982
+ foreach ($entity->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $related){
983
+ if ($related->getNotIsTree()){
984
+ $placeholders = $entity->getPlaceholders();
985
+ $replaceSibling = $related->getPlaceholdersAsSibling();
986
+ $replace = array_merge($placeholders, $replaceSibling);
987
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
988
+ }
989
+ }
990
+ }
991
+ elseif($scope == 'siblings_tree'){
992
+ foreach ($entity->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $related){
993
+ if ($related->getIsTree()){
994
+ $placeholders = $entity->getPlaceholders();
995
+ $replaceSibling = $related->getPlaceholdersAsSibling();
996
+ $replace = array_merge($placeholders, $replaceSibling);
997
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
998
+ }
999
+ }
1000
+ }
1001
+ elseif($scope == 'parents'){
1002
+ foreach ($entity->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD) as $related){
1003
+ $placeholders = $entity->getPlaceholders();
1004
+ $replaceSibling = $related->getPlaceholdersAsSibling();
1005
+ $replace = array_merge($placeholders, $replaceSibling);
1006
+ $content .= $this->_filterString($sourceContent, $filetype, $replace, true);
1007
+ }
1008
+ }
1009
+ elseif ($depend){
1010
+ if ($this->_validateDepend($entity, $depend)){
1011
+ $content .= $this->_filterString($sourceContent, $filetype, $entity->getPlaceholders(), true);
1012
+ }
1013
+ }
1014
+ else{
1015
+ $content .= $this->_filterString($sourceContent, $filetype, $entity->getPlaceholders(), true);
1016
+ }
1017
+ $this->_addFile($destinationFile, $content);
1018
+ }
1019
+ }
1020
+ return $this;
1021
+ }
1022
+
1023
+ /**
1024
+ * generate files for sibling relations
1025
+ * @access protected
1026
+ * @param $config
1027
+ * @return $this
1028
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1029
+ */
1030
+ protected function _buildSiblingFile($config) {
1031
+ foreach ($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $relation){
1032
+ $entities = $relation->getEntities();
1033
+ foreach ($entities as $index=>$entity){
1034
+ $depend = $config->depend;
1035
+ if (!$this->_validateDepend($relation, $depend, $index)){
1036
+ continue;
1037
+ }
1038
+
1039
+ $placeholders = array_merge($entities[$index]->getPlaceholders(), $entities[1 - $index]->getPlaceholdersAsSibling());
1040
+ $filetype = $config->filetype;
1041
+ $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->source, $filetype);
1042
+ $destinationFile = $this->_filterString((string)$config->destination, $filetype, $placeholders, true);
1043
+ $content = '';
1044
+ $code = $this->_sortCodeFiles((array)$config->code);
1045
+ foreach ($code as $key=>$file){
1046
+ $depend = $file->depend;
1047
+ if (!$this->_validateDepend($relation, $depend, $index)){
1048
+ continue;
1049
+ }
1050
+ $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name);
1051
+ $content .= $this->_filterString($sourceContent, $filetype, $placeholders, true);
1052
+ }
1053
+ $this->_addFile($destinationFile, $content);
1054
+ }
1055
+ }
1056
+ return $this;
1057
+ }
1058
+
1059
+ /**
1060
+ * create files for children relations
1061
+ * @access protected
1062
+ * @param Varien_Simplexml_Element
1063
+ * @return Ultimate_ModuleCreator_Model_Module
1064
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1065
+ */
1066
+ protected function _buildChildrenFile($config){
1067
+ foreach ($this->getRelations() as $relation){
1068
+ $type = $relation->getType();
1069
+ $entities = $relation->getEntities();
1070
+ $parent = false;
1071
+ $child = false;
1072
+ if ($type == Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT){
1073
+ $parent = $entities[0];
1074
+ $child = $entities[1];
1075
+ }
1076
+ elseif ($type == Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD){
1077
+ $parent = $entities[1];
1078
+ $child = $entities[0];
1079
+ }
1080
+ if ($parent && $child){
1081
+ $depend = $config->depend;
1082
+ if ($this->_validateDepend($relation, $depend)){
1083
+ $placeholders = array_merge($parent->getPlaceholders(), $child->getPlaceholdersAsSibling());
1084
+ $filetype = $config->filetype;
1085
+ $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->source, $filetype);
1086
+ $destinationFile = $this->_filterString((string)$config->destination, $filetype, $placeholders, true);
1087
+ $content = '';
1088
+ $code = $this->_sortCodeFiles((array)$config->code);
1089
+ foreach ($code as $key=>$file){
1090
+ $depend = $file->depend;
1091
+ if (!$this->_validateDepend($relation, $depend)){
1092
+ continue;
1093
+ }
1094
+ $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name);
1095
+ $content .= $this->_filterString($sourceContent, $filetype, $placeholders, true);
1096
+ }
1097
+ $this->_addFile($destinationFile, $content);
1098
+ }
1099
+ }
1100
+ }
1101
+ return $this;
1102
+ }
1103
+
1104
+ /**
1105
+ * build source file for an attribute
1106
+ * @access public
1107
+ * @param $config
1108
+ * @return Ultimate_ModuleCreator_Model_Module
1109
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1110
+ */
1111
+ protected function _buildAttributeFile($config){
1112
+ foreach ($this->getEntities() as $entity){
1113
+ foreach ($entity->getAttributes() as $attribute){
1114
+ $filetype = $config->filetype;
1115
+ $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->source, $filetype);
1116
+ $placeholders = array_merge($entity->getPlaceholders(), $attribute->getPlaceholders());
1117
+ $destinationFile = $this->_filterString((string)$config->destination, $filetype, $placeholders, true);
1118
+ $content = '';
1119
+ $depend = $config->depend;
1120
+ if (!$this->_validateDepend($attribute, $depend)){
1121
+ continue;
1122
+ }
1123
+ $code = $this->_sortCodeFiles((array)$config->code);
1124
+ foreach ($code as $key=>$file){
1125
+ $depend = $file->depend;
1126
+ if (!$this->_validateDepend($attribute, $depend)){
1127
+ continue;
1128
+ }
1129
+ $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name);
1130
+ $content .= $this->_filterString($sourceContent, $filetype, $placeholders, true);
1131
+ }
1132
+ $this->_addFile($destinationFile, $content);
1133
+ }
1134
+ }
1135
+ return $this;
1136
+ }
1137
+
1138
+ /**
1139
+ * get sample files source folder
1140
+ * @access public
1141
+ * @return string
1142
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1143
+ */
1144
+ public function getSourceFolder(){
1145
+ if (!isset($this->_sourceFolder)){
1146
+ $this->_sourceFolder = Mage::getConfig()->getModuleDir('etc', 'Ultimate_ModuleCreator').DS.'source'.DS;
1147
+ }
1148
+ return $this->_sourceFolder;
1149
+ }
1150
+ /**
1151
+ * filter placeholders
1152
+ * @access protected
1153
+ * @param string $string
1154
+ * @param string $fileType
1155
+ * @param mixed (null|array()) $replaceArray
1156
+ * @param bool $mergeReplace
1157
+ * @param bool $forLicence
1158
+ * @return string
1159
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1160
+ */
1161
+ protected function _filterString($string, $fileType, $replaceArray = null, $mergeReplace = false, $forLicence = false){
1162
+ $replace = $this->getPlaceholder();
1163
+ if (!$forLicence) {
1164
+ $replace['{{License}}'] = $this->getLicenseText($fileType);
1165
+ }
1166
+ if (!is_null($replaceArray)){
1167
+ if ($mergeReplace){
1168
+ $replace = array_merge($replace, $replaceArray);
1169
+ }
1170
+ else{
1171
+ $replace = $replaceArray;
1172
+ }
1173
+ }
1174
+ return str_replace(array_keys($replace), array_values($replace), $string);
1175
+ }
1176
+ /**
1177
+ * add file to create list
1178
+ * @access protected
1179
+ * @param $destinationFile
1180
+ * @param $content
1181
+ * @return $this
1182
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1183
+ */
1184
+ protected function _addFile($destinationFile, $content){
1185
+ if (trim($content)){
1186
+ $this->_files[$destinationFile] = $content;
1187
+ }
1188
+ return $this;
1189
+ }
1190
+ /**
1191
+ * get text for licence
1192
+ * @access public
1193
+ * @param string $fileType
1194
+ * @return string
1195
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1196
+ */
1197
+ public function getLicenseText($fileType){
1198
+ if (!$this->getData('processed_license_'.$fileType)){
1199
+ $eol = $this->getEol();
1200
+ $license = trim($this->getData('license'));
1201
+ if (!$license){
1202
+ return '';
1203
+ }
1204
+ while(strpos($license, '*/') !== false){
1205
+ $license = str_replace('*/', '', $license);
1206
+ }
1207
+ while(strpos($license, '/*') !== false){
1208
+ $license = str_replace('/*', '', $license);
1209
+ }
1210
+ while(strpos($license, '<!--') !== false){
1211
+ $license = str_replace('<!--', '', $license);
1212
+ }
1213
+ while(strpos($license, '-->') !== false){
1214
+ $license = str_replace('-->', '', $license);
1215
+ }
1216
+ $lines = explode("\n", $license);
1217
+ $top = '';
1218
+ $footer = '';
1219
+ if ($fileType == 'xml'){
1220
+ $top = '<!--'.$eol;
1221
+ $footer = $eol.'-->';
1222
+ }
1223
+ $processed = $top.'/**'.$eol;
1224
+ foreach ($lines as $line){
1225
+ $processed .= ' * '.$line.$eol;
1226
+ }
1227
+ $processed .= ' */'.$footer;
1228
+ $this->setData('processed_license_'.$fileType, $this->_filterString($processed, $fileType, array(), true, true));
1229
+ }
1230
+ return $this->getData('processed_license_'.$fileType);
1231
+ }
1232
+ /**
1233
+ * get all placeholders
1234
+ * @access public
1235
+ * @param null $param
1236
+ * @return array|null|string
1237
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1238
+ */
1239
+ public function getPlaceholder($param = null){
1240
+ if (is_null($this->_placeholders)){
1241
+ $this->_placeholders = array(
1242
+ '{{DS}}' => DS,
1243
+ '{{namespace}}' => $this->getNamespace(true),
1244
+ '{{sort_order}}' => (int)$this->getSortOrder(),
1245
+ '{{module}}' => strtolower($this->getModuleName()),
1246
+ '{{Namespace}}' => $this->getNamespace(),
1247
+ '{{Module}}' => $this->getModuleName(),
1248
+ '{{NAMESPACE}}' => strtoupper($this->getNamespace()),
1249
+ '{{MODULE}}' => strtoupper($this->getModuleName()),
1250
+ '{{qwertyuiop}}' => $this->getQwertyuiop(),
1251
+ '{{qwertyuiopp}}' => $this->getQwertyuiopp(),
1252
+ '{{Y}}' => date('Y'),
1253
+ '{{entity_default_config}}' => $this->getEntityDefaultConfig(),
1254
+ '{{module_menu}}' => $this->getMenuText(),
1255
+ '{{codepool}}' => $this->getCodepool(),
1256
+ '{{version}}' => $this->getVersion(),
1257
+ '{{menuItemsXml}}' => $this->getMenuItemsXml(),
1258
+ '{{menuAcl}}' => $this->getMenuAcl(),
1259
+ '{{ModuleFolder}}' => ucfirst(strtolower($this->getModuleName())),
1260
+ '{{ResourceSetup}}' => $this->getResourceSetupModel(),
1261
+ '{{depends}}' => $this->getDepends(),
1262
+ '{{productViewLayout}}' => $this->getProductViewLayout(),
1263
+ '{{categoryViewLayout}}' => $this->getCategoryViewLayout(),
1264
+ '{{defaultLayoutHandle}}' => $this->getFrontendDefaultLayoutHandle(),
1265
+ '{{categoryMenuEvent}}' => $this->getCategoryMenuEvent(),
1266
+ '{{customerCommentLinks}}' => $this->getCustomerCommentLinks(),
1267
+ '{{frontKey}}' => $this->getFrontKey(),
1268
+ '{{SystemTabName}}' => $this->getSystemTabName(),
1269
+ '{{systemTabPosition}}' => $this->getSystemTabPosition()
1270
+ );
1271
+ }
1272
+ if (is_null($param)){
1273
+ return $this->_placeholders;
1274
+ }
1275
+ if (isset($this->_placeholders[$param])){
1276
+ return $this->_placeholders[$param];
1277
+ }
1278
+ return '';
1279
+ }
1280
+ /**
1281
+ * get config.xml default section
1282
+ * @access public
1283
+ * @return string
1284
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1285
+ */
1286
+ public function getEntityDefaultConfig(){
1287
+ $eol = $this->getEol();
1288
+ $text = '';
1289
+ if ($this->getCreateFrontend()) {
1290
+ $text = $eol.$this->getPadding().'<default>'.$eol;
1291
+ $text.= $this->getPadding(2).'<'.strtolower($this->getModuleName()).'>'.$eol;
1292
+ foreach ($this->getEntities() as $entity){
1293
+ $text .= $this->getPadding(3).$entity->getDefaultConfig();
1294
+ }
1295
+ $text.= $this->getPadding(2).'</'.strtolower($this->getModuleName()).'>'.$eol;
1296
+ $text.= $this->getPadding().'</default>';
1297
+ }
1298
+ return $text;
1299
+ }
1300
+
1301
+ /**
1302
+ * check if module related to catalog
1303
+ * @access public
1304
+ * @return bool
1305
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1306
+ */
1307
+ public function getHasCatalogRelation(){
1308
+ return $this->getLinkProduct() || $this->getLinkCategory();
1309
+ }
1310
+
1311
+ /**
1312
+ * get menu for entities
1313
+ * @access public
1314
+ * @param $padding
1315
+ * @return string
1316
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1317
+ */
1318
+ public function getEntityMenu($padding){
1319
+ $text = '';
1320
+ foreach ($this->getEntities() as $entity){
1321
+ $text .= $entity->getMenu($padding);
1322
+ }
1323
+ return $text;
1324
+ }
1325
+ /**
1326
+ * get menu ACL for entities
1327
+ * @access public
1328
+ * @param $padding
1329
+ * @return string
1330
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1331
+ */
1332
+ public function getEntityMenuAcl($padding){
1333
+ $text = '';
1334
+ foreach ($this->getEntities() as $entity){
1335
+ $text .= $entity->getMenuAcl($padding);
1336
+ }
1337
+ return $text;
1338
+ }
1339
+
1340
+ /**
1341
+ * sort source code files
1342
+ * @access protected
1343
+ * @param $files
1344
+ * @param string $sortField
1345
+ * @return array
1346
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1347
+ */
1348
+ protected function _sortCodeFiles($files, $sortField = 'sort_order'){
1349
+ $sorted = array();
1350
+ foreach ($files as $key=> $values){
1351
+ $sorted[(int)$values->$sortField][] = $values;
1352
+ }
1353
+ ksort($sorted);
1354
+ $return = array();
1355
+ foreach ($sorted as $sort_order=>$values){
1356
+ foreach ($values as $file){
1357
+ $return[] = $file;
1358
+ }
1359
+ }
1360
+ return $return;
1361
+ }
1362
+
1363
+ /**
1364
+ * get module name in lower case
1365
+ * @access public
1366
+ * @return string
1367
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1368
+ */
1369
+ public function getLowerModuleName(){
1370
+ return strtolower($this->getModuleName());
1371
+ }
1372
+
1373
+ /**
1374
+ * get menu items xml
1375
+ * @access public
1376
+ * @return string
1377
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1378
+ */
1379
+ public function getMenuItemsXml(){
1380
+ $xml = '';
1381
+ $parts = array();
1382
+ $padding = 2;
1383
+ $namespace = $this->getNamespace(true);
1384
+ $eol = $this->getEol();
1385
+ if ($this->getMenuParent()){
1386
+ $parts = explode('/', $this->getMenuParent());
1387
+ }
1388
+ foreach ($parts as $part){
1389
+ $xml .= $this->getPadding($padding++).'<'.$part.'>'.$eol;
1390
+ $xml .= $this->getPadding($padding++).'<children>'.$eol;
1391
+ }
1392
+ $xml .= $this->getPadding($padding++).'<'.$namespace.'_'.$this->getLowerModuleName().' translate="title" module="'.$namespace.'_'.$this->getLowerModuleName().'">'.$eol;
1393
+ $xml .= $this->getPadding($padding).'<title>'.$this->getMenuText().'</title>'.$eol;
1394
+ $xml .= $this->getPadding($padding).'<sort_order>'.$this->getSortOrder().'</sort_order>'.$eol;
1395
+ $xml .= $this->getPadding($padding++).'<children>'.$eol;
1396
+ $xml .= $this->getEntityMenu($padding);
1397
+ $xml .= $this->getPadding(--$padding).'</children>'.$eol;
1398
+ $xml .= $this->getPadding(--$padding).'</'.$namespace.'_'.$this->getLowerModuleName().'>'.$eol;
1399
+
1400
+ $parts = array_reverse($parts);
1401
+ foreach ($parts as $part){
1402
+ $xml .= $this->getPadding(--$padding).'</children>'.$eol;
1403
+ $xml .= $this->getPadding(--$padding).'</'.$part.'>'.$eol;
1404
+ }
1405
+ return $xml;
1406
+ }
1407
+
1408
+ /**
1409
+ * get menu ACL
1410
+ * @access public
1411
+ * @return string
1412
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1413
+ */
1414
+ public function getMenuAcl(){
1415
+ $xml = '';
1416
+ $parts = array();
1417
+ $padding = 5;
1418
+ $eol = $this->getEol();
1419
+ $namespace = $this->getNamespace(true);
1420
+ if ($this->getMenuParent()){
1421
+ $parts = explode('/', $this->getMenuParent());
1422
+ }
1423
+ foreach ($parts as $part){
1424
+ $xml .= $this->getPadding($padding++).'<'.$part.'>'.$eol;
1425
+ $xml .= $this->getPadding($padding++).'<children>'.$eol;
1426
+ }
1427
+ $xml .= $this->getPadding($padding++).'<'.$namespace.'_'.$this->getLowerModuleName().' translate="title" module="'.$namespace.'_'.$this->getLowerModuleName().'">'.$eol;
1428
+ $xml .= $this->getPadding($padding++).'<title>'.$this->getMenuText().'</title>'.$eol;
1429
+ $xml .= $this->getPadding($padding++).'<children>'.$eol;
1430
+ $xml .= $this->getEntityMenuAcl($padding);
1431
+ $xml .= $this->getPadding(--$padding).'</children>'.$eol;
1432
+ $xml .= $this->getPadding(--$padding).'</'.$namespace.'_'.$this->getLowerModuleName().'>'.$eol;
1433
+
1434
+ $parts = array_reverse($parts);
1435
+ foreach ($parts as $part){
1436
+ $xml .= $this->getPadding(--$padding).'</children>'.$eol;
1437
+ $xml .= $this->getPadding(--$padding).'</'.$part.'>'.$eol;
1438
+ }
1439
+ return $xml;
1440
+ }
1441
+
1442
+ /**
1443
+ * get resource setup base class
1444
+ * @access public
1445
+ * @return string
1446
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1447
+ */
1448
+ public function getResourceSetupModel(){
1449
+ if ($this->getHasCatalogRelation() || $this->getHasEav()){
1450
+ return 'Mage_Catalog_Model_Resource_Setup';
1451
+ }
1452
+ return 'Mage_Core_Model_Resource_Setup';
1453
+ }
1454
+ /**
1455
+ * sort the translation file
1456
+ * @access protected
1457
+ * @param string $content
1458
+ * @return string
1459
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1460
+ */
1461
+ protected function _sortTranslationFile($content){
1462
+ $lines = explode($this->getEol(), $content);
1463
+ $distinct = array();
1464
+ foreach ($lines as $line){
1465
+ if (trim($line)){
1466
+ $distinct[$line] = 1;
1467
+ }
1468
+ }
1469
+ //remove blank line
1470
+ if (isset($distinct['"",""'])){
1471
+ unset($distinct['"",""']);
1472
+ }
1473
+ ksort($distinct);
1474
+ $content = implode($this->getEol(), array_keys($distinct));
1475
+ return $content;
1476
+ }
1477
+
1478
+ /**
1479
+ * this does nothing
1480
+ * don't look through the code - go away
1481
+ * I said it does nothing
1482
+ * @access public
1483
+ * @return string
1484
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1485
+ */
1486
+ public function getQwertyuiop(){
1487
+ return $this->getHelper()->getQwertyuiop();
1488
+ }
1489
+ /**
1490
+ * this also does nothing
1491
+ * don't look here either
1492
+ * @access public
1493
+ * @return string
1494
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1495
+ */
1496
+ public function getQwertyuiopp(){
1497
+ return $this->getHelper()->getQwertyuiopp();
1498
+ }
1499
+ /**
1500
+ * check module dependency
1501
+ * @access public
1502
+ * @return array
1503
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1504
+ */
1505
+ public function getDepends() {
1506
+ if (!$this->hasData('_depends')){
1507
+ $dependency = array('<Mage_Core />'=>1);
1508
+ if ($this->getLinkCore() || $this->getHasEav()){
1509
+ $dependency['<Mage_Catalog />'] = 1;
1510
+ }
1511
+ $eol = $this->getEol();
1512
+ $padding = $this->getPadding(4);
1513
+ $depends = '';
1514
+ foreach ($dependency as $key=>$value){
1515
+ $depends = $padding.$key.$eol;
1516
+ }
1517
+ $this->setData('_depends', $depends);
1518
+ }
1519
+ return $this->getData('_depends');
1520
+ }
1521
+
1522
+ /**
1523
+ * get layout for product view page
1524
+ * @access public
1525
+ * @return string
1526
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1527
+ */
1528
+ public function getProductViewLayout() {
1529
+ $content = '';
1530
+ $padding = $this->getPadding(3);
1531
+ $eol = $this->getEol();
1532
+ $tab = $this->getPadding();
1533
+ $ns = $this->getNamespace(true);
1534
+ $module = $this->getLowerModuleName();
1535
+ foreach ($this->getEntities() as $entity) {
1536
+ $name = strtolower($entity->getNameSingular());
1537
+ $names = strtolower($entity->getNamePlural());
1538
+ $label = $entity->getLabelPlural();
1539
+ if ($entity->getShowOnProduct()) {
1540
+ $content .= $padding.'<block type="'.$ns.'_'.$module.'/catalog_product_list_'.$name.'" name="product.info.'.$names.'" as="product_'.$names.'" template="'.$ns.'_'.$module.'/catalog/product/list/'.$name.'.phtml">'.$eol;
1541
+ $content .= $padding.$tab.'<action method="addToParentGroup"><group>detailed_info</group></action>'.$eol;
1542
+ $content .= $padding.$tab.'<action method="setTitle" translate="value" module="'.$ns.'_'.$module.'"><value>'.$label.'</value></action>'.$eol;
1543
+ $content .= $padding.'</block>'.$eol;
1544
+ }
1545
+ }
1546
+ return $content;
1547
+ }
1548
+ /**
1549
+ * get layout for category view page
1550
+ * @access public
1551
+ * @return string
1552
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1553
+ */
1554
+ public function getCategoryViewLayout() {
1555
+ $content = '';
1556
+ $padding = $this->getPadding(3);
1557
+ $eol = $this->getEol();
1558
+ $ns = $this->getNamespace(true);
1559
+ $module = $this->getLowerModuleName();
1560
+ foreach ($this->getEntities() as $entity) {
1561
+ $name = $entity->getNameSingular(true);
1562
+ $names = $entity->getNamePlural(true);
1563
+ $label = $entity->getLabelPlural();
1564
+ if ($entity->getShowOnProduct()) {
1565
+ $content .= $padding.'<block type="'.$ns.'_'.$module.'/catalog_category_list_'.$name.'" name="category.info.'.$names.'" as="category_'.$names.'" template="'.$ns.'_'.$module.'/catalog/category/list/'.$name.'.phtml" after="-" />'.$eol;
1566
+ }
1567
+ }
1568
+ return $content;
1569
+ }
1570
+
1571
+ /**
1572
+ * get default layout handle
1573
+ * @access public
1574
+ * @return string
1575
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1576
+ */
1577
+ public function getFrontendDefaultLayoutHandle() {
1578
+ $padding = $this->getPadding(1);
1579
+ $tab = $this->getPadding();
1580
+ $eol = $this->getEol();
1581
+ $top = array();
1582
+ $footer = array();
1583
+ $content = $eol.$padding;
1584
+ $namespace = $this->getNamespace(true);
1585
+ $tree = false;
1586
+ if ($this->getCreateFrontend()) {
1587
+ foreach ($this->getEntities() as $entity) {
1588
+ if ($entity->getCreateList()) {
1589
+ if ($entity->getListMenu() == Ultimate_ModuleCreator_Model_Source_Entity_Menu::TOP_LINKS) {
1590
+ $top[] = $entity;
1591
+ }
1592
+ elseif ($entity->getListMenu() == Ultimate_ModuleCreator_Model_Source_Entity_Menu::FOOTER_LINKS) {
1593
+ $footer[] = $entity;
1594
+ }
1595
+ if ($entity->getIsTree()) {
1596
+ $tree = true;
1597
+ }
1598
+ }
1599
+ }
1600
+ }
1601
+ if (count($top) > 0 || count($footer) > 0 || $tree) {
1602
+ $content .= '<default>'.$eol;
1603
+ if ($tree) {
1604
+ $content .= $padding.'<reference name="head">'.$eol;
1605
+ $content .= $padding.$tab.'<action method="addCss"><js>css/'.$this->getNamespace(true).'_'.$this->getLowerModuleName().'/tree.css</js></action>'.$eol;
1606
+ $content .= $padding.'</reference>'.$eol;
1607
+ }
1608
+ if (count($top) > 0) {
1609
+ $content .= $padding.$tab.'<reference name="top.links">'.$eol;
1610
+ $position = 120;
1611
+ foreach ($top as $entity) {
1612
+ $content .= $padding.$tab.$tab.'<action method="addLink" translate="label title" module="'.$namespace.'_'.$this->getLowerModuleName().'">'.$eol;
1613
+ $content .= $padding.$tab.$tab.$tab.'<label>'.$entity->getLabelPlural().'</label>'.$eol;
1614
+ $content .= $padding.$tab.$tab.$tab.'<url helper="'.$namespace.'_'.$this->getLowerModuleName().'/'.strtolower($entity->getNameSingular()).'/get'.ucfirst(strtolower($entity->getNamePlural())).'Url" />'.$eol;
1615
+ $content .= $padding.$tab.$tab.$tab.'<title>'.$entity->getLabelPlural().'</title>'.$eol;
1616
+ $content .= $padding.$tab.$tab.$tab.'<prepare />'.$eol;
1617
+ $content .= $padding.$tab.$tab.$tab.'<urlParams/>'.$eol;
1618
+ $content .= $padding.$tab.$tab.$tab.'<position>'.$position.'</position>'.$eol;
1619
+ $content .= $padding.$tab.$tab.'</action>'.$eol;
1620
+ $position += 10;
1621
+ }
1622
+ $content .= $padding.$tab.'</reference>'.$eol;
1623
+ }
1624
+ if (count($footer) > 0) {
1625
+ $content .= $padding.$tab.'<reference name="footer_links">'.$eol;
1626
+ $position = 120;
1627
+ foreach ($footer as $entity) {
1628
+ $content .= $padding.$tab.$tab.'<action method="addLink" translate="label title" module="'.$namespace.'_'.$this->getLowerModuleName().'">'.$eol;
1629
+ $content .= $padding.$tab.$tab.$tab.'<label>'.$entity->getLabelPlural().'</label>'.$eol;
1630
+ $content .= $padding.$tab.$tab.$tab.'<url helper="'.$namespace.'_'.$this->getLowerModuleName().'/'.strtolower($entity->getNameSingular()).'/get'.ucfirst(strtolower($entity->getNamePlural())).'Url" />'.$eol;
1631
+ $content .= $padding.$tab.$tab.$tab.'<title>'.$entity->getLabelPlural().'</title>'.$eol;
1632
+ $content .= $padding.$tab.$tab.$tab.'<prepare />'.$eol;
1633
+ $content .= $padding.$tab.$tab.$tab.'<urlParams/>'.$eol;
1634
+ $content .= $padding.$tab.$tab.$tab.'<position>'.$position.'</position>'.$eol;
1635
+ $content .= $padding.$tab.$tab.'</action>'.$eol;
1636
+ $position += 10;
1637
+ }
1638
+ $content .= $padding.$tab.'</reference>'.$eol;
1639
+ }
1640
+ $content .= $padding.'</default>';
1641
+ }
1642
+ return $content;
1643
+ }
1644
+
1645
+ /**
1646
+ * get xml for category menu event
1647
+ * @access public
1648
+ * @return string
1649
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1650
+ */
1651
+ public function getCategoryMenuEvent() {
1652
+ if ($this->getShowInCategoryMenu()) {
1653
+ $namespace = $this->getNamespace(true);
1654
+
1655
+ $eol = $this->getEol();
1656
+ $padding = $this->getPadding(2);
1657
+ $tab = $this->getPadding();
1658
+ $content = $eol;
1659
+ $content .= $padding.'<events>'.$eol;
1660
+ $content .= $padding.$tab.'<page_block_html_topmenu_gethtml_before>'.$eol;
1661
+ $content .= $padding.$tab.$tab.'<observers>'.$eol;
1662
+ $content .= $padding.$tab.$tab.$tab.'<'.$namespace.'_'.$this->getLowerModuleName().'>'.$eol;
1663
+ $content .= $padding.$tab.$tab.$tab.$tab.'<class>'.$namespace.'_'.$this->getLowerModuleName().'/observer</class>'.$eol;
1664
+ $content .= $padding.$tab.$tab.$tab.$tab.'<method>addItemsToTopmenuItems</method>'.$eol;
1665
+ $content .= $padding.$tab.$tab.$tab.'</'.$namespace.'_'.$this->getLowerModuleName().'>'.$eol;
1666
+ $content .= $padding.$tab.$tab.'</observers>'.$eol;
1667
+ $content .= $padding.$tab.'</page_block_html_topmenu_gethtml_before>'.$eol;
1668
+ $content .= $padding.'</events>'.$eol;
1669
+ return $content;
1670
+ }
1671
+ return '';
1672
+ }
1673
+ /**
1674
+ * get customer comment links
1675
+ * @access public
1676
+ * @return string
1677
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1678
+ */
1679
+ public function getCustomerCommentLinks() {
1680
+ $namespace = $this->getNamespace(true);
1681
+ $eol = $this->getEol();
1682
+ $padding = $this->getPadding(3);
1683
+ $content = $eol;
1684
+ $module = $this->getLowerModuleName();
1685
+ foreach ($this->getEntities() as $entity) {
1686
+ if ($entity->getAllowComment()) {
1687
+ $entityName = $entity->getNameSingular(true);
1688
+ $label = $entity->getLabelPlural();
1689
+ $content .= $padding . '<action method="addLink" translate="label" module="'.$namespace.'_'.$module.'"><name>'.$entityName.'_comments</name><path>'.$namespace.'_'.$module.'/'.$entityName.'_customer_comment</path><label>'.$label.' Comments</label></action>'.$eol;
1690
+ }
1691
+ }
1692
+ return $content;
1693
+ }
1694
+
1695
+ /**
1696
+ * get the module namespace
1697
+ * @access public
1698
+ * @param bool $lower
1699
+ * @return mixed|string
1700
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1701
+ */
1702
+ public function getNamespace($lower = false){
1703
+ $namespace = $this->getData('namespace');
1704
+ if ($lower){
1705
+ $namespace = strtolower($namespace);
1706
+ }
1707
+ return $namespace;
1708
+ }
1709
+
1710
+ /**
1711
+ * get front key
1712
+ * @access public
1713
+ * @return mixed
1714
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1715
+ */
1716
+ public function getFrontKey() {
1717
+ if (!$this->getCreateFrontend()) {
1718
+ return $this->getData('front_key');
1719
+ }
1720
+ if (!$this->getData('front_key')) {
1721
+ $frontKey = $this->getNamespace(true).'_'.$this->getLowerModuleName();
1722
+ $this->setData('front_key', $frontKey);
1723
+ }
1724
+ return $this->getData('front_key');
1725
+ }
1726
+
1727
+ /**
1728
+ * system configuration tab name
1729
+ * @access public
1730
+ * @return string
1731
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1732
+ */
1733
+ public function getSystemTabName(){
1734
+ if (!$this->getData('system_tab')){
1735
+ $this->setData('system_tab', $this->getNamespace());
1736
+ }
1737
+ return $this->getData('system_tab');
1738
+ }
1739
+ /**
1740
+ * system configuration tab position
1741
+ * @access public
1742
+ * @return string
1743
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
1744
+ */
1745
+ public function getSystemTabPosition(){
1746
+ return (int)$this->getData('system_tab_position');
1747
+ }
1748
+ }
app/code/community/Ultimate/ModuleCreator/Model/Module/Collection.php CHANGED
@@ -9,87 +9,87 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
 
16
  */
17
  /**
18
  * module collection
19
  *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
  */
24
- class Ultimate_ModuleCreator_Model_Module_Collection extends Varien_Data_Collection_Filesystem{
25
- /**
26
- * Files and folders regexsp
27
- *
28
- * @var string
29
- */
30
- protected $_allowedDirsMask = '/^[a-z0-9\.\-]+$/i';
31
- protected $_allowedFilesMask= '/^[a-z0-9\.\-\_]+\.(xml|ser)$/i';
32
- protected $_disallowedFilesMask = '/^package\.xml$/i';
33
 
34
- /**
35
- * Base dir where packages are located
36
- *
37
- * @var string
38
- */
39
- protected $_baseDir = '';
40
 
41
- /**
42
- * Set base dir
43
- * @access public
44
- * @return void
45
- * @author Marius Strajeru <marius.strajeru@gmail.com>
46
- */
47
- public function __construct(){
48
- $this->_baseDir = Mage::getBaseDir('var') . DS . 'modulecreator'.DS.'package';
49
- $io = new Varien_Io_File();
50
- $io->setAllowCreateFolders(true)->createDestinationDir($this->_baseDir);
51
- $this->addTargetDir($this->_baseDir);
52
- }
53
 
54
- /**
55
- * Row generator
56
- * @access public
57
- * @param string $filename
58
- * @return array
59
- * @author Marius Strajeru <marius.strajeru@gmail.com>
60
- */
61
- protected function _generateRow($filename){
62
- $row = parent::_generateRow($filename);
63
- $row['package'] = preg_replace('/\.(xml|ser)$/', '', str_replace($this->_baseDir . DS, '', $filename));
64
- $row['filename_id'] = $row['package'];
65
- $row['safe_id'] = strtr(base64_encode($row['package']), '+/=', '-_,');
66
- $folder = explode(DS, $row['package']);
67
- $row['folder'] = DS;
68
- array_pop($folder);
69
- if (!empty($folder)) {
70
- $row['folder'] = implode(DS, $folder) . DS;
71
- }
72
- return $row;
73
- }
74
 
75
- /**
76
- * Get all folders as options array
77
- * @access public
78
- * @return array
79
- * @author Marius Strajeru <marius.strajeru@gmail.com>
80
- */
81
- public function collectFolders() {
82
- $collectFiles = $this->_collectFiles;
83
- $collectDirs = $this->_collectDirs;
84
- $this->setCollectFiles(false)->setCollectDirs(true);
85
-
86
- $this->_collectRecursive($this->_baseDir);
87
- $result = array(DS => DS);
88
- foreach ($this->_collectedDirs as $dir) {
89
- $dir = str_replace($this->_baseDir . DS, '', $dir) . DS;
90
- $result[$dir] = $dir;
91
- }
92
- $this->setCollectFiles($collectFiles)->setCollectDirs($collectDirs);
93
- return $result;
94
- }
95
  }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
  */
18
  /**
19
  * module collection
20
  *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
  */
25
+ class Ultimate_ModuleCreator_Model_Module_Collection
26
+ extends Varien_Data_Collection_Filesystem {
27
+ /**
28
+ * Files and folders regexsp
29
+ * @var string
30
+ */
31
+ protected $_allowedDirsMask = '/^[a-z0-9\.\-]+$/i';
32
+ protected $_allowedFilesMask= '/^[a-z0-9\.\-\_]+\.(xml|ser)$/i';
33
+ protected $_disallowedFilesMask = '/^package\.xml$/i';
34
 
35
+ /**
36
+ * Base dir where packages are located
37
+ *
38
+ * @var string
39
+ */
40
+ protected $_baseDir = '';
41
 
42
+ /**
43
+ * Set base dir
44
+ * @access public
45
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
46
+ */
47
+ public function __construct() {
48
+ $this->_baseDir = Mage::getBaseDir('var') . DS . 'modulecreator'.DS.'package';
49
+ $io = new Varien_Io_File();
50
+ $io->setAllowCreateFolders(true)->createDestinationDir($this->_baseDir);
51
+ $this->addTargetDir($this->_baseDir);
52
+ }
 
53
 
54
+ /**
55
+ * Row generator
56
+ * @access public
57
+ * @param string $filename
58
+ * @return array
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ protected function _generateRow($filename) {
62
+ $row = parent::_generateRow($filename);
63
+ $row['package'] = preg_replace('/\.(xml|ser)$/', '', str_replace($this->_baseDir . DS, '', $filename));
64
+ $row['filename_id'] = $row['package'];
65
+ $row['safe_id'] = strtr(base64_encode($row['package']), '+/=', '-_,');
66
+ $folder = explode(DS, $row['package']);
67
+ $row['folder'] = DS;
68
+ array_pop($folder);
69
+ if (!empty($folder)) {
70
+ $row['folder'] = implode(DS, $folder) . DS;
71
+ }
72
+ return $row;
73
+ }
74
 
75
+ /**
76
+ * Get all folders as options array
77
+ * @access public
78
+ * @return array
79
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
80
+ */
81
+ public function collectFolders() {
82
+ $collectFiles = $this->_collectFiles;
83
+ $collectDirs = $this->_collectDirs;
84
+ $this->setCollectFiles(false)->setCollectDirs(true);
85
+
86
+ $this->_collectRecursive($this->_baseDir);
87
+ $result = array(DS => DS);
88
+ foreach ($this->_collectedDirs as $dir) {
89
+ $dir = str_replace($this->_baseDir . DS, '', $dir) . DS;
90
+ $result[$dir] = $dir;
91
+ }
92
+ $this->setCollectFiles($collectFiles)->setCollectDirs($collectDirs);
93
+ return $result;
94
+ }
95
  }
app/code/community/Ultimate/ModuleCreator/Model/Relation.php CHANGED
@@ -9,185 +9,203 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  class Ultimate_ModuleCreator_Model_Relation extends Ultimate_ModuleCreator_Model_Abstract{
18
- protected $_entity1;
19
- protected $_entity2;
20
- protected $_type;
21
- /**
22
- * set entities in relation
23
- * @access public
24
- * @param Ultimate_ModuleCreator_Model_Entity $entity1
25
- * @param Ultimate_ModuleCreator_Model_Entity $entity2
26
- * @param int $type
27
- * @return Ultimate_ModuleCreator_Model_Relation
28
- * @author Marius Strajeru <marius.strajeru@gmail.com>
29
- */
30
-
31
- public function setEntities(Ultimate_ModuleCreator_Model_Entity $entity1, Ultimate_ModuleCreator_Model_Entity $entity2, $type){
32
- $this->_entity1 = $entity1;
33
- $this->_entity2 = $entity2;
34
- $this->_type = $type;
35
- switch($type){
36
- case Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_NONE:
37
- break;
38
- case Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD:
39
- $this->_entity1->addRelatedEntity($type, $this->_entity2);
40
- $this->_entity2->addRelatedEntity(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_PARENT, $this->_entity1);
41
- break;
42
- case Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_PARENT:
43
- $this->_entity1->addRelatedEntity($type, $this->_entity2);
44
- $this->_entity2->addRelatedEntity(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD, $this->_entity1);
45
- break;
46
- case Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING:
47
- $this->_entity1->addRelatedEntity($type, $this->_entity2);
48
- $this->_entity2->addRelatedEntity(Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING, $this->_entity1);
49
- break;
50
- default:
51
- break;
52
- }
53
- return $this;
54
- }
55
- /**
56
- * get the relation type
57
- * @access public
58
- * @return int
59
- * @author Marius Strajeru <marius.strajeru@gmail.com>
60
- */
61
- public function getType(){
62
- return $this->_type;
63
- }
64
- /**
65
- * get relation entities
66
- * @access public
67
- * @return array
68
- * @author Marius Strajeru <marius.strajeru@gmail.com>
69
- */
70
- public function getEntities(){
71
- return array($this->_entity1, $this->_entity2);
72
- }
73
- /**
74
- * relation to xml
75
- * @access protected
76
- * @param array $arrAttributes
77
- * @param string $rootName
78
- * @param bool $addOpenTag
79
- * @param bool $addCdata
80
- * @return string
81
- * @author Marius Strajeru <marius.strajeru@gmail.com>
82
- */
83
- protected function __toXml(array $arrAttributes = array(), $rootName = 'relation', $addOpenTag=false, $addCdata=false){
84
- $xml = '';
85
- if ($rootName){
86
- $xml .= '<'.$rootName.'>';
87
- }
88
- $entities = $this->getEntities();
89
- $xml .= '<'.$entities[0]->getNameSingular().'_'.$entities[1]->getNameSingular().'>';
90
- $xml .= $this->getType();
91
- $xml .= '</'.$entities[0]->getNameSingular().'_'.$entities[1]->getNameSingular().'>';
92
- if ($rootName){
93
- $xml .= '</'.$rootName.'>';
94
- }
95
- return $xml;
96
- }
97
- /**
98
- * check if siblings can be listed in the entity view page
99
- * @access public
100
- * @param int $index
101
- * @return bool
102
- * @author Marius Strajeru <marius.strajeru@gmail.com>
103
- */
104
- public function getShowFrontendRelationSiblings($index){
105
- if ($this->getType() != Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_SIBLING){
106
- return false;
107
- }
108
- $index = !!$index;
109
- $entities = $this->getEntities();
110
- $e = $entities[$index];
111
- return $e->getFrontendView();
112
- }
113
- /**
114
- * check if children can be listed in the parent view page
115
- * @access public
116
- * @return bool
117
- * @author Marius Strajeru <marius.strajeru@gmail.com>
118
- */
119
- public function getShowFrontendRelationChildren(){
120
- if ($this->getType() == Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_CHILD){
121
- $index = 1;
122
- }
123
- elseif ($this->getType() == Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_PARENT){
124
- $index = 0;
125
- }
126
- else {
127
- return false;
128
- }
129
- $entities = $this->getEntities();
130
- $e = $entities[$index];
131
- return $e->getFrontendView();
132
- }
133
- /**
134
- * check if a relations has tree entities
135
- * @access public
136
- * @return bool
137
- * @author Marius Strajeru <marius.strajeru@gmail.com>
138
- */
139
- public function getHasTree(){
140
- return $this->_entity1->getIsTree() || $this->_entity2->getIsTree();
141
- }
142
- /**
143
- * check if a relations doesn not have tree entities
144
- * @access public
145
- * @return bool
146
- * @author Marius Strajeru <marius.strajeru@gmail.com>
147
- */
148
- public function getNotHasTree(){
149
- return !$this->getHasTree();
150
- }
151
- /**
152
- * check if one of the entities behaves as tree
153
- * @access public
154
- * @param int $index
155
- * @return bool
156
- * @author Marius Strajeru <marius.strajeru@gmail.com>
157
- */
158
- public function getEntityIsTree($index){
159
- $entities = $this->getEntities();
160
- return $entities[$index]->getIsTree();
161
- }
162
- /**
163
- * check if one of the entities behaves as tree
164
- * @access public
165
- * @param int $index
166
- * @return bool
167
- * @author Marius Strajeru <marius.strajeru@gmail.com>
168
- */
169
- public function getSiblingIsTree($index){
170
- return $this->getEntityIsTree(1 - $index);
171
- }
172
- /**
173
- * check if one of the entities does not behave as tree
174
- * @access public
175
- * @param int $index
176
- * @return bool
177
- * @author Marius Strajeru <marius.strajeru@gmail.com>
178
- */
179
- public function getSiblingIsNotTree($index){
180
- return !$this->getSiblingIsTree($index);
181
- }
182
- /**
183
- * check if entity has API
184
- * @access public
185
- * @param int $index
186
- * @return bool
187
- * @author Marius Strajeru <marius.strajeru@gmail.com>
188
- */
189
- public function getEntityHasApi($index){
190
- $entities = $this->getEntities();
191
- return $entities[$index]->getCreateApi();
192
- }
193
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  class Ultimate_ModuleCreator_Model_Relation extends Ultimate_ModuleCreator_Model_Abstract{
19
+ /**
20
+ * relation type constants
21
+ */
22
+ const RELATION_TYPE_NONE = 'none';
23
+ const RELATION_TYPE_CHILD = 'child';
24
+ const RELATION_TYPE_PARENT = 'parent';
25
+ const RELATION_TYPE_SIBLING = 'sibling';
26
+ /**
27
+ * @var Ultimate_ModuleCreator_Model_Entity
28
+ */
29
+ protected $_entity1;
30
+ /**
31
+ * @var Ultimate_ModuleCreator_Model_Entity
32
+ */
33
+ protected $_entity2;
34
+ /**
35
+ * relation type
36
+ * @var string
37
+ */
38
+ protected $_type;
39
+ /**
40
+ * set entities in relation
41
+ * @access public
42
+ * @param Ultimate_ModuleCreator_Model_Entity $entity1
43
+ * @param Ultimate_ModuleCreator_Model_Entity $entity2
44
+ * @param int $type
45
+ * @return Ultimate_ModuleCreator_Model_Relation
46
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
47
+ */
48
+ public function setEntities(Ultimate_ModuleCreator_Model_Entity $entity1, Ultimate_ModuleCreator_Model_Entity $entity2, $type){
49
+ $this->_entity1 = $entity1;
50
+ $this->_entity2 = $entity2;
51
+ $this->_type = $type;
52
+ switch($type){
53
+ case self::RELATION_TYPE_NONE:
54
+ break;
55
+ case self::RELATION_TYPE_CHILD:
56
+ $this->_entity1->addRelatedEntity($type, $this->_entity2);
57
+ $this->_entity2->addRelatedEntity(self::RELATION_TYPE_PARENT, $this->_entity1);
58
+ break;
59
+ case self::RELATION_TYPE_PARENT:
60
+ $this->_entity1->addRelatedEntity($type, $this->_entity2);
61
+ $this->_entity2->addRelatedEntity(self::RELATION_TYPE_CHILD, $this->_entity1);
62
+ break;
63
+ case self::RELATION_TYPE_SIBLING:
64
+ $this->_entity1->addRelatedEntity($type, $this->_entity2);
65
+ $this->_entity2->addRelatedEntity(self::RELATION_TYPE_SIBLING, $this->_entity1);
66
+ break;
67
+ default:
68
+ break;
69
+ }
70
+ return $this;
71
+ }
72
+ /**
73
+ * get the relation type
74
+ * @access public
75
+ * @return int
76
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
77
+ */
78
+ public function getType(){
79
+ return $this->_type;
80
+ }
81
+ /**
82
+ * get relation entities
83
+ * @access public
84
+ * @return array
85
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
86
+ */
87
+ public function getEntities(){
88
+ return array($this->_entity1, $this->_entity2);
89
+ }
90
+ /**
91
+ * relation to xml
92
+ * @access protected
93
+ * @param array $arrAttributes
94
+ * @param string $rootName
95
+ * @param bool $addOpenTag
96
+ * @param bool $addCdata
97
+ * @return string
98
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
99
+ */
100
+ public function toXml(array $arrAttributes = array(), $rootName = 'relation', $addOpenTag=false, $addCdata=false){
101
+ $xml = '';
102
+ $eol = $this->getEol();
103
+ if ($rootName){
104
+ $xml .= '<'.$rootName.'>'.$eol;
105
+ }
106
+ $entities = $this->getEntities();
107
+ $xml .= '<'.$entities[0]->getNameSingular().'_'.$entities[1]->getNameSingular().'>';
108
+ $xml .= $this->getType();
109
+ $xml .= '</'.$entities[0]->getNameSingular().'_'.$entities[1]->getNameSingular().'>'.$eol;
110
+ if ($rootName){
111
+ $xml .= '</'.$rootName.'>'.$eol;
112
+ }
113
+ return $xml;
114
+ }
115
+ /**
116
+ * check if siblings can be listed in the entity view page
117
+ * @access public
118
+ * @param int $index
119
+ * @return bool
120
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
121
+ */
122
+ public function getShowFrontendRelationSiblings($index){
123
+ if ($this->getType() != self::RELATION_TYPE_SIBLING){
124
+ return false;
125
+ }
126
+ $index = !!$index;
127
+ $entities = $this->getEntities();
128
+ $e = $entities[$index];
129
+ return $e->getCreateView();
130
+ }
131
+ /**
132
+ * check if children can be listed in the parent view page
133
+ * @access public
134
+ * @return bool
135
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
136
+ */
137
+ public function getShowFrontendRelationChildren(){
138
+ if ($this->getType() == self::RELATION_TYPE_CHILD){
139
+ $index = 1;
140
+ }
141
+ elseif ($this->getType() == self::RELATION_TYPE_PARENT){
142
+ $index = 0;
143
+ }
144
+ else {
145
+ return false;
146
+ }
147
+ $entities = $this->getEntities();
148
+ $e = $entities[$index];
149
+ return $e->getCreateView();
150
+ }
151
+ /**
152
+ * check if a relations has tree entities
153
+ * @access public
154
+ * @return bool
155
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
156
+ */
157
+ public function getHasTree(){
158
+ return $this->_entity1->getIsTree() || $this->_entity2->getIsTree();
159
+ }
160
+ /**
161
+ * check if a relations doesn not have tree entities
162
+ * @access public
163
+ * @return bool
164
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
165
+ */
166
+ public function getNotHasTree(){
167
+ return !$this->getHasTree();
168
+ }
169
+ /**
170
+ * check if one of the entities behaves as tree
171
+ * @access public
172
+ * @param int $index
173
+ * @return bool
174
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
175
+ */
176
+ public function getEntityIsTree($index){
177
+ $entities = $this->getEntities();
178
+ return $entities[$index]->getIsTree();
179
+ }
180
+ /**
181
+ * check if one of the entities behaves as tree
182
+ * @access public
183
+ * @param int $index
184
+ * @return bool
185
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
186
+ */
187
+ public function getSiblingIsTree($index){
188
+ return $this->getEntityIsTree(1 - $index);
189
+ }
190
+ /**
191
+ * check if one of the entities does not behave as tree
192
+ * @access public
193
+ * @param int $index
194
+ * @return bool
195
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
196
+ */
197
+ public function getSiblingIsNotTree($index){
198
+ return !$this->getSiblingIsTree($index);
199
+ }
200
+ /**
201
+ * check if entity has API
202
+ * @access public
203
+ * @param int $index
204
+ * @return bool
205
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
206
+ */
207
+ public function getEntityHasApi($index){
208
+ $entities = $this->getEntities();
209
+ return $entities[$index]->getApi();
210
+ }
211
+ }
app/code/community/Ultimate/ModuleCreator/Model/Source/Attribute/Scope.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * allowed attribute scopes
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Source_Attribute_Scope {
26
+ /**
27
+ * options
28
+ * @var null
29
+ */
30
+ protected $_options = null;
31
+ /**
32
+ * get options array
33
+ * @access public
34
+ * @param bool $withEmpty
35
+ * @return array|null
36
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
37
+ */
38
+ public function toArray($withEmpty = false){
39
+ if (is_null($this->_options)){
40
+ $this->_options = array();
41
+ $this->_options[] = array(
42
+ 'label' => Mage::helper('modulecreator')->__('Store View'),
43
+ 'value' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE
44
+ );
45
+ $this->_options[] = array(
46
+ 'label' => Mage::helper('modulecreator')->__('Website'),
47
+ 'value' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE
48
+ );
49
+ $this->_options[] = array(
50
+ 'label' => Mage::helper('modulecreator')->__('Global'),
51
+ 'value' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL
52
+ );
53
+ }
54
+ $options = $this->_options;
55
+ if ($withEmpty) {
56
+ $options = array_merge(array(''=>''), $options);
57
+ }
58
+ return $options;
59
+ }
60
+ }
app/code/community/Ultimate/ModuleCreator/Model/Source/Attribute/Type.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * allowed attribute types
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Source_Attribute_Type {
26
+ /**
27
+ * options
28
+ * @var mixed
29
+ */
30
+ protected $_options = null;
31
+ /**
32
+ * get options array
33
+ * @access public
34
+ * @param bool $withEmpty
35
+ * @return array|null
36
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
37
+ */
38
+ public function toArray($withEmpty = false) {
39
+ if (is_null($this->_options)){
40
+ $types = Mage::helper('modulecreator')->getAttributeTypes();
41
+ $groups = Mage::helper('modulecreator')->getAttributeTypeGroups();
42
+ foreach ($groups as $key=>$group) {
43
+ $this->_options[$key] = array('label'=>(string)$group->label, 'value'=>array());
44
+ }
45
+ foreach ($types as $type=>$values) {
46
+ $group = (string)$values->group;
47
+ if (!empty($group) && isset($this->_options[$group])) {
48
+ $this->_options[$group]['value'][] = array('label'=>(string)$values->label, 'value'=>$type);
49
+ }
50
+ else {
51
+ $this->_options[] = array('label'=>(string)$values->label, 'value'=>$type);
52
+ }
53
+ }
54
+ $this->_options = array_values($this->_options);
55
+ }
56
+ $options = $this->_options;
57
+ if ($withEmpty) {
58
+ array_unshift($options, array('label'=>'', 'value'=>''));
59
+ }
60
+ return $options;
61
+ }
62
+ }
app/code/community/Ultimate/ModuleCreator/Model/Source/Attribute/Value/Source.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * allowed attribute sources
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Source_Attribute_Value_Source {
26
+ /**
27
+ * options
28
+ * @var mixed
29
+ */
30
+ protected $_options = null;
31
+
32
+ /**
33
+ * get options array
34
+ * @access public
35
+ * @param bool $withEmpty
36
+ * @return array|null
37
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
38
+ */
39
+ public function toArray($withEmpty = false) {
40
+ if (is_null($this->_options)) {
41
+ $options = Mage::helper('modulecreator')->getDropdownSubtypes(true);
42
+ $this->_options = array();
43
+ foreach ($options as $key=>$option){
44
+ $this->_options[$key] = $option->label;
45
+ }
46
+ }
47
+ $options = $this->_options;
48
+ if ($withEmpty) {
49
+ $options = array_merge(array(''=>''), $options);
50
+ }
51
+ return $options;
52
+ }
53
+ }
app/code/community/Ultimate/ModuleCreator/Model/Source/Codepool.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * code pool source model
19
+ *
20
+ * @category Ultimate
21
+ * @package Ultimate_ModuleCreator
22
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
23
+ */
24
+ class Ultimate_ModuleCreator_Model_Source_Codepool {
25
+ /**
26
+ * get the list of available code pools
27
+ * @access public
28
+ * @param bool $withEmpty
29
+ * @return array
30
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
31
+ */
32
+ public function toOptionArray($withEmpty = false){
33
+ $options = array();
34
+ if ($withEmpty){
35
+ $options[] = array('value'=>'', 'label'=>Mage::helper('modulecreator')->__('Select a codepool'));
36
+ }
37
+ $options[] = array('value' => 'local', 'label'=>'local');
38
+ $options[] = array('value' => 'community', 'label'=>'community');
39
+ return $options;
40
+ }
41
+ /**
42
+ * get options as an array
43
+ * @access public
44
+ * @param bool $withEmpty
45
+ * @return array
46
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
47
+ */
48
+ public function getAllOptions($withEmpty = true){
49
+ $options = array();
50
+ foreach ($this->toOptionArray($withEmpty) as $key=>$option){
51
+ $options[$option['value']] = $option['label'];
52
+ }
53
+ return $options;
54
+ }
55
+ /**
56
+ * get options as an array - wrapper
57
+ * @param bool $withEmpty
58
+ * @return array
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function toArray($withEmpty = true){
62
+ return $this->getAllOptions($withEmpty);
63
+ }
64
+ }
app/code/community/Ultimate/ModuleCreator/Model/Source/Entity/Layout.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * allowed entity layouts
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Source_Entity_Layout {
26
+ /**
27
+ * options
28
+ * @var mixed
29
+ */
30
+ protected $_options = null;
31
+ /**
32
+ * get options array
33
+ * @access public
34
+ * @param bool $withEmpty
35
+ * @return array|null
36
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
37
+ */
38
+ public function toArray($withEmpty = false){
39
+ if (is_null($this->_options)){
40
+ $_options = Mage::getSingleton('page/source_layout')->toOptionArray();
41
+ foreach ($_options as $option){
42
+ $this->_options[$option['value']] = $option['label'];
43
+ }
44
+ }
45
+ $options = $this->_options;
46
+ if ($withEmpty) {
47
+ $options = array_merge(array(''=>''), $options);
48
+ }
49
+ return $options;
50
+ }
51
+ }
app/code/community/Ultimate/ModuleCreator/Model/Source/Entity/Menu.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * available menus
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Source_Entity_Menu {
26
+ const NO_MENU = 0;
27
+ const TOP_LINKS = 1;
28
+ const CATEGORY_MENU = 2;
29
+ const FOOTER_LINKS = 3;
30
+ /**
31
+ * options
32
+ * @var mixed
33
+ */
34
+ protected $_options = null;
35
+ /**
36
+ * get options array
37
+ * @access public
38
+ * @param bool $withEmpty
39
+ * @return array|null
40
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
41
+ */
42
+ public function toArray($withEmpty = false) {
43
+ if (is_null($this->_options)){
44
+ $this->_options[self::NO_MENU] = Mage::helper('modulecreator')->__('Do not include in any menu');
45
+ $this->_options[self::TOP_LINKS] = Mage::helper('modulecreator')->__('Include in top links. (near My account, Checkout, ...)');
46
+ $this->_options[self::CATEGORY_MENU] = Mage::helper('modulecreator')->__('Include in category menu');
47
+ $this->_options[self::FOOTER_LINKS] = Mage::helper('modulecreator')->__('Include in footer links');
48
+ }
49
+ $options = $this->_options;
50
+ if ($withEmpty) {
51
+ $options = array_merge(array(''=>''), $options);
52
+ }
53
+ return $options;
54
+ }
55
+ }
app/code/community/Ultimate/ModuleCreator/Model/Source/Entity/Type.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * allowed entity types
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Source_Entity_Type {
26
+ /**
27
+ * options
28
+ * @var mixed
29
+ */
30
+ protected $_options = null;
31
+ /**
32
+ * get options array
33
+ * @access public
34
+ * @param bool $withEmpty
35
+ * @return array|null
36
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
37
+ */
38
+ public function toArray($withEmpty = false) {
39
+ if (is_null($this->_options)){
40
+ $types = Mage::helper('modulecreator')->getEntityTypes();
41
+ foreach ($types as $type=>$values){
42
+ $this->_options[$type] = Mage::helper('modulecreator')->__((string)$values->label);
43
+ }
44
+ }
45
+ $options = $this->_options;
46
+ if ($withEmpty) {
47
+ $options = array_merge(array(''=>''), $options);
48
+ }
49
+ return $options;
50
+ }
51
+ }
app/code/community/Ultimate/ModuleCreator/Model/Source/Install.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate_ModuleCreator extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE_UMC.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
+ /**
19
+ * install source mode
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Model_Source_Install {
26
+ /**
27
+ * get the list of available install actions
28
+ * @access public
29
+ * @param bool $withEmpty
30
+ * @return array
31
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
32
+ */
33
+ public function toOptionArray($withEmpty = false) {
34
+ $options = array();
35
+ if ($withEmpty){
36
+ $options[] = array(
37
+ 'value'=>'',
38
+ 'label'=>Mage::helper('modulecreator')->__('Select action'));
39
+ }
40
+ $options[] = array(
41
+ 'value' => '1',
42
+ 'label'=>Mage::helper('modulecreator')->__('Install new extension on the current instance.')
43
+ );
44
+ $options[] = array(
45
+ 'value' => '0',
46
+ 'label'=>Mage::helper('modulecreator')->__('Create archive. I will install it later')
47
+ );
48
+ return $options;
49
+ }
50
+ /**
51
+ * get options as an array
52
+ * @access public
53
+ * @param bool $withEmpty
54
+ * @return array
55
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
56
+ */
57
+ public function getAllOptions($withEmpty = true) {
58
+ $options = array();
59
+ foreach ($this->toOptionArray($withEmpty) as $key=>$option) {
60
+ $options[$option['value']] = $option['label'];
61
+ }
62
+ return $options;
63
+ }
64
+
65
+ /**
66
+ * get options as an array - wrapper
67
+ * @param bool $withEmpty
68
+ * @return array
69
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
70
+ */
71
+ public function toArray($withEmpty = true) {
72
+ return $this->getAllOptions($withEmpty);
73
+ }
74
+ }
app/code/community/Ultimate/ModuleCreator/Model/Writer.php CHANGED
@@ -9,74 +9,74 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
  */
17
  /**
18
  * Zip writer
19
  *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
  */
24
- class Ultimate_ModuleCreator_Model_Writer extends Mage_Connect_Package_Writer{
25
- /**
26
- * prefix for path
27
- * @var string
28
- */
29
- protected $_pathPrefix = '';
30
- /**
31
- * constructor
32
- * @access public
33
- * @param array $files
34
- * @param mixed $namePackage
35
- * @return void
36
- * @author Marius Strajeru <marius.strajeru@gmail.com>
37
- */
38
- public function __construct($files, $namePackage=''){
39
- parent::__construct($files, $namePackage='');
40
- $this->_pathPrefix = 'var'.DS.'modulecreator'.DS;
41
- }
42
- /**
43
- * build the package
44
- * @access public
45
- * @return Ultimate_ModuleCreator_Model_Writer
46
- * @see Mage_Connect_Package_Writer::composePackage()
47
- * @author Marius Strajeru <marius.strajeru@gmail.com>
48
- */
49
- public function composePackage(){
50
- @mkdir(self::PATH_TO_TEMPORARY_DIRECTORY, 0777, true);
51
- $root = self::PATH_TO_TEMPORARY_DIRECTORY . basename($this->_namePackage);
52
- @mkdir($root, 0777, true);
53
- foreach ($this->_files as $file) {
54
- if (is_dir($file) || is_file($file)) {
55
- $fileName = basename($file);
56
- $filePath = dirname($file);
57
- if (substr($filePath, 0, strlen($this->_pathPrefix)) == $this->_pathPrefix){
58
- $filePath = substr($filePath, strlen($this->_pathPrefix));
59
- }
60
- @mkdir($root . DS . $filePath, 0777, true);
61
- if (is_file($file)) {
62
- copy($file, $root . DS . $filePath . DS . $fileName);
63
- }
64
- else {
65
- @mkdir($root . DS . $filePath . $fileName, 0777);
66
- }
67
- }
68
- }
69
- $this->_temporaryPackageDir = $root;
70
- return $this;
71
- }
72
- /**
73
- * set the package name
74
- * @access public
75
- * @return Ultimate_ModuleCreator_Model_Writer
76
- * @author Marius Strajeru <marius.strajeru@gmail.com>
77
- */
78
- public function setNamePackage($name){
79
- $this->_namePackage = $name;
80
- return $this;
81
- }
82
  }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2012
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
  */
17
  /**
18
  * Zip writer
19
  *
20
+ * @category Ultimate
21
+ * @package Ultimate_ModuleCreator
22
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
23
  */
24
+ class Ultimate_ModuleCreator_Model_Writer extends Mage_Connect_Package_Writer {
25
+ /**
26
+ * prefix for path
27
+ * @var string
28
+ */
29
+ protected $_pathPrefix = '';
30
+ /**
31
+ * constructor
32
+ * @access public
33
+ * @param array $files
34
+ * @param mixed $namePackage
35
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
36
+ */
37
+ public function __construct($files, $namePackage='') {
38
+ parent::__construct($files, $namePackage='');
39
+ $this->_pathPrefix = 'var'.DS.'modulecreator'.DS;
40
+ }
41
+ /**
42
+ * build the package
43
+ * @access public
44
+ * @return Ultimate_ModuleCreator_Model_Writer
45
+ * @see Mage_Connect_Package_Writer::composePackage()
46
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
47
+ */
48
+ public function composePackage() {
49
+ @mkdir(self::PATH_TO_TEMPORARY_DIRECTORY, 0777, true);
50
+ $root = self::PATH_TO_TEMPORARY_DIRECTORY . basename($this->_namePackage);
51
+ @mkdir($root, 0777, true);
52
+ foreach ($this->_files as $file) {
53
+ if (is_dir($file) || is_file($file)) {
54
+ $fileName = basename($file);
55
+ $filePath = dirname($file);
56
+ if (substr($filePath, 0, strlen($this->_pathPrefix)) == $this->_pathPrefix) {
57
+ $filePath = substr($filePath, strlen($this->_pathPrefix));
58
+ }
59
+ @mkdir($root . DS . $filePath, 0777, true);
60
+ if (is_file($file)) {
61
+ copy($file, $root . DS . $filePath . DS . $fileName);
62
+ }
63
+ else {
64
+ @mkdir($root . DS . $filePath . $fileName, 0777);
65
+ }
66
+ }
67
+ }
68
+ $this->_temporaryPackageDir = $root;
69
+ return $this;
70
+ }
71
+ /**
72
+ * set the package name
73
+ * @access public
74
+ * @param string $name
75
+ * @return Ultimate_ModuleCreator_Model_Writer
76
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
77
+ */
78
+ public function setNamePackage($name) {
79
+ $this->_namePackage = $name;
80
+ return $this;
81
+ }
82
  }
app/code/community/Ultimate/ModuleCreator/controllers/Adminhtml/ModulecreatorController.php CHANGED
@@ -9,367 +9,246 @@
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
- * @category Ultimate
13
- * @package Ultimate_ModuleCreator
14
- * @copyright Copyright (c) 2012
15
- * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
 
17
  /**
18
- * admin controller
19
- *
20
- * @category Ultimate
21
- * @package Ultimate_ModuleCreator
22
- * @author Marius Strajeru <marius.strajeru@gmail.com>
23
- */
24
- class Ultimate_ModuleCreator_Adminhtml_ModulecreatorController extends Mage_Adminhtml_Controller_Action{
25
- /**
26
- * default action
27
- * @access public
28
- * @return void
29
- * @author Marius Strajeru <marius.strajeru@gmail.com>
30
- */
31
- public function indexAction(){
32
- $this->_title($this->__('Ultimate module creator'));
33
- $this->loadLayout();
34
- $this->renderLayout();
35
- }
36
- /**
37
- * grid action
38
- * @access public
39
- * @return void
40
- * @author Marius Strajeru <marius.strajeru@gmail.com>
41
- */
42
- public function gridAction(){
43
- $this->loadLayout();
44
- $this->renderLayout();
45
- }
46
- /**
47
- * new action
48
- * @access public
49
- * @return void
50
- * @author Marius Strajeru <marius.strajeru@gmail.com>
51
- */
52
- public function newAction(){
53
- $this->_forward('edit');
54
- }
55
- /**
56
- * edit action
57
- * @access public
58
- * @return void
59
- * @author Marius Strajeru <marius.strajeru@gmail.com>
60
- */
61
- public function editAction(){
62
- $data = $this->_initModule();
63
- $this->_title($this->__('Ultimate module creator'));
64
- if ($data){
65
- $this->_getSession()->addNotice(Mage::helper('modulecreator')->__('You are editing the module: %s',(string)$data->extension));
66
- $this->_title((string)$data->descend('config/module'));
67
- }
68
- else{
69
- $this->_title($this->__('Add module'));
70
- }
71
- $this->loadLayout();
72
- $this->renderLayout();
73
- }
74
- /**
75
- * init module
76
- * @access protected
77
- * @return mixed
78
- * @author Marius Strajeru <marius.strajeru@gmail.com>
79
- */
80
- protected function _initModule(){
81
- $packageName = base64_decode(strtr($this->getRequest()->getParam('id'), '-_,', '+/='));
82
- if ($packageName){
83
- try {
84
- $data = Mage::helper('modulecreator')->loadModule($packageName);
85
- Mage::register('current_module', $data);
86
- return $data;
87
- }
88
- catch (Exception $e) {
89
- $this->_getSession()->addError($e->getMessage());
90
- $this->_redirect('*/*/index');
91
- }
92
- }
93
- return false;
94
- }
95
- /**
96
- * add new entity - action
97
- * @access public
98
- * @return void
99
- * @author Marius Strajeru <marius.strajeru@gmail.com>
100
- */
101
- public function addEntityAction(){
102
- $increment = $this->getRequest()->getParam('increment', 0);
103
- $entity = Mage::getModel('modulecreator/entity');
104
- $settings = Mage::getStoreConfig('modulecreator/entity_defaults');
105
- $entity->addData($settings);
106
- $response = Mage::app()->getLayout()
107
- ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_entities_entity')
108
- ->setTemplate('ultimate_modulecreator/edit/tab/entities/entity.phtml')
109
- ->setEntity($entity)
110
- ->setIncrement($increment)
111
- ->toHtml();
112
- $this->getResponse()->setBody($response);
113
- }
114
- /**
115
- * add new attribute/field
116
- * @access public
117
- * @return void
118
- * @author Marius Strajeru <marius.strajeru@gmail.com>
119
- */
120
- public function addAttributeAction(){
121
- $increment = $this->getRequest()->getParam('increment', 0);
122
- $entityId = $this->getRequest()->getParam('entity', 0);
123
- $response = Mage::app()->getLayout()
124
- ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_entities_entity_attribute')
125
- ->setTemplate('ultimate_modulecreator/edit/tab/entities/entity/attribute.phtml')
126
- ->setAttributeInstance(Mage::getModel('modulecreator/attribute'))
127
- ->setIncrement($increment)
128
- ->setEntityId($entityId)
129
- ->toHtml();
130
- $this->getResponse()->setBody($response);
131
- }
132
- /**
133
- * validate module before saving
134
- * @access public
135
- * @return void
136
- * @author Marius Strajeru <marius.strajeru@gmail.com>
137
- */
138
- public function validateAction(){
139
- $errors = array();
140
- $response = new Varien_Object();
141
- $response->setError(false);
142
- $data = $this->getRequest()->getPost();
143
- $entities = $this->getRequest()->getPost('entity');
144
- $settings = $this->getRequest()->getPost('settings');
145
- if (empty($settings['namespace'])){
146
- $error = new Varien_Object();
147
- $error->setField('settings_namespace');
148
- $error->setMessage(Mage::helper('modulecreator')->__('Fill in the Namespace'));
149
- $errors[] = $error->toArray();
150
- }
151
- if (empty($settings['module_name'])){
152
- $error = new Varien_Object();
153
- $error->setField('settings_module_name');
154
- $error->setMessage(Mage::helper('modulecreator')->__('Fill in the Module name'));
155
- $errors[] = $error->toArray();
156
- }
157
- else{
158
- $validModule = Mage::helper('modulecreator')->validateModuleName($settings['module_name'], $settings['current_extension']);
159
- if (is_string($validModule)){
160
- $error = new Varien_Object();
161
- $error->setMessage($validModule);
162
- $error->setField('settings_module_name');
163
- $errors[] = $error->toArray();
164
- }
165
- }
166
- $validExtension = Mage::helper('modulecreator')->validateExtensionName($settings['namespace'], $settings['module_name'], $settings['current_extension']);
167
- if (is_string($validExtension)){
168
- $error = new Varien_Object();
169
- $error->setMessage($validExtension);
170
- $errors[] = $error->toArray();
171
- }
172
- if (empty($entities)){
173
- $error = new Varien_Object();
174
- $error->setMessage(Mage::helper('modulecreator')->__('Add at least one entity'));
175
- $errors[] = $error->toArray();
176
- }
177
- else{
178
- //validate each entity
179
- $noAttributeEntities = false;
180
- $noNameEntities = false;
181
- foreach ($entities as $key=>$entity){
182
- if (empty($entity['name_singular'])){
183
- $error = new Varien_Object();
184
- $error->setMessage(Mage::helper('modulecreator')->__('This is a required field.'));
185
- $error->setField('entity_'.$key.'_name_singular');
186
- $errors[] = $error->toArray();
187
- }
188
- if (empty($entity['name_plural'])){
189
- $error = new Varien_Object();
190
- $error->setMessage(Mage::helper('modulecreator')->__('This is a required field.'));
191
- $error->setField('entity_'.$key.'_name_plural');
192
- $errors[] = $error->toArray();
193
- }
194
- if (!isset($entity['attributes']) && !$noAttributeEntities){
195
- $error = new Varien_Object();
196
- $error->setMessage(Mage::helper('modulecreator')->__('There are entities without attribtues. Add attributes or remove them before continuing.'));
197
- $errors[] = $error->toArray();
198
- $noAttributeEntities = true;
199
- }
200
- elseif (isset($entity['attributes'])){
201
- //validate attributes
202
- foreach ($entity['attributes'] as $attrKey=>$attribute){
203
- if (is_numeric($attrKey)){
204
- $validAttribute = Mage::helper('modulecreator')->validateAttributeName($attribute['code']);
205
- if (is_string($validAttribute)){
206
- $error = new Varien_Object();
207
- $error->setMessage($validAttribute);
208
- $error->setField('attribute_'.$key.'_'.$attrKey.'_code');
209
- $errors[] = $error->toArray();
210
- }
211
- }
212
- }
213
- }
214
- if ((!isset($entity['attributes']) || is_null($entity['attributes']['is_name'])) && !$noNameEntities){
215
- $error = new Varien_Object();
216
- $error->setMessage(Mage::helper('modulecreator')->__('Each entity must have an attribute set to behave as "Name"'));
217
- $errors[] = $error->toArray();
218
- $noNameEntities = true;
219
- }
220
- $validEntity = Mage::helper('modulecreator')->validateEntityName($settings['module_name'], @$entity['name_singular'], $settings['current_extension']);
221
- if (is_string($validEntity)){
222
- $error = new Varien_Object();
223
- $error->setMessage($validEntity);
224
- $error->setField('entity_'.$key.'_name_singular');
225
- $errors[] = $error->toArray();
226
- }
227
-
228
- }
229
- }
230
- try{
231
- $module = $this->_initModuleFromData($data);
232
- }
233
- catch (Exception $e){
234
- $error = new Varien_Object();
235
- $error->setMessage($e->getMessage());
236
- $errors[] = $error->toArray();
237
- }
238
- if (count($errors) > 0){
239
- $response->setError(true);
240
- $response->setErrors($errors);
241
- }
242
- $this->getResponse()->setBody($response->toJson());
243
- }
244
- /**
245
- * init a module from an array
246
- * @access public
247
- * @param array $data
248
- * @return Ultimate_ModuleCreator_Model_Module
249
- * @author Marius Strajeru <marius.strajeru@gmail.com>
250
- */
251
- protected function _initModuleFromData($data){
252
- $entitiesByIndex = array();
253
- $module = Mage::getModel('modulecreator/module');
254
- if (isset($data['settings'])){
255
- $module->addData($data['settings']);
256
- }
257
- if (isset($data['entity'])){
258
- $entities = $data['entity'];
259
- if (is_array($entities)){
260
- foreach ($entities as $key=>$entityData){
261
- $entity = Mage::getModel('modulecreator/entity');
262
- $entity->addData($entityData);
263
- if (isset($entityData['attributes']) && is_array($entityData['attributes'])){
264
- if (isset($entityData['attributes']['is_name'])){
265
- $isName = $entityData['attributes']['is_name'];
266
- unset($entityData['attributes']['is_name']);
267
- }
268
- if (isset($entityData['attributes'][$isName])){
269
- $entityData['attributes'][$isName]['is_name'] = 1;
270
- }
271
- foreach ($entityData['attributes'] as $attributeData){
272
- $attribute = Mage::getModel('modulecreator/attribute');
273
- $attribute->addData($attributeData);
274
- $entity->addAttribute($attribute);
275
- }
276
- }
277
- $module->addEntity($entity);
278
- $entitiesByIndex[$key] = $entity;
279
- }
280
- }
281
- if (isset($data['relation'])){
282
- foreach($data['relation'] as $index=>$values){
283
- foreach ($values as $jndex=>$type){
284
- if (isset($entitiesByIndex[$index]) && isset($entitiesByIndex[$jndex])){
285
- //Many to many relations between tree entities is not supported yet
286
- //ignore these relations
287
- if ($entitiesByIndex[$index]->getIsTree() && $entitiesByIndex[$jndex]->getIsTree()){
288
- $type = Ultimate_ModuleCreator_Helper_Data::RELATION_TYPE_NONE;
289
- }
290
- $relation = Mage::getModel('modulecreator/relation');
291
- $relation->setEntities($entitiesByIndex[$index], $entitiesByIndex[$jndex], $type);
292
- $module->addRelation($relation);
293
- }
294
- }
295
- }
296
- }
297
- }
298
- return $module;
299
- }
300
- /**
301
- * save module
302
- * @access public
303
- * @return void
304
- * @author Marius Strajeru <marius.strajeru@gmail.com>
305
- */
306
- public function saveAction(){
307
- $redirectBack = $this->getRequest()->getParam('back', false);
308
- try{
309
- $module = $this->_initModuleFromData($this->getRequest()->getPost());
310
- $messages = $module->buildModule();
311
- $module->save();
312
- foreach ($messages as $message){
313
- $this->_getSession()->addNotice($message);
314
- }
315
- $this->_getSession()->addSuccess(Mage::helper('modulecreator')->__('Your extension has been created!'));
316
- }
317
- catch (Exception $e){
318
- $this->_getSession()->addError($e->getMessage());
319
- $redirectBack = true;
320
- }
321
- if ($redirectBack) {
322
- $this->_redirect('*/*/edit', array(
323
- 'id' => strtr(base64_encode($module->getNamespace().'_'.$module->getModuleName()), '+/=', '-_,'),
324
- '_current' => true
325
- ));
326
- }
327
- else {
328
- $this->_redirect('*/*/');
329
- }
330
- }
331
- /**
332
- * action for menu order select
333
- * @access public
334
- * @return void
335
- * @author Marius Strajeru <marius.strajeru@gmail.com>
336
- */
337
- public function menuOrderAction(){
338
- $menu = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu');
339
- $items = array();
340
- foreach ($menu->children() as $key=>$values){
341
- if (1 == $values->disabled) {
342
- continue;
343
- }
344
- $item = array('label'=>(string)$values->title, 'sort_order'=>(int)$values->sort_order);
345
- $items[(int)$values->sort_order][] = $item;
346
- }
347
- ksort($items);
348
- $response = array();
349
- foreach ($items as $order=>$orderedItems){
350
- foreach ($orderedItems as $item){
351
- $response[] = $item;
352
- }
353
- }
354
- $this->getResponse()->setBody(json_encode($response));
355
- }
356
- /**
357
- * download module action
358
- * @access public
359
- * @return void
360
- * @author Marius Strajeru <marius.strajeru@gmail.com>
361
- */
362
- public function downloadAction(){
363
- $packageName = base64_decode(strtr($this->getRequest()->getParam('id'), '-_,', '+/='));
364
- $path = Mage::helper('modulecreator')->getLocalModulesDir();
365
- $file = $path . $packageName . '.tgz';
366
- if (file_exists($file) && is_readable($file)) {
367
- $content = file_get_contents($file);
368
- $this->_prepareDownloadResponse(basename($file), $content);
369
- }
370
- else{
371
- $this->_getSession()->addError(Mage::helper('modulecreator')->__('Your extension archive was not created or is not readable'));
372
- $this->_redirect('*/*');
373
- }
374
- }
375
- }
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/mit-license.php
11
  *
12
+ * @category Ultimate
13
+ * @package Ultimate_ModuleCreator
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
17
+ */
18
  /**
19
+ * main admin controller
20
+ *
21
+ * @category Ultimate
22
+ * @package Ultimate_ModuleCreator
23
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
24
+ */
25
+ class Ultimate_ModuleCreator_Adminhtml_ModulecreatorController
26
+ extends Mage_Adminhtml_Controller_Action {
27
+ /**
28
+ * @access public
29
+ * @return void
30
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
31
+ */
32
+ public function indexAction() {
33
+ $this->_title(Mage::helper('modulecreator')->__('Ultimate module creator'));
34
+ $this->_getSession()->addNotice(Mage::helper('modulecreator')->__(
35
+ 'To delete a module from this list go to "<strong>%s</strong>" and remove the files "<strong>%s</strong>" and "<strong>%s</strong>" and folder "<strong>%s</strong>" if they exist. Replace <strong>Namespace_Module</strong> with the appropriate value for each module. There is no delete link in here for security reasons.',
36
+ Mage::getBaseDir('var').DS.'modulecreator',
37
+ 'Namespace_Module.tgz',
38
+ 'package/Namespace_Module.xml',
39
+ 'package/Namespace_Module/'
40
+
41
+ ));
42
+ $this->loadLayout();
43
+ $this->renderLayout();
44
+ }
45
+
46
+ /**
47
+ * grid action
48
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
49
+ */
50
+ public function gridAction() {
51
+ $this->loadLayout();
52
+ $this->renderLayout();
53
+ }
54
+
55
+ /**
56
+ * new action
57
+ * @access public
58
+ * @return void
59
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
60
+ */
61
+ public function newAction() {
62
+ $this->_forward('edit');
63
+ }
64
+ /**
65
+ * edit action
66
+ * @access public
67
+ * @return void
68
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
69
+ */
70
+ public function editAction() {
71
+ $module = $this->_initModule();
72
+ $this->_title(Mage::helper('modulecreator')->__('Ultimate module creator'));
73
+ if ($module) {
74
+ $extensionName = $module->getNamespace().'_'.$module->getModuleName();
75
+ $this->_getSession()->addNotice(Mage::helper('modulecreator')->__('You are editing the module: %s', $extensionName));
76
+ $this->_title($extensionName);
77
+ }
78
+ else {
79
+ $this->_title(Mage::helper('modulecreator')->__('Add module'));
80
+ }
81
+ $this->loadLayout();
82
+ $this->renderLayout();
83
+ }
84
+ /**
85
+ * init module
86
+ * @access protected
87
+ * @return mixed
88
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
89
+ */
90
+ protected function _initModule() {
91
+ $packageName = base64_decode(strtr($this->getRequest()->getParam('id'), '-_,', '+/='));
92
+ if ($packageName) {
93
+ try {
94
+ $path = Mage::helper('modulecreator')->getLocalPackagesPath();
95
+ $packageName = basename($packageName);
96
+ $xmlFile = $path . $packageName . '.xml';
97
+ if (file_exists($xmlFile) && is_readable($xmlFile)) {
98
+ $xml = simplexml_load_file($xmlFile, 'Varien_Simplexml_Element');
99
+ $module = Mage::helper('modulecreator')->loadModule($xml);
100
+ Mage::register('current_module', $module);
101
+ return $module;
102
+ }
103
+ }
104
+ catch (Exception $e) {
105
+ Mage::logException($e);
106
+ $this->_getSession()->addError($e->getMessage());
107
+ $this->_redirect('*/*/index');
108
+ }
109
+ }
110
+ return false;
111
+ }
112
+ /**
113
+ * init a module from an array
114
+ * @access public
115
+ * @param array $data
116
+ * @return Ultimate_ModuleCreator_Model_Module
117
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
118
+ */
119
+ protected function _initModuleFromData($data) {
120
+ $entitiesByIndex = array();
121
+ $module = Mage::getModel('modulecreator/module');
122
+ if (isset($data['settings'])) {
123
+ $module->addData($data['settings']);
124
+ }
125
+ if (isset($data['entity'])) {
126
+ $entities = $data['entity'];
127
+ if (is_array($entities)) {
128
+ foreach ($entities as $key=>$entityData) {
129
+ $entity = Mage::getModel('modulecreator/entity');
130
+ $entity->addData($entityData);
131
+ $entity->setIndex($key);
132
+ if (isset($entityData['attributes']) && is_array($entityData['attributes'])) {
133
+ if (isset($entityData['attributes']['is_name'])) {
134
+ $isName = $entityData['attributes']['is_name'];
135
+ unset($entityData['attributes']['is_name']);
136
+ if (isset($entityData['attributes'][$isName])) {
137
+ $entityData['attributes'][$isName]['is_name'] = 1;
138
+ }
139
+ }
140
+ foreach ($entityData['attributes'] as $aKey=>$attributeData) {
141
+ $attribute = Mage::getModel('modulecreator/attribute');
142
+ $attribute->addData($attributeData);
143
+ $attribute->setIndex($aKey);
144
+ $entity->addAttribute($attribute);
145
+ }
146
+ }
147
+ $module->addEntity($entity);
148
+ $entitiesByIndex[$key] = $entity;
149
+ }
150
+ }
151
+ if (isset($data['relation'])) {
152
+ foreach($data['relation'] as $index=>$values){
153
+ foreach ($values as $jndex=>$type){
154
+ if (isset($entitiesByIndex[$index]) && isset($entitiesByIndex[$jndex])) {
155
+ $relation = Mage::getModel('modulecreator/relation');
156
+ $relation->setEntities($entitiesByIndex[$index], $entitiesByIndex[$jndex], $type);
157
+ $module->addRelation($relation);
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ return $module;
164
+ }
165
+
166
+ /**
167
+ * validate module before saving
168
+ * @access public
169
+ * @return void
170
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
171
+ */
172
+ public function validateAction(){
173
+ try{
174
+ $response = new Varien_Object();
175
+ $module = $this->_initModuleFromData($this->getRequest()->getPost());
176
+ $errors = $module->validate();
177
+ if (count($errors) == 0){
178
+ $messages = $module->buildModule();
179
+ $module->save();
180
+ $response->setError(false);
181
+ }
182
+ else{
183
+ if (isset($errors[''])){
184
+ $response->setMessage(implode('<br />', $errors['']));
185
+ unset($errors['']);
186
+ }
187
+ $response->setError(true);
188
+ $response->setAttributes($errors);
189
+ }
190
+ }
191
+ catch (Exception $e){
192
+ $response->setError(true);
193
+ $response->setMessage($e->getMessage());
194
+ }
195
+ $this->getResponse()->setBody($response->toJson());
196
+ }
197
+ /**
198
+ * save module - actually only redirects the page
199
+ * the save was done in validateAction(). there is no need to process the request twice.
200
+ * @access public
201
+ * @return void
202
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
203
+ */
204
+ public function saveAction() {
205
+ $this->_getSession()->addSuccess(Mage::helper('modulecreator')->__('Your extension has been created!'));
206
+ $module = $this->_initModuleFromData($this->getRequest()->getPost());
207
+ $redirectBack = $this->getRequest()->getParam('back', false);
208
+ if ($redirectBack) {
209
+ $this->_redirect('*/*/edit', array(
210
+ 'id' => strtr(base64_encode($module->getExtensionName()), '+/=', '-_,'),
211
+ '_current' => true
212
+ ));
213
+ }
214
+ else {
215
+ $this->_redirect('*/*/');
216
+ }
217
+ }
218
+ /**
219
+ * download module action
220
+ * @access public
221
+ * @return void
222
+ * @author Marius Strajeru <ultimate.module.creator@gmail.com>
223
+ */
224
+ public function downloadAction(){
225
+ $what = $this->getRequest()->getParam('type');
226
+ $packageName = base64_decode(strtr($this->getRequest()->getParam('id'), '-_,', '+/='));
227
+ $path = Mage::helper('modulecreator')->getLocalModulesDir();
228
+ $namePrefix = '';
229
+ switch ($what) {
230
+ case 'config' :
231
+ $file = $path.'package'.DS.$packageName . '.xml';
232
+ break;
233
+ case 'list':
234
+ $file = $path.'package'.DS.$packageName . DS. 'files.log';
235
+ $namePrefix = $packageName.'_';
236
+ break;
237
+ case 'uninstall' :
238
+ $file = $path.'package'.DS.$packageName . DS. 'uninstall.sql';
239
+ $namePrefix = $packageName.'_';
240
+ break;
241
+ default:
242
+ $file = $path . $packageName . '.tgz';
243
+ break;
244
+ }
245
+ if (file_exists($file) && is_readable($file)) {
246
+ $content = file_get_contents($file);
247
+ $this->_prepareDownloadResponse($namePrefix.basename($file), $content);
248
+ }
249
+ else{
250
+ $this->_getSession()->addError(Mage::helper('modulecreator')->__('Your extension archive was not created or is not readable'));
251
+ $this->_redirect('*/*');
252
+ }
253
+ }
254
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/adminhtml.xml CHANGED
@@ -10,53 +10,48 @@
10
  * It is also available through the world-wide-web at this URL:
11
  * http://opensource.org/licenses/mit-license.php
12
  *
13
- * @category Ultimate
14
- * @package Ultimate_ModuleCreator
15
- * @copyright Copyright (c) 2012
16
- * @license http://opensource.org/licenses/mit-license.php MIT License
17
- */
18
- /**
19
- * @category Ultimate
20
- * @package Ultimate_ModuleCreator
21
- * @author Marius Strajeru <marius.strajeru@gmail.com>
22
- */
23
  -->
24
  <config>
25
- <acl>
26
- <resources>
27
- <admin>
28
- <children>
29
- <system>
30
- <children>
31
- <config>
32
- <children>
33
- <modulecreator translate="title" module="modulecreator">
34
- <title>Ultimate module creator</title>
35
- </modulecreator>
36
- </children>
37
- </config>
38
- <modulecreator translate="title" module="modulecreator">
39
- <title>Module creator</title>
40
- <sort_order>10</sort_order>
41
- </modulecreator>
42
- </children>
43
- </system>
44
- </children>
45
- </admin>
46
- </resources>
47
- </acl>
48
- <menu>
49
- <system>
50
- <children>
51
- <modulecreator translate="title" module="modulecreator">
52
- <title>Module creator</title>
53
- <sort_order>10</sort_order>
54
- <action>adminhtml/modulecreator</action>
55
- <depends>
56
- <module>Ultimate_ModuleCreator</module>
57
- </depends>
58
- </modulecreator>
59
- </children>
60
- </system>
61
- </menu>
62
  </config>
10
  * It is also available through the world-wide-web at this URL:
11
  * http://opensource.org/licenses/mit-license.php
12
  *
13
+ * @category Ultimate
14
+ * @package Ultimate_ModuleCreator
15
+ * @copyright Copyright (c) 2014
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
 
 
 
 
 
18
  -->
19
  <config>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <config>
27
+ <children>
28
+ <modulecreator translate="title" module="modulecreator">
29
+ <title>Ultimate module creator</title>
30
+ </modulecreator>
31
+ </children>
32
+ </config>
33
+ <modulecreator translate="title" module="modulecreator">
34
+ <title>Module creator</title>
35
+ <sort_order>10</sort_order>
36
+ </modulecreator>
37
+ </children>
38
+ </system>
39
+ </children>
40
+ </admin>
41
+ </resources>
42
+ </acl>
43
+ <menu>
44
+ <system>
45
+ <children>
46
+ <modulecreator translate="title" module="modulecreator">
47
+ <title>Module creator</title>
48
+ <sort_order>10</sort_order>
49
+ <action>adminhtml/modulecreator</action>
50
+ <depends>
51
+ <module>Ultimate_ModuleCreator</module>
52
+ </depends>
53
+ </modulecreator>
54
+ </children>
55
+ </system>
56
+ </menu>
57
  </config>
app/code/community/Ultimate/ModuleCreator/etc/config.xml CHANGED
@@ -1,5 +1,5 @@
1
- <?xml version="1.0" ?>
2
- <!--
3
  /**
4
  * Ultimate_ModuleCreator extension
5
  *
@@ -10,76 +10,79 @@
10
  * It is also available through the world-wide-web at this URL:
11
  * http://opensource.org/licenses/mit-license.php
12
  *
13
- * @category Ultimate
14
- * @package Ultimate_ModuleCreator
15
- * @copyright Copyright (c) 2012
16
- * @license http://opensource.org/licenses/mit-license.php MIT License
17
- */
18
- /**
19
- * @category Ultimate
20
- * @package Ultimate_ModuleCreator
21
- * @author Marius Strajeru <marius.strajeru@gmail.com>
22
- */
23
  -->
24
  <config>
25
- <modules>
26
- <Ultimate_ModuleCreator>
27
- <version>1.6.3.1</version>
28
- </Ultimate_ModuleCreator>
29
- </modules>
30
- <global>
31
- <blocks>
32
- <modulecreator>
33
- <class>Ultimate_ModuleCreator_Block</class>
34
- </modulecreator>
35
- </blocks>
36
- <helpers>
37
- <modulecreator>
38
- <class>Ultimate_ModuleCreator_Helper</class>
39
- </modulecreator>
40
- </helpers>
41
- <models>
42
- <modulecreator>
43
- <class>Ultimate_ModuleCreator_Model</class>
44
- </modulecreator>
45
- </models>
46
- </global>
47
- <adminhtml>
48
- <translate>
49
- <modules>
50
- <Ultimate_ModuleCreator>
51
- <files>
52
- <default>Ultimate_ModuleCreator.csv</default>
53
- </files>
54
- </Ultimate_ModuleCreator>
55
- </modules>
56
- </translate>
57
- <layout>
58
- <updates>
59
- <ultimate_modulecreator>
60
- <file>ultimate_modulecreator.xml</file>
61
- </ultimate_modulecreator>
62
- </updates>
63
- </layout>
64
- </adminhtml>
65
- <admin>
66
- <routers>
67
- <adminhtml>
68
- <args>
69
- <modules>
70
- <Ultimate_ModuleCreator before="Mage_Adminhtml">Ultimate_ModuleCreator_Adminhtml</Ultimate_ModuleCreator>
71
- </modules>
72
- </args>
73
- </adminhtml>
74
- </routers>
75
- </admin>
76
- <default>
77
- <modulecreator>
78
- <settings>
79
- <namespace>Ultimate</namespace>
80
- <codepool>local</codepool>
81
- <install>0</install>
82
- <license><![CDATA[
 
 
 
 
 
 
 
 
83
  {{Namespace}}_{{Module}} extension
84
 
85
  NOTICE OF LICENSE
@@ -89,35 +92,55 @@ that is bundled with this package in the file LICENSE.txt.
89
  It is also available through the world-wide-web at this URL:
90
  http://opensource.org/licenses/mit-license.php
91
 
92
- @category {{Namespace}}
93
- @package {{Namespace}}_{{Module}}
94
- @copyright Copyright (c) {{Y}}
95
- @license http://opensource.org/licenses/mit-license.php MIT License
96
  ]]></license>
97
- <use_ddl>1</use_ddl>
98
- </settings>
99
- <entity_defaults>
100
- <use_frontend>1</use_frontend>
101
- <frontend_list>1</frontend_list>
102
- <frontend_view>1</frontend_view>
103
- <frontend_list_template>page/2columns-left.phtml</frontend_list_template>
104
- <frontend_view_template>page/2columns-left.phtml</frontend_view_template>
105
- <frontend_add_seo>1</frontend_add_seo>
106
- <created_to_grid>1</created_to_grid>
107
- <updated_to_grid>1</updated_to_grid>
108
- <create_api>0</create_api>
109
- <add_status>1</add_status>
110
- <rss>1</rss>
111
- <widget>1</widget>
112
- <link_product>1</link_product>
113
- <show_on_product>1</show_on_product>
114
- <show_products>1</show_products>
115
- <is_tree>0</is_tree>
116
- <url_rewrite>1</url_rewrite>
117
- </entity_defaults>
118
- <release>
119
- <beta>0</beta>
120
- </release>
121
- </modulecreator>
122
- </default>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
  /**
4
  * Ultimate_ModuleCreator extension
5
  *
10
  * It is also available through the world-wide-web at this URL:
11
  * http://opensource.org/licenses/mit-license.php
12
  *
13
+ * @category Ultimate
14
+ * @package Ultimate_ModuleCreator
15
+ * @copyright Copyright (c) 2014
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
 
 
 
 
 
18
  -->
19
  <config>
20
+ <modules>
21
+ <Ultimate_ModuleCreator>
22
+ <version>1.9.0.0</version>
23
+ <build></build>
24
+ </Ultimate_ModuleCreator>
25
+ </modules>
26
+ <global>
27
+ <blocks>
28
+ <modulecreator>
29
+ <class>Ultimate_ModuleCreator_Block</class>
30
+ </modulecreator>
31
+ </blocks>
32
+ <helpers>
33
+ <modulecreator>
34
+ <class>Ultimate_ModuleCreator_Helper</class>
35
+ </modulecreator>
36
+ </helpers>
37
+ <models>
38
+ <modulecreator>
39
+ <class>Ultimate_ModuleCreator_Model</class>
40
+ </modulecreator>
41
+ </models>
42
+ </global>
43
+ <adminhtml>
44
+ <translate>
45
+ <modules>
46
+ <Ultimate_ModuleCreator>
47
+ <files>
48
+ <default>Ultimate_ModuleCreator.csv</default>
49
+ </files>
50
+ </Ultimate_ModuleCreator>
51
+ </modules>
52
+ </translate>
53
+ <layout>
54
+ <updates>
55
+ <ultimate_modulecreator>
56
+ <file>ultimate_modulecreator.xml</file>
57
+ </ultimate_modulecreator>
58
+ </updates>
59
+ </layout>
60
+ </adminhtml>
61
+ <admin>
62
+ <routers>
63
+ <adminhtml>
64
+ <args>
65
+ <modules>
66
+ <Ultimate_ModuleCreator before="Mage_Adminhtml">Ultimate_ModuleCreator_Adminhtml</Ultimate_ModuleCreator>
67
+ </modules>
68
+ </args>
69
+ </adminhtml>
70
+ </routers>
71
+ </admin>
72
+ <default>
73
+ <modulecreator>
74
+ <general>
75
+ <help>1</help>
76
+ <collapsed>1</collapsed>
77
+ <tooltips>1</tooltips>
78
+ </general>
79
+ <settings>
80
+ <namespace>Ultimate</namespace>
81
+ <codepool>local</codepool>
82
+ <install>0</install>
83
+ <version>1.0.0</version>
84
+ <system_tab_position>2000</system_tab_position>
85
+ <license><![CDATA[
86
  {{Namespace}}_{{Module}} extension
87
 
88
  NOTICE OF LICENSE
92
  It is also available through the world-wide-web at this URL:
93
  http://opensource.org/licenses/mit-license.php
94
 
95
+ @category {{Namespace}}
96
+ @package {{Namespace}}_{{Module}}
97
+ @copyright Copyright (c) {{Y}}
98
+ @license http://opensource.org/licenses/mit-license.php MIT License
99
  ]]></license>
100
+ </settings>
101
+ <entity>
102
+ <type>flat</type>
103
+ <is_tree>0</is_tree>
104
+ <store>1</store>
105
+ <add_created_to_grid>1</add_created_to_grid>
106
+ <add_updated_to_grid>1</add_updated_to_grid>
107
+ <search>1</search>
108
+ <api>0</api>
109
+ <create_frontend>1</create_frontend>
110
+ <create_list>1</create_list>
111
+ <list_template>two_columns_left</list_template>
112
+ <create_view>1</create_view>
113
+ <view_template>two_columns_left</view_template>
114
+ <add_seo>1</add_seo>
115
+ <url_rewrite>1</url_rewrite>
116
+ <rss>1</rss>
117
+ <widget>1</widget>
118
+ <allow_comment>1</allow_comment>
119
+ <manage_comment>1</manage_comment>
120
+ <link_product>0</link_product>
121
+ <show_on_product>1</show_on_product>
122
+ <show_products>1</show_products>
123
+ <product_attribute>0</product_attribute>
124
+ <product_attribute_scope>1</product_attribute_scope>
125
+ <link_category>0</link_category>
126
+ <show_on_category>1</show_on_category>
127
+ <show_category>1</show_category>
128
+ <category_attribute>0</category_attribute>
129
+ <category_attribute_scope>1</category_attribute_scope>
130
+ <product_attribute_group>General</product_attribute_group>
131
+ <category_attribute_group>General Information</category_attribute_group>
132
+ </entity>
133
+ <attribute>
134
+ <type>text</type>
135
+ <scope>0</scope>
136
+ <required>1</required>
137
+ <editor>0</editor>
138
+ <admin_grid>1</admin_grid>
139
+ <frontend>1</frontend>
140
+ <widget>1</widget>
141
+ <rss>1</rss>
142
+ <options_source>custom</options_source>
143
+ </attribute>
144
+ </modulecreator>
145
+ </default>
146
  </config>
app/code/community/Ultimate/ModuleCreator/etc/jstranslator.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Ultimate_ModuleCreator extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE_UMC.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Ultimate
14
+ * @package Ultimate_ModuleCreator
15
+ * @copyright Copyright (c) 2014
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <jstranslator>
20
+ <are-you-sure translate="message" module="modulecreator">
21
+ <message>Are you sure?</message>
22
+ </are-you-sure>
23
+ <remove-field-attribute translate="message" module="modulecreator">
24
+ <message>Remove field / attribute</message>
25
+ </remove-field-attribute>
26
+ </jstranslator>
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Catalog/Product/Edit/Tab/Entity/01_content.php DELETED
@@ -1,176 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} tab on product edit form
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}} extends Mage_Adminhtml_Block_Widget_Grid{
11
- /**
12
- * Set grid params
13
- * @access protected
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- $this->setId('{{entity}}_grid');
20
- $this->setDefaultSort('position');
21
- $this->setDefaultDir('ASC');
22
- $this->setUseAjax(true);
23
- if ($this->getProduct()->getId()) {
24
- $this->setDefaultFilter(array('in_{{entities}}'=>1));
25
- }
26
- }
27
- /**
28
- * prepare the {{entity}} collection
29
- * @access protected
30
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}}
31
- * {{qwertyuiop}}
32
- */
33
- protected function _prepareCollection() {
34
- $collection = Mage::getResourceModel('{{module}}/{{entity}}_collection');
35
- if ($this->getProduct()->getId()){
36
- $constraint = 'related.product_id='.$this->getProduct()->getId();
37
- }
38
- else{
39
- $constraint = 'related.product_id=0';
40
- }
41
- $collection->getSelect()->joinLeft(
42
- array('related'=>$collection->getTable('{{module}}/{{entity}}_product')),
43
- 'related.{{entity}}_id=main_table.entity_id AND '.$constraint,
44
- array('position')
45
- );
46
- $this->setCollection($collection);
47
- parent::_prepareCollection();
48
- return $this;
49
- }
50
- /**
51
- * prepare mass action grid
52
- * @access protected
53
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}}
54
- * {{qwertyuiop}}
55
- */
56
- protected function _prepareMassaction(){
57
- return $this;
58
- }
59
- /**
60
- * prepare the grid columns
61
- * @access protected
62
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}}
63
- * {{qwertyuiop}}
64
- */
65
- protected function _prepareColumns(){
66
- $this->addColumn('in_{{entities}}', array(
67
- 'header_css_class' => 'a-center',
68
- 'type' => 'checkbox',
69
- 'name' => 'in_{{entities}}',
70
- 'values'=> $this->_getSelected{{Entities}}(),
71
- 'align' => 'center',
72
- 'index' => 'entity_id'
73
- ));
74
- $this->addColumn('{{nameAttribute}}', array(
75
- 'header'=> Mage::helper('{{module}}')->__('{{nameAttributeLabel}}'),
76
- 'align' => 'left',
77
- 'index' => '{{nameAttribute}}',
78
- ));
79
- $this->addColumn('position', array(
80
- 'header' => Mage::helper('{{module}}')->__('Position'),
81
- 'name' => 'position',
82
- 'width' => 60,
83
- 'type' => 'number',
84
- 'validate_class'=> 'validate-number',
85
- 'index' => 'position',
86
- 'editable' => true,
87
- ));
88
- }
89
- /**
90
- * Retrieve selected {{entities}}
91
- * @access protected
92
- * @return array
93
- * {{qwertyuiop}}
94
- */
95
- protected function _getSelected{{Entities}}(){
96
- ${{entities}} = $this->getProduct{{Entities}}();
97
- if (!is_array(${{entities}})) {
98
- ${{entities}} = array_keys($this->getSelected{{Entities}}());
99
- }
100
- return ${{entities}};
101
- }
102
- /**
103
- * Retrieve selected {{entities}}
104
- * @access protected
105
- * @return array
106
- * {{qwertyuiop}}
107
- */
108
- public function getSelected{{Entities}}() {
109
- ${{entities}} = array();
110
- //used helper here in order not to override the product model
111
- $selected = Mage::helper('{{module}}/product')->getSelected{{Entities}}(Mage::registry('current_product'));
112
- if (!is_array($selected)){
113
- $selected = array();
114
- }
115
- foreach ($selected as ${{entity}}) {
116
- ${{entities}}[${{entity}}->getId()] = array('position' => ${{entity}}->getPosition());
117
- }
118
- return ${{entities}};
119
- }
120
- /**
121
- * get row url
122
- * @access public
123
- * @return string
124
- * {{qwertyuiop}}
125
- */
126
- public function getRowUrl($item){
127
- return '#';
128
- }
129
- /**
130
- * get grid url
131
- * @access public
132
- * @return string
133
- * {{qwertyuiop}}
134
- */
135
- public function getGridUrl(){
136
- return $this->getUrl('*/*/{{entities}}Grid', array(
137
- 'id'=>$this->getProduct()->getId()
138
- ));
139
- }
140
- /**
141
- * get the current product
142
- * @access public
143
- * @return Mage_Catalog_Model_Product
144
- * {{qwertyuiop}}
145
- */
146
- public function getProduct(){
147
- return Mage::registry('current_product');
148
- }
149
- /**
150
- * Add filter
151
- * @access protected
152
- * @param object $column
153
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}}
154
- * {{qwertyuiop}}
155
- */
156
- protected function _addColumnFilterToCollection($column){
157
- if ($column->getId() == 'in_{{entities}}') {
158
- ${{entity}}Ids = $this->_getSelected{{Entities}}();
159
- if (empty(${{entity}}Ids)) {
160
- ${{entity}}Ids = 0;
161
- }
162
- if ($column->getFilter()->getValue()) {
163
- $this->getCollection()->addFieldToFilter('entity_id', array('in'=>${{entity}}Ids));
164
- }
165
- else {
166
- if(${{entity}}Ids) {
167
- $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>${{entity}}Ids));
168
- }
169
- }
170
- }
171
- else {
172
- parent::_addColumnFilterToCollection($column);
173
- }
174
- return $this;
175
- }
176
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Catalog/Product/Edit/Tab/Entity/IsTree/01_content.php DELETED
@@ -1,229 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} tab on product edit form
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}} extends {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Tree{
11
- protected $_{{entity}}Ids = null;
12
- protected $_selectedNodes = null;
13
- /**
14
- * constructor
15
- * Specify template to use
16
- * @access public
17
- * @return void
18
- * {{qwertyuiop}}
19
- */
20
- public function __construct(){
21
- parent::__construct();
22
- $this->setTemplate('{{namespace}}_{{module}}/catalog/product/edit/tab/{{entity}}.phtml');
23
- }
24
- /**
25
- * Retrieve currently edited product
26
- * @access public
27
- * @return Mage_Catalog_Model_Product
28
- * {{qwertyuiop}}
29
- */
30
- public function getProduct(){
31
- return Mage::registry('current_product');
32
- }
33
- /**
34
- * Return array with {{entityLabel}} IDs which the product is assigned to
35
- * @access public
36
- * @return array
37
- * {{qwertyuiop}}
38
- */
39
- public function get{{Entity}}Ids(){
40
- if (is_null($this->_{{entity}}Ids)){
41
- $selected{{Entities}} = Mage::helper('{{module}}/product')->getSelected{{Entities}}($this->getProduct());
42
- $ids = array();
43
- foreach ($selected{{Entities}} as ${{entity}}){
44
- $ids[] = ${{entity}}->getId();
45
- }
46
- $this->_{{entity}}Ids = $ids;
47
- }
48
- return $this->_{{entity}}Ids;
49
- }
50
- /**
51
- * Forms string out of get{{Entity}}Ids()
52
- * @access public
53
- * @return string
54
- * {{qwertyuiop}}
55
- */
56
- public function getIdsString(){
57
- return implode(',', $this->get{{Entity}}Ids());
58
- }
59
- /**
60
- * Returns root node and sets 'checked' flag (if necessary)
61
- * @access public
62
- * @return Varien_Data_Tree_Node
63
- * {{qwertyuiop}}
64
- */
65
- public function getRootNode(){
66
- $root = $this->getRoot();
67
- if ($root && in_array($root->getId(), $this->get{{Entity}}Ids())) {
68
- $root->setChecked(true);
69
- }
70
- return $root;
71
- }
72
- /**
73
- * Returns root node
74
- *
75
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}}|null $parentNode{{Entity}}
76
- * @param int $recursionLevel
77
- * @return Varien_Data_Tree_Node
78
- * {{qwertyuiop}}
79
- */
80
- public function getRoot($parentNode{{Entity}} = null, $recursionLevel = 3){
81
- if (!is_null($parentNode{{Entity}}) && $parentNode{{Entity}}->getId()) {
82
- return $this->getNode($parentNode{{Entity}}, $recursionLevel);
83
- }
84
- $root = Mage::registry('{{entity}}_root');
85
- if (is_null($root)) {
86
- $rootId = Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id();
87
-
88
- $ids = $this->getSelectedF{{Entity}}PathIds($rootId);
89
- $tree = Mage::getResourceSingleton('{{module}}/{{entity}}_tree')
90
- ->loadByIds($ids, false, false);
91
- if ($this->get{{Entity}}()) {
92
- $tree->loadEnsuredNodes($this->get{{Entity}}(), $tree->getNodeById($rootId));
93
- }
94
- $tree->addCollectionData($this->get{{Entity}}Collection());
95
- $root = $tree->getNodeById($rootId);
96
- Mage::register('{{entity}}_root', $root);
97
- }
98
- return $root;
99
- }
100
- /**
101
- * Returns array with configuration of current node
102
- * @access protected
103
- * @param Varien_Data_Tree_Node $node
104
- * @param int $level How deep is the node in the tree
105
- * @return array
106
- * {{qwertyuiop}}
107
- */
108
- protected function _getNodeJson($node, $level = 1){
109
- $item = parent::_getNodeJson($node, $level);
110
- if ($this->_isParentSelected{{Entity}}($node)) {
111
- $item['expanded'] = true;
112
- }
113
- if (in_array($node->getId(), $this->get{{Entity}}Ids())) {
114
- $item['checked'] = true;
115
- }
116
- return $item;
117
- }
118
-
119
- /**
120
- * Returns whether $node is a parent (not exactly direct) of a selected node
121
- * @access protected
122
- * @param Varien_Data_Tree_Node $node
123
- * @return bool
124
- * {{qwertyuiop}}
125
- */
126
- protected function _isParentSelected{{Entity}}($node){
127
- $result = false;
128
- // Contains string with all {{entityLabel}} IDs of children (not exactly direct) of the node
129
- $allChildren = $node->getAllChildren();
130
- if ($allChildren) {
131
- $selected{{Entity}}Ids = $this->get{{Entity}}Ids();
132
- $allChildrenArr = explode(',', $allChildren);
133
- for ($i = 0, $cnt = count($selected{{Entity}}Ids); $i < $cnt; $i++) {
134
- $isSelf = $node->getId() == $selected{{Entity}}Ids[$i];
135
- if (!$isSelf && in_array($selected{{Entity}}Ids[$i], $allChildrenArr)) {
136
- $result = true;
137
- break;
138
- }
139
- }
140
- }
141
- return $result;
142
- }
143
-
144
- /**
145
- * Returns array with nodes those are selected (contain current product)
146
- * @access protected
147
- * @return array
148
- * {{qwertyuiop}}
149
- */
150
- protected function _getSelectedNodes(){
151
- if ($this->_selectedNodes === null) {
152
- $this->_selectedNodes = array();
153
- $root = $this->getRoot();
154
- foreach ($this->get{{Entity}}Ids() as ${{entity}}Id) {
155
- if ($root) {
156
- $this->_selectedNodes[] = $root->getTree()->getNodeById(${{entity}}Id);
157
- }
158
- }
159
- }
160
- return $this->_selectedNodes;
161
- }
162
-
163
- /**
164
- * Returns JSON-encoded array of {{entityLabel}} children
165
- * @access public
166
- * @param int ${{entity}}Id
167
- * @return string
168
- * {{qwertyuiop}}
169
- */
170
- public function get{{Entity}}ChildrenJson(${{entity}}Id){
171
- ${{entity}} = Mage::getModel('{{module}}/{{entity}}')->load(${{entity}}Id);
172
- $node = $this->getRoot(${{entity}}, 1)->getTree()->getNodeById(${{entity}}Id);
173
- if (!$node || !$node->hasChildren()) {
174
- return '[]';
175
- }
176
-
177
- $children = array();
178
- foreach ($node->getChildren() as $child) {
179
- $children[] = $this->_getNodeJson($child);
180
- }
181
- return Mage::helper('core')->jsonEncode($children);
182
- }
183
-
184
- /**
185
- * Returns URL for loading tree
186
- * @access public
187
- * @param null $expanded
188
- * @return string
189
- * {{qwertyuiop}}
190
- */
191
- public function getLoadTreeUrl($expanded = null){
192
- return $this->getUrl('*/*/{{entities}}Json', array('_current' => true));
193
- }
194
-
195
- /**
196
- * Return distinct path ids of selected {{entitiesLabel}}
197
- * @access public
198
- * @param mixed $rootId Root {{entityLabel}} Id for context
199
- * @return array
200
- * {{qwertyuiop}}
201
- */
202
- public function getSelected{{Entity}}PathIds($rootId = false){
203
- $ids = array();
204
- ${{entity}}Ids = $this->get{{Entity}}Ids();
205
- if (empty(${{entity}}Ids)) {
206
- return array();
207
- }
208
- $collection = Mage::getResourceModel('{{module}}/{{entity}}_collection');
209
-
210
- if ($rootId) {
211
- $collection->addFieldToFilter('parent_id', $rootId);
212
- }
213
- else {
214
- $collection->addFieldToFilter('entity_id', array('in'=>${{entity}}Ids));
215
- }
216
-
217
- foreach ($collection as $item) {
218
- if ($rootId && !in_array($rootId, $item->getPathIds())) {
219
- continue;
220
- }
221
- foreach ($item->getPathIds() as $id) {
222
- if (!in_array($id, $ids)) {
223
- $ids[] = $id;
224
- }
225
- }
226
- }
227
- return $ids;
228
- }
229
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/01_content.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}} extends Mage_Adminhtml_Block_Widget_Grid_Container{
11
- /**
12
- * constructor
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- $this->_controller = 'adminhtml_{{entity}}';
19
- $this->_blockGroup = '{{module}}';
20
- $this->_headerText = Mage::helper('{{module}}')->__('{{EntityLabel}}');
21
- $this->_addButtonLabel = Mage::helper('{{module}}')->__('Add {{EntityLabel}}');
22
- parent::__construct();
23
- }
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Abstract/01_content.php DELETED
@@ -1,179 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin block abstract
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Abstract extends Mage_Adminhtml_Block_Template{
11
- /**
12
- * get current {{entityLabel}}
13
- * @access public
14
- * @return {{Namespace}}_{{Module}}_Model_Entity
15
- * {{qwertyuiop}}
16
- */
17
- public function get{{Entity}}(){
18
- return Mage::registry('{{entity}}');
19
- }
20
- /**
21
- * get current {{entityLabel}} id
22
- * @access public
23
- * @return int
24
- * {{qwertyuiop}}
25
- */
26
- public function get{{Entity}}Id(){
27
- if ($this->get{{Entity}}()) {
28
- return $this->get{{Entity}}()->getId();
29
- }
30
- return null;
31
- }
32
- /**
33
- * get current {{entityLabel}} {{nameAttributeLabel}}
34
- * @access public
35
- * @return string
36
- * {{qwertyuiop}}
37
- */
38
- public function get{{Entity}}{{EntityNameMagicCode}}(){
39
- return $this->get{{Entity}}()->get{{EntityNameMagicCode}}();
40
- }
41
- /**
42
- * get current {{entityLabel}} path
43
- * @access public
44
- * @return string
45
- * {{qwertyuiop}}
46
- */
47
- public function get{{Entity}}Path(){
48
- if ($this->get{{Entity}}()) {
49
- return $this->get{{Entity}}()->getPath();
50
- }
51
- return Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id();
52
- }
53
- /**
54
- * check if there is a root {{entityLabel}}
55
- * @access public
56
- * @return bool
57
- * {{qwertyuiop}}
58
- */
59
- public function hasRoot{{Entity}}(){
60
- $root = $this->getRoot();
61
- if ($root && $root->getId()) {
62
- return true;
63
- }
64
- return false;
65
- }
66
- /**
67
- * get the root
68
- * @access publoc
69
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}}|null $parentNode{{Entity}}
70
- * @param int $recursionLevel
71
- * @return Varien_Data_Tree_Node
72
- * {{qwertyuiop}}
73
- */
74
- public function getRoot($parentNode{{Entity}} = null, $recursionLevel = 3){
75
- if (!is_null($parentNode{{Entity}}) && $parentNode{{Entity}}->getId()) {
76
- return $this->getNode($parentNode{{Entity}}, $recursionLevel);
77
- }
78
- $root = Mage::registry('root');
79
- if (is_null($root)) {
80
- $rootId = Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id();
81
- $tree = Mage::getResourceSingleton('{{module}}/{{entity}}_tree')
82
- ->load(null, $recursionLevel);
83
- if ($this->get{{Entity}}()) {
84
- $tree->loadEnsuredNodes($this->get{{Entity}}(), $tree->getNodeById($rootId));
85
- }
86
- $tree->addCollectionData($this->get{{Entity}}Collection());
87
- $root = $tree->getNodeById($rootId);
88
- if ($root && $rootId != Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id()) {
89
- $root->setIsVisible(true);
90
- }
91
- elseif($root && $root->getId() == Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id()) {
92
- $root->set{{EntityNameMagicCode}}(Mage::helper('{{module}}')->__('Root'));
93
- }
94
- Mage::register('root', $root);
95
- }
96
- return $root;
97
- }
98
-
99
- /**
100
- * Get and register {{entitiesLabel}} root by specified {{entitiesLabel}} IDs
101
- * @accsess public
102
- * @param array $ids
103
- * @return Varien_Data_Tree_Node
104
- * {{qwertyuiop}}
105
- */
106
- public function getRootByIds($ids){
107
- $root = Mage::registry('root');
108
- if (null === $root) {
109
- ${{entity}}TreeResource = Mage::getResourceSingleton('{{module}}/{{entity}}_tree');
110
- $ids = ${{entity}}TreeResource->getExisting{{Entity}}IdsBySpecifiedIds($ids);
111
- $tree = ${{entity}}TreeResource->loadByIds($ids);
112
- $rootId = Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id();
113
- $root = $tree->getNodeById($rootId);
114
- if ($root && $rootId != Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id()) {
115
- $root->setIsVisible(true);
116
- }
117
- else if($root && $root->getId() == Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id()) {
118
- $root->setName(Mage::helper('{{module}}')->__('Root'));
119
- }
120
- $tree->addCollectionData($this->get{{Entity}}Collection());
121
- Mage::register('root', $root);
122
- }
123
- return $root;
124
- }
125
- /**
126
- * get specific node
127
- * @access public
128
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $parentNode{{Entity}}
129
- * @param $int $recursionLevel
130
- * @return Varien_Data_Tree_Node
131
- * {{qwertyuiop}}
132
- */
133
- public function getNode($parentNode{{Entity}}, $recursionLevel = 2){
134
- $tree = Mage::getResourceModel('{{module}}/{{entity}}_tree');
135
- $nodeId = $parentNode{{Entity}}->getId();
136
- $parentId = $parentNode{{Entity}}->getParentId();
137
- $node = $tree->loadNode($nodeId);
138
- $node->loadChildren($recursionLevel);
139
- if ($node && $nodeId != Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id()) {
140
- $node->setIsVisible(true);
141
- }
142
- elseif($node && $node->getId() == Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id()) {
143
- $node->set{{EntityNameMagicCode}}(Mage::helper('{{module}}')->__('Root'));
144
- }
145
- $tree->addCollectionData($this->get{{Entity}}Collection());
146
- return $node;
147
- }
148
- /**
149
- * get url for saving data
150
- * @access public
151
- * @param array $args
152
- * @return string
153
- * {{qwertyuiop}}
154
- */
155
- public function getSaveUrl(array $args = array()){
156
- $params = array('_current'=>true);
157
- $params = array_merge($params, $args);
158
- return $this->getUrl('*/*/save', $params);
159
- }
160
- /**
161
- * get url for edit
162
- * @access public
163
- * @param array $args
164
- * @return string
165
- * {{qwertyuiop}}
166
- */
167
- public function getEditUrl(){
168
- return $this->getUrl("*/{{module}}_{{entity}}/edit", array('_current'=>true, '_query'=>false, 'id'=>null, 'parent'=>null));
169
- }
170
- /**
171
- * Return root ids
172
- * @access public
173
- * @return array
174
- * {{qwertyuiop}}
175
- */
176
- public function getRootIds(){
177
- return array(Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id());
178
- }
179
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/01_content.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin edit block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{
11
- /**
12
- * constuctor
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- $this->_blockGroup = '{{module}}';
20
- $this->_controller = 'adminhtml_{{entity}}';
21
- $this->_updateButton('save', 'label', Mage::helper('{{module}}')->__('Save {{EntityLabel}}'));
22
- $this->_updateButton('delete', 'label', Mage::helper('{{module}}')->__('Delete {{EntityLabel}}'));
23
- $this->_addButton('saveandcontinue', array(
24
- 'label' => Mage::helper('{{module}}')->__('Save And Continue Edit'),
25
- 'onclick' => 'saveAndContinueEdit()',
26
- 'class' => 'save',
27
- ), -100);
28
- $this->_formScripts[] = "
29
- function saveAndContinueEdit(){
30
- editForm.submit($('edit_form').action+'back/edit/');
31
- }
32
- ";
33
- }
34
- /**
35
- * get the edit form header
36
- * @access public
37
- * @return string
38
- * {{qwertyuiop}}
39
- */
40
- public function getHeaderText(){
41
- if( Mage::registry('{{entity}}_data') && Mage::registry('{{entity}}_data')->getId() ) {
42
- return Mage::helper('{{module}}')->__("Edit {{EntityLabel}} '%s'", $this->htmlEscape(Mage::registry('{{entity}}_data')->get{{EntityNameMagicCode}}()));
43
- }
44
- else {
45
- return Mage::helper('{{module}}')->__('Add {{EntityLabel}}');
46
- }
47
- }
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/01_content.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} edit form
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form extends Mage_Adminhtml_Block_Widget_Form{
11
- /**
12
- * prepare form
13
- * @access protected
14
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form
15
- * {{qwertyuiop}}
16
- */
17
- protected function _prepareForm(){
18
- $form = new Varien_Data_Form(array(
19
- 'id' => 'edit_form',
20
- 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
21
- 'method' => 'post',
22
- 'enctype' => 'multipart/form-data'
23
- )
24
- );
25
- $form->setUseContainer(true);
26
- $this->setForm($form);
27
- return parent::_prepareForm();
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/IsTree/01_top.php DELETED
@@ -1,198 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} edit form
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form extends {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Abstract
11
- {
12
- /**
13
- * Additional buttons on {{entityLabel}} page
14
- * @var array
15
- */
16
- protected $_additionalButtons = array();
17
- /**
18
- * constroctor
19
- * set template
20
- * @access public
21
- * @return void
22
- * {{qwertyuiop}}
23
- */
24
- public function __construct(){
25
- parent::__construct();
26
- $this->setTemplate('{{namespace}}_{{module}}/{{entity}}/edit/form.phtml');
27
- }
28
- /**
29
- * prepare the layout
30
- * @access protected
31
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form
32
- * {{qwertyuiop}}
33
- */
34
- protected function _prepareLayout(){
35
- ${{entity}} = $this->get{{Entity}}();
36
- ${{entity}}Id = (int)${{entity}}->getId();
37
- $this->setChild('tabs',
38
- $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_edit_tabs', 'tabs')
39
- );
40
- $this->setChild('save_button',
41
- $this->getLayout()->createBlock('adminhtml/widget_button')
42
- ->setData(array(
43
- 'label' => Mage::helper('{{module}}')->__('Save {{EntityLabel}}'),
44
- 'onclick' => "{{entity}}Submit('" . $this->getSaveUrl() . "', true)",
45
- 'class' => 'save'
46
- ))
47
- );
48
- // Delete button
49
- if (!in_array(${{entity}}Id, $this->getRootIds())) {
50
- $this->setChild('delete_button',
51
- $this->getLayout()->createBlock('adminhtml/widget_button')
52
- ->setData(array(
53
- 'label' => Mage::helper('{{module}}')->__('Delete {{EntityLabel}}'),
54
- 'onclick' => "{{entity}}Delete('" . $this->getUrl('*/*/delete', array('_current' => true)) . "', true, {${{entity}}Id})",
55
- 'class' => 'delete'
56
- ))
57
- );
58
- }
59
-
60
- // Reset button
61
- $resetPath = ${{entity}} ? '*/*/edit' : '*/*/add';
62
- $this->setChild('reset_button',
63
- $this->getLayout()->createBlock('adminhtml/widget_button')
64
- ->setData(array(
65
- 'label' => Mage::helper('{{module}}')->__('Reset'),
66
- 'onclick' => "{{entity}}Reset('".$this->getUrl($resetPath, array('_current'=>true))."',true)"
67
- ))
68
- );
69
- return parent::_prepareLayout();
70
- }
71
- /**
72
- * get html for delete button
73
- * @access public
74
- * @return string
75
- * {{qwertyuiop}}
76
- */
77
- public function getDeleteButtonHtml(){
78
- return $this->getChildHtml('delete_button');
79
- }
80
- /**
81
- * get html for save button
82
- * @access public
83
- * @return string
84
- * {{qwertyuiop}}
85
- */
86
- public function getSaveButtonHtml(){
87
- return $this->getChildHtml('save_button');
88
- }
89
- /**
90
- * get html for reset button
91
- * @access public
92
- * @return string
93
- * {{qwertyuiop}}
94
- */
95
- public function getResetButtonHtml(){
96
- return $this->getChildHtml('reset_button');
97
- }
98
- /**
99
- * Retrieve additional buttons html
100
- * @access public
101
- * @return string
102
- * {{qwertyuiop}}
103
- */
104
- public function getAdditionalButtonsHtml(){
105
- $html = '';
106
- foreach ($this->_additionalButtons as $childName) {
107
- $html .= $this->getChildHtml($childName);
108
- }
109
- return $html;
110
- }
111
-
112
- /**
113
- * Add additional button
114
- *
115
- * @param string $alias
116
- * @param array $config
117
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form
118
- * {{qwertyuiop}}
119
- */
120
- public function addAdditionalButton($alias, $config){
121
- if (isset($config['name'])) {
122
- $config['element_name'] = $config['name'];
123
- }
124
- $this->setChild($alias . '_button',
125
- $this->getLayout()->createBlock('adminhtml/widget_button')->addData($config));
126
- $this->_additionalButtons[$alias] = $alias . '_button';
127
- return $this;
128
- }
129
- /**
130
- * Remove additional button
131
- * @access public
132
- * @param string $alias
133
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form
134
- * {{qwertyuiop}}
135
- */
136
- public function removeAdditionalButton($alias){
137
- if (isset($this->_additionalButtons[$alias])) {
138
- $this->unsetChild($this->_additionalButtons[$alias]);
139
- unset($this->_additionalButtons[$alias]);
140
- }
141
- return $this;
142
- }
143
- /**
144
- * get html for tabs
145
- * @access public
146
- * @return string
147
- * {{qwertyuiop}}
148
- */
149
- public function getTabsHtml(){
150
- return $this->getChildHtml('tabs');
151
- }
152
- /**
153
- * get the form header
154
- * @access public
155
- * @return string
156
- * {{qwertyuiop}}
157
- */
158
- public function getHeader(){
159
- if ($this->get{{Entity}}Id()) {
160
- return $this->get{{Entity}}{{EntityNameMagicCode}}();
161
- }
162
- else {
163
- return Mage::helper('{{module}}')->__('New Root {{EntityLabel}}');
164
- }
165
- }
166
- /**
167
- * get the delete url
168
- * @access public
169
- * @param array $args
170
- * @return string
171
- * {{qwertyuiop}}
172
- */
173
- public function getDeleteUrl(array $args = array()){
174
- $params = array('_current'=>true);
175
- $params = array_merge($params, $args);
176
- return $this->getUrl('*/*/delete', $params);
177
- }
178
- /**
179
- * Return URL for refresh input element 'path' in form
180
- * @access public
181
- * @param array $args
182
- * @return string
183
- * {{qwertyuiop}}
184
- */
185
- public function getRefreshPathUrl(array $args = array()){
186
- $params = array('_current'=>true);
187
- $params = array_merge($params, $args);
188
- return $this->getUrl('*/*/refreshPath', $params);
189
- }
190
- /**
191
- * check if request is ajax
192
- * @access public
193
- * @return bool
194
- * {{qwertyuiop}}
195
- */
196
- public function isAjax(){
197
- return Mage::app()->getRequest()->isXmlHttpRequest() || Mage::app()->getRequest()->getParam('isAjax');
198
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/IsTree/02_product_relation.php DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * get products json
3
- * @access public
4
- * @return string
5
- * {{qwertyuiop}}
6
- */
7
- public function getProductsJson(){
8
- $products = $this->get{{Entity}}()->getSelectedProducts();
9
- if (!empty($products)) {
10
- $positions = array();
11
- foreach ($products as $product){
12
- $positions[$product->getId()] = $product->getPosition();
13
- }
14
- return Mage::helper('core')->jsonEncode($positions);
15
- }
16
- return '{}';
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/IsTree/03_entity_relation.php DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * get {{siblingsLabel}} in json format
3
- * @access public
4
- * @return string
5
- * {{qwertyuiop}}
6
- */
7
- public function get{{Siblings}}Json(){
8
- ${{siblings}} = $this->get{{Entity}}()->getSelected{{Siblings}}();
9
- if (!empty(${{siblings}})) {
10
- $positions = array();
11
- foreach (${{siblings}} as ${{sibling}}){
12
- $positions[${{sibling}}->getId()] = ${{sibling}}->getPosition();
13
- }
14
- return Mage::helper('core')->jsonEncode($positions);
15
- }
16
- return '{}';
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Form/IsTree/04_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/IsTree/01_content.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin edit form
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{
11
- /**
12
- * constructor
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- $this->_objectId = 'entity_id';
19
- $this->_blockGroup = '{{module}}';
20
- $this->_controller = 'adminhtml_{{entity}}';
21
- $this->_mode = 'edit';
22
- parent::__construct();
23
- $this->setTemplate('{{namespace}}_{{module}}/{{entity}}/edit.phtml');
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/01_top.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} edit form tab
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form{
11
- /**
12
- * prepare the form
13
- * @access protected
14
- * @return {{Module}}_{{Entity}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Form
15
- * {{qwertyuiop}}
16
- */
17
- protected function _prepareForm(){
18
- $form = new Varien_Data_Form();
19
- $form->setHtmlIdPrefix('{{entity}}_');
20
- $form->setFieldNameSuffix('{{entity}}');
21
- $this->setForm($form);
22
- $fieldset = $form->addFieldset('{{entity}}_form', array('legend'=>Mage::helper('{{module}}')->__('{{EntityLabel}}')));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/02_image.php DELETED
@@ -1 +0,0 @@
1
- $fieldset->addType('image', Mage::getConfig()->getBlockClassName('{{module}}/adminhtml_{{entity}}_helper_image'));
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/03_file.php DELETED
@@ -1 +0,0 @@
1
- $fieldset->addType('file', Mage::getConfig()->getBlockClassName('{{module}}/adminhtml_{{entity}}_helper_file'));
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/04_wysiwyg.php DELETED
@@ -1 +0,0 @@
1
- $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig();
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/05_wysiwyg_is_tree.php DELETED
@@ -1 +0,0 @@
1
- $fieldset->addType('editor', Mage::getConfig()->getBlockClassName('{{module}}/adminhtml_helper_wysiwyg'));
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/06_path_tree.php DELETED
@@ -1,20 +0,0 @@
1
- if (!$this->get{{Entity}}()->getId()) {
2
- $parentId = $this->getRequest()->getParam('parent');
3
- if (!$parentId) {
4
- $parentId = Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id();
5
- }
6
- $fieldset->addField('path', 'hidden', array(
7
- 'name' => 'path',
8
- 'value' => $parentId
9
- ));
10
- }
11
- else {
12
- $fieldset->addField('id', 'hidden', array(
13
- 'name' => 'id',
14
- 'value' => $this->get{{Entity}}()->getId()
15
- ));
16
- $fieldset->addField('path', 'hidden', array(
17
- 'name' => 'path',
18
- 'value' => $this->get{{Entity}}()->getPath()
19
- ));
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/07_parents.php DELETED
@@ -1,8 +0,0 @@
1
- $values = Mage::getResourceModel('{{module}}/{{sibling}}_collection')->toOptionArray();
2
- array_unshift($values, array('label'=>'', 'value'=>''));
3
- $fieldset->addField('{{sibling}}_id', 'select', array(
4
- 'label' => Mage::helper('{{module}}')->__('{{SiblingLabel}}'),
5
- 'name' => '{{sibling}}_id',
6
- 'required' => false,
7
- 'values' => $values
8
- ));
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/08_attributes.php DELETED
@@ -1,5 +0,0 @@
1
- {{attributePreElementText}}
2
- $fieldset->addField('{{attributeCode}}', '{{attributeFormType}}', array(
3
- 'label' => Mage::helper('{{module}}')->__('{{attributeLabel}}'),
4
- 'name' => '{{attributeCode}}',
5
- {{attributeFormOptions}} ));
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/09_url_rewrite.php DELETED
@@ -1,7 +0,0 @@
1
- $fieldset->addField('url_key', 'text', array(
2
- 'label' => Mage::helper('{{module}}')->__('Url key'),
3
- 'name' => 'url_key',
4
- 'required' => true,
5
- 'class' => 'required-entry',
6
- 'note' => Mage::helper('{{module}}')->__('Relative to Website Base URL')
7
- ));
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/10_status.php DELETED
@@ -1,14 +0,0 @@
1
- $fieldset->addField('status', 'select', array(
2
- 'label' => Mage::helper('{{module}}')->__('Status'),
3
- 'name' => 'status',
4
- 'values'=> array(
5
- array(
6
- 'value' => 1,
7
- 'label' => Mage::helper('{{module}}')->__('Enabled'),
8
- ),
9
- array(
10
- 'value' => 0,
11
- 'label' => Mage::helper('{{module}}')->__('Disabled'),
12
- ),
13
- ),
14
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/11_rss.php DELETED
@@ -1,14 +0,0 @@
1
- $fieldset->addField('in_rss', 'select', array(
2
- 'label' => Mage::helper('{{module}}')->__('Show in rss'),
3
- 'name' => 'in_rss',
4
- 'values'=> array(
5
- array(
6
- 'value' => 1,
7
- 'label' => Mage::helper('{{module}}')->__('Yes'),
8
- ),
9
- array(
10
- 'value' => 0,
11
- 'label' => Mage::helper('{{module}}')->__('No'),
12
- ),
13
- ),
14
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/12_stores.php DELETED
@@ -1,7 +0,0 @@
1
- if (Mage::app()->isSingleStoreMode()){
2
- $fieldset->addField('store_id', 'hidden', array(
3
- 'name' => 'stores[]',
4
- 'value' => Mage::app()->getStore(true)->getId()
5
- ));
6
- Mage::registry('current_{{entity}}')->setStoreId(Mage::app()->getStore(true)->getId());
7
- }
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/13_add_values_not_tree.php DELETED
@@ -1,9 +0,0 @@
1
- if (Mage::getSingleton('adminhtml/session')->get{{Entity}}Data()){
2
- $form->setValues(Mage::getSingleton('adminhtml/session')->get{{Entity}}Data());
3
- Mage::getSingleton('adminhtml/session')->set{{Entity}}Data(null);
4
- }
5
- elseif (Mage::registry('current_{{entity}}')){
6
- $form->setValues(Mage::registry('current_{{entity}}')->getData());
7
- }
8
- return parent::_prepareForm();
9
- }
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/14_add_values_tree.php DELETED
@@ -1,3 +0,0 @@
1
- $form->addValues($this->get{{Entity}}()->getData());
2
- return parent::_prepareForm();
3
- }
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/15_get_entity_tree.php DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * get the current {{entityLabel}}
3
- * @access public
4
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
5
- */
6
- public function get{{Entity}}(){
7
- return Mage::registry('{{entity}}');
8
- }
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Form/16_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Meta/01_content.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * meta information tab
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Meta extends Mage_Adminhtml_Block_Widget_Form{
11
- /**
12
- * prepare the form
13
- * @access protected
14
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Meta
15
- * {{qwertyuiop}}
16
- */
17
- protected function _prepareForm(){
18
- $form = new Varien_Data_Form();
19
- $form->setFieldNameSuffix('{{entity}}');
20
- $this->setForm($form);
21
- $fieldset = $form->addFieldset('{{entity}}_meta_form', array('legend'=>Mage::helper('{{module}}')->__('Meta information')));
22
- $fieldset->addField('meta_title', 'text', array(
23
- 'label' => Mage::helper('{{module}}')->__('Meta-title'),
24
- 'name' => 'meta_title',
25
- ));
26
- $fieldset->addField('meta_description', 'textarea', array(
27
- 'name' => 'meta_description',
28
- 'label' => Mage::helper('{{module}}')->__('Meta-description'),
29
- ));
30
- $fieldset->addField('meta_keywords', 'textarea', array(
31
- 'name' => 'meta_keywords',
32
- 'label' => Mage::helper('{{module}}')->__('Meta-keywords'),
33
- ));
34
- $form->addValues(Mage::registry('current_{{entity}}')->getData());
35
- return parent::_prepareForm();
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Product/01_content.php DELETED
@@ -1,192 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} - product relation edit block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Product extends Mage_Adminhtml_Block_Widget_Grid{
11
- /**
12
- * Set grid params
13
- * @access protected
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- $this->setId('product_grid');
20
- $this->setDefaultSort('position');
21
- $this->setDefaultDir('ASC');
22
- $this->setUseAjax(true);
23
- if ($this->get{{Entity}}()->getId()) {
24
- $this->setDefaultFilter(array('in_products'=>1));
25
- }
26
- }
27
- /**
28
- * prepare the product collection
29
- * @access protected
30
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Product
31
- * {{qwertyuiop}}
32
- */
33
- protected function _prepareCollection() {
34
- $collection = Mage::getResourceModel('catalog/product_collection');
35
- $collection->addAttributeToSelect('price');
36
- $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
37
- $collection->joinAttribute('product_name', 'catalog_product/name', 'entity_id', null, 'left', $adminStore);
38
- if ($this->get{{Entity}}()->getId()){
39
- $constraint = '{{table}}.{{entity}}_id='.$this->get{{Entity}}()->getId();
40
- }
41
- else{
42
- $constraint = '{{table}}.{{entity}}_id=0';
43
- }
44
- $collection->joinField('position',
45
- '{{module}}/{{entity}}_product',
46
- 'position',
47
- 'product_id=entity_id',
48
- $constraint,
49
- 'left');
50
- $this->setCollection($collection);
51
- parent::_prepareCollection();
52
- return $this;
53
- }
54
- /**
55
- * prepare mass action grid
56
- * @access protected
57
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Product
58
- * {{qwertyuiop}}
59
- */
60
- protected function _prepareMassaction(){
61
- return $this;
62
- }
63
- /**
64
- * prepare the grid columns
65
- * @access protected
66
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Product
67
- * {{qwertyuiop}}
68
- */
69
- protected function _prepareColumns(){
70
- $this->addColumn('in_products', array(
71
- 'header_css_class' => 'a-center',
72
- 'type' => 'checkbox',
73
- 'name' => 'in_products',
74
- 'values'=> $this->_getSelectedProducts(),
75
- 'align' => 'center',
76
- 'index' => 'entity_id'
77
- ));
78
- $this->addColumn('product_name', array(
79
- 'header'=> Mage::helper('catalog')->__('Name'),
80
- 'align' => 'left',
81
- 'index' => 'product_name',
82
- ));
83
- $this->addColumn('sku', array(
84
- 'header'=> Mage::helper('catalog')->__('SKU'),
85
- 'align' => 'left',
86
- 'index' => 'sku',
87
- ));
88
- $this->addColumn('price', array(
89
- 'header'=> Mage::helper('catalog')->__('Price'),
90
- 'type' => 'currency',
91
- 'width' => '1',
92
- 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
93
- 'index' => 'price'
94
- ));
95
- $this->addColumn('position', array(
96
- 'header'=> Mage::helper('catalog')->__('Position'),
97
- 'name' => 'position',
98
- 'width' => 60,
99
- 'type' => 'number',
100
- 'validate_class'=> 'validate-number',
101
- 'index' => 'position',
102
- 'editable' => true,
103
- ));
104
- }
105
- /**
106
- * Retrieve selected products
107
- * @access protected
108
- * @return array
109
- * {{qwertyuiop}}
110
- */
111
- protected function _getSelectedProducts(){
112
- $products = $this->get{{Entity}}Products();
113
- if (!is_array($products)) {
114
- $products = array_keys($this->getSelectedProducts());
115
- }
116
- return $products;
117
- }
118
- /**
119
- * Retrieve selected products
120
- * @access protected
121
- * @return array
122
- * {{qwertyuiop}}
123
- */
124
- public function getSelectedProducts() {
125
- $products = array();
126
- $selected = Mage::registry('current_{{entity}}')->getSelectedProducts();
127
- if (!is_array($selected)){
128
- $selected = array();
129
- }
130
- foreach ($selected as $product) {
131
- $products[$product->getId()] = array('position' => $product->getPosition());
132
- }
133
- return $products;
134
- }
135
- /**
136
- * get row url
137
- * @access public
138
- * @return string
139
- * {{qwertyuiop}}
140
- */
141
- public function getRowUrl($item){
142
- return '#';
143
- }
144
- /**
145
- * get grid url
146
- * @access public
147
- * @return string
148
- * {{qwertyuiop}}
149
- */
150
- public function getGridUrl(){
151
- return $this->getUrl('*/*/productsGrid', array(
152
- 'id'=>$this->get{{Entity}}()->getId()
153
- ));
154
- }
155
- /**
156
- * get the current {{entity}}
157
- * @access public
158
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
159
- * {{qwertyuiop}}
160
- */
161
- public function get{{Entity}}(){
162
- return Mage::registry('current_{{entity}}');
163
- }
164
- /**
165
- * Add filter
166
- * @access protected
167
- * @param object $column
168
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Product
169
- * {{qwertyuiop}}
170
- */
171
- protected function _addColumnFilterToCollection($column){
172
- // Set custom filter for in product flag
173
- if ($column->getId() == 'in_products') {
174
- $productIds = $this->_getSelectedProducts();
175
- if (empty($productIds)) {
176
- $productIds = 0;
177
- }
178
- if ($column->getFilter()->getValue()) {
179
- $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
180
- }
181
- else {
182
- if($productIds) {
183
- $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
184
- }
185
- }
186
- }
187
- else {
188
- parent::_addColumnFilterToCollection($column);
189
- }
190
- return $this;
191
- }
192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Sibling/01_content.php DELETED
@@ -1,175 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{entity}} - {{sibling}} relation edit block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}} extends Mage_Adminhtml_Block_Widget_Grid{
11
- /**
12
- * Set grid params
13
- * @access protected
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- $this->setId('{{sibling}}_grid');
20
- $this->setDefaultSort('position');
21
- $this->setDefaultDir('ASC');
22
- $this->setUseAjax(true);
23
- if ($this->get{{Entity}}()->getId()) {
24
- $this->setDefaultFilter(array('in_{{siblings}}'=>1));
25
- }
26
- }
27
- /**
28
- * prepare the {{sibling}} collection
29
- * @access protected
30
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}}
31
- * {{qwertyuiop}}
32
- */
33
- protected function _prepareCollection() {
34
- $collection = Mage::getResourceModel('{{module}}/{{sibling}}_collection');
35
- if ($this->get{{Entity}}()->getId()){
36
- $constraint = 'related.{{entity}}_id='.$this->get{{Entity}}()->getId();
37
- }
38
- else{
39
- $constraint = 'related.{{entity}}_id=0';
40
- }
41
- $collection->getSelect()->joinLeft(
42
- array('related'=>$collection->getTable('{{module}}/{{entity}}_{{sibling}}')),
43
- 'related.{{sibling}}_id=main_table.entity_id AND '.$constraint,
44
- array('position'));
45
- $this->setCollection($collection);
46
- parent::_prepareCollection();
47
- return $this;
48
- }
49
- /**
50
- * prepare mass action grid
51
- * @access protected
52
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}}
53
- * {{qwertyuiop}}
54
- */
55
- protected function _prepareMassaction(){
56
- return $this;
57
- }
58
- /**
59
- * prepare the grid columns
60
- * @access protected
61
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}}
62
- * {{qwertyuiop}}
63
- */
64
- protected function _prepareColumns(){
65
- $this->addColumn('in_{{siblings}}', array(
66
- 'header_css_class' => 'a-center',
67
- 'type' => 'checkbox',
68
- 'name' => 'in_{{siblings}}',
69
- 'values'=> $this->_getSelected{{Siblings}}(),
70
- 'align' => 'center',
71
- 'index' => 'entity_id'
72
- ));
73
- $this->addColumn('{{siblingNameAttribute}}', array(
74
- 'header'=> Mage::helper('{{module}}')->__('{{siblingNameAttributeLabel}}'),
75
- 'align' => 'left',
76
- 'index' => '{{siblingNameAttribute}}',
77
- ));
78
- $this->addColumn('position', array(
79
- 'header'=> Mage::helper('{{module}}')->__('Position'),
80
- 'name' => 'position',
81
- 'width' => 60,
82
- 'type' => 'number',
83
- 'validate_class'=> 'validate-number',
84
- 'index' => 'position',
85
- 'editable' => true,
86
- ));
87
- }
88
- /**
89
- * Retrieve selected {{siblings}}
90
- * @access protected
91
- * @return array
92
- * {{qwertyuiop}}
93
- */
94
- protected function _getSelected{{Siblings}}(){
95
- ${{siblings}} = $this->get{{Entity}}{{Siblings}}();
96
- if (!is_array(${{siblings}})) {
97
- ${{siblings}} = array_keys($this->getSelected{{Siblings}}());
98
- }
99
- return ${{siblings}};
100
- }
101
- /**
102
- * Retrieve selected {{siblings}}
103
- * @access protected
104
- * @return array
105
- * {{qwertyuiop}}
106
- */
107
- public function getSelected{{Siblings}}() {
108
- ${{siblings}} = array();
109
- $selected = Mage::registry('current_{{entity}}')->getSelected{{Siblings}}();
110
- if (!is_array($selected)){
111
- $selected = array();
112
- }
113
- foreach ($selected as ${{sibling}}) {
114
- ${{siblings}}[${{sibling}}->getId()] = array('position' => ${{sibling}}->getPosition());
115
- }
116
- return ${{siblings}};
117
- }
118
- /**
119
- * get row url
120
- * @access public
121
- * @return string
122
- * {{qwertyuiop}}
123
- */
124
- public function getRowUrl($item){
125
- return '#';
126
- }
127
- /**
128
- * get grid url
129
- * @access public
130
- * @return string
131
- * {{qwertyuiop}}
132
- */
133
- public function getGridUrl(){
134
- return $this->getUrl('*/*/{{siblings}}Grid', array(
135
- 'id'=>$this->get{{Entity}}()->getId()
136
- ));
137
- }
138
- /**
139
- * get the current {{entity}}
140
- * @access public
141
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
142
- * {{qwertyuiop}}
143
- */
144
- public function get{{Entity}}(){
145
- return Mage::registry('current_{{entity}}');
146
- }
147
- /**
148
- * Add filter
149
- * @access protected
150
- * @param object $column
151
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}}
152
- * {{qwertyuiop}}
153
- */
154
- protected function _addColumnFilterToCollection($column){
155
- // Set custom filter for in product flag
156
- if ($column->getId() == 'in_{{siblings}}') {
157
- ${{sibling}}Ids = $this->_getSelected{{Siblings}}();
158
- if (empty(${{sibling}}Ids)) {
159
- ${{sibling}}Ids = 0;
160
- }
161
- if ($column->getFilter()->getValue()) {
162
- $this->getCollection()->addFieldToFilter('entity_id', array('in'=>${{sibling}}Ids));
163
- }
164
- else {
165
- if(${{sibling}}Ids) {
166
- $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>${{sibling}}Ids));
167
- }
168
- }
169
- }
170
- else {
171
- parent::_addColumnFilterToCollection($column);
172
- }
173
- return $this;
174
- }
175
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Sibling/IsTree/01_content.php DELETED
@@ -1,224 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{entity}} - {{sibling}} relation edit block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}} extends {{Namespace}}_{{Module}}_Block_Adminhtml_{{Sibling}}_Tree{
11
- protected $_{{sibling}}Ids = null;
12
- protected $_selectedNodes = null;
13
-
14
- /**
15
- * constructor
16
- * Specify template to use
17
- * @access public
18
- * @return void
19
- * {{qwertyuiop}}
20
- */
21
- public function __construct(){
22
- parent::__construct();
23
- $this->setTemplate('{{namespace}}_{{module}}/{{entity}}/edit/tab/{{sibling}}.phtml');
24
- }
25
- /**
26
- * Retrieve currently edited {{entityLabel}}
27
- * @access public
28
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
29
- * {{qwertyuiop}}
30
- */
31
- public function get{{Entity}}(){
32
- return Mage::registry('current_{{entity}}');
33
- }
34
- /**
35
- * Return array with {{siblingsLabel}} IDs which the {{entityLabel}} is linked to
36
- * @access public
37
- * @return array
38
- * {{qwertyuiop}}
39
- */
40
- public function get{{Sibling}}Ids(){
41
- if (is_null($this->_{{sibling}}Ids)){
42
- ${{siblings}} = $this->get{{Entity}}()->getSelected{{Siblings}}();
43
- $ids = array();
44
- foreach (${{siblings}} as ${{sibling}}){
45
- $ids[] = ${{sibling}}->getId();
46
- }
47
- $this->_{{sibling}}Ids = $ids;
48
- }
49
- return $this->_{{sibling}}Ids;
50
- }
51
- /**
52
- * Forms string out of get{{Sibling}}Ids()
53
- * @access public
54
- * @return string
55
- * {{qwertyuiop}}
56
- */
57
- public function getIdsString(){
58
- return implode(',', $this->get{{Sibling}}Ids());
59
- }
60
- /**
61
- * Returns root node and sets 'checked' flag (if necessary)
62
- * @access public
63
- * @return Varien_Data_Tree_Node
64
- * {{qwertyuiop}}
65
- */
66
- public function getRootNode(){
67
- $root = $this->getRoot();
68
- if ($root && in_array($root->getId(), $this->get{{Sibling}}Ids())) {
69
- $root->setChecked(true);
70
- }
71
- return $root;
72
- }
73
-
74
- /**
75
- * Returns root node
76
- *
77
- * @param {{Namespace}}_{{Module}}_Model_{{Sibling}}|null $parentNode{{Sibling}}
78
- * @param int $recursionLevel
79
- * @return Varien_Data_Tree_Node
80
- * {{qwertyuiop}}
81
- */
82
- public function getRoot($parentNode{{Sibling}} = null, $recursionLevel = 3){
83
- if (!is_null($parentNode{{Sibling}}) && $parentNode{{Sibling}}->getId()) {
84
- return $this->getNode($parentNode{{Sibling}}, $recursionLevel);
85
- }
86
- $root = Mage::registry('{{sibling}}_root');
87
- if (is_null($root)) {
88
- $rootId = Mage::helper('{{module}}/{{sibling}}')->getRoot{{Sibling}}Id();
89
- $ids = $this->getSelected{{Sibling}}PathIds($rootId);
90
- $tree = Mage::getResourceSingleton('{{module}}/{{sibling}}_tree')
91
- ->loadByIds($ids, false, false);
92
- if ($this->get{{Sibling}}()) {
93
- $tree->loadEnsuredNodes($this->get{{Sibling}}(), $tree->getNodeById($rootId));
94
- }
95
- $tree->addCollectionData($this->get{{Sibling}}Collection());
96
- $root = $tree->getNodeById($rootId);
97
- Mage::register('{{sibling}}_root', $root);
98
- }
99
- return $root;
100
- }
101
- /**
102
- * Returns array with configuration of current node
103
- * @access public
104
- * @param Varien_Data_Tree_Node $node
105
- * @param int $level How deep is the node in the tree
106
- * @return array
107
- * {{qwertyuiop}}
108
- */
109
- protected function _getNodeJson($node, $level = 1){
110
- $item = parent::_getNodeJson($node, $level);
111
- if ($this->_isParentSelected{{Sibling}}($node)) {
112
- $item['expanded'] = true;
113
- }
114
- if (in_array($node->getId(), $this->get{{Sibling}}Ids())) {
115
- $item['checked'] = true;
116
- }
117
- return $item;
118
- }
119
- /**
120
- * Returns whether $node is a parent (not exactly direct) of a selected node
121
- * @access public
122
- * @param Varien_Data_Tree_Node $node
123
- * @return bool
124
- * {{qwertyuiop}}
125
- */
126
- protected function _isParentSelected{{Sibling}}($node){
127
- $result = false;
128
- // Contains string with all {{siblingLabel}} IDs of children (not exactly direct) of the node
129
- $allChildren = $node->getAllChildren();
130
- if ($allChildren) {
131
- $selected{{Sibling}}Ids = $this->get{{Sibling}}Ids();
132
- $allChildrenArr = explode(',', $allChildren);
133
- for ($i = 0, $cnt = count($selected{{Sibling}}Ids); $i < $cnt; $i++) {
134
- $isSelf = $node->getId() == $selected{{Sibling}}Ids[$i];
135
- if (!$isSelf && in_array($selected{{Sibling}}Ids[$i], $allChildrenArr)) {
136
- $result = true;
137
- break;
138
- }
139
- }
140
- }
141
- return $result;
142
- }
143
- /**
144
- * Returns array with nodes those are selected (contain current {{entityLabel}})
145
- *
146
- * @return array
147
- */
148
- protected function _getSelectedNodes(){
149
- if ($this->_selectedNodes === null) {
150
- $this->_selectedNodes = array();
151
- $root = $this->getRoot();
152
- foreach ($this->get{{Sibling}}Ids() as ${{sibling}}Id) {
153
- if ($root) {
154
- $this->_selectedNodes[] = $root->getTree()->getNodeById(${{sibling}}Id);
155
- }
156
- }
157
- }
158
- return $this->_selectedNodes;
159
- }
160
-
161
- /**
162
- * Returns JSON-encoded array of {{siblingsLabel}} children
163
- * @access public
164
- * @param int ${{sibling}}Id
165
- * @return string
166
- * {{qwertyuiop}}
167
- */
168
- public function get{{Sibling}}ChildrenJson(${{sibling}}Id){
169
- ${{sibling}} = Mage::getModel('{{module}}/{{sibling}}')->load(${{sibling}}Id);
170
- $node = $this->getRoot(${{sibling}}, 1)->getTree()->getNodeById(${{sibling}}Id);
171
- if (!$node || !$node->hasChildren()) {
172
- return '[]';
173
- }
174
- $children = array();
175
- foreach ($node->getChildren() as $child) {
176
- $children[] = $this->_getNodeJson($child);
177
- }
178
- return Mage::helper('core')->jsonEncode($children);
179
- }
180
- /**
181
- * Returns URL for loading tree
182
- * @access public
183
- * @param null $expanded
184
- * @return string
185
- * {{qwertyuiop}}
186
- */
187
- public function getLoadTreeUrl($expanded = null){
188
- return $this->getUrl('*/*/{{siblings}}Json', array('_current' => true));
189
- }
190
-
191
- /**
192
- * Return distinct path ids of selected {{siblingsLabel}}
193
- * @access public
194
- * @param mixed $rootId Root {{siblingLabel}} Id for context
195
- * @return array
196
- * {{qwertyuiop}}
197
- */
198
- public function getSelected{{Sibling}}PathIds($rootId = false){
199
- $ids = array();
200
- ${{sibling}}Ids = $this->get{{Sibling}}Ids();
201
- if (empty(${{sibling}}Ids)) {
202
- return array();
203
- }
204
- $collection = Mage::getResourceModel('{{module}}/{{sibling}}_collection');
205
- if ($rootId) {
206
- $collection->addFieldToFilter('parent_id', $rootId);
207
- }
208
- else {
209
- $collection->addFieldToFilter('entity_id', array('in'=>${{sibling}}Ids));
210
- }
211
-
212
- foreach ($collection as $item) {
213
- if ($rootId && !in_array($rootId, $item->getPathIds())) {
214
- continue;
215
- }
216
- foreach ($item->getPathIds() as $id) {
217
- if (!in_array($id, $ids)) {
218
- $ids[] = $id;
219
- }
220
- }
221
- }
222
- return $ids;
223
- }
224
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tab/Stores/01_content.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * store selection tab
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form{
11
- /**
12
- * prepare the form
13
- * @access protected
14
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Stores
15
- * {{qwertyuiop}}
16
- */
17
- protected function _prepareForm(){
18
- $form = new Varien_Data_Form();
19
- $form->setFieldNameSuffix('{{entity}}');
20
- $this->setForm($form);
21
- $fieldset = $form->addFieldset('{{entity}}_stores_form', array('legend'=>Mage::helper('{{module}}')->__('Store views')));
22
- $field = $fieldset->addField('store_id', 'multiselect', array(
23
- 'name' => 'stores[]',
24
- 'label' => Mage::helper('{{module}}')->__('Store Views'),
25
- 'title' => Mage::helper('{{module}}')->__('Store Views'),
26
- 'required' => true,
27
- 'values'=> Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
28
- ));
29
- $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
30
- $field->setRenderer($renderer);
31
- $form->addValues(Mage::registry('current_{{entity}}')->getData());
32
- return parent::_prepareForm();
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/01_top.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin edit tabs
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs{
11
- /**
12
- * constructor
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- $this->setId('{{entity}}_tabs');
20
- $this->setDestElementId('edit_form');
21
- $this->setTitle(Mage::helper('{{module}}')->__('{{EntityLabel}}'));
22
- }
23
- /**
24
- * before render html
25
- * @access protected
26
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tabs
27
- * {{qwertyuiop}}
28
- */
29
- protected function _beforeToHtml(){
30
- $this->addTab('form_{{entity}}', array(
31
- 'label' => Mage::helper('{{module}}')->__('{{EntityLabel}}'),
32
- 'title' => Mage::helper('{{module}}')->__('{{EntityLabel}}'),
33
- 'content' => $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_edit_tab_form')->toHtml(),
34
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/02_seo.php DELETED
@@ -1,5 +0,0 @@
1
- $this->addTab('form_meta_{{entity}}', array(
2
- 'label' => Mage::helper('{{module}}')->__('Meta'),
3
- 'title' => Mage::helper('{{module}}')->__('Meta'),
4
- 'content' => $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_edit_tab_meta')->toHtml(),
5
- ));
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/03_stores.php DELETED
@@ -1,7 +0,0 @@
1
- if (!Mage::app()->isSingleStoreMode()){
2
- $this->addTab('form_store_{{entity}}', array(
3
- 'label' => Mage::helper('{{module}}')->__('Store views'),
4
- 'title' => Mage::helper('{{module}}')->__('Store views'),
5
- 'content' => $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_edit_tab_stores')->toHtml(),
6
- ));
7
- }
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/04_relations_tabs.php DELETED
@@ -1,5 +0,0 @@
1
- $this->addTab('{{siblings}}', array(
2
- 'label' => Mage::helper('{{module}}')->__('{{SiblingsLabel}}'),
3
- 'url' => $this->getUrl('*/*/{{siblings}}', array('_current' => true)),
4
- 'class' => 'ajax'
5
- ));
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/05_product_relation.php DELETED
@@ -1,5 +0,0 @@
1
- $this->addTab('products', array(
2
- 'label' => Mage::helper('{{module}}')->__('Associated products'),
3
- 'url' => $this->getUrl('*/*/products', array('_current' => true)),
4
- 'class' => 'ajax'
5
- ));
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/06_footer.php DELETED
@@ -1,3 +0,0 @@
1
- return parent::_beforeToHtml();
2
- }
3
- }
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/01_top.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin edit tabs
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs{
11
- /**
12
- * Initialize Tabs
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- $this->setId('{{entity}}_info_tabs');
20
- $this->setDestElementId('{{entity}}_tab_content');
21
- $this->setTitle(Mage::helper('{{module}}')->__('{{EntityLabel}}'));
22
- $this->setTemplate('widget/tabshoriz.phtml');
23
- }
24
- /**
25
- * Retrieve {{entityLabel}} entity
26
- * @access public
27
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
28
- * {{qwertyuiop}}
29
- */
30
- public function get{{Entity}}(){
31
- return Mage::registry('current_{{entity}}');
32
- }
33
- /**
34
- * Prepare Layout Content
35
- * @access public
36
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tabs
37
- */
38
- protected function _prepareLayout(){
39
- $this->addTab('form_{{entity}}', array(
40
- 'label' => Mage::helper('{{module}}')->__('{{EntityLabel}}'),
41
- 'title' => Mage::helper('{{module}}')->__('{{EntityLabel}}'),
42
- 'content' => $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_edit_tab_form')->toHtml(),
43
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/02_seo.php DELETED
@@ -1,5 +0,0 @@
1
- $this->addTab('form_meta_{{entity}}', array(
2
- 'label' => Mage::helper('{{module}}')->__('Meta'),
3
- 'title' => Mage::helper('{{module}}')->__('Meta'),
4
- 'content' => $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_edit_tab_meta')->toHtml(),
5
- ));
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/03_stores.php DELETED
@@ -1,7 +0,0 @@
1
- if (!Mage::app()->isSingleStoreMode()){
2
- $this->addTab('form_store_{{entity}}', array(
3
- 'label' => Mage::helper('{{module}}')->__('Store views'),
4
- 'title' => Mage::helper('{{module}}')->__('Store views'),
5
- 'content' => $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_edit_tab_stores')->toHtml(),
6
- ));
7
- }
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/04_relations_tabs.php DELETED
@@ -1,4 +0,0 @@
1
- $this->addTab('{{siblings}}', array(
2
- 'label' => Mage::helper('{{module}}')->__('{{SiblingsLabel}}'),
3
- 'content' => $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_edit_tab_{{sibling}}','{{entity}}.{{sibling}}.grid')->toHtml(),
4
- ));
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/05_product_relation.php DELETED
@@ -1,4 +0,0 @@
1
- $this->addTab('products', array(
2
- 'label' => Mage::helper('{{module}}')->__('Associated Products'),
3
- 'content' => $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_edit_tab_product','{{entity}}.product.grid')->toHtml(),
4
- ));
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Edit/Tabs/IsTree/06_footer.php DELETED
@@ -1,3 +0,0 @@
1
- return parent::_prepareLayout();
2
- }
3
- }
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/01_top.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin grid block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid extends Mage_Adminhtml_Block_Widget_Grid{
11
- /**
12
- * constructor
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- $this->setId('{{entity}}Grid');
20
- $this->setDefaultSort('entity_id');
21
- $this->setDefaultDir('ASC');
22
- $this->setSaveParametersInSession(true);
23
- $this->setUseAjax(true);
24
- }
25
- /**
26
- * prepare collection
27
- * @access protected
28
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid
29
- * {{qwertyuiop}}
30
- */
31
- protected function _prepareCollection(){
32
- $collection = Mage::getModel('{{module}}/{{entity}}')->getCollection();
33
- $this->setCollection($collection);
34
- return parent::_prepareCollection();
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/02_columns_top.php DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * prepare grid collection
3
- * @access protected
4
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid
5
- * {{qwertyuiop}}
6
- */
7
- protected function _prepareColumns(){
8
- $this->addColumn('entity_id', array(
9
- 'header' => Mage::helper('{{module}}')->__('Id'),
10
- 'index' => 'entity_id',
11
- 'type' => 'number'
12
- ));
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/03_parents.php DELETED
@@ -1,7 +0,0 @@
1
- ${{siblings}} = Mage::getResourceModel('{{module}}/{{sibling}}_collection')->toOptionHash();
2
- $this->addColumn('{{sibling}}_id', array(
3
- 'header' => Mage::helper('{{module}}')->__('{{SiblingLabel}}'),
4
- 'index' => '{{sibling}}_id',
5
- 'type' => 'options',
6
- 'options' => ${{siblings}}
7
- ));
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/04_grid_attributes.php DELETED
@@ -1,5 +0,0 @@
1
- $this->addColumn('{{attributeCode}}', array(
2
- 'header'=> Mage::helper('{{module}}')->__('{{attributeLabel}}'),
3
- 'index' => '{{attributeCode}}',
4
- {{attributeColumnOptions}}
5
- ));
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/05_url_rewrite.php DELETED
@@ -1,4 +0,0 @@
1
- $this->addColumn('url_key', array(
2
- 'header' => Mage::helper('{{module}}')->__('URL key'),
3
- 'index' => 'url_key',
4
- ));
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/06_grid_status.php DELETED
@@ -1,9 +0,0 @@
1
- $this->addColumn('status', array(
2
- 'header' => Mage::helper('{{module}}')->__('Status'),
3
- 'index' => 'status',
4
- 'type' => 'options',
5
- 'options' => array(
6
- '1' => Mage::helper('{{module}}')->__('Enabled'),
7
- '0' => Mage::helper('{{module}}')->__('Disabled'),
8
- )
9
- ));
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/07_stores.php DELETED
@@ -1,11 +0,0 @@
1
- if (!Mage::app()->isSingleStoreMode()) {
2
- $this->addColumn('store_id', array(
3
- 'header'=> Mage::helper('{{module}}')->__('Store Views'),
4
- 'index' => 'store_id',
5
- 'type' => 'store',
6
- 'store_all' => true,
7
- 'store_view'=> true,
8
- 'sortable' => false,
9
- 'filter_condition_callback'=> array($this, '_filterStoreCondition'),
10
- ));
11
- }
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/08_created_at.php DELETED
@@ -1,6 +0,0 @@
1
- $this->addColumn('created_at', array(
2
- 'header' => Mage::helper('{{module}}')->__('Created at'),
3
- 'index' => 'created_at',
4
- 'width' => '120px',
5
- 'type' => 'datetime',
6
- ));
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/09_updated_at.php DELETED
@@ -1,6 +0,0 @@
1
- $this->addColumn('updated_at', array(
2
- 'header' => Mage::helper('{{module}}')->__('Updated at'),
3
- 'index' => 'updated_at',
4
- 'width' => '120px',
5
- 'type' => 'datetime',
6
- ));
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/10_grid_actions.php DELETED
@@ -1,17 +0,0 @@
1
- $this->addColumn('action',
2
- array(
3
- 'header'=> Mage::helper('{{module}}')->__('Action'),
4
- 'width' => '100',
5
- 'type' => 'action',
6
- 'getter'=> 'getId',
7
- 'actions' => array(
8
- array(
9
- 'caption' => Mage::helper('{{module}}')->__('Edit'),
10
- 'url' => array('base'=> '*/*/edit'),
11
- 'field' => 'id'
12
- )
13
- ),
14
- 'filter'=> false,
15
- 'is_system' => true,
16
- 'sortable' => false,
17
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/11_grid_export.php DELETED
@@ -1,3 +0,0 @@
1
- $this->addExportType('*/*/exportCsv', Mage::helper('{{module}}')->__('CSV'));
2
- $this->addExportType('*/*/exportExcel', Mage::helper('{{module}}')->__('Excel'));
3
- $this->addExportType('*/*/exportXml', Mage::helper('{{module}}')->__('XML'));
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/12_columns_footer.php DELETED
@@ -1,2 +0,0 @@
1
- return parent::_prepareColumns();
2
- }
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/13_mass_action_top.php DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * prepare mass action
3
- * @access protected
4
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid
5
- * {{qwertyuiop}}
6
- */
7
- protected function _prepareMassaction(){
8
- $this->setMassactionIdField('entity_id');
9
- $this->getMassactionBlock()->setFormFieldName('{{entity}}');
10
- $this->getMassactionBlock()->addItem('delete', array(
11
- 'label'=> Mage::helper('{{module}}')->__('Delete'),
12
- 'url' => $this->getUrl('*/*/massDelete'),
13
- 'confirm' => Mage::helper('{{module}}')->__('Are you sure?')
14
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/14_mass_action_status.php DELETED
@@ -1,16 +0,0 @@
1
- $this->getMassactionBlock()->addItem('status', array(
2
- 'label'=> Mage::helper('{{module}}')->__('Change status'),
3
- 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
4
- 'additional' => array(
5
- 'status' => array(
6
- 'name' => 'status',
7
- 'type' => 'select',
8
- 'class' => 'required-entry',
9
- 'label' => Mage::helper('{{module}}')->__('Status'),
10
- 'values' => array(
11
- '1' => Mage::helper('{{module}}')->__('Enabled'),
12
- '0' => Mage::helper('{{module}}')->__('Disabled'),
13
- )
14
- )
15
- )
16
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/15_mass_action_flags.php DELETED
@@ -1,16 +0,0 @@
1
- $this->getMassactionBlock()->addItem('{{attributeCode}}', array(
2
- 'label'=> Mage::helper('{{module}}')->__('Change {{attributeLabel}}'),
3
- 'url' => $this->getUrl('*/*/mass{{AttributeMagicCode}}', array('_current'=>true)),
4
- 'additional' => array(
5
- 'flag_{{attributeCode}}' => array(
6
- 'name' => 'flag_{{attributeCode}}',
7
- 'type' => 'select',
8
- 'class' => 'required-entry',
9
- 'label' => Mage::helper('{{module}}')->__('{{attributeLabel}}'),
10
- 'values' => array(
11
- '1' => Mage::helper('{{module}}')->__('Yes'),
12
- '0' => Mage::helper('{{module}}')->__('No'),
13
- )
14
- )
15
- )
16
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/16_mass_action_parents.php DELETED
@@ -1,17 +0,0 @@
1
- $values = Mage::getResourceModel('{{module}}/{{sibling}}_collection')->toOptionHash();
2
- $values = array_reverse($values, true);
3
- $values[''] = '';
4
- $values = array_reverse($values, true);
5
- $this->getMassactionBlock()->addItem('{{sibling}}_id', array(
6
- 'label'=> Mage::helper('{{module}}')->__('Change {{SiblingLabel}}'),
7
- 'url' => $this->getUrl('*/*/mass{{Sibling}}Id', array('_current'=>true)),
8
- 'additional' => array(
9
- 'flag_{{sibling}}_id' => array(
10
- 'name' => 'flag_{{sibling}}_id',
11
- 'type' => 'select',
12
- 'class' => 'required-entry',
13
- 'label' => Mage::helper('{{module}}')->__('{{SiblingLabel}}'),
14
- 'values' => $values
15
- )
16
- )
17
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Grid/17_footer.php DELETED
@@ -1,47 +0,0 @@
1
- return $this;
2
- }
3
- /**
4
- * get the row url
5
- * @access public
6
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}}
7
- * @return string
8
- * {{qwertyuiop}}
9
- */
10
- public function getRowUrl($row){
11
- return $this->getUrl('*/*/edit', array('id' => $row->getId()));
12
- }
13
- /**
14
- * get the grid url
15
- * @access public
16
- * @return string
17
- * {{qwertyuiop}}
18
- */
19
- public function getGridUrl(){
20
- return $this->getUrl('*/*/grid', array('_current'=>true));
21
- }
22
- /**
23
- * after collection load
24
- * @access protected
25
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid
26
- * {{qwertyuiop}}
27
- */
28
- protected function _afterLoadCollection(){
29
- $this->getCollection()->walk('afterLoad');
30
- parent::_afterLoadCollection();
31
- }
32
- /**
33
- * filter store column
34
- * @access protected
35
- * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection
36
- * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
37
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid
38
- * {{qwertyuiop}}
39
- */
40
- protected function _filterStoreCondition($collection, $column){
41
- if (!$value = $column->getFilter()->getValue()) {
42
- return;
43
- }
44
- $collection->addStoreFilter($value);
45
- return $this;
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Helper/File/01_content.php DELETED
@@ -1,87 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} file field renderer helper
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Helper_File extends Varien_Data_Form_Element_Abstract{
11
- /**
12
- * constructor
13
- * @access public
14
- * @param array $data
15
- * @return void
16
- * {{qwertyuiop}}
17
- */
18
- public function __construct($data){
19
- parent::__construct($data);
20
- $this->setType('file');
21
- }
22
- /**
23
- * get element html
24
- * @access public
25
- * @return string
26
- * {{qwertyuiop}}
27
- */
28
- public function getElementHtml(){
29
- $html = '';
30
- $this->addClass('input-file');
31
- $html.= parent::getElementHtml();
32
- if ($this->getValue()) {
33
- $url = $this->_getUrl();
34
- if( !preg_match("/^http\:\/\/|https\:\/\//", $url) ) {
35
- $url = Mage::helper('{{module}}/{{entity}}')->getFileBaseUrl() . $url;
36
- }
37
- $html .= '<br /><a href="'.$url.'">'.$this->_getUrl().'</a> ';
38
- }
39
- $html.= $this->_getDeleteCheckbox();
40
- return $html;
41
- }
42
- /**
43
- * get the delete checkbox HTML
44
- * @access protected
45
- * @return string
46
- * {{qwertyuiop}}
47
- */
48
- protected function _getDeleteCheckbox(){
49
- $html = '';
50
- if ($this->getValue()) {
51
- $label = Mage::helper('{{module}}')->__('Delete File');
52
- $html .= '<span class="delete-image">';
53
- $html .= '<input type="checkbox" name="'.parent::getName().'[delete]" value="1" class="checkbox" id="'.$this->getHtmlId().'_delete"'.($this->getDisabled() ? ' disabled="disabled"': '').'/>';
54
- $html .= '<label for="'.$this->getHtmlId().'_delete"'.($this->getDisabled() ? ' class="disabled"' : '').'> '.$label.'</label>';
55
- $html .= $this->_getHiddenInput();
56
- $html .= '</span>';
57
- }
58
- return $html;
59
- }
60
- /**
61
- * get the hidden input
62
- * @access protected
63
- * @return string
64
- * {{qwertyuiop}}
65
- */
66
- protected function _getHiddenInput(){
67
- return '<input type="hidden" name="'.parent::getName().'[value]" value="'.$this->getValue().'" />';
68
- }
69
- /**
70
- * get the file url
71
- * @access protected
72
- * @return string
73
- * {{qwertyuiop}}
74
- */
75
- protected function _getUrl(){
76
- return $this->getValue();
77
- }
78
- /**
79
- * get the name
80
- * @access public
81
- * @return string
82
- * {{qwertyuiop}}
83
- */
84
- public function getName(){
85
- return $this->getData('name');
86
- }
87
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Helper/Image/01_content.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} image field renderer helper
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Helper_Image extends Varien_Data_Form_Element_Image{
11
- /**
12
- * get the url of the image
13
- * @access protected
14
- * @return string
15
- * {{qwertyuiop}}
16
- */
17
- protected function _getUrl(){
18
- $url = false;
19
- if ($this->getValue()) {
20
- $url = Mage::helper('{{module}}/{{entity}}_image')->getImageBaseUrl().$this->getValue();
21
- }
22
- return $url;
23
- }
24
- }
25
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Tree/01_top.php DELETED
@@ -1,219 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin tree block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Tree extends {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Abstract{
11
- /**
12
- * constructor
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- $this->setTemplate('{{namespace}}_{{module}}/{{entity}}/tree.phtml');
20
- $this->setUseAjax(true);
21
- $this->_withProductCount = true;
22
- }
23
- /**
24
- * prepare the layout
25
- * @access protected
26
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Tree
27
- * {{qwertyuiop}}
28
- */
29
- protected function _prepareLayout(){
30
- $addUrl = $this->getUrl("*/*/add", array(
31
- '_current'=>true,
32
- 'id'=>null,
33
- '_query' => false
34
- ));
35
-
36
- $this->setChild('add_sub_button',
37
- $this->getLayout()->createBlock('adminhtml/widget_button')
38
- ->setData(array(
39
- 'label' => Mage::helper('{{module}}')->__('Add Child {{EntityLabel}}'),
40
- 'onclick' => "addNew('".$addUrl."', false)",
41
- 'class' => 'add',
42
- 'id'=> 'add_child_{{entity}}_button',
43
- 'style' => $this->canAddChild() ? '' : 'display: none;'
44
- ))
45
- );
46
-
47
- $this->setChild('add_root_button',
48
- $this->getLayout()->createBlock('adminhtml/widget_button')
49
- ->setData(array(
50
- 'label' => Mage::helper('{{module}}')->__('Add Root {{EntityLabel}}'),
51
- 'onclick' => "addNew('".$addUrl."', true)",
52
- 'class' => 'add',
53
- 'id'=> 'add_root_{{entity}}_button'
54
- ))
55
- );
56
- return parent::_prepareLayout();
57
- }
58
- /**
59
- * get the {{entityLabel}} collection
60
- * @access public
61
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
62
- * {{qwertyuiop}}
63
- */
64
- public function get{{Entity}}Collection(){
65
- $collection = $this->getData('{{entity}}_collection');
66
- if (is_null($collection)) {
67
- $collection = Mage::getModel('{{module}}/{{entity}}')->getCollection();
68
- $this->setData('{{entity}}_collection', $collection);
69
- }
70
- return $collection;
71
- }
72
- /**
73
- * get html for add root button
74
- * @access public
75
- * @return string
76
- * {{qwertyuiop}}
77
- */
78
- public function getAddRootButtonHtml(){
79
- return $this->getChildHtml('add_root_button');
80
- }
81
- /**
82
- * get html for add child button
83
- * @access public
84
- * @return string
85
- * {{qwertyuiop}}
86
- */
87
- public function getAddSubButtonHtml(){
88
- return $this->getChildHtml('add_sub_button');
89
- }
90
- /**
91
- * get html for expand button
92
- * @access public
93
- * @return string
94
- * {{qwertyuiop}}
95
- */
96
- public function getExpandButtonHtml(){
97
- return $this->getChildHtml('expand_button');
98
- }
99
- /**
100
- * get html for add collapse button
101
- * @access public
102
- * @return string
103
- * {{qwertyuiop}}
104
- */
105
- public function getCollapseButtonHtml(){
106
- return $this->getChildHtml('collapse_button');
107
- }
108
- /**
109
- * get url for tree load
110
- * @access public
111
- * @param mxed $expanded
112
- * @return string
113
- * {{qwertyuiop}}
114
- */
115
- public function getLoadTreeUrl($expanded=null){
116
- $params = array('_current'=>true, 'id'=>null,'store'=>null);
117
- if ((is_null($expanded) && Mage::getSingleton('admin/session')->get{{Entity}}IsTreeWasExpanded())|| $expanded == true) {
118
- $params['expand_all'] = true;
119
- }
120
- return $this->getUrl('*/*/{{entities}}Json', $params);
121
- }
122
- /**
123
- * get url for loading nodes
124
- * @access public
125
- * @return string
126
- * {{qwertyuiop}}
127
- */
128
- public function getNodesUrl(){
129
- return $this->getUrl('*/{{module}}_{{entities}}/jsonTree');
130
- }
131
- /**
132
- * check if tree is expanded
133
- * @access public
134
- * @return string
135
- * {{qwertyuiop}}
136
- */
137
- public function getIsWasExpanded(){
138
- return Mage::getSingleton('admin/session')->get{{Entity}}IsTreeWasExpanded();
139
- }
140
- /**
141
- * get url for moving {{entityLabel}}
142
- * @access public
143
- * @return string
144
- * {{qwertyuiop}}
145
- */
146
- public function getMoveUrl(){
147
- return $this->getUrl('*/{{module}}_{{entity}}/move');
148
- }
149
- /**
150
- * get the tree as json
151
- * @access public
152
- * @param mixed $parentNode{{Entity}}
153
- * @return string
154
- * {{qwertyuiop}}
155
- */
156
- public function getTree($parentNode{{Entity}} = null){
157
- $rootArray = $this->_getNodeJson($this->getRoot($parentNode{{Entity}}));
158
- $tree = isset($rootArray['children']) ? $rootArray['children'] : array();
159
- return $tree;
160
- }
161
- /**
162
- * get the tree as json
163
- * @access public
164
- * @param mixed $parentNode{{Entity}}
165
- * @return string
166
- * {{qwertyuiop}}
167
- */
168
- public function getTreeJson($parentNode{{Entity}} = null){
169
- $rootArray = $this->_getNodeJson($this->getRoot($parentNode{{Entity}}));
170
- $json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());
171
- return $json;
172
- }
173
-
174
- /**
175
- * Get JSON of array of {{entitiesLabel}}, that are breadcrumbs for specified {{entityLabel}} path
176
- * @access public
177
- * @param string $path
178
- * @param string $javascriptVarName
179
- * @return string
180
- * {{qwertyuiop}}
181
- */
182
- public function getBreadcrumbsJavascript($path, $javascriptVarName){
183
- if (empty($path)) {
184
- return '';
185
- }
186
-
187
- ${{entities}} = Mage::getResourceSingleton('{{module}}/{{entity}}_tree')->loadBreadcrumbsArray($path);
188
- if (empty(${{entities}})) {
189
- return '';
190
- }
191
- foreach (${{entities}} as $key => ${{entity}}) {
192
- ${{entities}}[$key] = $this->_getNodeJson(${{entity}});
193
- }
194
- return
195
- '<script type="text/javascript">'
196
- . $javascriptVarName . ' = ' . Mage::helper('core')->jsonEncode(${{entities}}) . ';'
197
- . ($this->canAddChild() ? '$("add_child_{{entity}}_button").show();' : '$("add_child_{{entity}}_button").hide();')
198
- . '</script>';
199
- }
200
-
201
- /**
202
- * Get JSON of a tree node or an associative array
203
- * @access protected
204
- * @param Varien_Data_Tree_Node|array $node
205
- * @param int $level
206
- * @return string
207
- * {{qwertyuiop}}
208
- */
209
- protected function _getNodeJson($node, $level = 0){
210
- // create a node from data array
211
- if (is_array($node)) {
212
- $node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
213
- }
214
- $item = array();
215
- $item['text'] = $this->buildNodeName($node);
216
- $rootForStores = in_array($node->getEntityId(), $this->getRootIds());
217
- $item['id'] = $node->getId();
218
- $item['path'] = $node->getData('path');
219
- $item['cls'] = 'folder';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Tree/02_status.php DELETED
@@ -1,6 +0,0 @@
1
- if ($node->getStatus()){
2
- $item['cls'] .= ' active-category';
3
- }
4
- else{
5
- $item['cls'] .= ' no-active-category';
6
- }
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Tree/03_footer.php DELETED
@@ -1,84 +0,0 @@
1
- $item['allowDrop'] = true;
2
- $item['allowDrag'] = true;
3
- if ((int)$node->getChildrenCount()>0) {
4
- $item['children'] = array();
5
- }
6
- $isParent = $this->_isParentSelected{{Entity}}($node);
7
- if ($node->hasChildren()) {
8
- $item['children'] = array();
9
- if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) {
10
- foreach ($node->getChildren() as $child) {
11
- $item['children'][] = $this->_getNodeJson($child, $level+1);
12
- }
13
- }
14
- }
15
- if ($isParent || $node->getLevel() < 1) {
16
- $item['expanded'] = true;
17
- }
18
- return $item;
19
- }
20
- /**
21
- * Get node label
22
- * @access public
23
- * @param Varien_Object $node
24
- * @return string
25
- * {{qwertyuiop}}
26
- */
27
- public function buildNodeName($node){
28
- $result = $this->htmlEscape($node->get{{EntityNameMagicCode}}());
29
- return $result;
30
- }
31
- /**
32
- * check if entity is movable
33
- * @access protected
34
- * @param Varien_Object $node
35
- * @return bool
36
- * {{qwertyuiop}}
37
- */
38
- protected function _is{{Entity}}Moveable($node){
39
- return true;
40
- }
41
- /**
42
- * check if parent is selected
43
- * @access protected
44
- * @param Varien_Object $node
45
- * @return bool
46
- * {{qwertyuiop}}
47
- */
48
- protected function _isParentSelected{{Entity}}($node){
49
- if ($node && $this->get{{Entity}}()) {
50
- $pathIds = $this->get{{Entity}}()->getPathIds();
51
- if (in_array($node->getId(), $pathIds)) {
52
- return true;
53
- }
54
- }
55
- return false;
56
- }
57
-
58
- /**
59
- * Check if page loaded by outside link to {{entityLabel}} edit
60
- * @access public
61
- * @return boolean
62
- * {{qwertyuiop}}
63
- */
64
- public function isClearEdit(){
65
- return (bool) $this->getRequest()->getParam('clear');
66
- }
67
- /**
68
- * Check availability of adding root {{entityLabel}}
69
- * @access public
70
- * @return boolean
71
- * {{qwertyuiop}}
72
- */
73
- public function canAddRoot{{Entity}}(){
74
- return true;
75
- }
76
- /**
77
- * Check availability of adding child {{entityLabel}}
78
- * @access public
79
- * @return boolean
80
- */
81
- public function canAddChild(){
82
- return true;
83
- }
84
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/01_top.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin widget chooser
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser extends Mage_Adminhtml_Block_Widget_Grid{
11
- /**
12
- * Block construction, prepare grid params
13
- * @access public
14
- * @param array $arguments Object data
15
- * @return void
16
- * {{qwertyuiop}}
17
- */
18
- public function __construct($arguments=array()){
19
- parent::__construct($arguments);
20
- $this->setDefaultSort('entity_id');
21
- $this->setDefaultDir('ASC');
22
- $this->setUseAjax(true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/02_top_status.php DELETED
@@ -1 +0,0 @@
1
- $this->setDefaultFilter(array('chooser_status' => '1'));
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/03_content.php DELETED
@@ -1,88 +0,0 @@
1
- }
2
- /**
3
- * Prepare chooser element HTML
4
- * @access public
5
- * @param Varien_Data_Form_Element_Abstract $element Form Element
6
- * @return Varien_Data_Form_Element_Abstract
7
- * {{qwertyuiop}}
8
- */
9
- public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element){
10
- $uniqId = Mage::helper('core')->uniqHash($element->getId());
11
- $sourceUrl = $this->getUrl('{{module}}/adminhtml_{{module}}_{{entity}}_widget/chooser', array('uniq_id' => $uniqId));
12
- $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
13
- ->setElement($element)
14
- ->setTranslationHelper($this->getTranslationHelper())
15
- ->setConfig($this->getConfig())
16
- ->setFieldsetId($this->getFieldsetId())
17
- ->setSourceUrl($sourceUrl)
18
- ->setUniqId($uniqId);
19
- if ($element->getValue()) {
20
- ${{entity}} = Mage::getModel('{{module}}/{{entity}}')->load($element->getValue());
21
- if (${{entity}}->getId()) {
22
- $chooser->setLabel(${{entity}}->get{{EntityNameMagicCode}}());
23
- }
24
- }
25
- $element->setData('after_element_html', $chooser->toHtml());
26
- return $element;
27
- }
28
- /**
29
- * Grid Row JS Callback
30
- * @access public
31
- * @return string
32
- * {{qwertyuiop}}
33
- */
34
- public function getRowClickCallback(){
35
- $chooserJsObject = $this->getId();
36
- $js = '
37
- function (grid, event) {
38
- var trElement = Event.findElement(event, "tr");
39
- var {{entity}}Id = trElement.down("td").innerHTML.replace(/^\s+|\s+$/g,"");
40
- var {{entity}}Title = trElement.down("td").next().innerHTML;
41
- '.$chooserJsObject.'.setElementValue({{entity}}Id);
42
- '.$chooserJsObject.'.setElementLabel({{entity}}Title);
43
- '.$chooserJsObject.'.close();
44
- }
45
- ';
46
- return $js;
47
- }
48
- /**
49
- * Prepare a static blocks collection
50
- * @access protected
51
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser
52
- * {{qwertyuiop}}
53
- */
54
- protected function _prepareCollection(){
55
- $collection = Mage::getModel('{{module}}/{{entity}}')->getCollection();
56
- $this->setCollection($collection);
57
- return parent::_prepareCollection();
58
- }
59
- /**
60
- * Prepare columns for the a grid
61
- * @access protected
62
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser
63
- * {{qwertyuiop}}
64
- */
65
- protected function _prepareColumns(){
66
- $this->addColumn('chooser_id', array(
67
- 'header' => Mage::helper('{{module}}')->__('Id'),
68
- 'align' => 'right',
69
- 'index' => 'entity_id',
70
- 'type' => 'number',
71
- 'width' => 50
72
- ));
73
-
74
- $this->addColumn('chooser_{{nameAttribute}}', array(
75
- 'header'=> Mage::helper('{{module}}')->__('{{nameAttributeLabel}}'),
76
- 'align' => 'left',
77
- 'index' => '{{nameAttribute}}',
78
- ));
79
- if (!Mage::app()->isSingleStoreMode()) {
80
- $this->addColumn('store_id', array(
81
- 'header'=> Mage::helper('{{module}}')->__('Store Views'),
82
- 'index' => 'store_id',
83
- 'type' => 'store',
84
- 'store_all' => true,
85
- 'store_view'=> true,
86
- 'sortable' => false,
87
- ));
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/04_status.php DELETED
@@ -1,9 +0,0 @@
1
- $this->addColumn('chooser_status', array(
2
- 'header'=> Mage::helper('{{module}}')->__('Status'),
3
- 'index' => 'status',
4
- 'type' => 'options',
5
- 'options' => array(
6
- 0 => Mage::helper('{{module}}')->__('Disabled'),
7
- 1 => Mage::helper('{{module}}')->__('Enabled')
8
- ),
9
- ));
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/05_footer.php DELETED
@@ -1,22 +0,0 @@
1
- return parent::_prepareColumns();
2
- }
3
- /**
4
- * get url for grid
5
- * @access public
6
- * @return string
7
- * {{qwertyuiop}}
8
- */
9
- public function getGridUrl(){
10
- return $this->getUrl('adminhtml/{{module}}_{{entity}}_widget/chooser', array('_current' => true));
11
- }
12
- /**
13
- * after collection load
14
- * @access protected
15
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser
16
- * {{qwertyuiop}}
17
- */
18
- protected function _afterLoadCollection(){
19
- $this->getCollection()->walk('afterLoad');
20
- parent::_afterLoadCollection();
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Entity/Widget/Chooser/IsTree/01_content.php DELETED
@@ -1,135 +0,0 @@
1
- <?php
2
- {{License}}
3
-
4
- /**
5
- * {{EntityLabel}} chooser for Wysiwyg CMS widget
6
- *
7
- * @category {{Namespace}}
8
- * @package{{Namespace}}_{{Module}}
9
- * {{qwertyuiop}}
10
- */
11
- class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser extends {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Tree{
12
- protected $_selected{{Entities}} = array();
13
- /**
14
- * Block construction
15
- * Defines tree template and init tree params
16
- * @access public
17
- * @return void
18
- * {{qwertyuiop}}
19
- */
20
- public function __construct(){
21
- parent::__construct();
22
- $this->setTemplate('{{namespace}}_{{module}}/{{entity}}/widget/tree.phtml');
23
- }
24
- /**
25
- * Setter
26
- * @access public
27
- * @param array $selected{{Entities}}
28
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser
29
- * {{qwertyuiop}}
30
- */
31
- public function setSelected{{Entities}}($selected{{Entities}}){
32
- $this->_selected{{Entities}} = $selected{{Entities}};
33
- return $this;
34
- }
35
- /**
36
- * Getter
37
- * @access public
38
- * @return array
39
- * {{qwertyuiop}}
40
- */
41
- public function getSelected{{Entities}}(){
42
- return $this->_selected{{Entities}};
43
- }
44
- /**
45
- * Prepare chooser element HTML
46
- * @access public
47
- * @param Varien_Data_Form_Element_Abstract $element Form Element
48
- * @return Varien_Data_Form_Element_Abstract
49
- * {{qwertyuiop}}
50
- */
51
- public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element){
52
- $uniqId = Mage::helper('core')->uniqHash($element->getId());
53
- $sourceUrl = $this->getUrl('*/{{module}}_{{entity}}_widget/chooser', array('uniq_id' => $uniqId, 'use_massaction' => false));
54
- $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser')
55
- ->setElement($element)
56
- ->setTranslationHelper($this->getTranslationHelper())
57
- ->setConfig($this->getConfig())
58
- ->setFieldsetId($this->getFieldsetId())
59
- ->setSourceUrl($sourceUrl)
60
- ->setUniqId($uniqId);
61
- $value = $element->getValue();
62
- ${{entity}}Id = false;
63
- if ($value) {
64
- ${{entity}}Id = $value;
65
- }
66
- if (${{entity}}Id) {
67
- $label = Mage::getSingleton('{{module}}/{{entity}}')->load(${{entity}}Id)->get{{EntityNameMagicCode}}();
68
- $chooser->setLabel($label);
69
- }
70
- $element->setData('after_element_html', $chooser->toHtml());
71
- return $element;
72
- }
73
- /**
74
- * onClick listener js function
75
- * @access public
76
- * @return string
77
- * {{qwertyuiop}}
78
- */
79
- public function getNodeClickListener(){
80
- if ($this->getData('node_click_listener')) {
81
- return $this->getData('node_click_listener');
82
- }
83
- if ($this->getUseMassaction()) {
84
- $js = '
85
- function (node, e) {
86
- if (node.ui.toggleCheck) {
87
- node.ui.toggleCheck(true);
88
- }
89
- }
90
- ';
91
- }
92
- else {
93
- $chooserJsObject = $this->getId();
94
- $js = '
95
- function (node, e) {
96
- '.$chooserJsObject.'.setElementValue(node.attributes.id);
97
- '.$chooserJsObject.'.setElementLabel(node.text);
98
- '.$chooserJsObject.'.close();
99
- }
100
- ';
101
- }
102
- return $js;
103
- }
104
-
105
- /**
106
- * Get JSON of a tree node or an associative array
107
- * @access protected
108
- * @param Varien_Data_Tree_Node|array $node
109
- * @param int $level
110
- * @return string
111
- * {{qwertyuiop}}
112
- */
113
- protected function _getNodeJson($node, $level = 0){
114
- $item = parent::_getNodeJson($node, $level);
115
- if (in_array($node->getId(), $this->getSelected{{Entities}}())) {
116
- $item['checked'] = true;
117
- }
118
- return $item;
119
- }
120
-
121
- /**
122
- * Tree JSON source URL
123
- * @access public
124
- * @param mixed $expanded
125
- * @return string
126
- * {{qwertyuiop}}
127
- */
128
- public function getLoadTreeUrl($expanded=null){
129
- return $this->getUrl('*/{{module}}_{{entity}}_widget/{{entities}}Json', array(
130
- '_current'=>true,
131
- 'uniq_id' => $this->getId(),
132
- 'use_massaction' => $this->getUseMassaction()
133
- ));
134
- }
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Adminhtml/Helper/Wysiwyg/01_content.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{Module}} textarea attribute WYSIWYG button
5
- * @category {{Namespace}}
6
- * @package {{Namespace}}_{{Module}}
7
- * {{qwertyuiop}}
8
- */
9
- class {{Namespace}}_{{Module}}_Block_Adminhtml_Helper_Wysiwyg extends Varien_Data_Form_Element_Textarea
10
- {
11
- /**
12
- * Retrieve additional html and put it at the end of element html
13
- * @access public
14
- * @return string
15
- * {{qwertyuiop}}
16
- */
17
- public function getAfterElementHtml(){
18
- $html = parent::getAfterElementHtml();
19
- $disabled = ($this->getDisabled() || $this->getReadonly());
20
- $html .= Mage::getSingleton('core/layout')
21
- ->createBlock('adminhtml/widget_button', '', array(
22
- 'label' => Mage::helper('catalog')->__('WYSIWYG Editor'),
23
- 'type'=> 'button',
24
- 'disabled' => $disabled,
25
- 'class' => ($disabled) ? 'disabled btn-wysiwyg' : 'btn-wysiwyg',
26
- 'onclick' => 'catalogWysiwygEditor.open(\''.Mage::helper('adminhtml')->getUrl('*/*/wysiwyg').'\', \''.$this->getHtmlId().'\')'
27
- ))->toHtml();
28
- return $html;
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Catalog/Product/List/Entity/01_top.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} list on product page block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Catalog_Product_List_{{Entity}} extends Mage_Catalog_Block_Product_Abstract{
11
- /**
12
- * get the list of {{entities}}
13
- * @access protected
14
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
15
- * {{qwertyuiop}}
16
- */
17
- public function get{{Entity}}Collection(){
18
- if (!$this->hasData('{{entity}}_collection')){
19
- $product = Mage::registry('product');
20
- $collection = Mage::getResourceSingleton('{{module}}/{{entity}}_collection')
21
- ->addStoreFilter(Mage::app()->getStore())
22
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Catalog/Product/List/Entity/02_status.php DELETED
@@ -1 +0,0 @@
1
- ->addFilter('status', 1)
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Catalog/Product/List/Entity/03_footer.php DELETED
@@ -1,7 +0,0 @@
1
- ->addProductFilter($product);
2
- $collection->getSelect()->order('related_product.position', 'ASC');
3
- $this->setData('{{entity}}_collection', $collection);
4
- }
5
- return $this->getData('{{entity}}_collection');
6
- }
7
- }
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Catalog/Product/List/01_content.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} product list
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_Catalog_Product_List extends Mage_Core_Block_Template{
11
- /**
12
- * get the list of products
13
- * @access public
14
- * @return Mage_Catalog_Model_Resource_Product_Collection
15
- * {{qwertyuiop}}
16
- */
17
- public function getProductCollection(){
18
- $collection = $this->get{{Entity}}()->getSelectedProductsCollection();
19
- $collection->addAttributeToSelect('name');
20
- $collection->addUrlRewrite();
21
- $collection->getSelect()->order('related.position');
22
- Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
23
- Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
24
- return $collection;
25
- }
26
- /**
27
- * get current {{entity}}
28
- * @access public
29
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
30
- * {{qwertyuiop}}
31
- */
32
- public function get{{Entity}}(){
33
- return Mage::registry('current_{{module}}_{{entity}}');
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Child/List/01_content.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} {{SiblingsLabel}} list block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_{{Sibling}}_List extends {{Namespace}}_{{Module}}_Block_{{Sibling}}_List{
11
- /**
12
- * initialize
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- ${{entity}} = $this->get{{Entity}}();
20
- if (${{entity}}){
21
- $this->get{{Siblings}}()->addFilter('{{entity}}_id', ${{entity}}->getId());
22
- }
23
- }
24
- /**
25
- * prepare the layout - actually do nothing
26
- * @access protected
27
- * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_{{Sibling}}_List
28
- * {{qwertyuiop}}
29
- */
30
- protected function _prepareLayout(){
31
- return $this;
32
- }
33
- /**
34
- * get the current {{entity}}
35
- * @access public
36
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
37
- * {{qwertyuiop}}
38
- */
39
- public function get{{Entity}}(){
40
- return Mage::registry('current_{{module}}_{{entity}}');
41
- }
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Children/01_content.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} children list block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_Children extends {{Namespace}}_{{Module}}_Block_{{Entity}}_List{
11
- /**
12
- * prepare the layout
13
- * @access protected
14
- * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_Children
15
- * {{qwertyuiop}}
16
- */
17
- protected function _prepareLayout(){
18
- $this->get{{Entities}}()->addFieldToFilter('parent_id', $this->getCurrent{{Entity}}()->getId());
19
- return $this;
20
- }
21
- /**
22
- * ge the current {{entityLabel}}
23
- * @access protected
24
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
25
- * {{qwertyuiop}}
26
- */
27
- public function getCurrent{{Entity}}(){
28
- return Mage::registry('current_{{module}}_{{entity}}');
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/01_top.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} list block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_List extends Mage_Core_Block_Template{
11
- /**
12
- * initialize
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- ${{entities}} = Mage::getResourceModel('{{module}}/{{entity}}_collection')
20
- ->addStoreFilter(Mage::app()->getStore())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/02_status.php DELETED
@@ -1 +0,0 @@
1
- ->addFilter('status', 1)
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/03_footer.php DELETED
@@ -1,28 +0,0 @@
1
- ;
2
- ${{entities}}->setOrder('{{nameAttribute}}', 'asc');
3
- $this->set{{Entities}}(${{entities}});
4
- }
5
- /**
6
- * prepare the layout
7
- * @access protected
8
- * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_List
9
- * {{qwertyuiop}}
10
- */
11
- protected function _prepareLayout(){
12
- parent::_prepareLayout();
13
- $pager = $this->getLayout()->createBlock('page/html_pager', '{{module}}.{{entity}}.html.pager')
14
- ->setCollection($this->get{{Entities}}());
15
- $this->setChild('pager', $pager);
16
- $this->get{{Entities}}()->load();
17
- return $this;
18
- }
19
- /**
20
- * get the pager html
21
- * @access public
22
- * @return string
23
- * {{qwertyuiop}}
24
- */
25
- public function getPagerHtml(){
26
- return $this->getChildHtml('pager');
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/01_top.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} list block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_List extends Mage_Core_Block_Template{
11
- /**
12
- * initialize
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- ${{entities}} = Mage::getResourceModel('{{module}}/{{entity}}_collection')
20
- ->addStoreFilter(Mage::app()->getStore())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/02_status.php DELETED
@@ -1 +0,0 @@
1
- ->addFilter('status', 1)
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/03_center.php DELETED
@@ -1,58 +0,0 @@
1
- ;
2
- ${{entities}}->getSelect()->order('main_table.position');
3
- $this->set{{Entities}}(${{entities}});
4
- }
5
- /**
6
- * prepare the layout
7
- * @access protected
8
- * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_List
9
- * {{qwertyuiop}}
10
- */
11
- protected function _prepareLayout(){
12
- parent::_prepareLayout();
13
- $this->get{{Entities}}()->addFieldToFilter('level', 1);
14
- if ($this->_getDisplayMode() == 0){
15
- $pager = $this->getLayout()->createBlock('page/html_pager', '{{module}}.{{entities}}.html.pager')
16
- ->setCollection($this->get{{Entities}}());
17
- $this->setChild('pager', $pager);
18
- $this->get{{Entities}}()->load();
19
- }
20
- return $this;
21
- }
22
- /**
23
- * get the pager html
24
- * @access public
25
- * @return string
26
- * {{qwertyuiop}}
27
- */
28
- public function getPagerHtml(){
29
- return $this->getChildHtml('pager');
30
- }
31
- /**
32
- * get the display mode
33
- * @access protected
34
- * @return int
35
- * {{qwertyuiop}}
36
- */
37
- protected function _getDisplayMode(){
38
- return Mage::getStoreConfigFlag('{{module}}/{{entity}}/tree');
39
- }
40
- /**
41
- * draw {{entityLabel}}
42
- * @access public
43
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}}
44
- * @param int $level
45
- * @return int
46
- * {{qwertyuiop}}
47
- */
48
- public function draw{{Entity}}(${{entity}}, $level = 0){
49
- $html = '';
50
- $recursion = $this->getRecursion();
51
- if ($recursion !== '0' && $level >= $recursion){
52
- return '';
53
- }
54
- $storeIds = Mage::getResourceSingleton('{{module}}/{{entity}}')->lookupStoreIds(${{entity}}->getId());
55
- $validStoreIds = array(0, Mage::app()->getStore()->getId());
56
- if (!array_intersect($storeIds, $validStoreIds)){
57
- continue;
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/04_status_draw.php DELETED
@@ -1,3 +0,0 @@
1
- if (!${{entity}}->getStatus()){
2
- return '';
3
- }
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/05_children.php DELETED
@@ -1 +0,0 @@
1
- $children = ${{entity}}->getChildren{{Entities}}();
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/06_active_children.php DELETED
@@ -1,13 +0,0 @@
1
- $activeChildren = array();
2
- if ($recursion == 0 || $level < $recursion-1){
3
- foreach ($children as $child) {
4
- $childStoreIds = Mage::getResourceSingleton('{{module}}/{{entity}}')->lookupStoreIds($child->getId());
5
- $validStoreIds = array(0, Mage::app()->getStore()->getId());
6
- if (!array_intersect($childStoreIds, $validStoreIds)){
7
- continue;
8
- }
9
- if ($child->getStatus()) {
10
- $activeChildren[] = $child;
11
- }
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/07_active_children_no_status.php DELETED
@@ -1,9 +0,0 @@
1
- $activeChildren = array();
2
- foreach ($children as $child) {
3
- $childStoreIds = Mage::getResourceSingleton('{{module}}/{{entity}}')->lookupStoreIds($child->getId());
4
- $validStoreIds = array(0, Mage::app()->getStore()->getId());
5
- if (!array_intersect($childStoreIds, $validStoreIds)){
6
- continue;
7
- }
8
- $activeChildren[] = $child;
9
- }
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/List/IsTree/08_footer.php DELETED
@@ -1,25 +0,0 @@
1
- $html .= '<li>';
2
- $html .= '<a href="'.${{entity}}->get{{Entity}}Url().'">'.${{entity}}->get{{EntityNameMagicCode}}().'</a>';
3
- if (count($activeChildren) > 0) {
4
- $html .= '<ul>';
5
- foreach ($children as $child){
6
- $html .= $this->draw{{Entity}}($child, $level+1);
7
- }
8
- $html .= '</ul>';
9
- }
10
- $html .= '</li>';
11
- return $html;
12
- }
13
- /**
14
- * get recursion
15
- * @access public
16
- * @return int
17
- * {{qwertyuiop}}
18
- */
19
- public function getRecursion(){
20
- if (!$this->hasData('recursion')){
21
- $this->setData('recursion', Mage::getStoreConfig('{{module}}/{{entity}}/recursion'));
22
- }
23
- return $this->getData('recursion');
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/01_top.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} RSS block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_Rss extends Mage_Rss_Block_Abstract{
11
- /**
12
- * Cache tag constant for feed reviews
13
- * @var string
14
- */
15
- const CACHE_TAG = 'block_html_{{module}}_{{entity}}_rss';
16
- /**
17
- * constructor
18
- * @access protected
19
- * @return void
20
- * {{qwertyuiop}}
21
- */
22
- protected function _construct(){
23
- $this->setCacheTags(array(self::CACHE_TAG));
24
- /*
25
- * setting cache to save the rss for 10 minutes
26
- */
27
- $this->setCacheKey('{{module}}_{{entity}}_rss');
28
- $this->setCacheLifetime(600);
29
- }
30
- /**
31
- * toHtml method
32
- * @access protected
33
- * @return string
34
- * {{qwertyuiop}}
35
- */
36
- protected function _toHtml(){
37
- $url = Mage::helper('{{module}}')->get{{Entities}}Url();
38
- $title = Mage::helper('{{module}}')->__('{{EntitiesLabel}}');
39
- $rssObj = Mage::getModel('rss/rss');
40
- $data = array(
41
- 'title' => $title,
42
- 'description' => $title,
43
- 'link'=> $url,
44
- 'charset' => 'UTF-8',
45
- );
46
- $rssObj->_addHeader($data);
47
- $collection = Mage::getModel('{{module}}/{{entity}}')->getCollection()
48
- ->addStoreFilter(Mage::app()->getStore())
49
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/02_status.php DELETED
@@ -1 +0,0 @@
1
- ->addFilter('status', 1)
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/03_content_top.php DELETED
@@ -1,5 +0,0 @@
1
- ->addFilter('in_rss', 1)
2
- ->setOrder('created_at');
3
- $collection->load();
4
- foreach ($collection as $item){
5
- $description = '<p>';
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/04_content.php DELETED
@@ -1 +0,0 @@
1
- {{attributeRssText}}
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Rss/05_footer.php DELETED
@@ -1,11 +0,0 @@
1
- $description .= '</p>';
2
- $data = array(
3
- 'title'=>$item->get{{EntityNameMagicCode}}(),
4
- 'link'=>$item->get{{Entity}}Url(),
5
- 'description' => $description
6
- );
7
- $rssObj->_addEntry($data);
8
- }
9
- return $rssObj->createRssXml();
10
- }
11
- }
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Sibling/List/01_content.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} {{SiblingsLabel}} list block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_{{Sibling}}_List extends {{Namespace}}_{{Module}}_Block_{{Sibling}}_List{
11
- /**
12
- * initialize
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function __construct(){
18
- parent::__construct();
19
- ${{entity}} = $this->get{{Entity}}();
20
- if (${{entity}}){
21
- $this->get{{Siblings}}()->add{{Entity}}Filter(${{entity}}->getId());
22
- $this->get{{Siblings}}()->unshiftOrder('related_{{entity}}.position', 'ASC');
23
- }
24
- }
25
- /**
26
- * prepare the layout
27
- * @access protected
28
- * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_{{Sibling}}_List
29
- * {{qwertyuiop}}
30
- */
31
- protected function _prepareLayout(){
32
- return $this;
33
- }
34
- /**
35
- * get the current {{entity}}
36
- * @access public
37
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
38
- * {{qwertyuiop}}
39
- */
40
- public function get{{Entity}}(){
41
- return Mage::registry('current_{{module}}_{{entity}}');
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/View/01_content.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} view block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_View extends Mage_Core_Block_Template{
11
- /**
12
- * get the current {{entityLabel}}
13
- * @access public
14
- * @return mixed ({{Namespace}}_{{Module}}_Model_{{Entity}}|null)
15
- * {{qwertyuiop}}
16
- */
17
- public function getCurrent{{Entity}}(){
18
- return Mage::registry('current_{{module}}_{{entity}}');
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/Link/01_content.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} link widget block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_Widget_Link extends {{Namespace}}_{{Module}}_Block_{{Entity}}_Widget_View{
11
- protected $_htmlTemplate = '{{namespace}}_{{module}}/{{entity}}/widget/link.phtml';
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/Subtree/01_content.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} subtree block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_Widget_Subtree extends {{Namespace}}_{{Module}}_Block_{{Entity}}_List implements Mage_Widget_Block_Interface{
11
- protected $_template = '{{namespace}}_{{module}}/{{entity}}/widget/subtree.phtml';
12
- /**
13
- * prepare the layout
14
- * @access protected
15
- * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_Widget_Subtree
16
- * {{qwertyuiop}}
17
- */
18
- protected function _prepareLayout(){
19
- $this->get{{Entities}}()->addFieldToFilter('entity_id', $this->get{{Entity}}Id());
20
- return $this;
21
- }
22
- /**
23
- * get the display mode
24
- * @access protected
25
- * @return int
26
- * {{qwertyuiop}}
27
- */
28
- protected function _getDisplayMode(){
29
- return 1;
30
- }
31
- /**
32
- * get the element id
33
- * @access protected
34
- * @return int
35
- * {{qwertyuiop}}
36
- */
37
- public function getUniqueId(){
38
- if (!$this->getData('uniq_id')){
39
- $this->setData('uniq_id', uniqid('subtree'));
40
- }
41
- return $this->getData('uniq_id');
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/01_top.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} widget block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_{{Entity}}_Widget_View extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface{
11
- protected $_htmlTemplate = '{{namespace}}_{{module}}/{{entity}}/widget/view.phtml';
12
- /**
13
- * Prepare a for widget
14
- * @access protected
15
- * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_Widget_View
16
- * {{qwertyuiop}}
17
- */
18
- protected function _beforeToHtml() {
19
- parent::_beforeToHtml();
20
- ${{entity}}Id = $this->getData('{{entity}}_id');
21
- if (${{entity}}Id) {
22
- ${{entity}} = Mage::getModel('{{module}}/{{entity}}')
23
- ->setStoreId(Mage::app()->getStore()->getId())
24
- ->load(${{entity}}Id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/02_status.php DELETED
@@ -1 +0,0 @@
1
- if (${{entity}}->getStatus()) {
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/03_template.php DELETED
@@ -1,2 +0,0 @@
1
- $this->setCurrent{{Entity}}(${{entity}});
2
- $this->setTemplate($this->_htmlTemplate);
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/04_status.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Entity/Widget/View/05_footer.php DELETED
@@ -1,4 +0,0 @@
1
- }
2
- return $this;
3
- }
4
- }
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Block/Rss/01_content.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{Module}} RSS block
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Block_Rss extends Mage_Core_Block_Template{
11
- protected $_feeds = array();
12
- /**
13
- * add a new feed
14
- * @access public
15
- * @param string $label
16
- * @param string $url
17
- * @param bool $prepare
18
- * @return {{Namespace}}_{{Module}}_Block_Rss
19
- * {{qwertyuiop}}
20
- */
21
- public function addFeed($label, $url, $prepare = false){
22
- $link = ($prepare ? $this->getUrl($url) : $url);
23
- $feed = new Varien_Object();
24
- $feed->setLabel($label);
25
- $feed->setUrl($link);
26
- $this->_feeds[$link] = $feed;
27
- return $this;
28
- }
29
- /**
30
- * get the current feeds
31
- * @access public
32
- * @return array()
33
- * {{qwertyuiop}}
34
- */
35
- public function getFeeds(){
36
- return $this->_feeds;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Controller/Adminhtml/Module/01_content.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * module base admin controller
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Controller_Adminhtml_{{Module}} extends Mage_Adminhtml_Controller_Action{
11
- /**
12
- * upload file and get the uploaded name
13
- * @access public
14
- * @param string $input
15
- * @param string $destinationFolder
16
- * @param array $data
17
- * @return string
18
- * {{qwertyuiop}}
19
- */
20
- protected function _uploadAndGetName($input, $destinationFolder, $data){
21
- try{
22
- if (isset($data[$input]['delete'])){
23
- return '';
24
- }
25
- else{
26
- $uploader = new Varien_File_Uploader($input);
27
- $uploader->setAllowRenameFiles(true);
28
- $uploader->setFilesDispersion(true);
29
- $uploader->setAllowCreateFolders(true);
30
- $result = $uploader->save($destinationFolder);
31
- return $result['file'];
32
- }
33
- }
34
- catch (Exception $e){
35
- if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY){
36
- throw $e;
37
- }
38
- else{
39
- if (isset($data[$input]['value'])){
40
- return $data[$input]['value'];
41
- }
42
- }
43
- }
44
- return '';
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Controller/Router/01_top.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * Router
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract{
11
- /**
12
- * init routes
13
- * @access public
14
- * @param Varien_Event_Observer $observer
15
- * @return {{Namespace}}_{{Module}}_Controller_Router
16
- * {{qwertyuiop}}
17
- */
18
- public function initControllerRouters($observer){
19
- $front = $observer->getEvent()->getFront();
20
- $front->addRouter('{{module}}', $this);
21
- return $this;
22
- }
23
- /**
24
- * Validate and match entities and modify request
25
- * @access public
26
- * @param Zend_Controller_Request_Http $request
27
- * @return bool
28
- * {{qwertyuiop}}
29
- */
30
- public function match(Zend_Controller_Request_Http $request){
31
- if (!Mage::isInstalled()) {
32
- Mage::app()->getFrontController()->getResponse()
33
- ->setRedirect(Mage::getUrl('install'))
34
- ->sendResponse();
35
- exit;
36
- }
37
- $urlKey = trim($request->getPathInfo(), '/');
38
- $check = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Controller/Router/02_entity.php DELETED
@@ -1,6 +0,0 @@
1
- $check['{{entity}}'] = new Varien_Object(array(
2
- 'model' =>'{{module}}/{{entity}}',
3
- 'controller' => '{{entity}}',
4
- 'action' => 'view',
5
- 'param' => 'id',
6
- ));
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Controller/Router/03_footer.php DELETED
@@ -1,18 +0,0 @@
1
- foreach ($check as $key=>$settings){
2
- $model = Mage::getModel($settings->getModel());
3
- $id = $model->checkUrlKey($urlKey, Mage::app()->getStore()->getId());
4
- if ($id){
5
- $request->setModuleName('{{module}}')
6
- ->setControllerName($settings->getController())
7
- ->setActionName($settings->getAction())
8
- ->setParam($settings->getParam(), $id);
9
- $request->setAlias(
10
- Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
11
- $urlKey
12
- );
13
- return true;
14
- }
15
- }
16
- return false;
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Data/01_top.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{Module}} default helper
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Helper_Data extends Mage_Core_Helper_Abstract{
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Data/02_entity.php DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * get the url to the {{entitiesLabel}} list page
3
- * @access public
4
- * @return string
5
- * {{qwertyuiop}}
6
- */
7
- public function get{{Entities}}Url(){
8
- return Mage::getUrl('{{module}}/{{entity}}/index');
9
- }
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Data/03_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/01_top.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} helper
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Helper_{{Entity}} extends Mage_Core_Helper_Abstract{
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/02_tree.php DELETED
@@ -1,10 +0,0 @@
1
- const {{ENTITY}}_ROOT_ID = 1;
2
- /**
3
- * get the root id
4
- * @access public
5
- * @return int
6
- * {{qwertyuiop}}
7
- */
8
- public function getRoot{{Entity}}Id(){
9
- return self::{{ENTITY}}_ROOT_ID;
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/03_rss.php DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * check if the rss for {{entityLabel}} is enabled
3
- * @access public
4
- * @return bool
5
- * {{qwertyuiop}}
6
- */
7
- public function isRssEnabled(){
8
- return Mage::getStoreConfigFlag('rss/config/active') && Mage::getStoreConfigFlag('{{module}}/{{entity}}/rss');
9
- }
10
- /**
11
- * get the link to the {{entityLabel}} rss list
12
- * @access public
13
- * @return string
14
- * {{qwertyuiop}}
15
- */
16
- public function getRssUrl(){
17
- return Mage::getUrl('{{module}}/{{entity}}/rss');
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/04_file.php DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * get base files dir
3
- * @access public
4
- * @return string
5
- * {{qwertyuiop}}
6
- */
7
- public function getFileBaseDir(){
8
- return Mage::getBaseDir('media').DS.'{{entity}}'.DS.'file';
9
- }
10
- /**
11
- * get base file url
12
- * @access public
13
- * @return string
14
- * {{qwertyuiop}}
15
- */
16
- public function getFileBaseUrl(){
17
- return Mage::getBaseUrl('media').'{{entity}}'.'/'.'file';
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/05_footer.php DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * check if breadcrumbs can be used
3
- * @access public
4
- * @return bool
5
- * {{qwertyuiop}}
6
- */
7
- public function getUseBreadcrumbs(){
8
- return Mage::getStoreConfigFlag('{{module}}/{{entity}}/breadcrumbs');
9
- }
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Entity/Image/01_content.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} image helper
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Helper_{{Entity}}_Image extends {{Namespace}}_{{Module}}_Helper_Image_Abstract{
11
- /**
12
- * image placeholder
13
- * @var string
14
- */
15
- protected $_placeholder = 'images/placeholder/{{entity}}.jpg';
16
- /**
17
- * image subdir
18
- * @var string
19
- */
20
- protected $_subdir = '{{entity}}';
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Image/Abstract/01_content.php DELETED
@@ -1,447 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * abstract image helper
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- abstract class {{Namespace}}_{{Module}}_Helper_Image_Abstract extends Mage_Core_Helper_Data{
11
- /**
12
- * path to image placeholder
13
- * override in child
14
- * @var string
15
- */
16
- protected $_placeholder = '';
17
- /**
18
- * subdirectory to save imaves
19
- * override in child
20
- * @var string
21
- */
22
- protected $_subdir = '';
23
- /**
24
- * image processor
25
- * @var null|Varien_Image_Adapter_Gd2
26
- */
27
- protected $_imageProcessor = null;
28
- /**
29
- * image to process
30
- * @var unknown_type
31
- */
32
- protected $_image = null;
33
- /**
34
- * error message
35
- * @var string
36
- */
37
- protected $_openError = "";
38
- /**
39
- * keep image frame
40
- * @var bool
41
- */
42
- protected $_keepFrame = false;
43
- /**
44
- * keep image aspect ratio
45
- * @var bool
46
- */
47
- protected $_keepAspectRatio = true;
48
- /**
49
- * constrain image
50
- * @var bool
51
- */
52
- protected $_constrainOnly = true;
53
- /**
54
- * addaptive resize - crop
55
- * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
56
- * @var bool
57
- */
58
- protected $_adaptiveResize = 'center'; // false|center|top|bottom
59
- /**
60
- * image width
61
- * @var mixed(null|int)
62
- */
63
- protected $_width = null;
64
- /**
65
- * image height
66
- * @var mixed(null|int)
67
- */
68
- protected $_height = null;
69
- /**
70
- * image resize needed
71
- * @var mixed (null|array)
72
- */
73
- protected $_scheduledResize = null;
74
- /**
75
- * image is resized
76
- * @var bool
77
- */
78
- protected $_resized = false;
79
- /**
80
- * addaptive resize positions
81
- * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
82
- * @var array
83
- */
84
- protected $_adaptiveResizePositions = array(
85
- 'center'=>array(0.5,0.5),
86
- 'top' =>array(1,0),
87
- 'bottom'=>array(0,1)
88
- );
89
- /**
90
- * resized image folder name
91
- * @var string
92
- */
93
- protected $_resizeFolderName = 'cache';
94
- /**
95
- * get the image base dir
96
- * @access public
97
- * @return string
98
- * {{qwertyuiop}}
99
- */
100
- public function getImageBaseDir(){
101
- return Mage::getBaseDir('media').DS.$this->_subdir.DS.'image';
102
- }
103
- /**
104
- * get the image url for object
105
- * @access public
106
- * @return string
107
- * {{qwertyuiop}}
108
- */
109
- public function getImageBaseUrl(){
110
- return Mage::getBaseUrl('media').$this->_subdir.'/'.'image';
111
- }
112
-
113
- /**
114
- * init image
115
- * @access public
116
- * @param Varien_Object $object
117
- * @param string $imageField
118
- * @return {{Namespace}}_{{Module}}_Helper_Image_Abstract
119
- * {{qwertyuiop}}
120
- */
121
- public function init(Varien_Object $object, $imageField = 'image'){
122
- $this->_imageProcessor = null;
123
- $this->_image = $object->getDataUsingMethod($imageField);
124
- if(!$this->_image) {
125
- $this->_image = '/'.$this->_placeholder;
126
- }
127
- $this->_widht = null;
128
- $this->_height = null;
129
- $this->_scheduledResize = false;
130
- $this->_resized = false;
131
- $this->_adaptiveResize = 'center';
132
-
133
- try{
134
- $this->_getImageProcessor()->open($this->getImageBaseDir().$this->_image);
135
- }
136
- catch (Exception $e){
137
- $this->_openError = $e->getMessage();
138
- try{
139
- $this->_getImageProcessor()->open(Mage::getDesign()->getSkinUrl($this->_placeholder));
140
- $this->_image = '/'.$this->_placeholder;
141
- }
142
- catch(Exception $e) {
143
- $this->_openError .= "\n".$e->getMessage();
144
- $this->_image = null;
145
- }
146
- }
147
- return $this;
148
- }
149
- /**
150
- * get the image processor
151
- * @access protected
152
- * @return Varien_Image_Adapter_Gd2
153
- * {{qwertyuiop}}
154
- */
155
- protected function _getImageProcessor() {
156
- if (is_null($this->_imageProcessor)) {
157
- $this->_imageProcessor = Varien_Image_Adapter::factory('GD2');
158
- $this->_imageProcessor->keepFrame($this->_keepFrame);
159
- $this->_imageProcessor->keepAspectRatio($this->_keepAspectRatio);
160
- $this->_imageProcessor->constrainOnly($this->_constrainOnly);
161
- }
162
- return $this->_imageProcessor;
163
- }
164
- /**
165
- * Get/set keepAspectRatio
166
- * @access public
167
- * @param bool $value
168
- * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract)
169
- * {{qwertyuiop}}
170
- */
171
- public function keepAspectRatio($value = null){
172
- if (null !== $value) {
173
- $this->_getImageProcessor()->keepAspectRatio($value);
174
- return $this;
175
- }
176
- else {
177
- return $this->_getImageProcessor()->keepAspectRatio();
178
- }
179
- }
180
-
181
- /**
182
- * Get/set keepFrame
183
- * @access public
184
- * @param bool $value
185
- * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract)
186
- * {{qwertyuiop}}
187
- */
188
- public function keepFrame($value = null){
189
- if (null !== $value) {
190
- $this->_getImageProcessor()->keepFrame($value);
191
- return $this;
192
- }
193
- else {
194
- return $this->_getImageProcessor()->keepFrame();
195
- }
196
- }
197
- /**
198
- * Get/set keepTransparency
199
- * @access public
200
- * @param bool $value
201
- * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract)
202
- * {{qwertyuiop}}
203
- */
204
- public function keepTransparency($value = null){
205
- if (null !== $value) {
206
- $this->_getImageProcessor()->keepTransparency($value);
207
- return $this;
208
- }
209
- else {
210
- return $this->_getImageProcessor()->keepTransparency();
211
- }
212
- }
213
- /**
214
- * Get/set adaptiveResize
215
- * @access public
216
- * @param bool|string $value
217
- * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract)
218
- * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
219
- * {{qwertyuiop}}
220
- */
221
- public function adaptiveResize($value = null){
222
- if (null !== $value) {
223
- $this->_adaptiveResize = $value;
224
- if($value) {
225
- $this->keepFrame(false);
226
- }
227
- return $this;
228
- }
229
- else {
230
- return $this->_adaptiveResize;
231
- }
232
- }
233
- /**
234
- * Get/set constrainOnly
235
- * @access public
236
- * @param bool $value
237
- * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract)
238
- * {{qwertyuiop}}
239
- */
240
- public function constrainOnly($value = null){
241
- if (null !== $value) {
242
- $this->_getImageProcessor()->constrainOnly($value);
243
- return $this;
244
- }
245
- else {
246
- return $this->_getImageProcessor()->constrainOnly();
247
- }
248
- }
249
- /**
250
- * Get/set quality, values in percentage from 0 to 100
251
- * @access public
252
- * @param int $value
253
- * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract)
254
- * {{qwertyuiop}}
255
- */
256
- public function quality($value = null){
257
- if (null !== $value) {
258
- $this->_getImageProcessor()->quality($value);
259
- return $this;
260
- }
261
- else {
262
- return $this->_getImageProcessor()->quality();
263
- }
264
- }
265
- /**
266
- * Get/set keepBackgroundColor
267
- * @access public
268
- * @param array $value
269
- * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract)
270
- * {{qwertyuiop}}
271
- */
272
- public function backgroundColor($value = null){
273
- if (null !== $value) {
274
- $this->_getImageProcessor()-> backgroundColor($value);
275
- return $this;
276
- }
277
- else {
278
- return $this->_getImageProcessor()-> backgroundColor();
279
- }
280
- }
281
- /**
282
- * resize image
283
- * @access public
284
- * @param int $width - defaults to null
285
- * @param int $height - defaults to null
286
- * @return {{Namespace}}_{{Module}}_Helper_Image_Abstract
287
- * {{qwertyuiop}}
288
- */
289
- public function resize($width = null, $height = null) {
290
- $this->_scheduledResize = true;
291
- $this->_width = $width;
292
- $this->_height = $height;
293
- return $this;
294
- }
295
- /**
296
- * get destination image prefix
297
- * @access protected
298
- * @return {{Namespace}}_{{Module}}_Helper_Image_Abstract
299
- * {{qwertyuiop}}
300
- */
301
- protected function _getDestinationImagePrefix() {
302
- if(!$this->_image) {
303
- return $this;
304
- }
305
- $imageRealPath = "";
306
- if($this->_scheduledResize) {
307
- $width = $this->_width;
308
- $height = $this->_height;
309
- $adaptive = $this->adaptiveResize();
310
- $keepFrame = $this->keepFrame();
311
- $keepAspectRatio= $this->keepAspectRatio();
312
- $constrainOnly = $this->constrainOnly();
313
- $imageRealPath = $width.'x'.$height;
314
- $options = "";
315
-
316
- if(!$keepAspectRatio) {
317
- $imageRealPath .= '-exact';
318
- }
319
- else {
320
- if(!$keepFrame && $width && $height && ($adaptive !== false)) {
321
- $adaptive = strtolower(trim($adaptive));
322
- if(isset($this->_adaptiveResizePositions[$adaptive])) {
323
- $imageRealPath .= '-'.$adaptive;
324
- }
325
- }
326
- }
327
- if($keepFrame) {
328
- $imageRealPath .= '-frame';
329
- $_backgroundColor = $this->backgroundColor();
330
- if($_backgroundColor) {
331
- $imageRealPath .= '-'.implode('-',$_backgroundColor);
332
- }
333
- }
334
- if(!$constrainOnly) {
335
- $imageRealPath .= '-zoom';
336
- }
337
- }
338
- return $imageRealPath;
339
- }
340
- /**
341
- * get image destination path
342
- * @access protected
343
- * @return string
344
- * {{qwertyuiop}}
345
- */
346
- protected function _getDestinationPath() {
347
- if(!$this->_image) {
348
- return $this;
349
- }
350
- if($this->_scheduledResize) {
351
- return $this->getImageBaseDir().DS.$this->_resizeFolderName.DS.$this->_getDestinationImagePrefix().DS.$this->_image;
352
- } else {
353
- return $this->getImageBaseDir().DS.$this->_image;
354
- }
355
- }
356
- /**
357
- * get image url
358
- * @access protected
359
- * @return mixed (string|bool)
360
- * {{qwertyuiop}}
361
- */
362
- protected function _getImageUrl() {
363
- if(!$this->_image) {
364
- return false;
365
- }
366
- if($this->_scheduledResize) {
367
- return $this->getImageBaseUrl().'/'.$this->_resizeFolderName.'/'.$this->_getDestinationImagePrefix().$this->_image;
368
- }
369
- else {
370
- return $this->getImageBaseUrl().$this->_image;
371
- }
372
- }
373
- /**
374
- * resize image
375
- * @access protected
376
- * @return {{Namespace}}_{{Module}}_Helper_Image_Abstract
377
- * {{qwertyuiop}}
378
- */
379
- protected function _doResize() {
380
- if(!$this->_image || !$this->_scheduledResize || $this->_resized) {
381
- return $this;
382
- }
383
- $this->_resized = true; //mark as resized
384
- $width = $this->_width;
385
- $height = $this->_height;
386
- $adaptive = $width && $height &&
387
- $this->keepAspectRatio() && !$this->keepFrame() &&
388
- ($this->adaptiveResize() !== false);
389
- $adaptivePosition = false;
390
- if($adaptive) {
391
- $adaptive = strtolower(trim($this->adaptiveResize()));
392
- if(isset($this->_adaptiveResizePositions[$adaptive])) {
393
- $adaptivePosition = $this->_adaptiveResizePositions[$adaptive];
394
- }
395
- }
396
- $processor = $this->_getImageProcessor();
397
-
398
- if(!$adaptivePosition) {
399
- $processor->resize($width, $height);
400
- return $this;
401
- }
402
- //make adaptive resize
403
- //https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
404
- $currentRatio = $processor->getOriginalWidth() / $processor->getOriginalHeight();
405
- $targetRatio = $width / $height;
406
- if ($targetRatio > $currentRatio) {
407
- $processor->resize($width, null);
408
- }
409
- else {
410
- $processor->resize(null, $height);
411
- }
412
- $diffWidth = $processor->getOriginalWidth() - $width;
413
- $diffHeight = $processor->getOriginalHeight() - $height;
414
- if($diffWidth || $diffHeight) {
415
- $processor->crop(
416
- floor($diffHeight * $adaptivePosition[0]), //top rate
417
- floor($diffWidth / 2),
418
- ceil($diffWidth / 2),
419
- ceil($diffHeight * $adaptivePosition[1]) //bottom rate
420
- );
421
- }
422
- return $this;
423
- }
424
- /**
425
- * to string - no need for cache expire because the image names will be different
426
- * @access public
427
- * @return string
428
- * {{qwertyuiop}}
429
- */
430
- public function __toString(){
431
- try{
432
- if(!$this->_image) {
433
- throw new Exception($this->_openError);
434
- }
435
- $imageRealPath = $this->_getDestinationPath();
436
- if (!file_exists($imageRealPath)) {
437
- $this->_doResize();
438
- $this->_getImageProcessor()->save($imageRealPath);
439
- }
440
- return $this->_getImageUrl();
441
- }
442
- catch (Exception $e){
443
- Mage::logException($e);
444
- return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFr0lEQVR42rWXaUxUZxSGZVOKpWBRCGrSijBgDG1dagaxVgNSUqhAqq1CqzVVksb+sdZU0hgbfhQ1riEoiHFns4qVEYWglEWgVaBQLXRYJKzCzCA7KCpvz7njHbgz4AXSkryZYea73/Oe5Tv3zhQABtGfGcmCZPk/yYIZEuYIuDnJgeRKcn8pj/9Q7rw3M5g1moFpJGVnVxe0Wi20Oh107e1of/wYj1kdHejo7AR/z+oS1d0tqLunx6AeVm+vifoHBsAMZo1lYKVWq0NzyyO0PGrFo9Y2tLZp0KYRDA2bMjamN6c3OGzSxGwvmWDGWAasSR9qde0EbiVwG4E10AxnQw/XQ1nDUAYZZ2QU9fX1gRnMGtMAASTwMUvBGoYyQFoClmkJ5A0QhOHSlEtTbQoeAewVRdGy+kZoYDwGCGSacmOwKVQK6+9H/yh68uSJvAGGCGBTuACur6pCXUICssPDcXfHDvy5dy8KIyLQdOkSmh8+FNI8YCwCs54+fSpvgCNkOJeiwwieHROD3KBP8CDyJ9QePYLq/fuhjoqCml7L9/yI236+yI+L40hZDJRocHBwXAZGjTztq00o+mYbKiIj8cf2cGT6rIJKqUTakiW44a1EwdYtKNm1C/lfboBq0xcMM9GzZ8/kDRDMBJ5FkWeHrkPJD7uQvsYb177egr/LyzndQhPmpqYi2c0Fv23aiPxt25AZHIi8kycnZ4CaS1rz2lpcXbEUhd9ux7VVSmSfO8d1NaSY36cGBSJzrT9uhYYia+PnyFy/Dul+K6FpbmaoQc+fP5c3wF0twtnM5d27cfPTAEFJYRskcH69vjkMBaEh1BtBuEX9kbJIgav+q5EW6Iu0PXsYatCLFy/kDfCR4j7g1PIxSwwm+PogJCo98c/9+1L41s24FxaCIh8f5K3xwdVlC3CeTkTCewqkBvjhSthnkzMgwvn9WS9PpH7kh3Pve4yE0+brURLsixJqxOIPvKHyWoicM2eEWscrZuPI3Dk4tciNoRLJGuCB0q0fMMJQOb5YgQMz7BHj5mQYJvE+3shdqkDpvHkonz8PqmUKZJ8+zQAh0ti3HbDPbAriFusNDA0NscZngKFC9C8n2sm1foh6wwqHZ9vgdnIyYlZ5QeVojd/p0r+szHHZxR5Z8fGGCCtKSxHnZI1ouuZsyMcMlkjWAEN79dELEV/4ficOzZmOE7TpPlcnpDrb4A5d9oDgv7ja42ZcrAHOgLggfyTMskbsXBukROyeeAkYKkbPHd9UX48DHjMRa0lAgmfQJXenmiPFfQauH4+RwH89fBgXXGyRTOaOLpiFlsbGic8BHi5i9GyAm+7yoYOIUdghiZbfmmqBC++8iWiaCyJcXVaG6ABfpNCaLDJ32s0OV+ga2oP3Eu+QvJ/8A8mA3oDkvLP7Q8H+OOVB9ba2QKHja8icb4vEBTNx0cMB11xex10q071pFjhPa47QWuojPs58P+H7Cov/HyLGcjkD7Fw0IElf0oH9OOjpiBvudihztEG1uRnqSGoylE3RH/N0wsWon4WHFY1Gg5aWFjQ1NaGhoRH19Q1QqVR3iPEWyVzOgJh+iQFWQ10dTuz8DvsCVuOY0gXRXvNxNMQfsfRZjVotwGtpfBcWFqKoqAjldM+oqKhguJr2X0iayjw5Axy9sYGRE01yvvk7vo4HGEeel5fHnwt1r6qqYngj7b1IbD45Ayb1Z4DUgHS48BqGcb055Tk5uUIfVVdXIyMjQ2tra7uC9p7OHHkDBB7bgGn0/Bmv5ej5QaaOSlRcXIyamhoB7uzs7Ef72jJjogaM6//K9HPH63Q6qKkPKisrkZ6e3kiRL2c4yUzWgPjDZCIGAEgM0C8qNsBwbrh3STZSoLyB5QR8Ve1HKwGv5x7gsz5E8AL+HSie9YkYsHx5Rr25FJOUF2kuyUoCkjUgNcGZsJ6kpolDZrz6F2ZUsalEFcbPAAAAAElFTkSuQmCC';
445
- }
446
- }
447
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Product/01_top.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * Product helper
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Helper_Product extends {{Namespace}}_{{Module}}_Helper_Data{
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Product/02_content.php DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * get the selected {{entities}} for a product
3
- * @access public
4
- * @param Mage_Catalog_Model_Product $product
5
- * @return array()
6
- * {{qwertyuiop}}
7
- */
8
- public function getSelected{{Entities}}(Mage_Catalog_Model_Product $product){
9
- if (!$product->hasSelected{{Entities}}()) {
10
- ${{entities}} = array();
11
- foreach ($this->getSelected{{Entities}}Collection($product) as ${{entity}}) {
12
- ${{entities}}[] = ${{entity}};
13
- }
14
- $product->setSelected{{Entities}}(${{entities}});
15
- }
16
- return $product->getData('selected_{{entities}}');
17
- }
18
- /**
19
- * get {{entity}} collection for a product
20
- * @access public
21
- * @param Mage_Catalog_Model_Product $product
22
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
23
- */
24
- public function getSelected{{Entities}}Collection(Mage_Catalog_Model_Product $product){
25
- $collection = Mage::getResourceSingleton('{{module}}/{{entity}}_collection')
26
- ->addProductFilter($product);
27
- return $collection;
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Helper/Product/03_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/01_top.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * Adminhtml observer
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Adminhtml_Observer{
11
- /**
12
- * check if tab can be added
13
- * @access protected
14
- * @param Mage_Catalog_Model_Product $product
15
- * @return bool
16
- * {{qwertyuiop}}
17
- */
18
- protected function _canAddTab($product){
19
- if ($product->getId()){
20
- return true;
21
- }
22
- if (!$product->getAttributeSetId()){
23
- return false;
24
- }
25
- $request = Mage::app()->getRequest();
26
- if ($request->getParam('type') == 'configurable'){
27
- if ($request->getParam('attribtues')){
28
- return true;
29
- }
30
- }
31
- return false;
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/02_entity.php DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * add the {{entity}} tab to products
3
- * @access public
4
- * @param Varien_Event_Observer $observer
5
- * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer
6
- * {{qwertyuiop}}
7
- */
8
- public function add{{Entity}}Block($observer){
9
- $block = $observer->getEvent()->getBlock();
10
- $product = Mage::registry('product');
11
- if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs && $this->_canAddTab($product)){
12
- $block->addTab('{{entities}}', array(
13
- 'label' => Mage::helper('{{module}}')->__('{{Entities}}'),
14
- 'url' => Mage::helper('adminhtml')->getUrl('adminhtml/{{module}}_{{entity}}_catalog_product/{{entities}}', array('_current' => true)),
15
- 'class' => 'ajax',
16
- ));
17
- }
18
- return $this;
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/03_entity_save.php DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * save {{entity}} - product relation
3
- * @access public
4
- * @param Varien_Event_Observer $observer
5
- * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer
6
- * {{qwertyuiop}}
7
- */
8
- public function save{{Entity}}Data($observer){
9
- $post = Mage::app()->getRequest()->getPost('{{entities}}', -1);
10
- if ($post != '-1') {
11
- $post = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post);
12
- $product = Mage::registry('product');
13
- ${{entity}}Product = Mage::getResourceSingleton('{{module}}/{{entity}}_product')->saveProductRelation($product, $post);
14
- }
15
- return $this;
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/04_entity_save_tree.php DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * save {{entity}} - product relation
3
- * @access public
4
- * @param Varien_Event_Observer $observer
5
- * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer
6
- * {{qwertyuiop}}
7
- */
8
- public function save{{Entity}}Data($observer){
9
- $post = Mage::app()->getRequest()->getPost('{{entity}}_ids', -1);
10
- if ($post != '-1') {
11
- $post = explode(',', $post);
12
- $post = array_unique($post);
13
- $product = $observer->getEvent()->getProduct();
14
- Mage::getResourceSingleton('{{module}}/{{entity}}_product')->saveProductRelation($product, $post);
15
- }
16
- return $this;
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Observer/05_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Adminhtml/Search/Entity/01_content.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * Admin search model
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Adminhtml_Search_{{Entity}} extends Varien_Object{
11
- /**
12
- * Load search results
13
- * @access public
14
- * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Search_{{Entity}}
15
- * {{qwertyuiop}}
16
- */
17
- public function load(){
18
- $arr = array();
19
- if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
20
- $this->setResults($arr);
21
- return $this;
22
- }
23
- $collection = Mage::getResourceModel('{{module}}/{{entity}}_collection')
24
- ->addFieldToFilter('{{nameAttribute}}', array('like' => $this->getQuery().'%'))
25
- ->setCurPage($this->getStart())
26
- ->setPageSize($this->getLimit())
27
- ->load();
28
- foreach ($collection->getItems() as ${{entity}}) {
29
- $arr[] = array(
30
- 'id'=> '{{entity}}/1/'.${{entity}}->getId(),
31
- 'type' => Mage::helper('{{module}}')->__('{{EntityLabel}}'),
32
- 'name' => ${{entity}}->get{{EntityNameMagicCode}}(),
33
- 'description' => ${{entity}}->get{{EntityNameMagicCode}}(),
34
- 'url' => Mage::helper('adminhtml')->getUrl('*/{{module}}_{{entity}}/edit', array('id'=>${{entity}}->getId())),
35
- );
36
- }
37
- $this->setResults($arr);
38
- return $this;
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/01_top.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} model
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_{{Entity}} extends Mage_Core_Model_Abstract{
11
- /**
12
- * Entity code.
13
- * Can be used as part of method name for entity processing
14
- */
15
- const ENTITY= '{{module}}_{{entity}}';
16
- const CACHE_TAG = '{{module}}_{{entity}}';
17
- /**
18
- * Prefix of model events names
19
- * @var string
20
- */
21
- protected $_eventPrefix = '{{module}}_{{entity}}';
22
-
23
- /**
24
- * Parameter name in event
25
- * @var string
26
- */
27
- protected $_eventObject = '{{entity}}';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/02_var_sibling.php DELETED
@@ -1 +0,0 @@
1
- protected $_{{sibling}}Instance = null;
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/03_var_product_relation.php DELETED
@@ -1 +0,0 @@
1
- protected $_productInstance = null;
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/04_construct.php DELETED
@@ -1,25 +0,0 @@
1
- /**
2
- * constructor
3
- * @access public
4
- * @return void
5
- * {{qwertyuiop}}
6
- */
7
- public function _construct(){
8
- parent::_construct();
9
- $this->_init('{{module}}/{{entity}}');
10
- }
11
- /**
12
- * before save {{entityLabel}}
13
- * @access protected
14
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
15
- * {{qwertyuiop}}
16
- */
17
- protected function _beforeSave(){
18
- parent::_beforeSave();
19
- $now = Mage::getSingleton('core/date')->gmtDate();
20
- if ($this->isObjectNew()){
21
- $this->setCreatedAt($now);
22
- }
23
- $this->setUpdatedAt($now);
24
- return $this;
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/05_url.php DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * get the url to the {{entityLabel}} details page
3
- * @access public
4
- * @return string
5
- * {{qwertyuiop}}
6
- */
7
- public function get{{Entity}}Url(){
8
- return Mage::getUrl('{{module}}/{{entity}}/view', array('id'=>$this->getId()));
9
- }
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/06_url_rewrite_not_status.php DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * get the url to the {{entityLabel}} details page
3
- * @access public
4
- * @return string
5
- * {{qwertyuiop}}
6
- */
7
- public function get{{Entity}}Url(){
8
- if ($this->getUrlKey()){
9
- return Mage::getUrl('', array('_direct'=>$this->getUrlKey()));
10
- }
11
- return Mage::getUrl('{{module}}/{{entity}}/view', array('id'=>$this->getId()));
12
- }
13
- /**
14
- * check URL key
15
- * @access public
16
- * @param string $urlKey
17
- * @return mixed
18
- * {{qwertyuiop}}
19
- */
20
- public function checkUrlKey($urlKey){
21
- return $this->_getResource()->checkUrlKey($urlKey);
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/07_url_rewrite_status.php DELETED
@@ -1,23 +0,0 @@
1
- /**
2
- * get the url to the {{entityLabel}} details page
3
- * @access public
4
- * @return string
5
- * {{qwertyuiop}}
6
- */
7
- public function get{{Entity}}Url(){
8
- if ($this->getUrlKey()){
9
- return Mage::getUrl('', array('_direct'=>$this->getUrlKey()));
10
- }
11
- return Mage::getUrl('{{module}}/{{entity}}/view', array('id'=>$this->getId()));
12
- }
13
- /**
14
- * check URL key
15
- * @access public
16
- * @param string $urlKey
17
- * @param bool $active
18
- * @return mixed
19
- * {{qwertyuiop}}
20
- */
21
- public function checkUrlKey($urlKey, $active = true){
22
- return $this->_getResource()->checkUrlKey($urlKey, $active);
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/08_editors.php DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * get the {{entity}} {{attributeLabel}}
3
- * @access public
4
- * @return string
5
- * {{qwertyuiop}}
6
- */
7
- public function get{{AttributeMagicCode}}(){
8
- ${{attributeCode}} = $this->getData('{{attributeCode}}');
9
- $helper = Mage::helper('cms');
10
- $processor = $helper->getBlockTemplateProcessor();
11
- $html = $processor->filter(${{attributeCode}});
12
- return $html;
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/09_after_save_top.php DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * save {{entity}} relation
3
- * @access public
4
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
5
- * {{qwertyuiop}}
6
- */
7
- protected function _afterSave() {
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/10_after_save_product.php DELETED
@@ -1 +0,0 @@
1
- $this->getProductInstance()->save{{Entity}}Relation($this);
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/11_after_save_sibling.php DELETED
@@ -1 +0,0 @@
1
- $this->get{{Sibling}}Instance()->save{{Entity}}Relation($this);
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/12_after_save_footer.php DELETED
@@ -1,2 +0,0 @@
1
- return parent::_afterSave();
2
- }
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/13_product_relation.php DELETED
@@ -1,38 +0,0 @@
1
- /**
2
- * get product relation model
3
- * @access public
4
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_Product
5
- * {{qwertyuiop}}
6
- */
7
- public function getProductInstance(){
8
- if (!$this->_productInstance) {
9
- $this->_productInstance = Mage::getSingleton('{{module}}/{{entity}}_product');
10
- }
11
- return $this->_productInstance;
12
- }
13
- /**
14
- * get selected products array
15
- * @access public
16
- * @return array
17
- * {{qwertyuiop}}
18
- */
19
- public function getSelectedProducts(){
20
- if (!$this->hasSelectedProducts()) {
21
- $products = array();
22
- foreach ($this->getSelectedProductsCollection() as $product) {
23
- $products[] = $product;
24
- }
25
- $this->setSelectedProducts($products);
26
- }
27
- return $this->getData('selected_products');
28
- }
29
- /**
30
- * Retrieve collection selected products
31
- * @access public
32
- * @return {{Namespace}}_{{Module}}_Resource_{{Entity}}_Product_Collection
33
- * {{qwertyuiop}}
34
- */
35
- public function getSelectedProductsCollection(){
36
- $collection = $this->getProductInstance()->getProductCollection($this);
37
- return $collection;
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/14_sibling_relation.php DELETED
@@ -1,38 +0,0 @@
1
- /**
2
- * get {{sibling}} relation model
3
- * @access public
4
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_{{Sibling}}
5
- * {{qwertyuiop}}
6
- */
7
- public function get{{Sibling}}Instance(){
8
- if (!$this->_{{sibling}}Instance) {
9
- $this->_{{sibling}}Instance = Mage::getSingleton('{{module}}/{{entity}}_{{sibling}}');
10
- }
11
- return $this->_{{sibling}}Instance;
12
- }
13
- /**
14
- * get selected {{siblings}} array
15
- * @access public
16
- * @return array
17
- * {{qwertyuiop}}
18
- */
19
- public function getSelected{{Siblings}}(){
20
- if (!$this->hasSelected{{Siblings}}()) {
21
- ${{siblings}} = array();
22
- foreach ($this->getSelected{{Siblings}}Collection() as ${{sibling}}) {
23
- ${{siblings}}[] = ${{sibling}};
24
- }
25
- $this->setSelected{{Siblings}}(${{siblings}});
26
- }
27
- return $this->getData('selected_{{siblings}}');
28
- }
29
- /**
30
- * Retrieve collection selected {{siblings}}
31
- * @access public
32
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_{{Sibling}}_Collection
33
- * {{qwertyuiop}}
34
- */
35
- public function getSelected{{Siblings}}Collection(){
36
- $collection = $this->get{{Sibling}}Instance()->get{{Siblings}}Collection($this);
37
- return $collection;
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/15_tree.php DELETED
@@ -1,224 +0,0 @@
1
- /**
2
- * get the tree model
3
- * @access public
4
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree
5
- * {{qwertyuiop}}
6
- */
7
- public function getTreeModel(){
8
- return Mage::getResourceModel('{{module}}/{{entity}}_tree');
9
- }
10
- /**
11
- * get tree model instance
12
- * @access public
13
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree
14
- * {{qwertyuiop}}
15
- */
16
- public function getTreeModelInstance(){
17
- if (is_null($this->_treeModel)) {
18
- $this->_treeModel = Mage::getResourceSingleton('{{module}}/{{entity}}_tree');
19
- }
20
- return $this->_treeModel;
21
- }
22
- /**
23
- * Move {{entityLabel}}
24
- * @access public
25
- * @param int $parentId new parent {{entityLabel}} id
26
- * @param int $after{{Entity}}Id {{entityLabel}} id after which we have put current {{entityLabel}}
27
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
28
- * {{qwertyuiop}}
29
- */
30
- public function move($parentId, $after{{Entity}}Id){
31
- $parent = Mage::getModel('{{module}}/{{entity}}')->load($parentId);
32
- if (!$parent->getId()) {
33
- Mage::throwException(
34
- Mage::helper('{{module}}')->__('{{EntityLabel}} move operation is not possible: the new parent {{entityLabel}} was not found.')
35
- );
36
- }
37
- if (!$this->getId()) {
38
- Mage::throwException(
39
- Mage::helper('{{module}}')->__('{{EntityLabel}} move operation is not possible: the current {{entityLabel}} was not found.')
40
- );
41
- }
42
- elseif ($parent->getId() == $this->getId()) {
43
- Mage::throwException(
44
- Mage::helper('{{module}}')->__('{{EntityLabel}} move operation is not possible: parent {{entityLabel}} is equal to child {{entityLabel}}.')
45
- );
46
- }
47
- $this->setMoved{{Entity}}Id($this->getId());
48
- $eventParams = array(
49
- $this->_eventObject => $this,
50
- 'parent' => $parent,
51
- '{{entity}}_id' => $this->getId(),
52
- 'prev_parent_id' => $this->getParentId(),
53
- 'parent_id' => $parentId
54
- );
55
- $moveComplete = false;
56
- $this->_getResource()->beginTransaction();
57
- try {
58
- $this->getResource()->changeParent($this, $parent, $after{{Entity}}Id);
59
- $this->_getResource()->commit();
60
- $this->setAffected{{Entity}}Ids(array($this->getId(), $this->getParentId(), $parentId));
61
- $moveComplete = true;
62
- }
63
- catch (Exception $e) {
64
- $this->_getResource()->rollBack();
65
- throw $e;
66
- }
67
- if ($moveComplete) {
68
- Mage::app()->cleanCache(array(self::CACHE_TAG));
69
- }
70
- return $this;
71
- }
72
- /**
73
- * Get the parent {{entityLabel}}
74
- * @access public
75
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
76
- * {{qwertyuiop}}
77
- */
78
- public function getParent{{Entity}}(){
79
- if (!$this->hasData('parent_{{entity}}')) {
80
- $this->setData('parent_{{entity}}', Mage::getModel('{{module}}/{{entity}}')->load($this->getParentId()));
81
- }
82
- return $this->_getData('parent_{{entity}}');
83
- }
84
- /**
85
- * Get the parent id
86
- * @access public
87
- * @return int
88
- * {{qwertyuiop}}
89
- */
90
- public function getParentId(){
91
- $parentIds = $this->getParentIds();
92
- return intval(array_pop($parentIds));
93
- }
94
- /**
95
- * Get all parent {{entitiesLabel}} ids
96
- * @access public
97
- * @return array
98
- * {{qwertyuiop}}
99
- */
100
- public function getParentIds(){
101
- return array_diff($this->getPathIds(), array($this->getId()));
102
- }
103
- /**
104
- * Get all {{entitiesLabel}} children
105
- * @access public
106
- * @param bool $asArray
107
- * @return mixed (array|string)
108
- * {{qwertyuiop}}
109
- */
110
- public function getAllChildren($asArray = false){
111
- $children = $this->getResource()->getAllChildren($this);
112
- if ($asArray) {
113
- return $children;
114
- }
115
- else {
116
- return implode(',', $children);
117
- }
118
- }
119
- /**
120
- * Get all {{entitiesLabel}} children
121
- * @access public
122
- * @return string
123
- * {{qwertyuiop}}
124
- */
125
- public function getChildren(){
126
- return implode(',', $this->getResource()->getChildren($this, false));
127
- }
128
- /**
129
- * check the id
130
- * @access public
131
- * @return bool
132
- * {{qwertyuiop}}
133
- */
134
- public function checkId($id){
135
- return $this->_getResource()->checkId($id);
136
- }
137
- /**
138
- * Get array {{entitiesLabel}} ids which are part of {{entityLabel}} path
139
- * @access public
140
- * @return array
141
- * {{qwertyuiop}}
142
- */
143
- public function getPathIds(){
144
- $ids = $this->getData('path_ids');
145
- if (is_null($ids)) {
146
- $ids = explode('/', $this->getPath());
147
- $this->setData('path_ids', $ids);
148
- }
149
- return $ids;
150
- }
151
- /**
152
- * Retrieve level
153
- * @access public
154
- * @return int
155
- * {{qwertyuiop}}
156
- */
157
- public function getLevel(){
158
- if (!$this->hasLevel()) {
159
- return count(explode('/', $this->getPath())) - 1;
160
- }
161
- return $this->getData('level');
162
- }
163
- /**
164
- * Verify {{entityLabel}} ids
165
- * @access public
166
- * @param array $ids
167
- * @return bool
168
- * {{qwertyuiop}}
169
- */
170
- public function verifyIds(array $ids){
171
- return $this->getResource()->verifyIds($ids);
172
- }
173
- /**
174
- * check if {{entityLabel}} has children
175
- * @access public
176
- * @return bool
177
- * {{qwertyuiop}}
178
- */
179
- public function hasChildren(){
180
- return $this->_getResource()->getChildrenAmount($this) > 0;
181
- }
182
- /**
183
- * check if {{entityLabel}} can be deleted
184
- * @access protected
185
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
186
- * {{qwertyuiop}}
187
- */
188
- protected function _beforeDelete(){
189
- if ($this->getResource()->isForbiddenToDelete($this->getId())) {
190
- Mage::throwException(Mage::helper('{{module}}')->__("Can't delete root {{entityLabel}}."));
191
- }
192
- return parent::_beforeDelete();
193
- }
194
- /**
195
- * get the {{entitiesLabel}}
196
- * @access public
197
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $parent
198
- * @param int $recursionLevel
199
- * @param bool $sorted
200
- * @param bool $asCollection
201
- * @param bool $toLoad
202
- * {{qwertyuiop}}
203
- */
204
- public function get{{Entities}}($parent, $recursionLevel = 0, $sorted=false, $asCollection=false, $toLoad=true){
205
- return $this->getResource()->get{{Entities}}($parent, $recursionLevel, $sorted, $asCollection, $toLoad);
206
- }
207
- /**
208
- * Return parent {{entitiesLabel}} of current {{entityLabel}}
209
- * @access public
210
- * @return array
211
- * {{qwertyuiop}}
212
- */
213
- public function getParent{{Entities}}(){
214
- return $this->getResource()->getParent{{Entities}}($this);
215
- }
216
- /**
217
- * Retuen children {{entitiesLabel}} of current {{entityLabel}}
218
- * @access public
219
- * @return array
220
- * {{qwertyuiop}}
221
- */
222
- public function getChildren{{Entities}}(){
223
- return $this->getResource()->getChildren{{Entities}}($this);
224
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/16_tree_status.php DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * check if parents are enabled
3
- * @access public
4
- * @return bool
5
- * {{qwertyuiop}}
6
- */
7
- public function getStatusPath(){
8
- $parents = $this->getParent{{Entities}}();
9
- foreach ($parents as $parent){
10
- if (!$parent->getStatus()){
11
- return false;
12
- }
13
- }
14
- return $this->getStatus();
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/17_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/01_top.php DELETED
@@ -1,116 +0,0 @@
1
- <?php
2
- {{License}}
3
- class {{Namespace}}_{{Module}}_Model_{{Entity}}_Api extends Mage_Api_Model_Resource_Abstract{
4
- /**
5
- * init {{entityLabel}}
6
- * @access protected
7
- * @param ${{entity}}Id
8
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
9
- * {{qwertyuiop}}
10
- */
11
- protected function _init{{Entity}}(${{entity}}Id){
12
- ${{entity}} = Mage::getModel('{{module}}/{{entity}}')->load(${{entity}}Id);
13
- if (!${{entity}}->getId()) {
14
- $this->_fault('{{entity}}_not_exists');
15
- }
16
- return ${{entity}};
17
- }
18
- /**
19
- * get {{entities}}
20
- * @access public
21
- * @param mixed $filters
22
- * @return array
23
- * {{qwertyuiop}}
24
- */
25
- public function items($filters = null){
26
- $collection = Mage::getModel('{{module}}/{{entity}}')->getCollection();
27
- $apiHelper = Mage::helper('api');
28
- $filters = $apiHelper->parseFilters($filters);
29
- try {
30
- foreach ($filters as $field => $value) {
31
- $collection->addFieldToFilter($field, $value);
32
- }
33
- }
34
- catch (Mage_Core_Exception $e) {
35
- $this->_fault('filters_invalid', $e->getMessage());
36
- }
37
- $result = array();
38
- foreach ($collection as ${{entity}}) {
39
- $result[] = ${{entity}}->getData();
40
- }
41
- return $result;
42
- }
43
- /**
44
- * Add {{entity}}
45
- * @access public
46
- * @param array $data
47
- * @return array
48
- * {{qwertyuiop}}
49
- */
50
- public function add($data){
51
- try {
52
- if (is_null($data)){
53
- throw new Exception(Mage::helper('{{module}}')->__("Data cannot be null"));
54
- }
55
- ${{entity}} = Mage::getModel('{{module}}/{{entity}}')
56
- ->setData((array)$data)
57
- ->save();
58
- }
59
- catch (Mage_Core_Exception $e) {
60
- $this->_fault('data_invalid', $e->getMessage());
61
- }
62
- catch (Exception $e) {
63
- $this->_fault('data_invalid', $e->getMessage());
64
- }
65
- return ${{entity}}->getId();
66
- }
67
-
68
- /**
69
- * Change existing {{entity}} information
70
- * @access public
71
- * @param int ${{entity}}Id
72
- * @param array $data
73
- * @return bool
74
- * {{qwertyuiop}}
75
- */
76
- public function update(${{entity}}Id, $data){
77
- ${{entity}} = $this->_init{{Entity}}(${{entity}}Id);
78
- try {
79
- ${{entity}}->addData((array)$data);
80
- ${{entity}}->save();
81
- }
82
- catch (Mage_Core_Exception $e) {
83
- $this->_fault('save_error', $e->getMessage());
84
- }
85
-
86
- return true;
87
- }
88
- /**
89
- * remove {{entity}}
90
- * @access public
91
- * @param int ${{entity}}Id
92
- * @return bool
93
- * {{qwertyuiop}}
94
- */
95
- public function remove(${{entity}}Id){
96
- ${{entity}} = $this->_init{{Entity}}(${{entity}}Id);
97
- try {
98
- ${{entity}}->delete();
99
- }
100
- catch (Mage_Core_Exception $e) {
101
- $this->_fault('remove_error', $e->getMessage());
102
- }
103
- return true;
104
- }
105
- /**
106
- * get info
107
- * @access public
108
- * @param int ${{entity}}Id
109
- * @return array
110
- * {{qwertyuiop}}
111
- */
112
- public function info(${{entity}}Id){
113
- $result = array();
114
- ${{entity}} = $this->_init{{Entity}}(${{entity}}Id);
115
- $result = ${{entity}}->getData();
116
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/02_product_relation_info.php DELETED
@@ -1,6 +0,0 @@
1
- //related products
2
- $result['products'] = array();
3
- $relatedProductsCollection = ${{entity}}->getSelectedProductsCollection();
4
- foreach ($relatedProductsCollection as $product) {
5
- $result['products'][$product->getId()] = $product->getPosition();
6
- }
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/03_sibling_info.php DELETED
@@ -1,6 +0,0 @@
1
- //related {{siblings}}
2
- $result['{{siblings}}'] = array();
3
- $related{{Siblings}}Collection = ${{entity}}->getSelected{{Siblings}}Collection();
4
- foreach ($related{{Siblings}}Collection as ${{sibling}}) {
5
- $result['{{siblings}}'][${{sibling}}->getId()] = ${{sibling}}->getPosition();
6
- }
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/04_info_footer.php DELETED
@@ -1,2 +0,0 @@
1
- return $result;
2
- }
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/05_tree.php DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * Move {{entityLabel}} in tree
3
- *
4
- * @param int ${{entity}}Id
5
- * @param int $parentId
6
- * @param int $afterId
7
- * @return boolean
8
- */
9
- public function move(${{entity}}Id, $parentId, $afterId = null){
10
- ${{entity}} = $this->_init{{Entity}}(${{entity}}Id);
11
- $parent_{{entity}} = $this->_init{{Entity}}($parentId);
12
- if ($afterId === null && $parent_{{entity}}->hasChildren()) {
13
- $parentChildren = $parent_{{entity}}->getChildren();
14
- $afterId = array_pop(explode(',', $parentChildren));
15
- }
16
- if( strpos($parent_{{entity}}->getPath(), ${{entity}}->getPath()) === 0) {
17
- $this->_fault('not_moved', Mage::helper('{{module}}')->__("Cannot move parent inside {{entityLabel}}"));
18
- }
19
- try {
20
- ${{entity}}->move($parentId, $afterId);
21
- }
22
- catch (Mage_Core_Exception $e) {
23
- $this->_fault('not_moved', $e->getMessage());
24
- }
25
- return true;
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/06_product_relation.php DELETED
@@ -1,55 +0,0 @@
1
- /**
2
- * Assign product to {{entityLabel}}
3
- * @access public
4
- * @param int ${{entity}}Id
5
- * @param int ${{entity}}Id
6
- * @param int $position
7
- * @return boolean
8
- * {{qwertyuiop}}
9
- */
10
- public function assignProduct(${{entity}}Id, $productId, $position = null){
11
- ${{entity}} = $this->_init{{Entity}}(${{entity}}Id);
12
- $positions = array();
13
- $products = ${{entity}}->getSelectedProducts();
14
- foreach ($products as $product){
15
- $positions[$product->getId()] = array('position'=>$product->getPosition());
16
- }
17
- $product = Mage::getModel('catalog/product')->load($productId);
18
- if (!$product->getId()){
19
- $this->_fault('product_not_exists');
20
- }
21
- $positions[$productId]['position'] = $position;
22
- ${{entity}}->setProductsData($positions);
23
- try {
24
- ${{entity}}->save();
25
- }
26
- catch (Mage_Core_Exception $e) {
27
- $this->_fault('data_invalid', $e->getMessage());
28
- }
29
- return true;
30
- }
31
- /**
32
- * remove product from {{entityLabel}}
33
- * @access public
34
- * @param int ${{entity}}Id
35
- * @param int $productId
36
- * @return boolean
37
- * {{qwertyuiop}}
38
- */
39
- public function unassignProduct(${{entity}}Id, $productId){
40
- ${{entity}} = $this->_init{{Entity}}(${{entity}}Id);
41
- $positions = array();
42
- $products = ${{entity}}->getSelectedProducts();
43
- foreach ($products as $product){
44
- $positions[$product->getId()] = array('position'=>$product->getPosition());
45
- }
46
- unset($positions[$productId]);
47
- ${{entity}}->setProductsData($positions);
48
- try {
49
- ${{entity}}->save();
50
- }
51
- catch (Mage_Core_Exception $e) {
52
- $this->_fault('data_invalid', $e->getMessage());
53
- }
54
- return true;
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/07_sibling_relation.php DELETED
@@ -1,55 +0,0 @@
1
- /**
2
- * Assign {{siblingLabel}} to {{entityLabel}}
3
- * @access public
4
- * @param int ${{entity}}Id
5
- * @param int ${{sibling}}Id
6
- * @param int $position
7
- * @return boolean
8
- * {{qwertyuiop}}
9
- */
10
- public function assign{{Sibling}}(${{entity}}Id, ${{sibling}}Id, $position = null){
11
- ${{entity}} = $this->_init{{Entity}}(${{entity}}Id);
12
- $positions = array();
13
- ${{siblings}} = ${{entity}}->getSelected{{Siblings}}();
14
- foreach (${{siblings}} as ${{sibling}}){
15
- ${{siblings}}[${{sibling}}->getId()] = array('position'=>${{sibling}}->getPosition());
16
- }
17
- ${{sibling}} = Mage::getModel('{{module}}/{{sibling}}')->load(${{sibling}}Id);
18
- if (!${{sibling}}->getId()){
19
- $this->_fault('{{entity}}_{{sibling}}_not_exists');
20
- }
21
- $positions[${{sibling}}Id]['position'] = $position;
22
- ${{sibling}}->set{{Siblings}}Data($positions);
23
- try {
24
- ${{sibling}}->save();
25
- }
26
- catch (Mage_Core_Exception $e) {
27
- $this->_fault('data_invalid', $e->getMessage());
28
- }
29
- return true;
30
- }
31
- /**
32
- * remove {{siblingLabel}} from {{entityLabel}}
33
- * @access public
34
- * @param int ${{entity}}Id
35
- * @param int ${{sibling}}Id
36
- * @return boolean
37
- * {{qwertyuiop}}
38
- */
39
- public function unassign{{Sibling}}(${{entity}}Id, ${{sibling}}Id){
40
- ${{entity}} = $this->_init{{Entity}}(${{entity}}Id);
41
- $positions = array();
42
- ${{siblings}} = ${{entity}}->getSelected{{Siblings}}();
43
- foreach (${{siblings}} as ${{sibling}}){
44
- ${{siblings}}[${{sibling}}->getId()] = array('position'=>${{sibling}}->getPosition());
45
- }
46
- unset($positions[${{sibling}}Id]);
47
- ${{entity}}->set{{Siblings}}Data($positions);
48
- try {
49
- ${{entity}}->save();
50
- }
51
- catch (Mage_Core_Exception $e) {
52
- $this->_fault('data_invalid', $e->getMessage());
53
- }
54
- return true;
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/08_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/V2/01_top.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- {{License}}
3
- class {{Namespace}}_{{Module}}_Model_{{Entity}}_Api_V2 extends {{Namespace}}_{{Module}}_Model_{{Entity}}_Api{
4
- /**
5
- * {{EntityLabel}} info
6
- * @access public
7
- * @param int ${{entity}}Id
8
- * @return object
9
- * {{qwertyuiop}}
10
- */
11
- public function info(${{entity}}Id){
12
- $result = parent::info(${{entity}}Id);
13
- $result = Mage::helper('api')->wsiArrayPacker($result);
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/V2/02_product_relation.php DELETED
@@ -1,3 +0,0 @@
1
- foreach ($result->products as $key => $value) {
2
- $result->products[$key] = array('key' => $key, 'value' => $value);
3
- }
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/V2/03_sibling_relation.php DELETED
@@ -1,3 +0,0 @@
1
- foreach ($result->{{siblings}} as $key => $value) {
2
- $result->{{siblings}}[$key] = array('key' => $key, 'value' => $value);
3
- }
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Api/V2/04_footer.php DELETED
@@ -1,3 +0,0 @@
1
- return $result;
2
- }
3
- }
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Product/01_content.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} product model
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_{{Entity}}_Product extends Mage_Core_Model_Abstract{
11
- /**
12
- * Initialize resource
13
- * @access protected
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- protected function _construct(){
18
- $this->_init('{{module}}/{{entity}}_product');
19
- }
20
- /**
21
- * Save data for {{entity}}-product relation
22
- * @access public
23
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
24
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_Product
25
- * {{qwertyuiop}}
26
- */
27
- public function save{{Entity}}Relation(${{entity}}){
28
- $data = ${{entity}}->getProductsData();
29
- if (!is_null($data)) {
30
- $this->_getResource()->save{{Entity}}Relation(${{entity}}, $data);
31
- }
32
- return $this;
33
- }
34
- /**
35
- * get products for {{entity}}
36
- * @access public
37
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
38
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product_Collection
39
- * {{qwertyuiop}}
40
- */
41
- public function getProductCollection(${{entity}}){
42
- $collection = Mage::getResourceModel('{{module}}/{{entity}}_product_collection')
43
- ->add{{Entity}}Filter(${{entity}});
44
- return $collection;
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Entity/Sibling/01_content.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} {{siblingLabel}} model
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_{{Entity}}_{{Sibling}} extends Mage_Core_Model_Abstract{
11
- /**
12
- * Initialize resource
13
- * @access protected
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- protected function _construct(){
18
- $this->_init('{{module}}/{{entity}}_{{sibling}}');
19
- }
20
- /**
21
- * Save data for {{entity}} - {{sibling}} relation
22
- * @access public
23
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
24
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_{{Sibling}}
25
- * {{qwertyuiop}}
26
- */
27
- public function save{{Entity}}Relation(${{entity}}){
28
- $data = ${{entity}}->get{{Siblings}}Data();
29
- if (!is_null($data)) {
30
- $this->_getResource()->save{{Entity}}Relation(${{entity}}, $data);
31
- }
32
- return $this;
33
- }
34
- /**
35
- * get {{siblings}} for {{entity}}
36
- * @access public
37
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
38
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}}_Collection
39
- * {{qwertyuiop}}
40
- */
41
- public function get{{Siblings}}Collection(${{entity}}){
42
- $collection = Mage::getResourceModel('{{module}}/{{entity}}_{{sibling}}_collection')
43
- ->add{{Entity}}Filter(${{entity}});
44
- return $collection;
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/01_top.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} resource model
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} extends Mage_Core_Model_Resource_Db_Abstract{
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/02_tree_var.php DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * {{EntityLabel}} tree object
3
- * @var Varien_Data_Tree_Db
4
- */
5
- protected $_tree;
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/03_constructor.php DELETED
@@ -1,62 +0,0 @@
1
- /**
2
- * constructor
3
- * @access public
4
- * @return void
5
- * {{qwertyuiop}}
6
- */
7
- public function _construct(){
8
- $this->_init('{{module}}/{{entity}}', 'entity_id');
9
- }
10
-
11
- /**
12
- * Get store ids to which specified item is assigned
13
- * @access public
14
- * @param int ${{entity}}Id
15
- * @return array
16
- * {{qwertyuiop}}
17
- */
18
- public function lookupStoreIds(${{entity}}Id){
19
- $adapter = $this->_getReadAdapter();
20
- $select = $adapter->select()
21
- ->from($this->getTable('{{module}}/{{entity}}_store'), 'store_id')
22
- ->where('{{entity}}_id = ?',(int)${{entity}}Id);
23
- return $adapter->fetchCol($select);
24
- }
25
- /**
26
- * Perform operations after object load
27
- * @access public
28
- * @param Mage_Core_Model_Abstract $object
29
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
30
- * {{qwertyuiop}}
31
- */
32
- protected function _afterLoad(Mage_Core_Model_Abstract $object){
33
- if ($object->getId()) {
34
- $stores = $this->lookupStoreIds($object->getId());
35
- $object->setData('store_id', $stores);
36
- }
37
- return parent::_afterLoad($object);
38
- }
39
-
40
- /**
41
- * Retrieve select object for load object data
42
- *
43
- * @param string $field
44
- * @param mixed $value
45
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $object
46
- * @return Zend_Db_Select
47
- */
48
- protected function _getLoadSelect($field, $value, $object){
49
- $select = parent::_getLoadSelect($field, $value, $object);
50
- if ($object->getStoreId()) {
51
- $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
52
- $select->join(
53
- array('{{module}}_{{entity}}_store' => $this->getTable('{{module}}/{{entity}}_store')),
54
- $this->getMainTable() . '.entity_id = {{module}}_{{entity}}_store.{{entity}}_id',
55
- array()
56
- )
57
- ->where('{{module}}_{{entity}}_store.store_id IN (?)', $storeIds)
58
- ->order('{{module}}_{{entity}}_store.store_id DESC')
59
- ->limit(1);
60
- }
61
- return $select;
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/04_not_tree.php DELETED
@@ -1,35 +0,0 @@
1
- /**
2
- * Assign {{entityLabel}} to store views
3
- * @access protected
4
- * @param Mage_Core_Model_Abstract $object
5
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
6
- * {{qwertyuiop}}
7
- */
8
- protected function _afterSave(Mage_Core_Model_Abstract $object){
9
- $oldStores = $this->lookupStoreIds($object->getId());
10
- $newStores = (array)$object->getStores();
11
- if (empty($newStores)) {
12
- $newStores = (array)$object->getStoreId();
13
- }
14
- $table = $this->getTable('{{module}}/{{entity}}_store');
15
- $insert = array_diff($newStores, $oldStores);
16
- $delete = array_diff($oldStores, $newStores);
17
- if ($delete) {
18
- $where = array(
19
- '{{entity}}_id = ?' => (int) $object->getId(),
20
- 'store_id IN (?)' => $delete
21
- );
22
- $this->_getWriteAdapter()->delete($table, $where);
23
- }
24
- if ($insert) {
25
- $data = array();
26
- foreach ($insert as $storeId) {
27
- $data[] = array(
28
- '{{entity}}_id' => (int) $object->getId(),
29
- 'store_id' => (int) $storeId
30
- );
31
- }
32
- $this->_getWriteAdapter()->insertMultiple($table, $data);
33
- }
34
- return parent::_afterSave($object);
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/05_tree.php DELETED
@@ -1,193 +0,0 @@
1
- /**
2
- * Retrieve {{entityLabel}} tree object
3
- * @access protected
4
- * @return Varien_Data_Tree_Db
5
- * {{qwertyuiop}}
6
- */
7
- protected function _getTree(){
8
- if (!$this->_tree) {
9
- $this->_tree = Mage::getResourceModel('{{module}}/{{entity}}_tree')->load();
10
- }
11
- return $this->_tree;
12
- }
13
- /**
14
- * Process {{entityLabel}} data before delete
15
- * update children count for parent {{entityLabel}}
16
- * delete child {{entitiesLabel}}
17
- * @access protected
18
- * @param Varien_Object $object
19
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
20
- * {{qwertyuiop}}
21
- */
22
- protected function _beforeDelete(Mage_Core_Model_Abstract $object){
23
- parent::_beforeDelete($object);
24
- /**
25
- * Update children count for all parent {{entitiesLabel}}
26
- */
27
- $parentIds = $object->getParentIds();
28
- if ($parentIds) {
29
- $childDecrease = $object->getChildrenCount() + 1; // +1 is itself
30
- $data = array('children_count' => new Zend_Db_Expr('children_count - ' . $childDecrease));
31
- $where = array('entity_id IN(?)' => $parentIds);
32
- $this->_getWriteAdapter()->update( $this->getMainTable(), $data, $where);
33
- }
34
- $this->deleteChildren($object);
35
- return $this;
36
- }
37
- /**
38
- * Delete children {{entitiesLabel}} of specific {{entityLabel}}
39
- * @access public
40
- * @param Varien_Object $object
41
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
42
- * {{qwertyuiop}}
43
- */
44
- public function deleteChildren(Varien_Object $object){
45
- $adapter = $this->_getWriteAdapter();
46
- $pathField = $adapter->quoteIdentifier('path');
47
- $select = $adapter->select()
48
- ->from($this->getMainTable(), array('entity_id'))
49
- ->where($pathField . ' LIKE :c_path');
50
- $childrenIds = $adapter->fetchCol($select, array('c_path' => $object->getPath() . '/%'));
51
- if (!empty($childrenIds)) {
52
- $adapter->delete(
53
- $this->getMainTable(),
54
- array('entity_id IN (?)' => $childrenIds)
55
- );
56
- }
57
- /**
58
- * Add deleted children ids to object
59
- * This data can be used in after delete event
60
- */
61
- $object->setDeletedChildrenIds($childrenIds);
62
- return $this;
63
- }
64
- /**
65
- * Process {{entityLabel}} data after save {{entityLabel}} object
66
- * @access protected
67
- * @param Varien_Object $object
68
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
69
- * {{qwertyuiop}}
70
- */
71
- protected function _afterSave(Mage_Core_Model_Abstract $object){
72
- if (substr($object->getPath(), -1) == '/') {
73
- $object->setPath($object->getPath() . $object->getId());
74
- $this->_savePath($object);
75
- }
76
- $oldStores = $this->lookupStoreIds($object->getId());
77
- $newStores = (array)$object->getStores();
78
- if (empty($newStores)) {
79
- $newStores = (array)$object->getStoreId();
80
- }
81
- $table = $this->getTable('{{module}}/{{entity}}_store');
82
- $insert = array_diff($newStores, $oldStores);
83
- $delete = array_diff($oldStores, $newStores);
84
- if ($delete) {
85
- $where = array(
86
- '{{entity}}_id = ?' => (int) $object->getId(),
87
- 'store_id IN (?)' => $delete
88
- );
89
- $this->_getWriteAdapter()->delete($table, $where);
90
- }
91
- if ($insert) {
92
- $data = array();
93
- foreach ($insert as $storeId) {
94
- $data[] = array(
95
- '{{entity}}_id' => (int) $object->getId(),
96
- 'store_id' => (int) $storeId
97
- );
98
- }
99
- $this->_getWriteAdapter()->insertMultiple($table, $data);
100
- }
101
- return parent::_afterSave($object);
102
- }
103
-
104
- /**
105
- * Update path field
106
- * @access protected
107
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $object
108
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
109
- * {{qwertyuiop}}
110
- */
111
- protected function _savePath($object){
112
- if ($object->getId()) {
113
- $this->_getWriteAdapter()->update(
114
- $this->getMainTable(),
115
- array('path' => $object->getPath()),
116
- array('entity_id = ?' => $object->getId())
117
- );
118
- }
119
- return $this;
120
- }
121
-
122
- /**
123
- * Get maximum position of child {{entitiesLabel}} by specific tree path
124
- * @access protected
125
- * @param string $path
126
- * @return int
127
- * {{qwertyuiop}}
128
- */
129
- protected function _getMaxPosition($path){
130
- $adapter = $this->getReadConnection();
131
- $positionField = $adapter->quoteIdentifier('position');
132
- $level = count(explode('/', $path));
133
- $bind = array(
134
- 'c_level' => $level,
135
- 'c_path' => $path . '/%'
136
- );
137
- $select = $adapter->select()
138
- ->from($this->getMainTable(), 'MAX(' . $positionField . ')')
139
- ->where($adapter->quoteIdentifier('path') . ' LIKE :c_path')
140
- ->where($adapter->quoteIdentifier('level') . ' = :c_level');
141
-
142
- $position = $adapter->fetchOne($select, $bind);
143
- if (!$position) {
144
- $position = 0;
145
- }
146
- return $position;
147
- }
148
- /**
149
- * Get children {{entitiesLabel}} count
150
- * @access public
151
- * @param int ${{entity}}Id
152
- * @return int
153
- * {{qwertyuiop}}
154
- */
155
- public function getChildrenCount(${{entity}}Id){
156
- $select = $this->_getReadAdapter()->select()
157
- ->from($this->getMainTable(), 'children_count')
158
- ->where('entity_id = :entity_id');
159
- $bind = array('entity_id' => ${{entity}}Id);
160
- return $this->_getReadAdapter()->fetchOne($select, $bind);
161
- }
162
- /**
163
- * Check if {{entityLabel}} id exist
164
- * @access public
165
- * @param int $entityId
166
- * @return bool
167
- * {{qwertyuiop}}
168
- */
169
- public function checkId($entityId){
170
- $select = $this->_getReadAdapter()->select()
171
- ->from($this->getMainTable(), 'entity_id')
172
- ->where('entity_id = :entity_id');
173
- $bind = array('entity_id' => $entityId);
174
- return $this->_getReadAdapter()->fetchOne($select, $bind);
175
- }
176
-
177
- /**
178
- * Check array of {{entitiesLabel}} identifiers
179
- * @access public
180
- * @param array $ids
181
- * @return array
182
- * {{qwertyuiop}}
183
- */
184
- public function verifyIds(array $ids){
185
- if (empty($ids)) {
186
- return array();
187
- }
188
- $select = $this->_getReadAdapter()->select()
189
- ->from($this->getMainTable(), 'entity_id')
190
- ->where('entity_id IN(?)', $ids);
191
-
192
- return $this->_getReadAdapter()->fetchCol($select);
193
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/06_tree_before_save_no_url_rewrite.php DELETED
@@ -1,34 +0,0 @@
1
- /**
2
- * Process {{entityLabel}} data before saving
3
- * prepare path and increment children count for parent {{entitiesLabel}}
4
- * @access protected
5
- * @param Varien_Object $object
6
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
7
- * {{qwertyuiop}}
8
- */
9
- protected function _beforeSave(Mage_Core_Model_Abstract $object){
10
- parent::_beforeSave($object);
11
- if (!$object->getChildrenCount()) {
12
- $object->setChildrenCount(0);
13
- }
14
- if ($object->getLevel() === null) {
15
- $object->setLevel(1);
16
- }
17
- if (!$object->getId() && !$object->getInitialSetupFlag()) {
18
- $object->setPosition($this->_getMaxPosition($object->getPath()) + 1);
19
- $path = explode('/', $object->getPath());
20
- $level = count($path);
21
- $object->setLevel($level);
22
- if ($level) {
23
- $object->setParentId($path[$level - 1]);
24
- }
25
- $object->setPath($object->getPath() . '/');
26
- $toUpdateChild = explode('/',$object->getPath());
27
- $this->_getWriteAdapter()->update(
28
- $this->getMainTable(),
29
- array('children_count' => new Zend_Db_Expr('children_count+1')),
30
- array('entity_id IN(?)' => $toUpdateChild)
31
- );
32
- }
33
- return $this;
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/07_tree_before_save_url_rewrite.php DELETED
@@ -1,45 +0,0 @@
1
- /**
2
- * Process {{entityLabel}} data before saving
3
- * prepare path and increment children count for parent {{entitiesLabel}}
4
- * @access protected
5
- * @param Varien_Object $object
6
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
7
- * {{qwertyuiop}}
8
- */
9
- protected function _beforeSave(Mage_Core_Model_Abstract $object){
10
- if (!$object->getInitialSetupFlag()){
11
- if (!$this->getIsUniqueUrlKey($object)) {
12
- Mage::throwException(Mage::helper('{{module}}')->__('URL key already exists.'));
13
- }
14
- if (!$this->isValidUrlKey($object)) {
15
- Mage::throwException(Mage::helper('{{module}}')->__('The URL key contains capital letters or disallowed symbols.'));
16
- }
17
- if ($this->isNumericUrlKey($object)) {
18
- Mage::throwException(Mage::helper('{{module}}')->__('The URL key cannot consist only of numbers.'));
19
- }
20
- }
21
- parent::_beforeSave($object);
22
- if (!$object->getChildrenCount()) {
23
- $object->setChildrenCount(0);
24
- }
25
- if ($object->getLevel() === null) {
26
- $object->setLevel(1);
27
- }
28
- if (!$object->getId() && !$object->getInitialSetupFlag()) {
29
- $object->setPosition($this->_getMaxPosition($object->getPath()) + 1);
30
- $path = explode('/', $object->getPath());
31
- $level = count($path);
32
- $object->setLevel($level);
33
- if ($level) {
34
- $object->setParentId($path[$level - 1]);
35
- }
36
- $object->setPath($object->getPath() . '/');
37
- $toUpdateChild = explode('/',$object->getPath());
38
- $this->_getWriteAdapter()->update(
39
- $this->getMainTable(),
40
- array('children_count' => new Zend_Db_Expr('children_count+1')),
41
- array('entity_id IN(?)' => $toUpdateChild)
42
- );
43
- }
44
- return $this;
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/08_children_no_status.php DELETED
@@ -1,67 +0,0 @@
1
- /**
2
- * Get count of children {{entitiesLabel}}
3
- * @access public
4
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
5
- * @return int
6
- * {{qwertyuiop}}
7
- */
8
- public function getChildrenAmount(${{entity}}){
9
- $bind = array(
10
- 'c_path' => ${{entity}}->getPath() . '/%'
11
- );
12
- $select = $adapter->select()
13
- ->from(array('m' => $this->getMainTable()), array('COUNT(m.entity_id)'))
14
- ->where('m.path LIKE :c_path')
15
- return $this->_getReadAdapter()->fetchOne($select, $bind);
16
- }
17
- /**
18
- * Return parent {{entitiesLabel}} of {{entityLabel}}
19
- * @access public
20
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
21
- * @return array
22
- * {{qwertyuiop}}
23
- */
24
- public function getParent{{Entities}}(${{entity}}){
25
- $pathIds = array_reverse(explode('/', ${{entity}}->getPath()));
26
- ${{entities}} = Mage::getResourceModel('{{module}}/{{entity}}_collection')
27
- ->addFieldToFilter('entity_id', array('in' => $pathIds))
28
- ->load()
29
- ->getItems();
30
- return ${{entities}};
31
- }
32
- /**
33
- * Return child {{entitiesLabel}}
34
- * @access public
35
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
36
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
37
- * {{qwertyuiop}}
38
- */
39
- public function getChildren{{Entities}}(${{entity}}){
40
- $collection = ${{entity}}->getCollection();
41
- $collection
42
- ->addIdFilter(${{entity}}->getChildren())
43
- ->setOrder('position', Varien_Db_Select::SQL_ASC)
44
- ->load();
45
- return $collection;
46
- }
47
- /**
48
- * Return children ids of {{entityLabel}}
49
- * @access public
50
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
51
- * @param boolean $recursive
52
- * @return array
53
- * {{qwertyuiop}}
54
- */
55
- public function getChildren(${{entity}}, $recursive = true){
56
- $bind = array(
57
- 'c_path' => ${{entity}}->getPath() . '/%'
58
- );
59
- $select = $this->_getReadAdapter()->select()
60
- ->from(array('m' => $this->getMainTable()), 'entity_id')
61
- ->where($this->_getReadAdapter()->quoteIdentifier('path') . ' LIKE :c_path');
62
- if (!$recursive) {
63
- $select->where($this->_getReadAdapter()->quoteIdentifier('level') . ' <= :c_level');
64
- $bind['c_level'] = ${{entity}}->getLevel() + 1;
65
- }
66
- return $this->_getReadAdapter()->fetchCol($select, $bind);
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/09_children_status.php DELETED
@@ -1,73 +0,0 @@
1
- /**
2
- * Get count of active/not active children {{entitiesLabel}}
3
- *
4
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
5
- * @param bool $isActiveFlag
6
- * @return int
7
- * {{qwertyuiop}}
8
- */
9
- public function getChildrenAmount(${{entity}}, $isActiveFlag = true){
10
- $bind = array(
11
- 'active_flag' => $isActiveFlag,
12
- 'c_path' => ${{entity}}->getPath() . '/%'
13
- );
14
- $select = $adapter->select()
15
- ->from(array('m' => $this->getMainTable()), array('COUNT(m.entity_id)'))
16
- ->where('m.path LIKE :c_path')
17
- ->where('status' . ' = :active_flag');
18
- return $this->_getReadAdapter()->fetchOne($select, $bind);
19
- }
20
- /**
21
- * Return parent {{entitiesLabel}} of {{entityLabel}}
22
- * @access public
23
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
24
- * @return array
25
- * {{qwertyuiop}}
26
- */
27
- public function getParent{{Entities}}(${{entity}}){
28
- $pathIds = array_reverse(explode('/', ${{entity}}->getPath()));
29
- ${{entities}} = Mage::getResourceModel('{{module}}/{{entity}}_collection')
30
- ->addFieldToFilter('entity_id', array('in' => $pathIds))
31
- ->addFieldToFilter('status', 1)
32
- ->load()
33
- ->getItems();
34
- return ${{entities}};
35
- }
36
- /**
37
- * Return child {{entitiesLabel}}
38
- * @access public
39
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
40
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
41
- * {{qwertyuiop}}
42
- */
43
- public function getChildren{{Entities}}(${{entity}}){
44
- $collection = ${{entity}}->getCollection();
45
- $collection
46
- ->addFilter('status', 1)
47
- ->addIdFilter(${{entity}}->getChildren())
48
- ->setOrder('position', Varien_Db_Select::SQL_ASC)
49
- ->load();
50
- return $collection;
51
- }
52
- /**
53
- * Return children ids of {{entityLabel}}
54
- * @access public
55
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
56
- * @param boolean $recursive
57
- * @return array
58
- * {{qwertyuiop}}
59
- */
60
- public function getChildren(${{entity}}, $recursive = true){
61
- $bind = array(
62
- 'c_path' => ${{entity}}->getPath() . '/%'
63
- );
64
- $select = $this->_getReadAdapter()->select()
65
- ->from(array('m' => $this->getMainTable()), 'entity_id')
66
- ->where('status = ?', 1)
67
- ->where($this->_getReadAdapter()->quoteIdentifier('path') . ' LIKE :c_path');
68
- if (!$recursive) {
69
- $select->where($this->_getReadAdapter()->quoteIdentifier('level') . ' <= :c_level');
70
- $bind['c_level'] = ${{entity}}->getLevel() + 1;
71
- }
72
- return $this->_getReadAdapter()->fetchCol($select, $bind);
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/10_content.php DELETED
@@ -1,186 +0,0 @@
1
- /**
2
- * Retrieve {{entitiesLabel}}
3
- * @access public
4
- * @param integer $parent
5
- * @param integer $recursionLevel
6
- * @param boolean|string $sorted
7
- * @param boolean $asCollection
8
- * @param boolean $toLoad
9
- * @return Varien_Data_Tree_Node_Collection|{{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
10
- * {{qwertyuiop}}
11
- */
12
- public function get{{Entities}}($parent, $recursionLevel = 0, $sorted = false, $asCollection = false, $toLoad = true){
13
- $tree = Mage::getResourceModel('{{module}}/{{entity}}_tree');
14
- $nodes = $tree->loadNode($parent)
15
- ->loadChildren($recursionLevel)
16
- ->getChildren();
17
- $tree->addCollectionData(null, $sorted, $parent, $toLoad, true);
18
- if ($asCollection) {
19
- return $tree->getCollection();
20
- }
21
- return $nodes;
22
- }
23
- /**
24
- * Return all children ids of {{entity}} (with {{entity}} id)
25
- * @access public
26
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
27
- * @return array
28
- * {{qwertyuiop}}
29
- */
30
- public function getAllChildren(${{entity}}){
31
- $children = $this->getChildren(${{entity}});
32
- $myId = array(${{entity}}->getId());
33
- $children = array_merge($myId, $children);
34
- return $children;
35
- }
36
- /**
37
- * Check {{entityLabel}} is forbidden to delete.
38
- * @access public
39
- * @param integer ${{entity}}Id
40
- * @return boolean
41
- * {{qwertyuiop}}
42
- */
43
- public function isForbiddenToDelete(${{entity}}Id){
44
- return (${{entity}}Id == Mage::helper('{{module}}/{{entity}}')->getRoot{{Entity}}Id());
45
- }
46
- /**
47
- * Get {{entityLabel}} path value by its id
48
- * @access public
49
- * @param int ${{entity}}Id
50
- * @return string
51
- * {{qwertyuiop}}
52
- */
53
- public function get{{Entity}}PathById(${{entity}}Id){
54
- $select = $this->getReadConnection()->select()
55
- ->from($this->getMainTable(), array('path'))
56
- ->where('entity_id = :entity_id');
57
- $bind = array('entity_id' => (int)${{entity}}Id);
58
- return $this->getReadConnection()->fetchOne($select, $bind);
59
- }
60
- /**
61
- * Move {{entityLabel}} to another parent node
62
- * @access public
63
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
64
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $newParent
65
- * @param null|int $after{{Entity}}Id
66
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
67
- * {{qwertyuiop}}
68
- */
69
- public function changeParent({{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}, {{Namespace}}_{{Module}}_Model_{{Entity}} $newParent, $after{{Entity}}Id = null){
70
- $childrenCount = $this->getChildrenCount(${{entity}}->getId()) + 1;
71
- $table = $this->getMainTable();
72
- $adapter = $this->_getWriteAdapter();
73
- $levelFiled = $adapter->quoteIdentifier('level');
74
- $pathField = $adapter->quoteIdentifier('path');
75
-
76
- /**
77
- * Decrease children count for all old {{entityLabel}} parent {{entitiesLabel}}
78
- */
79
- $adapter->update(
80
- $table,
81
- array('children_count' => new Zend_Db_Expr('children_count - ' . $childrenCount)),
82
- array('entity_id IN(?)' => ${{entity}}->getParentIds())
83
- );
84
- /**
85
- * Increase children count for new {{entityLabel}} parents
86
- */
87
- $adapter->update(
88
- $table,
89
- array('children_count' => new Zend_Db_Expr('children_count + ' . $childrenCount)),
90
- array('entity_id IN(?)' => $newParent->getPathIds())
91
- );
92
-
93
- $position = $this->_processPositions(${{entity}}, $newParent, $after{{Entity}}Id);
94
-
95
- $newPath = sprintf('%s/%s', $newParent->getPath(), ${{entity}}->getId());
96
- $newLevel = $newParent->getLevel() + 1;
97
- $levelDisposition = $newLevel - ${{entity}}->getLevel();
98
-
99
- /**
100
- * Update children nodes path
101
- */
102
- $adapter->update(
103
- $table,
104
- array(
105
- 'path' => new Zend_Db_Expr('REPLACE(' . $pathField . ','.
106
- $adapter->quote(${{entity}}->getPath() . '/'). ', '.$adapter->quote($newPath . '/').')'
107
- ),
108
- 'level' => new Zend_Db_Expr( $levelFiled . ' + ' . $levelDisposition)
109
- ),
110
- array($pathField . ' LIKE ?' => ${{entity}}->getPath() . '/%')
111
- );
112
- /**
113
- * Update moved {{entityLabel}} data
114
- */
115
- $data = array(
116
- 'path' => $newPath,
117
- 'level' => $newLevel,
118
- 'position' =>$position,
119
- 'parent_id' =>$newParent->getId()
120
- );
121
- $adapter->update($table, $data, array('entity_id = ?' => ${{entity}}->getId()));
122
- // Update {{entityLabel}} object to new data
123
- ${{entity}}->addData($data);
124
- return $this;
125
- }
126
- /**
127
- * Process positions of old parent {{entityLabel}} children and new parent {{entityLabel}} children.
128
- * Get position for moved {{entityLabel}}
129
- * @access protected
130
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
131
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $newParent
132
- * @param null|int $after{{Entity}}Id
133
- * @return int
134
- * {{qwertyuiop}}
135
- */
136
- protected function _processPositions(${{entity}}, $newParent, $after{{Entity}}Id){
137
- $table = $this->getMainTable();
138
- $adapter= $this->_getWriteAdapter();
139
- $positionField = $adapter->quoteIdentifier('position');
140
-
141
- $bind = array(
142
- 'position' => new Zend_Db_Expr($positionField . ' - 1')
143
- );
144
- $where = array(
145
- 'parent_id = ?' => ${{entity}}->getParentId(),
146
- $positionField . ' > ?' => ${{entity}}->getPosition()
147
- );
148
- $adapter->update($table, $bind, $where);
149
-
150
- /**
151
- * Prepare position value
152
- */
153
- if ($after{{Entity}}Id) {
154
- $select = $adapter->select()
155
- ->from($table,'position')
156
- ->where('entity_id = :entity_id');
157
- $position = $adapter->fetchOne($select, array('entity_id' => $after{{Entity}}Id));
158
- $bind = array(
159
- 'position' => new Zend_Db_Expr($positionField . ' + 1')
160
- );
161
- $where = array(
162
- 'parent_id = ?' => $newParent->getId(),
163
- $positionField . ' > ?' => $position
164
- );
165
- $adapter->update($table, $bind, $where);
166
- }
167
- elseif ($after{{Entity}}Id !== null) {
168
- $position = 0;
169
- $bind = array(
170
- 'position' => new Zend_Db_Expr($positionField . ' + 1')
171
- );
172
- $where = array(
173
- 'parent_id = ?' => $newParent->getId(),
174
- $positionField . ' > ?' => $position
175
- );
176
- $adapter->update($table, $bind, $where);
177
- }
178
- else {
179
- $select = $adapter->select()
180
- ->from($table,array('position' => new Zend_Db_Expr('MIN(' . $positionField. ')')))
181
- ->where('parent_id = :parent_id');
182
- $position = $adapter->fetchOne($select, array('parent_id' => $newParent->getId()));
183
- }
184
- $position += 1;
185
- return $position;
186
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/11_url_rewrite_status.php DELETED
@@ -1,82 +0,0 @@
1
- /**
2
- * check url key
3
- * @access public
4
- * @param string $urlKey
5
- * @param bool $active
6
- * @return mixed
7
- * {{qwertyuiop}}
8
- */
9
- public function checkUrlKey($urlKey, $storeId, $active = true){
10
- $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID, $storeId);
11
- $select = $this->_initCheckUrlKeySelect($urlKey, $stores);
12
- if (!is_null($active)) {
13
- $select->where('e.status = ?', $active);
14
- }
15
- $select->reset(Zend_Db_Select::COLUMNS)
16
- ->columns('e.entity_id')
17
- ->limit(1);
18
-
19
- return $this->_getReadAdapter()->fetchOne($select);
20
- }
21
- /**
22
- * init the check select
23
- * @access protected
24
- * @param string $urlKey
25
- * @param array $store
26
- * @return Zend_Db_Select
27
- * {{qwertyuiop}}
28
- */
29
- protected function _initCheckUrlKeySelect($urlKey, $store){
30
- $select = $this->_getReadAdapter()->select()
31
- ->from(array('e' => $this->getMainTable()))
32
- ->join(
33
- array('es' => $this->getTable('{{module}}/{{entity}}_store')),
34
- 'e.entity_id = es.{{entity}}_id',
35
- array())
36
- ->where('e.url_key = ?', $urlKey)
37
- ->where('es.store_id IN (?)', $store);
38
- return $select;
39
- }
40
- /**
41
- * Check for unique URL key
42
- * @access public
43
- * @param Mage_Core_Model_Abstract $object
44
- * @return bool
45
- * {{qwertyuiop}}
46
- */
47
- public function getIsUniqueUrlKey(Mage_Core_Model_Abstract $object){
48
- if (Mage::app()->isSingleStoreMode() || !$object->hasStores()) {
49
- $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
50
- }
51
- else {
52
- $stores = (array)$object->getData('stores');
53
- }
54
- $select = $this->_initCheckUrlKeySelect($object->getData('url_key'), $stores);
55
- if ($object->getId()) {
56
- $select->where('e.entity_id <> ?', $object->getId());
57
- }
58
- if ($this->_getWriteAdapter()->fetchRow($select)) {
59
- return false;
60
- }
61
- return true;
62
- }
63
- /**
64
- * Check if the URL key is numeric
65
- * @access public
66
- * @param Mage_Core_Model_Abstract $object
67
- * @return bool
68
- * {{qwertyuiop}}
69
- */
70
- protected function isNumericUrlKey(Mage_Core_Model_Abstract $object){
71
- return preg_match('/^[0-9]+$/', $object->getData('url_key'));
72
- }
73
- /**
74
- * Checkif the URL key is valid
75
- * @access public
76
- * @param Mage_Core_Model_Abstract $object
77
- * @return bool
78
- * {{qwertyuiop}}
79
- */
80
- protected function isValidUrlKey(Mage_Core_Model_Abstract $object){
81
- return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('url_key'));
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/12_url_rewrite_not_status.php DELETED
@@ -1,78 +0,0 @@
1
- /**
2
- * check url key
3
- * @access public
4
- * @param string $urlKey
5
- * @return mixed
6
- * {{qwertyuiop}}
7
- */
8
- public function checkUrlKey($urlKey, $storeId){
9
- $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID, $storeId);
10
- $select = $this->_initCheckUrlKeySelect($urlKey, $stores);
11
- $select->reset(Zend_Db_Select::COLUMNS)
12
- ->columns('e.entity_id')
13
- ->limit(1);
14
-
15
- return $this->_getReadAdapter()->fetchOne($select);
16
- }
17
- /**
18
- * init the check select
19
- * @access protected
20
- * @param string $urlKey
21
- * @param array $store
22
- * @return Zend_Db_Select
23
- * {{qwertyuiop}}
24
- */
25
- protected function _initCheckUrlKeySelect($urlKey, $store){
26
- $select = $this->_getReadAdapter()->select()
27
- ->from(array('e' => $this->getMainTable()))
28
- ->join(
29
- array('es' => $this->getTable('{{module}}/{{entity}}_store')),
30
- 'e.entity_id = es.{{entity}}_id',
31
- array())
32
- ->where('e.url_key = ?', $urlKey)
33
- ->where('es.store_id IN (?)', $store);
34
- return $select;
35
- }
36
- /**
37
- * Check for unique URL key
38
- * @access public
39
- * @param Mage_Core_Model_Abstract $object
40
- * @return bool
41
- * {{qwertyuiop}}
42
- */
43
- public function getIsUniqueUrlKey(Mage_Core_Model_Abstract $object){
44
- if (Mage::app()->isSingleStoreMode() || !$object->hasStores()) {
45
- $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
46
- }
47
- else {
48
- $stores = (array)$object->getData('stores');
49
- }
50
- $select = $this->_initCheckUrlKeySelect($object->getData('url_key'), $stores);
51
- if ($object->getId()) {
52
- $select->where('e.entity_id <> ?', $object->getId());
53
- }
54
- if ($this->_getWriteAdapter()->fetchRow($select)) {
55
- return false;
56
- }
57
- return true;
58
- }
59
- /**
60
- * Check if the URL key is numeric
61
- * @access public
62
- * @param Mage_Core_Model_Abstract $object
63
- * @return bool
64
- * {{qwertyuiop}}
65
- */
66
- protected function isNumericUrlKey(Mage_Core_Model_Abstract $object){
67
- return preg_match('/^[0-9]+$/', $object->getData('url_key'));
68
- }
69
- /**
70
- * Checkif the URL key is valid
71
- * @access public
72
- * @param Mage_Core_Model_Abstract $object
73
- * @return bool
74
- * {{qwertyuiop}}
75
- */
76
- protected function isValidUrlKey(Mage_Core_Model_Abstract $object){
77
- return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('url_key'));
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/13_url_rewrite_before_save_not_tree.php DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * validate before saving
3
- * @access protected
4
- * @param $object
5
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}
6
- * {{qwertyuiop}}
7
- */
8
- protected function _beforeSave(Mage_Core_Model_Abstract $object){
9
- if (!$this->getIsUniqueUrlKey($object)) {
10
- Mage::throwException(Mage::helper('{{module}}')->__('URL key already exists.'));
11
- }
12
- if (!$this->isValidUrlKey($object)) {
13
- Mage::throwException(Mage::helper('{{module}}')->__('The URL key contains capital letters or disallowed symbols.'));
14
- }
15
- if ($this->isNumericUrlKey($object)) {
16
- Mage::throwException(Mage::helper('{{module}}')->__('The URL key cannot consist only of numbers.'));
17
- }
18
- return parent::_beforeSave($object);
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/14_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/01_top.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} collection resource model
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract{
11
- protected $_joinedFields = array();
12
- /**
13
- * constructor
14
- * @access public
15
- * @return void
16
- * {{qwertyuiop}}
17
- */
18
- public function _construct(){
19
- parent::_construct();
20
- $this->_init('{{module}}/{{entity}}');
21
- $this->_map['fields']['store'] = 'store_table.store_id';
22
- }
23
- /**
24
- * get {{entities}} as array
25
- * @access protected
26
- * @param string $valueField
27
- * @param string $labelField
28
- * @param array $additional
29
- * @return array
30
- * {{qwertyuiop}}
31
- */
32
- protected function _toOptionArray($valueField='entity_id', $labelField='{{nameAttribute}}', $additional=array()){
33
- return parent::_toOptionArray($valueField, $labelField, $additional);
34
- }
35
- /**
36
- * get options hash
37
- * @access protected
38
- * @param string $valueField
39
- * @param string $labelField
40
- * @return array
41
- * {{qwertyuiop}}
42
- */
43
- protected function _toOptionHash($valueField='entity_id', $labelField='{{nameAttribute}}'){
44
- return parent::_toOptionHash($valueField, $labelField);
45
- }
46
- /**
47
- * Add filter by store
48
- * @access public
49
- * @param int|Mage_Core_Model_Store $store
50
- * @param bool $withAdmin
51
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
52
- * {{qwertyuiop}}
53
- */
54
- public function addStoreFilter($store, $withAdmin = true){
55
- if (!isset($this->_joinedFields['store'])){
56
- if ($store instanceof Mage_Core_Model_Store) {
57
- $store = array($store->getId());
58
- }
59
- if (!is_array($store)) {
60
- $store = array($store);
61
- }
62
- if ($withAdmin) {
63
- $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
64
- }
65
- $this->addFilter('store', array('in' => $store), 'public');
66
- $this->_joinedFields['store'] = true;
67
- }
68
- return $this;
69
- }
70
- /**
71
- * Join store relation table if there is store filter
72
- * @access protected
73
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
74
- * {{qwertyuiop}}
75
- */
76
- protected function _renderFiltersBefore(){
77
- if ($this->getFilter('store')) {
78
- $this->getSelect()->join(
79
- array('store_table' => $this->getTable('{{module}}/{{entity}}_store')),
80
- 'main_table.entity_id = store_table.{{entity}}_id',
81
- array()
82
- )->group('main_table.entity_id');
83
- /*
84
- * Allow analytic functions usage because of one field grouping
85
- */
86
- $this->_useAnalyticFunction = true;
87
- }
88
- return parent::_renderFiltersBefore();
89
- }
90
- /**
91
- * Get SQL for get record count.
92
- * Extra GROUP BY strip added.
93
- * @access public
94
- * @return Varien_Db_Select
95
- * {{qwertyuiop}}
96
- */
97
- public function getSelectCountSql(){
98
- $countSelect = parent::getSelectCountSql();
99
- $countSelect->reset(Zend_Db_Select::GROUP);
100
- return $countSelect;
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/02_tree.php DELETED
@@ -1,95 +0,0 @@
1
- /**
2
- * Add Id filter
3
- * @access public
4
- * @param array ${{entity}}Ids
5
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
6
- * {{qwertyuiop}}
7
- */
8
- public function addIdFilter(${{entity}}Ids){
9
- if (is_array(${{entity}}Ids)) {
10
- if (empty(${{entity}}Ids)) {
11
- $condition = '';
12
- }
13
- else {
14
- $condition = array('in' => ${{entity}}Ids);
15
- }
16
- }
17
- elseif (is_numeric(${{entity}}Ids)) {
18
- $condition = ${{entity}}Ids;
19
- }
20
- elseif (is_string(${{entity}}Ids)) {
21
- $ids = explode(',', ${{entity}}Ids);
22
- if (empty($ids)) {
23
- $condition = ${{entity}}Ids;
24
- }
25
- else {
26
- $condition = array('in' => $ids);
27
- }
28
- }
29
- $this->addFieldToFilter('entity_id', $condition);
30
- return $this;
31
- }
32
- /**
33
- * Add {{entityLabel}} path filter
34
- * @access public
35
- * @param string $regexp
36
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
37
- * {{qwertyuiop}}
38
- */
39
- public function addPathFilter($regexp){
40
- $this->addFieldToFilter('path', array('regexp' => $regexp));
41
- return $this;
42
- }
43
-
44
- /**
45
- * Add {{entityLabel}} path filter
46
- * @access public
47
- * @param array|string $paths
48
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
49
- * {{qwertyuiop}}
50
- */
51
- public function addPathsFilter($paths){
52
- if (!is_array($paths)) {
53
- $paths = array($paths);
54
- }
55
- $write = $this->getResource()->getWriteConnection();
56
- $cond = array();
57
- foreach ($paths as $path) {
58
- $cond[] = $write->quoteInto('e.path LIKE ?', "$path%");
59
- }
60
- if ($cond) {
61
- $this->getSelect()->where(join(' OR ', $cond));
62
- }
63
- return $this;
64
- }
65
- /**
66
- * Add {{entityLabel}} level filter
67
- * @access public
68
- * @param int|string $level
69
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
70
- * {{qwertyuiop}}
71
- */
72
- public function addLevelFilter($level){
73
- $this->addFieldToFilter('level', array('lteq' => $level));
74
- return $this;
75
- }
76
- /**
77
- * Add root {{entityLabel}} filter
78
- * @access public
79
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
80
- */
81
- public function addRootLevelFilter(){
82
- $this->addFieldToFilter('path', array('neq' => '1'));
83
- $this->addLevelFilter(1);
84
- return $this;
85
- }
86
- /**
87
- * Add order field
88
- * @access public
89
- * @param string $field
90
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
91
- */
92
- public function addOrderField($field){
93
- $this->setOrder($field, self::SORT_ORDER_ASC);
94
- return $this;
95
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/03_tree_status.php DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * Add active {{entityLabel}} filter
3
- * @access public
4
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
5
- */
6
- public function addStatusFilter(){
7
- $this->addFieldToFilter('status', 1);
8
- return $this;
9
- }
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/04_product_relation.php DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * add the product filter to collection
3
- * @access public
4
- * @param mixed (Mage_Catalog_Model_Product|int) $product
5
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
6
- * {{qwertyuiop}}
7
- */
8
- public function addProductFilter($product){
9
- if ($product instanceof Mage_Catalog_Model_Product){
10
- $product = $product->getId();
11
- }
12
- if (!isset($this->_joinedFields['product'])){
13
- $this->getSelect()->join(
14
- array('related_product' => $this->getTable('{{module}}/{{entity}}_product')),
15
- 'related_product.{{entity}}_id = main_table.entity_id',
16
- array('position')
17
- );
18
- $this->getSelect()->where('related_product.product_id = ?', $product);
19
- $this->_joinedFields['product'] = true;
20
- }
21
- return $this;
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/05_sibling_relation.php DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * add the {{sibling}} filter to collection
3
- * @access public
4
- * @param mixed ({{Namespace}}_{{Module}}_Model_{{Sibling}}|int) ${{sibling}}
5
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
6
- * {{qwertyuiop}}
7
- */
8
- public function add{{Sibling}}Filter(${{sibling}}){
9
- if (${{sibling}} instanceof {{Namespace}}_{{Module}}_Model_{{Sibling}}){
10
- ${{sibling}} = ${{sibling}}->getId();
11
- }
12
- if (!isset($this->_joinedFields['{{sibling}}'])){
13
- $this->getSelect()->join(
14
- array('related_{{sibling}}' => $this->getTable('{{module}}/{{entity}}_{{sibling}}')),
15
- 'related_{{sibling}}.{{entity}}_id = main_table.entity_id',
16
- array('position')
17
- );
18
- $this->getSelect()->where('related_{{sibling}}.{{sibling}}_id = ?', ${{sibling}});
19
- $this->_joinedFields['{{sibling}}'] = true;
20
- }
21
- return $this;
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Collection/06_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Product/01_content.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} - product relation model
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product extends Mage_Core_Model_Resource_Db_Abstract{
11
- /**
12
- * initialize resource model
13
- * @access protected
14
- * @return void
15
- * @see Mage_Core_Model_Resource_Abstract::_construct()
16
- * {{qwertyuiop}}
17
- */
18
- protected function _construct(){
19
- $this->_init('{{module}}/{{entity}}_product', 'rel_id');
20
- }
21
- /**
22
- * Save {{entity}} - product relations
23
- * @access public
24
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
25
- * @param array $data
26
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product
27
- * {{qwertyuiop}}
28
- */
29
- public function save{{Entity}}Relation(${{entity}}, $data){
30
- if (!is_array($data)) {
31
- $data = array();
32
- }
33
- $deleteCondition = $this->_getWriteAdapter()->quoteInto('{{entity}}_id=?', ${{entity}}->getId());
34
- $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
35
-
36
- foreach ($data as $productId => $info) {
37
- $this->_getWriteAdapter()->insert($this->getMainTable(), array(
38
- '{{entity}}_id' => ${{entity}}->getId(),
39
- 'product_id' => $productId,
40
- 'position' => @$info['position']
41
- ));
42
- }
43
- return $this;
44
- }
45
- /**
46
- * Save product - {{entity}} relations
47
- * @access public
48
- * @param Mage_Catalog_Model_Product $prooduct
49
- * @param array $data
50
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product
51
- * @{{qwertyuiop}}
52
- */
53
- public function saveProductRelation($product, $data){
54
- if (!is_array($data)) {
55
- $data = array();
56
- }
57
- $deleteCondition = $this->_getWriteAdapter()->quoteInto('product_id=?', $product->getId());
58
- $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
59
-
60
- foreach ($data as ${{entity}}Id => $info) {
61
- $this->_getWriteAdapter()->insert($this->getMainTable(), array(
62
- '{{entity}}_id' => ${{entity}}Id,
63
- 'product_id' => $product->getId(),
64
- 'position' => @$info['position']
65
- ));
66
- }
67
- return $this;
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Product/Collection/01_content.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} - product relation resource model collection
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection{
11
- /**
12
- * remember if fields have been joined
13
- * @var bool
14
- */
15
- protected $_joinedFields = false;
16
- /**
17
- * join the link table
18
- * @access public
19
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product_Collection
20
- * {{qwertyuiop}}
21
- */
22
- public function joinFields(){
23
- if (!$this->_joinedFields){
24
- $this->getSelect()->join(
25
- array('related' => $this->getTable('{{module}}/{{entity}}_product')),
26
- 'related.product_id = e.entity_id',
27
- array('position')
28
- );
29
- $this->_joinedFields = true;
30
- }
31
- return $this;
32
- }
33
- /**
34
- * add {{entity}} filter
35
- * @access public
36
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} | int ${{entity}}
37
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product_Collection
38
- * {{qwertyuiop}}
39
- */
40
- public function add{{Entity}}Filter(${{entity}}){
41
- if (${{entity}} instanceof {{Namespace}}_{{Module}}_Model_{{Entity}}){
42
- ${{entity}} = ${{entity}}->getId();
43
- }
44
- if (!$this->_joinedFields){
45
- $this->joinFields();
46
- }
47
- $this->getSelect()->where('related.{{entity}}_id = ?', ${{entity}});
48
- return $this;
49
- }
50
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Product/IsTree/01_content.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} - product relation model
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product extends Mage_Core_Model_Resource_Db_Abstract{
11
- /**
12
- * initialize resource model
13
- * @access protected
14
- * @return void
15
- * @see Mage_Core_Model_Resource_Abstract::_construct()
16
- * {{qwertyuiop}}
17
- */
18
- protected function _construct(){
19
- $this->_init('{{module}}/{{entity}}_product', 'rel_id');
20
- }
21
- /**
22
- * Save {{entityLabel}} - product relations
23
- * @access public
24
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
25
- * @param array $data
26
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product
27
- * {{qwertyuiop}}
28
- */
29
- public function save{{Entity}}Relation(${{entity}}, $data){
30
- if (!is_array($data)) {
31
- $data = array();
32
- }
33
- $deleteCondition = $this->_getWriteAdapter()->quoteInto('{{entity}}_id=?', ${{entity}}->getId());
34
- $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
35
-
36
- foreach ($data as $productId => $info) {
37
- $this->_getWriteAdapter()->insert($this->getMainTable(), array(
38
- '{{entity}}_id' => ${{entity}}->getId(),
39
- 'product_id' => $productId,
40
- 'position' => @$info['position']
41
- ));
42
- }
43
- return $this;
44
- }
45
- /**
46
- * Save product - {{entityLabel}} relations
47
- * @access public
48
- * @param Mage_Catalog_Model_Product $prooduct
49
- * @param array $data
50
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product
51
- * {{qwertyuiop}}
52
- */
53
- public function saveProductRelation($product, ${{entity}}Ids){
54
-
55
- $old{{Entities}} = Mage::helper('{{module}}/product')->getSelected{{Entities}}($product);
56
- $old{{Entity}}Ids = array();
57
- foreach ($old{{Entities}} as ${{entity}}){
58
- $old{{Entity}}Ids[] = ${{entity}}->getId();
59
- }
60
- $insert = array_diff(${{entity}}Ids, $old{{Entity}}Ids);
61
- $delete = array_diff($old{{Entity}}Ids, ${{entity}}Ids);
62
- $write = $this->_getWriteAdapter();
63
- if (!empty($insert)) {
64
- $data = array();
65
- foreach ($insert as ${{entity}}Id) {
66
- if (empty(${{entity}}Id)) {
67
- continue;
68
- }
69
- $data[] = array(
70
- '{{entity}}_id' => (int)${{entity}}Id,
71
- 'product_id' => (int)$product->getId(),
72
- 'position'=> 1
73
- );
74
- }
75
- if ($data) {
76
- $write->insertMultiple($this->getMainTable(), $data);
77
- }
78
- }
79
- if (!empty($delete)) {
80
- foreach ($delete as ${{entity}}Id) {
81
- $where = array(
82
- 'product_id = ?' => (int)$product->getId(),
83
- '{{entity}}_id = ?' => (int)${{entity}}Id,
84
- );
85
- $write->delete($this->getMainTable(), $where);
86
- }
87
- }
88
- return $this;
89
- }
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/01_top.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} - {{SiblingLabel}} relation model
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}} extends Mage_Core_Model_Resource_Db_Abstract{
11
- /**
12
- * initialize resource model
13
- * @access protected
14
- * @return void
15
- * @see Mage_Core_Model_Resource_Abstract::_construct()
16
- * {{qwertyuiop}}
17
- */
18
- protected function _construct(){
19
- $this->_init('{{module}}/{{entity}}_{{sibling}}', 'rel_id');
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/02_save_relation.php DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * Save {{entity}} - {{sibling}} relations
3
- * @access public
4
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
5
- * @param array $data
6
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}}
7
- * {{qwertyuiop}}
8
- */
9
- public function save{{Entity}}Relation(${{entity}}, $data){
10
- if (!is_array($data)) {
11
- $data = array();
12
- }
13
- $deleteCondition = $this->_getWriteAdapter()->quoteInto('{{entity}}_id=?', ${{entity}}->getId());
14
- $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
15
-
16
- foreach ($data as ${{sibling}}Id => $info) {
17
- $this->_getWriteAdapter()->insert($this->getMainTable(), array(
18
- '{{entity}}_id' => ${{entity}}->getId(),
19
- '{{sibling}}_id' => ${{sibling}}Id,
20
- 'position' => @$info['position']
21
- ));
22
- }
23
- return $this;
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/03_save_relation_tree.php DELETED
@@ -1,47 +0,0 @@
1
- /**
2
- * Save {{entity}} - {{sibling}} relations
3
- * @access public
4
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}
5
- * @param array $data
6
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}}
7
- * {{qwertyuiop}}
8
- */
9
- public function save{{Entity}}Relation(${{entity}}, ${{sibling}}Ids){
10
- if (is_null(${{sibling}}Ids)){
11
- return $this;
12
- }
13
- $old{{Siblings}} = ${{entity}}->getSelected{{Siblings}}();
14
- $old{{Sibling}}Ids = array();
15
- foreach ($old{{Siblings}} as ${{sibling}}){
16
- $old{{Sibling}}Ids[] = ${{sibling}}->getId();
17
- }
18
- $insert = array_diff(${{sibling}}Ids, $old{{Sibling}}Ids);
19
- $delete = array_diff($old{{Sibling}}Ids, ${{sibling}}Ids);
20
- $write = $this->_getWriteAdapter();
21
- if (!empty($insert)) {
22
- $data = array();
23
- foreach ($insert as ${{sibling}}Id) {
24
- if (empty(${{sibling}}Id)) {
25
- continue;
26
- }
27
- $data[] = array(
28
- '{{sibling}}_id' => (int)${{sibling}}Id,
29
- '{{entity}}_id' => (int)${{entity}}->getId(),
30
- 'position'=> 1
31
- );
32
- }
33
- if ($data) {
34
- $write->insertMultiple($this->getMainTable(), $data);
35
- }
36
- }
37
- if (!empty($delete)) {
38
- foreach ($delete as ${{sibling}}Id) {
39
- $where = array(
40
- '{{entity}}_id = ?' => (int)${{entity}}->getId(),
41
- '{{sibling}}_id = ?' => (int)${{sibling}}Id,
42
- );
43
- $write->delete($this->getMainTable(), $where);
44
- }
45
- }
46
- return $this;
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/04_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Sibling/Collection/01_content.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} - {{SiblingLabel}} relation resource model collection
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}}_Collection extends {{Namespace}}_{{Module}}_Model_Resource_{{Sibling}}_Collection{
11
- /**
12
- * remember if fields have been joined
13
- * @var bool
14
- */
15
- protected $_joinedFields = false;
16
- /**
17
- * join the link table
18
- * @access public
19
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}}_Collection
20
- * {{qwertyuiop}}
21
- */
22
- public function joinFields(){
23
- if (!$this->_joinedFields){
24
- $this->getSelect()->join(
25
- array('related' => $this->getTable('{{module}}/{{entity}}_{{sibling}}')),
26
- 'related.{{sibling}}_id = main_table.entity_id',
27
- array('position')
28
- );
29
- $this->_joinedFields = true;
30
- }
31
- return $this;
32
- }
33
- /**
34
- * add {{entity}} filter
35
- * @access public
36
- * @param {{Namespace}}_{{Module}}_Model_{{Entity}} | int ${{entity}}
37
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}}_Collection
38
- * {{qwertyuiop}}
39
- */
40
- public function add{{Entity}}Filter(${{entity}}){
41
- if (${{entity}} instanceof {{Namespace}}_{{Module}}_Model_{{Entity}}){
42
- ${{entity}} = ${{entity}}->getId();
43
- }
44
- if (!$this->_joinedFields){
45
- $this->joinFields();
46
- }
47
- $this->getSelect()->where('related.{{entity}}_id = ?', ${{entity}});
48
- return $this;
49
- }
50
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/01_top.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} tree resource model
5
- * @category {{Namespace}}
6
- * @package {{Namespace}}_{{Module}}
7
- * {{qwertyuiop}}
8
- */
9
- class {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree extends Varien_Data_Tree_Dbp{
10
- const ID_FIELD = 'entity_id';
11
- const PATH_FIELD = 'path';
12
- const ORDER_FIELD = 'order';
13
- const LEVEL_FIELD = 'level';
14
- /**
15
- * {{EntitiesLabel}} resource collection
16
- * @var {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
17
- */
18
- protected $_collection;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/02_status_top.php DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Inactive {{entitiesLabel}} ids
3
- * @var array
4
- */
5
- protected $_inactive{{Entity}}Ids = null;
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/03_content.php DELETED
@@ -1,226 +0,0 @@
1
- /**
2
- * Initialize tree
3
- * @access public
4
- * @return void
5
- * {{qwertyuiop}}
6
- */
7
- public function __construct(){
8
- $resource = Mage::getSingleton('core/resource');
9
- parent::__construct(
10
- $resource->getConnection('{{module}}_write'),
11
- $resource->getTableName('{{module}}/{{entity}}'),
12
- array(
13
- Varien_Data_Tree_Dbp::ID_FIELD => 'entity_id',
14
- Varien_Data_Tree_Dbp::PATH_FIELD => 'path',
15
- Varien_Data_Tree_Dbp::ORDER_FIELD=> 'position',
16
- Varien_Data_Tree_Dbp::LEVEL_FIELD=> 'level',
17
- )
18
- );
19
- }
20
-
21
- /**
22
- * Get {{entitiesLabel}} collection
23
- * @access public
24
- * @param boolean $sorted
25
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
26
- * {{qwertyuiop}}
27
- */
28
- public function getCollection($sorted = false){
29
- if (is_null($this->_collection)) {
30
- $this->_collection = $this->_getDefaultCollection($sorted);
31
- }
32
- return $this->_collection;
33
- }
34
- /**
35
- * set the collection
36
- * @access public
37
- * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection
38
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree
39
- */
40
- public function setCollection($collection){
41
- if (!is_null($this->_collection)) {
42
- destruct($this->_collection);
43
- }
44
- $this->_collection = $collection;
45
- return $this;
46
- }
47
- /**
48
- * get the default collection
49
- * @access protected
50
- * @param boolean $sorted
51
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection
52
- */
53
- protected function _getDefaultCollection($sorted = false){
54
- $collection = Mage::getModel('{{module}}/{{entity}}')->getCollection();
55
- if ($sorted) {
56
- if (is_string($sorted)) {
57
- $collection->setOrder($sorted);
58
- }
59
- else {
60
- $collection->setOrder('name');
61
- }
62
- }
63
- return $collection;
64
- }
65
- /**
66
- * Executing parents move method and cleaning cache after it
67
- * @access public
68
- * @param unknown_type ${{entity}}
69
- * @param unknown_type $newParent
70
- * @param unknown_type $prevNode
71
- * {{qwertyuiop}}
72
- */
73
- public function move(${{entity}}, $newParent, $prevNode = null){
74
- Mage::getResourceSingleton('{{module}}/{{entity}}')->move(${{entity}}->getId(), $newParent->getId());
75
- parent::move(${{entity}}, $newParent, $prevNode);
76
- $this->_afterMove(${{entity}}, $newParent, $prevNode);
77
- }
78
-
79
- /**
80
- * Move tree after
81
- * @access protected
82
- * @param unknown_type ${{entity}}
83
- * @param Varien_Data_Tree_Node $newParent
84
- * @param Varien_Data_Tree_Node $prevNode
85
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree
86
- */
87
- protected function _afterMove(${{entity}}, $newParent, $prevNode){
88
- Mage::app()->cleanCache(array({{Namespace}}_{{Module}}_Model_{{Entity}}::CACHE_TAG));
89
- return $this;
90
- }
91
- /**
92
- * Load whole {{entityLabel}} tree, that will include specified {{entitiesLabel}} ids.
93
- * @access public
94
- * @param array $ids
95
- * @param bool $addCollectionData
96
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree
97
- * {{qwertyuiop}}
98
- */
99
- public function loadByIds($ids, $addCollectionData = true){
100
- $levelField = $this->_conn->quoteIdentifier('level');
101
- $pathField = $this->_conn->quoteIdentifier('path');
102
- // load first two levels, if no ids specified
103
- if (empty($ids)) {
104
- $select = $this->_conn->select()
105
- ->from($this->_table, 'entity_id')
106
- ->where($levelField . ' <= 2');
107
- $ids = $this->_conn->fetchCol($select);
108
- }
109
- if (!is_array($ids)) {
110
- $ids = array($ids);
111
- }
112
- foreach ($ids as $key => $id) {
113
- $ids[$key] = (int)$id;
114
- }
115
- // collect paths of specified IDs and prepare to collect all their parents and neighbours
116
- $select = $this->_conn->select()
117
- ->from($this->_table, array('path', 'level'))
118
- ->where('entity_id IN (?)', $ids);
119
- $where = array($levelField . '=0' => true);
120
-
121
- foreach ($this->_conn->fetchAll($select) as $item) {
122
- $pathIds = explode('/', $item['path']);
123
- $level = (int)$item['level'];
124
- while ($level > 0) {
125
- $pathIds[count($pathIds) - 1] = '%';
126
- $path = implode('/', $pathIds);
127
- $where["$levelField=$level AND $pathField LIKE '$path'"] = true;
128
- array_pop($pathIds);
129
- $level--;
130
- }
131
- }
132
- $where = array_keys($where);
133
-
134
- // get all required records
135
- if ($addCollectionData) {
136
- $select = $this->_createCollectionDataSelect();
137
- }
138
- else {
139
- $select = clone $this->_select;
140
- $select->order($this->_orderField . ' ' . Varien_Db_Select::SQL_ASC);
141
- }
142
- $select->where(implode(' OR ', $where));
143
-
144
- // get array of records and add them as nodes to the tree
145
- $arrNodes = $this->_conn->fetchAll($select);
146
- if (!$arrNodes) {
147
- return false;
148
- }
149
- $childrenItems = array();
150
- foreach ($arrNodes as $key => $nodeInfo) {
151
- $pathToParent = explode('/', $nodeInfo[$this->_pathField]);
152
- array_pop($pathToParent);
153
- $pathToParent = implode('/', $pathToParent);
154
- $childrenItems[$pathToParent][] = $nodeInfo;
155
- }
156
- $this->addChildNodes($childrenItems, '', null);
157
- return $this;
158
- }
159
- /**
160
- * Load array of {{entityLabel}} parents
161
- * @access public
162
- * @param string $path
163
- * @param bool $addCollectionData
164
- * @param bool $withRootNode
165
- * @return array
166
- * {{qwertyuiop}}
167
- */
168
- public function loadBreadcrumbsArray($path, $addCollectionData = true, $withRootNode = false){
169
- $pathIds = explode('/', $path);
170
- if (!$withRootNode) {
171
- array_shift($pathIds);
172
- }
173
- $result = array();
174
- if (!empty($pathIds)) {
175
- if ($addCollectionData) {
176
- $select = $this->_createCollectionDataSelect(false);
177
- }
178
- else {
179
- $select = clone $this->_select;
180
- }
181
- $select
182
- ->where('main_table.entity_id IN(?)', $pathIds)
183
- ->order($this->_conn->getLengthSql('main_table.path') . ' ' . Varien_Db_Select::SQL_ASC);
184
- $result = $this->_conn->fetchAll($select);
185
- }
186
- return $result;
187
- }
188
- /**
189
- * Obtain select for {{entitiesLabel}}
190
- * By default everything from entity table is selected
191
- * + name
192
- * @access public
193
- * @param bool $sorted
194
- * @param array $optionalAttributes
195
- * @return Zend_Db_Select
196
- * {{qwertyuiop}}
197
- */
198
- protected function _createCollectionDataSelect($sorted = true){
199
- $select = $this->_getDefaultCollection($sorted ? $this->_orderField : false)->getSelect();
200
- ${{entities}}Table = Mage::getSingleton('core/resource')->getTableName('{{module}}/{{entity}}');
201
- $subConcat = $this->_conn->getConcatSql(array('main_table.path', $this->_conn->quote('/%')));
202
- $subSelect = $this->_conn->select()
203
- ->from(array('see' => ${{entities}}Table), null)
204
- ->where('see.entity_id = main_table.entity_id')
205
- ->orWhere('see.path LIKE ?', $subConcat);
206
- return $select;
207
- }
208
- /**
209
- * Get real existing {{entityLabel}} ids by specified ids
210
- * @access public
211
- * @param array $ids
212
- * @return array
213
- * {{qwertyuiop}}
214
- */
215
- public function getExisting{{Entity}}IdsBySpecifiedIds($ids){
216
- if (empty($ids)) {
217
- return array();
218
- }
219
- if (!is_array($ids)) {
220
- $ids = array($ids);
221
- }
222
- $select = $this->_conn->select()
223
- ->from($this->_table, array('entity_id'))
224
- ->where('entity_id IN (?)', $ids);
225
- return $this->_conn->fetchCol($select);
226
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/04_not_status.php DELETED
@@ -1,41 +0,0 @@
1
- /**
2
- * add collection data
3
- * @access public
4
- * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection
5
- * @param boolean $sorted
6
- * @param array $exclude
7
- * @param boolean $toLoad
8
- * @return {{Namespace}}_{{Module}}_Model_Resource_Category_Tree
9
- * {{qwertyuiop}}
10
- */
11
- public function addCollectionData($collection = null, $sorted = false, $exclude = array(), $toLoad = true){
12
- if (is_null($collection)) {
13
- $collection = $this->getCollection($sorted);
14
- } else {
15
- $this->setCollection($collection);
16
- }
17
- if (!is_array($exclude)) {
18
- $exclude = array($exclude);
19
- }
20
- $nodeIds = array();
21
- foreach ($this->getNodes() as $node) {
22
- if (!in_array($node->getId(), $exclude)) {
23
- $nodeIds[] = $node->getId();
24
- }
25
- }
26
- $collection->addIdFilter($nodeIds);
27
- if ($toLoad) {
28
- $collection->load();
29
- foreach ($collection as ${{entity}}) {
30
- if ($this->getNodeById(${{entity}}->getId())) {
31
- $this->getNodeById(${{entity}}->getId())->addData(${{entity}}->getData());
32
- }
33
- }
34
- foreach ($this->getNodes() as $node) {
35
- if (!$collection->getItemById($node->getId()) && $node->getParent()) {
36
- $this->removeNode($node);
37
- }
38
- }
39
- }
40
- return $this;
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/05_status.php DELETED
@@ -1,144 +0,0 @@
1
- /**
2
- * add collection data
3
- * @access public
4
- * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection
5
- * @param boolean $sorted
6
- * @param array $exclude
7
- * @param boolean $toLoad
8
- * @param boolean $onlyActive
9
- * @return {{Namespace}}_{{Module}}_Model_Resource_Category_Tree
10
- * {{qwertyuiop}}
11
- */
12
- public function addCollectionData($collection = null, $sorted = false, $exclude = array(), $toLoad = true, $onlyActive = false){
13
- if (is_null($collection)) {
14
- $collection = $this->getCollection($sorted);
15
- } else {
16
- $this->setCollection($collection);
17
- }
18
- if (!is_array($exclude)) {
19
- $exclude = array($exclude);
20
- }
21
- $nodeIds = array();
22
- foreach ($this->getNodes() as $node) {
23
- if (!in_array($node->getId(), $exclude)) {
24
- $nodeIds[] = $node->getId();
25
- }
26
- }
27
- $collection->addIdFilter($nodeIds);
28
- if ($onlyActive) {
29
- $disabledIds = $this->_getDisabledIds($collection);
30
- if ($disabledIds) {
31
- $collection->addFieldToFilter('entity_id', array('nin' => $disabledIds));
32
- }
33
- $collection->addFieldToFilter('status', 1);
34
- }
35
- if ($toLoad) {
36
- $collection->load();
37
- foreach ($collection as ${{entity}}) {
38
- if ($this->getNodeById(${{entity}}->getId())) {
39
- $this->getNodeById(${{entity}}->getId())->addData(${{entity}}->getData());
40
- }
41
- }
42
- foreach ($this->getNodes() as $node) {
43
- if (!$collection->getItemById($node->getId()) && $node->getParent()) {
44
- $this->removeNode($node);
45
- }
46
- }
47
- }
48
- return $this;
49
- }
50
- /**
51
- * Add inactive {{entitiesLabel}} ids
52
- * @access public
53
- * @param unknown_type $ids
54
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree
55
- * {{qwertyuiop}}
56
- */
57
- public function addInactive{{Entity}}Ids($ids){
58
- if (!is_array($this->_inactive{{Entity}}Ids)) {
59
- $this->_initInactive{{Entity}}Ids();
60
- }
61
- $this->_inactive{{Entity}}Ids = array_merge($ids, $this->_inactive{{Entity}}Ids);
62
- return $this;
63
- }
64
- /**
65
- * Retrieve inactive {{entitiesLabel}} ids
66
- * @access protected
67
- * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree
68
- * {{qwertyuiop}}
69
- */
70
- protected function _initInactive{{Entity}}Ids(){
71
- $this->_inactive{{Entity}}Ids = array();
72
- return $this;
73
- }
74
- /**
75
- * Retrieve inactive {{entitiesLabel}} ids
76
- * @access public
77
- * @return array
78
- * {{qwertyuiop}}
79
- */
80
- public function getInactive{{Entity}}Ids(){
81
- if (!is_array($this->_inactive{{Entity}}Ids)) {
82
- $this->_initInactive{{Entity}}Ids();
83
- }
84
- return $this->_inactive{{Entity}}Ids;
85
- }
86
- /**
87
- * Return disable {{entityLabel}} ids
88
- * @access protected
89
- * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection
90
- * @return array
91
- * {{qwertyuiop}}
92
- */
93
- protected function _getDisabledIds($collection){
94
- $this->_inactiveItems = $this->getInactive{{Entity}}Ids();
95
- $this->_inactiveItems = array_merge(
96
- $this->_getInactiveItemIds($collection),
97
- $this->_inactiveItems
98
- );
99
- $allIds = $collection->getAllIds();
100
- $disabledIds = array();
101
-
102
- foreach ($allIds as $id) {
103
- $parents = $this->getNodeById($id)->getPath();
104
- foreach ($parents as $parent) {
105
- if (!$this->_getItemIsActive($parent->getId())){
106
- $disabledIds[] = $id;
107
- continue;
108
- }
109
- }
110
- }
111
- return $disabledIds;
112
- }
113
- /**
114
- * Retrieve inactive {{entityLabel}} item ids
115
- * @access protecte
116
- * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection
117
- * @return array
118
- * {{qwertyuiop}}
119
- */
120
- protected function _getInactiveItemIds($collection){
121
- $filter = $collection->getAllIdsSql();
122
- $table = Mage::getSingleton('core/resource')->getTable('{{module}}/{{entity}}');
123
- $bind = array(
124
- 'cond' => 0,
125
- );
126
- $select = $this->_conn->select()
127
- ->from(array('d'=>$table), array('d.entity_id'))
128
- ->where('d.entity_id IN (?)', new Zend_Db_Expr($filter))
129
- ->where('status = :cond');
130
- return $this->_conn->fetchCol($select, $bind);
131
- }
132
- /**
133
- * Check is {{entityLabel}} items active
134
- * @access protecte
135
- * @param int $id
136
- * @return boolean
137
- * {{qwertyuiop}}
138
- */
139
- protected function _getItemIsActive($id){
140
- if (!in_array($id, $this->_inactiveItems)) {
141
- return true;
142
- }
143
- return false;
144
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Entity/Tree/06_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/Model/Resource/Setup/01_content.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{Module}} setup
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup{
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/Catalog/ProductController/01_content.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{Entity}} product admin controller
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- require_once ("Mage/Adminhtml/controllers/Catalog/ProductController.php");
11
- class {{Namespace}}_{{Module}}_Adminhtml_{{Module}}_{{Entity}}_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController{
12
- /**
13
- * construct
14
- * @access protected
15
- * @return void
16
- * {{qwertyuiop}}
17
- */
18
- protected function _construct(){
19
- // Define module dependent translate
20
- $this->setUsedModuleName('{{Namespace}}_{{Module}}');
21
- }
22
- /**
23
- * {{entities}} in the catalog page
24
- * @access public
25
- * @return void
26
- * {{qwertyuiop}}
27
- */
28
- public function {{entities}}Action(){
29
- $this->_initProduct();
30
- $this->loadLayout();
31
- $this->getLayout()->getBlock('product.edit.tab.{{entity}}')
32
- ->setProduct{{Entities}}($this->getRequest()->getPost('product_{{entities}}', null));
33
- $this->renderLayout();
34
- }
35
- /**
36
- * {{entities}} grid in the catalog page
37
- * @access public
38
- * @return void
39
- * {{qwertyuiop}}
40
- */
41
- public function {{entities}}GridAction(){
42
- $this->_initProduct();
43
- $this->loadLayout();
44
- $this->getLayout()->getBlock('product.edit.tab.{{entity}}')
45
- ->setProduct{{Entities}}($this->getRequest()->getPost('product_{{entities}}', null));
46
- $this->renderLayout();
47
- }
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/Catalog/ProductController/IsTree/01_content.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} - product controller
5
- * @category {{Namespace}}
6
- * @package {{Namespace}}_{{Module}}
7
- * {{qwertyuiop}}
8
- */
9
- require_once ("Mage/Adminhtml/controllers/Catalog/ProductController.php");
10
- class {{Namespace}}_{{Module}}_Adminhtml_{{Module}}_{{Entity}}_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController{
11
- /**
12
- * {{entitiesLabel}} action
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function {{entities}}Action(){
18
- $this->_initProduct();
19
- $this->loadLayout();
20
- $this->renderLayout();
21
- }
22
- /**
23
- * {{entitiesLabel}} json action
24
- * @access public
25
- * @return void
26
- * {{qwertyuiop}}
27
- */
28
- public function {{entities}}JsonAction(){
29
- $product = $this->_initProduct();
30
- $this->getResponse()->setBody(
31
- $this->getLayout()->createBlock('{{module}}/adminhtml_catalog_product_edit_tab_{{entity}}')
32
- ->get{{Entity}}ChildrenJson($this->getRequest()->getParam('{{entity}}'))
33
- );
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/WidgetController/01_content.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin widget controller
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Adminhtml_{{Module}}_{{Entity}}_WidgetController extends Mage_Adminhtml_Controller_Action{
11
- /**
12
- * Chooser Source action
13
- * @access public
14
- * @return void
15
- * {{qwertyuiop}}
16
- */
17
- public function chooserAction(){
18
- $uniqId = $this->getRequest()->getParam('uniq_id');
19
- $grid = $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_widget_chooser', '', array(
20
- 'id' => $uniqId,
21
- ));
22
- $this->getResponse()->setBody($grid->toHtml());
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/WidgetController/02_tree.php DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * {{entitiesLabel}} json action
3
- * @access public
4
- * @return void
5
- * {{qwertyuiop}}
6
- */
7
- public function {{entities}}JsonAction(){
8
- if (${{entity}}Id = (int) $this->getRequest()->getPost('id')) {
9
- ${{entity}} = Mage::getModel('{{module}}/{{entity}}')->load(${{entity}}Id);
10
- if (${{entity}}->getId()) {
11
- Mage::register('{{entity}}', ${{entity}});
12
- Mage::register('current_{{entity}}', ${{entity}});
13
- }
14
- $this->getResponse()->setBody(
15
- $this->_get{{Entity}}TreeBlock()->getTreeJson(${{entity}})
16
- );
17
- }
18
- }
19
- /**
20
- * get {{entity}} tree block
21
- * @access protected
22
- * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser
23
- * {{qwertyuiop}}
24
- */
25
- protected function _get{{Entity}}TreeBlock(){
26
- return $this->getLayout()->createBlock('{{module}}/adminhtml_{{entity}}_widget_chooser', '', array(
27
- 'id' => $this->getRequest()->getParam('uniq_id'),
28
- 'use_massaction' => $this->getRequest()->getParam('use_massaction', false)
29
- ));
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/Entity/WidgetController/03_footer.php DELETED
@@ -1 +0,0 @@
1
- }
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/01_top.php DELETED
@@ -1,98 +0,0 @@
1
- <?php
2
- {{License}}
3
- /**
4
- * {{EntityLabel}} admin controller
5
- *
6
- * @category {{Namespace}}
7
- * @package {{Namespace}}_{{Module}}
8
- * {{qwertyuiop}}
9
- */
10
- class {{Namespace}}_{{Module}}_Adminhtml_{{Module}}_{{Entity}}Controller extends {{Namespace}}_{{Module}}_Controller_Adminhtml_{{Module}}{
11
- /**
12
- * init the {{entity}}
13
- * @access protected
14
- * @return {{Namespace}}_{{Module}}_Model_{{Entity}}
15
- */
16
- protected function _init{{Entity}}(){
17
- ${{entity}}Id = (int) $this->getRequest()->getParam('id');
18
- ${{entity}} = Mage::getModel('{{module}}/{{entity}}');
19
- if (${{entity}}Id) {
20
- ${{entity}}->load(${{entity}}Id);
21
- }
22
- Mage::register('current_{{entity}}', ${{entity}});
23
- return ${{entity}};
24
- }
25
- /**
26
- * default action
27
- * @access public
28
- * @return void
29
- * {{qwertyuiop}}
30
- */
31
- public function indexAction() {
32
- $this->loadLayout();
33
- $this->_title(Mage::helper('{{module}}')->__('{{Module}}'))
34
- ->_title(Mage::helper('{{module}}')->__('{{EntitiesLabel}}'));
35
- $this->renderLayout();
36
- }
37
- /**
38
- * grid action
39
- * @access public
40
- * @return void
41
- * {{qwertyuiop}}
42
- */
43
- public function gridAction() {
44
- $this->loadLayout()->renderLayout();
45
- }
46
- /**
47
- * edit {{entityLabel}} - action
48
- * @access public
49
- * @return void
50
- * {{qwertyuiop}}
51
- */
52
- public function editAction() {
53
- ${{entity}}Id = $this->getRequest()->getParam('id');
54
- ${{entity}} = $this->_init{{Entity}}();
55
- if (${{entity}}Id && !${{entity}}->getId()) {
56
- $this->_getSession()->addError(Mage::helper('{{module}}')->__('This {{entityLabel}} no longer exists.'));
57
- $this->_redirect('*/*/');
58
- return;
59
- }
60
- $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
61
- if (!empty($data)) {
62
- ${{entity}}->setData($data);
63
- }
64
- Mage::register('{{entity}}_data', ${{entity}});
65
- $this->loadLayout();
66
- $this->_title(Mage::helper('{{module}}')->__('{{Module}}'))
67
- ->_title(Mage::helper('{{module}}')->__('{{EntitiesLabel}}'));
68
- if (${{entity}}->getId()){
69
- $this->_title(${{entity}}->get{{EntityNameMagicCode}}());
70
- }
71
- else{
72
- $this->_title(Mage::helper('{{module}}')->__('Add {{entityLabel}}'));
73
- }
74
- if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
75
- $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
76
- }
77
- $this->renderLayout();
78
- }
79
- /**
80
- * new {{entityLabel}} action
81
- * @access public
82
- * @return void
83
- * {{qwertyuiop}}
84
- */
85
- public function newAction() {
86
- $this->_forward('edit');
87
- }
88
- /**
89
- * save {{entityLabel}} - action
90
- * @access public
91
- * @return void
92
- * {{qwertyuiop}}
93
- */
94
- public function saveAction() {
95
- if ($data = $this->getRequest()->getPost('{{entity}}')) {
96
- try {
97
- ${{entity}} = $this->_init{{Entity}}();
98
- ${{entity}}->addData($data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/02_upload_image.php DELETED
@@ -1,2 +0,0 @@
1
- ${{attributeCode}}Name = $this->_uploadAndGetName('{{attributeCode}}', Mage::helper('{{module}}/{{entity}}_image')->getImageBaseDir(), $data);
2
- ${{entity}}->setData('{{attributeCode}}', ${{attributeCode}}Name);
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/03_upload_files.php DELETED
@@ -1,2 +0,0 @@
1
- ${{attributeCode}}Name = $this->_uploadAndGetName('{{attributeCode}}', Mage::helper('{{module}}/{{entity}}')->getFileBaseDir(), $data);
2
- ${{entity}}->setData('{{attributeCode}}', ${{attributeCode}}Name);
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/04_save_product_relation.php DELETED
@@ -1,4 +0,0 @@
1
- $products = $this->getRequest()->getPost('products', -1);
2
- if ($products != -1) {
3
- ${{entity}}->setProductsData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($products));
4
- }
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/05_save_sibling_relation.php DELETED
@@ -1,4 +0,0 @@
1
- ${{siblings}} = $this->getRequest()->getPost('{{siblings}}', -1);
2
- if (${{siblings}} != -1) {
3
- ${{entity}}->set{{Siblings}}Data(Mage::helper('adminhtml/js')->decodeGridSerializedInput(${{siblings}}));
4
- }
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/06_save_sibling_relation_tree.php DELETED
@@ -1,6 +0,0 @@
1
- ${{siblings}} = $this->getRequest()->getPost('{{sibling}}_ids', -1);
2
- if (${{siblings}} != -1) {
3
- ${{siblings}} = explode(',', ${{siblings}});
4
- ${{siblings}} = array_unique(${{siblings}});
5
- ${{entity}}->set{{Siblings}}Data(${{siblings}});
6
- }
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/07_save.php DELETED
@@ -1,11 +0,0 @@
1
- ${{entity}}->save();
2
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('{{module}}')->__('{{EntityLabel}} was successfully saved'));
3
- Mage::getSingleton('adminhtml/session')->setFormData(false);
4
- if ($this->getRequest()->getParam('back')) {
5
- $this->_redirect('*/*/edit', array('id' => ${{entity}}->getId()));
6
- return;
7
- }
8
- $this->_redirect('*/*/');
9
- return;
10
- }
11
- catch (Mage_Core_Exception $e){
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/08_exception_upload.php DELETED
@@ -1,3 +0,0 @@
1
- if (isset($data['{{attributeCode}}']['value'])){
2
- $data['{{attributeCode}}'] = $data['{{attributeCode}}']['value'];
3
- }
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/09_exception.php DELETED
@@ -1,7 +0,0 @@
1
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
2
- Mage::getSingleton('adminhtml/session')->setFormData($data);
3
- $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
4
- return;
5
- }
6
- catch (Exception $e) {
7
- Mage::logException($e);
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/10_center.php DELETED
@@ -1,67 +0,0 @@
1
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('There was a problem saving the {{entityLabel}}.'));
2
- Mage::getSingleton('adminhtml/session')->setFormData($data);
3
- $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
4
- return;
5
- }
6
- }
7
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('Unable to find {{entityLabel}} to save.'));
8
- $this->_redirect('*/*/');
9
- }
10
- /**
11
- * delete {{entityLabel}} - action
12
- * @access public
13
- * @return void
14
- * {{qwertyuiop}}
15
- */
16
- public function deleteAction() {
17
- if( $this->getRequest()->getParam('id') > 0) {
18
- try {
19
- ${{entity}} = Mage::getModel('{{module}}/{{entity}}');
20
- ${{entity}}->setId($this->getRequest()->getParam('id'))->delete();
21
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('{{module}}')->__('{{EntityLabel}} was successfully deleted.'));
22
- $this->_redirect('*/*/');
23
- return;
24
- }
25
- catch (Mage_Core_Exception $e){
26
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
27
- $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
28
- }
29
- catch (Exception $e) {
30
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('There was an error deleteing {{entityLabel}}.'));
31
- $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
32
- Mage::logException($e);
33
- return;
34
- }
35
- }
36
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('Could not find {{entityLabel}} to delete.'));
37
- $this->_redirect('*/*/');
38
- }
39
- /**
40
- * mass delete {{entityLabel}} - action
41
- * @access public
42
- * @return void
43
- * {{qwertyuiop}}
44
- */
45
- public function massDeleteAction() {
46
- ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}');
47
- if(!is_array(${{entity}}Ids)) {
48
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('Please select {{entitiesLabel}} to delete.'));
49
- }
50
- else {
51
- try {
52
- foreach (${{entity}}Ids as ${{entity}}Id) {
53
- ${{entity}} = Mage::getModel('{{module}}/{{entity}}');
54
- ${{entity}}->setId(${{entity}}Id)->delete();
55
- }
56
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('{{module}}')->__('Total of %d {{entitiesLabel}} were successfully deleted.', count(${{entity}}Ids)));
57
- }
58
- catch (Mage_Core_Exception $e){
59
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
60
- }
61
- catch (Exception $e) {
62
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('There was an error deleteing {{entitiesLabel}}.'));
63
- Mage::logException($e);
64
- }
65
- }
66
- $this->_redirect('*/*/index');
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/11_mass_status.php DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * mass status change - action
3
- * @access public
4
- * @return void
5
- * {{qwertyuiop}}
6
- */
7
- public function massStatusAction(){
8
- ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}');
9
- if(!is_array(${{entity}}Ids)) {
10
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('Please select {{entitiesLabel}}.'));
11
- }
12
- else {
13
- try {
14
- foreach (${{entity}}Ids as ${{entity}}Id) {
15
- ${{entity}} = Mage::getSingleton('{{module}}/{{entity}}')->load(${{entity}}Id)
16
- ->setStatus($this->getRequest()->getParam('status'))
17
- ->setIsMassupdate(true)
18
- ->save();
19
- }
20
- $this->_getSession()->addSuccess($this->__('Total of %d {{entitiesLabel}} were successfully updated.', count(${{entity}}Ids)));
21
- }
22
- catch (Mage_Core_Exception $e){
23
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
24
- }
25
- catch (Exception $e) {
26
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('There was an error updating {{entitiesLabel}}.'));
27
- Mage::logException($e);
28
- }
29
- }
30
- $this->_redirect('*/*/index');
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/12_mass_update.php DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * mass {{attributeLabel}} change - action
3
- * @access public
4
- * @return void
5
- * {{qwertyuiop}}
6
- */
7
- public function mass{{AttributeMagicCode}}Action(){
8
- ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}');
9
- if(!is_array(${{entity}}Ids)) {
10
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('Please select {{entitiesLabel}}.'));
11
- }
12
- else {
13
- try {
14
- foreach (${{entity}}Ids as ${{entity}}Id) {
15
- ${{entity}} = Mage::getSingleton('{{module}}/{{entity}}')->load(${{entity}}Id)
16
- ->set{{AttributeMagicCode}}($this->getRequest()->getParam('flag_{{attributeCode}}'))
17
- ->setIsMassupdate(true)
18
- ->save();
19
- }
20
- $this->_getSession()->addSuccess($this->__('Total of %d {{entitiesLabel}} were successfully updated.', count(${{entity}}Ids)));
21
- }
22
- catch (Mage_Core_Exception $e){
23
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
24
- }
25
- catch (Exception $e) {
26
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('There was an error updating {{entitiesLabel}}.'));
27
- Mage::logException($e);
28
- }
29
- }
30
- $this->_redirect('*/*/index');
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/13_mass_parents.php DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * mass {{siblingLabel}} change - action
3
- * @access public
4
- * @return void
5
- * {{qwertyuiop}}
6
- */
7
- public function mass{{Sibling}}IdAction(){
8
- ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}');
9
- if(!is_array(${{entity}}Ids)) {
10
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('Please select {{entitiesLabel}}.'));
11
- }
12
- else {
13
- try {
14
- foreach (${{entity}}Ids as ${{entity}}Id) {
15
- ${{entity}} = Mage::getSingleton('{{module}}/{{entity}}')->load(${{entity}}Id)
16
- ->set{{Sibling}}Id($this->getRequest()->getParam('flag_{{sibling}}_id'))
17
- ->setIsMassupdate(true)
18
- ->save();
19
- }
20
- $this->_getSession()->addSuccess($this->__('Total of %d {{entitiesLabel}} were successfully updated.', count(${{entity}}Ids)));
21
- }
22
- catch (Mage_Core_Exception $e){
23
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
24
- }
25
- catch (Exception $e) {
26
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('{{module}}')->__('There was an error updating {{entitiesLabel}}.'));
27
- Mage::logException($e);
28
- }
29
- }
30
- $this->_redirect('*/*/index');
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/14_product_relation_actions.php DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * get grid of products action
3
- * @access public
4
- * @return void
5
- * {{qwertyuiop}}
6
- */
7
- public function productsAction(){
8
- $this->_init{{Entity}}();
9
- $this->loadLayout();
10
- $this->getLayout()->getBlock('{{entity}}.edit.tab.product')
11
- ->set{{Entity}}Products($this->getRequest()->getPost('{{entity}}_products', null));
12
- $this->renderLayout();
13
- }
14
- /**
15
- * get grid of products action
16
- * @access public
17
- * @return void
18
- * {{qwertyuiop}}
19
- */
20
- public function productsgridAction(){
21
- $this->_init{{Entity}}();
22
- $this->loadLayout();
23
- $this->getLayout()->getBlock('{{entity}}.edit.tab.product')
24
- ->set{{Entity}}Products($this->getRequest()->getPost('{{entity}}_products', null));
25
- $this->renderLayout();
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ultimate/ModuleCreator/etc/m/app/code/cp/Ns/Md/controllers/Adminhtml/Module/EntityController/15_sibling_actions.php DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * get {{siblings}} action
3
- * @access public
4
- * @return void
5
- * {{qwertyuiop}}
6
- */
7
- public function {{siblings}}Action(){
8
- $this->_init{{Entity}}();
9
- $this->loadLayout();
10
- $this->getLayout()->getBlock('{{entity}}.edit.tab.{{sibling}}')
11
- ->set{{Entity}}{{Siblings}}($this->getRequest()->getPost('{{entity}}_{{siblings}}', null));
12
- $this->renderLayout();
13
- }
14
- /**
15
- * get {{siblings}} grid action
16
- * @acce