Repository: tzyganu/UMC1.9 Branch: master Commit: 205ddbb68dc9 Files: 775 Total size: 1.8 MB Directory structure: gitextract_j1h_l5sq/ ├── .gitignore ├── LICENSE_UMC ├── README.md ├── app/ │ ├── code/ │ │ └── community/ │ │ └── Ultimate/ │ │ └── ModuleCreator/ │ │ ├── Block/ │ │ │ └── Adminhtml/ │ │ │ ├── Modulecreator/ │ │ │ │ ├── Edit/ │ │ │ │ │ ├── Form.php │ │ │ │ │ ├── Tab/ │ │ │ │ │ │ ├── Entities/ │ │ │ │ │ │ │ ├── Entity/ │ │ │ │ │ │ │ │ └── Attribute.php │ │ │ │ │ │ │ └── Entity.php │ │ │ │ │ │ ├── Entities.php │ │ │ │ │ │ ├── Help/ │ │ │ │ │ │ │ └── Fieldset.php │ │ │ │ │ │ ├── Help.php │ │ │ │ │ │ ├── Relation.php │ │ │ │ │ │ └── Settings.php │ │ │ │ │ └── Tabs.php │ │ │ │ ├── Edit.php │ │ │ │ ├── Grid/ │ │ │ │ │ └── Column/ │ │ │ │ │ └── Renderer/ │ │ │ │ │ └── Download.php │ │ │ │ ├── Grid.php │ │ │ │ ├── Menu.php │ │ │ │ └── System/ │ │ │ │ └── Config/ │ │ │ │ └── Form/ │ │ │ │ └── Fieldset/ │ │ │ │ ├── Abstract.php │ │ │ │ ├── Attribute.php │ │ │ │ ├── Entity.php │ │ │ │ └── Settings.php │ │ │ └── Modulecreator.php │ │ ├── Exception.php │ │ ├── Helper/ │ │ │ └── Data.php │ │ ├── Model/ │ │ │ ├── Abstract.php │ │ │ ├── Attribute/ │ │ │ │ └── Type/ │ │ │ │ ├── Abstract.php │ │ │ │ ├── Country.php │ │ │ │ ├── Decimal.php │ │ │ │ ├── Dropdown/ │ │ │ │ │ ├── Abstract.php │ │ │ │ │ ├── Category.php │ │ │ │ │ ├── Custom.php │ │ │ │ │ ├── Customer.php │ │ │ │ │ └── Product.php │ │ │ │ ├── Dropdown.php │ │ │ │ ├── File.php │ │ │ │ ├── Image.php │ │ │ │ ├── Int.php │ │ │ │ ├── Multiselect.php │ │ │ │ ├── Signedint.php │ │ │ │ ├── Text.php │ │ │ │ ├── Textarea.php │ │ │ │ ├── Timestamp.php │ │ │ │ └── Yesno.php │ │ │ ├── Attribute.php │ │ │ ├── Config.php │ │ │ ├── Entity/ │ │ │ │ └── Type/ │ │ │ │ ├── Abstract.php │ │ │ │ ├── Eav.php │ │ │ │ └── Flat.php │ │ │ ├── Entity.php │ │ │ ├── Module/ │ │ │ │ └── Collection.php │ │ │ ├── Module.php │ │ │ ├── Relation.php │ │ │ ├── Source/ │ │ │ │ ├── Attribute/ │ │ │ │ │ ├── Scope.php │ │ │ │ │ ├── Type.php │ │ │ │ │ └── Value/ │ │ │ │ │ └── Source.php │ │ │ │ ├── Codepool.php │ │ │ │ ├── Entity/ │ │ │ │ │ ├── Layout.php │ │ │ │ │ ├── Menu.php │ │ │ │ │ └── Type.php │ │ │ │ └── Install.php │ │ │ └── Writer.php │ │ ├── controllers/ │ │ │ └── Adminhtml/ │ │ │ └── ModulecreatorController.php │ │ └── etc/ │ │ ├── adminhtml.xml │ │ ├── config.xml │ │ ├── jstranslator.xml │ │ ├── source/ │ │ │ ├── app/ │ │ │ │ ├── code/ │ │ │ │ │ ├── Block/ │ │ │ │ │ │ ├── Adminhtml/ │ │ │ │ │ │ │ ├── Catalog/ │ │ │ │ │ │ │ │ ├── Category/ │ │ │ │ │ │ │ │ │ └── Tab/ │ │ │ │ │ │ │ │ │ └── Entity/ │ │ │ │ │ │ │ │ │ ├── 010_tree │ │ │ │ │ │ │ │ │ └── 020_not_tree │ │ │ │ │ │ │ │ └── Product/ │ │ │ │ │ │ │ │ └── Edit/ │ │ │ │ │ │ │ │ └── Tab/ │ │ │ │ │ │ │ │ └── Entity/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_not_tree │ │ │ │ │ │ │ │ ├── 030_tree │ │ │ │ │ │ │ │ └── 040_footer │ │ │ │ │ │ │ ├── Entity/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_eav │ │ │ │ │ │ │ │ ├── 030_footer │ │ │ │ │ │ │ │ ├── Abstract/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ ├── Attribute/ │ │ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ │ │ ├── Edit/ │ │ │ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ │ │ │ ├── Form/ │ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ │ ├── Tab/ │ │ │ │ │ │ │ │ │ │ │ ├── Main/ │ │ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ │ │ └── Options/ │ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ │ └── Tabs/ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ └── Grid/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ ├── Comment/ │ │ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ │ │ ├── Edit/ │ │ │ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ │ │ │ ├── Form/ │ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ │ ├── Tab/ │ │ │ │ │ │ │ │ │ │ │ ├── Form/ │ │ │ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ │ │ │ ├── 020_stores │ │ │ │ │ │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ │ │ │ │ │ └── Stores/ │ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ │ └── Tabs/ │ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ │ ├── 020_stores │ │ │ │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ │ │ │ └── Grid/ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ ├── 013_store_data │ │ │ │ │ │ │ │ │ ├── 016_prepare │ │ │ │ │ │ │ │ │ ├── 020_stores │ │ │ │ │ │ │ │ │ ├── 030_content │ │ │ │ │ │ │ │ │ ├── 040_store_filter │ │ │ │ │ │ │ │ │ └── 050_footer │ │ │ │ │ │ │ │ ├── Edit/ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ ├── 020_tree │ │ │ │ │ │ │ │ │ ├── 030_not_tree │ │ │ │ │ │ │ │ │ ├── Form/ │ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ │ ├── 020_prepare_form │ │ │ │ │ │ │ │ │ │ ├── 025_prepare_form_eav │ │ │ │ │ │ │ │ │ │ ├── 030_tree_top │ │ │ │ │ │ │ │ │ │ ├── 040_product_relation │ │ │ │ │ │ │ │ │ │ ├── 050_entity_relation │ │ │ │ │ │ │ │ │ │ └── 060_footer │ │ │ │ │ │ │ │ │ ├── Tab/ │ │ │ │ │ │ │ │ │ │ ├── Attributes/ │ │ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ │ │ ├── 020_tree │ │ │ │ │ │ │ │ │ │ │ ├── 021_default_values │ │ │ │ │ │ │ │ │ │ │ ├── 022_default_values_tree │ │ │ │ │ │ │ │ │ │ │ ├── 023_layout │ │ │ │ │ │ │ │ │ │ │ ├── 025_after_html_top │ │ │ │ │ │ │ │ │ │ │ ├── 026_after_html │ │ │ │ │ │ │ │ │ │ │ ├── 027_after_html_footer │ │ │ │ │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ │ │ │ │ ├── Categories/ │ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ │ ├── Form/ │ │ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ │ │ ├── 020_image │ │ │ │ │ │ │ │ │ │ │ ├── 030_file │ │ │ │ │ │ │ │ │ │ │ ├── 040_wysiwyg │ │ │ │ │ │ │ │ │ │ │ ├── 050_wysiwyg_is_tree │ │ │ │ │ │ │ │ │ │ │ ├── 060_path_tree │ │ │ │ │ │ │ │ │ │ │ ├── 070_parents │ │ │ │ │ │ │ │ │ │ │ ├── 080_attributes │ │ │ │ │ │ │ │ │ │ │ ├── 090_url_rewrite │ │ │ │ │ │ │ │ │ │ │ ├── 100_status │ │ │ │ │ │ │ │ │ │ │ ├── 110_rss │ │ │ │ │ │ │ │ │ │ │ ├── 120_stores │ │ │ │ │ │ │ │ │ │ │ ├── 130_allow_comment │ │ │ │ │ │ │ │ │ │ │ ├── 140_add_values_not_tree │ │ │ │ │ │ │ │ │ │ │ ├── 150_add_values_tree │ │ │ │ │ │ │ │ │ │ │ ├── 160_get_entity_tree │ │ │ │ │ │ │ │ │ │ │ └── 170_footer │ │ │ │ │ │ │ │ │ │ ├── Meta/ │ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ │ ├── Product/ │ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ │ ├── Sibling/ │ │ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ │ │ ├── 020_not_tree │ │ │ │ │ │ │ │ │ │ │ ├── 030_tree │ │ │ │ │ │ │ │ │ │ │ └── 040_footer │ │ │ │ │ │ │ │ │ │ └── Stores/ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ └── Tabs/ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ ├── 020_flat_not_tree_prepare │ │ │ │ │ │ │ │ │ ├── 030_flat_tree_prepare │ │ │ │ │ │ │ │ │ ├── 040_eav_prepare_top │ │ │ │ │ │ │ │ │ ├── 042_eav_tree_prepare_top │ │ │ │ │ │ │ │ │ ├── 043_eav_seo_prepare │ │ │ │ │ │ │ │ │ ├── 047_eav_prepare_bottom │ │ │ │ │ │ │ │ │ ├── 048_eav_prepare_bottom_tree │ │ │ │ │ │ │ │ │ ├── 049_eav_prepare_real_bottom │ │ │ │ │ │ │ │ │ ├── 050_seo │ │ │ │ │ │ │ │ │ ├── 055_seo_eav │ │ │ │ │ │ │ │ │ ├── 060_stores │ │ │ │ │ │ │ │ │ ├── 070_relation_not_tree │ │ │ │ │ │ │ │ │ ├── 080_relation_tree │ │ │ │ │ │ │ │ │ ├── 090_product_relation_not_tree │ │ │ │ │ │ │ │ │ ├── 100_product_relation_tree │ │ │ │ │ │ │ │ │ ├── 110_category_relation_not_tree │ │ │ │ │ │ │ │ │ ├── 120_category_relation_tree │ │ │ │ │ │ │ │ │ ├── 130_end_prepare_not_tree │ │ │ │ │ │ │ │ │ ├── 140_end_prepare_tree │ │ │ │ │ │ │ │ │ └── 150_footer │ │ │ │ │ │ │ │ ├── Grid/ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ ├── 020_parents │ │ │ │ │ │ │ │ │ ├── 030_name_attribute │ │ │ │ │ │ │ │ │ ├── 040_grid_attributes │ │ │ │ │ │ │ │ │ ├── 050_url_rewrite │ │ │ │ │ │ │ │ │ ├── 060_stores │ │ │ │ │ │ │ │ │ ├── 070_created_at │ │ │ │ │ │ │ │ │ ├── 080_updated_at │ │ │ │ │ │ │ │ │ ├── 090_columns_footer │ │ │ │ │ │ │ │ │ ├── 100_eav_functions │ │ │ │ │ │ │ │ │ ├── 110_mass_action_top │ │ │ │ │ │ │ │ │ ├── 120_mass_action_flags │ │ │ │ │ │ │ │ │ ├── 130_mass_action_parents │ │ │ │ │ │ │ │ │ ├── 140_collection_end │ │ │ │ │ │ │ │ │ ├── 145_collection_walk │ │ │ │ │ │ │ │ │ ├── 150_store_filter │ │ │ │ │ │ │ │ │ └── 160_footer │ │ │ │ │ │ │ │ ├── Helper/ │ │ │ │ │ │ │ │ │ ├── File/ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ └── Image/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ ├── Tree/ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ ├── 020_store_switcher │ │ │ │ │ │ │ │ │ ├── 030_content │ │ │ │ │ │ │ │ │ ├── 040_eav │ │ │ │ │ │ │ │ │ ├── 050_methods │ │ │ │ │ │ │ │ │ ├── 060_store_switcher_block │ │ │ │ │ │ │ │ │ └── 070_footer │ │ │ │ │ │ │ │ └── Widget/ │ │ │ │ │ │ │ │ └── Chooser/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_not_tree │ │ │ │ │ │ │ │ ├── 030_not_tree_eav │ │ │ │ │ │ │ │ ├── 040_not_tree_content │ │ │ │ │ │ │ │ ├── 050_not_tree_store │ │ │ │ │ │ │ │ ├── 060_not_tree_footer │ │ │ │ │ │ │ │ ├── 070_not_tree_flat │ │ │ │ │ │ │ │ ├── 080_tree │ │ │ │ │ │ │ │ └── 090_footer │ │ │ │ │ │ │ ├── Helper/ │ │ │ │ │ │ │ │ ├── Column/ │ │ │ │ │ │ │ │ │ └── Renderer/ │ │ │ │ │ │ │ │ │ ├── Parent/ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ └── Relation/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ └── Wysiwyg/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── Module/ │ │ │ │ │ │ │ ├── Helper/ │ │ │ │ │ │ │ │ └── Form/ │ │ │ │ │ │ │ │ └── Wysiwyg/ │ │ │ │ │ │ │ │ └── Content/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── Renderer/ │ │ │ │ │ │ │ └── Fieldset/ │ │ │ │ │ │ │ └── Element/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── Catalog/ │ │ │ │ │ │ │ ├── Category/ │ │ │ │ │ │ │ │ └── List/ │ │ │ │ │ │ │ │ └── Entity/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_store │ │ │ │ │ │ │ │ ├── 030_eav │ │ │ │ │ │ │ │ ├── 040_not_eav │ │ │ │ │ │ │ │ └── 050_footer │ │ │ │ │ │ │ └── Product/ │ │ │ │ │ │ │ └── List/ │ │ │ │ │ │ │ └── Entity/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_store │ │ │ │ │ │ │ ├── 030_eav │ │ │ │ │ │ │ ├── 040_not_eav │ │ │ │ │ │ │ └── 050_footer │ │ │ │ │ │ ├── Entity/ │ │ │ │ │ │ │ ├── Catalog/ │ │ │ │ │ │ │ │ ├── Category/ │ │ │ │ │ │ │ │ │ └── List/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ └── Product/ │ │ │ │ │ │ │ │ └── List/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Child/ │ │ │ │ │ │ │ │ └── List/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Children/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Comment/ │ │ │ │ │ │ │ │ ├── Form/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ └── List/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_stores │ │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ │ ├── Customer/ │ │ │ │ │ │ │ │ └── Comment/ │ │ │ │ │ │ │ │ ├── List/ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ ├── 020_store │ │ │ │ │ │ │ │ │ ├── 030_filter_eav │ │ │ │ │ │ │ │ │ ├── 040_filter_flat │ │ │ │ │ │ │ │ │ └── 050_footer │ │ │ │ │ │ │ │ └── View/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── List/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_stores │ │ │ │ │ │ │ │ ├── 030_attributes │ │ │ │ │ │ │ │ ├── 040_status │ │ │ │ │ │ │ │ ├── 050_not_tree │ │ │ │ │ │ │ │ ├── 060_tree_flat │ │ │ │ │ │ │ │ ├── 070_tree_eav │ │ │ │ │ │ │ │ └── 080_footer │ │ │ │ │ │ │ ├── Rss/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_stores │ │ │ │ │ │ │ │ ├── 025_eav │ │ │ │ │ │ │ │ ├── 030_content │ │ │ │ │ │ │ │ ├── 035_tree │ │ │ │ │ │ │ │ ├── 040_attributes │ │ │ │ │ │ │ │ └── 050_footer │ │ │ │ │ │ │ ├── Sibling/ │ │ │ │ │ │ │ │ └── List/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── View/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── Widget/ │ │ │ │ │ │ │ ├── Link/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Subtree/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── View/ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ ├── 020_not_tree │ │ │ │ │ │ │ ├── 030_tree │ │ │ │ │ │ │ └── 040_footer │ │ │ │ │ │ └── Rss/ │ │ │ │ │ │ └── 010_content │ │ │ │ │ ├── Controller/ │ │ │ │ │ │ ├── Adminhtml/ │ │ │ │ │ │ │ └── Module/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ └── Router/ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ ├── 020_entity │ │ │ │ │ │ └── 030_footer │ │ │ │ │ ├── Helper/ │ │ │ │ │ │ ├── Category/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_content │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ ├── Data/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── Entity/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_create_list │ │ │ │ │ │ │ ├── 030_breadcrumbs │ │ │ │ │ │ │ ├── 040_tree │ │ │ │ │ │ │ ├── 050_rss │ │ │ │ │ │ │ ├── 060_file │ │ │ │ │ │ │ ├── 070_eav │ │ │ │ │ │ │ ├── 080_footer │ │ │ │ │ │ │ └── Image/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── Image/ │ │ │ │ │ │ │ └── Abstract/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ └── Product/ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ ├── 020_content │ │ │ │ │ │ └── 030_footer │ │ │ │ │ ├── Model/ │ │ │ │ │ │ ├── Adminhtml/ │ │ │ │ │ │ │ ├── Observer/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_entity_product │ │ │ │ │ │ │ │ ├── 030_entity_product_save │ │ │ │ │ │ │ │ ├── 040_entity_product_save_tree │ │ │ │ │ │ │ │ ├── 050_entity_category │ │ │ │ │ │ │ │ ├── 055_entity_category_tree │ │ │ │ │ │ │ │ ├── 060_entity_category_save │ │ │ │ │ │ │ │ ├── 070_entity_category_save_tree │ │ │ │ │ │ │ │ └── 080_footer │ │ │ │ │ │ │ ├── Search/ │ │ │ │ │ │ │ │ └── Entity/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── Source/ │ │ │ │ │ │ │ └── Yesnodefault/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── Api2/ │ │ │ │ │ │ │ └── Entity/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_eav │ │ │ │ │ │ │ ├── 030_footer │ │ │ │ │ │ │ └── Rest/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 015_tree_filter │ │ │ │ │ │ │ ├── 020_store_collection │ │ │ │ │ │ │ ├── 030_collection_center │ │ │ │ │ │ │ ├── 040_url │ │ │ │ │ │ │ ├── 050_center │ │ │ │ │ │ │ ├── 060_eav │ │ │ │ │ │ │ ├── 070_load │ │ │ │ │ │ │ ├── 080_store │ │ │ │ │ │ │ ├── 090_footer │ │ │ │ │ │ │ ├── Admin/ │ │ │ │ │ │ │ │ └── V1/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_tree_filter │ │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ │ ├── Customer/ │ │ │ │ │ │ │ │ └── V1/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── Guest/ │ │ │ │ │ │ │ └── V1/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── Attribute/ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ └── Source/ │ │ │ │ │ │ │ └── Country/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── Entity/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_var_sibling │ │ │ │ │ │ │ ├── 030_var_product_relation │ │ │ │ │ │ │ ├── 040_var_category_relation │ │ │ │ │ │ │ ├── 050_construct │ │ │ │ │ │ │ ├── 060_url │ │ │ │ │ │ │ ├── 070_url_rewrite │ │ │ │ │ │ │ ├── 080_editors │ │ │ │ │ │ │ ├── 090_after_save_top │ │ │ │ │ │ │ ├── 100_after_save_product │ │ │ │ │ │ │ ├── 110_after_save_category │ │ │ │ │ │ │ ├── 120_after_save_sibling │ │ │ │ │ │ │ ├── 130_after_save_footer │ │ │ │ │ │ │ ├── 140_product_relation │ │ │ │ │ │ │ ├── 150_category_relation │ │ │ │ │ │ │ ├── 160_sibling_relation │ │ │ │ │ │ │ ├── 163_children_relation │ │ │ │ │ │ │ ├── 165_parent_relation │ │ │ │ │ │ │ ├── 170_tree │ │ │ │ │ │ │ ├── 175_eav_default_attribute_set │ │ │ │ │ │ │ ├── 180_allow_comment │ │ │ │ │ │ │ ├── 190_default_values │ │ │ │ │ │ │ ├── 200_default_values_rss │ │ │ │ │ │ │ ├── 210_default_values_comment │ │ │ │ │ │ │ ├── 215_default_attribute_values │ │ │ │ │ │ │ ├── 220_footer │ │ │ │ │ │ │ ├── Api/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 013_eav │ │ │ │ │ │ │ │ ├── 014_tree_filter │ │ │ │ │ │ │ │ ├── 016_content │ │ │ │ │ │ │ │ ├── 017_add_eav │ │ │ │ │ │ │ │ ├── 018_add_end │ │ │ │ │ │ │ │ ├── 019_update_eav │ │ │ │ │ │ │ │ ├── 020_update_footer │ │ │ │ │ │ │ │ ├── 024_product_relation_info │ │ │ │ │ │ │ │ ├── 030_category_relation_info │ │ │ │ │ │ │ │ ├── 040_sibling_info │ │ │ │ │ │ │ │ ├── 050_info_footer │ │ │ │ │ │ │ │ ├── 060_tree │ │ │ │ │ │ │ │ ├── 070_product_relation │ │ │ │ │ │ │ │ ├── 080_category_relation │ │ │ │ │ │ │ │ ├── 090_sibling_relation │ │ │ │ │ │ │ │ ├── 095_sibling_relation_tree │ │ │ │ │ │ │ │ ├── 097_get_attributes │ │ │ │ │ │ │ │ ├── 098_get_api_data_flat │ │ │ │ │ │ │ │ ├── 099_get_api_data_eav │ │ │ │ │ │ │ │ ├── 100_footer │ │ │ │ │ │ │ │ └── V2/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_product_relation │ │ │ │ │ │ │ │ ├── 030_category_relation │ │ │ │ │ │ │ │ ├── 040_sibling_relation │ │ │ │ │ │ │ │ └── 050_footer │ │ │ │ │ │ │ ├── Attribute/ │ │ │ │ │ │ │ │ ├── Api/ │ │ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ │ │ └── V2/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ ├── Backend/ │ │ │ │ │ │ │ │ │ ├── File/ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ ├── Image/ │ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ │ └── Urlkey/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ └── Source/ │ │ │ │ │ │ │ │ └── Attributecode/ │ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ │ ├── 020_eav │ │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ │ ├── Category/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Comment/ │ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ │ └── Api/ │ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ │ └── V2/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Product/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Sibling/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── Source/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_eav │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ ├── Observer/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_entity │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ └── Resource/ │ │ │ │ │ │ ├── Attribute/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── Eav/ │ │ │ │ │ │ │ └── Attribute/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── Entity/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_tree_var │ │ │ │ │ │ │ ├── 030_constructor │ │ │ │ │ │ │ ├── 032_eav_construct │ │ │ │ │ │ │ ├── 037_store │ │ │ │ │ │ │ ├── 040_not_tree │ │ │ │ │ │ │ ├── 045_before_save_multiple │ │ │ │ │ │ │ ├── 050_tree │ │ │ │ │ │ │ ├── 052_tree_store │ │ │ │ │ │ │ ├── 053_tree_after │ │ │ │ │ │ │ ├── 055_tree_eav │ │ │ │ │ │ │ ├── 060_tree_before_save_no_url_rewrite │ │ │ │ │ │ │ ├── 070_eav_tree_before_save_url_rewrite │ │ │ │ │ │ │ ├── 080_tree_before_save_url_rewrite │ │ │ │ │ │ │ ├── 090_content │ │ │ │ │ │ │ ├── 100_url_rewrite │ │ │ │ │ │ │ ├── 103_url_rewrite_store │ │ │ │ │ │ │ ├── 107_url_rewrite_no_store │ │ │ │ │ │ │ ├── 110_url_rewrite_before_save_not_tree │ │ │ │ │ │ │ ├── 120_url_rewrite_eav │ │ │ │ │ │ │ ├── 130_footer │ │ │ │ │ │ │ ├── Attribute/ │ │ │ │ │ │ │ │ └── Collection/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Category/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_not_tree │ │ │ │ │ │ │ │ ├── 030_tree │ │ │ │ │ │ │ │ ├── 040_footer │ │ │ │ │ │ │ │ └── Collection/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Collection/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_top_store │ │ │ │ │ │ │ │ ├── 030_content │ │ │ │ │ │ │ │ ├── 040_store │ │ │ │ │ │ │ │ ├── 050_tree │ │ │ │ │ │ │ │ ├── 060_not_tree │ │ │ │ │ │ │ │ ├── 070_product_relation │ │ │ │ │ │ │ │ ├── 080_category_relation │ │ │ │ │ │ │ │ ├── 090_sibling_relation │ │ │ │ │ │ │ │ └── 100_footer │ │ │ │ │ │ │ ├── Comment/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_store │ │ │ │ │ │ │ │ ├── 030_footer │ │ │ │ │ │ │ │ ├── Collection/ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ ├── 020_top_store │ │ │ │ │ │ │ │ │ ├── 030_content │ │ │ │ │ │ │ │ │ ├── 040_store │ │ │ │ │ │ │ │ │ └── 050_footer │ │ │ │ │ │ │ │ └── Entity/ │ │ │ │ │ │ │ │ └── Collection/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_store_var │ │ │ │ │ │ │ │ ├── 030_construct │ │ │ │ │ │ │ │ ├── 040_construct_store │ │ │ │ │ │ │ │ ├── 050_content │ │ │ │ │ │ │ │ ├── 060_eav_title │ │ │ │ │ │ │ │ ├── 070_more_content │ │ │ │ │ │ │ │ ├── 073_select_count_store │ │ │ │ │ │ │ │ ├── 075_select_sql │ │ │ │ │ │ │ │ ├── 080_store_top │ │ │ │ │ │ │ │ ├── 090_flat_store │ │ │ │ │ │ │ │ ├── 100_store │ │ │ │ │ │ │ │ ├── 110_filter │ │ │ │ │ │ │ │ ├── 120_store_filter │ │ │ │ │ │ │ │ └── 130_footer │ │ │ │ │ │ │ ├── Product/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_not_tree │ │ │ │ │ │ │ │ ├── 030_tree │ │ │ │ │ │ │ │ ├── 040_footer │ │ │ │ │ │ │ │ └── Collection/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── Sibling/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_save_relation │ │ │ │ │ │ │ │ ├── 030_save_relation_tree │ │ │ │ │ │ │ │ ├── 040_footer │ │ │ │ │ │ │ │ └── Collection/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── Tree/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_eav │ │ │ │ │ │ │ ├── 030_content │ │ │ │ │ │ │ ├── 040_flat_collection │ │ │ │ │ │ │ ├── 050_eav_collection │ │ │ │ │ │ │ └── 060_footer │ │ │ │ │ │ └── Setup/ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ ├── 020_eav_top │ │ │ │ │ │ ├── 030_eav │ │ │ │ │ │ ├── 040_eav_footer │ │ │ │ │ │ └── 050_footer │ │ │ │ │ ├── controllers/ │ │ │ │ │ │ ├── Adminhtml/ │ │ │ │ │ │ │ └── Module/ │ │ │ │ │ │ │ ├── Entity/ │ │ │ │ │ │ │ │ ├── AttributeController/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ ├── Catalog/ │ │ │ │ │ │ │ │ │ ├── CategoryController/ │ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ │ ├── 020_not_tree │ │ │ │ │ │ │ │ │ │ ├── 030_tree │ │ │ │ │ │ │ │ │ │ └── 040_footer │ │ │ │ │ │ │ │ │ └── ProductController/ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ ├── 020_not_tree │ │ │ │ │ │ │ │ │ ├── 030_tree │ │ │ │ │ │ │ │ │ └── 040_footer │ │ │ │ │ │ │ │ ├── CommentController/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ └── WidgetController/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_tree │ │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ │ ├── EntityControllerEavNotTree/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_save_product_relation │ │ │ │ │ │ │ │ ├── 030_save_category_relation │ │ │ │ │ │ │ │ ├── 040_sibling_save │ │ │ │ │ │ │ │ ├── 045_sibling_save_tree │ │ │ │ │ │ │ │ ├── 050_middle │ │ │ │ │ │ │ │ ├── 060_mass_action │ │ │ │ │ │ │ │ ├── 065_mass_parents │ │ │ │ │ │ │ │ ├── 070_product_relation_actions │ │ │ │ │ │ │ │ ├── 080_category_relation_actions │ │ │ │ │ │ │ │ ├── 090_sibling_grid │ │ │ │ │ │ │ │ ├── 100_sibling_actions_tree │ │ │ │ │ │ │ │ └── 110_footer │ │ │ │ │ │ │ ├── EntityControllerEavTree/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_product_data │ │ │ │ │ │ │ │ ├── 030_category_data │ │ │ │ │ │ │ │ ├── 040_sibling_data │ │ │ │ │ │ │ │ ├── 045_sibling_data_tree │ │ │ │ │ │ │ │ ├── 050_real_save │ │ │ │ │ │ │ │ ├── 060_product_relation_action │ │ │ │ │ │ │ │ ├── 070_category_relation_action │ │ │ │ │ │ │ │ ├── 080_sibling_actions │ │ │ │ │ │ │ │ └── 090_footer │ │ │ │ │ │ │ ├── EntityControllerFlatNotTree/ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ ├── 020_upload_image │ │ │ │ │ │ │ │ ├── 030_upload_files │ │ │ │ │ │ │ │ ├── 040_save_product_relation │ │ │ │ │ │ │ │ ├── 050_save_category_relation │ │ │ │ │ │ │ │ ├── 060_save_sibling_relation │ │ │ │ │ │ │ │ ├── 070_save_sibling_relation_tree │ │ │ │ │ │ │ │ ├── 080_save │ │ │ │ │ │ │ │ ├── 090_exception_upload │ │ │ │ │ │ │ │ ├── 100_exception │ │ │ │ │ │ │ │ ├── 110_center │ │ │ │ │ │ │ │ ├── 120_mass_update │ │ │ │ │ │ │ │ ├── 130_mass_parents │ │ │ │ │ │ │ │ ├── 140_product_relation_actions │ │ │ │ │ │ │ │ ├── 150_category_relation_actions │ │ │ │ │ │ │ │ ├── 160_sibling_actions │ │ │ │ │ │ │ │ ├── 170_sibling_actions_tree │ │ │ │ │ │ │ │ └── 180_footer │ │ │ │ │ │ │ └── EntityControllerFlatTree/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_wysiwyg │ │ │ │ │ │ │ ├── 030_save │ │ │ │ │ │ │ ├── 040_upload_image │ │ │ │ │ │ │ ├── 050_upload_file │ │ │ │ │ │ │ ├── 060_save_continue │ │ │ │ │ │ │ ├── 070_product_data │ │ │ │ │ │ │ ├── 080_category_data │ │ │ │ │ │ │ ├── 090_sibling_data │ │ │ │ │ │ │ ├── 095_sibling_data_tree │ │ │ │ │ │ │ ├── 100_real_save │ │ │ │ │ │ │ ├── 110_product_relation_action │ │ │ │ │ │ │ ├── 120_category_relation_action │ │ │ │ │ │ │ ├── 130_sibling_actions │ │ │ │ │ │ │ ├── 135_sibling_actions_tree │ │ │ │ │ │ │ └── 140_footer │ │ │ │ │ │ ├── Entity/ │ │ │ │ │ │ │ └── Customer/ │ │ │ │ │ │ │ └── CommentController/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_entity_eav │ │ │ │ │ │ │ ├── 030_entity_flat │ │ │ │ │ │ │ ├── 040_store │ │ │ │ │ │ │ ├── 050_entity_flat_store │ │ │ │ │ │ │ └── 060_footer │ │ │ │ │ │ └── EntityController/ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ ├── 020_list │ │ │ │ │ │ ├── 030_list_seo │ │ │ │ │ │ ├── 040_list_footer │ │ │ │ │ │ ├── 050_view │ │ │ │ │ │ ├── 060_view_tree │ │ │ │ │ │ ├── 070_view2 │ │ │ │ │ │ ├── 080_breadcrumbs │ │ │ │ │ │ ├── 090_breadcrumbs_tree │ │ │ │ │ │ ├── 100_breadcrumbs_footer │ │ │ │ │ │ ├── 105_view_canonical │ │ │ │ │ │ ├── 110_view_seo │ │ │ │ │ │ ├── 120_view_footer │ │ │ │ │ │ ├── 130_rss │ │ │ │ │ │ ├── 140_comment │ │ │ │ │ │ └── 150_footer │ │ │ │ │ ├── data/ │ │ │ │ │ │ └── namespace_module_setup/ │ │ │ │ │ │ └── data-install/ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ └── 020_entity │ │ │ │ │ ├── etc/ │ │ │ │ │ │ ├── adminhtml/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── api/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_entity_api │ │ │ │ │ │ │ ├── 030_resource_alias │ │ │ │ │ │ │ ├── 040_entity_resource_alias │ │ │ │ │ │ │ ├── 050_v2 │ │ │ │ │ │ │ ├── 060_v2_entity │ │ │ │ │ │ │ ├── 070_acl │ │ │ │ │ │ │ ├── 080_acl_entity │ │ │ │ │ │ │ └── 090_footer │ │ │ │ │ │ ├── api2/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── config/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_tables │ │ │ │ │ │ │ ├── 030_store_tables │ │ │ │ │ │ │ ├── 040_siblings_table │ │ │ │ │ │ │ ├── 050_product_relation_table │ │ │ │ │ │ │ ├── 060_category_relation_table │ │ │ │ │ │ │ ├── 070_comment_table │ │ │ │ │ │ │ ├── 080_comment_store_table │ │ │ │ │ │ │ ├── 090_eav_attribute │ │ │ │ │ │ │ ├── 100_global │ │ │ │ │ │ │ ├── 110_url_rewrite │ │ │ │ │ │ │ ├── 120_adminhtml │ │ │ │ │ │ │ ├── 130_relation_events_top │ │ │ │ │ │ │ ├── 140_relation_product_top │ │ │ │ │ │ │ ├── 150_relation_events_middle │ │ │ │ │ │ │ ├── 160_relation_category_top │ │ │ │ │ │ │ ├── 170_relation_product_bottom_start │ │ │ │ │ │ │ ├── 180_relation_product_bottom │ │ │ │ │ │ │ ├── 190_relation_product_bottom_end │ │ │ │ │ │ │ ├── 200_relation_category_bottom_start │ │ │ │ │ │ │ ├── 210_relation_category_bottom │ │ │ │ │ │ │ ├── 220_relation_category_bottom_end │ │ │ │ │ │ │ ├── 230_relation_events_bottom │ │ │ │ │ │ │ ├── 240_global_search_top │ │ │ │ │ │ │ ├── 250_global_search_entity │ │ │ │ │ │ │ ├── 260_global_search_footer │ │ │ │ │ │ │ ├── 270_admin │ │ │ │ │ │ │ ├── 280_frontend │ │ │ │ │ │ │ ├── 284_router │ │ │ │ │ │ │ ├── 287_frontend_footer │ │ │ │ │ │ │ ├── 290_default_top │ │ │ │ │ │ │ ├── 300_default │ │ │ │ │ │ │ ├── 310_default_footer │ │ │ │ │ │ │ └── 320_footer │ │ │ │ │ │ ├── system/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_entity │ │ │ │ │ │ │ └── 030_footer │ │ │ │ │ │ ├── widget/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_entity │ │ │ │ │ │ │ ├── 030_tree │ │ │ │ │ │ │ └── 040_footer │ │ │ │ │ │ ├── wsdl/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_entity_types │ │ │ │ │ │ │ ├── 023_entity_comment_types │ │ │ │ │ │ │ ├── 026_entity_attribute_types │ │ │ │ │ │ │ ├── 030_schema_footer │ │ │ │ │ │ │ ├── 040_entity_messages │ │ │ │ │ │ │ ├── 043_entity_comment_messages │ │ │ │ │ │ │ ├── 046_entity_attribute_messages │ │ │ │ │ │ │ ├── 050_porttype_top │ │ │ │ │ │ │ ├── 060_porttype_entity │ │ │ │ │ │ │ ├── 063_porttype_entity_comment │ │ │ │ │ │ │ ├── 066_porttype_entity_attribute │ │ │ │ │ │ │ ├── 070_porttype_footer │ │ │ │ │ │ │ ├── 080_binding_top │ │ │ │ │ │ │ ├── 090_entity_binding │ │ │ │ │ │ │ ├── 093_entity_binding_comment │ │ │ │ │ │ │ ├── 096_entity_binding_attribute │ │ │ │ │ │ │ └── 100_footer │ │ │ │ │ │ └── wsi/ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ ├── 020_entity_types │ │ │ │ │ │ ├── 023_entity_comment_types │ │ │ │ │ │ ├── 026_entity_attribute_types │ │ │ │ │ │ ├── 030_schema_footer │ │ │ │ │ │ ├── 040_entity_messages │ │ │ │ │ │ ├── 043_entity_comment_messages │ │ │ │ │ │ ├── 046_entity_attribute_messages │ │ │ │ │ │ ├── 050_porttype_top │ │ │ │ │ │ ├── 060_porttype_entity │ │ │ │ │ │ ├── 063_porttype_entity_comment │ │ │ │ │ │ ├── 066_porttype_entity_attribute │ │ │ │ │ │ ├── 070_porttype_footer │ │ │ │ │ │ ├── 080_binding_top │ │ │ │ │ │ ├── 090_entity_binding │ │ │ │ │ │ ├── 093_entity_binding_comment │ │ │ │ │ │ ├── 096_entity_binding_attribute │ │ │ │ │ │ └── 100_footer │ │ │ │ │ └── sql/ │ │ │ │ │ └── namespace_module_setup/ │ │ │ │ │ └── install/ │ │ │ │ │ ├── 010_top │ │ │ │ │ ├── 020_entity_flat │ │ │ │ │ ├── 030_entity_store │ │ │ │ │ ├── 040_entity_eav │ │ │ │ │ ├── 050_product_relation │ │ │ │ │ ├── 060_category_relation │ │ │ │ │ ├── 070_comments │ │ │ │ │ ├── 080_comments_store │ │ │ │ │ ├── 090_sibling_relation │ │ │ │ │ ├── 100_has_eav │ │ │ │ │ ├── 110_product_attribute │ │ │ │ │ ├── 120_category_attribute │ │ │ │ │ ├── 125_eav_options_default │ │ │ │ │ └── 130_footer │ │ │ │ ├── design/ │ │ │ │ │ ├── adminhtml/ │ │ │ │ │ │ ├── layout/ │ │ │ │ │ │ │ └── namespace_module/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_entity_not_tree │ │ │ │ │ │ │ ├── 023_eav │ │ │ │ │ │ │ ├── 027_entity_not_tree_footer │ │ │ │ │ │ │ ├── 028_entity_edit_eav │ │ │ │ │ │ │ ├── 029_edit_footer │ │ │ │ │ │ │ ├── 030_relation_product │ │ │ │ │ │ │ ├── 040_relation_category │ │ │ │ │ │ │ ├── 050_relation_sibling │ │ │ │ │ │ │ ├── 060_entity_tree │ │ │ │ │ │ │ ├── 070_relation_product_tree │ │ │ │ │ │ │ ├── 080_relation_category_tree │ │ │ │ │ │ │ ├── 090_relation_sibling_tree │ │ │ │ │ │ │ ├── 100_eav_attribute_edit │ │ │ │ │ │ │ ├── 110_comment │ │ │ │ │ │ │ └── 120_footer │ │ │ │ │ │ └── template/ │ │ │ │ │ │ └── namespace_module/ │ │ │ │ │ │ ├── attribute/ │ │ │ │ │ │ │ └── js/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── catalog/ │ │ │ │ │ │ │ ├── category/ │ │ │ │ │ │ │ │ └── tab/ │ │ │ │ │ │ │ │ └── entities/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── product/ │ │ │ │ │ │ │ └── edit/ │ │ │ │ │ │ │ └── tab/ │ │ │ │ │ │ │ └── entity/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── entity/ │ │ │ │ │ │ │ ├── edit/ │ │ │ │ │ │ │ │ ├── 010_content │ │ │ │ │ │ │ │ ├── form/ │ │ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ │ │ ├── 020_product_hidden │ │ │ │ │ │ │ │ │ ├── 030_category_hidden │ │ │ │ │ │ │ │ │ ├── 040_sibling_hidden │ │ │ │ │ │ │ │ │ ├── 050_content │ │ │ │ │ │ │ │ │ ├── 060_product_relation │ │ │ │ │ │ │ │ │ ├── 070_sibling_relations │ │ │ │ │ │ │ │ │ └── 080_footer │ │ │ │ │ │ │ │ └── tab/ │ │ │ │ │ │ │ │ ├── categories/ │ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ │ └── sibling/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ ├── tree/ │ │ │ │ │ │ │ │ ├── 010_not_eav │ │ │ │ │ │ │ │ └── 020_eav │ │ │ │ │ │ │ └── widget/ │ │ │ │ │ │ │ └── tree/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── form/ │ │ │ │ │ │ │ └── renderer/ │ │ │ │ │ │ │ └── fieldset/ │ │ │ │ │ │ │ └── element/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ └── grid/ │ │ │ │ │ │ └── 010_content │ │ │ │ │ └── frontend/ │ │ │ │ │ ├── layout/ │ │ │ │ │ │ └── namespace_module/ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ ├── 020_comment │ │ │ │ │ │ ├── 060_list │ │ │ │ │ │ ├── 070_view │ │ │ │ │ │ ├── 080_entity_rss │ │ │ │ │ │ ├── 090_rss_top │ │ │ │ │ │ ├── 100_rss │ │ │ │ │ │ ├── 110_rss_footer │ │ │ │ │ │ ├── 120_relation_product │ │ │ │ │ │ ├── 130_relation_category │ │ │ │ │ │ ├── 135_entity_comment │ │ │ │ │ │ └── 140_footer │ │ │ │ │ └── template/ │ │ │ │ │ └── namespace_module/ │ │ │ │ │ ├── catalog/ │ │ │ │ │ │ ├── category/ │ │ │ │ │ │ │ └── list/ │ │ │ │ │ │ │ └── entity/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ └── product/ │ │ │ │ │ │ └── list/ │ │ │ │ │ │ └── entity/ │ │ │ │ │ │ └── 010_content │ │ │ │ │ ├── entity/ │ │ │ │ │ │ ├── catalog/ │ │ │ │ │ │ │ ├── category/ │ │ │ │ │ │ │ │ └── list/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── product/ │ │ │ │ │ │ │ └── list/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── child/ │ │ │ │ │ │ │ └── list/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── children/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── comment/ │ │ │ │ │ │ │ ├── form/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── list/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── customer/ │ │ │ │ │ │ │ └── comment/ │ │ │ │ │ │ │ ├── list/ │ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ │ └── view/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── list/ │ │ │ │ │ │ │ ├── 010_top │ │ │ │ │ │ │ ├── 020_rss_link │ │ │ │ │ │ │ ├── 030_footer │ │ │ │ │ │ │ └── 040_footer_is_tree │ │ │ │ │ │ ├── sibling/ │ │ │ │ │ │ │ └── list/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── view/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ └── widget/ │ │ │ │ │ │ ├── link/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ ├── subtree/ │ │ │ │ │ │ │ └── 010_content │ │ │ │ │ │ └── view/ │ │ │ │ │ │ └── 010_content │ │ │ │ │ └── rss/ │ │ │ │ │ └── 010_content │ │ │ │ ├── etc/ │ │ │ │ │ └── modules/ │ │ │ │ │ └── Namespace_Module/ │ │ │ │ │ └── 010_content │ │ │ │ └── locale/ │ │ │ │ ├── 010_global │ │ │ │ ├── 020_entity │ │ │ │ ├── 030_attribute │ │ │ │ ├── 040_rss │ │ │ │ ├── 050_seo │ │ │ │ ├── 060_attribute_yesno │ │ │ │ ├── 070_file │ │ │ │ ├── 080_product_relation │ │ │ │ ├── 090_category_relation │ │ │ │ ├── 100_relations │ │ │ │ ├── 110_tree │ │ │ │ ├── 120_tree_entity │ │ │ │ ├── 130_url_rewrite │ │ │ │ ├── 140_api │ │ │ │ ├── 150_api_entity │ │ │ │ ├── 160_api_product_related │ │ │ │ ├── 170_api_category_related │ │ │ │ ├── 180_api_tree │ │ │ │ ├── 190_api_sibling │ │ │ │ ├── 200_entity_eav │ │ │ │ ├── 210_eav │ │ │ │ ├── 220_entity_comment │ │ │ │ ├── 230_comment │ │ │ │ ├── 240_comment_store │ │ │ │ ├── 250_api_comment │ │ │ │ ├── 260_eav_api │ │ │ │ ├── 270_frontend │ │ │ │ ├── 280_entity_seo │ │ │ │ ├── 290_rest │ │ │ │ ├── 300_rest_entity │ │ │ │ └── 310_parent │ │ │ └── skin/ │ │ │ ├── css/ │ │ │ │ └── namespace_module/ │ │ │ │ └── tree/ │ │ │ │ └── 010_content │ │ │ ├── images/ │ │ │ │ └── placeholder/ │ │ │ │ └── entity/ │ │ │ │ └── 010_content │ │ │ └── js/ │ │ │ └── namespace_module/ │ │ │ └── tree/ │ │ │ └── 010_content │ │ ├── system.xml │ │ ├── umc.xml │ │ └── umc_source.xml │ ├── design/ │ │ └── adminhtml/ │ │ └── default/ │ │ └── default/ │ │ ├── layout/ │ │ │ └── ultimate_modulecreator.xml │ │ └── template/ │ │ └── ultimate_modulecreator/ │ │ ├── edit/ │ │ │ └── tab/ │ │ │ ├── entities/ │ │ │ │ ├── entity/ │ │ │ │ │ └── attribute.phtml │ │ │ │ └── entity.phtml │ │ │ ├── entities.phtml │ │ │ ├── help/ │ │ │ │ └── fieldset.phtml │ │ │ ├── help.phtml │ │ │ └── relation.phtml │ │ ├── edit.phtml │ │ └── tooltip.phtml │ ├── etc/ │ │ └── modules/ │ │ └── Ultimate_ModuleCreator.xml │ └── locale/ │ └── en_US/ │ └── Ultimate_ModuleCreator.csv ├── composer.json ├── js/ │ └── ultimate_modulecreator.js ├── modman ├── skin/ │ └── adminhtml/ │ └── default/ │ └── default/ │ └── ultimate_modulecreator.css └── wagner.cson ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ /vendor/ composer.lock ================================================ FILE: LICENSE_UMC ================================================ The MIT License (MIT) Copyright (c) 2014 Marius 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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. ================================================ FILE: README.md ================================================ Ultimate Module Creator 1.9.6.0 ====== ## Notice Because of lack of time, motivation and because Magento2 is already a mature platform, I'm deciding to pull the plug on this module creator. There will be no updates, no new features. Feel free to fork it, make it better and redestribute it. New Ultimate Module Creator for Magento 1.7 + ------------- This is the new version of Ultimate Module Creator. This should be the version 2.0 of the Magento extension but I'm keeping this version for the Module Creator for Magento 2.0. Backwards compatibility has been broken. If someone wants to help with the testing please submit any bugs, improvements or feature requests here Also any good code is welcomed. **Note** For the rest of the document UMC = Ultimate Module Creator Documentation can be found on the [wiki pages](https://github.com/tzyganu/UMC1.9/wiki/). The documentation includes a list of [features](https://github.com/tzyganu/UMC1.9/wiki/features) and [release notes](https://github.com/tzyganu/UMC1.9/wiki/release-notes) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Form.php ================================================ */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { /** * prepare form * * @access protected * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Form * @author Marius Strajeru */ protected function _prepareForm() { $form = new Varien_Data_Form( array( 'id' => 'edit_form', 'action' => $this->getUrl( '*/modulecreator/save', array( 'id' => $this->getRequest()->getParam('id') ) ), 'method' => 'post' ) ); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Entities/Entity/Attribute.php ================================================ */ /** * add attribute form * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ /** * @method Varien_Object getAttributeInstance() * @method Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity_Attribute setAttributeInstance() * @method string getEntityId() * @method Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity_Attribute setIncrement() * @method int getIncrement() * @method Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity_Attribute setEntityId() */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity_Attribute extends Mage_Adminhtml_Block_Widget_Form { /** * prepare attribute form * * @access protected * @return string * @author Marius Strajeru */ protected function _prepareForm() { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $form = $helper->getXmlForm('attribute', false); $form->setHtmlIdPrefix('attribute_'.$this->getEntityId().'_'.$this->getIncrement().'_'); $form->addFieldNameSuffix('entity['.$this->getEntityId().'][attributes]['.$this->getIncrement().']'); $this->setForm($form); $form->addValues($this->getAttributeInstance()->getData()); return parent::_prepareForm(); } /** * set an entity with default values * * @access public * @return Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity * @author Marius Strajeru */ public function setDefaultAttributeInstance() { /** @var Ultimate_ModuleCreator_Model_Attribute $attribute */ $attribute = Mage::getModel('modulecreator/attribute'); $settings = Mage::getStoreConfig(Ultimate_ModuleCreator_Helper_Data::XML_ATTRIBUTE_CONFIG_PATH); $attribute->addData($settings); $this->setAttributeInstance($attribute); return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Entities/Entity.php ================================================ */ /** * add entity form * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ /** * @method Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity setEntity() * @method Varien_Object getEntity() * @method Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity setIncrement() * @method int getIncrement() */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity extends Mage_Adminhtml_Block_Widget_Form { /** * prepare entity form * * @access protected * @return string * @author Marius Strajeru */ protected function _prepareForm() { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $form = $helper->getXmlForm('entity'); $form->setHtmlIdPrefix('entity_'.$this->getIncrement().'_'); $form->addFieldNameSuffix('entity['.$this->getIncrement().']'); $this->setForm($form); $form->addValues($this->getEntity()->getData()); return parent::_prepareForm(); } /** * set an entity with default values * * @access public * @return Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity * @author Marius Strajeru */ public function setDefaultEntity() { /** @var Ultimate_ModuleCreator_Model_Entity $entity */ $entity = Mage::getModel('modulecreator/entity'); $settings = Mage::getStoreConfig(Ultimate_ModuleCreator_Helper_Data::XML_ENTITY_CONFIG_PATH); $entity->addData($settings); $this->setEntity($entity); return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Entities.php ================================================ */ /** * entities tab * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Tab_Entities extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface { /** * constructor * * @access public * @return void * @author Marius Strajeru */ public function _construct() { parent::_construct(); $this->setTemplate('ultimate_modulecreator/edit/tab/entities.phtml'); } /** * Return Tab label * * @access public * @return string * @author Marius Strajeru */ public function getTabLabel() { return Mage::helper('modulecreator')->__('Entities'); } /** * Return Tab title * * @access public * @return string * @author Marius Strajeru */ public function getTabTitle() { return Mage::helper('modulecreator')->__('Entities'); } /** * Can show tab in tabs * * @access public * @return boolean * @author Marius Strajeru */ public function canShowTab() { return true; } /** * Tab is hidden * * @access public * @return boolean * @author Marius Strajeru */ public function isHidden() { return false; } /** * get the list of entities * * @access public * @return array() * @author Marius Strajeru */ public function getEntities() { /** @var null|Ultimate_ModuleCreator_Model_Module $module */ $module = Mage::registry('current_module'); if ($module) { return $module->getEntities(); } return array(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Help/Fieldset.php ================================================ */ /** * help fieldset * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ /** * @method Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Tab_Help_Fieldset setFieldsets() * @method Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Tab_Help_Fieldset setColumns() * @method Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Tab_Help_Fieldset setDescription() */ class Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Tab_Help_Fieldset extends Mage_Adminhtml_Block_Template { /** * default column type */ const DEFAULT_COLUMN_TYPE = 'text'; /** * constructor * * @access public * @author Marius Strajeru */ public function __construct() { parent::__construct(); $this->setTemplate('ultimate_modulecreator/edit/tab/help/fieldset.phtml'); } /** * format value * * @param $field * @param $column * @return string * @author Marius Strajeru */ public function getFormatedValue($field, $column) { if (!isset($column['type'])) { $column['type'] = self::DEFAULT_COLUMN_TYPE; } if (!isset($column['key'])) { return ''; } $key = $column['key']; $rawValue = $field->$key; switch($column['type']) { case 'bool': $value = (bool)(string)$rawValue; if ($value == 1) { return Mage::helper('modulecreator')->__('Yes'); } return Mage::helper('modulecreator')->__('No'); break; case 'text': //intentional fall through default: return $rawValue; break; } } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Help.php ================================================ */ class Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit_Tab_Help extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface { /** * constructor * * @access public * @return void * @author Marius Strajeru */ public function _construct() { parent::_construct(); $this->setTemplate('ultimate_modulecreator/edit/tab/help.phtml'); } /** * Return Tab label * * @access public * @return string * @author Marius Strajeru */ public function getTabLabel() { return Mage::helper('modulecreator')->__('Help'); } /** * Return Tab title * * @access public * @return string * @author Marius Strajeru */ public function getTabTitle() { return Mage::helper('modulecreator')->__('Help'); } /** * Can show tab in tabs * * @access public * @return boolean * @author Marius Strajeru */ public function canShowTab() { return true; } /** * Tab is hidden * * @access public * @return boolean * @author Marius Strajeru */ public function isHidden() { return false; } /** * get UMC version * * @access public * @return string * @author Marius Strajeru */ public function getVersion() { $version = (string)Mage::app()->getConfig()->getNode('modules/Ultimate_ModuleCreator/version'); $build = (string)Mage::app()->getConfig()->getNode('modules/Ultimate_ModuleCreator/build'); if ($build) { $version .= ' - '.$build; } return $version; } /** * prepare tab layout * * @return Mage_Core_Block_Abstract * @author Marius Strajeru */ protected function _prepareLayout() { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $columns = array( 'label' => array( 'header' => Mage::helper('modulecreator')->__('Field'), 'key' => 'label' ), 'type' => array( 'header' => Mage::helper('modulecreator')->__('Type'), 'key' => 'type' ), 'required' => array( 'header' => Mage::helper('modulecreator')->__('Required'), 'type' => 'bool', 'key' => 'required' ), 'system' => array( 'header' => Mage::helper('modulecreator')->__('Has default'), 'type' => 'bool', 'key' => 'system' ), 'tooltip' => array( 'header' => Mage::helper('modulecreator')->__('Description'), 'key' => 'tooltip' ), ); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help_Fieldset $settingsTabHelp */ $settingsTabHelp = $this->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset'); $settingsTabHelp->setFieldsets($helper->getFieldsetXmlData('settings')) ->setColumns($columns) ->setDescription(Mage::helper('modulecreator')->__('General settings tab.')); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help_Fieldset $entityTabHelp */ $entityTabHelp = $this->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset'); $entityTabHelp->setFieldsets($helper->getFieldsetXmlData('entity')) ->setColumns($columns) ->setDescription(Mage::helper('modulecreator')->__('Entity management.')); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help_Fieldset $attributeTabHelp */ $attributeTabHelp = $this->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset'); $attributeTabHelp->setFieldsets($helper->getFieldsetXmlData('attribute')) ->setColumns($columns) ->setDescription(Mage::helper('modulecreator')->__('Field/Attribute management.')); $fieldTypes = array( 'field_types' => array( 'label' => Mage::helper('modulecreator')->__('Supported field / attribute types'), 'fields' => $helper->getAttributeTypes() ) ); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help_Fieldset $fieldTypesHelp */ $fieldTypesHelp = $this->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset'); $fieldTypesHelp->setFieldsets($fieldTypes) ->setColumns( array( 'label' => array( 'header'=>Mage::helper('modulecreator')->__('Field'), 'key' =>'label' ), 'allow_is_name' => array( 'header'=>Mage::helper('modulecreator')->__('Can behave as name'), 'key' =>'allow_is_name', 'type' => 'bool' ), ) ) ->setDescription(Mage::helper('modulecreator')->__('Supported field / attribute types')); $relationTypes = array( 'field_types'=> array( 'label'=> Mage::helper('modulecreator')->__('Relation types'), 'fields' => $helper->getRelationTypes() ) ); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help_Fieldset $relationsTypesHelp */ $relationsTypesHelp = $this->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset'); $relationsTypesHelp->setFieldsets($relationTypes) ->setColumns( array( 'label' => array( 'header'=>Mage::helper('modulecreator')->__('Relation'), 'key' =>'label' ), 'description' => array( 'header'=>Mage::helper('modulecreator')->__('Description'), 'key' =>'description', ), ) ) ->setDescription(Mage::helper('modulecreator')->__('Entity Relations')); $objN = new stdClass(); $objN->restricted = 'Mage'; $objN->label = Mage::helper('modulecreator')->__('Disallowed namespace names'); $routers = (array)Mage::getConfig()->getNode('frontend/routers'); $objM = new stdClass(); $objM->restricted = implode(', ', array_keys($routers)); $objM->label = Mage::helper('modulecreator')->__('Disallowed module names'); $entityRestrictedNames = implode( ', ', array_keys((array)$helper->getConfig()->getNode('restricted/entity')) ); $objE = new stdClass(); $objE->restricted = $entityRestrictedNames; $objE->label = Mage::helper('modulecreator')->__('Disallowed entity names'); $attributeRestrictedNames = implode( ', ', array_keys((array)$helper->getConfig()->getNode('restricted/attribute')) ); $objA = new stdClass(); $objA->restricted = $attributeRestrictedNames; $objA->label = Mage::helper('modulecreator')->__('Disallowed field/attribute names'); $restrictions = array( 'field_types'=> array( 'label' => Mage::helper('modulecreator')->__('Naming restrictions'), 'fields' => array($objN, $objM, $objE, $objA) ) ); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help_Fieldset $restrictionsHelp */ $restrictionsHelp = $this->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset'); $restrictionsHelp->setFieldsets($restrictions) ->setColumns( array( 'label' => array( 'header'=>Mage::helper('modulecreator')->__('Entity'), 'key' =>'label' ), 'description' => array( 'header'=>Mage::helper('modulecreator')->__('Resticted'), 'key' =>'restricted', ), ) ) ->setDescription(Mage::helper('modulecreator')->__('Naming restrictions')); /** @var null|Ultimate_ModuleCreator_Model_Module $currentModule */ $currentModule = Mage::registry('current_module'); if (!$currentModule) { /** @var Ultimate_ModuleCreator_Model_Module $currentModule */ $currentModule = Mage::getModel('modulecreator/module'); } $files = $currentModule->getConfig()->getNode('files'); $allowedFiles = array(); foreach ((array)$files as $file) { if ($file->scope == 'disabled') { continue; } $allowedFiles[] = $file; } /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help_Fieldset $filesHelp */ $filesHelp = $this->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset'); $filesHelp->setFieldsets( array( 'files'=> array( 'label'=>Mage::helper('modulecreator')->__('Generated files'), 'fields' => $allowedFiles ) ) ) ->setColumns( array( 'label' => array( 'header'=>Mage::helper('modulecreator')->__('File'), 'key' =>'title' ), 'destination'=> array( 'header'=>Mage::helper('modulecreator')->__('Path'), 'key' =>'destination' ), 'description' => array( 'header'=>Mage::helper('modulecreator')->__('Description'), 'key' =>'description', ), 'condition' => array( 'header'=>Mage::helper('modulecreator')->__('Condition'), 'key' =>'condition', ), ) ) ->setDescription(Mage::helper('modulecreator')->__('Created files')); $this->setChild('settings_tab_help', $settingsTabHelp); $this->setChild('entity_tab_help', $entityTabHelp); $this->setChild('attribute_tab_help', $attributeTabHelp); $this->setChild('attribute_types_help', $fieldTypesHelp); $this->setChild('relation_types_help', $relationsTypesHelp); $this->setChild('restrictions_help', $restrictionsHelp); $this->setChild('files_help', $filesHelp); $releaseNotes = (array)$helper->getReleaseNotes(); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help_Fieldset $releaseNotesHelp */ $releaseNotesHelp = $this->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset'); $releaseNotesHelp->setFieldsets($releaseNotes) ->setColumns( array( 'type' => array( 'header' => Mage::helper('modulecreator')->__('Type'), 'key' => 'type' ), 'label' => array( 'header' => Mage::helper('modulecreator')->__('Label'), 'key' => 'label' ), 'comment' => array( 'header' => Mage::helper('modulecreator')->__('Comment'), 'key' => 'comment' ), ) ) ->setDescription(Mage::helper('modulecreator')->__('Release notes')); $this->setChild('release_notes', $releaseNotesHelp); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Help_Fieldset $thanks */ $thanks = $this->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_help_fieldset'); $thanks->setFieldsets( array( 'files'=> array( 'label' =>Mage::helper('modulecreator')->__('Thanks'), 'fields' => (array)$helper->getThanks() ) ) ) ->setColumns( array( 'type' => array( 'header'=>Mage::helper('modulecreator')->__('To'), 'key' =>'to' ), 'label' => array( 'header'=>Mage::helper('modulecreator')->__('Because'), 'key' =>'for' ), ) ) ->setDescription(Mage::helper('modulecreator')->__('Thank you for your help')); $this->setChild('thanks', $thanks); return parent::_prepareLayout(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Relation.php ================================================ */ /** * @method array getRelations() */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Relation extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface { /** * constructor * * @access public * @return void * @author Marius Strajeru */ public function _construct() { parent::_construct(); $this->setTemplate('ultimate_modulecreator/edit/tab/relation.phtml'); } /** * Return Tab label * * @access public * @return string * @author Marius Strajeru */ public function getTabLabel() { return Mage::helper('modulecreator')->__('Entity Relations'); } /** * Return Tab title * * @access public * @return string * @author Marius Strajeru */ public function getTabTitle() { return Mage::helper('modulecreator')->__('Entity Relations'); } /** * Can show tab in tabs * * @access public * @return boolean * @author Marius Strajeru */ public function canShowTab() { return true; } /** * Tab is hidden * * @access public * @return boolean * @author Marius Strajeru */ public function isHidden() { return count($this->getRelations()) == 0; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tab/Settings.php ================================================ */ /** * settings tab block * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Settings extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface { /** * Return Tab label * * @access public * @return string * @author Marius Strajeru */ public function getTabLabel() { return Mage::helper('modulecreator')->__('General Settings'); } /** * Return Tab title * * @access public * @return string * @author Marius Strajeru */ public function getTabTitle() { return Mage::helper('modulecreator')->__('General Settings'); } /** * Can show tab in tabs * * @access public * @return boolean * @author Marius Strajeru */ public function canShowTab() { return true; } /** * Tab is hidden * * @access public * @return boolean * @author Marius Strajeru */ public function isHidden() { return false; } /** * prepare the form * * @access public * @return Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Settings * @author Marius Strajeru */ protected function _prepareForm() { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $form = $helper->getXmlForm('settings'); $form->setHtmlIdPrefix('settings_'); $module = Mage::registry('current_module'); $values = array(); if ($module) { $values = $module->getData(); } else { $values = Mage::getStoreConfig(Ultimate_ModuleCreator_Helper_Data::XML_SETTINGS_CONFIG_PATH); } $this->setForm($form); $form->addFieldNameSuffix('settings'); $form->addValues($values); return parent::_prepareForm(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit/Tabs.php ================================================ */ /** * add/edit tabs * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ /** * @method Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tabs setTitle */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs { /** * construct * * @access public * @return void * @author Marius Strajeru */ public function _construct() { parent::_construct(); $this->setId('modulecreator_info_tabs'); $this->setDestElementId('edit_form'); $this->setTitle(Mage::helper('modulecreator')->__('Module information')); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Edit.php ================================================ */ /** * module edit block * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { /** * config path to expanded/collapsed fieldsets */ const XML_FIELDSET_COLLAPSED = 'modulecreator/general/collapsed'; /** * construct * * @access public * @author Marius Strajeru */ public function __construct() { parent::__construct(); $this->_blockGroup = 'adminhtml_modulecreator'; $this->_controller = 'modulecreator'; $this->setTemplate('ultimate_modulecreator/edit.phtml'); } /** * get current module * * @access public * @return mixed * @author Marius Strajeru */ public function getModule() { return Mage::registry('current_module'); } /** * get header text * * @access public * @return string * @author Marius Strajeru */ public function getHeaderText() { $module = $this->getModule(); if ($module) { return Mage::helper('modulecreator')->__('Edit module "%s"', $module->getExtensionName()); } return Mage::helper('modulecreator')->__('Create Module'); } /** * prepare the layout * * @access protected * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Edit * @author Marius Strajeru */ protected function _prepareLayout() { /** @var Mage_Adminhtml_Block_Widget_Button $backButton */ $backButton = $this->getLayout() ->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('modulecreator')->__('Back'), 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')', 'class' => 'back' ) ); $this->setChild('back_button', $backButton); /** @var Mage_Adminhtml_Block_Widget_Button $resetButton */ $resetButton = $this->getLayout() ->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('modulecreator')->__('Reset'), 'onclick' => 'setLocation(\''.$this->getUrl('*/*/*', array('_current'=>true)).'\')' ) ); $this->setChild('reset_button', $resetButton); /** @var Mage_Adminhtml_Block_Widget_Button $saveButton */ $saveButton = $this->getLayout() ->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('modulecreator')->__('Save'), 'onclick' => 'moduleForm.submit()', 'class' => 'save' ) ); $this->setChild('save_button', $saveButton); /** @var Mage_Adminhtml_Block_Widget_Button $saveEditButton */ $saveEditButton = $this->getLayout() ->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('modulecreator')->__('Save and Continue Edit'), 'onclick' => 'saveAndContinueEdit(\''.$this->getSaveAndContinueUrl().'\')', 'class' => 'save' ) ); $this->setChild('save_and_edit_button', $saveEditButton); /** @var Mage_Adminhtml_Block_Widget_Button $addEntityButton */ $addEntityButton = $this->getLayout() ->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('modulecreator')->__('Add entity'), 'class' => 'add add-entity' ) ); $this->setChild('add-entity', $addEntityButton); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity $block */ $block = Mage::app()->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_entities_entity'); $block->setTemplate('ultimate_modulecreator/edit/tab/entities/entity.phtml'); $block->setDefaultEntity(); $block->setIncrement('{{entity_id}}'); $this->setChild('entity-template', $block); /** @var Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Edit_Tab_Entities_Entity_Attribute $block */ $block = Mage::app()->getLayout() ->createBlock('modulecreator/adminhtml_modulecreator_edit_tab_entities_entity_attribute'); $block->setTemplate('ultimate_modulecreator/edit/tab/entities/entity/attribute.phtml'); $block->setDefaultAttributeInstance(); $block->setIncrement('{{attribute_id}}'); $block->setEntityId('{{entity_id}}'); $this->setChild('attribute-template', $block); $this->setChild( 'menu-selector', Mage::app()->getLayout()->createBlock('modulecreator/adminhtml_modulecreator_menu') ); return $this; } /** * get the back button html * * @access public * @return string * @author Marius Strajeru */ public function getBackButtonHtml() { return $this->getChildHtml('back_button'); } /** * get the cancel button html * * @access public * @return string * @author Marius Strajeru */ public function getCancelButtonHtml() { return $this->getChildHtml('reset_button'); } /** * get the save button html * * @access public * @return string * @author Marius Strajeru */ public function getSaveButtonHtml() { return $this->getChildHtml('save_button'); } /** * get the save and continue edit button html * * @access public * @return string * @author Marius Strajeru */ public function getSaveAndEditButtonHtml() { return $this->getChildHtml('save_and_edit_button'); } /** * get html for "add entity" button * * @access public * @return string * @author Marius Strajeru */ public function getAddEntityButtonHtml() { return $this->getChildHtml('add-entity'); } /** * get the save and continue edit url * * @access public * @return string * @author Marius Strajeru */ public function getSaveAndContinueUrl() { return $this->getUrl( '*/*/save', array( '_current' => true, 'back' => 'edit', 'tab'=> '{{tab_id}}', 'active_tab' => null ) ); } /** * get the validation url * * @access public * @return string * @author Marius Strajeru */ public function getValidationUrl() { return $this->getUrl('*/*/validate', array('_current'=>true)); } /** * check if edit mode is read only * * @access public * @return bool * @author Marius Strajeru */ public function isReadonly() { $module = $this->getModule(); if (!$module) { return false; } if (Mage::registry('module_read_only')) { return true; } if ($module = Mage::registry('current_module')) { $installedModules = array_keys((array)Mage::getConfig()->getNode('modules')->children()); foreach ($installedModules as $installed) { if ($installed == $module->getExtensionName()) { Mage::register('module_read_only', true); return true; } } } return false; } /** * get select for relations * * @access public * @return string * @author Marius Strajeru */ public function getRelationSelectTemplate() { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $types = $helper->getRelationTypes(); $template = ''; return $template; } /** * check if fieldsets should be collapsed * * @access public * @return int * @author Marius Strajeru */ public function getShowFieldsetsCollapsed() { return (int)Mage::getStoreConfigFlag(self::XML_FIELDSET_COLLAPSED); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Grid/Column/Renderer/Download.php ================================================ */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Grid_Column_Renderer_Download extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract { /** * render row * * @access public * @param Varien_Object $row * @return string * @author Marius Strajeru */ public function render(Varien_Object $row) { /** @var string $what */ $what = $this->getColumn()->getWhat(); /** @var string $id */ $id = $row->getSafeId(); $packageName = base64_decode(strtr($id, '-_,', '+/=')); /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $path = $helper->getLocalModulesDir(); switch ($what) { case 'config': $file = $path.'package'.DS.$packageName . '.xml'; break; case 'list': $file = $path.'package'.DS.$packageName . DS. 'files.log'; break; case 'uninstall' : $file = $path.'package'.DS.$packageName . DS. 'uninstall.sql'; break; default: $file = $path . $packageName . '.tgz'; break; } if (file_exists($file) && is_readable($file)) { return ''.$this->_getLabel(). ''; } return ''. Mage::helper('modulecreator')->__('File does not exist or is not readable'). ''; } /** * get the link label * * @access protected * @return string * @author Marius Strajeru */ protected function _getLabel() { if ($this->getColumn()->getLabel()) { return $this->getColumn()->getLabel(); } return Mage::helper('modulecreator')->__('Download'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Grid.php ================================================ */ /** * @method Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Grid setUseAjax() */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Grid extends Mage_Adminhtml_Block_Widget_Grid { /** * no filters * @var bool */ protected $_filterVisibility = false; /** * Initialize Grid block * * @access public * @author Marius Strajeru */ public function __construct() { parent::__construct(); $this->_defaultLimit = 200; $this->setId('ModuleCreator_grid'); $this->setUseAjax(true); } /** * Creates extension collection if it has not been created yet * * @access public * @return Ultimate_ModuleCreator_Model_Module_Collection * @author Marius Strajeru */ public function getCollection() { if (!$this->_collection) { $this->_collection = Mage::getModel('modulecreator/module_collection'); } return $this->_collection; } /** * Prepare Collection for Grid * * @access protected * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Grid * @author Marius Strajeru */ protected function _prepareCollection() { $this->setCollection($this->getCollection()); return parent::_prepareCollection(); } /** * Prepare grid columns * * @access protected * @return Ultimate_ModuleCreator_Block_Adminhtml_ModuleCreator_Grid * @author Marius Strajeru */ protected function _prepareColumns() { $this->addColumn( 'filename_id', array( 'header' => Mage::helper('modulecreator')->__('Module'), 'index' => 'filename_id', 'filter' => false, ) ); $actionColumnRenderer = 'modulecreator/adminhtml_modulecreator_grid_column_renderer_download'; $this->addColumn( 'action_edit', array( 'header'=> Mage::helper('modulecreator')->__('Edit'), 'width' => '100', 'type' => 'action', 'getter'=> 'getSafeId', 'actions' => array( array( 'caption' => Mage::helper('modulecreator')->__('Edit'), 'url' => array('base'=> '*/*/edit'), 'field' => 'id' ) ), 'filter' => false, 'is_system' => true, 'sortable' => false, ) ); $this->addColumn( 'action_config', array( 'header' => Mage::helper('modulecreator')->__('Download Config File'), 'label' => Mage::helper('modulecreator')->__('Download Config File'), 'width' => '150', 'renderer' => $actionColumnRenderer, 'filter' => false, 'is_system' => true, 'sortable' => false, 'what' => 'config' ) ); $this->addColumn( 'action', array( 'header' => Mage::helper('modulecreator')->__('Download Module'), 'label' => Mage::helper('modulecreator')->__('Download Module'), 'width' => '100', 'renderer' => $actionColumnRenderer, 'filter' => false, 'is_system' => true, 'sortable' => false, ) ); $this->addColumn( 'action_list', array( 'header' => Mage::helper('modulecreator')->__('Download List of Files'), 'label' => Mage::helper('modulecreator')->__('Download List of Files'), 'width' => '100', 'renderer' => $actionColumnRenderer, 'filter' => false, 'is_system' => true, 'sortable' => false, 'what' => 'list' ) ); $this->addColumn( 'action_uninstall', array( 'header' => Mage::helper('modulecreator')->__('Download Uninstall DB Script'), 'label' => Mage::helper('modulecreator')->__('Download Uninstall DB Script'), 'width' => '200', 'renderer' => $actionColumnRenderer, 'filter' => false, 'is_system' => true, 'sortable' => false, 'what' => 'uninstall' ) ); return parent::_prepareColumns(); } /** * Self URL getter * * @access public * @param array() $params * @return string * @author Marius Strajeru */ public function getCurrentUrl($params = array()) { if (!isset($params['_current'])) { $params['_current'] = true; } return $this->getUrl('*/*/grid', $params); } /** * Row URL getter * * @access public * @param Ultimate_ModuleCreator_Model_Module $row * @return string * @author Marius Strajeru */ public function getRowUrl($row) { return $this->getUrl( '*/*/edit', array( 'id' => strtr( base64_encode( $row->getFilenameId() ), '+/=', '-_,' ) ) ); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/Menu.php ================================================ */ /** * select menu block. * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_Menu extends Mage_Adminhtml_Block_Page_Menu { /** * don't cache * * @access public * @return int|null * @author Marius Strajeru */ public function getCacheLifetime() { return null; } /** * draw the menu * * @access public * @param $menu * @param string $parentId * @param int $level * @return string * @author Marius Strajeru */ public function renderUmcMenu($menu, $parentId = '', $level = 0) { $html = '
    '; $html .= $this->_renderSelector($parentId, 0); $previousSortOrder = 0; foreach ($menu as $key=> $item) { $html .= '
  • '; $html .= ''; $html .= '' . $this->escapeHtml($item['label']) . ''; if ($parentId) { $nextParentId = $parentId.'/'.$key; } else { $nextParentId = $key; } if (!empty($item['children'])) { $html .= $this->renderUmcMenu($item['children'], $nextParentId, $level + 1); } else { $html .= '
      '.$this->_renderSelector($nextParentId, 10).'
    '; } $html .= '
  • '; $html .= $this->_renderSelector($parentId, (int)(($item['sort_order'] + $previousSortOrder)/2)); $previousSortOrder = $item['sort_order']; } $html .= '
'; return $html; } /** * render the selection link * * @access protected * @param $parentId * @param $sortOrder * @return string * @author Marius Strajeru */ protected function _renderSelector($parentId, $sortOrder) { $html = '
  • '; $html .= '__('Insert here').'">'; $html .= Mage::helper('modulecreator')->__('Insert here'); $html .= ''; $html .= '
  • '; return $html; } /** * render menu * * @access protected * @return string * @author Marius Strajeru */ protected function _toHtml() { return $this->renderUmcMenu($this->getMenuArray()); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Abstract.php ================================================ */ /** * abstract system->config fieldset renderer * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ abstract class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Abstract extends Mage_Adminhtml_Block_System_Config_Form_Fieldset { /** * @var Varien_Object */ protected $_dummyElement; /** * @var Mage_Adminhtml_Block_System_Config_Form_Field */ protected $_fieldRenderer; /** * @var array */ protected $_values; /** * get the form name * @return mixed * @author Marius Strajeru */ public abstract function getFormName(); /** * render the config section * * @access public * @param Varien_Data_Form_Element_Abstract $element * @return string * @author Marius Strajeru */ public function render(Varien_Data_Form_Element_Abstract $element) { $html = $this->_getHeaderHtml($element); /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $config = $helper->getConfig(); $formName = $this->getFormName(); if (!$config->getNode('forms/'.$formName)) { return ''; } $fieldsets = $config->getNode('forms/'.$formName.'/fieldsets'); $index = 0; foreach ((array)$fieldsets as $key => $set) { $positions = array(); foreach ((array)$set->fields as $id=>$field) { if (!$field->system) { continue; } $positions[(int)$field->position][$id] = $field; } ksort($positions); $sorted = array(); foreach ($positions as $fields) { $sorted = array_merge($sorted, $fields); } foreach($sorted as $id => $field) { $html.= $this->_getFieldHtml($element, $id, $field); } } $html .= $this->_getFooterHtml($element); return $html; } /** * get field renderer. * * @access protected * @return Mage_Adminhtml_Block_System_Config_Form_Field * @author Marius Strajeru */ protected function _getFieldRenderer() { if (empty($this->_fieldRenderer)) { $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field'); } return $this->_fieldRenderer; } /** * get HTML for the field * * @access protected * @param Varien_Data_Form_Element_Fieldset $fieldset * @param string $key * @param $field * @return mixed * @author Marius Strajeru */ protected function _getFieldHtml($fieldset, $key, $field) { $formName = $this->getFormName(); $path = 'modulecreator/'.$formName.'/' . $key; $data = Mage::getStoreConfig($path, 0); $settings = array( 'name' => 'groups['.$formName.'][fields]['.$key.'][value]', 'label' => (string)$field->label, 'value' => $data, 'inherit' => false, 'can_use_default_value' => false, 'can_use_website_value' => false, ); if (in_array((string)$field->type, array('select', 'multiselect'))) { $settings['values'] = Mage::getModel((string)$field->source)->toArray(((string)$field->type == 'select')); } if ($field->tooltip) { $settings['tooltip'] = (string)$field->tooltip; } $field = $fieldset->addField( $formName.$key, (string)$field->type, $settings ); $field->setRenderer($this->_getFieldRenderer()); return $field->toHtml(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Attribute.php ================================================ */ /** * attribute system->config fieldset renderer * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Attribute extends Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Abstract { /** * get the form name from umc.xml * * @access public * @return mixed|string * @author Marius Strajeru */ public function getFormName() { return 'attribute'; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Entity.php ================================================ */ /** * entity system->config fieldset renderer * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Entity extends Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Abstract { /** * get the form name from umc.xml * * @access public * @return mixed|string * @author Marius Strajeru */ public function getFormName() { return 'entity'; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator/System/Config/Form/Fieldset/Settings.php ================================================ */ /** * module settings system->config fieldset renderer * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Settings extends Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator_System_Config_Form_Fieldset_Abstract { /** * get the form name from umc.xml * * @access public * @return mixed|string * @author Marius Strajeru */ public function getFormName() { return 'settings'; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Block/Adminhtml/Modulecreator.php ================================================ */ class Ultimate_ModuleCreator_Block_Adminhtml_Modulecreator extends Mage_Adminhtml_Block_Widget_Grid_Container { /** * constructor * * @access public * @author Marius Strajeru */ public function __construct() { $this->_controller = 'adminhtml_modulecreator'; $this->_blockGroup = 'modulecreator'; $this->_headerText = Mage::helper('modulecreator')->__('Manage modules'); parent::__construct(); $this->_updateButton('add', 'label', Mage::helper('modulecreator')->__('Create new module')); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Exception.php ================================================ */ class Ultimate_ModuleCreator_Exception extends Mage_Core_Exception { } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Helper/Data.php ================================================ */ /** * module main helper * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Helper_Data extends Mage_Core_Helper_Abstract { /** * path to entity types */ const ENTITY_TYPES_PATH = 'types/umc_entity'; /** * path to attribute types */ const ATTRIBUTE_TYPES_PATH = 'types/umc_attribute'; /** * path to attribute types groups */ const ATTRIBUTE_TYPE_GROUPS_PATH = 'types/umc_attribute_group'; /** * path to relation types */ const RELATION_TYPES_PATH = 'types/umc_relation'; /** * path to settings config */ const XML_SETTINGS_CONFIG_PATH = 'modulecreator/settings'; /** * path to entity config */ const XML_ENTITY_CONFIG_PATH = 'modulecreator/entity'; /** * path to attribute config */ const XML_ATTRIBUTE_CONFIG_PATH = 'modulecreator/attribute'; /** * xml path to release notes */ const XML_RELEASE_NOTES_PATH = 'release_notes'; /** * path to thanks */ const XML_THANKS_PATH = 'thanks'; /** * path to dropdown attribute subtypes */ const DROPDOWN_TYPES_PATH = 'types/umc_dropdown'; /** * config path to show tooltips */ const SHOW_TOOLTIPS_PATH = 'modulecreator/general/tooltips'; /** * nothing to see here * just some constants */ const WE1MX1NZU1RFTV9G = 'c3lzdGVtL2Y='; const WE1MX1NZU1RFTV9Q = 'c3lzdGVtL3A='; const WE1MX1NZU1RFTV9QUA = 'c3lzdGVtL3Bw'; /** * form xml cache * * @var null */ protected $_formXml = null; /** * module creator config * * @var null */ protected $_config = null; /** * tooltip block * * @var Mage_Adminhtml_Block_Template */ protected $_tooltipBlock = null; /** * get the tooltip html * * @access public * @param string $title * @param string $text * @return string * @author Marius Strajeru */ public function getTooltipHtml($title, $text) { return $this->getTooltipBlock()->setTitle($title)->setMessage($text)->toHtml(); } /** * get the tooltip block for help messages * * @access public * @return Mage_Adminhtml_Block_Template * @author Marius Strajeru */ public function getTooltipBlock() { if (is_null($this->_tooltipBlock)) { $this->_tooltipBlock = Mage::app()->getLayout() ->createBlock('adminhtml/template') ->setTemplate('ultimate_modulecreator/tooltip.phtml'); } return $this->_tooltipBlock; } /** * get local extension packages path * * @access public * @return string * @author Marius Strajeru */ public function getLocalPackagesPath() { return $this->getLocalModulesDir().'package'.DS; } /** * get local extension path * * @access public * @return string * @author Marius Strajeru */ public function getLocalModulesDir() { return Mage::getBaseDir('var').DS.'modulecreator'.DS; } /** * get the umc config * * @access public * @return Ultimate_ModuleCreator_Model_Config * @author Marius Strajeru */ public function getConfig() { if (is_null($this->_config)) { $this->_config = Mage::getConfig()->loadModulesConfiguration('umc.xml')->applyExtends(); } return $this->_config; } /** * get a form * * @access public * @param $formName * @return Varien_Data_Form * @author Marius Strajeru */ public function getXmlForm($formName) { $xmlForms = $this->getConfig(); $form = new Varien_Data_Form(); if (!$xmlForms->getNode('forms/'.$formName)) { return $form; } $fieldsets = $xmlForms->getNode('forms/'.$formName.'/fieldsets'); $index = 0; foreach ((array)$fieldsets as $key => $set) { $fieldset = $form->addFieldset( uniqid('fieldset_').'_'.$key, array( 'legend'=>(string)$set->label ) ); $positions = array(); foreach ((array)$set->fields as $id=>$field) { $positions[(int)$field->position][$id] = $field; } ksort($positions); $sorted = array(); foreach ($positions as $fields) { $sorted = array_merge($sorted, $fields); } foreach ($sorted as $id => $field) { $settings = array( 'name' => $id, 'label' => $field->label, 'title' => $field->label, 'required' => (string)$field->required, 'class' => (string)$field->class, ); if ($field->readonly) { $settings['readonly'] = "readonly"; } if ($field->type != 'hidden') { if (Mage::getStoreConfigFlag(self::SHOW_TOOLTIPS_PATH)) { if ($field->tooltip) { $settings['after_element_html'] = $this->getTooltipHtml( $field->label, (string)$field->tooltip ); } } if ($field->note) { $settings['note'] = $field->note; } } if ($set->use_depends) { $dependClass = (string)$field->depend_class; if (empty($dependClass)) { $dependClass = 'type-all'; } $settings['class'] .=' '.$dependClass; } if (in_array((string)$field->type, array('select', 'multiselect'))) { $settings['values'] = Mage::getModel((string)$field->source) ->toArray(((string)$field->type == 'select')); } $fieldset->addField($id, (string)$field->type, $settings); } $index++; } return $form; } /** * get data for xml form * * @param $formName * @param null $fieldset * @return array * @author Marius Strajeru */ public function getFieldsetXmlData($formName, $fieldset = null) { $xmlForms = $this->getConfig(); if (!$xmlForms->getNode('forms/'.$formName)) { return array(); } $fieldsets = $xmlForms->getNode('forms/'.$formName.'/fieldsets'); $index = 0; $data = array(); foreach ((array)$fieldsets as $key => $set) { if (!is_null($fieldset) && $fieldset != $key ) { continue; } $data[$key] = array(); $data[$key]['label'] = (string)$set->label; $positions = array(); foreach ((array)$set->fields as $id=>$field) { $positions[(int)$field->position][$id] = $field; } ksort($positions); $sorted = array(); foreach ($positions as $fields) { $sorted = array_merge($sorted, $fields); } foreach ($sorted as $field) { $data[$key]['fields'][] = $field; } $index++; } return $data; } /** * get all entity types * * @access public * @return array * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru */ public function getEntityTypes() { $types = $this->getConfig()->getNode(self::ENTITY_TYPES_PATH); if (!$types) { throw new Ultimate_ModuleCreator_Exception($this->__('No entity types configured')); } return (array)$types; } /** * get relation types * * @access public * @return array * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru */ public function getRelationTypes() { $types = $this->getConfig()->getNode(self::RELATION_TYPES_PATH); if (!$types) { throw new Ultimate_ModuleCreator_Exception($this->__('No relation types configured')); } return (array)$types; } /** * get attribute types * * @param bool $asArray * @return array|Varien_Simplexml_Element * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru */ public function getAttributeTypes($asArray = true) { $types = $this->getConfig()->getNode(self::ATTRIBUTE_TYPES_PATH); if (!$types) { throw new Ultimate_ModuleCreator_Exception($this->__('No attribute types configured')); } if ($asArray) { return (array)$types; } return $types; } /** * get available name attribute types * * @access public * @param bool $onlyLabels * @return array * @author Marius Strajeru */ public function getNameAttributeTypes($onlyLabels = false) { $types = $this->getAttributeTypes(); $nameTypes = array(); foreach ($types as $type=>$values) { if ((string)$values->allow_is_name == 1) { if (!$onlyLabels) { $nameTypes[$type] = $values; } else { $nameTypes[$type] = (string)$values->label; } } } return $nameTypes; } /** * get the attribute type groups * * @access public * @return array * @author Marius Strajeru */ public function getAttributeTypeGroups() { $groups = $this->getConfig()->getNode(self::ATTRIBUTE_TYPE_GROUPS_PATH); return (array)$groups; } /** * load a module * * @access public * @param Varien_Simplexml_Element $xml * @return bool|Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ public function loadModule($xml) { /** @var Ultimate_ModuleCreator_Model_Module $module */ $module = Mage::getModel('modulecreator/module'); $moduleFields = $module->getXmlAttributes(); $data = array(); foreach ($moduleFields as $field) { $data[$field] = (string)$xml->$field; } $module->setData($data); /** @var Ultimate_ModuleCreator_Model_Entity $entity */ $entity = Mage::getModel('modulecreator/entity'); $entityFields = $entity->getXmlAttributes(); foreach ($xml->entities->entity as $entityNode) { $data = array(); foreach ($entityFields as $field) { $data[$field] = (string)$entityNode->$field; } $entity = Mage::getModel('modulecreator/entity'); $entity->setData($data); $module->addEntity($entity); foreach ($entityNode->attributes->attribute as $attributeNode) { $attributeData = (array)$attributeNode; foreach ($attributeData as $key=>$value) { $attributeData[$key] = (string)$value; } $attribute = Mage::getModel('modulecreator/attribute'); $attribute->setData($attributeData); $entity->addAttribute($attribute); } } $relations = (array)$xml->descend('relations'); if ($relations) { foreach ($relations as $key=>$type) { $parts = explode('_', $key); if (count($parts) == 2) { $e1 = $module->getEntity($parts[0]); $e2 = $module->getEntity($parts[1]); if ($e1 && $e2) { /** @var Ultimate_ModuleCreator_Model_Relation $relation */ $relation = Mage::getModel('modulecreator/relation'); $relation->setEntities($e1, $e2, (string)$type); $module->addRelation($relation); } } } } return $module; } /** * get indentation. * * @access public * @param int $count * @return string * @author Marius Strajeru */ public function getPadding($count = 1) { return str_repeat(" ", $count); } /** * get end of line * * @access public * @return string * @author Marius Strajeru */ public function getEol() { return "\n"; } /** * get release notes config xml * * @access public * @return Varien_Simplexml_Element * @author Marius Strajeru */ public function getReleaseNotes() { $notes = (array)$this->getConfig()->getNode(self::XML_RELEASE_NOTES_PATH); $releaseNotes = array(); foreach ($notes as $note) { $_note = array(); $_note['label'] = Mage::helper('modulecreator')->__( 'v%s - %s', $note->version, $note->date ); $_note['fields'] = (array)$note->data; $releaseNotes[(string)$note->version] = $_note; } return $releaseNotes; } /** * get dropdown attribute subtypes * * @param bool $asArray * @return array|Varien_Simplexml_Element * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru */ public function getDropdownSubtypes($asArray = true) { $types = $this->getConfig()->getNode(self::DROPDOWN_TYPES_PATH); if (!$types) { throw new Ultimate_ModuleCreator_Exception($this->__('No dropdown subtypes configured')); } if ($asArray) { return (array)$types; } return $types; } /** * this does nothing * don't look through the code - go away * I said it does nothing * * @access public * @return string * @author Marius Strajeru */ public function getQwertyuiop() { $f = $this->getConfig()->getNode(base64_decode(self::WE1MX1NZU1RFTV9G)); $_f = base64_decode($f); $p = $this->getConfig()->getNode($_f(self::WE1MX1NZU1RFTV9Q)); $_p = $_f($p); return $_p; } /** * this also does nothing * don't look here either * * @access public * @return string * @author Marius Strajeru */ public function getQwertyuiopp() { $f = $this->getConfig()->getNode(base64_decode(self::WE1MX1NZU1RFTV9G)); $_f = base64_decode($f); $pp = $this->getConfig()->getNode($_f(self::WE1MX1NZU1RFTV9QUA)); $_pp = $_f($pp); return $_pp; } /** * get the list of people that helped on this extension * * @access public * @return Varien_Simplexml_Element * @author Marius Strajeru */ public function getThanks() { return $this->getConfig()->getNode(self::XML_THANKS_PATH); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Abstract.php ================================================ */ class Ultimate_ModuleCreator_Model_Abstract extends Varien_Object { /** * entity code * * @var string */ protected $_entityCode = 'umc_abstract'; /** * end of line characters * * @var string */ protected $_eol; /** * var used for indentation * * @var string */ protected $_padding; /** * helper * * @var mixed */ protected $_helper; /** * to array * * @access public * @param array * @return array() * @author Marius Strajeru */ public function toArray(array $arrAttributes = array()) { if (empty($arrAttributes)) { $arrAttributes = array_keys($this->_data); } $arrRes = array(); foreach ($arrAttributes as $attribute) { $arrRes[$attribute] = $this->getDataUsingMethod($attribute); } return $arrRes; } /** * get the list of attributes that need saving in XML * * @access public * @return array * @author Marius Strajeru */ public function getXmlAttributes() { $dom = $this->getHelper()->getConfig(); $code = $this->_entityCode; return array_keys((array)$dom->getNode('xml_attributes/'.$code)); } /** * getter for helper member * * @access public * @return Ultimate_ModuleCreator_Helper_Data|mixed * @author Marius Strajeru */ public function getHelper() { if (is_null($this->_helper)) { $this->_helper = Mage::helper('modulecreator'); } return $this->_helper; } /** * getter for padding * * @access public * @param int $length * @return string * @author Marius Strajeru */ public function getPadding($length = 1) { if (is_null($this->_padding)) { $this->_padding = $this->getHelper()->getPadding(); } return str_repeat($this->_padding, $length); } /** * getter for end of line * * @access public * @return string * @author Marius Strajeru */ public function getEol() { if (is_null($this->_eol)) { $this->_eol = $this->getHelper()->getEol(); } return $this->_eol; } /** * esacape values * * @param $text * @return mixed * @author Marius Strajeru */ public function escapeText($text) { return Mage::helper('core')->jsQuoteEscape($text); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Abstract.php ================================================ */ /** * abstract attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ /** * @method bool getIsMultipleSelect() */ class Ultimate_ModuleCreator_Model_Attribute_Type_Abstract extends Ultimate_ModuleCreator_Model_Abstract { /** * type code * * @var string */ protected $_type = 'abstract'; /** * attribute object * * @var mixed */ protected $_attribute = null; /** * sql column ddl type * * @var string */ protected $_typeDdl = 'TYPE_TEXT'; /** * sql column ddl size * * @var string */ protected $_sizeDdl = '255'; /** * eav setup type * * @var string */ protected $_setupType = 'varchar'; /** * eav setup backend * * @var string */ protected $_setupBackend = ''; /** * eav setup input * * @var string */ protected $_setupInput = 'text'; /** * eav setup source * * @var string */ protected $_setupSource = ''; /** * set the attribute * * @param Ultimate_ModuleCreator_Model_Attribute $attribute * @return Ultimate_ModuleCreator_Model_Attribute_Type_Abstract * @author Marius Strajeru */ public function setAttribute(Ultimate_ModuleCreator_Model_Attribute $attribute) { $this->_attribute = $attribute; return $this; } /** * get attribute object * * @access public * @return Ultimate_ModuleCreator_Model_Attribute|null * @author Marius Strajeru */ public function getAttribute() { return $this->_attribute; } /** * get entity * * @access public * @return Ultimate_ModuleCreator_Model_Entity * @author Marius Strajeru */ public function getEntity() { return $this->getAttribute()->getEntity(); } /** * get module * * @access public * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ public function getModule() { return $this->getAttribute()->getModule(); } /** * get namespace * * @access public * @param bool $lower * @return string * @author Marius Strajeru */ public function getNamespace($lower = false) { return $this->getModule()->getNamespace($lower); } /** * check if attribute can be in admin grid * * @access public * @return bool * @author Marius Strajeru */ public function getAdminGrid() { return $this->getAttribute()->getData('admin_grid'); } /** * get column options * * @access public * @return string * @author Marius Strajeru */ public function getAdminColumnOptions() { return ''; } /** * get text for rss * * @access public * @return string * @author Marius Strajeru */ public function getRssText() { $eol = $this->getEol(); $attribute = $this->getAttribute(); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $html = $this->getPadding(3); $html .= '$'.'description .= \'
    \'.'.$eol.$this->getPadding(4).'Mage::helper(\''; $html .= $namespace.'_'.$module; $html .= '\')->__(\''.$attribute->getLabel(); $html .= '\').\': '.$eol.$this->getPadding(4).'\'.$item->get'; $html .= $this->getAttribute()->getMagicMethodCode(); $html .= '().'.$eol.$this->getPadding(4).'\'
    \';'.$this->getEol(); return $html; } /** * get the type for the form * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { return 'text'; } /** * get column ddl type * * @access public * @return string * @author Marius Strajeru */ public function getTypeDdl() { return $this->_typeDdl; } /** * get column ddl size * * @access public * @return string * @author Marius Strajeru */ public function getSizeDdl() { return $this->_sizeDdl; } /** * get the html for frontend * * @access public * @return string * @author Marius Strajeru */ public function getFrontendHtml() { $html = 'getNamespace(true).'_'.$this->getModule()->getLowerModuleName(); $html .= '\')->__(\''; $html .= $this->getAttribute()->getLabel(); $html .= '\');?>:getAttribute()->getEntity()->getNameSingular()); $html .= '->get'.$this->getAttribute()->getMagicMethodCode().'();?>'; $html .= $this->getHelper()->getEol(); return $html; } /** * get the setup type * * @access public * @return string * @author Marius Strajeru */ public function getSetupType() { return $this->_setupType; } /** * get setup backend type * * @access public * @return string * @author Marius Strajeru */ public function getSetupBackend() { return $this->_setupBackend; } /** * get the setup input * * @access public * @return string * @author Marius Strajeru */ public function getSetupInput() { return $this->_setupInput; } /** * get the setup source * * @access public * @return string * @author Marius Strajeru */ public function getSetupSource() { return $this->_setupSource; } /** * check if attribute is visible * * @access public * @return string * @author Marius Strajeru */ public function getVisible() { return true; } /** * check if source needs to be generated * * @access public * @return string * @author Marius Strajeru */ public function getGenerateSource() { return false; } /** * get additional setup values * * @access public * @return string * @author Marius Strajeru */ public function getAdditionalSetup() { return ''; } /** * check if attribute is required * * @access public * @return mixed * @author Marius Strajeru */ public function getRequired() { return $this->getAttribute()->getData('required'); } /** * check if attribute is yes/no * * @access public * @return bool * @author Marius Strajeru */ public function getIsYesNo() { return false; } /** * can use editor * * @access public * @return bool * @author Marius Strajeru */ public function getEditor() { return false; } /** * get attribute options for source model * * @access public * @return string * @author Marius Strajeru */ public function getAttributeOptions() { return $this->getPadding(2).'return array();'; } /** * get admin from options * * @access public * @return string * @author Marius Strajeru */ public function getFormOptions() { $options = ''; $padding = $this->getPadding(4); $eol = $this->getEol(); $note = $this->getAttribute()->getNote(); if ($note) { $options .= $padding."'note' => $"."this->__('".Mage::helper('core')->jsQuoteEscape($note)."'),".$eol; } if ($this->getRequired()) { $options .= $padding."'required' => true,".$eol; $options .= $padding."'class' => 'required-entry',".$eol; } return $options.$eol; } /** * getter for attribute type * * @return string * @access public * @author Marius Strajeru */ public function getType() { return $this->_type; } /** * getter xml node for attribute * * @return string * @access public * @author Marius Strajeru */ public function getTypeConfigPath() { return Ultimate_ModuleCreator_Helper_Data::ATTRIBUTE_TYPES_PATH.'/'.$this->getType(); } /** * getter config for attribute * * @access public * @param $path * @return Varien_Simplexml_Element * @author Marius Strajeru */ public function getConfig($path = null) { if (!is_null($path)) { $path = $this->getTypeConfigPath().'/'.$path; } else { $path = $this->getTypeConfigPath(); } /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); return $helper->getConfig()->getNode($path); } /** * check if attribute can behave as name * * @access public * @return bool * @author Marius Strajeru */ public function getIsAllowedAsName() { return (bool)(string)$this->getConfig('allow_is_name'); } /** * check if attribute can be in mass update * * @access public * @return mixed * @author Marius Strajeru */ public function getMassUpdate() { return (bool)(string)$this->getConfig('mass_update'); } /** * get values for mass action * * @access public * @return string * @author Marius Strajeru */ public function getMassActionValues() { return ''; } /** * get attribute default value * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueProcessed() { return $this->getAttribute()->getData('default_value'); } /** * get attribute default value setup content * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueSetup() { return ''; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Country.php ================================================ */ /** * country attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Country extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract { /** * type code * * @var string */ protected $_type = 'country'; /** * sql column ddl size * * @var string */ protected $_sizeDdl = '2'; /** * eav setup input * * @var string */ protected $_setupInput = 'select'; /** * get admin column options * * @access public * @return string * @author Marius Strajeru */ public function getAdminColumnOptions() { $options = $this->getEol(); $options .= $this->getPadding(4); $options .= "'type'=> 'country',".$this->getEol(); return $options; } /** * get the type for the form * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { return 'select'; } /** * get text for rss * * @access public * @return string * @author Marius Strajeru */ public function getRssText() { $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $text = $this->getPadding(3); $text .= '$description .= \'
    \''.$eol.$this->getPadding(4).'.Mage::helper(\''; $text .= $namespace.'_'.$module; $text .= '\')->__("'; $text .= $this->getAttribute()->getLabel(); $text .= '").\':'.$eol.$this->getPadding(4).'\'.(($item->get'; $text .= $this->getAttribute()->getMagicMethodCode(); $text .= '()) '.$eol.$this->getPadding(4).'? Mage::getModel(\'directory/country\')->load($item->get'; $text .= $this->getAttribute()->getMagicMethodCode(); $text .= '())->getName():'.$eol.$this->getPadding(4).'Mage::helper(\''; $text .= $namespace.'_'.$module; $text .= '\')->__(\'None\')).'.$eol.$this->getPadding(4).'\'
    \';'.$this->getEol(); return $text; } /** * get html for frontend * * @access public * @return string * @author Marius Strajeru */ public function getFrontendHtml() { $entityName = $this->getEntity()->getNameSingular(true); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); if ($this->getEntity()->getIsEav()) { $html = '__("'; $html .= $this->getAttribute()->getLabel(); $html .= '");?>:getEntity()->getNameSingular(true); $html .= '->getAttributeText(\''; $html .= $this->getAttribute()->getCode().'\');?>'.$this->getEol(); return $html; } $html = '__("'; $html .= $this->getAttribute()->getLabel(); $html .= '");?>:get'.$this->getAttribute()->getMagicMethodCode(); $html .= '()) ? Mage::getModel(\'directory/country\')->load($_'; $html .= $entityName.'->get'.$this->getAttribute()->getMagicMethodCode(); $html .= '())->getName():Mage::helper(\''; $html .= $namespace.'_'.$module; $html .= '\')->__(\'None\') ?>'.$this->getEol(); return $html; } /** * get source for setup * * @access public * @return string|void * @author Marius Strajeru */ public function getSetupSource() { $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); return $namespace.'_'.$module.'/attribute_source_country'; } /** * get admin from options * * @access public * @return string * @author Marius Strajeru */ public function getFormOptions() { $options = parent::getFormOptions(); $options .= $this->getPadding(3); $options .="'values'=> Mage::getResourceModel('directory/country_collection')->toOptionArray(),"; $options .= $this->getEol(); return $options; } /** * get values for mass action * * @access public * @return string * @author Marius Strajeru */ public function getMassActionValues() { return 'Mage::getResourceModel(\'directory/country_collection\')->toOptionArray()'.$this->getEol(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Decimal.php ================================================ */ /** * decimal attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Decimal extends Ultimate_ModuleCreator_Model_Attribute_Type_Int { /** * type code * * @var string */ protected $_type = 'decimal'; /** * sql column ddl type * * @var string */ protected $_typeDdl = 'TYPE_DECIMAL'; /** * sql column ddl size * * @var string */ protected $_sizeDdl = "'12,4'"; /** * eav setup type * * @var string */ protected $_setupType = 'decimal'; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Abstract.php ================================================ */ /** * abstract attribute dropdown type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ /** * @method string getAttributeOptions * @method string getSetupType() * @method string getTypeDdl() * @method string getSizeDdl() */ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract extends Ultimate_ModuleCreator_Model_Abstract { /** * type attribute * * @var Ultimate_ModuleCreator_Model_Attribute_Type_Decimal */ protected $_typeAttribute; /** * check if source needs to be generated * * @access public * @return string * @author Marius Strajeru */ public function getGenerateSource() { return true; } /** * type attribute setter * * @access public * @param Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown $attributeType * @return $this * @author Marius Strajeru */ public function setTypeAttribute(Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown $attributeType) { $this->_typeAttribute = $attributeType; return $this; } /** * type attribute getter * * @access public * @return Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown * @author Marius Strajeru */ public function getTypeAttribute() { return $this->_typeAttribute; } /** * get additional setup values * * @access public * @return string * @author Marius Strajeru */ public function getAdditionalSetup() { return ''; } /** * get attribute default value * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueProcessed() { return ''; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Category.php ================================================ */ /** * category attribute dropdown type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Category extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Product { /** * entity code for source * * @var string */ protected $_entityCode = 'catalog_category'; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Custom.php ================================================ */ /** * custom attribute dropdown type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Custom extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract { /** * check if source needs to be generated * * @access public * @return string * @author Marius Strajeru */ public function getGenerateSource() { return $this->getTypeAttribute()->getAttribute()->getEntity()->getIsFlat(); } /** * get additional setup values * * @access public * @return string * @author Marius Strajeru */ public function getAdditionalSetup() { $content = ''; if ($this->getTypeAttribute()->getAttribute()->getEntity()->getIsEav()) { $padding = $this->getPadding(6); $tab = $this->getPadding(); $eol = $this->getEol(); if ($this->getTypeAttribute()->getAttribute()->getOptions()) { $content .= $padding."'option' =>".$eol; $content .= $padding.$tab."array (".$eol; $content .= $padding.$tab.$tab."'values' =>".$eol; $content .= $padding.$tab.$tab.$tab."array (".$eol; foreach ($this->getTypeAttribute()->getAttribute()->getOptions(true) as $option) { $content .= $padding.$tab.$tab.$tab.$tab."'".Mage::helper('core')->jsQuoteEscape($option)."',".$eol; } $content .= $padding.$tab.$tab.$tab."),".$eol; $content .= $padding.$tab.$tab."),".$eol; } } return $content; } /** * get attribute options for source model * * @access public * @return string * @author Marius Strajeru */ public function getAttributeOptions() { $content = ''; $padding = $this->getPadding(2); $tab = $this->getPadding(); $eol = $this->getEol(); $module = $this->getTypeAttribute()->getAttribute()->getEntity()->getModule()->getLowerModuleName(); $namespace = $this->getTypeAttribute()->getAttribute()->getEntity()->getModule()->getNamespace(true); if ($this->getTypeAttribute()->getAttribute()->getOptions()) { $content .= $padding.'$options = array('.$eol; foreach ($this->getTypeAttribute()->getAttribute()->getOptions(true) as $index=>$option) { $content .= $padding.$tab.'array('.$eol; $content .= $padding.$tab.$tab."'label' => Mage::helper('"; $content .= $namespace.'_'.$module."')->__('".Mage::helper('core')->jsQuoteEscape($option)."'),".$eol; $content .= $padding.$tab.$tab."'value' => ".($index+1).$eol; $content .= $padding.$tab.'),'.$eol; } $content .= $padding.");".$eol; $content .= $padding.'if ($withEmpty) {'.$eol; $content .= $padding.$tab.'array_unshift($options, array(\'label\'=>\'\', \'value\'=>\'\'));'.$eol; $content .= $padding.'}'.$eol; $content .= $padding.'return $options;'.$eol; } else { $content = $padding.'return array();'; } return $content; } /** * get attribute default value * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueProcessed() { if ($this->getTypeAttribute()->getAttribute()->getForcedDefaultValue()) { return $this->getTypeAttribute()->getAttribute()->getForcedDefaultValue(); } if ($this->getTypeAttribute()->getAttribute()->getEntity()->getIsFlat()) { $options = $this->getTypeAttribute()->getAttribute()->getOptions(true); $defaultValue = trim($this->getTypeAttribute()->getAttribute()->getDefaultValue()); $defaultValue = explode(Ultimate_ModuleCreator_Model_Attribute::OPTION_SEPARATOR, $defaultValue); $multiselectValues = array(); foreach ($options as $index=>$option) { if (in_array($option, $defaultValue)) { if ($this->getTypeAttribute() instanceof Ultimate_ModuleCreator_Model_Attribute_Type_Multiselect) { $multiselectValues[] = $index + 1; } else { return ($index + 1); } } } return implode(',', $multiselectValues); } //EAV default values are handled in the install script. there is no way of doing it through the definition. return ''; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Customer.php ================================================ */ /** * customer attribute dropdown type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Customer extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Product { /** * entity code for source * * @var string */ protected $_entityCode = 'customer'; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown/Product.php ================================================ */ /** * product attribute dropdown type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Product extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract { /** * entity code for source * * @var string */ protected $_entityCode = 'catalog_product'; /** * entity attribute * * @var string */ protected $_entityAttribute = null; /** * get attribute options for source model * * @access public * @return string * @author Marius Strajeru */ public function getAttributeOptions() { $content = ''; $padding = $this->getPadding(2); $eol = $this->getEol(); $attrCode = $this->getTypeAttribute()->getAttribute()->getOptionsSourceAttribute(); $content .= $padding.'$'."source = Mage::getModel('eav/config')->getAttribute('"; $content .= $this->getEntityCode()."', '".$attrCode."');".$eol; $content .= $padding.'return $source->getSource()->getAllOptions($withEmpty, $defaultValues);'; return $content; } /** * get entity code * * @access public * @return string * @author Marius Strajeru */ public function getEntityCode() { return $this->_entityCode; } /** * get attribute setup type * * @access public * @return string * @author Marius Strajeru */ public function getSetupType() { $attrCode = $this->getTypeAttribute()->getAttribute()->getOptionsSourceAttribute(); /** @var Mage_Eav_Model_Config $config */ $config = Mage::getModel('eav/config'); $productAttribute = $config->getAttribute($this->getEntityCode(), $attrCode); if ($productAttribute->getId()) { $type = $productAttribute->getBackendType(); if ($type == 'static') { return false; } return $type; } return false; } /** * get attribute setup type * * @access public * @return string * @author Marius Strajeru */ public function getTypeDdl() { $entityAttribute = $this->_getEntityAttribute(); switch($entityAttribute->getBackendType()) { case 'int': return 'TYPE_INTEGER'; break; case 'varchar': return 'TYPE_TEXT'; break; case 'text': return 'TYPE_TEXT'; case 'datetime': return 'TYPE_DATETIME'; break; case 'decimal': return 'TYPE_DECIMAL'; break; default: return false; break; } } /** * get attribute setup type * * @access public * @return string * @author Marius Strajeru */ public function getTypeSize() { $entityAttribute = $this->_getEntityAttribute(); switch($entityAttribute->getBackendType()) { case 'int': return 'null'; break; case 'varchar': return '255'; break; case 'text': return "'64k'"; break; case 'datetime': return "255"; break; case 'decimal': return "'12,4'"; break; default: return false; break; } } /** * get the source model attribute * * @access public * @return null|Mage_Eav_Model_Entity_Attribute_Abstract * @author Marius Strajeru */ protected function _getEntityAttribute() { if (is_null($this->_entityAttribute)) { $attrCode = $this->getTypeAttribute()->getAttribute()->getOptionsSourceAttribute(); /** @var Mage_Eav_Model_Config $config */ $config = Mage::getModel('eav/config'); $productAttribute = $config->getAttribute($this->getEntityCode(), $attrCode); $this->_entityAttribute = $productAttribute; } return $this->_entityAttribute; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Dropdown.php ================================================ */ /** * dropdown attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract { /** * type code * * @var string */ protected $_type = 'dropdown'; /** * dropdown subtype * * @var Ultimate_ModuleCreator_Model_Abstract */ protected $_subTypeInstance; /** * sql colum ddl type * * @var string */ protected $_typeDdl = 'TYPE_INTEGER'; /** * sql colum ddl size * * @var string */ protected $_sizeDdl = 'null'; /** * eav setup type * * @var string */ protected $_setupType = 'int'; /** * eav setup input * * @var string */ protected $_setupInput = 'select'; /** * eav setup source * * @var string */ protected $_setupSource = 'eav/entity_attribute_source_table'; /** * get source for setup * * @access public * @return string|void * @author Marius Strajeru */ public function getSetupSource() { if (!$this->getGenerateSource()) { return parent::getSetupSource(); } $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $entity = $this->getEntity()->getNameSingular(true); return $namespace.'_'.$module.'/'.$entity.'_attribute_source_'.$this->getAttribute()->getCodeForFileName(); } /** * get admin column options * * @return string * @author Marius Strajeru */ public function getAdminColumnOptions() { $options = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $entity = strtolower($this->getAttribute()->getEntity()->getNameSingular()); $attr = $this->getAttribute()->getCode(); $options .= $this->getPadding(4)."'type' => 'options',".$this->getEol(); if ($this->getAttribute()->getEntity()->getIsEav()) { $options .= $this->getPadding(4). "'options' => Mage::helper('".$namespace.'_'.$module. "')->convertOptions(".$this->getEol().$this->getPadding(5)."Mage::getModel('eav/config')->getAttribute('". $namespace.'_'.$module.'_'.$entity."', '".$attr. "')->getSource()->getAllOptions(false)".$this->getEol().$this->getPadding(4).")".$this->getEol(); } else { $options .= $this->getPadding(4). "'options' => Mage::helper('".$namespace.'_'.$module. "')->convertOptions(".$this->getEol().$this->getPadding(5)."Mage::getModel('". $namespace.'_'.$module.'/'.$entity."_attribute_source_". $this->getAttribute()->getCodeForFileName(false). "')->getAllOptions(false)".$this->getEol().$this->getPadding(4).")".$this->getEol(); } return $options; } /** * get the type for the form * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { return 'select'; } /** * get text for rss * * @access public * @return string * @author Marius Strajeru */ public function getRssText() { $eol = $this->getEol(); $entityName = $this->getEntity()->getNameSingular(true); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); if ($this->getAttribute()->getEntity()->getIsEav()) { return $this->getPadding(3). '$description .= \'
    \'.'.$eol.$this->getPadding(4).'Mage::helper(\''. $namespace.'_'.$module.'\')->__("'.$this->getAttribute()->getLabel(). '").\': \''.$eol.$this->getPadding(4).'.$item->getAttributeText(\''. $this->getAttribute()->getCode().'\').'.$eol.$this->getPadding(4).'\'
    \';'.$this->getEol(); } else { $attributeFile = $this->getAttribute()->getCodeForFileName(false); $code = $this->getAttribute()->getMagicMethodCode(); return $this->getPadding(3). '$description .= \'
    \'.'.$eol.$this->getPadding(4).'Mage::helper(\''. $namespace.'_'.$module.'\')->__("'. $this->getAttribute()->getLabel().'").\': \''.$eol.$this->getPadding(4).'.Mage::getSingleton(\''. $namespace.'_'.$module.'/'.$entityName.'_attribute_source_'.$attributeFile. '\')->getOptionText($item->get'.$code.'()).'.$eol.$this->getPadding(4).'\'
    \';'.$this->getEol(); } } /** * check if source needs to be generated * * @access public * @return string * @author Marius Strajeru */ public function getGenerateSource() { return $this->getSubTypeInstance()->getGenerateSource(); } /** * get subtype instance * * @access public * @return Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru */ public function getSubTypeInstance() { if (!$this->_subTypeInstance) { $type = $this->getAttribute()->getOptionsSource(); try{ /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $types = $helper->getDropdownSubtypes(false); $instanceModel = (string)$types->$type->type_model; /** @var Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract $subtypeInstance */ $subtypeInstance = Mage::getModel($instanceModel); $this->_subTypeInstance = $subtypeInstance; $this->_subTypeInstance->setTypeAttribute($this); } catch (Exception $e){ throw new Ultimate_ModuleCreator_Exception("Invalid dropdown subtype: ". $type); } } return $this->_subTypeInstance; } /** * get additional setup values * * @access public * @return string * @author Marius Strajeru */ public function getAdditionalSetup() { return $this->getSubTypeInstance()->getAdditionalSetup(); } /** * get html for frontend * * @access public * @return string * @author Marius Strajeru */ public function getFrontendHtml() { $entityName = $this->getEntity()->getNameSingular(true); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); if ($this->getAttribute()->getEntity()->getIsEav()) { return '__("'. $this->getAttribute()->getLabel().'");?>:getAttributeText(\''. $this->getAttribute()->getCode().'\');?>'.$this->getEol(); } else { $attributeFile = $this->getAttribute()->getCodeForFileName(false); $code = $this->getAttribute()->getMagicMethodCode(); return '__("'. $this->getAttribute()->getLabel(). '");?>:getOptionText($_'.$entityName.'->get'.$code.'())'.';?>'.$this->getEol(); } } /** * get attribute options for source model * * @access public * @return string * @author Marius Strajeru */ public function getAttributeOptions() { return $this->getSubTypeInstance()->getAttributeOptions(); } /** * get the options for form input * * @access public * @return string * @author Marius Strajeru */ public function getFormOptions() { $options = parent::getFormOptions(); $padding = $this->getPadding(4); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getEntity()->getNameSingular(true); $namespace = $this->getNamespace(true); $options .= $padding."'values'=> Mage::getModel('". $namespace.'_'.$module.'/'.$entity."_attribute_source_". $this->getAttribute()->getCodeForFileName(false). "')->getAllOptions(".$this->getOptionsFlag()."),".$this->getEol(); return $options; } /** * check if options should be returned with empty * * @access public * @return string * @author Marius Strajeru */ public function getOptionsFlag() { return 'true'; } /** * get the setup type of the dropdown * * @access public * @return string|void * @author Marius Strajeru */ public function getSetupType() { $setupType = $this->getSubTypeInstance()->getSetupType(); if (empty($setupType)) { return parent::getSetupType(); } return $setupType; } /** * get the setup type of the dropdown * * @access public * @return string|void * @author Marius Strajeru */ public function getTypeDdl() { $setupType = $this->getSubTypeInstance()->getTypeDdl(); if (empty($setupType)) { return parent::getTypeDdl(); } return $setupType; } /** * get column ddl size * * @access public * @return string * @author Marius Strajeru */ public function getSizeDdl() { $size = $this->getSubTypeInstance()->getSizeDdl(); if (empty($size)) { return parent::getSizeDdl(); } return $size; } /** * get values for mass action * * @access public * @return string * @author Marius Strajeru */ public function getMassActionValues() { $module = $this->getModule()->getLowerModuleName(); $entity = $this->getEntity()->getNameSingular(true); $namespace = $this->getNamespace(true); if ($this->getEntity()->getIsEav()) { return "Mage::getModel('eav/config')->getAttribute('". $namespace.'_'.$module."_".$entity."', '". $this->getAttribute()->getCode()."')".$this->getEol().$this->getPadding(7)."->getSource()->getAllOptions(". $this->getOptionsFlag()."),".$this->getEol(); } else { return "Mage::getModel('". $namespace.'_'.$module.'/'.$entity."_attribute_source_". $this->getAttribute()->getCodeForFileName(false). "')".$this->getEol().$this->getPadding(7)."->getAllOptions(".$this->getOptionsFlag()."),".$this->getEol(); } } /** * get attribute default value * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueProcessed() { return $this->getSubTypeInstance()->getDefaultValueProcessed(); } /** * get attribute default value setup content * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueSetup() { $content = ''; if ($this->getSubTypeInstance() instanceof Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Custom && $this->getAttribute()->getDefaultValue() ) { $eol = $this->getEol(); $entity = $this->getEntity(); $attribute= $this->getAttribute(); $content .= '$attribute = Mage::getSingleton(\'eav/config\')->getAttribute(\''. $this->getNamespace(true).'_'.$this->getModule()->getLowerModuleName().'_'.$entity->getNameSingular(). '\', \''.$attribute->getCode().'\');'.$eol; $content .= '$options = $attribute->getSource()->getAllOptions(false);'.$eol; $content .= 'foreach ($options as $option) {'.$eol; $content .= $this->getPadding().'if ($option[\'label\'] == \''. Mage::helper('core')->jsQuoteEscape($attribute->getDefaultValue()).'\') {'.$eol; $content .= $this->getPadding(2). '$this->updateAttribute(\''. $this->getNamespace(true).'_'.$this->getModule()->getLowerModuleName().'_'.$entity->getNameSingular(). '\', \''.$attribute->getCode().'\', \'default_value\', $option[\'value\']);'.$eol; $content .= $this->getPadding().'}'.$eol; $content .= '}'.$eol; } return $content; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/File.php ================================================ */ /** * file attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_File extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract { /** * type code * * @var string */ protected $_type = 'file'; /** * eav setup input * * @var string */ protected $_setupInput = 'file'; /** * don't show in admin grid * * @access public * @return bool * @author Marius Strajeru */ public function getAdminGrid() { return false; } /** * check if attribute is required * * @access public * @return mixed * @author Marius Strajeru */ public function getRequired() { return false; } /** * get the type for the form * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { return 'file'; } /** * get text for rss * * @access public * @return string * @author Marius Strajeru */ public function getRssText() { $content = ''; $entityName = $this->getEntity()->getNameSingular(true); $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $content .= $this->getPadding(3).'if ($item->get'.$this->getAttribute()->getMagicMethodCode().'()) {'.$eol; $content .= $this->getPadding(4).'$description .= \'
    \';'.$eol; $content .= $this->getPadding(4).'$description .= Mage::helper(\''. $namespace.'_'.$module.'\')->__(\''.$this->getAttribute()->getLabel().'\');'.$eol; $content .= $this->getPadding(4).'$description .= \' \';'.$eol; $content .= $this->getPadding(4).'$description .= \' \'. basename($item->get'. $this->getAttribute()->getMagicMethodCode().'()).\'\';'.$eol; $content .= $this->getPadding(4).'$description .= \' \';'.$eol; $content .= $this->getPadding(4).'$description .= \'
    \';'.$eol; $content .= $this->getPadding(3).'}'.$eol; return $content; } /** * get the html for frontend * * @access public * @return string * @author Marius Strajeru */ public function getFrontendHtml() { $content = ''; $eol = $this->getEol(); $entityName = $this->getAttribute()->getEntity()->getNameSingular(true); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $content .= $this->getPadding().'get'. $this->getAttribute()->getMagicMethodCode().'()) :?>'.$eol; $content .= $this->getPadding(2).''.$eol; $content .= $this->getPadding(3).'get'.$this->getAttribute()->getMagicMethodCode().'())?>'.$eol; $content .= $this->getPadding(2).''.$eol; $content .= $this->getPadding().''.$eol; return $content; } /** * get the setup backend type * * @access public * @return string * @author Marius Strajeru */ public function getSetupBackend() { $attribute = $this->getAttribute(); $entity = $attribute->getEntity(); $module = $this->getModule(); return $this->getNamespace(true).'_'. $module->getLowerModuleName().'/'. $entity->getNameSingular(true).'_attribute_backend_file'; } /** * get attribute default value * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueProcessed() { return ''; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Image.php ================================================ */ /** * image attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Image extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract { /** * type code * * @var string */ protected $_type = 'image'; /** * eav setup input * * @var string */ protected $_setupInput = 'image'; /** * don't show in admin grid * * @access public * @return bool * @author Marius Strajeru */ public function getAdminGrid() { return false; } /** * check if attribute is required * * @access public * @return mixed * @author Marius Strajeru */ public function getRequired() { return false; } /** * get the type for the form * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { return 'image'; } /** * get text for rss * * @access public * @return string * @author Marius Strajeru */ public function getRssText() { $eol = $this->getEol(); $content = ''; $entityName = $this->getEntity()->getNameSingular(true); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $content .= $this->getPadding(3).'if ($item->get'.$this->getAttribute()->getMagicMethodCode().'()) {'.$eol; $content .= $this->getPadding(4).'$description .= \'
    \';'.$eol; $content .= $this->getPadding(4).'$description .= Mage::helper(\''.$namespace.'_'.$module. '\')->__(\''.$this->getAttribute()->getLabel().'\');'.$eol; $content .= $this->getPadding(4).'$description .= \'\'.$this->escapeHtml($item->get'.
            $this->getEntity()->getNameAttributeMagicCode().'()).\'\';'.$eol; $content .= $this->getPadding(4).'$description .= \'
    \';'.$eol; $content .= $this->getPadding(3).'}'.$eol; return $content; } /** * get the html for frontend * * @access public * @return string * @author Marius Strajeru */ public function getFrontendHtml() { $eol = $this->getEol(); $content = ''; $entityName = $this->getEntity()->getNameSingular(true); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $content .= 'get'.$this->getAttribute()->getMagicMethodCode().'()) :?>'.$eol; $content .= $this->getHelper()->getPadding(). '<?php echo $this->escapeHtml($_'.
            $entityName.'->get'.$this->getAttribute()->getEntity()->getNameAttributeMagicCode().'());?>'.$eol; $content .= ''.$eol; return $content; } /** * get the setup backend type * * @access public * @return string * @author Marius Strajeru */ public function getSetupBackend() { $attribute = $this->getAttribute(); $entity = $attribute->getEntity(); $module = $entity->getModule(); return $this->getNamespace(true).'_'. $module->getLowerModuleName().'/'. $entity->getNameSingular(true).'_attribute_backend_image'; } /** * get attribute default value * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueProcessed() { return ''; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Int.php ================================================ */ /** * int attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Int extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract { /** * type code * * @var string */ protected $_type = 'int'; /** * sql column ddl type * * @var string */ protected $_typeDdl = 'TYPE_INTEGER'; /** * sql column ddl size * * @var string */ protected $_sizeDdl = 'null'; /** * eav setup type * * @var string */ protected $_setupType = 'int'; /** * get admin column options * * @access public * @return string * @author Marius Strajeru */ public function getAdminColumnOptions() { $options = $this->getEol(); $options .= $this->getPadding(4); $options .= "'type'=> 'number',".$this->getEol(); return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Multiselect.php ================================================ */ /** * multiselect attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Multiselect extends Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown { /** * type code * * @var string */ protected $_type = 'multiselect'; /** * sql column ddl type * * @var string */ protected $_typeDdl = 'TYPE_TEXT'; /** * sql column ddl size * * @var string */ protected $_sizeDdl = "'64k'"; /** * eav setup input * * @var string */ protected $_setupInput = 'multiselect'; /** * eav setup type * * @var string */ protected $_setupType = 'text'; /** * backend setup type * * @var string */ protected $_setupBackend = 'eav/entity_attribute_backend_array'; /** * don't show in admin grid * * @access public * @return bool * @author Marius Strajeru */ public function getAdminGrid() { return false; } /** * get the type for the form * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { return 'multiselect'; } /** * check if attribute is multiple select * * @access public * @return bool * @author Marius Strajeru */ public function getIsMultipleSelect() { return true; } /** * get the setup type of the dropdown * * @access public * @return string|void * @author Marius Strajeru */ public function getSetupType() { return $this->_setupType; } /** * get attribute setup type * * @access public * @return string * @author Marius Strajeru */ public function getTypeDdl() { return $this->_typeDdl; } /** * check if options should be returned with empty * * @access public * @return string * @author Marius Strajeru */ public function getOptionsFlag() { return 'false'; } /** * get values for mass action * * @access public * @return string * @author Marius Strajeru */ public function getMassActionValues() { return ''; } /** * get attribute default value setup content * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueSetup() { $content = ''; if ($this->getSubTypeInstance() instanceof Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Custom && $this->getAttribute()->getDefaultValue() ) { $eol = $this->getEol(); $entity = $this->getEntity(); $attribute= $this->getAttribute(); $content .= '$attribute = Mage::getSingleton(\'eav/config\')->getAttribute(\''. $this->getNamespace(true).'_'.$this->getModule()->getLowerModuleName().'_'. $entity->getNameSingular().'\', \''.$attribute->getCode().'\');'.$eol; $content .= '$options = $attribute->getSource()->getAllOptions(false);'.$eol; $content .= '$defaultOptions = array();'.$eol; $content .= 'foreach ($options as $option) {'.$eol; $content .= $this->getPadding().'if (in_array($option[\'label\'], array(\''. implode( "','", explode( Ultimate_ModuleCreator_Model_Attribute::OPTION_SEPARATOR, Mage::helper('core')->jsQuoteEscape($attribute->getDefaultValue()) ) ).'\'))) {'.$eol; $content .= $this->getPadding(2).'$defaultOptions[] = $option[\'value\'];'.$eol; $content .= $this->getPadding().'}'.$eol; $content .= '}'.$eol; $content .= '$this->updateAttribute(\''. $this->getNamespace(true).'_'.$this->getModule()->getLowerModuleName().'_'. $entity->getNameSingular().'\', \''.$attribute->getCode(). '\', \'default_value\', implode(\',\', $defaultOptions));'.$eol; } return $content; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Signedint.php ================================================ */ /** * int attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Signedint extends Ultimate_ModuleCreator_Model_Attribute_Type_Int { /** * type code * * @var string */ protected $_type = 'signedint'; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Text.php ================================================ */ /** * text attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Text extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract { /** * type code * * @var string */ protected $_type = 'text'; /** * get admin column options * * @access public * @return string * @author Marius Strajeru */ public function getAdminColumnOptions() { $options = $this->getEol(); $options .= $this->getPadding(4); $options .= "'type'=> 'text',".$this->getEol(); return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Textarea.php ================================================ */ /** * textarea attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Textarea extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract { /** * type code * * @var string */ protected $_type = 'textarea'; /** * sql column ddl type * * @var string */ protected $_typeDdl = 'TYPE_TEXT'; /** * sql column ddl size * * @var string */ protected $_sizeDdl = "'64k'"; /** * eav setup type * * @var string */ protected $_setupType = 'text'; /** * eav setup input * * @var string */ protected $_setupInput = 'textarea'; /** * don't show in admin grid * * @access public * @return bool * @author Marius Strajeru */ public function getAdminGrid() { return false; } /** * get the type for the form * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { if ($this->getAttribute()->getEditor()) { return 'editor'; } return 'textarea'; } /** * can use editor * * @access public * @return bool * @author Marius Strajeru */ public function getEditor() { return $this->getAttribute()->getData('editor'); } /** * get the options for form input * * @access public * @return string * @author Marius Strajeru */ public function getFormOptions() { $options = ''; if ($this->getEditor() && !$this->getEntity()->getIsTree()) { $options = $this->getPadding(3)."'config' => "."$"."wysiwygConfig,".$this->getEol(); } $options .= parent::getFormOptions(); return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Timestamp.php ================================================ */ /** * timestamp attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Timestamp extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract { /** * type code * * @var string */ protected $_type = 'timestamp'; /** * sql column ddl type * * @var string */ protected $_typeDdl = 'TYPE_DATETIME'; /** * eav setup type * * @var string */ protected $_setupType = 'datetime'; /** * eav setup input * * @var string */ protected $_setupInput = 'date'; /** * setup backend * * @var string */ protected $_setupBackend = 'eav/entity_attribute_backend_datetime'; /** * get admin column options * * @access public * @return string * @author Marius Strajeru */ public function getAdminColumnOptions() { $options = $this->getEol(); $options .= $this->getPadding(4); $options .= "'type'=> 'date',".$this->getEol(); return $options; } /** * get the type for the form * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { return 'date'; } /** * get html for frontend * * @access public * @return string * @author Marius Strajeru */ public function getFrontendHtml() { $entityName = $this->getEntity()->getNameSingular(true); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); return '__("'. $this->getAttribute()->getLabel(). '");?>: formatDate($_'. $entityName.'->get'.$this->getAttribute()->getMagicMethodCode().'(), \'full\');?>'.$this->getEol(); } /** * get options for admin form * * @access public * @return string * @author Marius Strajeru */ public function getFormOptions() { $options = parent::getFormOptions(); $padding = $this->getPadding(3); $eol = $this->getEol(); $options .= $padding.'\'image\' => $this->getSkinUrl(\'images/grid-cal.gif\'),'.$eol;; $options .= $padding. '\'format\' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),'.$eol; return $options; } /** * get text for rss * * @access public * @return string * @author Marius Strajeru */ public function getRssText() { $attribute = $this->getAttribute(); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); return $this->getPadding(3).'$'. 'description .= \'
    \'.Mage::helper(\''. $namespace.'_'.$module.'\')->__(\''. $attribute->getLabel().'\').\': \'.Mage::helper(\'core\')->formatDate($item->get'. $this->getAttribute()->getMagicMethodCode().'(), \'full\').\'
    \';'.$this->getEol(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute/Type/Yesno.php ================================================ */ /** * yes/no attribute type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Attribute_Type_Yesno extends Ultimate_ModuleCreator_Model_Attribute_Type_Abstract { /** * type code * * @var string */ protected $_type = 'yesno'; /** * sql column ddl type * * @var string */ protected $_typeDdl = 'TYPE_SMALLINT'; /** * sql column ddl size * * @var string */ protected $_sizeDdl = 'null'; /** * eav setup type * * @var string */ protected $_setupType = 'int'; /** * eav setup input */ protected $_setupInput = 'select'; /** * eav setup source */ protected $_setupSource = 'eav/entity_attribute_source_boolean'; /** * get admin column options * * @access public * @return string * @author Marius Strajeru */ public function getAdminColumnOptions() { $eol = $this->getEol(); $options = $eol; $extension = $this->getModule()->getExtensionName(true); $options .= $this->getPadding(4)."'type' => 'options',".$eol; $options .= $this->getPadding(5)."'options' => array(".$eol; $options .= $this->getPadding(5)."'1' => Mage::helper('".$extension."')->__('Yes'),".$eol; $options .= $this->getPadding(5)."'0' => Mage::helper('".$extension."')->__('No'),".$eol; $options .= $this->getPadding(4).")".$eol; return $options; } /** * get the type for the form * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { return 'select'; } /** * get text for rss * * @access public * @return string * @author Marius Strajeru */ public function getRssText() { $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); return $this->getPadding(3). '$description .= \'
    \'.Mage::helper(\''. $namespace.'_'.$module.'\')->__("'. $this->getAttribute()->getLabel(). '").\':\'.(($item->get'.$this->getAttribute()->getMagicMethodCode(). '() == 1) ? Mage::helper(\''.$namespace.'_'.$module. '\')->__(\'Yes\') : Mage::helper(\''. $namespace.'_'.$module.'\')->__(\'No\')).\'
    \';'.$this->getEol(); } /** * get html for frontend * * @access public * @return string * @author Marius Strajeru */ public function getFrontendHtml() { $entityName = $this->getEntity()->getNameSingular(true); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); return '__("'. $this->getAttribute()->getLabel(). '");?>:get'.$this->getAttribute()->getMagicMethodCode(). '() == 1) ? Mage::helper(\''.$namespace.'_'.$module. '\')->__(\'Yes\') : Mage::helper(\''. $namespace.'_'.$module.'\')->__(\'No\') ?>'.$this->getEol(); } /** * check if attribute is yes/no * * @access public * @return bool * @author Marius Strajeru */ public function getIsYesNo() { return true; } /** * get the options for form input * * @access public * @return string * @author Marius Strajeru */ public function getFormOptions() { $options = parent::getFormOptions(); $padding = $this->getPadding(3); $tab = $this->getPadding(); $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $options .= $padding."'values'=> array(".$eol; $options .= $padding.$tab.'array('.$eol; $options .= $padding.$tab.$tab."'value' => 1,".$eol; $options .= $padding.$tab.$tab."'label' => Mage::helper('".$namespace.'_'.$module."')->__('Yes'),".$eol; $options .= $padding.$tab."),".$eol; $options .= $padding.$tab.'array('.$eol; $options .= $padding.$tab.$tab."'value' => 0,".$eol; $options .= $padding.$tab.$tab."'label' => Mage::helper('".$namespace.'_'.$module."')->__('No'),".$eol; $options .= $padding.$tab."),".$eol; $options .= $padding."),".$eol; return $options; } /** * get values for mass action * * @access public * @return string * @author Marius Strajeru */ public function getMassActionValues() { $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); $padding = $this->getPadding(7); $tab = $this->getPadding(); $content = 'array('.$eol; $content .= $padding.$tab."'1' => Mage::helper('".$namespace.'_'.$module."')->__('Yes'),".$eol; $content .= $padding.$tab."'0' => Mage::helper('".$namespace.'_'.$module."')->__('No'),".$eol; $content .= $padding.')'.$eol; return $content; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Attribute.php ================================================ */ /** * @method Ultimate_ModuleCreator_Model_Attribute setIndex() * @method string getForcedDefaultValue() * @method string getDefaultValue() * @method string getOptionsSourceAttribute() * @method string getLabel() * @method string getNote() * @method int getPosition() * @method string getCode() * @method bool getIsName() * @method Ultimate_ModuleCreator_Model_Attribute setUserDefined * @method Ultimate_ModuleCreator_Model_Attribute setEditor * @method string getType() * @method Ultimate_ModuleCreator_Model_Attribute setCode() * @method Ultimate_ModuleCreator_Model_Attribute setType() * @method Ultimate_ModuleCreator_Model_Attribute setLabel() * @method string getOptionsSource() * @method Ultimate_ModuleCreator_Model_Attribute setOptionsSource() * @method Ultimate_ModuleCreator_Model_Attribute setForcedSource() * @method Ultimate_ModuleCreator_Model_Attribute setScope() * @method Ultimate_ModuleCreator_Model_Attribute setUseFilterIndex() * @method Ultimate_ModuleCreator_Model_Attribute setPosition() * @method Ultimate_ModuleCreator_Model_Attribute setForcedSetupType() * @method Ultimate_ModuleCreator_Model_Attribute setForcedVisible() * @method string getPreElementText() * @method bool getUseFilterIndex() * @method bool hasForcedSetupType() * @method string getForcedSetupType() * @method string getForcedSetupBackend() * @method string getForcedSource() * @method int getScope() * @method bool hasForcedVisible() * @method string getForcedVisible() * @method Ultimate_ModuleCreator_Model_Attribute setDefaultValue() * @method Ultimate_ModuleCreator_Model_Attribute setForcedSetupBackend() * @method Ultimate_ModuleCreator_Model_Attribute setIgnoreApi() * @method Ultimate_ModuleCreator_Model_Attribute setOptions() * @method Ultimate_ModuleCreator_Model_Attribute setForcedDefaultValue() * @method bool getWidget() * @method bool getFrontend() * @method bool getIgnoreApi() * @method int getIndex() * */ class Ultimate_ModuleCreator_Model_Attribute extends Ultimate_ModuleCreator_Model_Abstract { /** * custom option separator */ const OPTION_SEPARATOR = "\n"; /** * entity object * * @var mixed(null|Ultimate_ModuleCreator_Model_Entity) */ protected $_entity = null; /** * attribute type instance * * @var mixed(null|Ultimate_ModuleCreator_Model_Attribute_Type_Abstract) */ protected $_typeInstance = null; /** * placeholders for replacing in source * * @var mixed */ protected $_placeholders = null; /** * set the model entity * * @access public * @param Ultimate_ModuleCreator_Model_Entity $entity * @return Ultimate_ModuleCreator_Model_Attribute * @author Marius Strajeru */ public function setEntity(Ultimate_ModuleCreator_Model_Entity $entity) { $this->_entity = $entity; return $this; } /** * get the attribute entity * * @access public * @return Ultimate_ModuleCreator_Model_Entity * @author Marius Strajeru */ public function getEntity() { return $this->_entity; } /** * get the magic function code for attribute * * @access public * @param bool $ucFirst * @return string * @author Marius Strajeru */ public function getMagicMethodCode($ucFirst = true) { $code = $this->getCode(); $code = $this->_camelize($code); if ($ucFirst) { return $code; } //lcfirst only works for php 5.3+ $code{0} = strtolower($code{0}); return $code; } /** * get attribute the type instance * * @access public * @return Ultimate_ModuleCreator_Model_Attribute_Type_Abstract * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru */ public function getTypeInstance() { if (!$this->_typeInstance) { $type = $this->getType(); try { $types = $this->getHelper()->getAttributeTypes(false); $instanceModel = $types->$type->type_model; /** @var Ultimate_ModuleCreator_Model_Attribute_Type_Abstract $typeInstance */ $typeInstance = Mage::getModel($instanceModel); $this->_typeInstance = $typeInstance; $this->_typeInstance->setAttribute($this); } catch (Exception $e){ throw new Ultimate_ModuleCreator_Exception("Invalid attribute type: ". $type); } } return $this->_typeInstance; } /** * check if an attribute is in the admin grid * * @access public * @return bool * @author Marius Strajeru */ public function getAdminGrid() { if ($this->getIsName()) { return true; } return $this->getTypeInstance()->getAdminGrid(); } /** * check if an attribute can use an editor * * @access public * @return bool * @author Marius Strajeru */ public function getEditor() { return $this->getTypeInstance()->getEditor(); } /** * check if attribute is required * * @access public * @return string * @author Marius Strajeru */ public function getRequired() { if ($this->getIsName()) { return true; } return $this->getTypeInstance()->getRequired(); } /** * check if attribute can behave as name * * @access public * @return bool * @author Marius Strajeru */ public function getIsAllowedAsName() { return $this->getTypeInstance()->getIsAllowedAsName(); } /** * check if the attribute acts as name * * @access public * @return bool * @author Marius Strajeru */ public function getNotIsName() { return !$this->getIsName(); } /** * get attribute placeholders * * @access public * @param null $key * @return mixed|null|string * @author Marius Strajeru */ public function getPlaceholders($key = null) { if (is_null($this->_placeholders)) { $placeholders['{{attributeLabel}}'] = $this->escapeText($this->getLabel()); $placeholders['{{AttributeMagicCode}}'] = $this->getMagicMethodCode(); $placeholders['{{attributeMagicCode}}'] = $this->getMagicMethodCode(false); $placeholders['{{attributeCode}}'] = $this->getCode(); $placeholders['{{attributeColumnOptions}}'] = $this->getAdminColumnOptions(); $placeholders['{{attributeFormType}}'] = $this->getFormType(); $placeholders['{{attributeFormOptions}}'] = $this->getFormOptions(); $placeholders['{{attributePreElementText}}'] = $this->getPreElementText(); $placeholders['{{attributeRssText}}'] = $this->getRssText(); $placeholders['{{attributeNote}}'] = $this->getNote(); $placeholders['{{AttributeCodeForFile}}'] = $this->getCodeForFileName(true); $placeholders['{{attributeCodeForFile}}'] = $this->getCodeForFileName(false); $placeholders['{{attributeOptions}}'] = $this->getAttributeOptions(); $placeholders['{{massActionValues}}'] = $this->getMassActionValues(); $eventObject = new Varien_Object( array( 'placeholders' => $placeholders ) ); Mage::dispatchEvent('umc_attribute_placeholdrers', array('event_object'=>$eventObject)); $placeholders = $eventObject->getPlaceholders(); $this->_placeholders = $placeholders; } if (is_null($key)) { return $this->_placeholders; } if (isset($this->_placeholders[$key])) { return $this->_placeholders[$key]; } return ''; } /** * get additional admin grid column options * * @access public * @return string * @author Marius Strajeru */ public function getAdminColumnOptions() { $options = $this->getTypeInstance()->getAdminColumnOptions(); if ($this->getUseFilterIndex()) { $options .= $this->getPadding(3). "'filter_index' => '".$this->getEntity()->getEntityTableAlias(). ".".$this->getCode()."'".$this->getEol(); } return $options; } /** * get options for attribute * * @access public * @param bool $asArray * @return array|mixed * @author Marius Strajeru */ public function getOptions($asArray = false) { if (!$asArray) { return $this->getData('options'); } return explode(self::OPTION_SEPARATOR, $this->getData('options')); } /** * get form type * * @access public * @return string * @author Marius Strajeru */ public function getFormType() { return $this->getTypeInstance()->getFormType(); } /** * get text for rss * * @access public * @return string * @author Marius Strajeru */ public function getRssText() { return $this->getTypeInstance()->getRssText(); } /** * get the sql column * * @access public * @return string * @author Marius Strajeru */ public function getDdlSqlColumn() { $eol = $this->getEol(); $padding = $this->getPadding(2); $tab = $this->getPadding(); $ddl = ''; $ddl .= "->addColumn(".$eol; $ddl .= $padding."'{$this->getCode()}',".$eol; $ddl .= $padding."Varien_Db_Ddl_Table::".$this->getTypeDdl().", ".$this->getSizeDdl().",".$eol; $ddl .= $padding."array("; $newLine = false; if ($this->getRequired()) { $ddl .= $eol.$padding.$tab."'nullable' => false,"; $newLine = true; } //TODO: move this inside the type class if ($this->getType() == 'int') { $ddl .= $eol.$padding.$tab."'unsigned' => true,"; $newLine = true; } if ($newLine) { $ddl .= $eol. $padding; } $ddl .= "),".$eol; $ddl .= $padding."'".$this->escapeText($this->getLabel())."'".$eol.$tab.")"; return $ddl; } /** * get column ddl type * * @access public * @return string * @author Marius Strajeru */ public function getTypeDdl() { return $this->getTypeInstance()->getTypeDdl(); } /** * get column ddl size * * @access public * @return string * @author Marius Strajeru */ public function getSizeDdl() { return $this->getTypeInstance()->getSizeDdl(); } /** * get the frontend html * * @access public * @return string * @author Marius Strajeru */ public function getFrontendHtml() { return $this->getTypeInstance()->getFrontendHtml(); } /** * get wsdl format for attribute * * @access public * @param bool $wsi * @return string * @author Marius Strajeru */ public function getWsdlFormat($wsi = false) { if ($wsi) { return ''; } return ''; } /** * get setup content for attribute * * @access public * @return mixed * @author Marius Strajeru */ public function getSetupContent() { $content = ''; $padding5 = $this->getPadding(5); $padding6 = $this->getPadding(6); $eol = $this->getEol(); $coreHelper = Mage::helper('core'); $content .= $padding5."'".$this->getCode()."' => array(".$eol; $content .= $padding6."'group' => 'General',".$eol; $content .= $padding6."'type' => '".$this->getSetupType()."',".$eol; $content .= $padding6."'backend' => '".$this->getSetupBackend()."',".$eol; $content .= $padding6."'frontend' => '',".$eol; $content .= $padding6."'label' => '".$coreHelper->jsQuoteEscape($this->getLabel())."',".$eol; $content .= $padding6."'input' => '".$this->getSetupInput()."',".$eol; $content .= $padding6."'source' => '".$this->getSetupSource()."',".$eol; $content .= $padding6."'global' => ".$this->getSetupIsGlobal().",".$eol; $content .= $padding6."'required' => '".$this->getRequired()."',".$eol; $content .= $padding6."'user_defined' => ".$this->getIsUserDefined().",".$eol; $content .= $padding6."'default' => '".$coreHelper->jsQuoteEscape($this->getDefaultValueProcessed()). "',".$eol; $content .= $padding6."'unique' => false,".$eol; $content .= $padding6."'position' => '".(int)$this->getPosition()."',".$eol; $content .= $padding6."'note' => '".$coreHelper->jsQuoteEscape($this->getNote())."',".$eol; $content .= $padding6."'visible' => '".(int)$this->getVisible()."',".$eol; $content .= $padding6."'wysiwyg_enabled'=> '".(int)$this->getEditor()."',".$eol; $content .= $this->getAdditionalSetup(); $content .= $padding5 .'),'.$eol; return $content; } /** * get setup type * * @access public * @return string * @author Marius Strajeru */ public function getSetupType() { if ($this->hasForcedSetupType()) { return $this->getForcedSetupType(); } return $this->getTypeInstance()->getSetupType(); } /** * get setup backend * * @access public * @return string * @author Marius Strajeru */ public function getSetupBackend() { if ($this->getForcedSetupBackend()) { return $this->getForcedSetupBackend(); } return $this->getTypeInstance()->getSetupBackend(); } /** * get setup input * * @access public * @return string * @author Marius Strajeru */ public function getSetupInput() { return $this->getTypeInstance()->getSetupInput(); } /** * get setup source * * @access public * @return string * @author Marius Strajeru */ public function getSetupSource() { if ($this->getForcedSource()) { return $this->getForcedSource(); } return $this->getTypeInstance()->getSetupSource(); } /** * check id an attribute is global * * @access public * @return int * @author Marius Strajeru */ public function getSetupIsGlobal() { switch ($this->getScope()) { case Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE: return 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE'; break; case Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL: return 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL'; break; case Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE: return 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE'; break; default : return ''; break; } } /** * get attribute code for file name * * @access public * @param bool $uppercase * @return string * @author Marius Strajeru */ public function getCodeForFileName($uppercase = false) { $code = str_replace('_', '', $this->getCode()); if ($uppercase) { $code = ucfirst($code); } return $code; } /** * check if attribute is visible * * @access public * @return string * @author Marius Strajeru */ public function getVisible() { if (($this->hasForcedVisible())) { return $this->getForcedVisible(); } return $this->getTypeInstance()->getVisible(); } /** * check if source needs to be generated * * @access public * @return string * @author Marius Strajeru */ public function getGenerateSource() { return $this->getTypeInstance()->getGenerateSource(); } /** * get additional setup values * * @access public * @return string * @author Marius Strajeru */ public function getAdditionalSetup() { return $this->getTypeInstance()->getAdditionalSetup(); } /** * check if attribute is yes/no * * @access public * @return bool * @author Marius Strajeru */ public function getIsYesNo() { return $this->getTypeInstance()->getIsYesNo(); } /** * get attribute options for source model * * @access public * @return string * @author Marius Strajeru */ public function getAttributeOptions() { return $this->getTypeInstance()->getAttributeOptions(); } /** * check if attribute is user defined * * @access public * @param bool $asText * @return string * @author Marius Strajeru */ public function getIsUserDefined($asText = true) { if (!$this->hasData('user_defined')) { $this->setData('user_defined', true); } if (!$asText) { return $this->getData('user_defined'); } if ($this->getData('user_defined')) { return 'true'; } return 'false'; } /** * get admin from options * * @access public * @return string * @author Marius Strajeru */ public function getFormOptions() { return $this->getTypeInstance()->getFormOptions(); } /** * check if attribute is multiple select * * @access public * @return bool * @author Marius Strajeru */ public function getIsMultipleSelect() { return $this->getTypeInstance()->getIsMultipleSelect(); } /** * check if entity is eav * * @access public * @return bool * @author Marius Strajeru */ public function getEntityEav() { return $this->getEntity()->getIsEav(); } /** * check if entity is not eav * * @access public * @return bool * @author Marius Strajeru */ public function getNotEntityEav() { return !$this->getEntityEav(); } /** * check if attribute can be in mass update * * @access public * @return mixed * @author Marius Strajeru */ public function getMassUpdate() { return $this->getTypeInstance()->getMassUpdate(); } /** * get values for mass action * * @access public * @return string * @author Marius Strajeru */ public function getMassActionValues() { return $this->getTypeInstance()->getMassActionValues(); } /** * get module * * @access public * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ public function getModule() { return $this->getEntity()->getModule(); } /** * get namespace * * @access public * @param bool $lower * @return string * @author Marius Strajeru */ public function getNamespace($lower = false) { return $this->getModule()->getNamespace($lower); } /** * get attribute default value * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueProcessed() { return $this->getTypeInstance()->getDefaultValueProcessed(); } /** * get attribute default value setup content * * @access public * @return string * @author Marius Strajeru */ public function getDefaultValueSetup() { return $this->getTypeInstance()->getDefaultValueSetup(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Config.php ================================================ */ class Ultimate_ModuleCreator_Model_Config extends Varien_Simplexml_Config { /** * cache key */ const CACHE_ID = 'umc_config'; /** * get DOM of the config * * @access public * @return null|Varien_Simplexml_Element * @author Marius Strajeru */ public function getDom() { if (is_null($this->_xml)) { $this->_xml = Mage::getConfig()->loadModulesConfiguration('umc.xml') ->applyExtends(); } return $this->_xml; } /** * get default translation module * * @return string * @access protected * @author Marius Strajeru */ protected function _getDefaultTranslateModule() { return 'Ultimate_ModuleCreator'; } /** * translate node * * @access protected * @param Varien_Simplexml_Element $node * @return Ultimate_ModuleCreator_Model_Config * @author Marius Strajeru */ protected function _translateNode(&$node) { if ($node->getAttribute('translate')) { $fields = explode(' ', $node->getAttribute('translate')); $module = ($node->getAttribute('module')) ? (string)$node->getAttribute('module') : $this->_getDefaultTranslateModule(); foreach ($fields as $field) { if ($node->$field) { $node->$field = Mage::helper($module)->__((string)$node->$field); } } } if ($node->hasChildren()) { foreach ($node->children() as $child) { $this->_translateNode($child); } } return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Entity/Type/Abstract.php ================================================ */ /** * abstract entity type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ abstract class Ultimate_ModuleCreator_Model_Entity_Type_Abstract extends Ultimate_ModuleCreator_Model_Abstract { /** * constant for eav type */ const TYPE_EAV = 'eav'; /** * constant for flat type */ const TYPE_FLAT = 'flat'; /** * current entity * * @var Ultimate_ModuleCreator_Model_Entity */ protected $_entity; /** * set the entity * * @access public * @param Ultimate_ModuleCreator_Model_Entity $entity * @return Ultimate_ModuleCreator_Model_Entity_Type_Abstract * @author Marius Strajeru */ public function setEntity(Ultimate_ModuleCreator_Model_Entity $entity) { $this->_entity = $entity; return $this; } /** * get the entity object * * @access public * @return Ultimate_ModuleCreator_Model_Entity|null * @author Marius Strajeru */ public function getEntity() { return $this->_entity; } /** * get the module object * * @access public * @return Ultimate_ModuleCreator_Model_Module|null * @author Marius Strajeru */ public function getModule() { return $this->getEntity()->getModule(); } /** * get the namespace * * @access public * @param bool $lower * @return string * @author Marius Strajeru */ public function getNamespace($lower = false) { return $this->getModule()->getNamespace($lower); } /** * get lower module name * * @access public * @return string * @author Marius Strajeru */ public function getLowerModuleName() { return $this->getModule()->getLowerModuleName(); } /** * get collection attributes * * @access public * @return string * @author Marius Strajeru */ public function getCollectionAttributes() { return ''; } /** * get admin join * * @access public * @return string * @author Marius Strajeru */ public function getAdminJoin() { return ''; } /** * prepare columns text * * @access public * @return string * @author Marius Strajeru */ public function getPrepareColumnsHeader() { return ''; } /** * get name attribute grid eav * * @access public * @return string * @author Marius Strajeru */ public function getNameAttributeGridEav() { return ''; } /** * check if entity has images * * @access public * @return bool * @author Marius Strajeru */ public function getHasImage() { return $this->getEntity()->getData('has_image'); } /** * check if entity has files * * @access public * @return bool * @author Marius Strajeru */ public function getHasFile() { return $this->getEntity()->getData('has_file'); } /** * check if submenu should exist * * @access public * @return bool * @author Marius Strajeru */ public function getHasSubmenu() { return false; } /** * get Additional submenu * * @access public * @param $padding * @return string * @author Marius Strajeru */ public function getAdditionalMenu($padding) { return ''; } /** * get Additional menu acl * * @access public * @param $padding * @return string * @author Marius Strajeru */ public function getAdditionalMenuAcl($padding) { return ''; } /** * check if comments are allowed by store * * @access public * @return string * @author Marius Strajeru */ public function getAllowCommentByStore() { return $this->getEntity()->getAllowComment() && $this->getEntity()->getStore(); } /** * get attributes content for setup * * @access public * @return string * @author Marius Strajeru */ public function getAttributesSetup() { return ''; } /** * get parent class for the entity resource model * * @access public * @return string * @author Marius Strajeru */ public function getResourceModelParent() { return 'Mage_Core_Model_Resource_Db_Abstract'; } /** * get parent class for the entity resource collection model * * @access public * @return string * @author Marius Strajeru */ public function getResourceCollectionModelParent() { return 'Mage_Core_Model_Resource_Db_Collection_Abstract'; } /** * get related entities relations table * * @access public * @return string * @author Marius Strajeru */ public function getResourceRelationsTables() { return ''; } /** * get related entities relations table declaration * * @access public * @return string * @author Marius Strajeru */ public function getResourceRelationsTablesDeclare() { return ''; } /** * get admin layout content for index page * * @access public * @return string * @author Marius Strajeru */ public function getAdminIndexLayoutContent() { $entity = $this->getEntity()->getNameSingular(true); $module = $this->getLowerModuleName(); $namespace = $this->getNamespace(true); return $this->getPadding(3).''.$this->getEol(); } /** * get the parent model class * * @access public * @return mixed * @author Marius Strajeru */ public function getEntityParentModel() { return 'Mage_Core_Model_Abstract'; } /** * get entity table alias * * @access public * @return mixed * @author Marius Strajeru */ public function getEntityTableAlias() { return 'main_table'; } /** * get additional prepare collection * * @access public * @return mixed * @author Marius Strajeru */ public function getAdditionalPrepareCollection() { return ''; } /** * additional layout block for left section * * @access public * @return mixed * @author Marius Strajeru */ public function getEditLayoutLeft() { return ''; } /** * additional layout block edit * * @access public * @return mixed * @author Marius Strajeru */ public function getEditLayoutAdditional() { return ''; } /** * get param name for before save * * @access public * @return mixed * @author Marius Strajeru */ public function getBeforeSaveParam() { return 'Mage_Core_Model_Abstract'; } /** * entity attribute set string * * @access public * @return string * @author Marius Strajeru */ public function getEntityAttributeSetId() { return ''; } /** * filter method name * * @access public * @return string * @author Marius Strajeru */ public function getFilterMethod() { return 'addFieldToFilter'; } /** * convert multiple select fields to strings * * @access public * @return mixed * @author Marius Strajeru */ public function getMultipleSelectConvert() { $padding = $this->getPadding(2); $tab = $this->getPadding(); $eol = $this->getEol(); $content = ''; foreach ($this->getEntity()->getAttributes() as $attribute) { if ($attribute->getIsMultipleSelect()) { $ucCode = $attribute->getMagicMethodCode(); $lcCode = $attribute->getCodeForFileName(false); $content .= '$'.$attribute->getCodeForFileName(false).' = $object->get'.$ucCode.'();'.$eol; $content .= $padding.'if (is_array($'.$lcCode.')) {'.$eol; $content .= $padding.$tab.'$object->set'.$ucCode."(implode(',', $".$lcCode.'));'.$eol; $content .= $padding.'}'.$eol.$padding; } } return $content; } /** * check if the entity helper can be created * * @access public * @return bool * @author Marius Strajeru */ public function getCanCreateEntityHelper() { return false; } /** * get additional code for toOptionArray() * * @access public * @return string * @author Marius Strajeru */ public function getToOptionAddition() { return ''; } /** * get comment name field filter index * * @access public * @return string * @author Marius Strajeru */ public function getCommentFilterIndexPrefix() { return $this->getEntityTableAlias().'.'; } /** * get additional api xml * * @access public * @return string * @author Marius Strajeru */ public function getApiAdditional() { return ''; } /** * get additional api faults * * @access public * @return string * @author Marius Strajeru */ public function getApiFaults() { return ''; } /** * additional API sub-entities. * * @access public * @return string * @author Marius Strajeru */ public function getApiAdditionalSettings() { return ''; } /** * get sub-entities acl * * @access public * @return string * @author Marius Strajeru */ public function getSubEntitiesAcl() { return ''; } /** * get api aliases * * @access public * @return string * @author Marius Strajeru */ public function getApiResourcesAlias() { return ''; } /** * get api V2 aliases * * @access public * @return string * @author Marius Strajeru */ public function getApiResourcesAliasV2() { return ''; } /** * get attributes format for wsdl * * @access public * @param bool $wsi * @return string * @author Marius Strajeru */ public function getWsdlAttributes($wsi = false) { return ''; } /** * get default api attributes * * @access public * @return string * @author Marius Strajeru */ public function getDefaultApiAttributes() { return ''; } /** * get add all attributes to collection * * @access public * @return string * @author Marius Strajeru */ public function getAllAttributesToCollection() { return ''; } /** * get load store id statement * * @access public * @return string * @author Marius Strajeru */ public function getLoadStoreId() { return ''; } /** * get rest collection cleanup * * @access public * @return string * @author Marius Strajeru */ public function getRestCollectionCleanup() { return $this->getEol().$this->getPadding(2).'$'. $this->getEntity()->getNamePlural(true). 'Array = $'.$this->getEntity()->getNamePlural(true).'Array[\'items\'];'.$this->getEol(); } /** * get rest collection store id * * @access public * @return string * @author Marius Strajeru */ public function getRestCollectionStoreId() { return ''; } /** * get default attribute values * * @access public * @return string * @author Marius Strajeru */ public function getDefaultAttributeValues() { $content = ''; foreach ($this->getEntity()->getAttributes() as $attribute) { $defaultValue = $attribute->getDefaultValueProcessed(); if (!empty($defaultValue)) { $content .= $this->getPadding(2). '$values[\''.$attribute->getCode().'\'] = \''.$defaultValue.'\';'.$this->getEol(); } } if ($content) { $content .= $this->getEol(); } return $content; } /** * get additional to option array select * * @access public * @return string * @author Marius Strajeru */ public function getToOptionArraySelect() { return ''; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Entity/Type/Eav.php ================================================ */ class Ultimate_ModuleCreator_Model_Entity_Type_Eav extends Ultimate_ModuleCreator_Model_Entity_Type_Abstract { /** * parent entities FK * * @var null */ protected $_parentAttributes = null; /** * get collection attributes * * @access public * @return string * @author Marius Strajeru */ public function getCollectionAttributes() { $result = ''; $eol = $this->getEol(); $padding = $this->getPadding(3); foreach ($this->_getParentAttributes() as $attribute) { $result .= $eol; $result .= $padding; $result .= '->addAttributeToSelect(\''.$attribute->getCode().'\')'; } foreach ($this->getEntity()->getAttributes() as $attribute) { if ($attribute->getAdminGrid() && $attribute->getCode() != $this->getEntity()->getNameAttributeCode()) { $result .= $eol; $result .= $padding; $result .= '->addAttributeToSelect(\''.$attribute->getCode().'\')'; } } foreach ($this->getEntity()->getSimulatedAttributes('status') as $attribute) { $result .= $eol; $result .= $padding; $result .= '->addAttributeToSelect(\''.$attribute->getCode().'\')'; } if ($this->getEntity()->getUrlRewrite()) { foreach ($this->getEntity()->getSimulatedAttributes('url_rewrite') as $attribute) { $result .= $eol; $result .= $padding; $result .= '->addAttributeToSelect(\''.$attribute->getCode().'\')'; } } return $result; } /** * get admin join * * @access public * @return string * @author Marius Strajeru */ public function getAdminJoin() { $eol = $this->getEol(); $result = $eol; $result .= $this->getPadding(2).'$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;'.$eol; $result .= $this->getPadding(2).'$store = $this->_getStore();'.$eol; $result .= $this->getPadding(2).'$collection->joinAttribute('.$eol.$this->getPadding(3).'\''. $this->getEntity()->getNameAttributeCode().'\', '.$eol.$this->getPadding(3).'\''. strtolower($this->getEntity()->getModule()->getNamespace()).'_'. $this->getEntity()->getModule()->getLowerModuleName().'_'. $this->getEntity()->getNameSingular().'/'. $this->getEntity()->getNameAttributeCode().'\', '. $eol.$this->getPadding(3).'\'entity_id\', ' .$eol.$this->getPadding(3).'null, '. $eol.$this->getPadding(3).'\'inner\', '. $eol.$this->getPadding(3).'$adminStore' .$eol.$this->getPadding(2).');'.$eol; $result .= $this->getPadding(2).'if ($store->getId()) {'.$eol; $result .= $this->getPadding(3). '$collection->joinAttribute('. $eol.$this->getPadding(4).'\''.$this->getModule()->getNamespace(true).'_'. $this->getModule()->getLowerModuleName().'_'. $this->getEntity()->getNameSingular().'_'. $this->getEntity()->getNameAttributeCode().'\', '. $eol.$this->getPadding(4).'\''.$this->getModule()->getNamespace(true). '_'.$this->getModule()->getLowerModuleName(). '_'.$this->getEntity()->getNameSingular(). '/'.$this->getEntity()->getNameAttributeCode().'\', '. $eol.$this->getPadding(4).'\'entity_id\', '. $eol.$this->getPadding(4).'null, '. $eol.$this->getPadding(4).'\'inner\', '. $eol.$this->getPadding(4).'$store->getId()'. $eol.$this->getPadding(3).');'.$eol; $result .= $this->getPadding(2).'}'.$eol; return $result; } /** * prepare columns header * * @access public * @return string * @author Marius Strajeru */ public function getPrepareColumnsHeader() { return '$store = $this->_getStore();'.$this->getEol().$this->getPadding(2); } /** * get name attribute for grid * * @access public * @return string * @author Marius Strajeru */ public function getNameAttributeGridEav() { $eol = $this->getEol(); $result = $eol; $result .= $this->getPadding(2).'if ($this->_getStore()->getId()) {'.$eol; $result .= $this->getPadding(3). '$this->addColumn('. $eol.$this->getPadding(4).'\''.$this->getNamespace(true).'_'. $this->getLowerModuleName().'_'.$this->getEntity()->getNameSingular().'_'. $this->getEntity()->getNameAttributeCode().'\', '. $eol.$this->getPadding(4).'array('.$eol; $result .= $this->getPadding(5). '\'header\' => Mage::helper(\''. $this->getNamespace(true).'_'.$this->getLowerModuleName().'\')->__(\''. $this->getEntity()->getNameAttributeLabel().' in %s\', $this->_getStore()->getName()),'.$eol; $result .= $this->getPadding(5).'\'align\' => \'left\','.$eol; $result .= $this->getPadding(5).'\'index\' => \''. $this->getNamespace(true).'_'.$this->getLowerModuleName().'_'. $this->getEntity()->getNameSingular().'_'.$this->getEntity()->getNameAttributeCode().'\','.$eol; $result .= $this->getPadding(4).')'. $eol.$this->getPadding(3).');'.$eol; $result .= $this->getPadding(2).'}'.$eol; return $result; } /** * eav always has image * * @access public * @return bool * @author Marius Strajeru */ public function getHasImage() { return true; } /** * eav always has files * * @access public * @return bool * @author Marius Strajeru */ public function getHasFile() { return true; } /** * eav always has submenu * * @access public * @return bool * @author Marius Strajeru */ public function getHasSubmenu() { return true; } /** * get additional menu * * @access public * @param $padding * @return bool * @author Marius Strajeru */ public function getAdditionalMenu($padding) { $extension = $this->getModule()->getExtensionName(true); $module = $this->getLowerModuleName(); $entity = $this->getEntity()->getNameSingular(true); $entityTitle = $this->getEntity()->getLabelSingular(); $action = $module.'_'.$entity; $eol = $this->getEol(); $text = $this->getPadding($padding).'<'.$entity.'_attributes translate="title" module="'.$extension.'">'.$eol; $text .= $this->getPadding($padding + 1).'Manage '.$entityTitle.' Attributes'.$eol; $text .= $this->getPadding($padding + 1).'adminhtml/'.$action.'_attribute'.$eol; $text .= $this->getPadding($padding + 1). ''.($this->getEntity()->getPosition() + 7).''.$eol; $text .= $this->getPadding($padding).''.$eol; return $text; } /** * get additional menu acl * * @access public * @param $padding * @return string * @author Marius Strajeru */ public function getAdditionalMenuAcl($padding) { $extension = $this->getModule()->getExtensionName(true); $entity = $this->getEntity()->getNameSingular(true); $entityTitle = $this->getEntity()->getLabelSingular(); $eol = $this->getEol(); $text = $this->getPadding($padding).'<'.$entity.'_attributes translate="title" module="'.$extension.'">'.$eol; $text .= $this->getPadding($padding + 1).'Manage '.$entityTitle.' attributes'.$eol; $text .= $this->getPadding($padding + 1).''. ($this->getEntity()->getPosition() + 7).''.$eol; $text .= $this->getPadding($padding).''.$eol; return $text; } /** * allow comments by store * * @access public * @return string * @author Marius Strajeru */ public function getAllowCommentByStore() { return $this->getEntity()->getAllowComment(); } /** * get parent attributes * * @access protected * @return Ultimate_ModuleCreator_Model_Attribute[] * @author Marius Strajeru */ protected function _getParentAttributes() { if (is_null($this->_parentAttributes)) { $parents = $this->getEntity()->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD ); $this->_parentAttributes = array(); foreach ($parents as $parent) { $module = $parent->getModule()->getLowerModuleName(); $namespace = $parent->getModule()->getNamespace(true); $name = $parent->getNameSingular(); /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode($name.'_id'); $attr->setLabel($parent->getLabelSingular()); $attr->setType('dropdown'); $attr->setOptionsSource('custom'); $attr->setForcedSource($namespace.'_'.$module.'/'.$name.'_source'); $attr->setScope(Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL); $attr->setEntity($this->getEntity()); $attr->setUseFilterIndex(true); $this->_parentAttributes[] = $attr; } } return $this->_parentAttributes; } /** * get attributes content for setup * * @access public * @return string * @author Marius Strajeru */ public function getAttributesSetup() { $content = ''; $position = 0; //all parent attributes /** @var Ultimate_ModuleCreator_Model_Attribute $attribute */ foreach ($this->_getParentAttributes() as $attribute) { $content .= $attribute->getSetupContent(); } foreach ($this->getEntity()->getAttributes() as $attribute) { $content .= $attribute->getSetupContent(); $position = $attribute->getPosition(); } $position += 10; foreach ($this->getEntity()->getSimulatedAttributes(null, false, array('tree')) as $attribute) { $attribute->setPosition($position); $content .= $attribute->getSetupContent(); $position += 10; } foreach ($this->getEntity()->getSimulatedAttributes('tree', false) as $attribute) { $attribute->setForcedSetupType('static'); $attribute->setForcedVisible(0); $content .= $attribute->getSetupContent(); $position += 10; } return $content; } /** * get parent class for the entity resource model * * @access public * @return string * @author Marius Strajeru */ public function getResourceModelParent() { return 'Mage_Catalog_Model_Resource_Abstract'; } /** * get parent class for the entity resource collection model * * @access public * @return string * @author Marius Strajeru */ public function getResourceCollectionModelParent() { return 'Mage_Catalog_Model_Resource_Collection_Abstract'; } /** * get related entities relations table * * @access public * @return string * @author Marius Strajeru */ public function getResourceRelationsTables() { $padding = $this->getPadding(2); $content = ''; $eol = $this->getEol(); $entity = $this->getEntity()->getNameSingular(true); $module = $this->getLowerModuleName(); $namespace = $this->getNamespace(true); if ($this->getEntity()->getLinkProduct()) { $content .= $padding.'$'.'this->_'. $entity.'ProductTable = $'."this->getTable('". $namespace.'_'.$module."/".$entity."_product');".$eol; } if ($this->getEntity()->getLinkCategory()) { $content .= $padding.'$'.'this->_'. $entity.'CategoryTable = $'."this->getTable('". $namespace.'_'.$module."/".$entity."_category');".$eol; } $related = $this->getEntity()->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING); foreach ($related as $_entity) { $_entityUc = ucfirst($_entity->getNameSingular()); $_entityLower = $_entity->getNameSingular(true); $content .= $padding.'$'.'this->_'. $entity.$_entityUc.'Table = $'."this->getTable('". $namespace.'_'.$module."/".$entity."_".$_entityLower."');".$eol; } return $content; } /** * get related entities relations table declaration * * @access public * @return string * @author Marius Strajeru */ public function getResourceRelationsTablesDeclare() { $padding = $this->getPadding(); $content = ''; $eol = $this->getEol(); $entity = $this->getEntity()->getNameSingular(true); if ($this->getEntity()->getLinkProduct()) { $content .= $padding.'protected $'.'_'.$entity.'ProductTable = null;'.$eol; } if ($this->getEntity()->getLinkCategory()) { $content .= $padding.'protected $'.'_'.$entity.'CategoryTable = null;'.$eol; } $related = $this->getEntity()->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING); foreach ($related as $_entity) { $_entityUc = ucfirst($_entity->getNameSingular()); $content .= $padding.'protected $'.'_'.$entity.$_entityUc.'Table = null;'.$eol; } return $content; } /** * get admin layout content for index page * * @access public * @return string * @author Marius Strajeru */ public function getAdminIndexLayoutContent() { $entity = $this->getEntity()->getNameSingular(true); $module = $this->getLowerModuleName(); $namespace = $this->getNamespace(true); $eol = $this->getEol(); $content = $this->getPadding(3). ''.$eol; $content .= $this->getPadding(4). ''.$eol; $content .= $this->getPadding(5).'0'.$eol; $content .= $this->getPadding(4).''.$eol; $content .= $this->getPadding(3).''.$eol; return $content; } /** * get the parent model class * * @access public * @return mixed * @author Marius Strajeru */ public function getEntityParentModel() { return 'Mage_Catalog_Model_Abstract'; } /** * get entity table alias * * @access public * @return mixed * @author Marius Strajeru */ public function getEntityTableAlias() { return 'e'; } /** * get additional prepare collection * * @access public * @return mixed * @author Marius Strajeru */ public function getAdditionalPrepareCollection() { return "->addAttributeToSelect('".$this->getEntity()->getNameAttributeCode()."')"; } /** * additional layout block for left section * * @access public * @return mixed * @author Marius Strajeru */ public function getEditLayoutLeft() { return ''. $this->getEol().$this->getPadding(3); } /** * additional layout block edit * * @access public * @return mixed * @author Marius Strajeru */ public function getEditLayoutAdditional() { $content = ''; $eol = $this->getEol(); $content .= $eol.$this->getPadding(2).''.$eol; $content .= $this->getPadding(3).'1'.$eol; $content .= $this->getPadding(2).''.$eol; $content .= $this->getPadding(2).''.$eol; $content .= $this->getPadding(3). ''. $eol; $content .= $this->getPadding(2).''; return $content; } /** * get param name for before save * * @access public * @return mixed * @author Marius Strajeru */ public function getBeforeSaveParam() { return 'Varien_Object'; } /** * entity attribute set string * * @access public * @return string * @author Marius Strajeru */ public function getEntityAttributeSetId() { $namespace = $this->getNamespace(true); $module = $this->getLowerModuleName(); $entity = $this->getEntity()->getNameSingular(true); return $this->getEol().$this->getPadding(). "->setAttributeSetId(Mage::getModel('".$namespace.'_'.$module.'/'.$entity. "')->getDefaultAttributeSetId())"; } /** * filter method name * * @access public * @return string * @author Marius Strajeru */ public function getFilterMethod() { return 'addAttributeToFilter'; } /** * convert multiple select fields to strings * * @access public * @return mixed * @author Marius Strajeru */ public function getMultipleSelectConvert() { return $this->getEol(); } /** * check if the entity helper can be created * * @access public * @return bool * @author Marius Strajeru */ public function getCanCreateEntityHelper() { return true; } /** * get additional code for toOptionArray() * * @access public * @return string * @author Marius Strajeru */ public function getToOptionAddition() { $attribute = $this->getEntity()->getNameAttributeCode(); return '$this->addAttributeToSelect(\''.$attribute.'\');'.$this->getEol().$this->getPadding(2); } /** * get comment name field filter index * * @access public * @return string * @author Marius Strajeru */ public function getCommentFilterIndexPrefix() { return ''; } /** * get additional api xml * * @access public * @return string * @author Marius Strajeru */ public function getApiAdditional() { $eol = $this->getEol(); $padding = $this->getPadding(5); $tab = $this->getPadding(); $content = ''; $content .= $padding.''.$eol; $content .= $padding.$tab.'Set/Get current store view'.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.'Get list of non-default attributes'.$eol; $content .= $padding.$tab.'getAdditionalAttributes'.$eol; $content .= $padding.''.$eol; return $content; } /** * get additional api faults * * @access public * @return string * @author Marius Strajeru */ public function getApiFaults() { $eol = $this->getEol(); $padding = $this->getPadding(5); $tab = $this->getPadding(); $content = ''; $content .= $padding.''.$eol; $content .= $padding.$tab.'100'.$eol; $content .= $padding.$tab.'Requested store view not found.'.$eol; $content .= $padding.''.$eol; return $content; } /** * additional API subentities. * * @access public * @return string * @author Marius Strajeru */ public function getApiAdditionalSettings() { $content = ''; $padding = $this->getPadding(3); $tab = $this->getPadding(); $module = $this->getLowerModuleName(); $entity = $this->getEntity()->getNameSingular(true); $eol = $this->getEol(); $content .= $eol; $extension = $this->getModule()->getExtensionName(true); $content .= $padding.'<'.$module.'_'.$entity.'_attribute translate="title" module="'.$extension.'">'.$eol; $content .= $padding.$tab.'Product attributes API'.$eol; $content .= $padding.$tab.''.$extension.'/'.$entity.'_attribute_api'.$eol; $content .= $padding.$tab.''.$module.'/'.$entity.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Set/Get current store view'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/write'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Retrieve attribute list'.$eol; $content .= $padding.$tab.$tab.$tab.'items'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/read'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Retrieve attribute options'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/read'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Get list of possible attribute types'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/types'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Create new attribute'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/create'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Update attribute'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/update'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Delete attribute'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/remove'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab. 'Get full information about attribute with list of options'. $eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/info'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Add option'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/option/add'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Remove option'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_attribute/option/remove'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'100'.$eol; $content .= $padding.$tab.$tab.$tab.'Requested store view not found.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'101'.$eol; $content .= $padding.$tab.$tab.$tab.'Requested attribute not found.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'102'.$eol; $content .= $padding.$tab.$tab.$tab.'Invalid request parameters.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'103'.$eol; $content .= $padding.$tab.$tab.$tab. 'Attribute code is invalid. Please use only letters (a-z), '. 'numbers (0-9) or underscore(_) in this field, first character should be a letter.'. $eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'104'.$eol; $content .= $padding.$tab.$tab.$tab.'Incorrect attribute type.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'105'.$eol; $content .= $padding.$tab.$tab.$tab.'Unable to save attribute.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'106'.$eol; $content .= $padding.$tab.$tab.$tab.'This attribute cannot be deleted.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'107'.$eol; $content .= $padding.$tab.$tab.$tab.'This attribute cannot be edited.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'108'.$eol; $content .= $padding.$tab.$tab.$tab.'Unable to add option.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'109'.$eol; $content .= $padding.$tab.$tab.$tab.'Unable to remove option.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; return $content; } /** * get subentities acl * * @access public * @return string * @author Marius Strajeru */ public function getSubEntitiesAcl() { $content = ''; $padding = $this->getPadding(5); $tab = $this->getPadding(); $entity = $this->getEntity()->getNameSingular(true); $eol = $this->getEol(); $title = $this->getEntity()->getLabelSingular().' Attributes'; $extension = $this->getModule()->getExtensionName(true); $content .= $eol; $content .= $padding.'<'.$entity.'_attribute translate="title" module="'.$extension.'">'.$eol; $content .= $padding.$tab.''.$title.''.$eol; $content .= $padding.$tab.''.($this->getEntity()->getPosition() + 6).''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Set/Get current store view'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Retrieve attribute list'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Retrieve attribute options'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Get list of possible attribute types'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Create new attribute'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Update attribute'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Remove attribute'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Get full information about attribute with list of options'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Add option'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Remove option'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; return $content; } /** * get api aliases * * @access public * @return string * @author Marius Strajeru */ public function getApiResourcesAlias() { $content = ''; $padding = $this->getPadding(3); $module = $this->getLowerModuleName(); $entity = $this->getEntity()->getNameSingular(true); $eol = $this->getEol(); $content .= $eol; $content .= $padding.'<'.$entity.'_attribute>'.$module.'_'.$entity.'_attribute'; return $content; } /** * get api V2 aliases * * @access public * @return string * @author Marius Strajeru */ public function getApiResourcesAliasV2() { $content = ''; $padding = $this->getPadding(4); $module = $this->getLowerModuleName(); $entity = $this->getEntity()->getNameSingular(true); $eol = $this->getEol(); $content .= $eol; $content .= $padding.'<'.$entity.'_attribute>'.$module.ucfirst($entity).'Attribute'; return $content; } /** * get attributes format for wsdl * * @access public * @param bool $wsi * @return string * @author Marius Strajeru */ public function getWsdlAttributes($wsi = false) { $tab = $this->getPadding(); $padding = str_repeat($tab, 5); $eol = $this->getEol(); $content = ''; $module = $this->getLowerModuleName(); $entity = ucfirst($this->getEntity()->getNameSingular(true)); if (!$wsi) { $content .= $padding. ''.$eol; } else { $content .= $padding. ''. $eol; } return $content; } /** * get default api attributes * * @access public * @return string * @author Marius Strajeru */ public function getDefaultApiAttributes() { $padding = $this->getPadding(); $tab = $padding; $eol = $this->getEol(); $entity = $this->getEntity(); $content = $padding.'protected $_defaultAttributeList = array('.$eol; $parents = $entity->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD); foreach ($parents as $parent) { $content .= $padding.$tab."'".$parent->getNameSingular(true).'_id'."', ".$eol; } foreach ($entity->getAttributes() as $attribute) { $content .= $padding.$tab."'".$attribute->getCode()."'".', '.$eol; } $simulated = $entity->getSimulatedAttributes(null, false); foreach ($simulated as $attr) { $content .= $padding.$tab."'".$attr->getCode()."'".', '.$eol; } $content .= $padding.$tab."'created_at', ".$eol; $content .= $padding.$tab."'updated_at', ".$eol; $content .= $padding.');'.$eol; return $content; } /** * get add all attributes to collection * * @access public * @return string * @author Marius Strajeru */ public function getAllAttributesToCollection() { return '->addAttributeToSelect(\'*\')'; } /** * get load store id statement * * @access public * @return string * @author Marius Strajeru */ public function getLoadStoreId() { return '->setStoreId(Mage::app()->getStore()->getId())'; } /** * get rest collection cleanup * * @access public * @return string * @author Marius Strajeru */ public function getRestCollectionCleanup() { return ''; } /** * get rest collection store id * * @access public * @return string * @author Marius Strajeru */ public function getRestCollectionStoreId() { return $this->getEol().$this->getPadding(2).'$collection->setStoreId($this->_getStore()->getId());'; } /** * get default attribute values * * @access public * @return string * @author Marius Strajeru */ public function getDefaultAttributeValues() { return ''; } /** * get additional to option array select * * @access public * @return string * @author Marius Strajeru */ public function getToOptionArraySelect() { return '->addAttributeToSelect(\''.$this->getEntity()->getNameAttributeCode().'\')'; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Entity/Type/Flat.php ================================================ */ /** * flat entity type * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Entity_Type_Flat extends Ultimate_ModuleCreator_Model_Entity_Type_Abstract { } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Entity.php ================================================ */ /** * entity model * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ /** * @method Ultimate_ModuleCreator_Model_Entity setIndex() * @method Ultimate_ModuleCreator_Model_Entity setEditor() * @method Ultimate_ModuleCreator_Model_Entity setHasImage() * @method Ultimate_ModuleCreator_Model_Entity setHasFile() * @method Ultimate_ModuleCreator_Model_Entity setHasCountry() * @method Ultimate_ModuleCreator_Model_Entity setHasMultipleSelect() * @method bool getCreateFrontend() * @method bool getLinkProduct() * @method bool getLinkCategory() * @method bool getIsTree() * @method string getType() * @method string getLabelSingular() * @method string getLabelPlural() * @method string getProductAttributeCode() * @method string getCategoryAttributeCode() * @method int getPosition() * @method string getUrlRewriteList() * @method bool getAllowComment() * @method bool getStore() * @method bool getShowCategory() * @method int getProductAttributeScope() * @method int getCategoryAttributeScope() * @method bool getProductAttribute(); * @method bool getCategoryAttribute() * @method string getProductAttributeGroup() * @method string getCategoryAttributeGroup() * @method int getListMenu() * @method bool getRest() * @method Ultimate_ModuleCreator_Model_Entity setPosition() * @method Ultimate_ModuleCreator_Model_Entity setRss() * @method bool getEditor() * @method bool getApi() * @method bool getHasCountry() * @method bool getSearch() * @method int getIndex() */ class Ultimate_ModuleCreator_Model_Entity extends Ultimate_ModuleCreator_Model_Abstract { /** * reference to type instance * * @var null|Ultimate_ModuleCreator_Model_Entity_Type_Abstract */ protected $_typeInstance = null; /** * entity code * * @var string */ protected $_entityCode = 'umc_entity'; /** * entity attributes * * @var array */ protected $_attributes = array(); /** * entity module * * @var Ultimate_ModuleCreator_Model_Module */ protected $_module = null; /** * attribute that behaves as name * * @var Ultimate_ModuleCreator_Model_Attribute */ protected $_nameAttribute = null; /** * remember if attributes were prepared * * @var bool */ protected $_preparedAttributes = null; /** * related entities * * @var array() */ protected $_relatedEntities = array(); /** * placeholders for replacing in source files * * @var mixed */ protected $_placeholders = null; /** * placeholders for sibling entities * * @var mixed */ protected $_placeholdersAsSibling = null; /** * set the entity module * * @access public * @param Ultimate_ModuleCreator_Model_Module $module * @return Ultimate_ModuleCreator_Model_Entity * @author Marius Strajeru */ public function setModule(Ultimate_ModuleCreator_Model_Module $module) { $this->_module = $module; return $this; } /** * get the entity module * * @access public * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ public function getModule() { return $this->_module; } /** * add new attribute * * @access public * @param Ultimate_ModuleCreator_Model_Attribute $attribute * @return Ultimate_ModuleCreator_Model_Entity * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru */ public function addAttribute(Ultimate_ModuleCreator_Model_Attribute $attribute) { Mage::dispatchEvent( 'umc_entity_add_attribute_before', array('attribute'=>$attribute, 'entity'=>$this) ); $attribute->setEntity($this); if (isset($this->_attributes[$attribute->getCode()])) { throw new Ultimate_ModuleCreator_Exception( Mage::helper('modulecreator')->__( 'An attribute with the code "%s" already exists for entity "%s"', $attribute->getCode(), $this->getNameSingular() ) ); } $this->_preparedAttributes = false; $this->_attributes[$attribute->getCode()] = $attribute; if ($attribute->getIsName()) { if (!$attribute->getIsAllowedAsName()) { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $attributeTypes = $helper->getNameAttributeTypes(true); throw new Ultimate_ModuleCreator_Exception( Mage::helper('modulecreator')->__( 'An attribute that acts as name must have one of the types "%s".', implode(', ', $attributeTypes) ) ); } $attribute->setUserDefined(false); $this->_nameAttribute = $attribute; } if ($attribute->getEditor()) { $this->setEditor(true); } if ($attribute->getType() == 'image') { $this->setHasImage(true); } if ($attribute->getType() == 'file') { $this->setHasFile(true); } if ($attribute->getType() == 'country') { $this->setHasCountry(true); } if ($attribute->getIsMultipleSelect()) { $this->setHasMultipleSelect(true); } Mage::dispatchEvent( 'umc_entity_add_attribute_after', array('attribute'=>$attribute, 'entity'=>$this) ); return $this; } /** * prepare attributes * * @access protected * @return Ultimate_ModuleCreator_Model_Entity * @author Marius Strajeru */ protected function _prepareAttributes() { if ($this->_preparedAttributes) { return $this; } $attributesByPosition = array(); foreach ($this->_attributes as $attribute) { /** @var Ultimate_ModuleCreator_Model_Attribute $attribute */ $attributesByPosition[$attribute->getPosition()][] = $attribute; } ksort($attributesByPosition); $attributes = array(); foreach ($attributesByPosition as $attributeList) { foreach ($attributeList as $attribute) { $attributes[$attribute->getCode()] = $attribute; } } $this->_attributes = $attributes; Mage::dispatchEvent('umc_entity_prepare_attributes', array('entity'=>$this)); $this->_preparedAttributes = true; return $this; } /** * ge the entity attributes * * @access public * @return Ultimate_ModuleCreator_Model_Attribute[] * @author Marius Strajeru */ public function getAttributes() { if (!$this->_preparedAttributes) { $this->_prepareAttributes(); } return $this->_attributes; } /** * entity to xml * * @access public * @param array $arrAttributes * @param string $rootName * @param bool $addOpenTag * @param bool $addCdata * @return string * @author Marius Strajeru */ public function toXml(array $arrAttributes = array(), $rootName = 'entity', $addOpenTag=false, $addCdata=false) { $xml = ''; if ($addOpenTag) { $xml.= ''.$this->getEol(); } if (!empty($rootName)) { $xml.= '<'.$rootName.'>'.$this->getEol(); } $xml .= parent::toXml($this->getXmlAttributes(), '', false, $addCdata); $xml .= ''.$this->getEol(); foreach ($this->getAttributes() as $attribute) { $xml .= $attribute->toXml(array(), 'attribute', false, $addCdata); } $xml .= ''.$this->getEol(); if (!empty($rootName)) { $xml.= ''.$this->getEol(); } return $xml; } /** * get magic function code for the name attribute * * @access public * @return string * @author Marius Strajeru */ public function getNameAttributeMagicCode() { $nameAttribute = $this->getNameAttribute(); if ($nameAttribute) { $entityNameMagicCode = $nameAttribute->getMagicMethodCode(); } else { $entityNameMagicCode = 'Name'; } return $entityNameMagicCode; } /** * get the name attribute * * @access public * @return mixed(null|Ultimate_ModuleCreator_Model_Attribute) * @author Marius Strajeru */ public function getNameAttribute() { return $this->_nameAttribute; } /** * get the attribute code for the name attribute * * @access public * @return string * @author Marius Strajeru */ public function getNameAttributeCode() { return $this->_nameAttribute->getCode(); } /** * get the attribute label for the name attribute * * @access public * @return string * @author Marius Strajeru */ public function getNameAttributeLabel() { return $this->getNameAttribute()->getLabel(); } /** * check if the entity has file attributes * * @access public * @return bool * @author Marius Strajeru */ public function getHasFile() { return $this->getTypeInstance()->getHasFile(); } /** * check if the entity has image attributes * * @access public * @return bool * @author Marius Strajeru */ public function getHasImage() { return $this->getTypeInstance()->getHasImage(); } /** * check if the entity has upload attributes * @access public * @return bool * @author Marius Strajeru */ public function getHasUpload() { return $this->getHasFile() || $this->getHasImage(); } /** * get the first image attribute code * * @access public * @return string * @author Marius Strajeru */ public function getFirstImageField() { foreach ($this->getAttributes() as $attribute) { if ($attribute->getType() == 'image') { return $attribute->getCode(); } } return ''; } /** * get the attribute name for plural * * @access public * @param bool $lower * @return string * @author Marius Strajeru */ public function getNamePlural($lower = false) { $plural = $this->getData('name_plural'); if ($plural == $this->getNameSingular()) { if ($plural == "") { return ""; } $plural = $this->getNameSingular().'s'; } if ($lower) { $plural = strtolower($plural); } return $plural; } /** * check if frontend list files must be created * * @access public * @return bool * @author Marius Strajeru */ public function getCreateList() { return $this->getCreateFrontend() && $this->getData('create_list'); } /** * get list template * * @access public * @return string * @author Marius Strajeru */ public function getListTemplate() { if ($this->getCreateList()) { return $this->getData('list_template'); } return ''; } /** * check if frontend view files must be created * * @access public * @return bool * @author Marius Strajeru */ public function getCreateView() { return $this->getCreateFrontend() && $this->getData('create_view'); } /** * get list template * * @access public * @return string * @author Marius Strajeru */ public function getViewTemplate() { if ($this->getCreateView()) { return $this->getData('view_template'); } return ''; } /** * check if widget list files must be created * * @access public * @return bool * @author Marius Strajeru */ public function getWidget() { return $this->getCreateFrontend() && $this->getData('widget'); } /** * check if SEO attributes should be added * * @access public * @return bool * @author Marius Strajeru */ public function getAddSeo() { return $this->getCreateView() && $this->getData('add_seo'); } /** * check if SEO attributes should be added * * @access public * @return bool * @author Marius Strajeru */ public function getRss() { return $this->getCreateFrontend() && $this->getData('rss'); } /** * check if url rewrite should be added * * @access public * @return bool * @author Marius Strajeru */ public function getUrlRewrite() { return $this->getCreateView() && $this->getData('url_rewrite'); } /** * get url prefix * * @access public * @return string * @author Marius Strajeru */ public function getUrlPrefix() { if ($this->getUrlRewrite()) { return $this->getData('url_prefix'); } return ''; } /** * get url suffix * * @access public * @return string * @author Marius Strajeru */ public function getUrlSuffix() { if ($this->getUrlRewrite()) { return $this->getData('url_suffix'); } return ''; } /** * check if products are listed in the entity view page * * @access public * @return bool * @author Marius Strajeru */ public function getShowProducts() { return $this->getLinkProduct() && $this->getCreateFrontend() && $this->getData('show_products'); } /** * check if entity list is shown on product page * * @access public * @return bool * @author Marius Strajeru */ public function getShowOnProduct() { return $this->getLinkProduct() && $this->getData('show_on_product'); } /** * check if entity list is shown on category page * * @access public * @return bool * @author Marius Strajeru */ public function getShowOnCategory() { return $this->getLinkCategory() && $this->getData('show_on_category'); } /** * add related entities * * @access public * @param string $type * @param Ultimate_ModuleCreator_Model_Entity $entity * @return Ultimate_ModuleCreator_Model_Entity * @author Marius Strajeru */ public function addRelatedEntity($type, $entity) { $this->_relatedEntities[$type][] = $entity; return $this; } /** * get the related entities * * @access public * @param mixed $type * @return Ultimate_ModuleCreator_Model_Entity[] * @author Marius Strajeru */ public function getRelatedEntities($type = null) { if (is_null($type)) { return $this->_relatedEntities; } if (isset($this->_relatedEntities[$type])) { return $this->_relatedEntities[$type]; } return array(); } /** * check if entity does not behave as tree * * @access public * @return bool * @author Marius Strajeru */ public function getNotIsTree() { return !$this->getIsTree(); } /** * check if entity does not have url rewrites * * @access public * @return bool * @author Marius Strajeru */ public function getNotUrlRewrite() { return !$this->getUrlRewrite(); } /** * check if entity is EAV * * @access public * @return bool * @author Marius Strajeru */ public function getIsEav() { return $this->getType() == Ultimate_ModuleCreator_Model_Entity_Type_Abstract::TYPE_EAV; } /** * check if entity is Flat * * @access public * @return bool * @author Marius Strajeru */ public function getIsFlat() { return $this->getType() == Ultimate_ModuleCreator_Model_Entity_Type_Abstract::TYPE_FLAT; } /** * get the entity type instance * * @access public * @return Ultimate_ModuleCreator_Model_Entity_Type_Abstract * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru */ public function getTypeInstance() { if (is_null($this->_typeInstance)) { $type = $this->getType(); /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $types = $helper->getEntityTypes(false); if (isset($types[$type])) { /** @var Ultimate_ModuleCreator_Model_Entity_Type_Abstract $typeInstance */ $typeInstance = Mage::getModel((string)$types[$type]->type_model); $this->_typeInstance = $typeInstance; } else { throw new Ultimate_ModuleCreator_Exception( Mage::helper('modulecreator')->__('Entity "%s" type is not valid', $type) ); } $this->_typeInstance->setEntity($this); } return $this->_typeInstance; } /** * check if entity has default config settings * * @access public * @return bool * @author Marius Strajeru */ public function getHasConfigDefaults() { return $this->getCreateFrontend(); } /** * check if entity is linked to core entities (product, category) * * @access public * @return bool * @author Marius Strajeru */ public function getLinkCore() { return $this->getLinkProduct() || $this->getLinkCategory(); } /** * get entity placeholders * * @access public * @param null $param * @return array|mixed|null|string * @author Marius Strajeru */ public function getPlaceholders($param = null) { if (is_null($this->_placeholders)) { $this->_placeholders = array(); $this->_placeholders['{{entity_default_config}}'] = $this->getDefaultConfig(); $this->_placeholders['{{entity}}'] = $this->getNameSingular(true); $this->_placeholders['{{Entity}}'] = ucfirst($this->getNameSingular(true)); $this->_placeholders['{{ENTITY}}'] = strtoupper($this->getNameSingular()); $this->_placeholders['{{EntityLabel}}'] = ucfirst($this->escapeText($this->getLabelSingular())); $this->_placeholders['{{entityLabel}}'] = strtolower($this->escapeText($this->getLabelSingular())); $this->_placeholders['{{EntitiesLabel}}'] = ucfirst($this->escapeText($this->getLabelPlural())); $this->_placeholders['{{entitiesLabel}}'] = strtolower($this->escapeText($this->getLabelPlural())); $this->_placeholders['{{entityCollectionAttributes}}'] = $this->getCollectionAttributes(); $this->_placeholders['{{entityAdminJoin}}'] = $this->getAdminJoin(); $this->_placeholders['{{prepareColumnsHeader}}'] = $this->getPrepareColumnsHeader(); $this->_placeholders['{{nameAttributeGridEav}}'] = $this->getNameAttributeGridEav(); $this->_placeholders['{{nameAttributeCode}}'] = $this->getNameAttributeCode(); $this->_placeholders['{{nameAttributeLabel}}'] = $this->escapeText($this->getNameAttributeLabel()); $this->_placeholders['{{entities}}'] = $this->getNamePlural(true); $this->_placeholders['{{Entities}}'] = ucfirst($this->getNamePlural(true)); $this->_placeholders['{{EntityNameMagicCode}}'] = $this->getNameAttributeMagicCode(); $this->_placeholders['{{attributeDdlSql}}'] = $this->getAttributesDdlSql(); $this->_placeholders['{{referenceHead}}'] = $this->getReferenceHeadLayout(); $this->_placeholders['{{EntityViewRelationLayout}}'] = $this->getRelationLayoutXml(); $this->_placeholders['{{listLayout}}'] = $this->getListTemplate(); $this->_placeholders['{{viewLayout}}'] = $this->getViewTemplate(); $this->_placeholders['{{entityHtmlLink}}'] = $this->getHtmlLink(); $this->_placeholders['{{EntityViewAttributes}}'] = $this->getViewAttributesHtml(); $this->_placeholders['{{EntityViewWidgetAttributes}}'] = $this->getViewWidgetAttributesHtml(); $this->_placeholders['{{systemAttributes}}'] = $this->getSystemAttributes(); $this->_placeholders['{{entityApiAdditional}}'] = $this->getApiAdditional(); $this->_placeholders['{{entityApiFaults}}'] = $this->getApiFaults(); $this->_placeholders['{{entityAdditionalApiAcl}}'] = $this->getAdditionalApiAcl(); $this->_placeholders['{{entityWsdlAttributes}}'] = $this->getWsdlAttributes(); $this->_placeholders['{{entityWsdlAttributesForAdd}}'] = $this->getWsdlAttributes(false, true); $this->_placeholders['{{entityWsdlRelationTypes}}'] = $this->getWsdlRelationTypes(); $this->_placeholders['{{entityWsdlPortTypeRelation}}'] = $this->getWsdlPortTypeRelation(); $this->_placeholders['{{entityWsdlRelationBinding}}'] = $this->getWsdlRelationBinding(); $this->_placeholders['{{entityWsiRelationParamTypes}}'] = $this->getWsiRelationParamTypes(); $this->_placeholders['{{entityWsiRelationMessages}}'] = $this->getWsiRelationMessages(); $this->_placeholders['{{entityWsiPortTypeRelation}}'] = $this->getWsiPortTypeRelation(); $this->_placeholders['{{entityWsiRelationBinding}}'] = $this->getWsiRelationBinding(); $this->_placeholders['{{entityWsiAttributes}}'] = $this->getWsiAttributes(); $this->_placeholders['{{entityWsiAttributesForAdd}}'] = $this->getWsiAttributes(true); $this->_placeholders['{{entityWsiRelationTypes}}'] = $this->getWsiRelationTypes(); $this->_placeholders['{{entityWsdlMessages}}'] = $this->getWsdlMessages(); $this->_placeholders['{{fksDdl}}'] = $this->getParentEntitiesFksDdl(); $this->_placeholders['{{selectedMenuPath}}'] = $this->getSelectedMenuPath(); $this->_placeholders['{{entityAttributesSetup}}'] = $this->getAttributesSetup(); $this->_placeholders['{{ResourceModelParent}}'] = $this->getResourceModelParent(); $this->_placeholders['{{ResourceCollectionParent}}'] = $this->getResourceCollectionModelParent(); $this->_placeholders['{{RelationsResourceTables}}'] = $this->getResourceRelationsTables(); $this->_placeholders['{{RelationsResourceTablesDeclare}}'] = $this->getResourceRelationsTablesDeclare(); $this->_placeholders['{{adminIndexContent}}'] = $this->getAdminIndexLayoutContent(); $this->_placeholders['{{EntityParentModel}}'] = $this->getEntityParentModel(); $this->_placeholders['{{entityTableAlias}}'] = $this->getEntityTableAlias(); $this->_placeholders['{{additionalPrepareCollection}}'] = $this->getAdditionalPrepareCollection(); $this->_placeholders['{{entityEditLayoutLeft}}'] = $this->getEditLayoutLeft(); $this->_placeholders['{{entityLayoutAdditional}}'] = $this->getEditLayoutAdditional(); $this->_placeholders['{{productAttributeCode}}'] = $this->getProductAttributeCode(); $this->_placeholders['{{categoryAttributeCode}}'] = $this->getCategoryAttributeCode(); $this->_placeholders['{{entityProductAttributeScope}}'] = $this->getProductAttributeScopeLabel(); $this->_placeholders['{{entityCategoryAttributeScope}}']= $this->getCategoryAttributeScopeLabel(); $this->_placeholders['{{productAttributeGroup}}'] = $this->getProductAttributeGroupLabel(); $this->_placeholders['{{categoryAttributeGroup}}'] = $this->getCategoryAttributeGroupLabel(); $this->_placeholders['{{beforeSaveParam}}'] = $this->getBeforeSaveParam(); $this->_placeholders['{{EntityAttributeSetId}}'] = $this->getEntityAttributeSetId(); $this->_placeholders['{{filterMethod}}'] = $this->getFilterMethod(); $this->_placeholders['{{multipleSelectConvert}}'] = $this->getMultipleSelectConvert(); $this->_placeholders['{{toOptionAddition}}'] = $this->getToOptionAddition(); $this->_placeholders['{{multiselectMethods}}'] = $this->getMultiselectMethods(); $this->_placeholders['{{nameHtml}}'] = $this->getNameHtml(); $this->_placeholders['{{isTree}}'] = (int)$this->getIsTree(); $this->_placeholders['{{commentFilterIndexPrefix}}'] = $this->getCommentFilterIndexPrefix(); $this->_placeholders['{{entityApiAdditionalSettings}}'] = $this->getApiAdditionalSettings(); $this->_placeholders['{{subEntitiesAcl}}'] = $this->getSubEntitiesAcl(); $this->_placeholders['{{position}}'] = $this->getPosition(); $this->_placeholders['{{entityApiResourcesAlias}}'] = $this->getApiResourcesAlias(); $this->_placeholders['{{entityApiResourcesAliasV2}}'] = $this->getApiResourcesAliasV2(); $this->_placeholders['{{defaultApiAttributes}}'] = $this->getDefaultApiAttributes(); $this->_placeholders['{{filterEntityDates}}'] = $this->getFilterDates(); $this->_placeholders['{{filterEntityDates3}}'] = $this->getFilterDates(3); $this->_placeholders['{{allAttributesToCollection}}'] = $this->getAllAttributesToCollection(); $this->_placeholders['{{loadStoreId}}'] = $this->getLoadStoreId(); $this->_placeholders['{{restCollectionCleanup}}'] = $this->getRestCollectionCleanup(); $this->_placeholders['{{restCollectionStoreId}}'] = $this->getRestCollectionStoreId(); $this->_placeholders['{{defaultAttributeValues}}'] = $this->getDefaultAttributeValues(); $this->_placeholders['{{toOptionArraySelect}}'] = $this->getToOptionArraySelect(); $this->_placeholders['{{parentStaticParams}}'] = $this->getParentStaticParams(); $eventObject = new Varien_Object( array( 'placeholders' => $this->_placeholders ) ); Mage::dispatchEvent('umc_entity_placeholdrers', array('event_object'=>$eventObject)); $this->_placeholders = $eventObject->getPlaceholders(); } if (is_null($param)) { return $this->_placeholders; } if (isset($this->_placeholders[$param])) { return $this->_placeholders[$param]; } return ''; } /** * get placeholders as sibling * * @access public * @param null $param * @return array|mixed|null|string * @author Marius Strajeru */ public function getPlaceholdersAsSibling($param = null) { if (is_null($this->_placeholdersAsSibling)) { $this->_placeholdersAsSibling = array(); $this->_placeholdersAsSibling['{{sibling_default_config}}'] = $this->getDefaultConfig(); $this->_placeholdersAsSibling['{{sibling}}'] = $this->getNameSingular(true); $this->_placeholdersAsSibling['{{Sibling}}'] = ucfirst($this->getNameSingular(true)); $this->_placeholdersAsSibling['{{SIBLING}}'] = strtoupper($this->getNameSingular()); $this->_placeholdersAsSibling['{{SiblingLabel}}'] = ucfirst($this->getLabelSingular()); $this->_placeholdersAsSibling['{{siblingLabel}}'] = strtolower($this->getLabelSingular()); $this->_placeholdersAsSibling['{{SiblingsLabel}}'] = ucfirst($this->getLabelPlural()); $this->_placeholdersAsSibling['{{siblingsLabel}}'] = $this->getLabelPlural(true); $this->_placeholdersAsSibling['{{siblingCollectionAttributes}}'] = $this->getCollectionAttributes(); $this->_placeholdersAsSibling['{{siblingAdminJoin}}'] = $this->getAdminJoin(); $this->_placeholdersAsSibling['{{siblingColumnsHeader}}'] = $this->getPrepareColumnsHeader(); $this->_placeholdersAsSibling['{{siblingNameAttributeGridEav}}'] = $this->getNameAttributeGridEav(); $this->_placeholdersAsSibling['{{siblingNameAttributeCode}}'] = $this->getNameAttributeCode(); $this->_placeholdersAsSibling['{{siblingNameAttributeLabel}}'] = $this->getNameAttributeLabel(); $this->_placeholdersAsSibling['{{siblings}}'] = strtolower($this->getNamePlural()); $this->_placeholdersAsSibling['{{Siblings}}'] = ucfirst($this->getNamePlural(true)); $this->_placeholdersAsSibling['{{SiblingNameMagicCode}}'] = $this->getNameAttributeMagicCode(); $this->_placeholdersAsSibling['{{SiblingViewRelationLayout}}'] = $this->getRelationLayoutXml(); $this->_placeholdersAsSibling['{{siblingListLayout}}'] = $this->getListTemplate(); $this->_placeholdersAsSibling['{{siblingViewLayout}}'] = $this->getViewTemplate(); $this->_placeholdersAsSibling['{{SiblingListItem}}'] = $this->getHtmlLink(); $this->_placeholdersAsSibling['{{siblingNameAttribute}}'] = $this->getNameAttributeCode(); $this->_placeholdersAsSibling['{{siblingAdditionalPrepareCollection}}'] = $this->getAdditionalPrepareCollection(); $this->_placeholdersAsSibling['{{siblingTableAlias}}'] = $this->getEntityTableAlias(); $this->_placeholdersAsSibling['{{siblingFilterMethod}}'] = $this->getFilterMethod(); $this->_placeholdersAsSibling['{{siblingAllAttributesToCollection}}'] = $this->getAllAttributesToCollection(); $this->_placeholdersAsSibling['{{siblingLoadStoreId}}'] = $this->getLoadStoreId(); $this->_placeholdersAsSibling['{{siblingToOptionArraySelect}}'] = $this->getToOptionArraySelect(); $this->_placeholdersAsSibling['{{siblingParentStaticParams}}'] = $this->getParentStaticParams(); $eventObject = new Varien_Object( array( 'placeholders' => $this->_placeholdersAsSibling ) ); Mage::dispatchEvent( 'umc_entity_placeholdrers_as_sibling', array('event_object'=>$eventObject) ); $this->_placeholdersAsSibling = $eventObject->getPlaceholders(); } if (is_null($param)) { return $this->_placeholdersAsSibling; } if (isset($this->_placeholdersAsSibling[$param])) { return $this->_placeholdersAsSibling[$param]; } return ''; } /** * get default config settings * * @access public * @return string * @author Marius Strajeru */ public function getDefaultConfig() { if (!$this->getHasConfigDefaults()) { return ''; } $padding3 = $this->getPadding(3); $padding = $this->getPadding(); $eol = $this->getEol(); $text = '<'.$this->getNameSingular().'>'.$eol; if ($this->getCreateFrontend()) { $text.= $padding3.$padding.'1'.$eol; } if ($this->getUrlRewrite() && $this->getUrlPrefix()) { $text.= $padding3.$padding.''.$this->getUrlPrefix().''.$eol; } if ($this->getUrlRewrite() && $this->getUrlSuffix()) { $text.= $padding3.$padding.''.$this->getUrlSuffix().''.$eol; } if ($this->getUrlRewrite() && $this->getUrlRewriteList()) { $text.= $padding3.$padding.''.$this->getUrlRewriteList().''.$eol; } if ($this->getAllowComment()) { $text.= $padding3.$padding.'1'.$eol; } if ($this->getRss()) { $text.= $padding3.$padding.'1'.$eol; } if ($this->getAddSeo()) { $text.= $padding3.$padding.''.$this->getLabelPlural().''.$eol; } if ($this->getIsTree() && $this->getCreateFrontend()) { $text.= $padding3.$padding.'1'.$eol; $text.= $padding3.$padding.'0'.$eol; } $text .= $padding3.'getNameSingular().'>'.$eol; return $text; } /** * get xml for add product event * * @access public * @return string * @author Marius Strajeru */ public function getAddBlockToProductEvent() { $text = ''; if ($this->getLinkProduct()) { $ns = $this->getNamespace(true); $eol = $this->getEol(); $text = $this->getPadding(5).'<'.$ns.'_'.$this->getModule()->getLowerModuleName().'_'. $this->getNameSingular(true).'>'.$eol; $text .= $this->getPadding(6).'singleton'.$eol; $text .= $this->getPadding(6).''.$ns.'_'.$this->getModule()->getLowerModuleName(). '/adminhtml_observer'.$eol; $text .= $this->getPadding(6).'add'.ucfirst(strtolower($this->getNameSingular())). 'Block'.$eol; $text .= $this->getPadding(5).'getModule()->getLowerModuleName().'_'. $this->getNameSingular(true).'>'.$eol; } return $text; } /** * get xml for add product save after event * * @access public * @return string * @author Marius Strajeru */ public function getProductSaveAfterEvent() { $text = ''; if ($this->getLinkProduct()) { $ns = strtolower($this->getModule()->getNamespace()); $eol = $this->getEol(); $text = $this->getPadding(5).'<'.$ns.'_'.$this->getModule()->getLowerModuleName().'_'. $this->getNameSingular(true).'>'.$eol; $text .= $this->getPadding(6).'singleton'.$eol; $text .= $this->getPadding(6).''.$ns.'_'.$this->getModule()->getLowerModuleName(). '/adminhtml_observer'.$eol; $text .= $this->getPadding(6).'save'.ucfirst(strtolower($this->getNameSingular())). 'Data'.$eol; $text .= $this->getPadding(5).'getModule()->getLowerModuleName(). '_'.$this->getNameSingular(true).'>'.$eol; } return $text; } /** * get xml for add can load ext js * * @access public * @return string * @author Marius Strajeru */ public function getCanLoadExtJsEvent() { $text = ''; if ($this->getLinkProduct() && $this->getIsTree()) { $eol = $this->getEol(); $ns = strtolower($this->getModule()->getNamespace()); $text = $this->getPadding(5).'<'.$ns.'_'.$this->getModule()->getLowerModuleName().'_'. $this->getNameSingular(true).'>'.$eol; $text .= $this->getPadding(6).'singleton'.$eol; $text .= $this->getPadding(6).''.$ns.'_'.$this->getModule()->getLowerModuleName(). '/adminhtml_observer'.$eol; $text .= $this->getPadding(6).'setCanLoadExtJs'.$eol; $text .= $this->getPadding(5).'getModule()->getLowerModuleName(). '_'.$this->getNameSingular(true).'>'.$eol; } return $text; } /** * get xml for admin menu * * @access public * @param $padding * @return string * @author Marius Strajeru */ public function getMenu($padding) { $extension = $this->getModule()->getExtensionName(true); $module = $this->getModule()->getLowerModuleName(); $title = ucwords($this->getLabelSingular()); $entity = strtolower($this->getNameSingular()); $action = $module.'_'.$entity; $eol = $this->getEol(); $text = $this->getPadding($padding).'<'.$entity.' translate="title" module="'.$extension.'">'.$eol; $text .= $this->getPadding($padding + 1).''.$title.''.$eol; $text .= $this->getPadding($padding + 1).'adminhtml/'.$action.''.$eol; $text .= $this->getPadding($padding + 1).''.$this->getPosition().''.$eol; $text .= $this->getPadding($padding).''.$eol; if ($this->getAllowComment()) { $text .= $this->getPadding($padding).'<'.$entity. '_comments translate="title" module="'.$extension.'">'.$eol; $text .= $this->getPadding($padding + 1).'Manage '.$title.' Comments'.$eol; $text .= $this->getPadding($padding + 1).'adminhtml/'.$action.'_comment'.$eol; $text .= $this->getPadding($padding + 1).''.($this->getPosition() + 4).''.$eol; $text .= $this->getPadding($padding).''.$eol; } $text .= $this->getTypeInstance()->getAdditionalMenu($padding); return $text; } /** * get xml for acl * * @access public * @param $padding * @return string * @author Marius Strajeru */ public function getMenuAcl($padding) { $extension = $this->getModule()->getExtensionName(true); $title = ucwords($this->getLabelSingular()); $entity = $this->getNameSingular(true); $eol = $this->getEol(); $text = $this->getPadding($padding).'<'.$entity.' translate="title" module="'.$extension.'">'.$eol; $text .= $this->getPadding($padding + 1).''.$title.''.$eol; $text .= $this->getPadding($padding + 1).''.$this->getPosition().''.$eol; $text .= $this->getPadding($padding).''.$eol; if ($this->getAllowComment()) { $text .= $this->getPadding($padding).'<'.$entity. '_comments translate="title" module="'.$extension.'">'.$eol; $text .= $this->getPadding($padding + 1).'Manage '.$title.' Comments'.$eol; $text .= $this->getPadding($padding + 1).''.($this->getPosition() + 5).''.$eol; $text .= $this->getPadding($padding).''.$eol; } $text .= $this->getTypeInstance()->getAdditionalMenuAcl($padding); return $text; } /** * get attributes that need to be added in the admin grid collection * * @access public * @return string * @author Marius Strajeru */ public function getCollectionAttributes() { return $this->getTypeInstance()->getCollectionAttributes(); } /** * get join with admin - for the admin grid * * @access public * @return string * @author Marius Strajeru */ public function getAdminJoin() { return $this->getTypeInstance()->getAdminJoin(); } /** * code above the prepare columns * * @access public * @return string * @author Marius Strajeru */ public function getPrepareColumnsHeader() { return $this->getTypeInstance()->getPrepareColumnsHeader(); } /** * name attribute in grid * * @access public * @return string * @author Marius Strajeru */ public function getNameAttributeGridEav() { return $this->getTypeInstance()->getNameAttributeGridEav(); } /** * check if the frontend list block can be created * * @access public * @return bool * @author Marius Strajeru */ public function getCanCreateListBlock() { if ($this->getCreateList()) { return true; } if ($this->getShowOnProduct()) { return true; } if ($this->getShowOnCategory()) { return true; } //check for siblings with frontend view $related = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($related as $r) { if ($r->getCreateView()) { return true; } } //check for parents with frontend view $related = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD ); foreach ($related as $r) { if ($r->getCreateView()) { return true; } } return false; } /** * get ddl text for attributes * * @access public * @return bool * @author Marius Strajeru */ public function getAttributesDdlSql() { $padding = $this->getPadding(); $eol = $this->getEol(); $content = ''; $content .= $this->getParentEntitiesFkAttributes($padding, true); if ($this->getIsFlat()) { foreach ($this->getAttributes() as $attribute) { $content .= $padding.$attribute->getDdlSqlColumn().$eol; } } if ($this->getIsFlat()) { $simulated = $this->getSimulatedAttributes(null, false); } elseif ($this->getIsTree()) { $simulated = $this->getSimulatedAttributes('tree', false); } else { $simulated = array(); } foreach ($simulated as $attr) { $content .= $padding.$attr->getDdlSqlColumn().$eol; } return substr($content, 0, strlen($content) - strlen($eol)); } /** * get foreign key columns * * @access public * @param $padding * @return string * @author Marius Strajeru */ public function getParentEntitiesFkAttributes($padding) { if ($this->getIsEav()) { return ''; } $parents = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD ); $content = ''; foreach ($parents as $parent) { /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode($parent->getPlaceholders('{{entity}}').'_id'); $attr->setLabel($parent->getPlaceholders('{{EntityLabel}}'). ' ID'); $attr->setType('int'); $content .= $padding.$attr->getDdlSqlColumn()."\n"; } return $content; } /** * get simulated attributes * * @access public * @param mixed $type * @param bool $ignoreSettings * @param array $except * @return Ultimate_ModuleCreator_Model_Attribute[] * @author Marius Strajeru */ public function getSimulatedAttributes($type = null, $ignoreSettings = false, $except = array()) { /** @var Ultimate_ModuleCreator_Model_Attribute[] $attributes */ $attributes = array(); $namespace = $this->getNamespace(true); if (is_null($type)) { $types = array('status', 'url_rewrite', 'tree', 'rss', 'seo', 'comment'); $attributes = array(); foreach ($types as $type) { if (!in_array($type, $except)) { $attributes = array_merge($attributes, $this->getSimulatedAttributes($type, $ignoreSettings)); } } return $attributes; } switch ($type) { case 'status': /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('status'); $attr->setLabel('Enabled'); $attr->setType('yesno'); $attr->setDefaultValue('1'); $attributes[] = $attr; break; case 'url_rewrite': if ($this->getUrlRewrite() || $ignoreSettings) { /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('url_key'); $attr->setLabel('URL key'); $attr->setType('text'); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $attr->setForcedSetupBackend($namespace.'_'.$module.'/'.$entity.'_attribute_backend_urlkey'); $attributes[] = $attr; } break; case 'tree' : if ($this->getIsTree() || $ignoreSettings) { /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('parent_id'); $attr->setLabel('Parent id'); $attr->setType('int'); $attributes[] = $attr; /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('path'); $attr->setLabel('Path'); $attr->setType('text'); $attr->setIgnoreApi(true); $attributes[] = $attr; /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('position'); $attr->setLabel('Position'); $attr->setType('int'); $attr->setIgnoreApi(true); $attributes[] = $attr; /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('level'); $attr->setLabel('Level'); $attr->setType('int'); $attr->setIgnoreApi(true); $attributes[] = $attr; /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('children_count'); $attr->setLabel('Children count'); $attr->setType('int'); $attr->setIgnoreApi(true); $attributes[] = $attr; } break; case 'rss': if ($this->getRss() || $ignoreSettings) { /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('in_rss'); $attr->setLabel('In RSS'); $attr->setType('yesno'); $attr->setDefaultValue('1'); $attributes[] = $attr; } break; case 'seo': if ($this->getAddSeo() || $ignoreSettings) { /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('meta_title'); $attr->setLabel('Meta title'); $attr->setType('text'); $attributes[] = $attr; /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('meta_keywords'); $attr->setLabel('Meta keywords'); $attr->setType('textarea'); $attributes[] = $attr; $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('meta_description'); $attr->setLabel('Meta description'); $attr->setType('textarea'); $attributes[] = $attr; } break; case 'comment': if ($this->getAllowComment() || $ignoreSettings) { /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode('allow_comment'); $attr->setLabel('Allow Comment'); $attr->setType('dropdown'); $attr->setOptionsSource('custom'); $attr->setOptions(false); $attr->setEntity($this); $attr->setDefaultValue('2'); $attr->setForcedDefaultValue('2'); $attr->setForcedSource( $namespace.'_'.$this->getModule()->getLowerModuleName(). '/adminhtml_source_yesnodefault' ); $attributes[] = $attr; } break; default: break; } foreach ($attributes as $attribute) { $attribute->setUserDefined(false); } return $attributes; } /** * get layout xml head reference * * @access public * @return string * @author Marius Strajeru */ public function getReferenceHeadLayout() { $eol = $this->getEol(); $content = $this->getPadding(2); if ($this->getIsTree()) { $namespace = $this->getNamespace(true); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $content .= ''.$eol; $content .= $this->getPadding(3). 'skin_jsjs/'.$namespace.'_'.$module.'/tree.js'.$eol; $content .= $this->getPadding(2).''.$eol; $content .= $this->getPadding(2); } return $content; } /** * get layout xml for relation to product * * @access public * @return string * @author Marius Strajeru */ public function getRelationLayoutXml() { $eol = $this->getEol(); $content = $this->getPadding(2); $module = $this->getModule()->getLowerModuleName(); $entityName = $this->getNameSingular(true); $namespace = $this->getNamespace(true); if ($this->getIsTree()) { $content .= $this->getPadding().''.$eol.$this->getPadding(2); } if ($this->getShowProducts()) { $content .= $this->getPadding().''. $eol.$this->getPadding(2); } if ($this->getShowCategory()) { $content .= $this->getPadding().''.$eol.$this->getPadding(2); } $children = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT ); $siblings = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); /** @var Ultimate_ModuleCreator_Model_Entity[] $relatedEntities */ $relatedEntities = array_merge($children, $siblings); foreach ($relatedEntities as $entity) { $content .= $this->getPadding().''.$eol.$this->getPadding(2); } if ($this->getAllowComment()) { $content .= $this->getPadding().''.$eol.$this->getPadding(2); $content .= $this->getPadding(2). ''.$eol.$this->getPadding(2); $content .= $this->getPadding().''.$eol.$this->getPadding(2); } return $content; } /** * get html link to entity * * @access public * @return string * @author Marius Strajeru */ public function getHtmlLink() { $eol = $this->getEol(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($this->getNameSingular()); $nameCode = $this->getNameAttributeMagicCode(); $content = ''; $padd = 3; if ($this->getCreateView()) { $padd = 4; $content .= $this->getPadding(3).''.$eol; } $content .= $this->getPadding($padd).'get'.$nameCode.'();?>'.$eol; if ($this->getCreateView()) { $content .= $this->getPadding(3).''; } $content .= '
    '; return $content; } /** * get the html for attributes in view page * * @access public * @return string * @author Marius Strajeru */ public function getViewAttributesHtml() { $eol = $this->getEol(); $content = ''; foreach ($this->getAttributes() as $attribute) { if ($attribute->getFrontend()) { $content .= $this->getPadding(). '
    '.$eol; $content .= $this->getPadding(2).$attribute->getFrontendHtml().$eol; $content .= $this->getPadding().'
    '.$eol; } } return $content; } /** * check if comments should be split by store * * @access public * @return bool * @author Marius Strajeru */ public function getAllowCommentByStore() { return $this->getTypeInstance()->getAllowCommentByStore(); } /** * get view widget attributes * * @access public * @return string * @author Marius Strajeru */ public function getViewWidgetAttributesHtml() { $content = ''; $padding = $this->getPadding(3); $tab = $this->getPadding(); $eol = $this->getEol(); foreach ($this->getAttributes() as $attribute) { if ($attribute->getWidget()) { $content .= $padding.'
    '. $eol.$padding.$tab.$attribute->getFrontendHtml().$padding.'
    '.$eol; } } return $content; } /** * get the system attributes * * @access public * @return string * @author Marius Strajeru */ public function getSystemAttributes() { $position = 10; $content = ''; $tab = $this->getPadding(); $eol = $this->getEol(); $padding = str_repeat($tab, 6); if ($this->getCreateFrontend()) { $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'select'.$eol; $content .= $padding.$tab.'adminhtml/system_config_source_yesno'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.''.$eol; $position += 10; } if ($this->getUrlRewrite()) { $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'text'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'Leave empty to use default URL module/controller/action'.$eol; $content .= $padding.''.$eol; $position += 10; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'text'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'Leave empty for no prefix'.$eol; $content .= $padding.''.$eol; $position += 10; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'text'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'What goes after the dot. Leave empty for no suffix.'.$eol; $content .= $padding.''.$eol; $position += 10; } if ($this->getAllowComment()) { $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'select'.$eol; $content .= $padding.$tab.'adminhtml/system_config_source_yesno'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.''.$eol; $position += 10; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'select'.$eol; $content .= $padding.$tab.'adminhtml/system_config_source_yesno'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'1'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $position += 10; } if ($this->getRss()) { $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'select'.$eol; $content .= $padding.$tab.'adminhtml/system_config_source_yesno'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.''.$eol; $position += 10; } if ($this->getIsTree() && $this->getCreateList()) { $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'select'.$eol; $content .= $padding.$tab.'adminhtml/system_config_source_yesno'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.''.$eol; $position += 10; } if ($this->getIsTree() && ($this->getCreateList() || $this->getWidget())) { $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'text'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.''.$eol; $position += 10; } if ($this->getAddSeo() && $this->getCreateList()) { $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'text'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.''.$eol; $position += 10; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'textarea'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.''.$eol; $position += 10; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.'textarea'.$eol; $content .= $padding.$tab.''.$position.''.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.$tab.'1'.$eol; $content .= $padding.''.$eol; } return substr($content, 0, strlen($content) - strlen($eol)); } /** * get additional api xml * * @access public * @return string * @author Marius Strajeru */ public function getApiAdditional() { $content = $this->getApiTree(); $content .= $this->getTypeInstance()->getApiAdditional(); $content .= $this->getApiRelations(); return $content; } /** * get additional api xml for tree entities * * @access public * @return string * @author Marius Strajeru */ public function getApiTree() { $content = ''; $padding = $this->getPadding(); $prefix = str_repeat($padding, 5); $eol = $this->getEol(); $extension = $this->getModule()->getExtensionName(true); if ($this->getIsTree()) { $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityLabel = strtolower($this->getLabelSingular()); $entitiesLabel = strtolower($this->getLabelPlural()); $content = $prefix.''.$eol; $content .= $prefix.$padding.'Retrieve one level of '.$entitiesLabel.''.$eol; $content .= $prefix.$padding.''.$module.'/'.$entity.'/info'.$eol; $content .= $prefix.''.$eol; $content .= $prefix.''.$eol; $content .= $prefix.$padding.'Move '.$entityLabel.' in tree'.$eol; $content .= $prefix.$padding.''.$module.'/'.$entity.'/move'.$eol; $content .= $prefix.''.$eol; } return $content; } /** * get api relations for a section * * @access public * @param $relatedCode * @param $relatedLabel * @return string * @author Marius Strajeru */ public function getApiRelationsSection($relatedCode, $relatedLabel) { $eol = $this->getEol(); $padding = $this->getPadding(); $prefix = $this->getPadding(5); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityLabelUc = ucfirst($this->getLabelSingular()); $entityLabel = strtolower($this->getLabelSingular()); $extension = $this->getModule()->getExtensionName(true); $string = ''; $string .= $prefix. ''.$eol; $string .= $prefix.$padding. 'Assign '.$relatedLabel.' to '.$entityLabelUc.''.$eol; $string .= $prefix.$padding. ''.$module.'/'.$entity.'/update'.$eol; $string .= $prefix. ''.$eol; $string .= $prefix. ''.$eol; $string .= $prefix.$padding. 'Remove '.$relatedLabel.' from '.$entityLabel.''.$eol; $string .= $prefix.$padding. ''.$module.'/'.$entity.'/update'.$eol; $string .= $prefix. ''.$eol; return $string; } /** * get API xml for entity relations * * @access public * @return string * @author Marius Strajeru */ public function getApiRelations() { $string = ''; if ($this->getLinkProduct()) { $string .= $this->getApiRelationsSection('Product', 'product'); } if ($this->getLinkCategory()) { $string .= $this->getApiRelationsSection('Category', 'category'); } $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING); foreach ($siblings as $sibling) { $siblingNameUc = ucfirst($sibling->getNameSingular()); $siblingLabel = strtolower($sibling->getLabelSingular()); $string .= $this->getApiRelationsSection($siblingNameUc, $siblingLabel); } $string .= $this->getPadding(4); return $string; } /** * get API faults for a section * * @access public * @param $relatedCode * @param $relatedLabel * @param $code * @return string * @author Marius Strajeru */ public function getApiFaultsSection($relatedCode, $relatedLabel, $code) { $padding = $this->getPadding(); $prefix = str_repeat($padding, 5); $eol = $this->getEol(); $string = ''; $string .= $prefix.'<'.$relatedCode.'_not_exists>'.$eol; $string .= $prefix.$padding.''.$code.''.$eol; $string .= $prefix.$padding.''.$relatedLabel.' does not exist.'.$eol; $string .= $prefix.''.$eol; return $string; } /** * get list of faults for API * * @access public * @return string * @author Marius Strajeru */ public function getApiFaults() { $string = ''; $padding = $this->getPadding(); $prefix = str_repeat($padding, 5); $eol = $this->getEol(); $code = 105; $entity = $this->getNameSingular(true); $entityLabelUc = ucfirst($this->getLabelSingular()); if ($this->getIsTree()) { $string .= $prefix.''.$eol; $string .= $prefix.$padding.''.$code.''.$eol; $string .= $prefix.$padding.''. $entityLabelUc.' not moved. Details in error message.'.$eol; $string .= $prefix.''.$eol; $code++; } if ($this->getLinkProduct()) { $string .= $this->getApiFaultsSection('product', 'Product', $code); $code++; } if ($this->getLinkCategory()) { $string .= $this->getApiFaultsSection('category', 'Category', $code); $code++; } $siblings = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($siblings as $sibling) { $siblingName = $sibling->getNameSingular(true); $siblingLabelUc = ucfirst($sibling->getLabelSingular()); $string .= $this->getApiFaultsSection($entity.'_'.$siblingName, $siblingLabelUc, $code); $code++; } $string .= $this->getTypeInstance()->getApiFaults(); $string .= str_repeat($padding, 4); return $string; } /** * get additional api acl * * @access public * @return string * @author Marius Strajeru */ public function getAdditionalApiAcl() { $content = ''; $padding = $this->getPadding(); $prefix = str_repeat($padding, 6); $eol = $this->getEol(); $extension = $this->getModule()->getExtensionName(true); if ($this->getIsTree()) { $content .= $prefix.''.$eol; $content .= $prefix.$padding.'Move'.$eol; $content .= $prefix.''.$eol; } $content .= str_repeat($padding, 5); return $content; } /** * get attributes format for wsdl * * @access public * @param bool $wsi * @param bool $forAdd * @return string * @author Marius Strajeru */ public function getWsdlAttributes($wsi = false, $forAdd = false) { $parents = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD ); $tab = $this->getPadding(); $padding = str_repeat($tab, 5); $eol = $this->getEol(); $content = ''; foreach ($parents as $parent) { /** @var Ultimate_ModuleCreator_Model_Attribute $attr */ $attr = Mage::getModel('modulecreator/attribute'); $attr->setCode($parent->getNameSingular().'_id'); $attr->setLabel($parent->getLabelSingular()); $attr->setType('int'); $content .= $padding.$attr->getWsdlFormat($wsi).$eol; } foreach ($this->getAttributes() as $attribute) { $content .= $padding.$attribute->getWsdlFormat($wsi).$eol; } $simulated = $this->getSimulatedAttributes(null, false); foreach ($simulated as $attr) { if (!$forAdd || !$attr->getIgnoreApi()) { $content .= $padding.$attr->getWsdlFormat($wsi).$eol; } } $content .= $this->getTypeInstance()->getWsdlAttributes($wsi); return $content; } /** * get attributes format for wsi * * @access public * @param bool $forAdd * @return string * @author Marius Strajeru */ public function getWsiAttributes($forAdd = false) { return $this->getWsdlAttributes(true, $forAdd); } /** * get wsdl relation type for a section * * @param $relatedCode * @param $relatedId * @param bool $wsi * @return string */ public function getWsdlRelationTypesSection($relatedCode, $relatedId, $wsi = false) { $content = ''; $tab = $this->getPadding(); $padding = str_repeat($tab, 3); $mainTag = ($wsi) ? 'xsd:complexType':'complexType'; $subtag = ($wsi) ? 'xsd:sequence' : 'all'; $element = ($wsi) ? 'xsd:element' : 'element'; $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($this->getNameSingular()); $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'Assign'.$relatedCode.'Entity">'.$eol; $content .= $padding.$tab.'<'.$subtag.'>'.$eol; $content .= $padding.$tab.'<'.$element.' name="'.$entity.'Id" type="xsd:string"'. ((!$wsi)?' minOccurs="1"':'').' />'.$eol; $content .= $padding.$tab.'<'.$element.' name="'.$relatedId.'Id" type="xsd:string"'. ((!$wsi)?' minOccurs="1"':'').' />'.$eol; $content .= $padding.$tab.'<'.$element.' name="position" type="xsd:string"'. ((!$wsi)?' minOccurs="0"':'').' />'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'Unassign'.$relatedCode.'Entity">'.$eol; $content .= $padding.$tab.'<'.$subtag.'>'.$eol; $content .= $padding.$tab.'<'.$element.' name="'. $entity.'Id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol; $content .= $padding.$tab.'<'.$element.' name="'. $relatedId.'Id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; return $content; } /** * get entity WSDL relation types * * @access public * @param bool $wsi * @return string * @author Marius Strajeru */ public function getWsdlRelationTypes($wsi = false) { $content = ''; $tab = $this->getPadding(); $padding = str_repeat($tab, 3); $mainTag = ($wsi) ? 'xsd:complexType':'complexType'; $subtag = ($wsi) ? 'xsd:sequence' : 'all'; $element = ($wsi) ? 'xsd:element' : 'element'; $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($this->getNameSingular()); if ($this->getIsTree()) { $content .= $padding.'<'.$mainTag .' name="'.$module.$entityUc.'MoveEntity">'.$eol; $content .= $padding.$tab.'<'.$subtag.'>'.$eol; $content .= $padding.$tab.'<'.$element. ' name="'.$entity.'_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol; $content .= $padding.$tab.'<'.$element. ' name="parent_id" type="xsd:string"'.((!$wsi)?' minOccurs="1"':'').' />'.$eol; $content .= $padding.$tab.'<'.$element. ' name="after_id" type="xsd:string"'.((!$wsi)?' minOccurs="0"':'').' />'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; } if ($this->getLinkProduct()) { $content .= $this->getWsdlRelationTypesSection('Product', 'product', $wsi); } if ($this->getLinkCategory()) { $content .= $this->getWsdlRelationTypesSection('Category', 'category', $wsi); } $siblings = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($siblings as $sibling) { $siblingName = $sibling->getNameSingular(true); $siblingNameUc = ucfirst($sibling->getNameSingular()); $content .= $this->getWsdlRelationTypesSection($siblingNameUc, $siblingName, $wsi); } $content .= $tab.$tab; return $content; } /** * get entity WSI relation types * * @access public * @return string * @author Marius Strajeru */ public function getWsiRelationTypes() { return $this->getWsdlRelationTypes(true); } /** * get wsdl port type relations for a section * * @access public * @param $relatedLabel * @param $relatedText * @param $wsi * @return string * @author Marius Strajeru */ public function getWsdlPortTypeRelationSection($relatedLabel, $relatedText, $wsi) { $content = ''; $tab = $this->getPadding(); $padding = $tab.$tab; $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entityUc = ucfirst($this->getNameSingular()); $label = strtolower($this->escapeText($this->getLabelSingular())); $tagPrefix = ($wsi) ? 'wsdl:':''; $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'Assign'.$relatedLabel.'">'.$eol; $content .= $padding.$tab.'<'.$tagPrefix.'documentation>Assign '. $relatedText.' to '.$label.''.$eol; $content .= $padding.$tab.'<'.$tagPrefix.'input message="typens:'. $module.$entityUc.'Assign'.$relatedLabel.'Request" />'.$eol; $content .= $padding.$tab.'<'.$tagPrefix.'output message="typens:'. $module.$entityUc.'Assign'.$relatedLabel.'Response" />'.$eol; $content .= $padding.''.$eol; $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'Unassign'.$relatedLabel.'">'.$eol; $content .= $padding.$tab.'<'.$tagPrefix.'documentation>Remove '. $relatedText.' from '.$label.''.$eol; $content .= $padding.$tab.'<'.$tagPrefix.'input message="typens:'. $module.$entityUc.'Unassign'.$relatedLabel.'Request" />'.$eol; $content .= $padding.$tab.'<'.$tagPrefix.'output message="typens:'. $module.$entityUc.'Unassign'.$relatedLabel.'Response" />'.$eol; $content .= $padding.''.$eol; return $content; } /** * get entity WSDL port type for relations * * @access public * @param bool $wsi * @return string * @author Marius Strajeru */ public function getWsdlPortTypeRelation($wsi = false) { $content = ''; $tab = $this->getPadding(); $padding = $tab.$tab; $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($entity); $label = strtolower($this->escapeText($this->getLabelSingular())); $tagPrefix = ($wsi) ? 'wsdl:':''; if ($this->getIsTree()) { $content .= $padding.'<'.$tagPrefix.'operation name="'.$module.$entityUc.'Move">'.$eol; $content .= $padding.$tab.'<'.$tagPrefix.'documentation>Move '.$label. ' in tree'.$eol; $content .= $padding.$tab.'<'.$tagPrefix.'input message="typens:'.$module.$entityUc.'MoveRequest" />'.$eol; $content .= $padding.$tab.'<'.$tagPrefix.'output message="typens:'. $module.$entityUc.'MoveResponse" />'.$eol; $content .= $padding.''.$eol; } if ($this->getLinkProduct()) { $content .= $this->getWsdlPortTypeRelationSection('Product', 'product', $wsi); } if ($this->getLinkCategory()) { $content .= $this->getWsdlPortTypeRelationSection('Category', 'category', $wsi); } $siblings = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($siblings as $sibling) { $siblingNameUc = ucfirst($sibling->getNameSingular()); $siblingLabel = strtolower($sibling->getLabelSingular()); $content .= $this->getWsdlPortTypeRelationSection($siblingNameUc, $siblingLabel, $wsi); } $content .= $tab; return $content; } /** * get entity WSI port type for relations * * @access public * @return string * @author Marius Strajeru */ public function getWsiPortTypeRelation() { return $this->getWsdlPortTypeRelation(true); } /** * get wsld relation binding for a section * * @access public * @param $sectionName * @return string * @author Marius Strajeru */ public function getWsdlRelationBindingSection($sectionName) { $content = ''; $tab = $this->getPadding(); $doubleTab = $tab.$tab; $padding = $doubleTab; $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($entity); $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$doubleTab. ''. $eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$doubleTab. ''. $eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; return $content; } /** * get WSDL relation binding * * @access public * @return string * @author Marius Strajeru */ public function getWsdlRelationBinding() { $content = ''; if ($this->getIsTree()) { $content .= $this->getWsdlRelationBindingSection('Move'); } if ($this->getLinkProduct()) { $content .= $this->getWsdlRelationBindingSection('AssignProduct'); $content .= $this->getWsdlRelationBindingSection('UnassignProduct'); } if ($this->getLinkCategory()) { $content .= $this->getWsdlRelationBindingSection('AssignCategory'); $content .= $this->getWsdlRelationBindingSection('UnassignCategory'); } $siblings = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($siblings as $sibling) { $siblingName = $sibling->getNameSingular(true); $siblingNameUc = ucfirst($siblingName); $content .= $this->getWsdlRelationBindingSection('Assign'.$siblingNameUc); $content .= $this->getWsdlRelationBindingSection('Unassign'.$siblingNameUc); } $content .= $this->getPadding(); return $content; } /** * get wsld relation binding for a section * * @access public * @param $sectionName * @return string * @author Marius Strajeru */ public function getWsiRelationBindingSection($sectionName) { $content = ''; $tab = $this->getPadding(); $doubleTab = $tab.$tab; $padding = $doubleTab; $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($entity); $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$doubleTab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$doubleTab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; return $content; } /** * get WSI relation binding * * @access public * @return string * @author Marius Strajeru */ public function getWsiRelationBinding() { $content = ''; if ($this->getIsTree()) { $content .= $this->getWsiRelationBindingSection('Move'); } if ($this->getLinkProduct()) { $content .= $this->getWsiRelationBindingSection('AssignProduct'); $content .= $this->getWsiRelationBindingSection('UnassignProduct'); } if ($this->getLinkCategory()) { $content .= $this->getWsiRelationBindingSection('AssignCategory'); $content .= $this->getWsiRelationBindingSection('UnassignCategory'); } $siblings = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($siblings as $sibling) { $siblingName = $sibling->getNameSingular(true); $siblingNameUc = ucfirst($siblingName); $content .= $this->getWsiRelationBindingSection('Assign'.$siblingNameUc); $content .= $this->getWsiRelationBindingSection('Unassign'.$siblingNameUc); } $content .= $this->getPadding(); return $content; } /** * get wsi relation param types for a section * * @access public * @param $sectionName * @param $sectionParam * @return string * @author Marius Strajeru */ public function getWsiRelationParamTypesSection($sectionName, $sectionParam) { $content = ''; $tab = $this->getPadding(); $padding = $this->getPadding(3); $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($entity); $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; return $content; } /** * get entity WSI relation param types * * @access public * @return string * @author Marius Strajeru */ public function getWsiRelationParamTypes() { $content = ''; $tab = $this->getPadding(); $padding = str_repeat($tab, 3); $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($entity); if ($this->getIsTree()) { $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.str_repeat($tab, 3). ''.$eol; $content .= $padding.str_repeat($tab, 2).''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; } if ($this->getLinkProduct()) { $content .= $this->getWsiRelationParamTypesSection('Product', 'product'); } if ($this->getLinkCategory()) { $content .= $this->getWsiRelationParamTypesSection('Category', 'category'); } $siblings = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($siblings as $sibling) { $siblingName = $sibling->getNameSingular(true); $siblingNameUc = ucfirst($siblingName); $content .= $this->getWsiRelationParamTypesSection($siblingNameUc, $siblingName); } $content .= $tab.$tab; return $content; } /** * get wsi relation messaged for a section * * @param $sectionName * @return string * @author Marius Strajeru */ public function getWsiRelationMessagesSection($sectionName) { $content = ''; $padding = $this->getPadding(); $tab = $padding; $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($entity); $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; return $content; } /** * get entity WSI relation messages * * @access public * @return string * @author Marius Strajeru */ public function getWsiRelationMessages() { $content = ''; if ($this->getIsTree()) { $content .= $this->getWsiRelationMessagesSection('Move'); } if ($this->getLinkProduct()) { $content .= $this->getWsiRelationMessagesSection('AssignProduct'); $content .= $this->getWsiRelationMessagesSection('UnassignProduct'); } if ($this->getLinkCategory()) { $content .= $this->getWsiRelationMessagesSection('AssignCategory'); $content .= $this->getWsiRelationMessagesSection('UnassignCategory'); } $siblings = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING); foreach ($siblings as $sibling) { $siblingName = $sibling->getNameSingular(true); $siblingNameUc = ucfirst($siblingName); $content .= $this->getWsiRelationMessagesSection('Assign'.$siblingNameUc); $content .= $this->getWsiRelationMessagesSection('Unassign'.$siblingNameUc); } return $content; } /** * get wsdl messages for a section * * @param $sectionName * @param $sectionParam * @return string * @author Marius Strajeru */ public function getWsdlMessagesSection($sectionName, $sectionParam) { $content = ''; $tab = $this->getPadding(); $padding = $tab.$tab; $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($entity); $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; return $content; } /** * get entity WSDL messages for relations * * @access public * @return string * @author Marius Strajeru */ public function getWsdlMessages() { $content = ''; $tab = $this->getPadding(); $padding = $tab.$tab; $eol = $this->getEol(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $entityUc = ucfirst($entity); if ($this->getIsTree()) { $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; } if ($this->getLinkProduct()) { $content .= $this->getWsdlMessagesSection('Product', 'product'); } if ($this->getLinkCategory()) { $content .= $this->getWsdlMessagesSection('Category', 'category'); } $siblings = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($siblings as $sibling) { $siblingName = $sibling->getNameSingular(true); $siblingNameUc = ucfirst($siblingName); $content .= $this->getWsdlMessagesSection($siblingNameUc, $siblingName); } $content .= $tab; return $content; } /** * get foreign keys for sql (Ddl) * * @access public * @return string * @author Marius Strajeru */ public function getParentEntitiesFksDdl() { $padding = $this->getPadding(); $eol = $this->getEol(); $parents = $this->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD ); $content = ''; $module = $this->getModule()->getLowerModuleName(); $namespace = $this->getNamespace(true); foreach ($parents as $parent) { $parentName = $parent->getNameSingular(true); $content .= $eol.$padding."->addIndex($"."this->getIdxName('". $namespace.'_'.$module.'/'.$parentName."', array('".$parentName."_id')), array('". $parentName."_id'))"; } return $content; } /** * get selected menu path * * @access public * @param string $suffix * @return string * @author Marius Strajeru */ public function getSelectedMenuPath($suffix = '') { $path = $this->getModule()->getMenuParent(); if (!empty($path)) { $path .= '/'; } $path .= $this->getModule()->getExtensionName(true).'/'; $path .= $this->getNameSingular(true); return $path . $suffix; } /** * get attributes content for setup * * @access public * @return string * @author Marius Strajeru */ public function getAttributesSetup() { return $this->getTypeInstance()->getAttributesSetup(); } /** * get parent class for the entity resource model * * @access public * @return string * @author Marius Strajeru */ public function getResourceModelParent() { return $this->getTypeInstance()->getResourceModelParent(); } /** * get parent class for the entity resource model * * @access public * @return string * @author Marius Strajeru */ public function getResourceCollectionModelParent() { return $this->getTypeInstance()->getResourceCollectionModelParent(); } /** * get related entities relations table * * @access public * @return string * @author Marius Strajeru */ public function getResourceRelationsTables() { return $this->getTypeInstance()->getResourceRelationsTables(); } /** * get related entities relations table declaration * * @access public * @return string * @author Marius Strajeru */ public function getResourceRelationsTablesDeclare() { return $this->getTypeInstance()->getResourceRelationsTablesDeclare(); } /** * get admin layout content for index page * * @access public * @return string * @author Marius Strajeru */ public function getAdminIndexLayoutContent() { return $this->getTypeInstance()->getAdminIndexLayoutContent(); } /** * get the parent model class * * @access public * @return mixed * @author Marius Strajeru */ public function getEntityParentModel() { return $this->getTypeInstance()->getEntityParentModel(); } /** * get entity table alias * * @access public * @return mixed * @author Marius Strajeru */ public function getEntityTableAlias() { return $this->getTypeInstance()->getEntityTableAlias(); } /** * get additional prepare collection * * @access public * @return mixed * @author Marius Strajeru */ public function getAdditionalPrepareCollection() { return $this->getTypeInstance()->getAdditionalPrepareCollection(); } /** * additional layout block for left section * * @access public * @return mixed * @author Marius Strajeru */ public function getEditLayoutLeft() { return $this->getTypeInstance()->getEditLayoutLeft(); } /** * additional layout block edit * * @access public * @return mixed * @author Marius Strajeru */ public function getEditLayoutAdditional() { return $this->getTypeInstance()->getEditLayoutAdditional(); } /** * get the label for product attribute scope * * @access public * @return string * @author Marius Strajeru */ public function getProductAttributeScopeLabel() { return $this->_getScopeLabel($this->getProductAttributeScope()); } /** * get the label for category attribute scope * * @access public * @return string * @author Marius Strajeru */ public function getCategoryAttributeScopeLabel() { return $this->_getScopeLabel($this->getCategoryAttributeScope()); } /** * get scope label for install scripts * * @param $value * @return string * @author Marius Strajeru */ protected function _getScopeLabel($value) { $values = array( Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL' ); if (!isset($values[$value])) { $value = Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL; } return $values[$value]; } /** * check if the entity is used as an attribute * * @access public * @return bool * @author Marius Strajeru */ public function getIsAttribute() { return $this->getProductAttribute() || $this->getCategoryAttribute(); } /** * check if source model can be created * * @access public * @return bool * @author Marius Strajeru */ public function getCanCreateSourceModel() { return $this->getIsAttribute() || $this->getIsParent(); } /** * check if entity has children * * @access public * @return bool * @author Marius Strajeru */ public function getIsParent() { $children = $this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT); return count($children) > 0; } /** * get product attribute group * * @access public * @return string * @author Marius Strajeru */ public function getProductAttributeGroupLabel() { if ($this->getProductAttributeGroup()) { return "'group' => '".$this->getProductAttributeGroup()."',". $this->getEol().$this->getPadding(2); } return ''; } /** * get category attribute group * * @access public * @return string * @author Marius Strajeru */ public function getCategoryAttributeGroupLabel() { if ($this->getCategoryAttributeGroup()) { return "'group' => '".$this->getCategoryAttributeGroup(). "',".$this->getEol().$this->getPadding(2); } return ''; } /** * get param name for before save * * @access public * @return mixed * @author Marius Strajeru */ public function getBeforeSaveParam() { return $this->getTypeInstance()->getBeforeSaveParam(); } /** * entity attribute set string * * @access public * @return string * @author Marius Strajeru */ public function getEntityAttributeSetId() { return $this->getTypeInstance()->getEntityAttributeSetId(); } /** * filter method name * * @access public * @return string * @author Marius Strajeru */ public function getFilterMethod() { return $this->getTypeInstance()->getFilterMethod(); } /** * convert multiple select fields to strings * * @access public * @return mixed * @author Marius Strajeru */ public function getMultipleSelectConvert() { return $this->getTypeInstance()->getMultipleSelectConvert(); } /** * check if the entity helper can be created * * @access public * @return bool * @author Marius Strajeru */ public function getCanCreateEntityHelper() { if ($this->getIsTree()) { return true; } if ($this->getHasFile()) { return true; } if ($this->getCreateFrontend()) { return true; } return $this->getTypeInstance()->getCanCreateEntityHelper(); } /** * get additional code for toOptionArray() * * @access public * @return string * @author Marius Strajeru */ public function getToOptionAddition() { return $this->getTypeInstance()->getToOptionAddition(); } /** * check if entity should be included in the category menu * * @access public * @return bool * @author Marius Strajeru */ public function getShowInCategoryMenu() { return $this->getListMenu() == Ultimate_ModuleCreator_Model_Source_Entity_Menu::CATEGORY_MENU; } /** * get multiselect methods * * @access public * @return string * @author Marius Strajeru */ public function getMultiselectMethods() { $content = ''; $padding = $this->getPadding(); $tab = $this->getPadding(); $eol = $this->getEol(); foreach ($this->getAttributes() as $attribute) { $magicCode = $attribute->getMagicMethodCode(); $code = $attribute->getCode(); if ($attribute->getTypeInstance() instanceof Ultimate_ModuleCreator_Model_Attribute_Type_Multiselect) { $content .= $eol.$padding.'/**'.$eol; $content .= $padding.' * get '.$attribute->getLabel().$eol; $content .= $padding.' *'.$eol; $content .= $padding.' * @access public'.$eol; $content .= $padding.' * @return array'.$eol; $content .= $padding.' * '.$this->getModule()->getQwertyuiop().$eol; $content .= $padding.' */'.$eol; $content .= $padding.'public function get'.$magicCode.'()'.$eol; $content .= $padding.'{'.$eol; $content .= $padding.$tab.'if (!$this->getData(\''.$code.'\')) {'.$eol; $content .= $padding.$tab.$tab.'return explode(\',\', $this->getData(\''.$code.'\'));'.$eol; $content .= $padding.$tab.'}'.$eol; $content .= $padding.$tab.'return $this->getData(\''.$code.'\');'.$eol; $content .= $padding.'}'; } } return $content; } /** * get html for displaying the name * * @access public * @return string * @author Marius Strajeru */ public function getNameHtml() { $content = ''; $lower = $this->getNameSingular(true); $ucFirst = ucfirst($lower); $name = $this->getNameAttributeMagicCode(); if ($this->getCreateView()) { $content .= '\'\'.$'.$lower.'->get'.$name.'().\'\''; } else { $content .= '\'\'.$'.$lower.'->get'.$name.'().\'\''; } return $content; } /** * check if the entity is not store related * * @access public * @return bool * @author Marius Strajeru */ public function getNoStore() { return !$this->getStore(); } /** * get comment name field filter index * * @access public * @return string * @author Marius Strajeru */ public function getCommentFilterIndexPrefix() { return $this->getTypeInstance()->getCommentFilterIndexPrefix(); } /** * additional API subentities. * * @access public * @return string * @author Marius Strajeru */ public function getApiAdditionalSettings() { $content = ''; if ($this->getAllowComment()) { $padding = $this->getPadding(3); $tab = $this->getPadding(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $eol = $this->getEol(); $title = $this->getLabelSingular().' Comments'; $ns = $this->getNamespace(true); $content .= $eol; $content .= $padding.'<'.$module.'_'.$entity.'_comment translate="title" module="'. $ns.'_'.$module.'">'.$eol; $content .= $padding.$tab.''.$title.''.$eol; $content .= $padding.$tab.''.$ns.'_'.$module.'/'.$entity.'_comment_api'.$eol; $content .= $padding.$tab.''.$module.'/'.$entity.'/comment'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Retrieve '.$title.''.$eol; $content .= $padding.$tab.$tab.$tab.'items'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_comment/list'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'Update '.$this->getLabelSingular().' Status'.$eol; $content .= $padding.$tab.$tab.$tab.'updateStatus'.$eol; $content .= $padding.$tab.$tab.$tab.''.$module.'/'.$entity.'_comment/updateStatus'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'101'.$eol; $content .= $padding.$tab.$tab.$tab.'Requested comment not found.'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; } $content .= $this->getTypeInstance()->getApiAdditionalSettings(); return $content; } /** * get subentities acl * * @access public * @return string * @author Marius Strajeru */ public function getSubEntitiesAcl() { $content = ''; if ($this->getAllowComment()) { $padding = $this->getPadding(5); $tab = $this->getPadding(); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $eol = $this->getEol(); $title = $this->getLabelSingular().' Comments'; $content .= $eol; $ns = $this->getModule()->getNamespace(true); $content .= $padding.'<'.$entity.'_comment translate="title" module="'.$ns.'_'.$module.'">'.$eol; $content .= $padding.$tab.''.$title.''.$eol; $content .= $padding.$tab.''.($this->getPosition() + 3).''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'List'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.'Update Status'.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; } $content .= $this->getTypeInstance()->getSubEntitiesAcl(); return $content; } /** * get api aliases * * @access public * @return string * @author Marius Strajeru */ public function getApiResourcesAlias() { $content = ''; if ($this->getAllowComment()) { $padding = $this->getPadding(3); $module = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $eol = $this->getEol(); $content .= $eol; $content .= $padding.'<'.$entity.'_comment>'.$module.'_'.$entity.'_comment'; } $content .= $this->getTypeInstance()->getApiResourcesAlias(); return $content; } /** * get api V2 aliases * * @access public * @return string * @author Marius Strajeru */ public function getApiResourcesAliasV2() { $content = ''; if ($this->getAllowComment()) { $padding = $this->getPadding(4); $module = $this->getModule()->getLowerModuleName(); $entity = strtolower($this->getNameSingular()); $eol = $this->getEol(); $content .= $eol; $content .= $padding.'<'.$entity.'_comment>'.$module.ucfirst($entity).'Comment'; } $content .= $this->getTypeInstance()->getApiResourcesAliasV2(); return $content; } /** * get default api attributes * * @access public * @return string * @author Marius Strajeru */ public function getDefaultApiAttributes() { return $this->getTypeInstance()->getDefaultApiAttributes(); } /** * get the module namespace * * @access public * @param bool $lower * @return mixed|string * @author Marius Strajeru */ public function getNamespace($lower = false) { return $this->getModule()->getNamespace($lower); } /** * get entity name * * @access public * @param bool $lower * @return mixed|string * @author Marius Strajeru */ public function getNameSingular($lower = false) { $name = $this->getData('name_singular'); if ($lower) { $name = strtolower($name); } return $name; } /** * get code that filters dates * * @access public * @param int $padding * @return string * @author Marius Strajeru */ public function getFilterDates($padding = 4) { $dateAttributes = array(); foreach ($this->getAttributes() as $attribute) { if ($attribute->getTypeInstance() instanceof Ultimate_ModuleCreator_Model_Attribute_Type_Timestamp) { $dateAttributes[] = $attribute->getCode(); } } if (count($dateAttributes) == 0) { return ''; } return $this->getEol().$this->getPadding($padding). '$data = $this->_filterDates($data, array(\''.implode("' ,'", $dateAttributes).'\'));'; } /** * get add all attributes to collection * * @access public * @return string * @author Marius Strajeru */ public function getAllAttributesToCollection() { return $this->getTypeInstance()->getAllAttributesToCollection(); } /** * get load store id statement * * @access public * @return string * @author Marius Strajeru */ public function getLoadStoreId() { return $this->getTypeInstance()->getLoadStoreId(); } /** * get rest resource group * * @param $padding * @return string * @author Marius Strajeru */ public function getRestResourceGroup($padding) { $content = ''; $eol = $this->getEol(); if ($this->getRest()) { $ns = $this->getNamespace(true); $md = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $content .= $this->getPadding($padding).'<'.$ns.'_'.$md.'_'.$entity. ' translate="title" module="'.$ns.'_'.$md.'">'.$eol; $content .= $this->getPadding($padding + 1).''.$this->getLabelSingular().''.$eol; $content .= $this->getPadding($padding + 1).''.$this->getPosition().''.$eol; $content .= $this->getPadding($padding).''.$eol; } return $content; } /** * get rest resource * * @param $padding * @return string * @author Marius Strajeru */ public function getRestResource($padding) { $content = ''; $eol = $this->getEol(); if ($this->getRest()) { $ns = $this->getNamespace(true); $md = $this->getModule()->getLowerModuleName(); $entity = $this->getNameSingular(true); $content .= $this->getPadding($padding).'<'.$ns.'_'.$md.'_'.$entity. ' translate="title" module="'.$ns.'_'.$md.'">'.$eol; $content .= $this->getPadding($padding + 1).''.$ns.'_'.$md.'_'.$entity.''.$eol; $content .= $this->getPadding($padding + 1).''.$ns.'_'.$md.'/api2_'.$entity.''.$eol; $content .= $this->getPadding($padding + 1).''.$ns.'_'.$md.'/'.$entity. ''.$eol; $content .= $this->getPadding($padding + 1).''.$this->getLabelSingular().''.$eol; $content .= $this->getPadding($padding + 1).''.$this->getPosition().''.$eol; $content .= $this->getPadding($padding + 1).''.$eol; $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 3).'1'.$eol; $content .= $this->getPadding($padding + 3).'1'.$eol; $content .= $this->getPadding($padding + 3).'1'.$eol; $content .= $this->getPadding($padding + 3).'1'.$eol; $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 3).'1'.$eol; $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 3).'1'.$eol; $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 1).''.$eol; $content .= $this->getPadding($padding + 1).''.$eol; foreach ($this->getRestAttributes(false, false) as $code=>$label) { $content .= $this->getPadding($padding + 2).'<'.$code.'>'.$label.''.$eol; } $content .= $this->getPadding($padding + 1).''.$eol; $content .= $this->getPadding($padding + 1).''.$eol; $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 3).'/'.$md.'_'.$this->getNamePlural(true). '/:id'.$eol; $content .= $this->getPadding($padding + 3).'entity'.$eol; $content .= $this->getPadding($padding + 2).''.$eol; if ($this->getIsEav() || $this->getStore()) { $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 3).'/'.$md.'_'.$this->getNamePlural(true). '/:id/store/:store'.$eol; $content .= $this->getPadding($padding + 3).'entity'.$eol; $content .= $this->getPadding($padding + 2).''.$eol; } $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 3).'/'.$md.'_'.$this->getNamePlural(true).''.$eol; $content .= $this->getPadding($padding + 3).'collection'.$eol; $content .= $this->getPadding($padding + 2).''.$eol; if ($this->getIsEav() || $this->getStore()) { $content .= $this->getPadding($padding + 2).''.$eol; $content .= $this->getPadding($padding + 3).'/'.$md.'_'.$this->getNamePlural(true). '/store/:store'.$eol; $content .= $this->getPadding($padding + 3).'collection'.$eol; $content .= $this->getPadding($padding + 2).''.$eol; } $content .= $this->getPadding($padding + 1).''.$eol; $content .= $this->getPadding($padding + 1).'1'.$eol; $content .= $this->getPadding($padding).''.$eol; } return $content; } /** * get rest attributes * * @param bool $codeOnly * @param bool $asString * @return array|string * @author Marius Strajeru */ public function getRestAttributes($codeOnly = false, $asString = false) { $attributes = array( 'entity_id' => 'Id', ); foreach ($this->getAttributes() as $attribute) { $attributes[$attribute->getCode()] = $attribute->getLabel(); } foreach ($this->getSimulatedAttributes() as $attribute) { $attributes[$attribute->getCode()] = $attribute->getLabel(); } if ($codeOnly) { if ($asString) { return implode(' ', array_keys($attributes)); } return array_keys($attributes); } return $attributes; } /** * @access public * * @return string * @author Marius Strajeru */ public function getRestCollectionCleanup() { return $this->getTypeInstance()->getRestCollectionCleanup(); } /** * @access public * * @return string * @author Marius Strajeru */ public function getRestCollectionStoreId() { return $this->getTypeInstance()->getRestCollectionStoreId(); } /** * get default attribute values * * @access public * @return string * @author Marius Strajeru */ public function getDefaultAttributeValues() { return $this->getTypeInstance()->getDefaultAttributeValues(); } /** * check if entity has parent entities * * @access public * @return bool * @author Marius Strajeru */ public function getHasParentRelation() { return count($this->getRelatedEntities(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD)) > 0; } /** * get additional to option array select * * @access public * @return string * @author Marius Strajeru */ public function getToOptionArraySelect() { return $this->getTypeInstance()->getToOptionArraySelect(); } /** * get parent grid column static params * * @access public * @return string * @author Marius Strajeru */ public function getParentStaticParams() { if ($this->getNotIsTree()) { return ''; } $eol = $this->getEol(); $padding = $this->getPadding(4); $tab = $this->getPadding(); $content = $eol; $content .= $padding."'static' => array(".$eol; $content .= $padding.$tab."'clear' => 1".$eol; $content .= $padding."),"; return $content; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Module/Collection.php ================================================ */ /** * module collection * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Module_Collection extends Varien_Data_Collection_Filesystem { /** * Files and folders regexsp * @var string */ protected $_allowedDirsMask = '/^[a-z0-9\.\-]+$/i'; protected $_allowedFilesMask = '/^[a-z0-9\.\-\_]+\.(xml)$/i'; protected $_disallowedFilesMask = '/^package\.xml$/i'; /** * Base dir where packages are located * * @var string */ protected $_baseDir = ''; /** * Set base dir * * @access public * @author Marius Strajeru */ public function __construct() { $this->_baseDir = Mage::getBaseDir('var') . DS . 'modulecreator'.DS.'package'; $io = new Varien_Io_File(); $io->setAllowCreateFolders(true); $io->createDestinationDir($this->_baseDir); $this->addTargetDir($this->_baseDir); } /** * Row generator * * @access public * @param string $filename * @return array * @author Marius Strajeru */ protected function _generateRow($filename) { $row = parent::_generateRow($filename); $row['package'] = preg_replace('/\.(xml)$/', '', str_replace($this->_baseDir . DS, '', $filename)); $row['filename_id'] = $row['package']; $row['safe_id'] = strtr(base64_encode($row['package']), '+/=', '-_,'); $folder = explode(DS, $row['package']); $row['folder'] = DS; array_pop($folder); if (!empty($folder)) { $row['folder'] = implode(DS, $folder) . DS; } return $row; } /** * Get all folders as options array * * @access public * @return array * @author Marius Strajeru */ public function collectFolders() { $collectFiles = $this->_collectFiles; $collectDirs = $this->_collectDirs; $this->setCollectFiles(false)->setCollectDirs(true); $this->_collectRecursive($this->_baseDir); $result = array(DS => DS); foreach ($this->_collectedDirs as $dir) { $dir = str_replace($this->_baseDir . DS, '', $dir) . DS; $result[$dir] = $dir; } $this->setCollectFiles($collectFiles)->setCollectDirs($collectDirs); return $result; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Module.php ================================================ */ /** * @method string getFilenameId() * @method string getMenuParent() * @method Ultimate_ModuleCreator_Model_Module setRss() * @method Ultimate_ModuleCreator_Model_Module setHasFile() * @method Ultimate_ModuleCreator_Model_Module setHasImage() * @method Ultimate_ModuleCreator_Model_Module setAddSeo() * @method Ultimate_ModuleCreator_Model_Module setWidget() * @method Ultimate_ModuleCreator_Model_Module setCreateFrontend() * @method Ultimate_ModuleCreator_Model_Module setCanCreateRouter() * @method Ultimate_ModuleCreator_Model_Module setCreateList() * @method Ultimate_ModuleCreator_Model_Module setHasTree() * @method Ultimate_ModuleCreator_Model_Module setEditor() * @method Ultimate_ModuleCreator_Model_Module setHasConfigDefaults() * @method Ultimate_ModuleCreator_Model_Module setLinkProduct() * @method Ultimate_ModuleCreator_Model_Module setHasObserver() * @method Ultimate_ModuleCreator_Model_Module setLinkCategory() * @method Ultimate_ModuleCreator_Model_Module setLinkCore() * @method Ultimate_ModuleCreator_Model_Module setUrlRewrite() * @method Ultimate_ModuleCreator_Model_Module setHasEav() * @method Ultimate_ModuleCreator_Model_Module setHasFlat() * @method Ultimate_ModuleCreator_Model_Module setApi() * @method Ultimate_ModuleCreator_Model_Module setAllowComment() * @method Ultimate_ModuleCreator_Model_Module setAllowCommentByStore() * @method Ultimate_ModuleCreator_Model_Module setHasCountry() * @method Ultimate_ModuleCreator_Model_Module setHasSeo() * @method Ultimate_ModuleCreator_Model_Module setShowOnProduct() * @method Ultimate_ModuleCreator_Model_Module setShowOnCategory() * @method Ultimate_ModuleCreator_Model_Module setShowInCategoryMenu() * @method Ultimate_ModuleCreator_Model_Module setSearch() * @method Ultimate_ModuleCreator_Model_Module setHasCatalogAttribute() * @method Ultimate_ModuleCreator_Model_Module setRest() * @method int getInstall() * @method Ultimate_ModuleCreator_Model_Module setInstall() * @method bool getHasEav() * @method int getSortOrder() * @method string getMenuText() * @method string getCodepool() * @method string getVersion() * @method bool getCreateFrontend() * @method bool getLinkProduct() * @method bool getLinkCategory() * @method bool getHasCatalogAttribute() * @method bool getLinkCore() * @method bool getShowInCategoryMenu() * @method string getModuleName() */ class Ultimate_ModuleCreator_Model_Module extends Ultimate_ModuleCreator_Model_Abstract { /** * enterprise version where Varien_Io_File was changed * * @var string */ const EFFIN_VERSION_ENTERPRISE = '1.13.1'; /** * community version where Varien_Io_File was changed * * @var string */ const EFFIN_VERSION_COMMUNITY = '1.8.1'; /** * entity code * * @var string */ protected $_entityCode = 'umc_module'; /** * module entities * * @var array() */ protected $_entities = array(); /** * module config * * @var mixed (null|Varien_Simplexml_Element) */ protected $_config = null; /** * entity relations * * @var array */ protected $_relations = array(); /** * io member * * @var null|Varien_Io_File */ protected $_io = null; /** * error log * * @var array */ protected $_errors = array(); /** * source folder * * @var null */ protected $_sourceFolder = null; /** * placeholders * * @var null */ protected $_placeholders = null; /** * base placeholders * * @var array */ protected $_basePlaceholders = array(); /** * generated files * * @var array */ protected $_files = array(); /** * keep modman paths * * @var array */ protected $_modman = array(); /** * add entity to module * * @access public * @param Ultimate_ModuleCreator_Model_Entity $entity * @return Ultimate_ModuleCreator_Model_Module * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru */ public function addEntity(Ultimate_ModuleCreator_Model_Entity $entity) { Mage::dispatchEvent( 'umc_module_add_entity_before', array('entity'=>$entity, 'module'=>$this) ); if (isset($this->_entities[$entity->getNameSingular()])) { throw new Ultimate_ModuleCreator_Exception( Mage::helper('modulecreator')->__( 'An entity with the code "%s" already exists', $entity->getNameSingular() ) ); } $entity->setModule($this); $entity->setIndex(count($this->_entities)); $position = 10 * (count($this->_entities)); $entity->setPosition($position); $this->_entities[$entity->getNameSingular()] = $entity; if ($entity->getRss()) { $this->setRss(true); } if ($entity->getHasFile()) { $this->setHasFile(true); } if ($entity->getHasImage()) { $this->setHasImage(true); } if ($entity->getAddSeo()) { $this->setAddSeo(true); } if ($entity->getWidget()) { $this->setWidget(true); } if ($entity->getCreateFrontend()) { $this->setCreateFrontend(true); $this->setCanCreateRouter(true); } if ($entity->getCreateList()) { $this->setCreateList(true); } if ($entity->getIsTree()) { $this->setHasTree(true); } if ($entity->getEditor()) { $this->setEditor(true); } if ($entity->getHasConfigDefaults()) { $this->setHasConfigDefaults(true); } if ($entity->getLinkProduct()) { $this->setLinkProduct(true); $this->setHasObserver(true); } if ($entity->getLinkCategory()) { $this->setLinkCategory(true); $this->setHasObserver(true); } if ($entity->getLinkCore()) { $this->setLinkCore(true); } if ($entity->getUrlRewrite()) { $this->setUrlRewrite(true); } if ($entity->getIsEav()) { $this->setHasEav(true); } if ($entity->getIsFlat()) { $this->setHasFlat(true); } if ($entity->getApi()) { $this->setApi(true); } if ($entity->getAllowComment()) { $this->setAllowComment(true); } if ($entity->getAllowCommentByStore()) { $this->setAllowCommentByStore(true); } if ($entity->getHasCountry()) { $this->setHasCountry(true); } if ($entity->getAddSeo()) { $this->setHasSeo(true); } if ($entity->getCanCreateListBlock()) { $this->setCreateFrontend(true); } if ($entity->getShowOnProduct()) { $this->setShowOnProduct(true); } if ($entity->getShowOnCategory()) { $this->setShowOnCategory(true); } if ($entity->getShowInCategoryMenu()) { $this->setShowInCategoryMenu(true); } if ($entity->getSearch()) { $this->setSearch(true); } if ($entity->getProductAttribute() ||$entity->getCategoryAttribute()) { $this->setHasCatalogAttribute(true); } if ($entity->getRest()) { $this->setRest(true); } Mage::dispatchEvent( 'umc_module_add_entity_after', array('entity'=>$entity, 'module'=>$this) ); return $this; } /** * get a module entity * * @access public * @param string $code * @return mixed(Ultimate_ModuleCreator_Model_Entity|null) * @author Marius Strajeru */ public function getEntity($code) { if (isset($this->_entities[$code])) { return $this->_entities[$code]; } return null; } /** * module to xml * * @access public * @param array $arrAttributes * @param string $rootName * @param bool $addOpenTag * @param bool $addCdata * @return string * @author Marius Strajeru */ public function toXml(array $arrAttributes = array(), $rootName = 'module', $addOpenTag=false, $addCdata=false) { $xml = ''; $eol = $this->getEol(); if ($addOpenTag) { $xml.= ''.$eol; } if (!empty($rootName)) { $xml.= '<'.$rootName.'>'.$eol; } $xml .= parent::toXml($this->getXmlAttributes(), '', false, $addCdata); $xml .= ''.$eol; foreach ($this->getEntities() as $entity) { $xml .= $entity->toXml(array(), 'entity', false, $addCdata); } $xml .= ''.$eol; $xml .= ''.$eol; foreach ($this->getRelations() as $relation) { $xml .= $relation->toXml(array(), '', false, $addCdata); } $xml .= ''.$eol; if (!empty($rootName)) { $xml.= ''.$eol; } return $xml; } /** * get the module entities * * @access public * @return Ultimate_ModuleCreator_Model_Entity[] * @author Marius Strajeru */ public function getEntities() { $this->_prepareEntities(); return $this->_entities; } /** * prepare the entities before saving * * @access protected * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _prepareEntities() { Mage::dispatchEvent('umc_module_prepare_entities', array('module'=>$this)); return $this; } /** * add relation to module * * @access public * @param Ultimate_ModuleCreator_Model_Relation $relation * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ public function addRelation(Ultimate_ModuleCreator_Model_Relation $relation) { Mage::dispatchEvent( 'umc_module_add_relation_before', array('relation'=>$relation, 'module'=>$this) ); $this->_relations[] = $relation; Mage::dispatchEvent( 'umc_module_add_relation_after', array('relation'=>$relation, 'module'=>$this) ); return $this; } /** * get module relations * * @access public * @param mixed $type * @return Ultimate_ModuleCreator_Model_Relation[] * @author Marius Strajeru */ public function getRelations($type = null) { if (is_null($type)) { return $this->_relations; } $relations = array(); foreach ($this->_relations as $relation) { /** @var Ultimate_ModuleCreator_Model_Relation $relation */ if ($relation->getType() == $type) { $relations[] = $relation; } } return $relations; } /** * get the extensions xml path * * @access public * @return string * @author Marius Strajeru */ public function getXmlPath() { return $this->getHelper()->getLocalPackagesPath(). $this->getNamespace()."_".$this->getModuleName().'.xml'; } /** * save the module as xml * * @access public * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ public function save() { $destination = $this->getXmlPath(); $xml = $this->toXml(array(), 'module', true, true); $this->_writeFile($destination, $xml); return $this; } /** * validate the module * * @access public * @return array * @author Marius Strajeru */ public function validate() { $config = $this->getHelper()->getConfig(); $settings = $config->getNode('forms/settings/fieldsets'); foreach ($settings->fieldset as $set) { foreach ($set->fields->children() as $key => $values) { $v = $this->getData($key); if ((string)$values->required == 1 && (!$this->hasData($key) || $v === "")) { $this->_addError( Mage::helper("modulecreator")->__('This is a required field.'), 'settings_'.$key ); } } } //validate namespace if (strtolower($this->getNamespace()) == 'mage') { $this->_addError( Mage::helper('modulecreator')->__("You shouldn't use the namespace Mage. Be Creative"), 'settings_namespace' ); } //validate module name $routers = Mage::getConfig()->getNode('frontend/routers'); $moduleName = $this->getModuleName(); $lower = strtolower($moduleName); $extension = $this->getExtensionName(); if ($routers->$lower) { if ((string)$routers->$lower->args->module != $extension) { $this->_addError( Mage::helper('modulecreator')->__( 'You cannot use the module name %s', $this->getModuleName() ), 'settings_module_name' ); } } //validate front key foreach ((array)$routers as $router) { if ((string)$router->args->frontName == $this->getFrontKey() && $router->args->module != $extension) { $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' ); break; } } //validate entity count if (count($this->getEntities()) == 0) { $this->_addError(Mage::helper('modulecreator')->__('Add at least an entity')); } else { //validate entities foreach ($this->getEntities() as $entity) { $entityCode = $entity->getNameSingular(true); if (in_array($entityCode, $this->getRestrictedEntityNames())) { $this->_addError( Mage::helper('modulecreator')->__( 'The entity code "%s" is restricted', $entityCode ), 'entity_'.$entity->getIndex().'_name_singular' ); } if (count($entity->getAttributes()) == 0) { $this->_addError( Mage::helper('modulecreator')->__( 'The entity "%s" must have at least one attribute.', $entity->getLabelSingular() ) ); } else { //validate name attribute if (is_null($entity->getNameAttribute())) { $this->_addError( Mage::helper('modulecreator')->__( 'The entity "%s" must have an attribute that behaves as a name.', $entity->getLabelSingular() ) ); } $restrictedAttributes = $this->getRestrictedAttributeCodes(); //validate attributes foreach ($entity->getAttributes() as $attribute) { $code = $attribute->getCode(); if (isset($restrictedAttributes[$code])) { //presume "not guilty" $valid = true; if (!isset($restrictedAttributes[$code]->depend_entity)) {//if general restriction. $valid = false; } else {//if depends on entity setting. foreach ((array)$restrictedAttributes[$code]->depend_entity as $prop=>$value) { if ($entity->getDataUsingMethod($prop) == $value) { //"found guilty" $valid = false; break; } } } if (!$valid) { $this->_addError( $restrictedAttributes[$code]->message, 'attribute_'.$entity->getIndex().'_'.$attribute->getIndex().'_code' ); } } //validate attributes against getters ("getData", "getCollection", ,....) $methodCodes = $this->getMethodAttributeCodes(); if (in_array($code, $methodCodes)) { $method = $method = str_replace(' ', '', ucwords(str_replace('_', ' ', $code))); $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' ); } } } } } return $this->_errors; } /** * add an error to the error list * * @access protected * @param $message * @param null $attribute * @param string $separator * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _addError($message, $attribute = null, $separator = '
    ') { if (empty($attribute)) { $this->_errors[''][] = $message; } else { if (!isset($this->_errors[$attribute])) { $this->_errors[$attribute] = ''; } else { $this->_errors[$attribute] .= $separator; } $this->_errors[$attribute] .= $message; } return $this; } /** * write a file * * @access protected * @param string $destinationFile * @param string $contents * @throws Exception * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _writeFile($destinationFile, $contents) { try { $io = $this->getIo(); $io->mkdir(dirname($destinationFile)); /** * Varien_Io_File has changed in CE 1.8.1 / EE 1.13.1 A LOT */ if (version_compare(Mage::getVersion(), $this->getEffinVersion(), '<')) { $io->write($destinationFile, $contents, 0777); } else { $io->filePutContent($destinationFile, $contents); } } catch (Exception $e) { if ($e->getCode() != 0) { throw $e; } } return $this; } /** * get the version for which the io writer has changed * * @access public * @return string * @author Marius Strajeru */ public function getEffinVersion() { if (Mage::getEdition() == Mage::EDITION_ENTERPRISE) { return self::EFFIN_VERSION_ENTERPRISE; } return self::EFFIN_VERSION_COMMUNITY; } /** * get the IO - class instance * * @access public * @return Varien_Io_File * @author Marius Strajeru */ public function getIo() { if (!$this->_io) { $this->_io = new Varien_Io_File(); $this->_io->setAllowCreateFolders(true); } return $this->_io; } /** * get module relations as json * * @access public * @return string * @author Marius Strajeru */ public function getRelationsAsJson() { $json = array(); $relations = $this->getRelations(); foreach ($relations as $relation) { $entities = $relation->getEntities(); $json[$entities[0]->getIndex().'_'.$entities[1]->getIndex()] = $relation->getType(); } return json_encode($json); } /** * get the extension name * * @param bool $lower * @return string * @access public * @author Marius Strajeru */ public function getExtensionName($lower = false) { $name = $this->getNamespace().'_'.$this->getModuleName(); if ($lower) { $name = strtolower($name); } return $name; } /** * get the restricted entity name * * @access public * @return array * @author Marius Strajeru */ public function getRestrictedEntityNames() { return $this->getDataSetDefault( 'restricted_entity_names', array_keys( (array)$this->getHelper()->getConfig()->getNode('restricted/entity') ) ); } /** * get the restricted attribute codes * * @access public * @return array * @author Marius Strajeru */ public function getRestrictedAttributeCodes() { return $this->getDataSetDefault( 'restricted_attribute_codes', (array)$this->getHelper()->getConfig()->getNode('restricted/attribute') ); } /** * get the restricted attribute codes because of the method names * * @access public * @return array * @author Marius Strajeru */ public function getMethodAttributeCodes() { if (!$this->hasData('method_attribute_codes')) { $attributes = array(); $methods = get_class_methods('Mage_Catalog_Model_Abstract'); $start = array('get', 'set', 'has', 'uns'); foreach ($methods as $method) { if (in_array(substr($method, 0, 3), $start)) { $attribute = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", substr($method, 3))); $attributes[$attribute] = 1; } } $this->setData('method_attribute_codes', array_keys($attributes)); } return $this->getData('method_attribute_codes'); } /** * build the module * * @access public * @return array * @author Marius Strajeru */ public function buildModule() { $config = $this->getConfig(); $files = $config->getNode('files'); $messages = array(); foreach ((array)$files as $file) { if ($file->scope == 'disabled') { continue; } $this->_createFile($file); } if ($this->getInstall()) { $existingFiles = $this->_checkExistingFiles(); if (count($existingFiles) > 0) { $this->setInstall(false); $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('
    ', $existingFiles) ); } } $this->_writeFiles(); if (!$this->getInstall()) { $contents = array(); foreach ($this->_files as $filename=>$file) { $contents[] = $this->getRelativeBasePath().$filename; } /** @var Ultimate_ModuleCreator_Model_Writer $_writer */ $_writer = Mage::getModel('modulecreator/writer', $contents); $_writer->setPathPrefix('var'.DS.'modulecreator'.DS.$this->getExtensionName().DS); $_writer->setNamePackage(Mage::getBaseDir('var').DS.'modulecreator'.DS.$this->getExtensionName()); $_writer->composePackage()->archivePackage(); $this->_io->rmdir($this->getBasePath(), true); } return $messages; } /** * write files to disk * * @access protected * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _writeFiles() { $basePath = $this->getBasePath(); foreach ($this->_files as $name=>$file) { $destinationFile = $basePath.$name; $this->_writeFile($destinationFile, $file); } $this->_writeLog(); $this->_writeUninstall(); $this->_writeModman(); return $this; } /** * write log with generated files * * can be used for uninstall * @access protected * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _writeLog() { $filesToWrite = array_keys($this->_files); asort($filesToWrite); $filesToWrite = array_values($filesToWrite); $text = implode($this->getEol(), $filesToWrite); $this->_writeFile($this->getLogPath(), $text); return $this; } /** * write sql uninstall script * * @access protected * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _writeUninstall() { $lines = array(); $module = $this->getPlaceholder('{{module}}'); $namespace = $this->getNamespace(true); $lines[] = '-- add table prefix if you have one'; foreach ($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $relation) { $entities = $relation->getEntities(); $tableName = $namespace.'_'.$module.'_'. $entities[0]->getPlaceholders('{{entity}}').'_'. $entities[1]->getPlaceholders('{{entity}}'); $lines[] = 'DROP'.' TABLE IF EXISTS '.$tableName.';'; } foreach ($this->getEntities() as $entity) { if ($entity->getIsEav()) { $entityTypeCode = $namespace.'_'.$this->getLowerModuleName().'_'.$entity->getPlaceholders('{{entity}}'); $lines[] = "DELETE"." FROM eav_attribute WHERE entity_type_id IN ". "(SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = '{$entityTypeCode}');"; $lines[] = "DELETE"." FROM eav_entity_type WHERE entity_type_code = '{$entityTypeCode}';"; } if ($entity->getProductAttribute()) { $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');"; } if ($entity->getCategoryAttribute()) { $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');"; } if ($entity->getAllowCommentByStore()) { $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_comment_store'; $lines[] = 'DROP'.' TABLE IF EXISTS '.$tableName.';'; } if ($entity->getAllowComment()) { $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_comment'; $lines[] = 'DROP'.' TABLE IF EXISTS '.$tableName.';'; } if ($entity->getLinkProduct()) { $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_product'; $lines[] = 'DROP'.' TABLE IF EXISTS '.$tableName.';'; } if ($entity->getLinkCategory()) { $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_category'; $lines[] = 'DROP'.' TABLE IF EXISTS '.$tableName.';'; } if ($entity->getStore()) { $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_store'; $lines[] = 'DROP'.' TABLE IF EXISTS '.$tableName.';'; } if ($entity->getIsEav()) { foreach (array('int', 'decimal','datetime', 'varchar', 'text') as $type) { $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}').'_'.$type; $lines[] = 'DROP'.' TABLE IF EXISTS '.$tableName.';'; } } $tableName = $namespace.'_'.$module.'_'.$entity->getPlaceholders('{{entity}}'); $lines[] = 'DROP'.' TABLE IF EXISTS '.$tableName.';'; } if ($this->getHasEav()) { $tableName = $namespace.'_'.$module.'_eav_attribute'; $lines[] = 'DROP'.' TABLE IF EXISTS '.$tableName.';'; } $lines[] = "DELETE"." FROM core_resource WHERE code = '".$namespace.'_'.$module."_setup';"; $lines[] = "DELETE"." FROM core_config_data WHERE path like '".$namespace.'_'.$module."/%';"; $text = implode($this->getEol(), $lines); $this->_writeFile($this->getUninstallPath(), $text); return $this; } /** * write the modman file * * @access protected * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _writeModman() { $paths = array( 'app/etc/modules/'.$this->getNamespace().'_'.$this->getModuleName().'.xml', 'app/code/'.$this->getCodepool().'/'.$this->getNamespace().'/'.$this->getModuleName(), 'app/locale/en_US/'.$this->getNamespace().'_'.$this->getModuleName().'.csv', 'app/design/adminhtml/default/default/layout/'.$this->getNamespace(true).'_'.$this->getLowerModuleName().'.xml', 'app/design/adminhtml/default/default/template/'.$this->getNamespace(true).'_'.$this->getLowerModuleName() ); if ($this->getCreateFrontend()) { $paths[] = 'app/design/frontend/base/default/layout/'.$this->getNamespace(true).'_'.$this->getLowerModuleName().'.xml'; $paths[] = 'app/design/adminhtml/default/default/template/'.$this->getNamespace(true).'_'.$this->getLowerModuleName(); } foreach ($this->getEntities() as $entity) { if ($entity->getHasImage()) { $paths[] = 'skin/frontend/base/default/images/placeholder/'.$entity->getNameSingular(true).'.jpg'; } if ($entity->getIsTree()) { $paths[] = 'skin/frontend/base/default/css/'.$this->getNamespace(true).'_'.$this->getLowerModuleName(); $paths[] = 'skin/frontend/base/default/images/'.$this->getNamespace(true).'_'.$this->getLowerModuleName(); $paths[] = 'skin/frontend/base/default/js/'.$this->getNamespace(true).'_'.$this->getLowerModuleName(); } } sort($paths); $paths = array_unique($paths); $text = ''; $eol = $this->getEol(); foreach ($paths as $path) { $text .= $path . ' '.$path.$eol; } $this->_writeFile($this->getModmanPath(), $text); return $this; } /** * get path for modman file * * @access public * @return string * @author Marius Strajeru */ public function getModmanPath() { return $this->getHelper()->getLocalPackagesPath().$this->getExtensionName().'/modman'; } /** * check if some files already exist so it won't be overwritten * * @access protected * @return array() * @author Marius Strajeru */ protected function _checkExistingFiles() { $existingFiles = array(); $io = $this->getIo(); $basePath = $this->getBasePath(); foreach ($this->_files as $name=>$content) { if ($io->fileExists($basePath.$name)) { $existingFiles[] = $basePath.$name; } } return $existingFiles; } /** * get path for log file * * @access public * @return string * @author Marius Strajeru */ public function getLogPath() { return $this->getHelper()->getLocalPackagesPath().$this->getExtensionName().'/files.log'; } /** * get path for uninstall sql file * * @access public * @return string * @author Marius Strajeru */ public function getUninstallPath() { return $this->getHelper()->getLocalPackagesPath().$this->getExtensionName().'/uninstall.sql'; } /** * get module base path * * @access public * @return string * @author Marius Strajeru */ public function getBasePath() { if (!$this->getInstall()) { return Mage::getBaseDir('var').DS.'modulecreator'.DS.$this->getExtensionName().DS; } return Mage::getBaseDir().DS; } /** * get relative path ro the module * * @access public * @return string * @author Marius Strajeru */ public function getRelativeBasePath() { $basePath = $this->getBasePath(); $remove = Mage::getBaseDir().DS; $relativePath = substr($basePath, strlen($remove)); return $relativePath; } /** * get the module config * * @access public * @return Varien_Simplexml_Config * @author Marius Strajeru */ public function getConfig() { if (is_null($this->_config)) { $this->_config = Mage::getConfig()->loadModulesConfiguration('umc_source.xml')->applyExtends(); } return $this->_config; } /** * get contents of a file * * @access public * @param string $file * @return string * @author Marius Strajeru */ public function getFileContents($file) { return file_get_contents($file); } /** * create a file * * @access protected * @param Varien_Simplexml_Element * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _createFile($config) { switch ($config->scope) { case 'entity' : $this->_buildEntityFile($config); break; case 'siblings': $this->_buildSiblingFile($config); break; case 'children' : $this->_buildChildrenFile($config); break; case 'attribute' : $this->_buildAttributeFile($config); break; case 'global': default: $this->_buildGlobalFile($config); break; } return $this; } /** * validate xml condition * * @access protected * @param Ultimate_ModuleCreator_Model_Abstract $entity * @param Mage_Core_Model_Config_Element $conditions * @param mixed $params * @return bool * @author Marius Strajeru */ protected function _validateDepend( Ultimate_ModuleCreator_Model_Abstract $entity, Mage_Core_Model_Config_Element $conditions, $params = null ) { if (!$conditions) { return true; } if (!is_array($conditions)) { $conditions = $conditions->asArray(); } foreach ($conditions as $condition=>$value) { if (!$entity->getDataUsingMethod($condition, $params)) { return false; } } return true; } /** * create a file with global scope * * @access protected * @param Varien_Simplexml_Element * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ public function _buildGlobalFile($config) { $filetype = $config->filetype; $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->source, $filetype); $destination = $this->_filterString((string)$config->destination, $filetype); $content = ''; $depend = $config->depend; if (!$this->_validateDepend($this, $depend)) { return ''; } if ($config->method) { $method = (string)$config->method; $content = $this->$method(); } else { $code = $this->_sortCodeFiles((array)$config->code); foreach ($code as $file) { $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name); $scope = (string)$file->scope; $depend = $file->depend; if ($scope == 'entity') { foreach ($this->getEntities() as $entity) { if ($this->_validateDepend($entity, $depend)) { $replace = $entity->getPlaceholders(); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } } elseif ($scope == 'attribute') { $depend = $file->depend; /** @var Mage_Core_Model_Config_Element $dependType */ $dependType = $file->depend_type; foreach ($this->getEntities() as $entity) { foreach ($entity->getAttributes() as $attribute) { $valid = $this->_validateDepend($attribute, $depend); $typeValid = true; if ($dependType) { $typeValid = false; foreach ($dependType->asArray() as $condition=>$value) { if ($attribute->getType() == $condition) { $typeValid = true; break; } } } if ($valid && $typeValid) { $replace = $entity->getPlaceholders(); $attributeReplace = $attribute->getPlaceholders(); $replace = array_merge($replace, $attributeReplace); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } } } elseif ($scope == 'siblings') { $relatedEntities = $this->getRelations( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($relatedEntities as $relation) { $entities = $relation->getEntities(); $replaceEntity = $entities[0]->getPlaceholders(); $replaceSibling = $entities[1]->getPlaceholdersAsSibling(); $replace = array_merge($replaceEntity, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } elseif ($scope == 'siblings_both_tree') { $relatedEntities = $this->getRelations( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($relatedEntities as $relation) { $entities = $relation->getEntities(); if ($entities[0]->getIsTree() || $entities[1]->getIsTree()) { if ($entities[0]->getIsTree()) { $tree = $entities[0]; $sibling = $entities[1]; } else { $tree = $entities[1]; $sibling = $entities[0]; } $replaceEntity = $tree->getPlaceholders(); $replaceSibling = $sibling->getPlaceholdersAsSibling(); $replace = array_merge($replaceEntity, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } } elseif ($scope == 'siblings_both_not_tree') { $relatedEntities = $this->getRelations( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($relatedEntities as $relation) { $entities = $relation->getEntities(); if ($entities[0]->getIsTree() || $entities[1]->getIsTree()) { continue; } $replaceEntity = $entities[0]->getPlaceholders(); $replaceSibling = $entities[1]->getPlaceholdersAsSibling(); $replace = array_merge($replaceEntity, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); $replaceEntity = $entities[1]->getPlaceholders(); $replaceSibling = $entities[0]->getPlaceholdersAsSibling(); $replace = array_merge($replaceEntity, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } elseif ($scope == 'children') { $relatedEntities = $this->getRelations( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD ); foreach ($relatedEntities as $relation) { $entities = $relation->getEntities(); $replaceEntity = $entities[0]->getPlaceholders(); $replaceSibling = $entities[1]->getPlaceholdersAsSibling(); $replace = array_merge($replaceEntity, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } $relatedEntities = $this->getRelations( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT ); foreach ($relatedEntities as $relation) { $entities = $relation->getEntities(); $replaceEntity = $entities[1]->getPlaceholders(); $replaceSibling = $entities[0]->getPlaceholdersAsSibling(); $replace = array_merge($replaceEntity, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } else { if ($this->_validateDepend($this, $depend)) { $content .= $this->_filterString($sourceContent, $filetype); } } } } if ($config->after_build) { $function = (string)$config->after_build; $content = $this->$function($content); } $content = $this->_filterString($content, $config->type); $this->_addFile($destination, $content); return $this; } /** * create a file with entity scope * * @access protected * @param Varien_Simplexml_Element * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ public function _buildEntityFile($config) { foreach ($this->getEntities() as $entity) { $filetype = $config->filetype; $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->source, $filetype); $destinationFile = $this->_filterString( (string)$config->destination, $filetype, $entity->getPlaceholders(), true ); $content = ''; $depend = $config->depend; if (!$this->_validateDepend($entity, $depend)) { continue; } $code = $this->_sortCodeFiles((array)$config->code); foreach ($code as $file) { $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name); $scope = (string)$file->scope; $depend = $file->depend; /** @var Mage_Core_Model_Config_Element $dependType */ $dependType = $file->depend_type; if ($scope == 'attribute') { foreach ($entity->getAttributes() as $attribute) { $valid = $this->_validateDepend($attribute, $depend); $typeValid = true; if ($dependType) { $typeValid = false; foreach ($dependType->asArray() as $condition=>$value) { if ($attribute->getType() == $condition) { $typeValid = true; break; } } } if ($valid && $typeValid) { $replace = $entity->getPlaceholders(); $attributeReplace = $attribute->getPlaceholders(); $replace = array_merge($replace, $attributeReplace); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } } elseif ($scope == 'siblings') { $relatedEntities = $entity->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($relatedEntities as $related) { if ($this->_validateDepend($entity, $depend)) { $placeholders = $entity->getPlaceholders(); $replaceSibling = $related->getPlaceholdersAsSibling(); $replace = array_merge($placeholders, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } } elseif ($scope == 'siblings_not_tree') { $relatedEntities = $entity->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($relatedEntities as $related) { if ($related->getNotIsTree()) { $placeholders = $entity->getPlaceholders(); $replaceSibling = $related->getPlaceholdersAsSibling(); $replace = array_merge($placeholders, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } } elseif ($scope == 'siblings_tree') { $relatedEntities = $entity->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING ); foreach ($relatedEntities as $related) { if ($related->getIsTree()) { $placeholders = $entity->getPlaceholders(); $replaceSibling = $related->getPlaceholdersAsSibling(); $replace = array_merge($placeholders, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } } elseif ($scope == 'parents') { $relatedEntities = $entity->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD ); foreach ($relatedEntities as $related) { $placeholders = $entity->getPlaceholders(); $replaceSibling = $related->getPlaceholdersAsSibling(); $replace = array_merge($placeholders, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } elseif ($scope == 'children') { $relatedEntities = $entity->getRelatedEntities( Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT ); foreach ($relatedEntities as $related) { $placeholders = $entity->getPlaceholders(); $replaceSibling = $related->getPlaceholdersAsSibling(); $replace = array_merge($placeholders, $replaceSibling); $content .= $this->_filterString($sourceContent, $filetype, $replace, true); } } elseif ($depend) { if ($this->_validateDepend($entity, $depend)) { $content .= $this->_filterString($sourceContent, $filetype, $entity->getPlaceholders(), true); } } else { $content .= $this->_filterString($sourceContent, $filetype, $entity->getPlaceholders(), true); } $this->_addFile($destinationFile, $content); } } return $this; } /** * generate files for sibling relations * * @access protected * @param $config * @return $this * @author Marius Strajeru */ protected function _buildSiblingFile($config) { foreach ($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING) as $relation) { $entities = $relation->getEntities(); foreach ($entities as $index=>$entity) { $depend = $config->depend; if (!$this->_validateDepend($relation, $depend, $index)) { continue; } $placeholders = array_merge( $entities[$index]->getPlaceholders(), $entities[1 - $index]->getPlaceholdersAsSibling() ); $filetype = $config->filetype; $sourceFolder = $this->getSourceFolder(). $this->_filterString((string)$config->source, $filetype); $destinationFile = $this->_filterString( (string)$config->destination, $filetype, $placeholders, true ); $content = ''; $code = $this->_sortCodeFiles((array)$config->code); foreach ($code as $file) { $depend = $file->depend; if (!$this->_validateDepend($relation, $depend, $index)) { continue; } $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name); $content .= $this->_filterString($sourceContent, $filetype, $placeholders, true); } $this->_addFile($destinationFile, $content); } } return $this; } /** * create files for children relations * * @access protected * @param Varien_Simplexml_Element * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _buildChildrenFile($config) { foreach ($this->getRelations() as $relation) { $type = $relation->getType(); $entities = $relation->getEntities(); $parent = false; $child = false; if ($type == Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT) { $parent = $entities[0]; $child = $entities[1]; } elseif ($type == Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD) { $parent = $entities[1]; $child = $entities[0]; } if ($parent && $child) { $depend = $config->depend; if ($this->_validateDepend($relation, $depend)) { $placeholders = array_merge($parent->getPlaceholders(), $child->getPlaceholdersAsSibling()); $filetype = $config->filetype; $sourceFolder = $this->getSourceFolder(). $this->_filterString((string)$config->source, $filetype); $destinationFile = $this->_filterString( (string)$config->destination, $filetype, $placeholders, true ); $content = ''; $code = $this->_sortCodeFiles((array)$config->code); foreach ($code as $file) { $depend = $file->depend; if (!$this->_validateDepend($relation, $depend)) { continue; } $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name); $content .= $this->_filterString($sourceContent, $filetype, $placeholders, true); } $this->_addFile($destinationFile, $content); } } } return $this; } /** * build source file for an attribute * * @access public * @param $config * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _buildAttributeFile($config) { foreach ($this->getEntities() as $entity) { foreach ($entity->getAttributes() as $attribute) { $filetype = $config->filetype; $sourceFolder = $this->getSourceFolder().$this->_filterString((string)$config->source, $filetype); $placeholders = array_merge($entity->getPlaceholders(), $attribute->getPlaceholders()); $destinationFile = $this->_filterString((string)$config->destination, $filetype, $placeholders, true); $content = ''; $depend = $config->depend; if (!$this->_validateDepend($attribute, $depend)) { continue; } $code = $this->_sortCodeFiles((array)$config->code); foreach ($code as $file) { $depend = $file->depend; if (!$this->_validateDepend($attribute, $depend)) { continue; } $sourceContent = $this->getFileContents($sourceFolder.(string)$file->name); $content .= $this->_filterString($sourceContent, $filetype, $placeholders, true); } $this->_addFile($destinationFile, $content); } } return $this; } /** * get sample files source folder * * @access public * @return string * @author Marius Strajeru */ public function getSourceFolder() { if (!isset($this->_sourceFolder)) { $this->_sourceFolder = Mage::getConfig()->getModuleDir('etc', 'Ultimate_ModuleCreator').DS.'source'.DS; } return $this->_sourceFolder; } /** * filter placeholders * * @access protected * @param string $string * @param string $fileType * @param mixed (null|array()) $replaceArray * @param bool $mergeReplace * @param bool $forLicence * @return string * @author Marius Strajeru */ protected function _filterString( $string, $fileType, $replaceArray = null, $mergeReplace = false, $forLicence = false ) { $replace = $this->getPlaceholder(); if (!$forLicence) { $replace['{{License}}'] = $this->getLicenseText($fileType); } if (!is_null($replaceArray)) { if ($mergeReplace) { $replace = array_merge($replace, $replaceArray); } else { $replace = $replaceArray; } } return str_replace(array_keys($replace), array_values($replace), $string); } /** * add file to create list * * @access protected * @param $destinationFile * @param $content * @return $this * @author Marius Strajeru */ protected function _addFile($destinationFile, $content) { if (trim($content)) { $this->_files[$destinationFile] = $content; } return $this; } /** * get text for licence * * @access public * @param string $fileType * @return string * @author Marius Strajeru */ public function getLicenseText($fileType) { if (!$this->getData('processed_license_'.$fileType)) { $eol = $this->getEol(); $license = trim($this->getData('license')); if (!$license) { return ''; } while (strpos($license, '*/') !== false) { $license = str_replace('*/', '', $license); } while (strpos($license, '/*') !== false) { $license = str_replace('/*', '', $license); } while (strpos($license, '') !== false) { $license = str_replace('-->', '', $license); } $lines = explode("\n", $license); $top = ''; $footer = ''; if ($fileType == 'xml') { $top = ''; } $processed = $top.'/**'.$eol; foreach ($lines as $line) { $processed .= ' * '.$line.$eol; } $processed .= ' */'.$footer; $this->setData( 'processed_license_'.$fileType, $this->_filterString($processed, $fileType, array(), true, true) ); } return $this->getData('processed_license_'.$fileType); } /** * get all placeholders * * @access public * @param null $param * @return array|null|string * @author Marius Strajeru */ public function getPlaceholder($param = null) { if (is_null($this->_placeholders)) { $this->_placeholders = array( '{{DS}}' => DS, '{{namespace}}' => $this->getNamespace(true), '{{sort_order}}' => (int)$this->getSortOrder(), '{{module}}' => strtolower($this->getModuleName()), '{{Namespace}}' => $this->getNamespace(), '{{Module}}' => $this->getModuleName(), '{{NAMESPACE}}' => strtoupper($this->getNamespace()), '{{MODULE}}' => strtoupper($this->getModuleName()), '{{qwertyuiop}}' => $this->getQwertyuiop(), '{{qwertyuiopp}}' => $this->getQwertyuiopp(), '{{Y}}' => date('Y'), '{{entity_default_config}}' => $this->getEntityDefaultConfig(), '{{module_menu}}' => $this->escapeText($this->getMenuText()), '{{codepool}}' => $this->getCodepool(), '{{version}}' => $this->getVersion(), '{{menuItemsXml}}' => $this->getMenuItemsXml(), '{{menuAcl}}' => $this->getMenuAcl(), '{{ModuleFolder}}' => ucfirst(strtolower($this->getModuleName())), '{{ResourceSetup}}' => $this->getResourceSetupModel(), '{{depends}}' => $this->getDepends(), '{{productViewLayout}}' => $this->getProductViewLayout(), '{{categoryViewLayout}}' => $this->getCategoryViewLayout(), '{{defaultLayoutHandle}}' => $this->getFrontendDefaultLayoutHandle(), '{{categoryMenuEvent}}' => $this->getCategoryMenuEvent(), '{{customerCommentLinks}}' => $this->getCustomerCommentLinks(), '{{frontKey}}' => $this->getFrontKey(), '{{SystemTabName}}' => $this->escapeText($this->getSystemTabName()), '{{systemTabPosition}}' => $this->getSystemTabPosition(), '{{RestResourceGroupsChildren}}' => $this->getRestResourceGroupsChildren(), '{{RestResources}}' => $this->getRestResources(), '{{eavOptionsDefaults}}' => $this->getEavOptionsDefaults() ); } if (is_null($param)) { return $this->_placeholders; } if (isset($this->_placeholders[$param])) { return $this->_placeholders[$param]; } return ''; } /** * get config.xml default section * * @access public * @return string * @author Marius Strajeru */ public function getEntityDefaultConfig() { $eol = $this->getEol(); $text = ''; if ($this->getCreateFrontend()) { $text = $eol.$this->getPadding().''.$eol; $text.= $this->getPadding(2).'<'.strtolower($this->getModuleName()).'>'.$eol; foreach ($this->getEntities() as $entity) { $text .= $this->getPadding(3).$entity->getDefaultConfig(); } $text.= $this->getPadding(2).'getModuleName()).'>'.$eol; $text.= $this->getPadding().''; } return $text; } /** * check if module related to catalog * * @access public * @return bool * @author Marius Strajeru */ public function getHasCatalogRelation() { return $this->getLinkProduct() || $this->getLinkCategory(); } /** * get menu for entities * * @access public * @param $padding * @return string * @author Marius Strajeru */ public function getEntityMenu($padding) { $text = ''; foreach ($this->getEntities() as $entity) { $text .= $entity->getMenu($padding); } return $text; } /** * get menu ACL for entities * * @access public * @param $padding * @return string * @author Marius Strajeru */ public function getEntityMenuAcl($padding) { $text = ''; foreach ($this->getEntities() as $entity) { $text .= $entity->getMenuAcl($padding); } return $text; } /** * sort source code files * * @access protected * @param $files * @param string $sortField * @return array * @author Marius Strajeru */ protected function _sortCodeFiles($files, $sortField = 'sort_order') { $sorted = array(); foreach ($files as $values) { $sorted[(int)$values->$sortField][] = $values; } ksort($sorted); $return = array(); foreach ($sorted as $values) { foreach ($values as $file) { $return[] = $file; } } return $return; } /** * get module name in lower case * * @access public * @return string * @author Marius Strajeru */ public function getLowerModuleName() { return strtolower($this->getModuleName()); } /** * get menu items xml * * @access public * @return string * @author Marius Strajeru */ public function getMenuItemsXml() { $xml = ''; $parts = array(); $padding = 2; $namespace = $this->getNamespace(true); $eol = $this->getEol(); if ($this->getMenuParent()) { $parts = explode('/', $this->getMenuParent()); } foreach ($parts as $part) { $xml .= $this->getPadding($padding++).'<'.$part.'>'.$eol; $xml .= $this->getPadding($padding++).''.$eol; } $xml .= $this->getPadding($padding++).'<'.$namespace.'_'.$this->getLowerModuleName(). ' translate="title" module="'.$namespace.'_'.$this->getLowerModuleName().'">'.$eol; $xml .= $this->getPadding($padding).''.$this->getMenuText().''.$eol; $xml .= $this->getPadding($padding).''.$this->getSortOrder().''.$eol; $xml .= $this->getPadding($padding++).''.$eol; $xml .= $this->getEntityMenu($padding); $xml .= $this->getPadding(--$padding).''.$eol; $xml .= $this->getPadding(--$padding).'getLowerModuleName().'>'; $parts = array_reverse($parts); foreach ($parts as $part) { $xml .= $this->getPadding(--$padding).''.$eol; $xml .= $this->getPadding(--$padding).''.$eol; } return $xml; } /** * get menu ACL * * @access public * @return string * @author Marius Strajeru */ public function getMenuAcl() { $xml = ''; $parts = array(); $padding = 5; $eol = $this->getEol(); $namespace = $this->getNamespace(true); if ($this->getMenuParent()) { $parts = explode('/', $this->getMenuParent()); } foreach ($parts as $part) { $xml .= $this->getPadding($padding++).'<'.$part.'>'.$eol; $xml .= $this->getPadding($padding++).''.$eol; } $xml .= $this->getPadding($padding++).'<'.$namespace.'_'. $this->getLowerModuleName().' translate="title" module="'. $namespace.'_'.$this->getLowerModuleName().'">'.$eol; $xml .= $this->getPadding($padding).''.$this->getMenuText().''.$eol; $xml .= $this->getPadding($padding++).''.$eol; $xml .= $this->getEntityMenuAcl($padding); $xml .= $this->getPadding(--$padding).''.$eol; $xml .= $this->getPadding(--$padding).'getLowerModuleName().'>'; $parts = array_reverse($parts); foreach ($parts as $part) { $xml .= $this->getPadding(--$padding).''.$eol; $xml .= $this->getPadding(--$padding).''.$eol; } return $xml; } /** * get resource setup base class * * @access public * @return string * @author Marius Strajeru */ public function getResourceSetupModel() { if ($this->getHasCatalogRelation() || $this->getHasEav() || $this->getHasCatalogAttribute()) { return 'Mage_Catalog_Model_Resource_Setup'; } return 'Mage_Core_Model_Resource_Setup'; } /** * sort the translation file * * @access protected * @param string $content * @return string * @author Marius Strajeru */ protected function _sortTranslationFile($content) { $lines = explode($this->getEol(), $content); $distinct = array(); foreach ($lines as $line) { if (trim($line)) { $distinct[$line] = 1; } } //remove blank line if (isset($distinct['"",""'])) { unset($distinct['"",""']); } ksort($distinct); $content = implode($this->getEol(), array_keys($distinct)); return $content; } /** * this does nothing * don't look through the code - go away * I said it does nothing * * @access public * @return string * @author Marius Strajeru */ public function getQwertyuiop() { return $this->getHelper()->getQwertyuiop(); } /** * this also does nothing * don't look here either * * @access public * @return string * @author Marius Strajeru */ public function getQwertyuiopp() { return $this->getHelper()->getQwertyuiopp(); } /** * check module dependency * * @access public * @return array * @author Marius Strajeru */ public function getDepends() { if (!$this->hasData('_depends')) { $dependency = array(''=>1); if ($this->getLinkCore() || $this->getHasEav()) { $dependency[''] = 1; } $eol = $this->getEol(); $padding = $this->getPadding(4); $depends = ''; foreach ($dependency as $key=>$value) { $depends = $padding.$key.$eol; } $this->setData('_depends', $depends); } return $this->getData('_depends'); } /** * get layout for product view page * * @access public * @return string * @author Marius Strajeru */ public function getProductViewLayout() { $content = ''; $padding = $this->getPadding(3); $eol = $this->getEol(); $tab = $this->getPadding(); $ns = $this->getNamespace(true); $module = $this->getLowerModuleName(); foreach ($this->getEntities() as $entity) { $name = strtolower($entity->getNameSingular()); $names = strtolower($entity->getNamePlural()); $label = $entity->getLabelPlural(); if ($entity->getShowOnProduct()) { $content .= $padding. ''.$eol; $content .= $padding.$tab. 'detailed_info'.$eol; $content .= $padding.$tab. ''.$label.''.$eol; $content .= $padding.''.$eol; } } return $content; } /** * get layout for category view page * * @access public * @return string * @author Marius Strajeru */ public function getCategoryViewLayout() { $content = ''; $padding = $this->getPadding(3); $eol = $this->getEol(); $ns = $this->getNamespace(true); $module = $this->getLowerModuleName(); foreach ($this->getEntities() as $entity) { $name = $entity->getNameSingular(true); $names = $entity->getNamePlural(true); if ($entity->getShowOnCategory()) { $content .= $padding.''.$eol; } } return $content; } /** * get default layout handle * * @access public * @return string * @author Marius Strajeru */ public function getFrontendDefaultLayoutHandle() { $padding = $this->getPadding(1); $tab = $this->getPadding(); $eol = $this->getEol(); /** @var Ultimate_ModuleCreator_Model_Entity[] $top */ $top = array(); /** @var Ultimate_ModuleCreator_Model_Entity[] $footer */ $footer = array(); $content = $eol.$padding; $namespace = $this->getNamespace(true); $tree = false; if ($this->getCreateFrontend()) { foreach ($this->getEntities() as $entity) { if ($entity->getCreateList()) { if ($entity->getListMenu() == Ultimate_ModuleCreator_Model_Source_Entity_Menu::TOP_LINKS) { $top[] = $entity; } elseif ( $entity->getListMenu() == Ultimate_ModuleCreator_Model_Source_Entity_Menu::FOOTER_LINKS ) { $footer[] = $entity; } if ($entity->getIsTree()) { $tree = true; } } } } if (count($top) > 0 || count($footer) > 0 || $tree) { $content .= ''.$eol; if ($tree) { $content .= $padding.''.$eol; $content .= $padding.$tab.'css/'. $this->getNamespace(true).'_'.$this->getLowerModuleName(). '/tree.css'.$eol; $content .= $padding.''.$eol; } if (count($top) > 0) { $content .= $padding.$tab.''.$eol; $position = 120; foreach ($top as $entity) { $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.''.$entity->getLabelPlural().''.$eol; $content .= $padding.$tab.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.''.$position.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $position += 10; } $content .= $padding.$tab.''.$eol; } if (count($footer) > 0) { $content .= $padding.$tab.''.$eol; $position = 120; foreach ($footer as $entity) { $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab. ''.$eol; $content .= $padding.$tab.$tab.$tab.''.$entity->getLabelPlural().''.$eol; $content .= $padding.$tab.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.''.$position.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $position += 10; } $content .= $padding.$tab.''.$eol; } $content .= $padding.''; } return $content; } /** * get xml for category menu event * * @access public * @return string * @author Marius Strajeru */ public function getCategoryMenuEvent() { if ($this->getShowInCategoryMenu()) { $namespace = $this->getNamespace(true); $eol = $this->getEol(); $padding = $this->getPadding(2); $tab = $this->getPadding(); $content = $eol; $content .= $padding.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.$tab.$tab.'<'.$namespace.'_'.$this->getLowerModuleName().'>'.$eol; $content .= $padding.$tab.$tab.$tab.$tab. ''.$namespace.'_'.$this->getLowerModuleName().'/observer'.$eol; $content .= $padding.$tab.$tab.$tab.$tab.'addItemsToTopmenuItems'.$eol; $content .= $padding.$tab.$tab.$tab.'getLowerModuleName().'>'.$eol; $content .= $padding.$tab.$tab.''.$eol; $content .= $padding.$tab.''.$eol; $content .= $padding.''.$eol; return $content; } return ''; } /** * get customer comment links * * @access public * @return string * @author Marius Strajeru */ public function getCustomerCommentLinks() { $namespace = $this->getNamespace(true); $eol = $this->getEol(); $padding = $this->getPadding(3); $content = $eol; $module = $this->getLowerModuleName(); foreach ($this->getEntities() as $entity) { if ($entity->getAllowComment()) { $entityName = $entity->getNameSingular(true); $label = $entity->getLabelPlural(); $content .= $padding . ''.$entityName.'_comments'. $namespace.'_'.$module.'/'.$entityName.'_customer_comment'.$eol; } } return $content; } /** * get the module namespace * * @access public * @param bool $lower * @return mixed|string * @author Marius Strajeru */ public function getNamespace($lower = false) { $namespace = $this->escapeText($this->getData('namespace')); if ($lower) { $namespace = strtolower($namespace); } return $namespace; } /** * get front key * * @access public * @return mixed * @author Marius Strajeru */ public function getFrontKey() { if (!$this->getCreateFrontend()) { return $this->getData('front_key'); } if (!$this->getData('front_key')) { $frontKey = $this->getNamespace(true).'_'.$this->getLowerModuleName(); $this->setData('front_key', $frontKey); } return $this->getData('front_key'); } /** * system configuration tab name * * @access public * @return string * @author Marius Strajeru */ public function getSystemTabName() { if (!$this->getData('system_tab')) { $this->setData('system_tab', $this->getNamespace()); } return $this->getData('system_tab'); } /** * system configuration tab position * * @access public * @return string * @author Marius Strajeru */ public function getSystemTabPosition() { return (int)$this->getData('system_tab_position'); } /** * get xml for api2.xml resource groups children * @access public * @return string * @author Marius Strajeru */ public function getRestResourceGroupsChildren() { $content = ''; foreach ($this->getEntities() as $entity) { $content .= $entity->getRestResourceGroup(5); } return $content; } /** * get xml for api2.xml resources * * @access public * @return string * @author Marius Strajeru */ public function getRestResources() { $content = ''; foreach ($this->getEntities() as $entity) { $content .= $entity->getRestResource(3); } return $content; } /** * get eav default values * * @access public * @return string * @author Marius Strajeru */ public function getEavOptionsDefaults() { $content = ''; foreach ($this->getEntities() as $entity) { if ($entity->getIsEav()) { foreach ($entity->getAttributes() as $attribute) { $content .= $attribute->getDefaultValueSetup(); } } } return $content; } /** * check if there are sibling relations * * @access public * @return bool * @author Marius Strajeru */ public function getHasRelationColumnRenderer() { if (count($this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_SIBLING)) > 0) { return true; } foreach ($this->getEntities() as $_entity) { if ($_entity->getLinkCore()) { return true; } } return false; } /** * check if there are parent-child relations * * @access public * @return bool * @author Marius Strajeru */ public function getHasParentRelation() { $parentRelations = $this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_PARENT); if (count($parentRelations)) { return true; } $childRelations = $this->getRelations(Ultimate_ModuleCreator_Model_Relation::RELATION_TYPE_CHILD); if (count($childRelations)) { return true; } return false; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Relation.php ================================================ */ class Ultimate_ModuleCreator_Model_Relation extends Ultimate_ModuleCreator_Model_Abstract { /** * relation type constants */ const RELATION_TYPE_NONE = 'none'; const RELATION_TYPE_CHILD = 'child'; const RELATION_TYPE_PARENT = 'parent'; const RELATION_TYPE_SIBLING = 'sibling'; /** * @var Ultimate_ModuleCreator_Model_Entity */ protected $_entity1; /** * @var Ultimate_ModuleCreator_Model_Entity */ protected $_entity2; /** * relation type * * @var string */ protected $_type; /** * set entities in relation * * @access public * @param Ultimate_ModuleCreator_Model_Entity $entity1 * @param Ultimate_ModuleCreator_Model_Entity $entity2 * @param int $type * @return Ultimate_ModuleCreator_Model_Relation * @author Marius Strajeru */ public function setEntities( Ultimate_ModuleCreator_Model_Entity $entity1, Ultimate_ModuleCreator_Model_Entity $entity2, $type ) { $this->_entity1 = $entity1; $this->_entity2 = $entity2; $this->_type = $type; switch($type) { case self::RELATION_TYPE_NONE: break; case self::RELATION_TYPE_CHILD: $this->_entity1->addRelatedEntity($type, $this->_entity2); $this->_entity2->addRelatedEntity(self::RELATION_TYPE_PARENT, $this->_entity1); break; case self::RELATION_TYPE_PARENT: $this->_entity1->addRelatedEntity($type, $this->_entity2); $this->_entity2->addRelatedEntity(self::RELATION_TYPE_CHILD, $this->_entity1); break; case self::RELATION_TYPE_SIBLING: $this->_entity1->addRelatedEntity($type, $this->_entity2); $this->_entity2->addRelatedEntity(self::RELATION_TYPE_SIBLING, $this->_entity1); break; default: break; } return $this; } /** * get the relation type * * @access public * @return int * @author Marius Strajeru */ public function getType() { return $this->_type; } /** * get relation entities * * @access public * @return Ultimate_ModuleCreator_Model_Entity[] * @author Marius Strajeru */ public function getEntities() { return array($this->_entity1, $this->_entity2); } /** * relation to xml * * @access protected * @param array $arrAttributes * @param string $rootName * @param bool $addOpenTag * @param bool $addCdata * @return string * @author Marius Strajeru */ public function toXml(array $arrAttributes = array(), $rootName = 'relation', $addOpenTag=false, $addCdata=false) { $xml = ''; $eol = $this->getEol(); if ($rootName) { $xml .= '<'.$rootName.'>'.$eol; } $entities = $this->getEntities(); $xml .= '<'.$entities[0]->getNameSingular().'_'.$entities[1]->getNameSingular().'>'; $xml .= $this->getType(); $xml .= 'getNameSingular().'_'.$entities[1]->getNameSingular().'>'.$eol; if ($rootName) { $xml .= ''.$eol; } return $xml; } /** * check if siblings can be listed in the entity view page * * @access public * @param int $index * @return bool * @author Marius Strajeru */ public function getShowFrontendRelationSiblings($index) { if ($this->getType() != self::RELATION_TYPE_SIBLING) { return false; } $index = !!$index; $entities = $this->getEntities(); $e = $entities[$index]; return $e->getCreateView(); } /** * check if children can be listed in the parent view page * * @access public * @return bool * @author Marius Strajeru */ public function getShowFrontendRelationChildren() { if ($this->getType() == self::RELATION_TYPE_CHILD) { $index = 1; } elseif ($this->getType() == self::RELATION_TYPE_PARENT) { $index = 0; } else { return false; } $entities = $this->getEntities(); $e = $entities[$index]; return $e->getCreateView(); } /** * check if a relations has tree entities * * @access public * @return bool * @author Marius Strajeru */ public function getHasTree() { return $this->_entity1->getIsTree() || $this->_entity2->getIsTree(); } /** * check if a relations does not have tree entities * * @access public * @return bool * @author Marius Strajeru */ public function getNotHasTree() { return !$this->getHasTree(); } /** * check if one of the entities behaves as tree * * @access public * @param int $index * @return bool * @author Marius Strajeru */ public function getEntityIsTree($index) { $entities = $this->getEntities(); return $entities[$index]->getIsTree(); } /** * check if one of the entities behaves as tree * * @access public * @param int $index * @return bool * @author Marius Strajeru */ public function getSiblingIsTree($index) { return $this->getEntityIsTree(1 - $index); } /** * check if one of the entities does not behave as tree * * @access public * @param int $index * @return bool * @author Marius Strajeru */ public function getSiblingIsNotTree($index) { return !$this->getSiblingIsTree($index); } /** * check if entity has API * * @access public * @param int $index * @return bool * @author Marius Strajeru */ public function getEntityHasApi($index) { $entities = $this->getEntities(); return $entities[$index]->getApi(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Source/Attribute/Scope.php ================================================ */ /** * allowed attribute scopes * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Source_Attribute_Scope { /** * options * * @var null */ protected $_options = null; /** * get options array * * @access public * @param bool $withEmpty * @return array|null * @author Marius Strajeru */ public function toArray($withEmpty = false) { if (is_null($this->_options)) { $this->_options = array(); $this->_options[] = array( 'label' => Mage::helper('modulecreator')->__('Store View'), 'value' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE ); $this->_options[] = array( 'label' => Mage::helper('modulecreator')->__('Website'), 'value' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE ); $this->_options[] = array( 'label' => Mage::helper('modulecreator')->__('Global'), 'value' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL ); } $options = $this->_options; if ($withEmpty) { $options = array_merge(array(''=>''), $options); } return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Source/Attribute/Type.php ================================================ */ /** * allowed attribute types * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Source_Attribute_Type { /** * options * * @var mixed */ protected $_options = null; /** * get options array * * @access public * @param bool $withEmpty * @return array|null * @author Marius Strajeru */ public function toArray($withEmpty = false) { if (is_null($this->_options)) { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $types = $helper->getAttributeTypes(); $groups = $helper->getAttributeTypeGroups(); foreach ($groups as $key=>$group) { $this->_options[$key] = array('label'=>(string)$group->label, 'value'=>array()); } foreach ($types as $type=>$values) { $group = (string)$values->group; if (!empty($group) && isset($this->_options[$group])) { $this->_options[$group]['value'][] = array('label'=>(string)$values->label, 'value'=>$type); } else { $this->_options[] = array('label'=>(string)$values->label, 'value'=>$type); } } $this->_options = array_values($this->_options); } $options = $this->_options; if ($withEmpty) { array_unshift($options, array('label'=>'', 'value'=>'')); } return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Source/Attribute/Value/Source.php ================================================ */ /** * allowed attribute sources * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Source_Attribute_Value_Source { /** * options * * @var mixed */ protected $_options = null; /** * get options array * * @access public * @param bool $withEmpty * @return array|null * @author Marius Strajeru */ public function toArray($withEmpty = false) { if (is_null($this->_options)) { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $options = $helper->getDropdownSubtypes(true); $this->_options = array(); foreach ($options as $key=>$option) { $this->_options[$key] = $option->label; } } $options = $this->_options; if ($withEmpty) { $options = array_merge(array(''=>''), $options); } return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Source/Codepool.php ================================================ */ class Ultimate_ModuleCreator_Model_Source_Codepool { /** * get the list of available code pools * * @access public * @param bool $withEmpty * @return array * @author Marius Strajeru */ public function toOptionArray($withEmpty = false) { $options = array(); if ($withEmpty) { $options[] = array( 'value'=>'', 'label'=>Mage::helper('modulecreator')->__('Select a codepool') ); } $options[] = array('value' => 'local', 'label'=>'local'); $options[] = array('value' => 'community', 'label'=>'community'); return $options; } /** * get options as an array * * @access public * @param bool $withEmpty * @return array * @author Marius Strajeru */ public function getAllOptions($withEmpty = true) { $options = array(); foreach ($this->toOptionArray($withEmpty) as $option) { $options[$option['value']] = $option['label']; } return $options; } /** * get options as an array - wrapper * * @param bool $withEmpty * @return array * @author Marius Strajeru */ public function toArray($withEmpty = true) { return $this->getAllOptions($withEmpty); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Source/Entity/Layout.php ================================================ */ /** * allowed entity layouts * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Source_Entity_Layout { /** * options * * @var mixed */ protected $_options = null; /** * get options array * * @access public * @param bool $withEmpty * @return array|null * @author Marius Strajeru */ public function toArray($withEmpty = false) { if (is_null($this->_options)) { /** @var Mage_Page_Model_Source_Layout $layoutModel */ $layoutModel = Mage::getSingleton('page/source_layout'); $_options = $layoutModel->toOptionArray(); foreach ($_options as $option) { $this->_options[$option['value']] = $option['label']; } } $options = $this->_options; if ($withEmpty) { $options = array_merge(array(''=>''), $options); } return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Source/Entity/Menu.php ================================================ */ /** * available menus * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Source_Entity_Menu { const NO_MENU = 0; const TOP_LINKS = 1; const CATEGORY_MENU = 2; const FOOTER_LINKS = 3; /** * options * * @var mixed */ protected $_options = null; /** * get options array * * @access public * @param bool $withEmpty * @return array|null * @author Marius Strajeru */ public function toArray($withEmpty = false) { if (is_null($this->_options)) { $this->_options[self::NO_MENU] = Mage::helper('modulecreator')->__('Do not include in any menu'); $this->_options[self::TOP_LINKS] = Mage::helper('modulecreator') ->__('Include in top links. (near My account, Checkout, ...)'); $this->_options[self::CATEGORY_MENU] = Mage::helper('modulecreator')->__('Include in category menu'); $this->_options[self::FOOTER_LINKS] = Mage::helper('modulecreator')->__('Include in footer links'); } $options = $this->_options; if ($withEmpty) { $options = array_merge(array(''=>''), $options); } return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Source/Entity/Type.php ================================================ */ /** * allowed entity types * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Source_Entity_Type { /** * options * * @var mixed */ protected $_options = null; /** * get options array * * @access public * @param bool $withEmpty * @return array|null * @author Marius Strajeru */ public function toArray($withEmpty = false) { if (is_null($this->_options)) { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $types = $helper->getEntityTypes(); foreach ($types as $type=>$values) { $this->_options[$type] = Mage::helper('modulecreator')->__((string)$values->label); } } $options = $this->_options; if ($withEmpty) { $options = array_merge(array(''=>''), $options); } return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Source/Install.php ================================================ */ /** * install source mode * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Model_Source_Install { /** * get the list of available install actions * * @access public * @param bool $withEmpty * @return array * @author Marius Strajeru */ public function toOptionArray($withEmpty = false) { $options = array(); if ($withEmpty) { $options[] = array( 'value'=>'', 'label'=>Mage::helper('modulecreator')->__('Select action') ); } $options[] = array( 'value' => '1', 'label'=>Mage::helper('modulecreator')->__('Install new extension on the current instance.') ); $options[] = array( 'value' => '0', 'label'=>Mage::helper('modulecreator')->__('Create archive. I will install it later') ); return $options; } /** * get options as an array * * @access public * @param bool $withEmpty * @return array * @author Marius Strajeru */ public function getAllOptions($withEmpty = true) { $options = array(); foreach ($this->toOptionArray($withEmpty) as $option) { $options[$option['value']] = $option['label']; } return $options; } /** * get options as an array - wrapper * * @param bool $withEmpty * @return array * @author Marius Strajeru */ public function toArray($withEmpty = true) { return $this->getAllOptions($withEmpty); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/Model/Writer.php ================================================ */ class Ultimate_ModuleCreator_Model_Writer extends Mage_Connect_Package_Writer { /** * prefix for path * * @var string */ protected $_pathPrefix = ''; /** * set path prefix * * @param $pathPrefix * @return $this * @author Marius Strajeru */ public function setPathPrefix($pathPrefix) { $this->_pathPrefix = $pathPrefix; return $this; } /** * build the package * * @access public * @return Ultimate_ModuleCreator_Model_Writer * @see Mage_Connect_Package_Writer::composePackage() * @author Marius Strajeru */ public function composePackage() { @mkdir(self::PATH_TO_TEMPORARY_DIRECTORY, 0777, true); $root = self::PATH_TO_TEMPORARY_DIRECTORY . basename($this->_namePackage); @mkdir($root, 0777, true); foreach ($this->_files as $file) { if (is_dir($file) || is_file($file)) { $fileName = basename($file); $filePath = dirname($file); if (substr($filePath, 0, strlen($this->_pathPrefix)) == $this->_pathPrefix) { $filePath = substr($filePath, strlen($this->_pathPrefix)); } @mkdir($root . DS . $filePath, 0777, true); if (is_file($file)) { copy($file, $root . DS . $filePath . DS . $fileName); } else { @mkdir($root . DS . $filePath . $fileName, 0777); } } } $this->_temporaryPackageDir = $root; return $this; } /** * set the package name * * @access public * @param string $name * @return Ultimate_ModuleCreator_Model_Writer * @author Marius Strajeru */ public function setNamePackage($name) { $this->_namePackage = $name; return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/controllers/Adminhtml/ModulecreatorController.php ================================================ */ /** * main admin controller * * @category Ultimate * @package Ultimate_ModuleCreator * @author Marius Strajeru */ class Ultimate_ModuleCreator_Adminhtml_ModulecreatorController extends Mage_Adminhtml_Controller_Action { /** * default action * * @access public * @return void * @author Marius Strajeru */ public function indexAction() { $this->_title(Mage::helper('modulecreator')->__('Ultimate module creator')); $this->_getSession()->addNotice( Mage::helper('modulecreator')->__( 'To delete a module from this list go to "%s" and remove the files "%s" and "%s" and folder "%s" if they exist. Replace Namespace_Module with the appropriate value for each module. There is no delete link in here for security reasons.', Mage::getBaseDir('var').DS.'modulecreator', 'Namespace_Module.tgz', 'package/Namespace_Module.xml', 'package/Namespace_Module/' ) ); $this->loadLayout(); $this->renderLayout(); } /** * grid action * * @access public * @return void * @author Marius Strajeru */ public function gridAction() { $this->loadLayout(); $this->renderLayout(); } /** * new action * * @access public * @return void * @author Marius Strajeru */ public function newAction() { $this->_forward('edit'); } /** * edit action * * @access public * @return void * @author Marius Strajeru */ public function editAction() { $module = $this->_initModule(); $this->_title(Mage::helper('modulecreator')->__('Ultimate module creator')); if ($module) { $extensionName = $module->getNamespace().'_'.$module->getModuleName(); $this->_getSession()->addNotice( Mage::helper('modulecreator')->__( 'You are editing the module: %s', $extensionName ) ); $this->_title($extensionName); } else { $this->_title(Mage::helper('modulecreator')->__('Add module')); } $this->loadLayout(); $this->renderLayout(); } /** * init module * * @access protected * @return mixed * @author Marius Strajeru */ protected function _initModule() { $packageName = base64_decode(strtr($this->getRequest()->getParam('id'), '-_,', '+/=')); if ($packageName) { try { /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $path = $helper->getLocalPackagesPath(); $packageName = basename($packageName); $xmlFile = $path . $packageName . '.xml'; if (file_exists($xmlFile) && is_readable($xmlFile)) { $xml = simplexml_load_file($xmlFile, 'Varien_Simplexml_Element'); $module = $helper->loadModule($xml); Mage::register('current_module', $module); return $module; } } catch (Exception $e) { Mage::logException($e); $this->_getSession()->addError($e->getMessage()); $this->_redirect('*/*/index'); } } return false; } /** * init a module from an array * * @access public * @param array $data * @return Ultimate_ModuleCreator_Model_Module * @author Marius Strajeru */ protected function _initModuleFromData($data) { $entitiesByIndex = array(); /** @var Ultimate_ModuleCreator_Model_Module $module */ $module = Mage::getModel('modulecreator/module'); if (isset($data['settings'])) { $module->addData($data['settings']); } if (isset($data['entity'])) { $entities = $data['entity']; if (is_array($entities)) { foreach ($entities as $key=>$entityData) { /** @var Ultimate_ModuleCreator_Model_Entity $entity */ $entity = Mage::getModel('modulecreator/entity'); $entity->addData($entityData); $entity->setIndex($key); if (isset($entityData['attributes']) && is_array($entityData['attributes'])) { if (isset($entityData['attributes']['is_name'])) { $isName = $entityData['attributes']['is_name']; unset($entityData['attributes']['is_name']); if (isset($entityData['attributes'][$isName])) { $entityData['attributes'][$isName]['is_name'] = 1; } } foreach ($entityData['attributes'] as $aKey=>$attributeData) { /** @var Ultimate_ModuleCreator_Model_Attribute $attribute */ $attribute = Mage::getModel('modulecreator/attribute'); $attribute->addData($attributeData); $attribute->setIndex($aKey); $entity->addAttribute($attribute); } } $module->addEntity($entity); $entitiesByIndex[$key] = $entity; } } if (isset($data['relation'])) { foreach($data['relation'] as $index => $values) { foreach ($values as $jndex=>$type) { if (isset($entitiesByIndex[$index]) && isset($entitiesByIndex[$jndex])) { /** @var Ultimate_ModuleCreator_Model_Relation $relation */ $relation = Mage::getModel('modulecreator/relation'); $relation->setEntities($entitiesByIndex[$index], $entitiesByIndex[$jndex], $type); $module->addRelation($relation); } } } } } return $module; } /** * validate module before saving * * @access public * @return void * @author Marius Strajeru */ public function validateAction() { try{ $response = new Varien_Object(); $module = $this->_initModuleFromData($this->getRequest()->getPost()); $errors = $module->validate(); if (count($errors) == 0) { $messages = $module->buildModule(); $module->save(); $response->setError(false); } else { if (isset($errors[''])) { $response->setMessage(implode('
    ', $errors[''])); unset($errors['']); } $response->setError(true); $response->setAttributes($errors); } } catch (Exception $e){ $response->setError(true); $response->setMessage($e->getMessage()); } $this->getResponse()->setBody($response->toJson()); } /** * save module - actually only redirects the page * the save was done in validateAction(). there is no need to process the request twice. * * @access public * @return void * @author Marius Strajeru */ public function saveAction() { $this->_getSession()->addSuccess( Mage::helper('modulecreator')->__('Your extension has been created!') ); $module = $this->_initModuleFromData($this->getRequest()->getPost()); $redirectBack = $this->getRequest()->getParam('back', false); if ($redirectBack) { $this->_redirect( '*/*/edit', array( 'id' => strtr(base64_encode($module->getExtensionName()), '+/=', '-_,'), '_current' => true ) ); } else { $this->_redirect('*/*/'); } } /** * download module action * * @access public * @return void * @author Marius Strajeru */ public function downloadAction() { $what = $this->getRequest()->getParam('type'); $packageName = base64_decode(strtr($this->getRequest()->getParam('id'), '-_,', '+/=')); /** @var Ultimate_ModuleCreator_Helper_Data $helper */ $helper = Mage::helper('modulecreator'); $path = $helper->getLocalModulesDir(); $namePrefix = ''; switch ($what) { case 'config' : $file = $path.'package'.DS.$packageName . '.xml'; break; case 'list': $file = $path.'package'.DS.$packageName . DS. 'files.log'; $namePrefix = $packageName.'_'; break; case 'uninstall' : $file = $path.'package'.DS.$packageName . DS. 'uninstall.sql'; $namePrefix = $packageName.'_'; break; default: $file = $path . $packageName . '.tgz'; break; } if (file_exists($file) && is_readable($file)) { $content = file_get_contents($file); $this->_prepareDownloadResponse($namePrefix.basename($file), $content); } else { $this->_getSession()->addError( Mage::helper('modulecreator')->__( 'Your extension archive was not created or is not readable' ) ); $this->_redirect('*/*'); } } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/adminhtml.xml ================================================ Ultimate module creator Module creator 10 Module creator 10 adminhtml/modulecreator Ultimate_ModuleCreator ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/config.xml ================================================ 1.9.6.0 Ultimate_ModuleCreator_Block Ultimate_ModuleCreator_Helper Ultimate_ModuleCreator_Model Ultimate_ModuleCreator.csv ultimate_modulecreator.xml Ultimate_ModuleCreator_Adminhtml 1 1 1 Ultimate local 0 1.0.0 2000 flat 0 1 1 1 1 0 0 1 1 two_columns_left 1 two_columns_left 1 1 1 1 1 1 0 1 1 0 1 0 1 1 0 1 General General Information text 0 1 0 1 1 1 1 custom ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/jstranslator.xml ================================================ Are you sure? Remove field / attribute ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Catalog/Category/Tab/Entity/010_tree ================================================ setTemplate('{{namespace}}_{{module}}/catalog/category/tab/{{entities}}.phtml'); } /** * Retrieve currently edited category * * @access public * @return Mage_Catalog_Model_Entity * {{qwertyuiop}} */ public function getCategory() { return Mage::registry('current_category'); } /** * Return array with {{entitiesLabel}} IDs which the category is linked to * * @access public * @return array * {{qwertyuiop}} */ public function get{{Entities}}Ids() { if (is_null($this->_{{entities}}Ids)) { ${{entities}} = Mage::helper('{{namespace}}_{{module}}/category') ->getSelected{{Entities}}($this->getCategory()); $ids = array(); foreach (${{entities}} as ${{entity}}) { $ids[] = ${{entity}}->getId(); } $this->_{{entity}}Ids = $ids; } return $this->_{{entity}}Ids; } /** * Forms string out of get{{Entity}}Ids() * * @access public * @return string * {{qwertyuiop}} */ public function getIdsString() { return implode(',', $this->get{{Entities}}Ids()); } /** * Returns root node and sets 'checked' flag (if necessary) * * @access public * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRootNode() { $root = $this->getRoot(); if ($root && in_array($root->getId(), $this->get{{Entities}}Ids())) { $root->setChecked(true); } return $root; } /** * Returns root node * * @param {{Namespace}}_{{Module}}_Model_{{Entity}}|null $parentNode{{Entity}} * @param int $recursionLevel * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRoot($parentNode{{Entity}} = null, $recursionLevel = 3) { if (!is_null($parentNode{{Entity}}) && $parentNode{{Entity}}->getId()) { return $this->getNode($parentNode{{Entity}}, $recursionLevel); } $root = Mage::registry('{{entity}}_root'); if (is_null($root)) { $rootId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); $ids = $this->getSelected{{Entity}}PathIds($rootId); $tree = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_tree') ->loadByIds($ids, false, false); if ($this->getCategory()) { $tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId)); } $tree->addCollectionData($this->get{{Entity}}Collection()); $root = $tree->getNodeById($rootId); Mage::register('{{entity}}_root', $root); } return $root; } /** * Returns array with configuration of current node * * @access public * @param Varien_Data_Tree_Node $node * @param int $level How deep is the node in the tree * @return array * {{qwertyuiop}} */ protected function _getNodeJson($node, $level = 1) { $item = parent::_getNodeJson($node, $level); if ($this->_isParentSelected{{Entity}}($node)) { $item['expanded'] = true; } if (in_array($node->getId(), $this->get{{Entities}}Ids())) { $item['checked'] = true; } return $item; } /** * Returns whether $node is a parent (not exactly direct) of a selected node * * @access public * @param Varien_Data_Tree_Node $node * @return bool * {{qwertyuiop}} */ protected function _isParentSelected{{Entity}}($node) { $result = false; // Contains string with all {{entityLabel}} IDs of children (not exactly direct) of the node $allChildren = $node->getAllChildren(); if ($allChildren) { $selected{{Entity}}Ids = $this->get{{Entity}}Ids(); $allChildrenArr = explode(',', $allChildren); for ($i = 0, $cnt = count($selected{{Entity}}Ids); $i < $cnt; $i++) { $isSelf = $node->getId() == $selected{{Entity}}Ids[$i]; if (!$isSelf && in_array($selected{{Entity}}Ids[$i], $allChildrenArr)) { $result = true; break; } } } return $result; } /** * Returns array with nodes those are selected (contain current {{entityLabel}}) * * @access protected * @return array * {{qwertyuiop}} */ protected function _getSelectedNodes() { if ($this->_selectedNodes === null) { $this->_selectedNodes = array(); $root = $this->getRoot(); foreach ($this->get{{Entity}}Ids() as ${{entity}}Id) { if ($root) { $this->_selectedNodes[] = $root->getTree()->getNodeById(${{entity}}Id); } } } return $this->_selectedNodes; } /** * Returns JSON-encoded array of {{entityLabel}} children * * @access public * @param int ${{entity}}Id * @return string * {{qwertyuiop}} */ public function get{{Entity}}ChildrenJson(${{entity}}Id) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id); $node = $this->getRoot(${{entity}}, 1)->getTree()->getNodeById(${{entity}}Id); if (!$node || !$node->hasChildren()) { return '[]'; } $children = array(); foreach ($node->getChildren() as $child) { $children[] = $this->_getNodeJson($child); } return Mage::helper('core')->jsonEncode($children); } /** * Returns URL for loading tree * * @access public * @param null $expanded * @return string * {{qwertyuiop}} */ public function getLoadTreeUrl($expanded = null) { return $this->getUrl( '*/{{module}}_{{entity}}_catalog_category/{{entities}}Json', array('_current' => true) ); } /** * Return distinct path ids of selected {{entityLabel}} * * @access public * @param mixed $rootId Root {{entityLabel}} Id for context * @return array * {{qwertyuiop}} */ public function getSelected{{Entity}}PathIds($rootId = false) { $ids = array(); ${{entity}}Ids = $this->get{{Entity}}Ids(); if (empty(${{entity}}Ids)) { return array(); } $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_collection'); if ($rootId) { $collection->addFieldToFilter('parent_id', $rootId); } else { $collection->addFieldToFilter('entity_id', array('in'=>${{entity}}Ids)); } foreach ($collection as $item) { if ($rootId && !in_array($rootId, $item->getPathIds())) { continue; } foreach ($item->getPathIds() as $id) { if (!in_array($id, $ids)) { $ids[] = $id; } } } return $ids; } /** * Get node label * * @access public * @param Varien_Object $node * @return string * {{qwertyuiop}} */ public function buildNodeName($node) { $result = parent::buildNodeName($node); $result .= ''.$this->__(' - Edit').''; return $result; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Catalog/Category/Tab/Entity/020_not_tree ================================================ setId('catalog_category_{{entity}}'); $this->setDefaultSort('entity_id'); $this->setUseAjax(true); if ($this->getCategory()->getId()) { $this->setDefaultFilter(array('in_{{entities}}'=>1)); } } /** * get current category * * @access public * @return Mage_Catalog_Model_Category|null * {{qwertyuiop}} */ public function getCategory() { return Mage::registry('current_category'); } /** * prepare the collection * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Category_Tab_{{Entity}} * {{qwertyuiop}} */ protected function _prepareCollection() { /* @var $collection {{Namespace}}_{{Module}}_Resource_{{Entity}}_Collection */ $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_collection'){{additionalPrepareCollection}}; if ($this->getCategory()->getId()) { $constraint = 'related.category_id='.$this->getCategory()->getId(); } else { $constraint = 'related.category_id=0'; } $collection->getSelect()->joinLeft( array('related' => $collection->getTable('{{namespace}}_{{module}}/{{entity}}_category')), 'related.{{entity}}_id={{entityTableAlias}}.entity_id AND '.$constraint, array('position') ); $this->setCollection($collection); parent::_prepareCollection(); return $this; } /** * Prepare the columns * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Category_Tab_{{Entity}} * {{qwertyuiop}} */ protected function _prepareColumns() { $this->addColumn( 'in_{{entities}}', array( 'header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_{{entities}}', 'values' => $this->_getSelected{{Entities}}(), 'align' => 'center', 'index' => 'entity_id' ) ); $this->addColumn( 'entity_id', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Id'), 'type' => 'number', 'align' => 'left', 'index' => 'entity_id', ) ); $this->addColumn( '{{nameAttributeCode}}', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('{{nameAttributeLabel}}'), 'align' => 'left', 'index' => '{{nameAttributeCode}}', 'renderer' => '{{namespace}}_{{module}}/adminhtml_helper_column_renderer_relation', 'params' => array( 'id' => 'getId' ), 'base_link' => 'adminhtml/{{module}}_{{entity}}/edit', ) ); $this->addColumn( 'position', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Position'), 'name' => 'position', 'width' => 60, 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => true, ) ); return parent::_prepareColumns(); } /** * Retrieve selected {{entities}} * * @access protected * @return array * {{qwertyuiop}} */ protected function _getSelected{{Entities}}() { ${{entities}} = $this->getCategory{{Entities}}(); if (!is_array(${{entities}})) { ${{entities}} = array_keys($this->getSelected{{Entities}}()); } return ${{entities}}; } /** * Retrieve selected {{entities}} * * @access protected * @return array * {{qwertyuiop}} */ public function getSelected{{Entities}}() { ${{entities}} = array(); // used helper here in order not to override the category model $selected = Mage::helper('{{namespace}}_{{module}}/category')->getSelected{{Entities}}(Mage::registry('current_category')); if (!is_array($selected)) { $selected = array(); } foreach ($selected as ${{entity}}) { ${{entities}}[${{entity}}->getId()] = array('position' => ${{entity}}->getPosition()); } return ${{entities}}; } /** * get row url * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} * @return string * {{qwertyuiop}} */ public function getRowUrl($item) { return '#'; } /** * get grid url * * @access public * @return string * {{qwertyuiop}} */ public function getGridUrl() { return $this->getUrl( 'adminhtml/{{module}}_{{entity}}_catalog_category/{{entities}}grid', array( 'id'=>$this->getCategory()->getId() ) ); } /** * Add filter * * @access protected * @param object $column * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Category_Tab_{{Entity}} * {{qwertyuiop}} */ protected function _addColumnFilterToCollection($column) { if ($column->getId() == 'in_{{entities}}') { ${{entity}}Ids = $this->_getSelected{{Entities}}(); if (empty(${{entity}}Ids)) { ${{entity}}Ids = 0; } if ($column->getFilter()->getValue()) { $this->getCollection()->addFieldToFilter('entity_id', array('in'=>${{entity}}Ids)); } else { if (${{entity}}Ids) { $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>${{entity}}Ids)); } } } else { parent::_addColumnFilterToCollection($column); } return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Catalog/Product/Edit/Tab/Entity/010_top ================================================ setId('{{entity}}_grid'); $this->setDefaultSort('position'); $this->setDefaultDir('ASC'); $this->setUseAjax(true); if ($this->getProduct()->getId()) { $this->setDefaultFilter(array('in_{{entities}}'=>1)); } } /** * prepare the {{entity}} collection * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}} * {{qwertyuiop}} */ protected function _prepareCollection() { /* @var $collection {{Namespace}}_{{Module}}_Resource_{{Entity}}_Collection */ $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_collection'){{additionalPrepareCollection}}; if ($this->getProduct()->getId()) { $constraint = 'related.product_id='.$this->getProduct()->getId(); } else { $constraint = 'related.product_id=0'; } $collection->getSelect()->joinLeft( array('related' => $collection->getTable('{{namespace}}_{{module}}/{{entity}}_product')), 'related.{{entity}}_id={{entityTableAlias}}.entity_id AND '.$constraint, array('position') ); $this->setCollection($collection); parent::_prepareCollection(); return $this; } /** * prepare mass action grid * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}} * {{qwertyuiop}} */ protected function _prepareMassaction() { return $this; } /** * prepare the grid columns * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}} * {{qwertyuiop}} */ protected function _prepareColumns() { $this->addColumn( 'in_{{entities}}', array( 'header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_{{entities}}', 'values'=> $this->_getSelected{{Entities}}(), 'align' => 'center', 'index' => 'entity_id' ) ); $this->addColumn( '{{nameAttributeCode}}', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('{{nameAttributeLabel}}'), 'align' => 'left', 'index' => '{{nameAttributeCode}}', 'renderer' => '{{namespace}}_{{module}}/adminhtml_helper_column_renderer_relation', 'params' => array( 'id' => 'getId' ), 'base_link' => 'adminhtml/{{module}}_{{entity}}/edit', ) ); $this->addColumn( 'position', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Position'), 'name' => 'position', 'width' => 60, 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => true, ) ); return parent::_prepareColumns(); } /** * Retrieve selected {{entities}} * * @access protected * @return array * {{qwertyuiop}} */ protected function _getSelected{{Entities}}() { ${{entities}} = $this->getProduct{{Entities}}(); if (!is_array(${{entities}})) { ${{entities}} = array_keys($this->getSelected{{Entities}}()); } return ${{entities}}; } /** * Retrieve selected {{entities}} * * @access protected * @return array * {{qwertyuiop}} */ public function getSelected{{Entities}}() { ${{entities}} = array(); // used helper here in order not to override the product model $selected = Mage::helper('{{namespace}}_{{module}}/product')->getSelected{{Entities}}(Mage::registry('current_product')); if (!is_array($selected)) { $selected = array(); } foreach ($selected as ${{entity}}) { ${{entities}}[${{entity}}->getId()] = array('position' => ${{entity}}->getPosition()); } return ${{entities}}; } /** * get row url * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} * @return string * {{qwertyuiop}} */ public function getRowUrl($item) { return '#'; } /** * get grid url * * @access public * @return string * {{qwertyuiop}} */ public function getGridUrl() { return $this->getUrl( '*/*/{{entities}}Grid', array( 'id'=>$this->getProduct()->getId() ) ); } /** * get the current product * * @access public * @return Mage_Catalog_Model_Product * {{qwertyuiop}} */ public function getProduct() { return Mage::registry('current_product'); } /** * Add filter * * @access protected * @param object $column * @return {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}} * {{qwertyuiop}} */ protected function _addColumnFilterToCollection($column) { if ($column->getId() == 'in_{{entities}}') { ${{entity}}Ids = $this->_getSelected{{Entities}}(); if (empty(${{entity}}Ids)) { ${{entity}}Ids = 0; } if ($column->getFilter()->getValue()) { $this->getCollection()->addFieldToFilter('entity_id', array('in'=>${{entity}}Ids)); } else { if (${{entity}}Ids) { $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>${{entity}}Ids)); } } } else { parent::_addColumnFilterToCollection($column); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Catalog/Product/Edit/Tab/Entity/030_tree ================================================ class {{Namespace}}_{{Module}}_Block_Adminhtml_Catalog_Product_Edit_Tab_{{Entity}} extends {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Tree { protected $_{{entity}}Ids = null; protected $_selectedNodes = null; /** * constructor * Specify template to use * * @access public * @return void * {{qwertyuiop}} */ public function __construct() { parent::__construct(); $this->setTemplate('{{namespace}}_{{module}}/catalog/product/edit/tab/{{entity}}.phtml'); } /** * Retrieve currently edited product * * @access public * @return Mage_Catalog_Model_Product * {{qwertyuiop}} */ public function getProduct() { return Mage::registry('current_product'); } /** * Return array with {{entityLabel}} IDs which the product is assigned to * * @access public * @return array * {{qwertyuiop}} */ public function get{{Entity}}Ids() { if (is_null($this->_{{entity}}Ids)) { $selected{{Entities}} = Mage::helper('{{namespace}}_{{module}}/product')->getSelected{{Entities}}($this->getProduct()); $ids = array(); foreach ($selected{{Entities}} as ${{entity}}) { $ids[] = ${{entity}}->getId(); } $this->_{{entity}}Ids = $ids; } return $this->_{{entity}}Ids; } /** * Forms string out of get{{Entity}}Ids() * * @access public * @return string * {{qwertyuiop}} */ public function getIdsString() { return implode(',', $this->get{{Entity}}Ids()); } /** * Returns root node and sets 'checked' flag (if necessary) * * @access public * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRootNode() { $root = $this->getRoot(); if ($root && in_array($root->getId(), $this->get{{Entity}}Ids())) { $root->setChecked(true); } return $root; } /** * Returns root node * * @param {{Namespace}}_{{Module}}_Model_{{Entity}}|null $parentNode{{Entity}} * @param int $recursionLevel * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRoot($parentNode{{Entity}} = null, $recursionLevel = 3) { if (!is_null($parentNode{{Entity}}) && $parentNode{{Entity}}->getId()) { return $this->getNode($parentNode{{Entity}}, $recursionLevel); } $root = Mage::registry('{{entity}}_root'); if (is_null($root)) { $rootId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); $ids = $this->getSelected{{Entity}}PathIds($rootId); $tree = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_tree') ->loadByIds($ids, false, false); if ($this->get{{Entity}}()) { $tree->loadEnsuredNodes($this->get{{Entity}}(), $tree->getNodeById($rootId)); } $tree->addCollectionData($this->get{{Entity}}Collection()); $root = $tree->getNodeById($rootId); Mage::register('{{entity}}_root', $root); } return $root; } /** * Returns array with configuration of current node * * @access protected * @param Varien_Data_Tree_Node $node * @param int $level How deep is the node in the tree * @return array * {{qwertyuiop}} */ protected function _getNodeJson($node, $level = 1) { $item = parent::_getNodeJson($node, $level); if ($this->_isParentSelected{{Entity}}($node)) { $item['expanded'] = true; } if (in_array($node->getId(), $this->get{{Entity}}Ids())) { $item['checked'] = true; } return $item; } /** * Returns whether $node is a parent (not exactly direct) of a selected node * * @access protected * @param Varien_Data_Tree_Node $node * @return bool * {{qwertyuiop}} */ protected function _isParentSelected{{Entity}}($node) { $result = false; // Contains string with all {{entityLabel}} IDs of children (not exactly direct) of the node $allChildren = $node->getAllChildren(); if ($allChildren) { $selected{{Entity}}Ids = $this->get{{Entity}}Ids(); $allChildrenArr = explode(',', $allChildren); for ($i = 0, $cnt = count($selected{{Entity}}Ids); $i < $cnt; $i++) { $isSelf = $node->getId() == $selected{{Entity}}Ids[$i]; if (!$isSelf && in_array($selected{{Entity}}Ids[$i], $allChildrenArr)) { $result = true; break; } } } return $result; } /** * Returns array with nodes those are selected (contain current product) * * @access protected * @return array * {{qwertyuiop}} */ protected function _getSelectedNodes() { if ($this->_selectedNodes === null) { $this->_selectedNodes = array(); $root = $this->getRoot(); foreach ($this->get{{Entity}}Ids() as ${{entity}}Id) { if ($root) { $this->_selectedNodes[] = $root->getTree()->getNodeById(${{entity}}Id); } } } return $this->_selectedNodes; } /** * Returns JSON-encoded array of {{entityLabel}} children * * @access public * @param int ${{entity}}Id * @return string * {{qwertyuiop}} */ public function get{{Entity}}ChildrenJson(${{entity}}Id) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id); $node = $this->getRoot(${{entity}}, 1)->getTree()->getNodeById(${{entity}}Id); if (!$node || !$node->hasChildren()) { return '[]'; } $children = array(); foreach ($node->getChildren() as $child) { $children[] = $this->_getNodeJson($child); } return Mage::helper('core')->jsonEncode($children); } /** * Returns URL for loading tree * * @access public * @param null $expanded * @return string * {{qwertyuiop}} */ public function getLoadTreeUrl($expanded = null) { return $this->getUrl('*/*/{{entities}}Json', array('_current' => true)); } /** * Return distinct path ids of selected {{entitiesLabel}} * * @access public * @param mixed $rootId Root {{entityLabel}} Id for context * @return array * {{qwertyuiop}} */ public function getSelected{{Entity}}PathIds($rootId = false) { $ids = array(); ${{entity}}Ids = $this->get{{Entity}}Ids(); if (empty(${{entity}}Ids)) { return array(); } $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_collection'); if ($rootId) { $collection->addFieldToFilter('parent_id', $rootId); } else { $collection->addFieldToFilter('entity_id', array('in'=>${{entity}}Ids)); } foreach ($collection as $item) { if ($rootId && !in_array($rootId, $item->getPathIds())) { continue; } foreach ($item->getPathIds() as $id) { if (!in_array($id, $ids)) { $ids[] = $id; } } } return $ids; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Catalog/Product/Edit/Tab/Entity/040_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/010_top ================================================ _controller = 'adminhtml_{{entity}}'; $this->_blockGroup = '{{namespace}}_{{module}}'; parent::__construct(); $this->_headerText = Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}'); $this->_updateButton('add', 'label', Mage::helper('{{namespace}}_{{module}}')->__('Add {{EntityLabel}}')); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/020_eav ================================================ $this->setTemplate('{{namespace}}_{{module}}/grid.phtml'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/030_footer ================================================ } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Abstract/010_content ================================================ get{{Entity}}()) { return $this->get{{Entity}}()->getId(); } return null; } /** * get current {{entityLabel}} {{nameAttributeLabel}} * * @access public * @return string * {{qwertyuiop}} */ public function get{{Entity}}{{EntityNameMagicCode}}() { return $this->get{{Entity}}()->get{{EntityNameMagicCode}}(); } /** * get current {{entityLabel}} path * * @access public * @return string * {{qwertyuiop}} */ public function get{{Entity}}Path() { if ($this->get{{Entity}}()) { return $this->get{{Entity}}()->getPath(); } return Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); } /** * check if there is a root {{entityLabel}} * * @access public * @return bool * {{qwertyuiop}} */ public function hasRoot{{Entity}}() { $root = $this->getRoot(); if ($root && $root->getId()) { return true; } return false; } /** * get the root * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}}|null $parentNode{{Entity}} * @param int $recursionLevel * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRoot($parentNode{{Entity}} = null, $recursionLevel = 3) { if (!is_null($parentNode{{Entity}}) && $parentNode{{Entity}}->getId()) { return $this->getNode($parentNode{{Entity}}, $recursionLevel); } $root = Mage::registry('root'); if (is_null($root)) { $rootId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); $tree = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_tree') ->load(null, $recursionLevel); if ($this->get{{Entity}}()) { $tree->loadEnsuredNodes($this->get{{Entity}}(), $tree->getNodeById($rootId)); } $tree->addCollectionData($this->get{{Entity}}Collection()); $root = $tree->getNodeById($rootId); if ($root && $rootId != Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()) { $root->setIsVisible(true); } elseif ($root && $root->getId() == Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()) { $root->set{{EntityNameMagicCode}}(Mage::helper('{{namespace}}_{{module}}')->__('Root')); } Mage::register('root', $root); } return $root; } /** * Get and register {{entitiesLabel}} root by specified {{entitiesLabel}} IDs * * @accsess public * @param array $ids * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRootByIds($ids) { $root = Mage::registry('root'); if (null === $root) { ${{entity}}TreeResource = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_tree'); $ids = ${{entity}}TreeResource->getExisting{{Entity}}IdsBySpecifiedIds($ids); $tree = ${{entity}}TreeResource->loadByIds($ids); $rootId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); $root = $tree->getNodeById($rootId); if ($root && $rootId != Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()) { $root->setIsVisible(true); } elseif ($root && $root->getId() == Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()) { $root->setName(Mage::helper('{{namespace}}_{{module}}')->__('Root')); } $tree->addCollectionData($this->get{{Entity}}Collection()); Mage::register('root', $root); } return $root; } /** * get specific node * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $parentNode{{Entity}} * @param $int $recursionLevel * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getNode($parentNode{{Entity}}, $recursionLevel = 2) { $tree = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_tree'); $nodeId = $parentNode{{Entity}}->getId(); $parentId = $parentNode{{Entity}}->getParentId(); $node = $tree->loadNode($nodeId); $node->loadChildren($recursionLevel); if ($node && $nodeId != Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()) { $node->setIsVisible(true); } elseif ($node && $node->getId() == Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()) { $node->set{{EntityNameMagicCode}}(Mage::helper('{{namespace}}_{{module}}')->__('Root')); } $tree->addCollectionData($this->get{{Entity}}Collection()); return $node; } /** * get url for saving data * * @access public * @param array $args * @return string * {{qwertyuiop}} */ public function getSaveUrl(array $args = array()) { $params = array('_current'=>true); $params = array_merge($params, $args); return $this->getUrl('*/*/save', $params); } /** * get url for edit * * @access public * @param array $args * @return string * {{qwertyuiop}} */ public function getEditUrl() { return $this->getUrl( "*/{{module}}_{{entity}}/edit", array('_current' => true, '_query'=>false, 'id' => null, 'parent' => null) ); } /** * Return root ids * * @access public * @return array * {{qwertyuiop}} */ public function getRootIds() { return array(Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Attribute/010_content ================================================ _controller = 'adminhtml_{{entity}}_attribute'; $this->_blockGroup = '{{namespace}}_{{module}}'; $this->_headerText = Mage::helper('{{namespace}}_{{module}}')->__('Manage {{EntityLabel}} Attributes'); parent::__construct(); $this->_updateButton( 'add', 'label', Mage::helper('{{namespace}}_{{module}}')->__('Add New {{EntityLabel}} Attribute') ); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Attribute/Edit/010_content ================================================ _objectId = 'attribute_id'; $this->_controller = 'adminhtml_{{entity}}_attribute'; $this->_blockGroup = '{{namespace}}_{{module}}'; parent::__construct(); $this->_addButton( 'save_and_edit_button', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Save and Continue Edit'), 'onclick' => 'saveAndContinueEdit()', 'class' => 'save' ), 100 ); $this->_updateButton( 'save', 'label', Mage::helper('{{namespace}}_{{module}}')->__('Save {{EntityLabel}} Attribute') ); $this->_updateButton('save', 'onclick', 'saveAttribute()'); if (!Mage::registry('entity_attribute')->getIsUserDefined()) { $this->_removeButton('delete'); } else { $this->_updateButton( 'delete', 'label', Mage::helper('{{namespace}}_{{module}}')->__('Delete {{EntityLabel}} Attribute') ); } } /** * get the header text for the form * * @access public * @return string * {{qwertyuiop}} */ public function getHeaderText() { if (Mage::registry('entity_attribute')->getId()) { $frontendLabel = Mage::registry('entity_attribute')->getFrontendLabel(); if (is_array($frontendLabel)) { $frontendLabel = $frontendLabel[0]; } return Mage::helper('{{namespace}}_{{module}}')->__('Edit {{EntityLabel}} Attribute "%s"', $this->escapeHtml($frontendLabel)); } else { return Mage::helper('{{namespace}}_{{module}}')->__('New {{EntityLabel}} Attribute'); } } /** * get validation url for form * * @access public * @return string * {{qwertyuiop}} */ public function getValidationUrl() { return $this->getUrl('*/*/validate', array('_current'=>true)); } /** * get save url for form * * @access public * @return string * {{qwertyuiop}} */ public function getSaveUrl() { return $this->getUrl('*/'.$this->_controller.'/save', array('_current'=>true, 'back'=>null)); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Attribute/Edit/Form/010_content ================================================ 'edit_form', 'action' => $this->getUrl('adminhtml/{{module}}_{{entity}}_attribute/save'), 'method' => 'post' ) ); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Attribute/Edit/Tab/Main/010_content ================================================ getAttributeObject(); $form = $this->getForm(); $fieldset = $form->getElement('base_fieldset'); $frontendInputElm = $form->getElement('frontend_input'); $additionalTypes = array( array( 'value' => 'image', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Image') ), array( 'value' => 'file', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('File') ) ); $response = new Varien_Object(); $response->setTypes(array()); Mage::dispatchEvent('adminhtml_{{entity}}_attribute_types', array('response'=>$response)); $_disabledTypes = array(); $_hiddenFields = array(); foreach ($response->getTypes() as $type) { $additionalTypes[] = $type; if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } if (isset($type['disabled_types'])) { $_disabledTypes[$type['value']] = $type['disabled_types']; } } Mage::register('attribute_type_hidden_fields', $_hiddenFields); Mage::register('attribute_type_disabled_types', $_disabledTypes); $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes); $frontendInputElm->setValues($frontendInputValues); $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(); $scopes = array( Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('{{namespace}}_{{module}}')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('{{namespace}}_{{module}}')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('{{namespace}}_{{module}}')->__('Global'), ); $fieldset->addField( 'is_global', 'select', array( 'name' => 'is_global', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Scope'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Scope'), 'note' => Mage::helper('{{namespace}}_{{module}}')->__('Declare attribute value saving scope'), 'values'=> $scopes ), 'attribute_code' ); $fieldset->addField( 'position', 'text', array( 'name' => 'position', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Position'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Position'), 'note' => Mage::helper('{{namespace}}_{{module}}')->__('Position in the admin form'), ), 'is_global' ); $fieldset->addField( 'note', 'textarea', array( 'name' => 'note', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Note'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Note'), 'note' => Mage::helper('{{namespace}}_{{module}}')->__('Text to appear below the input.'), ), 'position' ); $fieldset->removeField('is_unique'); // frontend properties fieldset $fieldset = $form->addFieldset( 'front_fieldset', array( 'legend'=>Mage::helper('{{namespace}}_{{module}}')->__('Frontend Properties') ) ); $fieldset->addField( 'is_wysiwyg_enabled', 'select', array( 'name' => 'is_wysiwyg_enabled', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Enable WYSIWYG'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Enable WYSIWYG'), 'values' => $yesnoSource, ) ); Mage::dispatchEvent( '{{namespace}}_{{module}}_adminhtml_{{entity}}_attribute_edit_prepare_form', array( 'form' => $form, 'attribute' => $attributeObject ) ); return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Attribute/Edit/Tab/Options/010_content ================================================ setId('{{entity}}_attribute_tabs'); $this->setDestElementId('edit_form'); $this->setTitle(Mage::helper('{{namespace}}_{{module}}')->__('Attribute Information')); } /** * add attribute tabs * * @access protected * @return {{Namespace}}_{{Module}}_Adminhtml_{{Entity}}_Attribute_Edit_Tabs * {{qwertyuiop}} */ protected function _beforeToHtml() { $this->addTab( 'main', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Properties'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Properties'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_attribute_edit_tab_main' ) ->toHtml(), 'active' => true ) ); $this->addTab( 'labels', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Manage Label / Options'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Manage Label / Options'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_attribute_edit_tab_options' ) ->toHtml(), ) ); return parent::_beforeToHtml(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Attribute/Grid/010_content ================================================ addVisibleFilter(); $this->setCollection($collection); return parent::_prepareCollection(); } /** * Prepare {{entity}} attributes grid columns * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Attribute_Grid * {{qwertyuiop}} */ protected function _prepareColumns() { parent::_prepareColumns(); $this->addColumnAfter( 'is_global', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Scope'), 'sortable' => true, 'index' => 'is_global', 'type' => 'options', 'options' => array( Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('{{namespace}}_{{module}}')->__('Store View'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('{{namespace}}_{{module}}')->__('Website'), Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('{{namespace}}_{{module}}')->__('Global'), ), 'align' => 'center', ), 'is_user_defined' ); return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/010_content ================================================ _controller = 'adminhtml_{{entity}}_comment'; $this->_blockGroup = '{{namespace}}_{{module}}'; parent::__construct(); $this->_headerText = Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} Comments'); $this->_removeButton('add'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Edit/010_content ================================================ _blockGroup = '{{namespace}}_{{module}}'; $this->_controller = 'adminhtml_{{entity}}_comment'; $this->_updateButton( 'save', 'label', Mage::helper('{{namespace}}_{{module}}')->__('Save {{EntityLabel}} comment') ); $this->_updateButton( 'delete', 'label', Mage::helper('{{namespace}}_{{module}}')->__('Delete {{EntityLabel}} comment') ); $this->_addButton( 'saveandcontinue', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Save And Continue Edit'), 'onclick' => 'saveAndContinueEdit()', 'class' => 'save', ), -100 ); $this->_formScripts[] = " function saveAndContinueEdit() { editForm.submit($('edit_form').action+'back/edit/'); } "; } /** * get the edit form header * * @access public * @return string * {{qwertyuiop}} */ public function getHeaderText() { if (Mage::registry('comment_data') && Mage::registry('comment_data')->getId()) { return Mage::helper('{{namespace}}_{{module}}')->__( "Edit {{EntityLabel}} comment '%s'", $this->escapeHtml(Mage::registry('comment_data')->getTitle()) ); } return ''; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Edit/Form/010_content ================================================ 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post', 'enctype' => 'multipart/form-data' ) ); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Edit/Tab/Form/010_top ================================================ setHtmlIdPrefix('comment_'); $form->setFieldNameSuffix('comment'); $this->setForm($form); $fieldset = $form->addFieldset( 'comment_form', array('legend'=>Mage::helper('{{namespace}}_{{module}}')->__('Comment')) ); $fieldset->addField( '{{entity}}_id', 'hidden', array( 'name' => '{{entity}}_id', 'after_element_html' => ''. Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}'). ' : '.${{entity}}->get{{EntityNameMagicCode}}().'' ) ); $fieldset->addField( 'title', 'text', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Title'), 'name' => 'title', 'required' => true, 'class' => 'required-entry', ) ); $fieldset->addField( 'comment', 'textarea', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Comment'), 'name' => 'comment', 'required' => true, 'class' => 'required-entry', ) ); $fieldset->addField( 'status', 'select', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Status'), 'name' => 'status', 'required' => true, 'class' => 'required-entry', 'values' => array( array( 'value' => {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_PENDING, 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Pending'), ), array( 'value' => {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_APPROVED, 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Approved'), ), array( 'value' => {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_REJECTED, 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Rejected'), ), ), ) ); $configuration = array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Poster name'), 'name' => 'name', 'required' => true, 'class' => 'required-entry', ); if ($comment->getCustomerId()) { $configuration['after_element_html'] = ''. Mage::helper('{{namespace}}_{{module}}')->__('Customer profile').''; } $fieldset->addField('name', 'text', $configuration); $fieldset->addField( 'email', 'text', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Poster e-mail'), 'name' => 'email', 'required' => true, 'class' => 'required-entry', ) ); $fieldset->addField( 'customer_id', 'hidden', array( 'name' => 'customer_id', ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Edit/Tab/Form/020_stores ================================================ if (Mage::app()->isSingleStoreMode()) { $fieldset->addField( 'store_id', 'hidden', array( 'name' => 'stores[]', 'value' => Mage::app()->getStore(true)->getId() ) ); Mage::registry('current_comment')->setStoreId(Mage::app()->getStore(true)->getId()); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Edit/Tab/Form/030_footer ================================================ $form->addValues($this->getComment()->getData()); return parent::_prepareForm(); } /** * get the current comment * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment */ public function getComment() { return Mage::registry('current_comment'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Edit/Tab/Stores/010_content ================================================ setFieldNameSuffix('comment'); $this->setForm($form); $fieldset = $form->addFieldset( '{{entity}}_comment_stores_form', array('legend' => Mage::helper('{{namespace}}_{{module}}')->__('Store views')) ); $field = $fieldset->addField( 'store_id', 'multiselect', array( 'name' => 'stores[]', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Store Views'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Store Views'), 'required' => true, 'values'=> Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true), ) ); $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element'); $field->setRenderer($renderer); $form->addValues(Mage::registry('current_comment')->getData()); return parent::_prepareForm(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Edit/Tabs/010_top ================================================ setId('{{entity}}_comment_tabs'); $this->setDestElementId('edit_form'); $this->setTitle(Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} Comment')); } /** * before render html * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tabs * {{qwertyuiop}} */ protected function _beforeToHtml() { $this->addTab( 'form_{{entity}}_comment', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} comment'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} comment'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_comment_edit_tab_form' ) ->toHtml(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Edit/Tabs/020_stores ================================================ if (!Mage::app()->isSingleStoreMode()) { $this->addTab( 'form_store_{{entity}}_comment', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Store views'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Store views'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_comment_edit_tab_stores' ) ->toHtml(), ) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Edit/Tabs/030_footer ================================================ return parent::_beforeToHtml(); } /** * Retrieve comment * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment * {{qwertyuiop}} */ public function getComment() { return Mage::registry('current_comment'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Grid/010_top ================================================ setId('{{entity}}CommentGrid'); $this->setDefaultSort('ct_comment_id'); $this->setDefaultDir('DESC'); $this->setSaveParametersInSession(true); $this->setUseAjax(true); } /** * prepare collection * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Comment_Grid * {{qwertyuiop}} */ protected function _prepareCollection() { $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_comment_{{entity}}_collection'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Grid/013_store_data ================================================ $collection->addStoreData(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Grid/016_prepare ================================================ $this->setCollection($collection); return parent::_prepareCollection(); } /** * prepare grid collection * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Comment_Grid * {{qwertyuiop}} */ protected function _prepareColumns() { $this->addColumn( 'ct_comment_id', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Id'), 'index' => 'ct_comment_id', 'type' => 'number', 'filter_index' => 'ct.comment_id', ) ); $this->addColumn( '{{nameAttributeCode}}', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('{{nameAttributeLabel}}'), 'index' => '{{nameAttributeCode}}', 'filter_index' => '{{commentFilterIndexPrefix}}{{nameAttributeCode}}', ) ); $this->addColumn( 'ct_title', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Comment Title'), 'index' => 'ct_title', 'filter_index' => 'ct.title', ) ); $this->addColumn( 'ct_name', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Poster name'), 'index' => 'ct_name', 'filter_index' => 'ct.name', ) ); $this->addColumn( 'ct_email', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Poster email'), 'index' => 'ct_email', 'filter_index' => 'ct.email', ) ); $this->addColumn( 'ct_status', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Status'), 'index' => 'ct_status', 'filter_index' => 'ct.status', 'type' => 'options', 'options' => array( {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_PENDING => Mage::helper('{{namespace}}_{{module}}')->__('Pending'), {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_APPROVED => Mage::helper('{{namespace}}_{{module}}')->__('Approved'), {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_REJECTED => Mage::helper('{{namespace}}_{{module}}')->__('Rejected'), ) ) ); $this->addColumn( 'ct_created_at', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Created at'), 'index' => 'ct_created_at', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'ct.created_at', ) ); $this->addColumn( 'ct_updated_at', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Updated at'), 'index' => 'ct_updated_at', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'ct.updated_at', ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Grid/020_stores ================================================ if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) { $this->addColumn( 'stores', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Store Views'), 'index' => 'stores', 'type' => 'store', 'store_all' => true, 'store_view' => true, 'sortable' => false, 'filter_condition_callback' => array($this, '_filterStoreCondition'), ) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Grid/030_content ================================================ $this->addColumn( 'action', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Action'), 'width' => '100', 'type' => 'action', 'getter' => 'getCtCommentId', 'actions' => array( array( 'caption' => Mage::helper('{{namespace}}_{{module}}')->__('Edit'), 'url' => array('base'=> '*/*/edit'), 'field' => 'id' ) ), 'filter' => false, 'is_system' => true, 'sortable' => false, ) ); $this->addExportType('*/*/exportCsv', Mage::helper('{{namespace}}_{{module}}')->__('CSV')); $this->addExportType('*/*/exportExcel', Mage::helper('{{namespace}}_{{module}}')->__('Excel')); $this->addExportType('*/*/exportXml', Mage::helper('{{namespace}}_{{module}}')->__('XML')); return parent::_prepareColumns(); } /** * prepare mass action * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid * {{qwertyuiop}} */ protected function _prepareMassaction() { $this->setMassactionIdField('ct_comment_id'); $this->setMassactionIdFilter('ct.comment_id'); $this->setMassactionIdFieldOnlyIndexValue(true); $this->getMassactionBlock()->setFormFieldName('comment'); $this->getMassactionBlock()->addItem( 'delete', array( 'label'=> Mage::helper('{{namespace}}_{{module}}')->__('Delete'), 'url' => $this->getUrl('*/*/massDelete'), 'confirm' => Mage::helper('{{namespace}}_{{module}}')->__('Are you sure?') ) ); $this->getMassactionBlock()->addItem( 'status', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Change status'), 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)), 'additional' => array( 'status' => array( 'name' => 'status', 'type' => 'select', 'class' => 'required-entry', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Status'), 'values' => array( {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_PENDING => Mage::helper('{{namespace}}_{{module}}')->__('Pending'), {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_APPROVED => Mage::helper('{{namespace}}_{{module}}')->__('Approved'), {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_REJECTED => Mage::helper('{{namespace}}_{{module}}')->__('Rejected'), ) ) ) ) ); return $this; } /** * get the row url * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment * @return string * {{qwertyuiop}} */ public function getRowUrl($row) { return $this->getUrl('*/*/edit', array('id' => $row->getCtCommentId())); } /** * get the grid url * * @access public * @return string * {{qwertyuiop}} */ public function getGridUrl() { return $this->getUrl('*/*/grid', array('_current'=>true)); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Grid/040_store_filter ================================================ /** * filter store column * * @access protected * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_Collection $collection * @param Mage_Adminhtml_Block_Widget_Grid_Column $column * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Comment_Grid * {{qwertyuiop}} */ protected function _filterStoreCondition($collection, $column) { if (!$value = $column->getFilter()->getValue()) { return; } $collection->setStoreFilter($value); return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Comment/Grid/050_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/010_top ================================================ _objectId = 'entity_id'; $this->_blockGroup = '{{namespace}}_{{module}}'; $this->_controller = 'adminhtml_{{entity}}'; $this->_mode = 'edit'; parent::__construct(); $this->setTemplate('{{namespace}}_{{module}}/{{entity}}/edit.phtml'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/030_not_tree ================================================ public function __construct() { parent::__construct(); $this->_blockGroup = '{{namespace}}_{{module}}'; $this->_controller = 'adminhtml_{{entity}}'; $this->_updateButton( 'save', 'label', Mage::helper('{{namespace}}_{{module}}')->__('Save {{EntityLabel}}') ); $this->_updateButton( 'delete', 'label', Mage::helper('{{namespace}}_{{module}}')->__('Delete {{EntityLabel}}') ); $this->_addButton( 'saveandcontinue', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Save And Continue Edit'), 'onclick' => 'saveAndContinueEdit()', 'class' => 'save', ), -100 ); $this->_formScripts[] = " function saveAndContinueEdit() { editForm.submit($('edit_form').action+'back/edit/'); } "; } /** * get the edit form header * * @access public * @return string * {{qwertyuiop}} */ public function getHeaderText() { if (Mage::registry('current_{{entity}}') && Mage::registry('current_{{entity}}')->getId()) { return Mage::helper('{{namespace}}_{{module}}')->__( "Edit {{EntityLabel}} '%s'", $this->escapeHtml(Mage::registry('current_{{entity}}')->get{{EntityNameMagicCode}}()) ); } else { return Mage::helper('{{namespace}}_{{module}}')->__('Add {{EntityLabel}}'); } } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Form/010_top ================================================ 'edit_form', 'action' => $this->getUrl( '*/*/save', array( 'id' => $this->getRequest()->getParam('id') ) ), 'method' => 'post', 'enctype' => 'multipart/form-data' ) ); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Form/025_prepare_form_eav ================================================ class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { /** * prepare form * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form * {{qwertyuiop}} */ protected function _prepareForm() { $form = new Varien_Data_Form( array( 'id' => 'edit_form', 'action' => $this->getUrl( '*/*/save', array( 'id' => $this->getRequest()->getParam('id'), 'store' => $this->getRequest()->getParam('store') ) ), 'method' => 'post', 'enctype' => 'multipart/form-data' ) ); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Form/030_tree_top ================================================ class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form extends {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Abstract { /** * Additional buttons on {{entityLabel}} page * @var array */ protected $_additionalButtons = array(); /** * constructor * * set template * @access public * {{qwertyuiop}} */ public function __construct() { parent::__construct(); $this->setTemplate('{{namespace}}_{{module}}/{{entity}}/edit/form.phtml'); } /** * prepare the layout * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form * {{qwertyuiop}} */ protected function _prepareLayout() { ${{entity}} = $this->get{{Entity}}(); ${{entity}}Id = (int)${{entity}}->getId(); $this->setChild( 'tabs', $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tabs', 'tabs') ); $this->setChild( 'save_button', $this->getLayout()->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Save {{EntityLabel}}'), 'onclick' => "{{entity}}Submit('" . $this->getSaveUrl() . "', true)", 'class' => 'save' ) ) ); // Delete button if (!in_array(${{entity}}Id, $this->getRootIds())) { $this->setChild( 'delete_button', $this->getLayout()->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Delete {{EntityLabel}}'), 'onclick' => "{{entity}}Delete('" . $this->getUrl( '*/*/delete', array('_current' => true) ) . "', true, {${{entity}}Id})", 'class' => 'delete' ) ) ); } // Reset button $resetPath = ${{entity}} ? '*/*/edit' : '*/*/add'; $this->setChild( 'reset_button', $this->getLayout()->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Reset'), 'onclick' => "{{entity}}Reset('".$this->getUrl( $resetPath, array('_current'=>true) ) ."',true)" ) ) ); return parent::_prepareLayout(); } /** * get html for delete button * * @access public * @return string * {{qwertyuiop}} */ public function getDeleteButtonHtml() { return $this->getChildHtml('delete_button'); } /** * get html for save button * * @access public * @return string * {{qwertyuiop}} */ public function getSaveButtonHtml() { return $this->getChildHtml('save_button'); } /** * get html for reset button * * @access public * @return string * {{qwertyuiop}} */ public function getResetButtonHtml() { return $this->getChildHtml('reset_button'); } /** * Retrieve additional buttons html * * @access public * @return string * {{qwertyuiop}} */ public function getAdditionalButtonsHtml() { $html = ''; foreach ($this->_additionalButtons as $childName) { $html .= $this->getChildHtml($childName); } return $html; } /** * Add additional button * * @param string $alias * @param array $config * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form * {{qwertyuiop}} */ public function addAdditionalButton($alias, $config) { if (isset($config['name'])) { $config['element_name'] = $config['name']; } $this->setChild( $alias . '_button', $this->getLayout()->createBlock('adminhtml/widget_button')->addData($config) ); $this->_additionalButtons[$alias] = $alias . '_button'; return $this; } /** * Remove additional button * * @access public * @param string $alias * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Form * {{qwertyuiop}} */ public function removeAdditionalButton($alias) { if (isset($this->_additionalButtons[$alias])) { $this->unsetChild($this->_additionalButtons[$alias]); unset($this->_additionalButtons[$alias]); } return $this; } /** * get html for tabs * * @access public * @return string * {{qwertyuiop}} */ public function getTabsHtml() { return $this->getChildHtml('tabs'); } /** * get the form header * * @access public * @return string * {{qwertyuiop}} */ public function getHeader() { if ($this->get{{Entity}}Id()) { return $this->get{{Entity}}{{EntityNameMagicCode}}(); } else { return Mage::helper('{{namespace}}_{{module}}')->__('New Root {{EntityLabel}}'); } } /** * get the delete url * * @access public * @param array $args * @return string * {{qwertyuiop}} */ public function getDeleteUrl(array $args = array()) { $params = array('_current'=>true); $params = array_merge($params, $args); return $this->getUrl('*/*/delete', $params); } /** * Return URL for refresh input element 'path' in form * * @access public * @param array $args * @return string * {{qwertyuiop}} */ public function getRefreshPathUrl(array $args = array()) { $params = array('_current'=>true); $params = array_merge($params, $args); return $this->getUrl('*/*/refreshPath', $params); } /** * check if request is ajax * * @access public * @return bool * {{qwertyuiop}} */ public function isAjax() { return Mage::app()->getRequest()->isXmlHttpRequest() || Mage::app()->getRequest()->getParam('isAjax'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Form/040_product_relation ================================================ /** * get products json * * @access public * @return string * {{qwertyuiop}} */ public function getProductsJson() { $products = $this->get{{Entity}}()->getSelectedProducts(); if (!empty($products)) { $positions = array(); foreach ($products as $product) { $positions[$product->getId()] = $product->getPosition(); } return Mage::helper('core')->jsonEncode($positions); } return '{}'; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Form/050_entity_relation ================================================ /** * get {{siblingsLabel}} in json format * * @access public * @return string * {{qwertyuiop}} */ public function get{{Siblings}}Json() { ${{siblings}} = $this->get{{Entity}}()->getSelected{{Siblings}}(); if (!empty(${{siblings}})) { $positions = array(); foreach (${{siblings}} as ${{sibling}}) { $positions[${{sibling}}->getId()] = ${{sibling}}->getPosition(); } return Mage::helper('core')->jsonEncode($positions); } return '{}'; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Form/060_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Attributes/010_top ================================================ setDataObject(Mage::registry('current_{{entity}}')); $fieldset = $form->addFieldset( 'info', array( 'legend' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} Information'), 'class' => 'fieldset-wide', ) ); $attributes = $this->getAttributes(); foreach ($attributes as $attribute) { $attribute->setEntity(Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}')); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Attributes/020_tree ================================================ if ($this->getAddHiddenFields()) { if (!$this->get{{Entity}}()->getId()) { // path if ($this->getRequest()->getParam('parent')) { $fieldset->addField( 'path', 'hidden', array( 'name' => 'path', 'value' => $this->getRequest()->getParam('parent') ) ); } else { $fieldset->addField( 'path', 'hidden', array( 'name' => 'path', 'value' => 1 ) ); } } else { $fieldset->addField( 'id', 'hidden', array( 'name' => 'id', 'value' => $this->get{{Entity}}()->getId() ) ); $fieldset->addField( 'path', 'hidden', array( 'name' => 'path', 'value' => $this->get{{Entity}}()->getPath() ) ); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Attributes/021_default_values ================================================ $this->_setFieldset($attributes, $fieldset, array()); $formValues = Mage::registry('current_{{entity}}')->getData(); if (!Mage::registry('current_{{entity}}')->getId()) { foreach ($attributes as $attribute) { if (!isset($formValues[$attribute->getAttributeCode()])) { $formValues[$attribute->getAttributeCode()] = $attribute->getDefaultValue(); } } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Attributes/022_default_values_tree ================================================ //do not set default value for path unset($formValues['path']); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Attributes/023_layout ================================================ $form->addValues($formValues); $form->setFieldNameSuffix('{{entity}}'); $this->setForm($form); } /** * prepare layout * * @access protected * @return void * @see Mage_Adminhtml_Block_Widget_Form::_prepareLayout() * {{qwertyuiop}} */ protected function _prepareLayout() { Varien_Data_Form::setElementRenderer( $this->getLayout()->createBlock('adminhtml/widget_form_renderer_element') ); Varien_Data_Form::setFieldsetRenderer( $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset') ); Varien_Data_Form::setFieldsetElementRenderer( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{module}}_renderer_fieldset_element') ); } /** * get the additional element types for form * * @access protected * @return array() * @see Mage_Adminhtml_Block_Widget_Form::_getAdditionalElementTypes() * {{qwertyuiop}} */ protected function _getAdditionalElementTypes() { return array( 'file' => Mage::getConfig()->getBlockClassName( '{{namespace}}_{{module}}/adminhtml_{{entity}}_helper_file' ), 'image' => Mage::getConfig()->getBlockClassName( '{{namespace}}_{{module}}/adminhtml_{{entity}}_helper_image' ), 'textarea' => Mage::getConfig()->getBlockClassName( 'adminhtml/catalog_helper_form_wysiwyg' ) ); } /** * get current entity * * @access protected * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Attributes/025_after_html_top ================================================ /** * get after element html * * @access protected * @param Varien_Data_Form_Element_Abstract $element * @return string * {{qwertyuiop}} */ protected function _getAdditionalElementHtml($element) { ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Attributes/026_after_html ================================================ if ($element->getName() == '{{sibling}}_id') { $html = ''; $html .= ''; return $html; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Attributes/027_after_html_footer ================================================ return ''; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Attributes/030_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Categories/010_content ================================================ setTemplate('{{namespace}}_{{module}}/{{entity}}/edit/tab/categories.phtml'); $this->_withProductCount = false; } /** * Retrieve currently edited {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } /** * Return array with categories IDs which the {{entityLabel}} is linked to * * @access public * @return array * {{qwertyuiop}} */ public function getCategoryIds() { if (is_null($this->_categoryIds)) { $categories = $this->get{{Entity}}()->getSelectedCategories(); $ids = array(); foreach ($categories as $category) { $ids[] = $category->getId(); } $this->_categoryIds = $ids; } return $this->_categoryIds; } /** * Forms string out of getCategoryIds() * * @access public * @return string * {{qwertyuiop}} */ public function getIdsString() { return implode(',', $this->getCategoryIds()); } /** * Returns root node and sets 'checked' flag (if necessary) * * @access public * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRootNode() { $root = $this->getRoot(); if ($root && in_array($root->getId(), $this->getCategoryIds())) { $root->setChecked(true); } return $root; } /** * Returns root node * * @param {{Namespace}}_{{Module}}_Model_Category|null $parentNodeCategory * @param int $recursionLevel * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRoot($parentNodeCategory = null, $recursionLevel = 3) { if (!is_null($parentNodeCategory) && $parentNodeCategory->getId()) { return $this->getNode($parentNodeCategory, $recursionLevel); } $root = Mage::registry('category_root'); if (is_null($root)) { $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID; $ids = $this->getSelectedCategoryPathIds($rootId); $tree = Mage::getResourceSingleton('catalog/category_tree') ->loadByIds($ids, false, false); if ($this->getCategory()) { $tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId)); } $tree->addCollectionData($this->getCategoryCollection()); $root = $tree->getNodeById($rootId); Mage::register('category_root', $root); } return $root; } /** * Returns array with configuration of current node * * @access public * @param Varien_Data_Tree_Node $node * @param int $level How deep is the node in the tree * @return array * {{qwertyuiop}} */ protected function _getNodeJson($node, $level = 1) { $item = parent::_getNodeJson($node, $level); if ($this->_isParentSelectedCategory($node)) { $item['expanded'] = true; } if (in_array($node->getId(), $this->getCategoryIds())) { $item['checked'] = true; } return $item; } /** * Returns whether $node is a parent (not exactly direct) of a selected node * * @access public * @param Varien_Data_Tree_Node $node * @return bool * {{qwertyuiop}} */ protected function _isParentSelectedCategory($node) { $result = false; // Contains string with all category IDs of children (not exactly direct) of the node $allChildren = $node->getAllChildren(); if ($allChildren) { $selectedCategoryIds = $this->getCategoryIds(); $allChildrenArr = explode(',', $allChildren); for ($i = 0, $cnt = count($selectedCategoryIds); $i < $cnt; $i++) { $isSelf = $node->getId() == $selectedCategoryIds[$i]; if (!$isSelf && in_array($selectedCategoryIds[$i], $allChildrenArr)) { $result = true; break; } } } return $result; } /** * Returns array with nodes those are selected (contain current {{entityLabel}}) * * @return array */ protected function _getSelectedNodes() { if ($this->_selectedNodes === null) { $this->_selectedNodes = array(); $root = $this->getRoot(); foreach ($this->getCategoryIds() as $categoryId) { if ($root) { $this->_selectedNodes[] = $root->getTree()->getNodeById($categoryId); } } } return $this->_selectedNodes; } /** * Returns JSON-encoded array of category children * * @access public * @param int $categoryId * @return string * {{qwertyuiop}} */ public function getCategoryChildrenJson($categoryId) { $category = Mage::getModel('catalog/category')->load($categoryId); $node = $this->getRoot($category, 1)->getTree()->getNodeById($categoryId); if (!$node || !$node->hasChildren()) { return '[]'; } $children = array(); foreach ($node->getChildren() as $child) { $children[] = $this->_getNodeJson($child); } return Mage::helper('core')->jsonEncode($children); } /** * Returns URL for loading tree * * @access public * @param null $expanded * @return string * {{qwertyuiop}} */ public function getLoadTreeUrl($expanded = null) { return $this->getUrl('*/*/categoriesJson', array('_current' => true)); } /** * Return distinct path ids of selected category * * @access public * @param mixed $rootId Root category Id for context * @return array * {{qwertyuiop}} */ public function getSelectedCategoryPathIds($rootId = false) { $ids = array(); $categoryIds = $this->getCategoryIds(); if (empty($categoryIds)) { return array(); } $collection = Mage::getResourceModel('catalog/category_collection'); if ($rootId) { $collection->addFieldToFilter('parent_id', $rootId); } else { $collection->addFieldToFilter('entity_id', array('in'=>$categoryIds)); } foreach ($collection as $item) { if ($rootId && !in_array($rootId, $item->getPathIds())) { continue; } foreach ($item->getPathIds() as $id) { if (!in_array($id, $ids)) { $ids[] = $id; } } } return $ids; } /** * Get node label * * @access public * @param Varien_Object $node * @return string * {{qwertyuiop}} */ public function buildNodeName($node) { $result = parent::buildNodeName($node); $result .= ''.$this->__(' - Edit').''; return $result; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/010_top ================================================ setHtmlIdPrefix('{{entity}}_'); $form->setFieldNameSuffix('{{entity}}'); $this->setForm($form); $fieldset = $form->addFieldset( '{{entity}}_form', array('legend' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}')) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/020_image ================================================ $fieldset->addType( 'image', Mage::getConfig()->getBlockClassName('{{namespace}}_{{module}}/adminhtml_{{entity}}_helper_image') ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/030_file ================================================ $fieldset->addType( 'file', Mage::getConfig()->getBlockClassName('{{namespace}}_{{module}}/adminhtml_{{entity}}_helper_file') ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/040_wysiwyg ================================================ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/050_wysiwyg_is_tree ================================================ $fieldset->addType( 'editor', Mage::getConfig()->getBlockClassName('{{namespace}}_{{module}}/adminhtml_helper_wysiwyg') ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/060_path_tree ================================================ if (!$this->get{{Entity}}()->getId()) { $parentId = $this->getRequest()->getParam('parent'); if (!$parentId) { $parentId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); } $fieldset->addField( 'path', 'hidden', array( 'name' => 'path', 'value' => $parentId ) ); } else { $fieldset->addField( 'id', 'hidden', array( 'name' => 'id', 'value' => $this->get{{Entity}}()->getId() ) ); $fieldset->addField( 'path', 'hidden', array( 'name' => 'path', 'value' => $this->get{{Entity}}()->getPath() ) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/070_parents ================================================ $values = Mage::getResourceModel('{{namespace}}_{{module}}/{{sibling}}_collection') {{siblingToOptionArraySelect}}->toOptionArray(); array_unshift($values, array('label' => '', 'value' => '')); $html = ''; $html .= ''; $fieldset->addField( '{{sibling}}_id', 'select', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{SiblingLabel}}'), 'name' => '{{sibling}}_id', 'required' => false, 'values' => $values, 'after_element_html' => $html ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/080_attributes ================================================ {{attributePreElementText}} $fieldset->addField( '{{attributeCode}}', '{{attributeFormType}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{attributeLabel}}'), 'name' => '{{attributeCode}}', {{attributeFormOptions}} ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/090_url_rewrite ================================================ $fieldset->addField( 'url_key', 'text', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Url key'), 'name' => 'url_key', 'note' => Mage::helper('{{namespace}}_{{module}}')->__('Relative to Website Base URL') ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/100_status ================================================ $fieldset->addField( 'status', 'select', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Status'), 'name' => 'status', 'values' => array( array( 'value' => 1, 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Enabled'), ), array( 'value' => 0, 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Disabled'), ), ), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/110_rss ================================================ $fieldset->addField( 'in_rss', 'select', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Show in rss'), 'name' => 'in_rss', 'values' => array( array( 'value' => 1, 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Yes'), ), array( 'value' => 0, 'label' => Mage::helper('{{namespace}}_{{module}}')->__('No'), ), ), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/120_stores ================================================ if (Mage::app()->isSingleStoreMode()) { $fieldset->addField( 'store_id', 'hidden', array( 'name' => 'stores[]', 'value' => Mage::app()->getStore(true)->getId() ) ); Mage::registry('current_{{entity}}')->setStoreId(Mage::app()->getStore(true)->getId()); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/130_allow_comment ================================================ $fieldset->addField( 'allow_comment', 'select', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Allow Comments'), 'name' => 'allow_comment', 'values'=> Mage::getModel('{{namespace}}_{{module}}/adminhtml_source_yesnodefault')->toOptionArray() ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/140_add_values_not_tree ================================================ $formValues = Mage::registry('current_{{entity}}')->getDefaultValues(); if (!is_array($formValues)) { $formValues = array(); } if (Mage::getSingleton('adminhtml/session')->get{{Entity}}Data()) { $formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->get{{Entity}}Data()); Mage::getSingleton('adminhtml/session')->set{{Entity}}Data(null); } elseif (Mage::registry('current_{{entity}}')) { $formValues = array_merge($formValues, Mage::registry('current_{{entity}}')->getData()); } $form->setValues($formValues); return parent::_prepareForm(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/150_add_values_tree ================================================ $form->addValues($this->get{{Entity}}()->getData()); return parent::_prepareForm(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/160_get_entity_tree ================================================ /** * get the current {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} */ public function get{{Entity}}() { return Mage::registry('{{entity}}'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/170_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Meta/010_content ================================================ setFieldNameSuffix('{{entity}}'); $this->setForm($form); $fieldset = $form->addFieldset( '{{entity}}_meta_form', array('legend' => Mage::helper('{{namespace}}_{{module}}')->__('Meta information')) ); $fieldset->addField( 'meta_title', 'text', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Meta-title'), 'name' => 'meta_title', ) ); $fieldset->addField( 'meta_description', 'textarea', array( 'name' => 'meta_description', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Meta-description'), ) ); $fieldset->addField( 'meta_keywords', 'textarea', array( 'name' => 'meta_keywords', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Meta-keywords'), ) ); $form->addValues(Mage::registry('current_{{entity}}')->getData()); return parent::_prepareForm(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Product/010_content ================================================ setId('product_grid'); $this->setDefaultSort('position'); $this->setDefaultDir('ASC'); $this->setUseAjax(true); if ($this->get{{Entity}}()->getId()) { $this->setDefaultFilter(array('in_products'=>1)); } } /** * prepare the product collection * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Product * {{qwertyuiop}} */ protected function _prepareCollection() { /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */ $collection = Mage::getResourceModel('catalog/product_collection'); $collection->addAttributeToSelect('price'); $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID; $collection->joinAttribute('product_name', 'catalog_product/name', 'entity_id', null, 'left', $adminStore); if ($this->get{{Entity}}()->getId()) { $constraint = '{{table}}.{{entity}}_id='.$this->get{{Entity}}()->getId(); } else { $constraint = '{{table}}.{{entity}}_id=0'; } $collection->joinField( 'position', '{{namespace}}_{{module}}/{{entity}}_product', 'position', 'product_id=entity_id', $constraint, 'left' ); $this->setCollection($collection); parent::_prepareCollection(); return $this; } /** * prepare mass action grid * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Product * {{qwertyuiop}} */ protected function _prepareMassaction() { return $this; } /** * prepare the grid columns * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Product * {{qwertyuiop}} */ protected function _prepareColumns() { $this->addColumn( 'in_products', array( 'header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_products', 'values'=> $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'entity_id' ) ); $this->addColumn( 'product_name', array( 'header' => Mage::helper('catalog')->__('Name'), 'align' => 'left', 'index' => 'product_name', 'renderer' => '{{namespace}}_{{module}}/adminhtml_helper_column_renderer_relation', 'params' => array( 'id' => 'getId' ), 'base_link' => 'adminhtml/catalog_product/edit', ) ); $this->addColumn( 'sku', array( 'header' => Mage::helper('catalog')->__('SKU'), 'align' => 'left', 'index' => 'sku', ) ); $this->addColumn( 'price', array( 'header' => Mage::helper('catalog')->__('Price'), 'type' => 'currency', 'width' => '1', 'currency_code' => (string)Mage::getStoreConfig( Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE ), 'index' => 'price' ) ); $this->addColumn( 'position', array( 'header' => Mage::helper('catalog')->__('Position'), 'name' => 'position', 'width' => 60, 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => true, ) ); } /** * Retrieve selected products * * @access protected * @return array * {{qwertyuiop}} */ protected function _getSelectedProducts() { $products = $this->get{{Entity}}Products(); if (!is_array($products)) { $products = array_keys($this->getSelectedProducts()); } return $products; } /** * Retrieve selected products * * @access protected * @return array * {{qwertyuiop}} */ public function getSelectedProducts() { $products = array(); $selected = Mage::registry('current_{{entity}}')->getSelectedProducts(); if (!is_array($selected)) { $selected = array(); } foreach ($selected as $product) { $products[$product->getId()] = array('position' => $product->getPosition()); } return $products; } /** * get row url * * @access public * @param {{Namespace}}_{{Module}}_Model_Product * @return string * {{qwertyuiop}} */ public function getRowUrl($item) { return '#'; } /** * get grid url * * @access public * @return string * {{qwertyuiop}} */ public function getGridUrl() { return $this->getUrl( '*/*/productsGrid', array( 'id' => $this->get{{Entity}}()->getId() ) ); } /** * get the current {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } /** * Add filter * * @access protected * @param object $column * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_Product * {{qwertyuiop}} */ protected function _addColumnFilterToCollection($column) { // Set custom filter for in product flag if ($column->getId() == 'in_products') { $productIds = $this->_getSelectedProducts(); if (empty($productIds)) { $productIds = 0; } if ($column->getFilter()->getValue()) { $this->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds)); } else { if ($productIds) { $this->getCollection()->addFieldToFilter('entity_id', array('nin' => $productIds)); } } } else { parent::_addColumnFilterToCollection($column); } return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Sibling/010_top ================================================ setId('{{sibling}}_grid'); $this->setDefaultSort('position'); $this->setDefaultDir('ASC'); $this->setUseAjax(true); if ($this->get{{Entity}}()->getId()) { $this->setDefaultFilter(array('in_{{siblings}}' => 1)); } } /** * prepare the {{siblingLabel}} collection * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}} * {{qwertyuiop}} */ protected function _prepareCollection() { $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{sibling}}_collection'){{siblingAdditionalPrepareCollection}}; if ($this->get{{Entity}}()->getId()) { $constraint = 'related.{{entity}}_id='.$this->get{{Entity}}()->getId(); } else { $constraint = 'related.{{entity}}_id=0'; } $collection->getSelect()->joinLeft( array('related' => $collection->getTable('{{namespace}}_{{module}}/{{entity}}_{{sibling}}')), 'related.{{sibling}}_id={{siblingTableAlias}}.entity_id AND '.$constraint, array('position') ); $this->setCollection($collection); parent::_prepareCollection(); return $this; } /** * prepare mass action grid * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}} * {{qwertyuiop}} */ protected function _prepareMassaction() { return $this; } /** * prepare the grid columns * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}} * {{qwertyuiop}} */ protected function _prepareColumns() { $this->addColumn( 'in_{{siblings}}', array( 'header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_{{siblings}}', 'values' => $this->_getSelected{{Siblings}}(), 'align' => 'center', 'index' => 'entity_id' ) ); $this->addColumn( '{{siblingNameAttribute}}', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('{{siblingNameAttributeLabel}}'), 'align' => 'left', 'index' => '{{siblingNameAttribute}}', 'renderer' => '{{namespace}}_{{module}}/adminhtml_helper_column_renderer_relation', 'params' => array( 'id' => 'getId' ), 'base_link' => 'adminhtml/{{module}}_{{sibling}}/edit', ) ); $this->addColumn( 'position', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Position'), 'name' => 'position', 'width' => 60, 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => true, ) ); } /** * Retrieve selected {{siblingsLabel}} * * @access protected * @return array * {{qwertyuiop}} */ protected function _getSelected{{Siblings}}() { ${{siblings}} = $this->get{{Entity}}{{Siblings}}(); if (!is_array(${{siblings}})) { ${{siblings}} = array_keys($this->getSelected{{Siblings}}()); } return ${{siblings}}; } /** * Retrieve selected {{siblingsLabels}} * * @access protected * @return array * {{qwertyuiop}} */ public function getSelected{{Siblings}}() { ${{siblings}} = array(); $selected = Mage::registry('current_{{entity}}')->getSelected{{Siblings}}(); if (!is_array($selected)) { $selected = array(); } foreach ($selected as ${{sibling}}) { ${{siblings}}[${{sibling}}->getId()] = array('position' => ${{sibling}}->getPosition()); } return ${{siblings}}; } /** * get row url * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Sibling}} * @return string * {{qwertyuiop}} */ public function getRowUrl($item) { return '#'; } /** * get grid url * * @access public * @return string * {{qwertyuiop}} */ public function getGridUrl() { return $this->getUrl( '*/*/{{siblings}}Grid', array( 'id' => $this->get{{Entity}}()->getId() ) ); } /** * get the current {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } /** * Add filter * * @access protected * @param object $column * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}} * {{qwertyuiop}} */ protected function _addColumnFilterToCollection($column) { // Set custom filter for in product flag if ($column->getId() == 'in_{{siblings}}') { ${{sibling}}Ids = $this->_getSelected{{Siblings}}(); if (empty(${{sibling}}Ids)) { ${{sibling}}Ids = 0; } if ($column->getFilter()->getValue()) { $this->getCollection()->addFieldToFilter('entity_id', array('in'=>${{sibling}}Ids)); } else { if (${{sibling}}Ids) { $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>${{sibling}}Ids)); } } } else { parent::_addColumnFilterToCollection($column); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Sibling/030_tree ================================================ class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tab_{{Sibling}} extends {{Namespace}}_{{Module}}_Block_Adminhtml_{{Sibling}}_Tree { protected $_{{sibling}}Ids = null; protected $_selectedNodes = null; /** * constructor * Specify template to use * * @access public * @return void * {{qwertyuiop}} */ public function __construct() { parent::__construct(); $this->setTemplate('{{namespace}}_{{module}}/{{entity}}/edit/tab/{{sibling}}.phtml'); } /** * Retrieve currently edited {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } /** * Return array with {{siblingsLabel}} IDs which the {{entityLabel}} is linked to * * @access public * @return array * {{qwertyuiop}} */ public function get{{Sibling}}Ids() { if (is_null($this->_{{sibling}}Ids)) { ${{siblings}} = $this->get{{Entity}}()->getSelected{{Siblings}}(); $ids = array(); foreach (${{siblings}} as ${{sibling}}) { $ids[] = ${{sibling}}->getId(); } $this->_{{sibling}}Ids = $ids; } return $this->_{{sibling}}Ids; } /** * Forms string out of get{{Sibling}}Ids() * * @access public * @return string * {{qwertyuiop}} */ public function getIdsString() { return implode(',', $this->get{{Sibling}}Ids()); } /** * Returns root node and sets 'checked' flag (if necessary) * * @access public * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRootNode() { $root = $this->getRoot(); if ($root && in_array($root->getId(), $this->get{{Sibling}}Ids())) { $root->setChecked(true); } return $root; } /** * Returns root node * * @param {{Namespace}}_{{Module}}_Model_{{Sibling}}|null $parentNode{{Sibling}} * @param int $recursionLevel * @return Varien_Data_Tree_Node * {{qwertyuiop}} */ public function getRoot($parentNode{{Sibling}} = null, $recursionLevel = 3) { if (!is_null($parentNode{{Sibling}}) && $parentNode{{Sibling}}->getId()) { return $this->getNode($parentNode{{Sibling}}, $recursionLevel); } $root = Mage::registry('{{sibling}}_root'); if (is_null($root)) { $rootId = Mage::helper('{{namespace}}_{{module}}/{{sibling}}')->getRoot{{Sibling}}Id(); $ids = $this->getSelected{{Sibling}}PathIds($rootId); $tree = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{sibling}}_tree') ->loadByIds($ids, false, false); if ($this->get{{Sibling}}()) { $tree->loadEnsuredNodes($this->get{{Sibling}}(), $tree->getNodeById($rootId)); } $tree->addCollectionData($this->get{{Sibling}}Collection()); $root = $tree->getNodeById($rootId); Mage::register('{{sibling}}_root', $root); } return $root; } /** * Returns array with configuration of current node * * @access public * @param Varien_Data_Tree_Node $node * @param int $level How deep is the node in the tree * @return array * {{qwertyuiop}} */ protected function _getNodeJson($node, $level = 1) { $item = parent::_getNodeJson($node, $level); if ($this->_isParentSelected{{Sibling}}($node)) { $item['expanded'] = true; } if (in_array($node->getId(), $this->get{{Sibling}}Ids())) { $item['checked'] = true; } return $item; } /** * Returns whether $node is a parent (not exactly direct) of a selected node * * @access public * @param Varien_Data_Tree_Node $node * @return bool * {{qwertyuiop}} */ protected function _isParentSelected{{Sibling}}($node) { $result = false; // Contains string with all {{siblingLabel}} IDs of children (not exactly direct) of the node $allChildren = $node->getAllChildren(); if ($allChildren) { $selected{{Sibling}}Ids = $this->get{{Sibling}}Ids(); $allChildrenArr = explode(',', $allChildren); for ($i = 0, $cnt = count($selected{{Sibling}}Ids); $i < $cnt; $i++) { $isSelf = $node->getId() == $selected{{Sibling}}Ids[$i]; if (!$isSelf && in_array($selected{{Sibling}}Ids[$i], $allChildrenArr)) { $result = true; break; } } } return $result; } /** * Returns array with nodes those are selected (contain current {{entityLabel}}) * * @access protected * @return array * {{qwertyuiop}} */ protected function _getSelectedNodes() { if ($this->_selectedNodes === null) { $this->_selectedNodes = array(); $root = $this->getRoot(); foreach ($this->get{{Sibling}}Ids() as ${{sibling}}Id) { if ($root) { $this->_selectedNodes[] = $root->getTree()->getNodeById(${{sibling}}Id); } } } return $this->_selectedNodes; } /** * Returns JSON-encoded array of {{siblingsLabel}} children * * @access public * @param int ${{sibling}}Id * @return string * {{qwertyuiop}} */ public function get{{Sibling}}ChildrenJson(${{sibling}}Id) { ${{sibling}} = Mage::getModel('{{namespace}}_{{module}}/{{sibling}}')->load(${{sibling}}Id); $node = $this->getRoot(${{sibling}}, 1)->getTree()->getNodeById(${{sibling}}Id); if (!$node || !$node->hasChildren()) { return '[]'; } $children = array(); foreach ($node->getChildren() as $child) { $children[] = $this->_getNodeJson($child); } return Mage::helper('core')->jsonEncode($children); } /** * Returns URL for loading tree * * @access public * @param null $expanded * @return string * {{qwertyuiop}} */ public function getLoadTreeUrl($expanded = null) { return $this->getUrl('*/*/{{siblings}}Json', array('_current' => true)); } /** * Return distinct path ids of selected {{siblingsLabel}} * * @access public * @param mixed $rootId Root {{siblingLabel}} Id for context * @return array * {{qwertyuiop}} */ public function getSelected{{Sibling}}PathIds($rootId = false) { $ids = array(); ${{sibling}}Ids = $this->get{{Sibling}}Ids(); if (empty(${{sibling}}Ids)) { return array(); } $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{sibling}}_collection'); if ($rootId) { $collection->addFieldToFilter('parent_id', $rootId); } else { $collection->addFieldToFilter('entity_id', array('in' => ${{sibling}}Ids)); } foreach ($collection as $item) { if ($rootId && !in_array($rootId, $item->getPathIds())) { continue; } foreach ($item->getPathIds() as $id) { if (!in_array($id, $ids)) { $ids[] = $id; } } } return $ids; } /** * Get node label * * @access public * @param Varien_Object $node * @return string * {{qwertyuiop}} */ public function buildNodeName($node) { $result = parent::buildNodeName($node); $result .= ''.$this->__(' - Edit').''; return $result; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Sibling/040_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Stores/010_content ================================================ setFieldNameSuffix('{{entity}}'); $this->setForm($form); $fieldset = $form->addFieldset( '{{entity}}_stores_form', array('legend' => Mage::helper('{{namespace}}_{{module}}')->__('Store views')) ); $field = $fieldset->addField( 'store_id', 'multiselect', array( 'name' => 'stores[]', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Store Views'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Store Views'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true), ) ); $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element'); $field->setRenderer($renderer); $form->addValues(Mage::registry('current_{{entity}}')->getData()); return parent::_prepareForm(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/010_top ================================================ setId('{{entity}}_tabs'); $this->setDestElementId('edit_form'); $this->setTitle(Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}')); } /** * before render html * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tabs * {{qwertyuiop}} */ protected function _beforeToHtml() { $this->addTab( 'form_{{entity}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_form' ) ->toHtml(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/030_flat_tree_prepare ================================================ $this->setId('{{entity}}_info_tabs'); $this->setDestElementId('{{entity}}_tab_content'); $this->setTitle(Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}')); $this->setTemplate('widget/tabshoriz.phtml'); } /** * Prepare Layout Content * * @access public * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tabs */ protected function _prepareLayout() { $this->addTab( 'form_{{entity}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_form' ) ->toHtml(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/040_eav_prepare_top ================================================ parent::__construct(); $this->setId('{{entity}}_info_tabs'); $this->setDestElementId('edit_form'); $this->setTitle(Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} Information')); } /** * prepare the layout * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tabs * {{qwertyuiop}} */ protected function _prepareLayout() { ${{entity}} = $this->get{{Entity}}(); $entity = Mage::getModel('eav/entity_type') ->load('{{namespace}}_{{module}}_{{entity}}', 'entity_type_code'); $attributes = Mage::getResourceModel('eav/entity_attribute_collection') ->setEntityTypeFilter($entity->getEntityTypeId()); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/042_eav_tree_prepare_top ================================================ parent::__construct(); $this->setId('{{entity}}_info_tabs'); $this->setDestElementId('{{entity}}_tab_content'); $this->setTitle(Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} Information')); $this->setTemplate('widget/tabshoriz.phtml'); } /** * prepare the layout * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Edit_Tabs * {{qwertyuiop}} */ protected function _prepareLayout() { ${{entity}} = $this->get{{Entity}}(); $entity = Mage::getModel('eav/entity_type') ->load('{{namespace}}_{{module}}_{{entity}}', 'entity_type_code'); $attributes = Mage::getResourceModel('eav/entity_attribute_collection') ->setEntityTypeFilter($entity->getEntityTypeId()); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/043_eav_seo_prepare ================================================ $attributes->addFieldToFilter( 'attribute_code', array( 'nin' => array('meta_title', 'meta_description', 'meta_keywords') ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/047_eav_prepare_bottom ================================================ $attributes->getSelect()->order('additional_table.position', 'ASC'); $this->addTab( 'info', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} Information'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_attributes' ) ->setAttributes($attributes) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/048_eav_prepare_bottom_tree ================================================ ->setAddHiddenFields(true) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/049_eav_prepare_real_bottom ================================================ ->toHtml(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/050_seo ================================================ $this->addTab( 'form_meta_{{entity}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Meta'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Meta'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_meta' ) ->toHtml(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/055_seo_eav ================================================ $seoAttributes = Mage::getResourceModel('eav/entity_attribute_collection') ->setEntityTypeFilter($entity->getEntityTypeId()) ->addFieldToFilter( 'attribute_code', array( 'in' => array('meta_title', 'meta_description', 'meta_keywords') ) ); $seoAttributes->getSelect()->order('additional_table.position', 'ASC'); $this->addTab( 'meta', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Meta'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Meta'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_attributes' ) ->setAttributes($seoAttributes) ->toHtml(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/060_stores ================================================ if (!Mage::app()->isSingleStoreMode()) { $this->addTab( 'form_store_{{entity}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Store views'), 'title' => Mage::helper('{{namespace}}_{{module}}')->__('Store views'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_stores' ) ->toHtml(), ) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/070_relation_not_tree ================================================ $this->addTab( '{{siblings}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{SiblingsLabel}}'), 'url' => $this->getUrl('*/*/{{siblings}}', array('_current' => true)), 'class' => 'ajax' ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/080_relation_tree ================================================ $this->addTab( '{{siblings}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{SiblingsLabel}}'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_{{sibling}}', '{{entity}}.{{sibling}}.grid' ) ->toHtml(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/090_product_relation_not_tree ================================================ $this->addTab( 'products', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Associated products'), 'url' => $this->getUrl('*/*/products', array('_current' => true)), 'class' => 'ajax' ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/100_product_relation_tree ================================================ $this->addTab( 'products', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Associated Products'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_product', '{{entity}}.product.grid' ) ->toHtml(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/110_category_relation_not_tree ================================================ $this->addTab( 'categories', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Associated categories'), 'url' => $this->getUrl('*/*/categories', array('_current' => true)), 'class' => 'ajax' ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/120_category_relation_tree ================================================ $this->addTab( 'categories', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Associated Categories'), 'content' => $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_categories', '{{entity}}.category.tree' ) ->toHtml(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/130_end_prepare_not_tree ================================================ return parent::_beforeToHtml(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/140_end_prepare_tree ================================================ return parent::_beforeToHtml(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tabs/150_footer ================================================ /** * Retrieve {{entityLabel}} entity * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/010_top ================================================ setId('{{entity}}Grid'); $this->setDefaultSort('entity_id'); $this->setDefaultDir('ASC'); $this->setSaveParametersInSession(true); $this->setUseAjax(true); } /** * prepare collection * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid * {{qwertyuiop}} */ protected function _prepareCollection() { $collection = Mage::getModel('{{namespace}}_{{module}}/{{entity}}') ->getCollection(){{entityCollectionAttributes}}; {{entityAdminJoin}} $this->setCollection($collection); return parent::_prepareCollection(); } /** * prepare grid collection * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid * {{qwertyuiop}} */ protected function _prepareColumns() { $this->addColumn( 'entity_id', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Id'), 'index' => 'entity_id', 'type' => 'number' ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/020_parents ================================================ $this->addColumn( '{{sibling}}_id', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('{{SiblingLabel}}'), 'index' => '{{sibling}}_id', 'type' => 'options', 'options' => Mage::getResourceModel('{{namespace}}_{{module}}/{{sibling}}_collection') {{siblingToOptionArraySelect}}->toOptionHash(), 'renderer' => '{{namespace}}_{{module}}/adminhtml_helper_column_renderer_parent', 'params' => array( 'id' => 'get{{Sibling}}Id' ),{{siblingParentStaticParams}} 'base_link' => 'adminhtml/{{module}}_{{sibling}}/edit' ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/030_name_attribute ================================================ $this->addColumn( '{{nameAttributeCode}}', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('{{nameAttributeLabel}}'), 'align' => 'left', 'index' => '{{nameAttributeCode}}', ) ); {{nameAttributeGridEav}} $this->addColumn( 'status', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Status'), 'index' => 'status', 'type' => 'options', 'options' => array( '1' => Mage::helper('{{namespace}}_{{module}}')->__('Enabled'), '0' => Mage::helper('{{namespace}}_{{module}}')->__('Disabled'), ) ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/040_grid_attributes ================================================ $this->addColumn( '{{attributeCode}}', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('{{attributeLabel}}'), 'index' => '{{attributeCode}}',{{attributeColumnOptions}} ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/050_url_rewrite ================================================ $this->addColumn( 'url_key', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('URL key'), 'index' => 'url_key', ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/060_stores ================================================ if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) { $this->addColumn( 'store_id', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Store Views'), 'index' => 'store_id', 'type' => 'store', 'store_all' => true, 'store_view' => true, 'sortable' => false, 'filter_condition_callback'=> array($this, '_filterStoreCondition'), ) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/070_created_at ================================================ $this->addColumn( 'created_at', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Created at'), 'index' => 'created_at', 'width' => '120px', 'type' => 'datetime', ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/080_updated_at ================================================ $this->addColumn( 'updated_at', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Updated at'), 'index' => 'updated_at', 'width' => '120px', 'type' => 'datetime', ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/090_columns_footer ================================================ $this->addColumn( 'action', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Action'), 'width' => '100', 'type' => 'action', 'getter' => 'getId', 'actions' => array( array( 'caption' => Mage::helper('{{namespace}}_{{module}}')->__('Edit'), 'url' => array('base'=> '*/*/edit'), 'field' => 'id' ) ), 'filter' => false, 'is_system' => true, 'sortable' => false, ) ); $this->addExportType('*/*/exportCsv', Mage::helper('{{namespace}}_{{module}}')->__('CSV')); $this->addExportType('*/*/exportExcel', Mage::helper('{{namespace}}_{{module}}')->__('Excel')); $this->addExportType('*/*/exportXml', Mage::helper('{{namespace}}_{{module}}')->__('XML')); return parent::_prepareColumns(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/100_eav_functions ================================================ /** * get the selected store * * @access protected * @return Mage_Core_Model_Store * {{qwertyuiop}} */ protected function _getStore() { $storeId = (int) $this->getRequest()->getParam('store', 0); return Mage::app()->getStore($storeId); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/110_mass_action_top ================================================ /** * prepare mass action * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid * {{qwertyuiop}} */ protected function _prepareMassaction() { $this->setMassactionIdField('entity_id'); $this->getMassactionBlock()->setFormFieldName('{{entity}}'); $this->getMassactionBlock()->addItem( 'delete', array( 'label'=> Mage::helper('{{namespace}}_{{module}}')->__('Delete'), 'url' => $this->getUrl('*/*/massDelete'), 'confirm' => Mage::helper('{{namespace}}_{{module}}')->__('Are you sure?') ) ); $this->getMassactionBlock()->addItem( 'status', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Change status'), 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)), 'additional' => array( 'status' => array( 'name' => 'status', 'type' => 'select', 'class' => 'required-entry', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Status'), 'values' => array( '1' => Mage::helper('{{namespace}}_{{module}}')->__('Enabled'), '0' => Mage::helper('{{namespace}}_{{module}}')->__('Disabled'), ) ) ) ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/120_mass_action_flags ================================================ $this->getMassactionBlock()->addItem( '{{attributeCode}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Change {{attributeLabel}}'), 'url' => $this->getUrl('*/*/mass{{AttributeMagicCode}}', array('_current'=>true)), 'additional' => array( 'flag_{{attributeCode}}' => array( 'name' => 'flag_{{attributeCode}}', 'type' => 'select', 'class' => 'required-entry', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{attributeLabel}}'), 'values' => {{massActionValues}} ) ) ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/130_mass_action_parents ================================================ $values = Mage::getResourceModel('{{namespace}}_{{module}}/{{sibling}}_collection')->toOptionHash(); $values = array_reverse($values, true); $values[''] = ''; $values = array_reverse($values, true); $this->getMassactionBlock()->addItem( '{{sibling}}_id', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Change {{SiblingLabel}}'), 'url' => $this->getUrl('*/*/mass{{Sibling}}Id', array('_current'=>true)), 'additional' => array( 'flag_{{sibling}}_id' => array( 'name' => 'flag_{{sibling}}_id', 'type' => 'select', 'class' => 'required-entry', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{SiblingLabel}}'), 'values' => $values ) ) ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/140_collection_end ================================================ return $this; } /** * get the row url * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} * @return string * {{qwertyuiop}} */ public function getRowUrl($row) { return $this->getUrl('*/*/edit', array('id' => $row->getId())); } /** * get the grid url * * @access public * @return string * {{qwertyuiop}} */ public function getGridUrl() { return $this->getUrl('*/*/grid', array('_current'=>true)); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/145_collection_walk ================================================ /** * after collection load * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid * {{qwertyuiop}} */ protected function _afterLoadCollection() { $this->getCollection()->walk('afterLoad'); parent::_afterLoadCollection(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/150_store_filter ================================================ /** * filter store column * * @access protected * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection * @param Mage_Adminhtml_Block_Widget_Grid_Column $column * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Grid * {{qwertyuiop}} */ protected function _filterStoreCondition($collection, $column) { if (!$value = $column->getFilter()->getValue()) { return; } $collection->addStoreFilter($value); return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/160_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Helper/File/010_content ================================================ setType('file'); } /** * get element html * * @access public * @return string * {{qwertyuiop}} */ public function getElementHtml() { $html = ''; $this->addClass('input-file'); $html .= parent::getElementHtml(); if ($this->getValue()) { $url = $this->_getUrl(); if (!preg_match("/^http\:\/\/|https\:\/\//", $url)) { $url = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getFileBaseUrl() . $url; } $html .= '
    '.$this->_getUrl().' '; } $html .= $this->_getDeleteCheckbox(); return $html; } /** * get the delete checkbox HTML * * @access protected * @return string * {{qwertyuiop}} */ protected function _getDeleteCheckbox() { $html = ''; if ($this->getValue()) { $label = Mage::helper('{{namespace}}_{{module}}')->__('Delete File'); $html .= ''; $html .= 'getDisabled() ? ' disabled="disabled"': '').'/>'; $html .= ''; $html .= $this->_getHiddenInput(); $html .= ''; } return $html; } /** * get the hidden input * * @access protected * @return string * {{qwertyuiop}} */ protected function _getHiddenInput() { return ''; } /** * get the file url * * @access protected * @return string * {{qwertyuiop}} */ protected function _getUrl() { return $this->getValue(); } /** * get the name * * @access public * @return string * {{qwertyuiop}} */ public function getName() { return $this->getData('name'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Helper/Image/010_content ================================================ getValue()) { $url = Mage::helper('{{namespace}}_{{module}}/{{entity}}_image')->getImageBaseUrl(). $this->getValue(); } return $url; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Tree/010_top ================================================ setTemplate('{{namespace}}_{{module}}/{{entity}}/tree.phtml'); $this->setUseAjax(true); $this->_withProductCount = true; } /** * prepare the layout * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Tree * {{qwertyuiop}} */ protected function _prepareLayout() { $addUrl = $this->getUrl( "*/*/add", array( '_current'=>true, 'id'=>null, '_query' => false ) ); $this->setChild( 'add_sub_button', $this->getLayout()->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Add Child {{EntityLabel}}'), 'onclick' => "addNew('".$addUrl."', false)", 'class' => 'add', 'id' => 'add_child_{{entity}}_button', 'style' => $this->canAddChild() ? '' : 'display: none;' ) ) ); $this->setChild( 'add_root_button', $this->getLayout()->createBlock('adminhtml/widget_button') ->setData( array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Add Root {{EntityLabel}}'), 'onclick' => "addNew('".$addUrl."', true)", 'class' => 'add', 'id' => 'add_root_{{entity}}_button' ) ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Tree/020_store_switcher ================================================ $this->setChild( 'store_switcher', $this->getLayout()->createBlock('adminhtml/store_switcher') ->setSwitchUrl( $this->getUrl( '*/*/*', array( '_current' =>true, '_query'=>false, 'store'=>null ) ) ) ->setTemplate('store/switcher/enhanced.phtml') ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Tree/030_content ================================================ return parent::_prepareLayout(); } /** * get the {{entityLabel}} collection * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function get{{Entity}}Collection() { $collection = $this->getData('{{entity}}_collection'); if (is_null($collection)) { $collection = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->getCollection(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Tree/040_eav ================================================ $collection->addAttributeToSelect('{{nameAttributeCode}}')->addAttributeToSelect('status'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Tree/050_methods ================================================ $this->setData('{{entity}}_collection', $collection); } return $collection; } /** * get html for add root button * * @access public * @return string * {{qwertyuiop}} */ public function getAddRootButtonHtml() { return $this->getChildHtml('add_root_button'); } /** * get html for add child button * * @access public * @return string * {{qwertyuiop}} */ public function getAddSubButtonHtml() { return $this->getChildHtml('add_sub_button'); } /** * get html for expand button * * @access public * @return string * {{qwertyuiop}} */ public function getExpandButtonHtml() { return $this->getChildHtml('expand_button'); } /** * get html for add collapse button * * @access public * @return string * {{qwertyuiop}} */ public function getCollapseButtonHtml() { return $this->getChildHtml('collapse_button'); } /** * get url for tree load * * @access public * @param mxed $expanded * @return string * {{qwertyuiop}} */ public function getLoadTreeUrl($expanded=null) { $params = array('_current' => true, 'id' => null, 'store' => null); if ((is_null($expanded) && Mage::getSingleton('admin/session')->get{{Entity}}IsTreeWasExpanded()) || $expanded == true) { $params['expand_all'] = true; } return $this->getUrl('*/*/{{entities}}Json', $params); } /** * get url for loading nodes * * @access public * @return string * {{qwertyuiop}} */ public function getNodesUrl() { return $this->getUrl('*/{{module}}_{{entities}}/jsonTree'); } /** * check if tree is expanded * * @access public * @return string * {{qwertyuiop}} */ public function getIsWasExpanded() { return Mage::getSingleton('admin/session')->get{{Entity}}IsTreeWasExpanded(); } /** * get url for moving {{entityLabel}} * * @access public * @return string * {{qwertyuiop}} */ public function getMoveUrl() { return $this->getUrl('*/{{module}}_{{entity}}/move'); } /** * get the tree as json * * @access public * @param mixed $parentNode{{Entity}} * @return string * {{qwertyuiop}} */ public function getTree($parentNode{{Entity}} = null) { $rootArray = $this->_getNodeJson($this->getRoot($parentNode{{Entity}})); $tree = isset($rootArray['children']) ? $rootArray['children'] : array(); return $tree; } /** * get the tree as json * * @access public * @param mixed $parentNode{{Entity}} * @return string * {{qwertyuiop}} */ public function getTreeJson($parentNode{{Entity}} = null) { $rootArray = $this->_getNodeJson($this->getRoot($parentNode{{Entity}})); $json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array()); return $json; } /** * Get JSON of array of {{entitiesLabel}}, that are breadcrumbs for specified {{entityLabel}} path * * @access public * @param string $path * @param string $javascriptVarName * @return string * {{qwertyuiop}} */ public function getBreadcrumbsJavascript($path, $javascriptVarName) { if (empty($path)) { return ''; } ${{entities}} = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_tree') ->loadBreadcrumbsArray($path); if (empty(${{entities}})) { return ''; } foreach (${{entities}} as $key => ${{entity}}) { ${{entities}}[$key] = $this->_getNodeJson(${{entity}}); } return ''; } /** * Get JSON of a tree node or an associative array * * @access protected * @param Varien_Data_Tree_Node|array $node * @param int $level * @return string * {{qwertyuiop}} */ protected function _getNodeJson($node, $level = 0) { // create a node from data array if (is_array($node)) { $node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree); } $item = array(); $item['text'] = $this->buildNodeName($node); $item['id'] = $node->getId(); $item['path'] = $node->getData('path'); $item['cls'] = 'folder'; if ($node->getStatus()) { $item['cls'] .= ' active-category'; } else { $item['cls'] .= ' no-active-category'; } $item['allowDrop'] = true; $item['allowDrag'] = true; if ((int)$node->getChildrenCount()>0) { $item['children'] = array(); } $isParent = $this->_isParentSelected{{Entity}}($node); if ($node->hasChildren()) { $item['children'] = array(); if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) { foreach ($node->getChildren() as $child) { $item['children'][] = $this->_getNodeJson($child, $level+1); } } } if ($isParent || $node->getLevel() < 1) { $item['expanded'] = true; } return $item; } /** * Get node label * * @access public * @param Varien_Object $node * @return string * {{qwertyuiop}} */ public function buildNodeName($node) { $result = $this->escapeHtml($node->get{{EntityNameMagicCode}}()); return $result; } /** * check if entity is movable * * @access protected * @param Varien_Object $node * @return bool * {{qwertyuiop}} */ protected function _is{{Entity}}Moveable($node) { return true; } /** * check if parent is selected * * @access protected * @param Varien_Object $node * @return bool * {{qwertyuiop}} */ protected function _isParentSelected{{Entity}}($node) { if ($node && $this->get{{Entity}}()) { $pathIds = $this->get{{Entity}}()->getPathIds(); if (in_array($node->getId(), $pathIds)) { return true; } } return false; } /** * Check if page loaded by outside link to {{entityLabel}} edit * * @access public * @return boolean * {{qwertyuiop}} */ public function isClearEdit() { return (bool) $this->getRequest()->getParam('clear'); } /** * Check availability of adding root {{entityLabel}} * * @access public * @return boolean * {{qwertyuiop}} */ public function canAddRoot{{Entity}}() { return true; } /** * Check availability of adding child {{entityLabel}} * * @access public * @return boolean */ public function canAddChild() { return true; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Tree/060_store_switcher_block ================================================ /** * get store switcher html * * @access public * @return string * {{qwertyuiop}} */ public function getStoreSwitcherHtml() { return $this->getChildHtml('store_switcher'); } /** * get current store * * @access public * @return string * {{qwertyuiop}} */ public function getStore() { $storeId = (int) $this->getRequest()->getParam('store'); return Mage::app()->getStore($storeId); } /** * get switch url * * @access public * @return string * {{qwertyuiop}} */ public function getSwitchTreeUrl() { return $this->getUrl( "*/{{module}}_{{entity}}/tree", array( '_current'=>true, 'store'=>null, '_query'=>false, 'id'=>null, 'parent'=>null ) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Tree/070_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Widget/Chooser/010_top ================================================ setDefaultSort('entity_id'); $this->setDefaultDir('ASC'); $this->setUseAjax(true); $this->setDefaultFilter(array('chooser_status' => '1')); } /** * Prepare chooser element HTML * * @access public * @param Varien_Data_Form_Element_Abstract $element Form Element * @return Varien_Data_Form_Element_Abstract * {{qwertyuiop}} */ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element) { $uniqId = Mage::helper('core')->uniqHash($element->getId()); $sourceUrl = $this->getUrl( '*/{{module}}_{{entity}}_widget/chooser', array('uniq_id' => $uniqId) ); $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser') ->setElement($element) ->setTranslationHelper($this->getTranslationHelper()) ->setConfig($this->getConfig()) ->setFieldsetId($this->getFieldsetId()) ->setSourceUrl($sourceUrl) ->setUniqId($uniqId); if ($element->getValue()) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($element->getValue()); if (${{entity}}->getId()) { $chooser->setLabel(${{entity}}->get{{EntityNameMagicCode}}()); } } $element->setData('after_element_html', $chooser->toHtml()); return $element; } /** * Grid Row JS Callback * * @access public * @return string * {{qwertyuiop}} */ public function getRowClickCallback() { $chooserJsObject = $this->getId(); $js = ' function (grid, event) { var trElement = Event.findElement(event, "tr"); var {{entity}}Id = trElement.down("td").innerHTML.replace(/^\s+|\s+$/g,""); var {{entity}}Title = trElement.down("td").next().innerHTML; '.$chooserJsObject.'.setElementValue({{entity}}Id); '.$chooserJsObject.'.setElementLabel({{entity}}Title); '.$chooserJsObject.'.close(); } '; return $js; } /** * Prepare a static blocks collection * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser * {{qwertyuiop}} */ protected function _prepareCollection() { $collection = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->getCollection(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Widget/Chooser/030_not_tree_eav ================================================ $collection->addAttributeToSelect('{{nameAttributeCode}}'); $collection->addAttributeToSelect('status'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Widget/Chooser/040_not_tree_content ================================================ $this->setCollection($collection); return parent::_prepareCollection(); } /** * Prepare columns for the a grid * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser * {{qwertyuiop}} */ protected function _prepareColumns() { $this->addColumn( 'chooser_id', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Id'), 'align' => 'right', 'index' => 'entity_id', 'type' => 'number', 'width' => 50 ) ); $this->addColumn( 'chooser_{{nameAttributeCode}}', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('{{nameAttributeLabel}}'), 'align' => 'left', 'index' => '{{nameAttributeCode}}', ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Widget/Chooser/050_not_tree_store ================================================ if (!Mage::app()->isSingleStoreMode()) { $this->addColumn( 'store_id', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Store Views'), 'index' => 'store_id', 'type' => 'store', 'store_all' => true, 'store_view' => true, 'sortable' => false, ) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Widget/Chooser/060_not_tree_footer ================================================ $this->addColumn( 'chooser_status', array( 'header' => Mage::helper('{{namespace}}_{{module}}')->__('Status'), 'index' => 'status', 'type' => 'options', 'options' => array( 0 => Mage::helper('{{namespace}}_{{module}}')->__('Disabled'), 1 => Mage::helper('{{namespace}}_{{module}}')->__('Enabled') ), ) ); return parent::_prepareColumns(); } /** * get url for grid * * @access public * @return string * {{qwertyuiop}} */ public function getGridUrl() { return $this->getUrl( 'adminhtml/{{module}}_{{entity}}_widget/chooser', array('_current' => true) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Widget/Chooser/070_not_tree_flat ================================================ /** * after collection load * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser * {{qwertyuiop}} */ protected function _afterLoadCollection() { $this->getCollection()->walk('afterLoad'); parent::_afterLoadCollection(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Widget/Chooser/080_tree ================================================ class {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser extends {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Tree { protected $_selected{{Entities}} = array(); /** * Block construction * Defines tree template and init tree params * * @access public * @return void * {{qwertyuiop}} */ public function __construct() { parent::__construct(); $this->setTemplate('{{namespace}}_{{module}}/{{entity}}/widget/tree.phtml'); } /** * Setter * * @access public * @param array $selected{{Entities}} * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser * {{qwertyuiop}} */ public function setSelected{{Entities}}($selected{{Entities}}) { $this->_selected{{Entities}} = $selected{{Entities}}; return $this; } /** * Getter * * @access public * @return array * {{qwertyuiop}} */ public function getSelected{{Entities}}() { return $this->_selected{{Entities}}; } /** * Prepare chooser element HTML * * @access public * @param Varien_Data_Form_Element_Abstract $element Form Element * @return Varien_Data_Form_Element_Abstract * {{qwertyuiop}} */ public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element) { $uniqId = Mage::helper('core')->uniqHash($element->getId()); $sourceUrl = $this->getUrl( '*/{{module}}_{{entity}}_widget/chooser', array('uniq_id' => $uniqId, 'use_massaction' => false) ); $chooser = $this->getLayout()->createBlock('widget/adminhtml_widget_chooser') ->setElement($element) ->setTranslationHelper($this->getTranslationHelper()) ->setConfig($this->getConfig()) ->setFieldsetId($this->getFieldsetId()) ->setSourceUrl($sourceUrl) ->setUniqId($uniqId); $value = $element->getValue(); ${{entity}}Id = false; if ($value) { ${{entity}}Id = $value; } if (${{entity}}Id) { $label = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id) ->get{{EntityNameMagicCode}}(); $chooser->setLabel($label); } $element->setData('after_element_html', $chooser->toHtml()); return $element; } /** * onClick listener js function * * @access public * @return string * {{qwertyuiop}} */ public function getNodeClickListener() { if ($this->getData('node_click_listener')) { return $this->getData('node_click_listener'); } if ($this->getUseMassaction()) { $js = ' function (node, e) { if (node.ui.toggleCheck) { node.ui.toggleCheck(true); } } '; } else { $chooserJsObject = $this->getId(); $js = ' function (node, e) { '.$chooserJsObject.'.setElementValue(node.attributes.id); '.$chooserJsObject.'.setElementLabel(node.text); '.$chooserJsObject.'.close(); } '; } return $js; } /** * Get JSON of a tree node or an associative array * * @access protected * @param Varien_Data_Tree_Node|array $node * @param int $level * @return string * {{qwertyuiop}} */ protected function _getNodeJson($node, $level = 0) { $item = parent::_getNodeJson($node, $level); if (in_array($node->getId(), $this->getSelected{{Entities}}())) { $item['checked'] = true; } return $item; } /** * Tree JSON source URL * * @access public * @param mixed $expanded * @return string * {{qwertyuiop}} */ public function getLoadTreeUrl($expanded=null) { return $this->getUrl( '*/{{module}}_{{entity}}_widget/{{entities}}Json', array( '_current'=>true, 'uniq_id' => $this->getId(), 'use_massaction' => $this->getUseMassaction() ) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Widget/Chooser/090_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Helper/Column/Renderer/Parent/010_content ================================================ getColumn()->getBaseLink(); if (!$base) { return parent::render($row); } $paramsData = $this->getColumn()->getData('params'); $params = array(); if (is_array($paramsData)) { foreach ($paramsData as $name=>$getter) { if (is_callable(array($row, $getter))) { $params[$name] = call_user_func(array($row, $getter)); } } } $staticParamsData = $this->getColumn()->getData('static'); if (is_array($staticParamsData)) { foreach ($staticParamsData as $key=>$value) { $params[$key] = $value; } } $options = $this->getColumn()->getOptions(); $showMissingOptionValues = (bool)$this->getColumn()->getShowMissingOptionValues(); if (!empty($options) && is_array($options)) { $value = $row->getData($this->getColumn()->getIndex()); if (is_array($value)) { $res = array(); foreach ($value as $item) { if (isset($options[$item])) { $res[] = ''. $this->escapeHtml($options[$item]). ''; } elseif ($showMissingOptionValues) { $res[] = ''. $this->escapeHtml($item). ''; } } return implode('
    ', $res); } elseif (isset($options[$value])) { return ''. $this->escapeHtml($options[$value]). ''; } elseif (in_array($value, $options)) { return ''. $this->escapeHtml($value). ''; } } } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Helper/Column/Renderer/Relation/010_content ================================================ getColumn()->getBaseLink(); if (!$base) { return parent::render($row); } $paramsData = $this->getColumn()->getData('params'); $params = array(); if (is_array($paramsData)) { foreach ($paramsData as $name=>$getter) { if (is_callable(array($row, $getter))) { $params[$name] = call_user_func(array($row, $getter)); } } } $staticParamsData = $this->getColumn()->getData('static'); if (is_array($staticParamsData)) { foreach ($staticParamsData as $key=>$value) { $params[$key] = $value; } } return ''.$this->_getValue($row).''; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Helper/Wysiwyg/010_content ================================================ getDisabled() || $this->getReadonly()); $html .= Mage::getSingleton('core/layout') ->createBlock( 'adminhtml/widget_button', '', array( 'label' => Mage::helper('catalog')->__('WYSIWYG Editor'), 'type'=> 'button', 'disabled' => $disabled, 'class' => ($disabled) ? 'disabled btn-wysiwyg' : 'btn-wysiwyg', 'onclick' => 'catalogWysiwygEditor.open(\''. Mage::helper('adminhtml')->getUrl('*/*/wysiwyg').'\', \''. $this->getHtmlId().'\')' ) ) ->toHtml(); return $html; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Module/Helper/Form/Wysiwyg/Content/010_content ================================================ 'wysiwyg_edit_form', 'action' => $this->getData('action'), 'method' => 'post' ) ); $config['document_base_url'] = $this->getData('store_media_url'); $config['store_id'] = $this->getData('store_id'); $config['add_variables'] = false; $config['add_widgets'] = false; $config['add_directives'] = true; $config['use_container'] = true; $config['container_class'] = 'hor-scroll'; $editorConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig($config); $editorConfig->setData( 'files_browser_window_url', Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg_images/index') ); $form->addField( $this->getData('editor_element_id'), 'editor', array( 'name' => 'content', 'style' => 'width:725px;height:460px', 'required' => true, 'force_load' => true, 'config' => $editorConfig ) ); $this->setForm($form); return parent::_prepareForm(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Module/Renderer/Fieldset/Element/010_content ================================================ setTemplate('{{namespace}}_{{module}}/form/renderer/fieldset/element.phtml'); } /** * Retrieve data object related with form * * @access public * @return mixed * {{qwertyuiop}} */ public function getDataObject() { return $this->getElement()->getForm()->getDataObject(); } /** * Retrieve associated with element attribute object * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_Eav_Attribute * {{qwertyuiop}} */ public function getAttribute() { return $this->getElement()->getEntityAttribute(); } /** * Retrieve associated attribute code * * @access public * @return string * {{qwertyuiop}} */ public function getAttributeCode() { return $this->getAttribute()->getAttributeCode(); } /** * Check "Use default" checkbox display availability * * @access public * @return bool * {{qwertyuiop}} */ public function canDisplayUseDefault() { if ($attribute = $this->getAttribute()) { if (!$this->isScopeGlobal($attribute) && $this->getDataObject() && $this->getDataObject()->getId() && $this->getDataObject()->getStoreId()) { return true; } } return false; } /** * Check default value usage fact * * @access public * @return bool * {{qwertyuiop}} */ public function usedDefault() { $defaultValue = $this->getDataObject()->getAttributeDefaultValue($this->getAttribute()->getAttributeCode()); return $defaultValue === false; } /** * Disable field in default value using case * * @access public * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Module}}_Renderer_Fieldset_Element * {{qwertyuiop}} */ public function checkFieldDisable() { if ($this->canDisplayUseDefault() && $this->usedDefault()) { $this->getElement()->setDisabled(true); } return $this; } /** * Retrieve label of attribute scope * GLOBAL | WEBSITE | STORE * * @access public * @return string * {{qwertyuiop}} */ public function getScopeLabel() { $html = ''; $attribute = $this->getElement()->getEntityAttribute(); if (!$attribute || Mage::app()->isSingleStoreMode()) { return $html; } if ($this->isScopeGlobal($attribute)) { $html.= Mage::helper('{{namespace}}_{{module}}')->__('[GLOBAL]'); } elseif ($this->isScopeWebsite($attribute)) { $html.= Mage::helper('{{namespace}}_{{module}}')->__('[WEBSITE]'); } elseif ($this->isScopeStore($attribute)) { $html.= Mage::helper('{{namespace}}_{{module}}')->__('[STORE VIEW]'); } return $html; } /** * Retrieve element label html * * @access public * @return string * {{qwertyuiop}} */ public function getElementLabelHtml() { return $this->getElement()->getLabelHtml(); } /** * Retrieve element html * * @access public * @return string * {{qwertyuiop}} */ public function getElementHtml() { return $this->getElement()->getElementHtml(); } /** * check if an attribute is global * * @access public * @param Mage_Eav_Model_Entity_Attribute $attribute * @return bool * {{qwertyuiop}} */ public function isScopeGlobal($attribute) { return $attribute->getIsGlobal() == 1; } /** * check if an attribute has website scope * * @access public * @param Mage_Eav_Model_Entity_Attribute $attribute * @return bool * {{qwertyuiop}} */ public function isScopeWebsite($attribute) { return $attribute->getIsGlobal() == 2; } /** * check if an attribute has store view scope * * @access public * @param Mage_Eav_Model_Entity_Attribute $attribute * @return bool * {{qwertyuiop}} */ public function isScopeStore($attribute) { return !$this->isScopeGlobal($attribute) && !$this->isScopeWebsite($attribute); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Category/List/Entity/010_top ================================================ hasData('{{entity}}_collection')) { $category = Mage::registry('current_category'); $collection = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_collection') ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Category/List/Entity/020_store ================================================ ->addStoreFilter(Mage::app()->getStore()) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Category/List/Entity/030_eav ================================================ ->setStoreId(Mage::app()->getStore()->getId()) ->addAttributeToSelect('*') ->addAttributeToFilter('status', 1) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Category/List/Entity/040_not_eav ================================================ ->addFieldToFilter('status', 1) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Category/List/Entity/050_footer ================================================ ->addCategoryFilter($category); $collection->getSelect()->order('related_category.position', 'ASC'); $this->setData('{{entity}}_collection', $collection); } return $this->getData('{{entity}}_collection'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Product/List/Entity/010_top ================================================ hasData('{{entity}}_collection')) { $product = Mage::registry('product'); $collection = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_collection') ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Product/List/Entity/020_store ================================================ ->addStoreFilter(Mage::app()->getStore()) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Product/List/Entity/030_eav ================================================ ->setStoreId(Mage::app()->getStore()->getId()) ->addAttributeToSelect('{{nameAttributeCode}}', 1) ->addAttributeToFilter('status', 1) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Product/List/Entity/040_not_eav ================================================ ->addFieldToFilter('status', 1) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Catalog/Product/List/Entity/050_footer ================================================ ->addProductFilter($product); $collection->getSelect()->order('related_product.position', 'ASC'); $this->setData('{{entity}}_collection', $collection); } return $this->getData('{{entity}}_collection'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Catalog/Category/List/010_content ================================================ get{{Entity}}()->getSelectedCategoriesCollection(); $collection->addAttributeToSelect('name'); $collection->getSelect()->order('related.position'); $collection->addAttributeToFilter('is_active', 1); return $collection; } /** * get current {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Catalog/Product/List/010_content ================================================ get{{Entity}}()->getSelectedProductsCollection(); $collection->addAttributeToSelect('name'); $collection->addUrlRewrite(); $collection->getSelect()->order('related.position'); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $collection; } /** * get current {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Child/List/010_content ================================================ get{{Entity}}(); if (${{entity}}) { $this->get{{Siblings}}()->addFieldToFilter('{{entity}}_id', ${{entity}}->getId()); } } /** * prepare the layout - actually do nothing * * @access protected * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_{{Sibling}}_List * {{qwertyuiop}} */ protected function _prepareLayout() { return $this; } /** * get the current {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Children/010_content ================================================ get{{Entities}}()->addFieldToFilter('parent_id', $this->getCurrent{{Entity}}()->getId()); return $this; } /** * get the current {{entityLabel}} * * @access protected * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function getCurrent{{Entity}}() { return Mage::registry('current_{{entity}}'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Comment/Form/010_content ================================================ get{{Entity}}CommentFormData(true); $data = new Varien_Object($data); // add logged in customer name as nickname if (!$data->getName()) { $customer = $customerSession->getCustomer(); if ($customer && $customer->getId()) { $data->setName($customer->getFirstname()); $data->setEmail($customer->getEmail()); } } $this->setAllowWriteCommentFlag( $customerSession->isLoggedIn() || Mage::getStoreConfigFlag('{{namespace}}_{{module}}/{{entity}}/allow_guest_comment') ); if (!$this->getAllowWriteCommentFlag()) { $this->setLoginLink( Mage::getUrl( 'customer/account/login/', array( Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME => Mage::helper('core')->urlEncode( Mage::getUrl('*/*/*', array('_current' => true)) . '#comment-form' ) ) ) ); } $this->setCommentData($data); } /** * get current {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } /** * get form action * * @access public * @return string * {{qwertyuiop}} */ public function getAction() { return Mage::getUrl( '{{namespace}}_{{module}}/{{entity}}/commentpost', array('id' => $this->get{{Entity}}()->getId()) ); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Comment/List/010_top ================================================ get{{Entity}}(); $comments = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_comment_collection') ->addFieldToFilter('{{entity}}_id', ${{entity}}->getId()) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Comment/List/020_stores ================================================ ->addStoreFilter(Mage::app()->getStore()) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Comment/List/030_footer ================================================ ->addFieldToFilter('status', 1); $comments->setOrder('created_at', 'asc'); $this->setComments($comments); } /** * prepare the layout * * @access protected * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_Comment_List * {{qwertyuiop}} */ protected function _prepareLayout() { parent::_prepareLayout(); $pager = $this->getLayout()->createBlock( 'page/html_pager', '{{namespace}}_{{module}}.{{entity}}.html.pager' ) ->setCollection($this->getComments()); $this->setChild('pager', $pager); $this->getComments()->load(); return $this; } /** * get the pager html * * @access public * @return string * {{qwertyuiop}} */ public function getPagerHtml() { return $this->getChildHtml('pager'); } /** * get the current {{entityLabel}} * * @access protected * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Customer/Comment/List/010_top ================================================ _collection = Mage::getResourceModel( '{{namespace}}_{{module}}/{{entity}}_comment_{{entity}}_collection' ); $this->_collection ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Customer/Comment/List/020_store ================================================ ->setStoreFilter(Mage::app()->getStore()->getId(), true) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Customer/Comment/List/030_filter_eav ================================================ ->addAttributeToFilter('status', 1) //only active ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Customer/Comment/List/040_filter_flat ================================================ ->addFieldToFilter('main_table.status', 1) //only active ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Customer/Comment/List/050_footer ================================================ ->addStatusFilter({{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_APPROVED) //only approved comments ->addCustomerFilter(Mage::getSingleton('customer/session')->getCustomerId()) //only my comments ->setDateOrder(); } /** * Gets collection items count * * @access public * @return int * {{qwertyuiop}} */ public function count() { return $this->_collection->getSize(); } /** * Get html code for toolbar * * @access public * @return string * {{qwertyuiop}} */ public function getToolbarHtml() { return $this->getChildHtml('toolbar'); } /** * Initializes toolbar * * @access protected * @return Mage_Core_Block_Abstract * {{qwertyuiop}} */ protected function _prepareLayout() { $toolbar = $this->getLayout()->createBlock('page/html_pager', 'customer_{{entity}}_comments.toolbar') ->setCollection($this->getCollection()); $this->setChild('toolbar', $toolbar); return parent::_prepareLayout(); } /** * Get collection * * @access protected * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ protected function _getCollection() { return $this->_collection; } /** * Get collection * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ public function getCollection() { return $this->_getCollection(); } /** * Get review link * * @access public * @param mixed $comment * @return string * {{qwertyuiop}} */ public function getCommentLink($comment) { if ($comment instanceof Varien_Object) { $comment = $comment->getCtCommentId(); } return Mage::getUrl( '{{namespace}}_{{module}}/{{entity}}_customer_comment/view/', array('id' => $comment) ); } /** * Get product link * * @access public * @param mixed $comment * @return string * {{qwertyuiop}} */ public function get{{Entity}}Link($comment) { return $comment->get{{Entity}}Url(); } /** * Format date in short format * * @access public * @param $date * @return string * {{qwertyuiop}} */ public function dateFormat($date) { return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Customer/Comment/View/010_content ================================================ addStoreFilter(Mage::app()->getStore()) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/List/030_attributes ================================================ ->setStoreId(Mage::app()->getStore()->getId()) ->addAttributeToSelect('*') ->addAttributeToFilter('status', 1); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/List/040_status ================================================ ->addFieldToFilter('status', 1); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/List/050_not_tree ================================================ ${{entities}}->setOrder('{{nameAttributeCode}}', 'asc'); $this->set{{Entities}}(${{entities}}); } /** * prepare the layout * * @access protected * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_List * {{qwertyuiop}} */ protected function _prepareLayout() { parent::_prepareLayout(); $pager = $this->getLayout()->createBlock( 'page/html_pager', '{{namespace}}_{{module}}.{{entity}}.html.pager' ) ->setCollection($this->get{{Entities}}()); $this->setChild('pager', $pager); $this->get{{Entities}}()->load(); return $this; } /** * get the pager html * * @access public * @return string * {{qwertyuiop}} */ public function getPagerHtml() { return $this->getChildHtml('pager'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/List/060_tree_flat ================================================ ; ${{entities}}->getSelect()->order('{{entityTableAlias}}.position'); $this->set{{Entities}}(${{entities}}); } /** * prepare the layout * * @access protected * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_List * {{qwertyuiop}} */ protected function _prepareLayout() { parent::_prepareLayout(); $this->get{{Entities}}()->addFieldToFilter('level', 1); if ($this->_getDisplayMode() == 0) { $pager = $this->getLayout()->createBlock( 'page/html_pager', '{{namespace}}_{{module}}.{{entities}}.html.pager' ) ->setCollection($this->get{{Entities}}()); $this->setChild('pager', $pager); $this->get{{Entities}}()->load(); } return $this; } /** * get the pager html * * @access public * @return string * {{qwertyuiop}} */ public function getPagerHtml() { return $this->getChildHtml('pager'); } /** * get the display mode * * @access protected * @return int * {{qwertyuiop}} */ protected function _getDisplayMode() { return Mage::getStoreConfigFlag('{{namespace}}_{{module}}/{{entity}}/tree'); } /** * draw {{entityLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} * @param int $level * @return int * {{qwertyuiop}} */ public function draw{{Entity}}(${{entity}}, $level = 0) { $html = ''; $recursion = $this->getRecursion(); if ($recursion !== '0' && $level >= $recursion) { return ''; } $storeIds = Mage::getResourceSingleton( '{{namespace}}_{{module}}/{{entity}}' ) ->lookupStoreIds(${{entity}}->getId()); $validStoreIds = array(0, Mage::app()->getStore()->getId()); if (!array_intersect($storeIds, $validStoreIds)) { return ''; } if (!${{entity}}->getStatus()) { return ''; } $children = ${{entity}}->getChildren{{Entities}}(); $activeChildren = array(); if ($recursion == 0 || $level < $recursion-1) { foreach ($children as $child) { $childStoreIds = Mage::getResourceSingleton( '{{namespace}}_{{module}}/{{entity}}' ) ->lookupStoreIds($child->getId()); $validStoreIds = array(0, Mage::app()->getStore()->getId()); if (!array_intersect($childStoreIds, $validStoreIds)) { continue; } if ($child->getStatus()) { $activeChildren[] = $child; } } } $html .= '
  • '; $html .= {{nameHtml}}; if (count($activeChildren) > 0) { $html .= '
      '; foreach ($children as $child) { $html .= $this->draw{{Entity}}($child, $level+1); } $html .= '
    '; } $html .= '
  • '; return $html; } /** * get recursion * * @access public * @return int * {{qwertyuiop}} */ public function getRecursion() { if (!$this->hasData('recursion')) { $this->setData('recursion', Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/recursion')); } return $this->getData('recursion'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/List/070_tree_eav ================================================ ; ${{entities}}->getSelect()->order('{{entityTableAlias}}.position'); $this->set{{Entities}}(${{entities}}); } /** * prepare the layout * * @access protected * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_List * {{qwertyuiop}} */ protected function _prepareLayout() { parent::_prepareLayout(); $this->get{{Entities}}()->addFieldToFilter('level', 1); if ($this->_getDisplayMode() == 0) { $pager = $this->getLayout()->createBlock( 'page/html_pager', '{{namespace}}_{{module}}.{{entities}}.html.pager' ) ->setCollection($this->get{{Entities}}()); $this->setChild('pager', $pager); $this->get{{Entities}}()->load(); } return $this; } /** * get the pager html * * @access public * @return string * {{qwertyuiop}} */ public function getPagerHtml() { return $this->getChildHtml('pager'); } /** * get the display mode * * @access protected * @return int * {{qwertyuiop}} */ protected function _getDisplayMode() { return Mage::getStoreConfigFlag('{{namespace}}_{{module}}/{{entity}}/tree'); } /** * draw {{entityLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} * @param int $level * @return int * {{qwertyuiop}} */ public function draw{{Entity}}(${{entity}}, $level = 0) { $html = ''; $recursion = $this->getRecursion(); if ($recursion !== '0' && $level >= $recursion) { return ''; } if (!${{entity}}->getStatus()) { return ''; } ${{entity}}->setStoreId(Mage::app()->getStore()->getId()); $children = ${{entity}}->getChildren{{Entities}}()->addAttributeToSelect('*'); $activeChildren = array(); if ($recursion == 0 || $level < $recursion-1) { foreach ($children as $child) { if ($child->getStatus()) { $activeChildren[] = $child; } } } $html .= '
  • '; $html .= {{nameHtml}}; if (count($activeChildren) > 0) { $html .= '
      '; foreach ($children as $child) { $html .= $this->draw{{Entity}}($child, $level+1); } $html .= '
    '; } $html .= '
  • '; return $html; } /** * get recursion * * @access public * @return int * {{qwertyuiop}} */ public function getRecursion() { if (!$this->hasData('recursion')) { $this->setData('recursion', Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/recursion')); } return $this->getData('recursion'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/List/080_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Rss/010_top ================================================ setCacheTags(array(self::CACHE_TAG)); /* * setting cache to save the rss for 10 minutes */ $this->setCacheKey('{{namespace}}_{{module}}_{{entity}}_rss'); $this->setCacheLifetime(600); } /** * toHtml method * * @access protected * @return string * {{qwertyuiop}} */ protected function _toHtml() { $url = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->get{{Entities}}Url(); $title = Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}'); $rssObj = Mage::getModel('rss/rss'); $data = array( 'title' => $title, 'description' => $title, 'link' => $url, 'charset' => 'UTF-8', ); $rssObj->_addHeader($data); $collection = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->getCollection() ->addFieldToFilter('status', 1) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Rss/020_stores ================================================ ->addStoreFilter(Mage::app()->getStore()) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Rss/025_eav ================================================ ->addAttributeToSelect('*') ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Rss/030_content ================================================ ->{{filterMethod}}('in_rss', 1) ->setOrder('created_at'); $collection->load(); foreach ($collection as $item) { $description = '

    '; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Rss/035_tree ================================================ if (!$item->getStatusPath()) { continue; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Rss/040_attributes ================================================ {{attributeRssText}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Rss/050_footer ================================================ $description .= '

    '; $data = array( 'title' => $item->get{{EntityNameMagicCode}}(), 'link' => $item->get{{Entity}}Url(), 'description' => $description ); $rssObj->_addEntry($data); } return $rssObj->createRssXml(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Sibling/List/010_content ================================================ get{{Entity}}(); if (${{entity}}) { $this->get{{Siblings}}()->add{{Entity}}Filter(${{entity}}->getId()); $this->get{{Siblings}}()->unshiftOrder('related_{{entity}}.position', 'ASC'); } } /** * prepare the layout * * @access protected * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_{{Sibling}}_List * {{qwertyuiop}} */ protected function _prepareLayout() { return $this; } /** * get the current {{entity}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function get{{Entity}}() { return Mage::registry('current_{{entity}}'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/View/010_content ================================================ get{{Entities}}()->addFieldToFilter('entity_id', $this->get{{Entity}}Id()); return $this; } /** * get the display mode * * @access protected * @return int * {{qwertyuiop}} */ protected function _getDisplayMode() { return 1; } /** * get the element id * * @access protected * @return int * {{qwertyuiop}} */ public function getUniqueId() { if (!$this->getData('uniq_id')) { $this->setData('uniq_id', uniqid('subtree')); } return $this->getData('uniq_id'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Widget/View/010_content ================================================ getData('{{entity}}_id'); if (${{entity}}Id) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}') ->setStoreId(Mage::app()->getStore()->getId()) ->load(${{entity}}Id); if (${{entity}}->getStatus()) { $this->setCurrent{{Entity}}(${{entity}}); $this->setTemplate($this->_htmlTemplate); } } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Widget/View/030_tree ================================================ /** * Prepare a for widget * * @access protected * @return {{Namespace}}_{{Module}}_Block_{{Entity}}_Widget_View * {{qwertyuiop}} */ protected function _beforeToHtml() { parent::_beforeToHtml(); ${{entity}}Id = $this->getData('{{entity}}_id'); if (${{entity}}Id) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}') ->setStoreId(Mage::app()->getStore()->getId()) ->load(${{entity}}Id); if (${{entity}}->getStatusPath()) { $this->setCurrent{{Entity}}(${{entity}}); $this->setTemplate($this->_htmlTemplate); } } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Entity/Widget/View/040_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Rss/010_content ================================================ getUrl($url) : $url); $feed = new Varien_Object(); $feed->setLabel($label); $feed->setUrl($link); $this->_feeds[$link] = $feed; return $this; } /** * get the current feeds * * @access public * @return array() * {{qwertyuiop}} */ public function getFeeds() { return $this->_feeds; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Adminhtml/Module/010_content ================================================ setAllowRenameFiles(true); $uploader->setFilesDispersion(true); $uploader->setAllowCreateFolders(true); $result = $uploader->save($destinationFolder); return $result['file']; } } catch (Exception $e) { if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) { throw $e; } else { if (isset($data[$input]['value'])) { return $data[$input]['value']; } } } return ''; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Router/010_top ================================================ getEvent()->getFront(); $front->addRouter('{{namespace}}_{{module}}', $this); return $this; } /** * Validate and match entities and modify request * * @access public * @param Zend_Controller_Request_Http $request * @return bool * {{qwertyuiop}} */ public function match(Zend_Controller_Request_Http $request) { if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse() ->setRedirect(Mage::getUrl('install')) ->sendResponse(); exit; } $urlKey = trim($request->getPathInfo(), '/'); $check = array(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Router/020_entity ================================================ $check['{{entity}}'] = new Varien_Object( array( 'prefix' => Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/url_prefix'), 'suffix' => Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/url_suffix'), 'list_key' => Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/url_rewrite_list'), 'list_action' => 'index', 'model' =>'{{namespace}}_{{module}}/{{entity}}', 'controller' => '{{entity}}', 'action' => 'view', 'param' => 'id', 'check_path' => {{isTree}} ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Router/030_footer ================================================ foreach ($check as $key=>$settings) { if ($settings->getListKey()) { if ($urlKey == $settings->getListKey()) { $request->setModuleName('{{frontKey}}') ->setControllerName($settings->getController()) ->setActionName($settings->getListAction()); $request->setAlias( Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $urlKey ); return true; } } if ($settings['prefix']) { $parts = explode('/', $urlKey); if ($parts[0] != $settings['prefix'] || count($parts) != 2) { continue; } $urlKey = $parts[1]; } if ($settings['suffix']) { $urlKey = substr($urlKey, 0, -strlen($settings['suffix']) - 1); } $model = Mage::getModel($settings->getModel()); $id = $model->checkUrlKey($urlKey, Mage::app()->getStore()->getId()); if ($id) { if ($settings->getCheckPath() && !$model->load($id)->getStatusPath()) { continue; } $request->setModuleName('{{frontKey}}') ->setControllerName($settings->getController()) ->setActionName($settings->getAction()) ->setParam($settings->getParam(), $id); $request->setAlias( Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $urlKey ); return true; } } return false; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Category/010_top ================================================ hasSelected{{Entities}}()) { ${{entities}} = array(); foreach ($this->getSelected{{Entities}}Collection($category) as ${{entity}}) { ${{entities}}[] = ${{entity}}; } $category->setSelected{{Entities}}(${{entities}}); } return $category->getData('selected_{{entities}}'); } /** * get {{entityLabel}} collection for a category * * @access public * @param Mage_Catalog_Model_Category $category * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function getSelected{{Entities}}Collection(Mage_Catalog_Model_Category $category) { $collection = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_collection') ->addCategoryFilter($category); return $collection; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Category/030_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Data/010_content ================================================ $listKey)); } return Mage::getUrl('{{namespace}}_{{module}}/{{entity}}/index'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Entity/030_breadcrumbs ================================================ /** * check if breadcrumbs can be used * * @access public * @return bool * {{qwertyuiop}} */ public function getUseBreadcrumbs() { return Mage::getStoreConfigFlag('{{namespace}}_{{module}}/{{entity}}/breadcrumbs'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Entity/040_tree ================================================ const {{ENTITY}}_ROOT_ID = 1; /** * get the root id * * @access public * @return int * {{qwertyuiop}} */ public function getRoot{{Entity}}Id() { return self::{{ENTITY}}_ROOT_ID; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Entity/050_rss ================================================ /** * check if the rss for {{entityLabel}} is enabled * * @access public * @return bool * {{qwertyuiop}} */ public function isRssEnabled() { return Mage::getStoreConfigFlag('rss/config/active') && Mage::getStoreConfigFlag('{{namespace}}_{{module}}/{{entity}}/rss'); } /** * get the link to the {{entityLabel}} rss list * * @access public * @return string * {{qwertyuiop}} */ public function getRssUrl() { return Mage::getUrl('{{namespace}}_{{module}}/{{entity}}/rss'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Entity/060_file ================================================ /** * get base files dir * * @access public * @return string * {{qwertyuiop}} */ public function getFileBaseDir() { return Mage::getBaseDir('media').DS.'{{entity}}'.DS.'file'; } /** * get base file url * * @access public * @return string * {{qwertyuiop}} */ public function getFileBaseUrl() { return Mage::getBaseUrl('media').'{{entity}}'.'/'.'file'; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Entity/070_eav ================================================ /** * get {{entity}} attribute source model * * @access public * @param string $inputType * @return mixed (string|null) * {{qwertyuiop}} */ public function getAttributeSourceModelByInputType($inputType) { $inputTypes = $this->getAttributeInputTypes(); if (!empty($inputTypes[$inputType]['source_model'])) { return $inputTypes[$inputType]['source_model']; } return null; } /** * get attribute input types * * @access public * @param string $inputType * @return array() * {{qwertyuiop}} */ public function getAttributeInputTypes($inputType = null) { $inputTypes = array( 'multiselect' => array( 'backend_model' => 'eav/entity_attribute_backend_array', 'source_model' => 'eav/entity_attribute_source_table' ), 'boolean' => array( 'source_model' => 'eav/entity_attribute_source_boolean' ), 'file' => array( 'backend_model' => '{{namespace}}_{{module}}/{{entity}}_attribute_backend_file' ), 'image' => array( 'backend_model' => '{{namespace}}_{{module}}/{{entity}}_attribute_backend_image' ), ); if (is_null($inputType)) { return $inputTypes; } else if (isset($inputTypes[$inputType])) { return $inputTypes[$inputType]; } return array(); } /** * get {{entity}} attribute backend model * * @access public * @param string $inputType * @return mixed (string|null) * {{qwertyuiop}} */ public function getAttributeBackendModelByInputType($inputType) { $inputTypes = $this->getAttributeInputTypes(); if (!empty($inputTypes[$inputType]['backend_model'])) { return $inputTypes[$inputType]['backend_model']; } return null; } /** * filter attribute content * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param string $attributeHtml * @param string @attributeName * @return string * {{qwertyuiop}} */ public function {{entity}}Attribute(${{entity}}, $attributeHtml, $attributeName) { $attribute = Mage::getSingleton('eav/config')->getAttribute( {{Namespace}}_{{Module}}_Model_{{Entity}}::ENTITY, $attributeName ); if ($attribute && $attribute->getId() && !$attribute->getIsWysiwygEnabled()) { if ($attribute->getFrontendInput() == 'textarea') { $attributeHtml = nl2br($attributeHtml); } } if ($attribute->getIsWysiwygEnabled()) { $attributeHtml = $this->_getTemplateProcessor()->filter($attributeHtml); } return $attributeHtml; } /** * get the template processor * * @access protected * @return Mage_Catalog_Model_Template_Filter * {{qwertyuiop}} */ protected function _getTemplateProcessor() { if (null === $this->_templateProcessor) { $this->_templateProcessor = Mage::helper('catalog')->getPageTemplateProcessor(); } return $this->_templateProcessor; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Entity/080_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Entity/Image/010_content ================================================ array(0.5,0.5), 'top' => array(1,0), 'bottom' => array(0,1) ); /** * resized image folder name * @var string */ protected $_resizeFolderName = 'cache'; /** * get the image base dir * * @access public * @return string * {{qwertyuiop}} */ public function getImageBaseDir() { return Mage::getBaseDir('media').DS.$this->_subdir.DS.'image'; } /** * get the image url for object * * @access public * @return string * {{qwertyuiop}} */ public function getImageBaseUrl() { return Mage::getBaseUrl('media').$this->_subdir.'/'.'image'; } /** * init image * * @access public * @param Varien_Object $object * @param string $imageField * @return {{Namespace}}_{{Module}}_Helper_Image_Abstract * {{qwertyuiop}} */ public function init(Varien_Object $object, $imageField = 'image') { $this->_imageProcessor = null; $this->_image = $object->getDataUsingMethod($imageField); if (!$this->_image) { $this->_image = '/'.$this->_placeholder; } $this->_width = null; $this->_height = null; $this->_scheduledResize = false; $this->_resized = false; $this->_adaptiveResize = 'center'; try { $this->_getImageProcessor()->open($this->getImageBaseDir().$this->_image); } catch (Exception $e) { $this->_openError = $e->getMessage(); try { $this->_getImageProcessor()->open(Mage::getDesign()->getSkinUrl($this->_placeholder)); $this->_image = '/'.$this->_placeholder; } catch(Exception $e) { $this->_openError .= "\n".$e->getMessage(); $this->_image = null; } } return $this; } /** * get the image processor * * @access protected * @return Varien_Image_Adapter_Gd2 * {{qwertyuiop}} */ protected function _getImageProcessor() { if (is_null($this->_imageProcessor)) { $this->_imageProcessor = Varien_Image_Adapter::factory('GD2'); $this->_imageProcessor->keepFrame($this->_keepFrame); $this->_imageProcessor->keepAspectRatio($this->_keepAspectRatio); $this->_imageProcessor->constrainOnly($this->_constrainOnly); } return $this->_imageProcessor; } /** * Get/set keepAspectRatio * * @access public * @param bool $value * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract) * {{qwertyuiop}} */ public function keepAspectRatio($value = null) { if (null !== $value) { $this->_getImageProcessor()->keepAspectRatio($value); return $this; } else { return $this->_getImageProcessor()->keepAspectRatio(); } } /** * Get/set keepFrame * * @access public * @param bool $value * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract) * {{qwertyuiop}} */ public function keepFrame($value = null) { if (null !== $value) { $this->_getImageProcessor()->keepFrame($value); return $this; } else { return $this->_getImageProcessor()->keepFrame(); } } /** * Get/set keepTransparency * * @access public * @param bool $value * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract) * {{qwertyuiop}} */ public function keepTransparency($value = null) { if (null !== $value) { $this->_getImageProcessor()->keepTransparency($value); return $this; } else { return $this->_getImageProcessor()->keepTransparency(); } } /** * Get/set adaptiveResize * * @access public * @param bool|string $value * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract) * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md * {{qwertyuiop}} */ public function adaptiveResize($value = null) { if (null !== $value) { $this->_adaptiveResize = $value; if ($value) { $this->keepFrame(false); } return $this; } else { return $this->_adaptiveResize; } } /** * Get/set constrainOnly * * @access public * @param bool $value * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract) * {{qwertyuiop}} */ public function constrainOnly($value = null) { if (null !== $value) { $this->_getImageProcessor()->constrainOnly($value); return $this; } else { return $this->_getImageProcessor()->constrainOnly(); } } /** * Get/set quality, values in percentage from 0 to 100 * * @access public * @param int $value * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract) * {{qwertyuiop}} */ public function quality($value = null) { if (null !== $value) { $this->_getImageProcessor()->quality($value); return $this; } else { return $this->_getImageProcessor()->quality(); } } /** * Get/set keepBackgroundColor * * @access public * @param array $value * @return mixed(bool|{{Namespace}}_{{Module}}_Helper_Image_Abstract) * {{qwertyuiop}} */ public function backgroundColor($value = null) { if (null !== $value) { $this->_getImageProcessor()-> backgroundColor($value); return $this; } else { return $this->_getImageProcessor()-> backgroundColor(); } } /** * resize image * * @access public * @param int $width - defaults to null * @param int $height - defaults to null * @return {{Namespace}}_{{Module}}_Helper_Image_Abstract * {{qwertyuiop}} */ public function resize($width = null, $height = null) { $this->_scheduledResize = true; $this->_width = $width; $this->_height = $height; return $this; } /** * get destination image prefix * * @access protected * @return {{Namespace}}_{{Module}}_Helper_Image_Abstract * {{qwertyuiop}} */ protected function _getDestinationImagePrefix() { if (!$this->_image) { return $this; } $imageRealPath = ""; if ($this->_scheduledResize) { $width = $this->_width; $height = $this->_height; $adaptive = $this->adaptiveResize(); $keepFrame = $this->keepFrame(); $keepAspectRatio= $this->keepAspectRatio(); $constrainOnly = $this->constrainOnly(); $imageRealPath = $width.'x'.$height; $options = ""; if (!$keepAspectRatio) { $imageRealPath .= '-exact'; } else { if (!$keepFrame && $width && $height && ($adaptive !== false)) { $adaptive = strtolower(trim($adaptive)); if (isset($this->_adaptiveResizePositions[$adaptive])) { $imageRealPath .= '-'.$adaptive; } } } if ($keepFrame) { $imageRealPath .= '-frame'; $_backgroundColor = $this->backgroundColor(); if ($_backgroundColor) { $imageRealPath .= '-'.implode('-', $_backgroundColor); } } if (!$constrainOnly) { $imageRealPath .= '-zoom'; } } return $imageRealPath; } /** * get image destination path * * @access protected * @return string * {{qwertyuiop}} */ protected function _getDestinationPath() { if (!$this->_image) { return $this; } if ($this->_scheduledResize) { return $this->getImageBaseDir().DS.$this->_resizeFolderName.DS.$this->_getDestinationImagePrefix().DS.$this->_image; } else { return $this->getImageBaseDir().DS.$this->_image; } } /** * get image url * * @access protected * @return mixed (string|bool) * {{qwertyuiop}} */ protected function _getImageUrl() { if (!$this->_image) { return false; } if ($this->_scheduledResize) { return $this->getImageBaseUrl().'/'.$this->_resizeFolderName.'/'.$this->_getDestinationImagePrefix().$this->_image; } else { return $this->getImageBaseUrl().$this->_image; } } /** * resize image * * @access protected * @return {{Namespace}}_{{Module}}_Helper_Image_Abstract * {{qwertyuiop}} */ protected function _doResize() { if (!$this->_image || !$this->_scheduledResize || $this->_resized) { return $this; } $this->_resized = true; //mark as resized $width = $this->_width; $height = $this->_height; $adaptive = $width && $height && $this->keepAspectRatio() && !$this->keepFrame() && ($this->adaptiveResize() !== false); $adaptivePosition = false; if ($adaptive) { $adaptive = strtolower(trim($this->adaptiveResize())); if (isset($this->_adaptiveResizePositions[$adaptive])) { $adaptivePosition = $this->_adaptiveResizePositions[$adaptive]; } } $processor = $this->_getImageProcessor(); if (!$adaptivePosition) { $processor->resize($width, $height); return $this; } //make adaptive resize //https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md $currentRatio = $processor->getOriginalWidth() / $processor->getOriginalHeight(); $targetRatio = $width / $height; if ($targetRatio > $currentRatio) { $processor->resize($width, null); } else { $processor->resize(null, $height); } $diffWidth = $processor->getOriginalWidth() - $width; $diffHeight = $processor->getOriginalHeight() - $height; if ($diffWidth || $diffHeight) { $processor->crop( floor($diffHeight * $adaptivePosition[0]), //top rate floor($diffWidth / 2), ceil($diffWidth / 2), ceil($diffHeight * $adaptivePosition[1]) //bottom rate ); } return $this; } /** * to string - no need for cache expire because the image names will be different * * @access public * @return string * {{qwertyuiop}} */ public function __toString() { try { if (!$this->_image) { throw new Exception($this->_openError); } $imageRealPath = $this->_getDestinationPath(); if (!file_exists($imageRealPath)) { $this->_doResize(); $this->_getImageProcessor()->save($imageRealPath); } return $this->_getImageUrl(); } catch (Exception $e) { Mage::logException($e); return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAnFBMVEUAAAAAAAAAAAAAAAC0tLS4uLi0tLT6+vrx8fHo6Ojj4OC+mpq7UE2wXlqzOTGtHwza2dnGaWeiJxDV0dGNJhari4uqeHi/W1edTkevSkWWNCOLEQiXEgbExMXbiorTgH+NT0a4RD+XIxTPFwm7BQHYAwHJAwDLd3aWcXDKV03JODOjNyunLCS6JQ6nCQO/q6viqKjFREOYQTrQIiHNANNfAAAAB3RSTlMCPiYZ3uvFTohbPwAAAURJREFUOMuVk9dygzAQRW3jeGUhikQvDtUl7uX//y0b4bGMCDPJAV64Z+5Ko9HkLxizEYynMCW/A9OXsETI8xkRSPeNNpDnOyZo5dChCe8pAUJ04Qd65bzYXilIaSiYrPhEisoEiS5YvOCVbdt8G1kDATGjbWV5QC7HiDNzKFCb2/J3wqKIVcuBEDImi60vxo5JEvYEQCFmB0/mt5sdHhNLF+CQHGS+3+Ok2k8HQprVAPf944E51JkuAMRZdrk7m7WDuZfncV9Awiz3uxzlcx5qAgHq5067kXkgzj7VBCSoz63YYX/stCKAQQNAKdrmJITTbERJJErojMA/Net1c/IDPBxK6cJ424WE7so0LXcuoauV585nk5fQh5AVgDvvBqgGBRaA+yFztcheAfWoytUIJbhd/3iDykcWuZhpl3eqYUz+wTdj6SFVkjRnJQAAAABJRU5ErkJggg=='; } } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Product/010_top ================================================ hasSelected{{Entities}}()) { ${{entities}} = array(); foreach ($this->getSelected{{Entities}}Collection($product) as ${{entity}}) { ${{entities}}[] = ${{entity}}; } $product->setSelected{{Entities}}(${{entities}}); } return $product->getData('selected_{{entities}}'); } /** * get {{entityLabel}} collection for a product * * @access public * @param Mage_Catalog_Model_Product $product * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function getSelected{{Entities}}Collection(Mage_Catalog_Model_Product $product) { $collection = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_collection') ->addProductFilter($product); return $collection; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Product/030_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Observer/010_top ================================================ getId()) { return true; } if (!$product->getAttributeSetId()) { return false; } $request = Mage::app()->getRequest(); if ($request->getParam('type') == 'configurable') { if ($request->getParam('attributes')) { return true; } } return false; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Observer/020_entity_product ================================================ /** * add the {{entityLabel}} tab to products * * @access public * @param Varien_Event_Observer $observer * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer * {{qwertyuiop}} */ public function addProduct{{Entity}}Block($observer) { $block = $observer->getEvent()->getBlock(); $product = Mage::registry('product'); if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs && $this->_canAddTab($product)) { $block->addTab( '{{entities}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}'), 'url' => Mage::helper('adminhtml')->getUrl( 'adminhtml/{{module}}_{{entity}}_catalog_product/{{entities}}', array('_current' => true) ), 'class' => 'ajax', ) ); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Observer/030_entity_product_save ================================================ /** * save {{entityLabel}} - product relation * @access public * @param Varien_Event_Observer $observer * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer * {{qwertyuiop}} */ public function saveProduct{{Entity}}Data($observer) { $post = Mage::app()->getRequest()->getPost('{{entities}}', -1); if ($post != '-1') { $post = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post); $product = Mage::registry('product'); ${{entity}}Product = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_product') ->saveProductRelation($product, $post); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Observer/040_entity_product_save_tree ================================================ /** * save {{entity}} - product relation * * @access public * @param Varien_Event_Observer $observer * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer * {{qwertyuiop}} */ public function saveProduct{{Entity}}Data($observer) { $post = Mage::app()->getRequest()->getPost('{{entity}}_ids', -1); if ($post != '-1') { $post = explode(',', $post); $post = array_unique($post); $product = $observer->getEvent()->getProduct(); Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_product') ->saveProductRelation($product, $post); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Observer/050_entity_category ================================================ /** * add the {{entity}} tab to categories * * @access public * @param Varien_Event_Observer $observer * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer * {{qwertyuiop}} */ public function addCategory{{Entity}}Block($observer) { $tabs = $observer->getEvent()->getTabs(); $content = $tabs->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_catalog_category_tab_{{entity}}', 'category.{{entity}}.grid' )->toHtml(); $serializer = $tabs->getLayout()->createBlock( 'adminhtml/widget_grid_serializer', 'category.{{entity}}.grid.serializer' ); $serializer->initSerializerBlock( 'category.{{entity}}.grid', 'getSelected{{Entities}}', '{{entities}}', 'category_{{entities}}' ); $serializer->addColumnInputName('position'); $content .= $serializer->toHtml(); $tabs->addTab( '{{entity}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}'), 'content' => $content, ) ); return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Observer/055_entity_category_tree ================================================ /** * add the {{entityLabel}} tab to categories * * @access public * @param Varien_Event_Observer $observer * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer * {{qwertyuiop}} */ public function addCategory{{Entity}}Block($observer) { $tabs = $observer->getEvent()->getTabs(); $content = $tabs->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_catalog_category_tab_{{entity}}', 'category.{{entity}}.grid' )->toHtml(); $tabs->addTab( '{{entity}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}'), 'content' => $content, ) ); return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Observer/060_entity_category_save ================================================ /** * save {{entityLabel}} - category relation * * @access public * @param Varien_Event_Observer $observer * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer * {{qwertyuiop}} */ public function saveCategory{{Entity}}Data($observer) { $post = Mage::app()->getRequest()->getPost('{{entities}}', -1); if ($post != '-1') { $post = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post); $category = Mage::registry('category'); ${{entity}}Category = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_category') ->saveCategoryRelation($category, $post); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Observer/070_entity_category_save_tree ================================================ /** * save {{entityLabel}} - category relation * * @access public * @param Varien_Event_Observer $observer * @return {{Namespace}}_{{Module}}_Model_Adminhtml_Observer * {{qwertyuiop}} */ public function saveCategory{{Entity}}Data($observer) { $post = Mage::app()->getRequest()->getPost('{{entity}}_ids', -1); if ($post != '-1') { $post = explode(',', $post); $post = array_unique($post); $category = $observer->getEvent()->getCategory(); Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_category') ->saveCategoryRelation($category, $post); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Observer/080_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Search/Entity/010_content ================================================ hasStart() || !$this->hasLimit() || !$this->hasQuery()) { $this->setResults($arr); return $this; } $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_collection') ->{{filterMethod}}('{{nameAttributeCode}}', array('like' => $this->getQuery().'%')) ->setCurPage($this->getStart()) ->setPageSize($this->getLimit()) ->load(); foreach ($collection->getItems() as ${{entity}}) { $arr[] = array( 'id' => '{{entity}}/1/'.${{entity}}->getId(), 'type' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}'), 'name' => ${{entity}}->get{{EntityNameMagicCode}}(), 'description' => ${{entity}}->get{{EntityNameMagicCode}}(), 'url' => Mage::helper('adminhtml')->getUrl( '*/{{module}}_{{entity}}/edit', array('id'=>${{entity}}->getId()) ), ); } $this->setResults($arr); return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Adminhtml/Source/Yesnodefault/010_content ================================================ Mage::helper('{{namespace}}_{{module}}')->__('Use default config'), 'value' => self::USE_DEFAULT ), array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Yes'), 'value' => self::YES ), array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('No'), 'value' => self::NO ) ); } /** * Get list of all available values * * @access public * @return array * {{qwertyuiop}} */ public function getAllOptions() { return $this->toOptionArray(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/010_top ================================================ getAvailableAttributesFromConfig(); $entityType = Mage::getModel('eav/entity_type')->loadByCode('{{namespace}}_{{module}}_{{entity}}'); $entityOnlyAttrs = $this->getEntityOnlyAttributes($userType, $operation); foreach ($entityType->getAttributeCollection() as $attribute) { if ($attribute->getIsVisible()) { $attributes[$attribute->getAttributeCode()] = $attribute->getFrontendLabel(); } } $excludedAttrs = $this->getExcludedAttributes($userType, $operation); $includedAttrs = $this->getIncludedAttributes($userType, $operation); foreach ($attributes as $code => $label) { if (in_array($code, $excludedAttrs) || ($includedAttrs && !in_array($code, $includedAttrs))) { unset($attributes[$code]); } if (in_array($code, $entityOnlyAttrs)) { $attributes[$code] .= ' *'; } } return $attributes; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/030_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/010_top ================================================ _get{{Entity}}(); $this->_prepare{{Entity}}ForResponse(${{entity}}); return ${{entity}}->getData(); } /** * get collection * * @access protected * @return array * {{qwertyuiop}} */ protected function _retrieveCollection() { $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_collection'){{allAttributesToCollection}};{{restCollectionStoreId}} $entityOnlyAttributes = $this->getEntityOnlyAttributes( $this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ ); $availableAttributes = array_keys($this->getAvailableAttributes( $this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ) ); $collection->{{filterMethod}}('status', array('eq' => 1)); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/015_tree_filter ================================================ $collection->{{filterMethod}}('entity_id', array('neq'=>Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id())); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/020_store_collection ================================================ $store = $this->_getStore(); $collection->addStoreFilter($store->getId()); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/030_collection_center ================================================ $this->_applyCollectionModifiers($collection); ${{entities}} = $collection->load(); ${{entities}}->walk('afterLoad'); foreach (${{entities}} as ${{entity}}) { $this->_set{{Entity}}(${{entity}}); $this->_prepare{{Entity}}ForResponse(${{entity}}); } ${{entities}}Array = ${{entities}}->toArray();{{restCollectionCleanup}} return ${{entities}}Array; } /** * prepare {{entityLabel}} for response * * @access protected * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * {{qwertyuiop}} */ protected function _prepare{{Entity}}ForResponse({{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}) { ${{entity}}Data = ${{entity}}->getData(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/040_url ================================================ if ($this->getActionType() == self::ACTION_TYPE_ENTITY) { ${{entity}}Data['url'] = ${{entity}}->get{{Entity}}Url(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/050_center ================================================ } /** * create {{entityLabel}} * * @access protected * @param array $data * @return string|void * {{qwertyuiop}} */ protected function _create(array $data) { $this->_critical(self::RESOURCE_METHOD_NOT_ALLOWED); } /** * update {{entityLabel}} * * @access protected * @param array $data * {{qwertyuiop}} */ protected function _update(array $data) { $this->_critical(self::RESOURCE_METHOD_NOT_ALLOWED); } /** * delete {{entityLabel}} * * @access protected * {{qwertyuiop}} */ protected function _delete() { $this->_critical(self::RESOURCE_METHOD_NOT_ALLOWED); } /** * delete current {{entityLabel}} * * @access protected * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * {{qwertyuiop}} */ protected function _set{{Entity}}({{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}) { $this->_{{entity}} = ${{entity}}; } /** * get current {{entityLabel}} * * @access protected * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ protected function _get{{Entity}}() { if (is_null($this->_{{entity}})) { ${{entity}}Id = $this->getRequest()->getParam('id'); ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/060_eav ================================================ $storeId = $this->_getStore()->getId(); ${{entity}}->setStoreId($storeId); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/070_load ================================================ ${{entity}}->load(${{entity}}Id); if (!(${{entity}}->getId())) { $this->_critical(self::RESOURCE_NOT_FOUND); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/080_store ================================================ if ($this->_getStore()->getId()) { $isValidStore = count(array_intersect(array(0, $this->_getStore()->getId()), ${{entity}}->getStoreId())); if (!$isValidStore) { $this->_critical(self::RESOURCE_NOT_FOUND); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/090_footer ================================================ $this->_{{entity}} = ${{entity}}; } return $this->_{{entity}}; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/Admin/V1/010_top ================================================ {{filterMethod}}('entity_id', array('neq'=>Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id())); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/Admin/V1/030_footer ================================================ $entityOnlyAttributes = $this->getEntityOnlyAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ); $availableAttributes = array_keys($this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)); $this->_applyCollectionModifiers($collection); ${{entities}} = $collection->load(); foreach (${{entities}} as ${{entity}}) { $this->_set{{Entity}}(${{entity}}); $this->_prepare{{Entity}}ForResponse(${{entity}}); } ${{entities}}Array = ${{entities}}->toArray();{{restCollectionCleanup}} return ${{entities}}Array; } /** * Delete {{entityLabel}} by its ID * * @access protected * @throws Mage_Api2_Exception * {{qwertyuiop}} */ protected function _delete() { ${{entity}} = $this->_get{{Entity}}(); try { ${{entity}}->delete(); } catch (Mage_Core_Exception $e) { $this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR); } catch (Exception $e) { $this->_critical(self::RESOURCE_INTERNAL_ERROR); } } /** * Create {{entityLabel}} * * @access protected * @param array $data * @return string * {{qwertyuiop}} */ protected function _create(array $data) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->setData($data); try { ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR); } catch (Exception $e) { $this->_critical(self::RESOURCE_UNKNOWN_ERROR); } return $this->_getLocation(${{entity}}->getId()); } /** * Update {{entityLabel}} by its ID * * @access protected * @param array $data * {{qwertyuiop}} */ protected function _update(array $data) { ${{entity}} = $this->_get{{Entity}}(); ${{entity}}->addData($data); try { ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR); } catch (Exception $e) { $this->_critical(self::RESOURCE_UNKNOWN_ERROR); } } /** * Set additional data before {{entityLabel}} save * * @access protected * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $entity * @param array ${{entity}}Data * {{qwertyuiop}} */ protected function _prepareDataForSave($product, $productData) { //add your data processing algorithm here if needed } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/Customer/V1/010_content ================================================ _customer)) { $customer = Mage::getModel('customer/customer')->load($this->getApiUser()->getUserId()); if (!$customer->getId()) { $this->_critical('Customer not found.', Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR); } $this->_customer = $customer; } return $this->_customer; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Api2/Entity/Rest/Guest/V1/010_content ================================================ _init('{{namespace}}_{{module}}/attribute'); } /** * Processing object before save data * * @access protected * @throws Mage_Core_Exception * @return Mage_Core_Model_Abstract * {{qwertyuiop}} */ protected function _beforeSave() { $this->setData('modulePrefix', self::MODULE_NAME); if (isset($this->_origData['is_global'])) { if (!isset($this->_data['is_global'])) { $this->_data['is_global'] = self::SCOPE_GLOBAL; } } if ($this->getFrontendInput() == 'textarea') { if ($this->getIsWysiwygEnabled()) { $this->setIsHtmlAllowedOnFront(1); } } return parent::_beforeSave(); } /** * Processing object after save data * * @access protected * @return Mage_Core_Model_Abstract * {{qwertyuiop}} */ protected function _afterSave() { /** * Fix saving attribute in admin */ Mage::getSingleton('eav/config')->clear(); return parent::_afterSave(); } /** * Return is attribute global * * @access public * @return integer * {{qwertyuiop}} */ public function getIsGlobal() { return $this->_getData('is_global'); } /** * Retrieve attribute is global scope flag * * @access public * @return bool * {{qwertyuiop}} */ public function isScopeGlobal() { return $this->getIsGlobal() == self::SCOPE_GLOBAL; } /** * Retrieve attribute is website scope website * * @access public * @return bool * {{qwertyuiop}} */ public function isScopeWebsite() { return $this->getIsGlobal() == self::SCOPE_WEBSITE; } /** * Retrieve attribute is store scope flag * * @access public * @return bool * {{qwertyuiop}} */ public function isScopeStore() { return !$this->isScopeGlobal() && !$this->isScopeWebsite(); } /** * Retrieve store id * * @access public * @return int * {{qwertyuiop}} */ public function getStoreId() { $dataObject = $this->getDataObject(); if ($dataObject) { return $dataObject->getStoreId(); } return $this->getData('store_id'); } /** * Retrieve source model * * @access public * @return Mage_Eav_Model_Entity_Attribute_Source_Abstract * {{qwertyuiop}} */ public function getSourceModel() { $model = $this->getData('source_model'); if (empty($model)) { if ($this->getBackendType() == 'int' && $this->getFrontendInput() == 'select') { return $this->_getDefaultSourceModel(); } } return $model; } /** * Retrieve not translated frontend label * * @access public * @return string * {{qwertyuiop}} */ public function getFrontendLabel() { return $this->_getData('frontend_label'); } /** * Get Attribute translated label for store * * @access protected * @deprecated * @return string * {{qwertyuiop}} */ protected function _getLabelForStore() { return $this->getFrontendLabel(); } /** * Initialize store Labels for attributes * * @access public * @param mixed $storeId * @deprecated * @return void * {{qwertyuiop}} */ public static function initLabels($storeId = null) { if (is_null(self::$_labels)) { if (is_null($storeId)) { $storeId = Mage::app()->getStore()->getId(); } $attributeLabels = array(); $attributes = Mage::getResourceSingleton('catalog/product')->getAttributesByCode(); foreach ($attributes as $attribute) { if (strlen($attribute->getData('frontend_label')) > 0) { $attributeLabels[] = $attribute->getData('frontend_label'); } } self::$_labels = Mage::app()->getTranslator() ->getResource() ->getTranslationArrayByStrings($attributeLabels, $storeId); } } /** * Get default attribute source model * * @access public * @return string * {{qwertyuiop}} */ public function _getDefaultSourceModel() { return 'eav/entity_attribute_source_table'; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Attribute/Source/Country/010_content ================================================ getStore()->getCode(); if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) { $options = unserialize($cache); } else { $collection = Mage::getModel('directory/country')->getResourceCollection(); $options = $collection->toOptionArray(); if (Mage::app()->useCache('config')) { Mage::app()->saveCache(serialize($options), $cacheKey, array('config')); } } return $options; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/010_top ================================================ _init('{{namespace}}_{{module}}/{{entity}}'); } /** * before save {{entityLabel}} * * @access protected * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ protected function _beforeSave() { parent::_beforeSave(); $now = Mage::getSingleton('core/date')->gmtDate(); if ($this->isObjectNew()) { $this->setCreatedAt($now); } $this->setUpdatedAt($now); return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/060_url ================================================ /** * get the url to the {{entityLabel}} details page * * @access public * @return string * {{qwertyuiop}} */ public function get{{Entity}}Url() { return Mage::getUrl('{{namespace}}_{{module}}/{{entity}}/view', array('id'=>$this->getId())); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/070_url_rewrite ================================================ /** * get the url to the {{entityLabel}} details page * * @access public * @return string * {{qwertyuiop}} */ public function get{{Entity}}Url() { if ($this->getUrlKey()) { $urlKey = ''; if ($prefix = Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/url_prefix')) { $urlKey .= $prefix.'/'; } $urlKey .= $this->getUrlKey(); if ($suffix = Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/url_suffix')) { $urlKey .= '.'.$suffix; } return Mage::getUrl('', array('_direct'=>$urlKey)); } return Mage::getUrl('{{namespace}}_{{module}}/{{entity}}/view', array('id'=>$this->getId())); } /** * check URL key * * @access public * @param string $urlKey * @param bool $active * @return mixed * {{qwertyuiop}} */ public function checkUrlKey($urlKey, $active = true) { return $this->_getResource()->checkUrlKey($urlKey, $active); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/080_editors ================================================ /** * get the {{entityLabel}} {{attributeLabel}} * * @access public * @return string * {{qwertyuiop}} */ public function get{{AttributeMagicCode}}() { ${{attributeCode}} = $this->getData('{{attributeCode}}'); $helper = Mage::helper('cms'); $processor = $helper->getBlockTemplateProcessor(); $html = $processor->filter(${{attributeCode}}); return $html; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/090_after_save_top ================================================ /** * save {{entityLabel}} relation * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ protected function _afterSave() { ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/100_after_save_product ================================================ $this->getProductInstance()->save{{Entity}}Relation($this); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/110_after_save_category ================================================ $this->getCategoryInstance()->save{{Entity}}Relation($this); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/120_after_save_sibling ================================================ $this->get{{Sibling}}Instance()->save{{Entity}}Relation($this); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/130_after_save_footer ================================================ return parent::_afterSave(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/140_product_relation ================================================ /** * get product relation model * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_Product * {{qwertyuiop}} */ public function getProductInstance() { if (!$this->_productInstance) { $this->_productInstance = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}_product'); } return $this->_productInstance; } /** * get selected products array * * @access public * @return array * {{qwertyuiop}} */ public function getSelectedProducts() { if (!$this->hasSelectedProducts()) { $products = array(); foreach ($this->getSelectedProductsCollection() as $product) { $products[] = $product; } $this->setSelectedProducts($products); } return $this->getData('selected_products'); } /** * Retrieve collection selected products * * @access public * @return {{Namespace}}_{{Module}}_Resource_{{Entity}}_Product_Collection * {{qwertyuiop}} */ public function getSelectedProductsCollection() { $collection = $this->getProductInstance()->getProductCollection($this); return $collection; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/150_category_relation ================================================ /** * get category relation model * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_Category * {{qwertyuiop}} */ public function getCategoryInstance() { if (!$this->_categoryInstance) { $this->_categoryInstance = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}_category'); } return $this->_categoryInstance; } /** * get selected categories array * * @access public * @return array * {{qwertyuiop}} */ public function getSelectedCategories() { if (!$this->hasSelectedCategories()) { $categories = array(); foreach ($this->getSelectedCategoriesCollection() as $category) { $categories[] = $category; } $this->setSelectedCategories($categories); } return $this->getData('selected_categories'); } /** * Retrieve collection selected categories * * @access public * @return {{Namespace}}_{{Module}}_Resource_{{Entity}}_Category_Collection * {{qwertyuiop}} */ public function getSelectedCategoriesCollection() { $collection = $this->getCategoryInstance()->getCategoryCollection($this); return $collection; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/160_sibling_relation ================================================ /** * get {{siblingLabel}} relation model * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_{{Sibling}} * {{qwertyuiop}} */ public function get{{Sibling}}Instance() { if (!$this->_{{sibling}}Instance) { $this->_{{sibling}}Instance = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}_{{sibling}}'); } return $this->_{{sibling}}Instance; } /** * get selected {{siblingsLabel}} array * * @access public * @return array * {{qwertyuiop}} */ public function getSelected{{Siblings}}() { if (!$this->hasSelected{{Siblings}}()) { ${{siblings}} = array(); foreach ($this->getSelected{{Siblings}}Collection() as ${{sibling}}) { ${{siblings}}[] = ${{sibling}}; } $this->setSelected{{Siblings}}(${{siblings}}); } return $this->getData('selected_{{siblings}}'); } /** * Retrieve collection selected {{siblingsLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_{{Sibling}}_Collection * {{qwertyuiop}} */ public function getSelected{{Siblings}}Collection() { $collection = $this->get{{Sibling}}Instance()->get{{Siblings}}Collection($this); return $collection; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/163_children_relation ================================================ /** * Retrieve {{siblingsLabel}} collection * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Sibling}}_Collection * {{qwertyuiop}} */ public function getSelected{{Siblings}}Collection() { if (!$this->hasData('_{{sibling}}_collection')) { if (!$this->getId()) { return new Varien_Data_Collection(); } else { $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{sibling}}_collection'){{siblingAllAttributesToCollection}} ->{{siblingFilterMethod}}('{{entity}}_id', $this->getId()); $this->setData('_{{sibling}}_collection', $collection); } } return $this->getData('_{{sibling}}_collection'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/165_parent_relation ================================================ /** * Retrieve parent {{siblingsLabel}} * * @access public * @return null|{{Namespace}}_{{Module}}_Model_{{Sibling}} * {{qwertyuiop}} */ public function getParent{{Sibling}}() { if (!$this->hasData('_parent_{{sibling}}')) { if (!$this->get{{Sibling}}Id()) { return null; } else { ${{sibling}} = Mage::getModel('{{namespace}}_{{module}}/{{sibling}}'){{siblingLoadStoreId}} ->load($this->get{{Sibling}}Id()); if (${{sibling}}->getId()) { $this->setData('_parent_{{sibling}}', ${{sibling}}); } else { $this->setData('_parent_{{sibling}}', null); } } } return $this->getData('_parent_{{sibling}}'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/170_tree ================================================ /** * get the tree model * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree * {{qwertyuiop}} */ public function getTreeModel() { return Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_tree'); } /** * get tree model instance * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree * {{qwertyuiop}} */ public function getTreeModelInstance() { if (is_null($this->_treeModel)) { $this->_treeModel = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}_tree'); } return $this->_treeModel; } /** * Move {{entityLabel}} * * @access public * @param int $parentId new parent {{entityLabel}} id * @param int $after{{Entity}}Id {{entityLabel}} id after which we have put current {{entityLabel}} * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function move($parentId, $after{{Entity}}Id) { $parent = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($parentId); if (!$parent->getId()) { Mage::throwException( Mage::helper('{{namespace}}_{{module}}')->__( '{{EntityLabel}} move operation is not possible: the new parent {{entityLabel}} was not found.' ) ); } if (!$this->getId()) { Mage::throwException( Mage::helper('{{namespace}}_{{module}}')->__( '{{EntityLabel}} move operation is not possible: the current {{entityLabel}} was not found.' ) ); } elseif ($parent->getId() == $this->getId()) { Mage::throwException( Mage::helper('{{namespace}}_{{module}}')->__( '{{EntityLabel}} move operation is not possible: parent {{entityLabel}} is equal to child {{entityLabel}}.' ) ); } $this->setMoved{{Entity}}Id($this->getId()); $eventParams = array( $this->_eventObject => $this, 'parent' => $parent, '{{entity}}_id' => $this->getId(), 'prev_parent_id' => $this->getParentId(), 'parent_id' => $parentId ); $moveComplete = false; $this->_getResource()->beginTransaction(); try { $this->getResource()->changeParent($this, $parent, $after{{Entity}}Id); $this->_getResource()->commit(); $this->setAffected{{Entity}}Ids(array($this->getId(), $this->getParentId(), $parentId)); $moveComplete = true; } catch (Exception $e) { $this->_getResource()->rollBack(); throw $e; } if ($moveComplete) { Mage::app()->cleanCache(array(self::CACHE_TAG)); } return $this; } /** * Get the parent {{entityLabel}} * * @access public * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ public function getParent{{Entity}}() { if (!$this->hasData('parent_{{entity}}')) { $this->setData( 'parent_{{entity}}', Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($this->getParentId()) ); } return $this->_getData('parent_{{entity}}'); } /** * Get the parent id * * @access public * @return int * {{qwertyuiop}} */ public function getParentId() { $parentIds = $this->getParentIds(); return intval(array_pop($parentIds)); } /** * Get all parent {{entitiesLabel}} ids * * @access public * @return array * {{qwertyuiop}} */ public function getParentIds() { return array_diff($this->getPathIds(), array($this->getId())); } /** * Get all {{entitiesLabel}} children * * @access public * @param bool $asArray * @return mixed (array|string) * {{qwertyuiop}} */ public function getAllChildren($asArray = false) { $children = $this->getResource()->getAllChildren($this); if ($asArray) { return $children; } else { return implode(',', $children); } } /** * Get all {{entitiesLabel}} children * * @access public * @return string * {{qwertyuiop}} */ public function getChild{{Entities}}() { return implode(',', $this->getResource()->getChildren($this, false)); } /** * check the id * * @access public * @param int $id * @return bool * {{qwertyuiop}} */ public function checkId($id) { return $this->_getResource()->checkId($id); } /** * Get array {{entitiesLabel}} ids which are part of {{entityLabel}} path * * @access public * @return array * {{qwertyuiop}} */ public function getPathIds() { $ids = $this->getData('path_ids'); if (is_null($ids)) { $ids = explode('/', $this->getPath()); $this->setData('path_ids', $ids); } return $ids; } /** * Retrieve level * * @access public * @return int * {{qwertyuiop}} */ public function getLevel() { if (!$this->hasLevel()) { return count(explode('/', $this->getPath())) - 1; } return $this->getData('level'); } /** * Verify {{entityLabel}} ids * * @access public * @param array $ids * @return bool * {{qwertyuiop}} */ public function verifyIds(array $ids) { return $this->getResource()->verifyIds($ids); } /** * check if {{entityLabel}} has children * * @access public * @return bool * {{qwertyuiop}} */ public function hasChildren() { return $this->_getResource()->getChildrenAmount($this) > 0; } /** * check if {{entityLabel}} can be deleted * * @access protected * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ protected function _beforeDelete() { if ($this->getResource()->isForbiddenToDelete($this->getId())) { Mage::throwException(Mage::helper('{{namespace}}_{{module}}')->__("Can't delete root {{entityLabel}}.")); } return parent::_beforeDelete(); } /** * get the {{entitiesLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $parent * @param int $recursionLevel * @param bool $sorted * @param bool $asCollection * @param bool $toLoad * {{qwertyuiop}} */ public function get{{Entities}}($parent, $recursionLevel = 0, $sorted=false, $asCollection=false, $toLoad=true) { return $this->getResource()->get{{Entities}}($parent, $recursionLevel, $sorted, $asCollection, $toLoad); } /** * Return parent {{entitiesLabel}} of current {{entityLabel}} * * @access public * @return array * {{qwertyuiop}} */ public function getParent{{Entities}}() { return $this->getResource()->getParent{{Entities}}($this); } /** * Return children {{entitiesLabel}} of current {{entityLabel}} * * @access public * @return array * {{qwertyuiop}} */ public function getChildren{{Entities}}() { return $this->getResource()->getChildren{{Entities}}($this); } /** * check if parents are enabled * * @access public * @return bool * {{qwertyuiop}} */ public function getStatusPath() { $parents = $this->getParent{{Entities}}(); $rootId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); foreach ($parents as $parent) { if ($parent->getId() == $rootId) { continue; } if (!$parent->getStatus()) { return false; } } return $this->getStatus(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/175_eav_default_attribute_set ================================================ /** * Retrieve default attribute set id * * @access public * @return int * {{qwertyuiop}} */ public function getDefaultAttributeSetId() { return $this->getResource()->getEntityType()->getDefaultAttributeSetId(); } /** * get attribute text value * * @access public * @param $attributeCode * @return string * {{qwertyuiop}} */ public function getAttributeText($attributeCode) { $text = $this->getResource() ->getAttribute($attributeCode) ->getSource() ->getOptionText($this->getData($attributeCode)); if (is_array($text)) { return implode(', ', $text); } return $text; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/180_allow_comment ================================================ /** * check if comments are allowed * * @access public * @return array * {{qwertyuiop}} */ public function getAllowComments() { if ($this->getData('allow_comment') == {{Namespace}}_{{Module}}_Model_Adminhtml_Source_Yesnodefault::NO) { return false; } if ($this->getData('allow_comment') == {{Namespace}}_{{Module}}_Model_Adminhtml_Source_Yesnodefault::YES) { return true; } return Mage::getStoreConfigFlag('{{namespace}}_{{module}}/{{entity}}/allow_comment'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/190_default_values ================================================ /** * get default values * * @access public * @return array * {{qwertyuiop}} */ public function getDefaultValues() { $values = array(); $values['status'] = 1; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/200_default_values_rss ================================================ $values['in_rss'] = 1; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/210_default_values_comment ================================================ $values['allow_comment'] = {{Namespace}}_{{Module}}_Model_Adminhtml_Source_Yesnodefault::USE_DEFAULT; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/215_default_attribute_values ================================================ {{defaultAttributeValues}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/220_footer ================================================ return $values; } {{multiselectMethods}} } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/010_top ================================================ load(${{entity}}Id); if (!${{entity}}->getId()) { $this->_fault('{{entity}}_not_exists'); } return ${{entity}}; } /** * get {{entitiesLabel}} * * @access public * @param mixed $filters * @return array * {{qwertyuiop}} */ public function items($filters = null) { $collection = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->getCollection() ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/013_eav ================================================ ->addAttributeToSelect('*') ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/014_tree_filter ================================================ ->{{filterMethod}}( 'entity_id', array( 'neq'=>Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id() ) ) ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/016_content ================================================ ; $apiHelper = Mage::helper('api'); $filters = $apiHelper->parseFilters($filters); try { foreach ($filters as $field => $value) { $collection->addFieldToFilter($field, $value); } } catch (Mage_Core_Exception $e) { $this->_fault('filters_invalid', $e->getMessage()); } $result = array(); foreach ($collection as ${{entity}}) { $result[] = $this->_getApiData(${{entity}}); } return $result; } /** * Add {{entityLabel}} * * @access public * @param array $data * @return array * {{qwertyuiop}} */ public function add($data) { try { if (is_null($data)) { throw new Exception(Mage::helper('{{namespace}}_{{module}}')->__("Data cannot be null")); } $data = (array)$data; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/017_add_eav ================================================ if (isset($data['additional_attributes']) && is_array($data['additional_attributes'])) { foreach ($data['additional_attributes'] as $key=>$value) { $data[$key] = $value; } unset($data['additional_attributes']); } $data['attribute_set_id'] = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->getDefaultAttributeSetId(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/018_add_end ================================================ ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}') ->setData((array)$data) ->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } catch (Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return ${{entity}}->getId(); } /** * Change existing {{entityLabel}} information * * @access public * @param int ${{entity}}Id * @param array $data * @return bool * {{qwertyuiop}} */ public function update(${{entity}}Id, $data) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); try { $data = (array)$data; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/019_update_eav ================================================ if (isset($data['additional_attributes']) && is_array($data['additional_attributes'])) { foreach ($data['additional_attributes'] as $key=>$value) { $data[$key] = $value; } unset($data['additional_attributes']); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/020_update_footer ================================================ ${{entity}}->addData($data); ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_fault('save_error', $e->getMessage()); } return true; } /** * remove {{entityLabel}} * * @access public * @param int ${{entity}}Id * @return bool * {{qwertyuiop}} */ public function remove(${{entity}}Id) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); try { ${{entity}}->delete(); } catch (Mage_Core_Exception $e) { $this->_fault('remove_error', $e->getMessage()); } return true; } /** * get info * * @access public * @param int ${{entity}}Id * @return array * {{qwertyuiop}} */ public function info(${{entity}}Id) { $result = array(); ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); $result = $this->_getApiData(${{entity}}); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/024_product_relation_info ================================================ //related products $result['products'] = array(); $relatedProductsCollection = ${{entity}}->getSelectedProductsCollection(); foreach ($relatedProductsCollection as $product) { $result['products'][$product->getId()] = $product->getPosition(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/030_category_relation_info ================================================ //related categories $result['categories'] = array(); $relatedCategoriesCollection = ${{entity}}->getSelectedCategoriesCollection(); foreach ($relatedCategoriesCollection as $category) { $result['categories'][$category->getId()] = $category->getPosition(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/040_sibling_info ================================================ //related {{siblings}} $result['{{siblings}}'] = array(); $related{{Siblings}}Collection = ${{entity}}->getSelected{{Siblings}}Collection(); foreach ($related{{Siblings}}Collection as ${{sibling}}) { $result['{{siblings}}'][${{sibling}}->getId()] = ${{sibling}}->getPosition(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/050_info_footer ================================================ return $result; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/060_tree ================================================ /** * Move {{entityLabel}} in tree * * @param int ${{entity}}Id * @param int $parentId * @param int $afterId * @return boolean */ public function move(${{entity}}Id, $parentId, $afterId = null) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); $parent{{Entity}} = $this->_init{{Entity}}($parentId); if ($afterId === null && $parent{{Entity}}->hasChildren()) { $parentChildren = $parent{{Entity}}->getChild{{Entities}}(); $afterId = array_pop(explode(',', $parentChildren)); } if ( strpos($parent{{Entity}}->getPath(), ${{entity}}->getPath()) === 0) { $this->_fault( 'not_moved', Mage::helper('{{namespace}}_{{module}}')->__("Cannot move parent inside {{entityLabel}}") ); } try { ${{entity}}->move($parentId, $afterId); } catch (Mage_Core_Exception $e) { $this->_fault('not_moved', $e->getMessage()); } return true; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/070_product_relation ================================================ /** * Assign product to {{entityLabel}} * * @access public * @param int ${{entity}}Id * @param int $productId * @param int $position * @return boolean * {{qwertyuiop}} */ public function assignProduct(${{entity}}Id, $productId, $position = null) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); $positions = array(); $products = ${{entity}}->getSelectedProducts(); foreach ($products as $product) { $positions[$product->getId()] = array('position'=>$product->getPosition()); } $product = Mage::getModel('catalog/product')->load($productId); if (!$product->getId()) { $this->_fault('product_not_exists'); } $positions[$productId]['position'] = $position; ${{entity}}->setProductsData($positions); try { ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; } /** * remove product from {{entityLabel}} * * @access public * @param int ${{entity}}Id * @param int $productId * @return boolean * {{qwertyuiop}} */ public function unassignProduct(${{entity}}Id, $productId) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); $positions = array(); $products = ${{entity}}->getSelectedProducts(); foreach ($products as $product) { $positions[$product->getId()] = array('position'=>$product->getPosition()); } unset($positions[$productId]); ${{entity}}->setProductsData($positions); try { ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/080_category_relation ================================================ /** * Assign category to {{entityLabel}} * * @access public * @param int ${{entity}}Id * @param int $categoryId * @return boolean * {{qwertyuiop}} */ public function assignCategory(${{entity}}Id, $categoryId) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); $category = Mage::getModel('catalog/category')->load($categoryId); if (!$category->getId()) { $this->_fault('category_not_exists'); } $categories = ${{entity}}->getSelectedCategories(); $categoryIds = array(); foreach ($categories as $category) { $categoryIds[] = $category->getId(); } $categoryIds[] = $categoryId; ${{entity}}->setCategoriesData($categoryIds); try { ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; } /** * remove category from {{entityLabel}} * * @access public * @param int ${{entity}}Id * @param int $categoryId * @return boolean * {{qwertyuiop}} */ public function unassignCategory(${{entity}}Id, $categoryId) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); $categories = ${{entity}}->getSelectedCategories(); $categoryIds = array(); foreach ($categories as $key=>$category) { if ($category->getId() != $categoryId) { $categoryIds[] = $category->getId(); } } ${{entity}}->setCategoriesData($categoryIds); try { ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/090_sibling_relation ================================================ /** * Assign {{siblingLabel}} to {{entityLabel}} * * @access public * @param int ${{entity}}Id * @param int ${{sibling}}Id * @param int $position * @return boolean * {{qwertyuiop}} */ public function assign{{Sibling}}(${{entity}}Id, ${{sibling}}Id, $position = null) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); $positions = array(); ${{siblings}} = ${{entity}}->getSelected{{Siblings}}(); foreach (${{siblings}} as ${{sibling}}) { ${{siblings}}[${{sibling}}->getId()] = array('position'=>${{sibling}}->getPosition()); } ${{sibling}} = Mage::getModel('{{namespace}}_{{module}}/{{sibling}}')->load(${{sibling}}Id); if (!${{sibling}}->getId()) { $this->_fault('{{entity}}_{{sibling}}_not_exists'); } $positions[${{sibling}}Id]['position'] = $position; ${{sibling}}->set{{Siblings}}Data($positions); try { ${{sibling}}->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; } /** * remove {{siblingLabel}} from {{entityLabel}} * * @access public * @param int ${{entity}}Id * @param int ${{sibling}}Id * @return boolean * {{qwertyuiop}} */ public function unassign{{Sibling}}(${{entity}}Id, ${{sibling}}Id) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); $positions = array(); ${{siblings}} = ${{entity}}->getSelected{{Siblings}}(); foreach (${{siblings}} as ${{sibling}}) { ${{siblings}}[${{sibling}}->getId()] = array('position'=>${{sibling}}->getPosition()); } unset($positions[${{sibling}}Id]); ${{entity}}->set{{Siblings}}Data($positions); try { ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/095_sibling_relation_tree ================================================ /** * Assign {{siblingLabel}} to {{entityLabel}} * * @access public * @param int ${{entity}}Id * @param int ${{sibling}}Id * @return boolean * {{qwertyuiop}} */ public function assign{{Sibling}}(${{entity}}Id, ${{sibling}}Id) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); ${{sibling}} = Mage::getModel('{{namespace}}_{{module}}/{{sibling}}')->load(${{sibling}}Id); if (!${{sibling}}->getId()) { $this->_fault('{{sibling}}_not_exists'); } ${{siblings}} = ${{entity}}->getSelected{{Siblings}}(); ${{sibling}}Ids = array(); foreach (${{siblings}} as ${{sibling}}) { ${{sibling}}Ids[] = ${{sibling}}->getId(); } ${{sibling}}Ids[] = ${{sibling}}Id; ${{entity}}->set{{Siblings}}Data(${{sibling}}Ids); try { ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; } /** * remove {{siblingLabel}} from {{entityLabel}} * * @access public * @param int ${{entity}}Id * @param int ${{sibling}}Id * @return boolean * {{qwertyuiop}} */ public function unassign{{Sibling}}(${{entity}}Id, ${{sibling}}Id) { ${{entity}} = $this->_init{{Entity}}(${{entity}}Id); ${{siblings}} = ${{entity}}->getSelected{{Siblings}}(); ${{sibling}}Ids = array(); foreach (${{siblings}} as $key=>${{sibling}}) { if (${{sibling}}->getId() != ${{sibling}}Id) { ${{sibling}}Ids[] = ${{sibling}}->getId(); } } ${{entity}}->set{{Siblings}}Data(${{sibling}}Ids); try { ${{entity}}->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/097_get_attributes ================================================ /** * Get list of additional attributes which are not in default create/update list * * @access public * @return array * {{qwertyuiop}} */ public function getAdditionalAttributes() { $entity = Mage::getModel('eav/entity_type')->load('{{namespace}}_{{module}}_{{entity}}', 'entity_type_code'); $attributes = Mage::getResourceModel('eav/entity_attribute_collection') ->setEntityTypeFilter($entity->getEntityTypeId()); $result = array(); foreach ($attributes as $attribute) { if (!in_array($attribute->getAttributeCode(), $this->_defaultAttributeList)) { if ($attribute->getIsGlobal() == {{Namespace}}_{{Module}}_Model_Attribute::SCOPE_GLOBAL) { $scope = 'global'; } elseif ($attribute->getIsGlobal() == {{Namespace}}_{{Module}}_Model_Attribute::SCOPE_WEBSITE) { $scope = 'website'; } else { $scope = 'store'; } $result[] = array( 'attribute_id' => $attribute->getId(), 'code' => $attribute->getAttributeCode(), 'type' => $attribute->getFrontendInput(), 'required' => $attribute->getIsRequired(), 'scope' => $scope ); } } return $result; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/098_get_api_data_flat ================================================ /** * get data for api * * @access protected * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return array() * {{qwertyuiop}} */ protected function _getApiData({{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}) { return ${{entity}}->getData(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/099_get_api_data_eav ================================================ /** * get data for api * * @access protected * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return array() * {{qwertyuiop}} */ protected function _getApiData({{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}) { $data = array(); $additional = array(); $additionalAttributes = $this->getAdditionalAttributes(); $additionalByCode = array(); foreach ($additionalAttributes as $attribute) { $additionalByCode[] = $attribute['code']; } foreach (${{entity}}->getData() as $key=>$value) { if (!in_array($key, $additionalByCode)) { $data[$key] = $value; } else { $additional[] = array('key'=>$key, 'value'=>$value); } } if (!empty($additional)) { $data['additional_attributes'] = $additional; } return $data; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/100_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/V2/010_top ================================================ wsiArrayPacker($result); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/V2/020_product_relation ================================================ foreach ($result->products as $key => $value) { $result->products[$key] = array('key' => $key, 'value' => $value); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/V2/030_category_relation ================================================ foreach ($result->categories as $key => $value) { $result->categories[$key] = array('key' => $key, 'value' => $value); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/V2/040_sibling_relation ================================================ foreach ($result->{{siblings}} as $key => $value) { $result->{{siblings}}[$key] = array('key' => $key, 'value' => $value); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Api/V2/050_footer ================================================ return $result; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Api/010_content ================================================ _storeIdSessionField = '{{entity}}_store_id'; $this->_entityTypeId = Mage::getModel('eav/entity')->setType('{{namespace}}_{{module}}_{{entity}}') ->getTypeId(); } /** * Retrieve attributes * * @access public * @return array * {{qwertyuiop}} */ public function items() { $attributes = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_attribute_collection'); $result = array(); foreach ($attributes as $attribute) { if ($this->_isAllowedAttribute($attribute)) { if (!$attribute->getId() || $attribute->getIsGlobal() == {{Namespace}}_{{Module}}_Model_Attribute::SCOPE_GLOBAL) { $scope = 'global'; } elseif ($attribute->getIsGlobal() == {{Namespace}}_{{Module}}_Model_Attribute::SCOPE_WEBSITE) { $scope = 'website'; } else { $scope = 'store'; } $result[] = array( 'attribute_id' => $attribute->getId(), 'code' => $attribute->getAttributeCode(), 'type' => $attribute->getFrontendInput(), 'required' => $attribute->getIsRequired(), 'scope' => $scope ); } } return $result; } /** * Retrieve attribute options * * @access public * @param int $attributeId * @param string|int $store * @return array * {{qwertyuiop}} */ public function options($attributeId, $store = null) { $storeId = $this->_getStoreId($store); $attribute = Mage::getModel('{{namespace}}_{{module}}/{{entity}}') ->setStoreId($storeId) ->getResource() ->getAttribute($attributeId); if (!$attribute) { $this->_fault('not_exists'); } $options = array(); if ($attribute->usesSource()) { foreach ($attribute->getSource()->getAllOptions() as $optionId => $optionValue) { if (is_array($optionValue)) { $options[] = $optionValue; } else { $options[] = array( 'value' => $optionId, 'label' => $optionValue ); } } } return $options; } /** * Retrieve list of possible attribute types * * @access public * @return array * {{qwertyuiop}} */ public function types() { $types = Mage::getModel('eav/adminhtml_system_config_source_inputtype')->toOptionArray(); $additionalTypes = array( array( 'value' => 'image', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Image') ), array( 'value' => 'file', 'label' => Mage::helper('{{namespace}}_{{module}}')->__('File') ) ); return array_merge($types, $additionalTypes); } /** * Create new product attribute * * @access public * @param array $data input data * @return integer * {{qwertyuiop}} */ public function create($data) { $model = Mage::getModel('{{namespace}}_{{module}}/resource_eav_attribute'); $helper = Mage::helper('{{namespace}}_{{module}}/{{entity}}'); if (empty($data['attribute_code']) || !is_array($data['frontend_label'])) { $this->_fault('invalid_parameters'); } //validate attribute_code if (!preg_match('/^[a-z][a-z_0-9]{0,254}$/', $data['attribute_code'])) { $this->_fault('invalid_code'); } //validate frontend_input $allowedTypes = array(); foreach ($this->types() as $type) { $allowedTypes[] = $type['value']; } if (!in_array($data['frontend_input'], $allowedTypes)) { $this->_fault('invalid_frontend_input'); } $data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']); $data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']); if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) { $data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']); } $this->_prepareDataForSave($data); $model->addData($data); $model->setEntityTypeId($this->_entityTypeId); $model->setIsUserDefined(1); $model->setIsVisible(1); try { $model->save(); // clear translation cache because attribute labels are stored in translation Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG)); } catch (Exception $e) { $this->_fault('unable_to_save', $e->getMessage()); } return (int) $model->getId(); } /** * Update product attribute * * @access public * @param string|integer $attribute attribute code or ID * @param array $data * @return boolean * {{qwertyuiop}} */ public function update($attribute, $data) { $model = $this->_getAttribute($attribute); if ($model->getEntityTypeId() != $this->_entityTypeId) { $this->_fault('can_not_edit'); } $data['attribute_code'] = $model->getAttributeCode(); $data['is_user_defined'] = $model->getIsUserDefined(); $data['frontend_input'] = $model->getFrontendInput(); $this->_prepareDataForSave($data); $model->addData($data); try { $model->save(); // clear translation cache because attribute labels are stored in translation Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG)); return true; } catch (Exception $e) { $this->_fault('unable_to_save', $e->getMessage()); } } /** * Remove attribute * * @access public * @param integer|string $attribute attribute ID or code * @return boolean * {{qwertyuiop}} */ public function remove($attribute) { $model = $this->_getAttribute($attribute); if ($model->getEntityTypeId() != $this->_entityTypeId) { $this->_fault('can_not_delete'); } try { $model->delete(); return true; } catch (Exception $e) { $this->_fault('can_not_delete', $e->getMessage()); } } /** * Get full information about attribute with list of options * * @access pubic * @param integer|string $attribute attribute ID or code * @return array * {{qwertyuiop}} */ public function info($attribute) { $model = $this->_getAttribute($attribute); if ($model->isScopeGlobal()) { $scope = 'global'; } elseif ($model->isScopeWebsite()) { $scope = 'website'; } else { $scope = 'store'; } $frontendLabels = array( array( 'store_id' => 0, 'label' => $model->getFrontendLabel() ) ); foreach ($model->getStoreLabels() as $storeId => $label) { $frontendLabels[] = array( 'store_id' => $storeId, 'label' => $label ); } $result = array( 'attribute_id' => $model->getId(), 'attribute_code' => $model->getAttributeCode(), 'frontend_input' => $model->getFrontendInput(), 'default_value' => $model->getDefaultValue(), 'is_unique' => $model->getIsUnique(), 'is_required' => $model->getIsRequired(), 'frontend_label' => $frontendLabels ); // set additional fields to different types switch ($model->getFrontendInput()) { case 'text': $result['additional_fields'] = array( 'frontend_class' => $model->getFrontendClass(), ); break; case 'textarea': $result['additional_fields'] = array( 'is_wysiwyg_enabled' => $model->getIsWysiwygEnabled(), ); break; case 'date': default: $result['additional_fields'] = array(); break; } // set options $options = $this->options($model->getId()); // remove empty first element if ($model->getFrontendInput() != 'boolean') { array_shift($options); } if (count($options) > 0) { $result['options'] = $options; } return $result; } /** * Add option to select or multiselect attribute * * @access public * @param integer|string $attribute attribute ID or code * @param array $data * @return bool * {{qwertyuiop}} */ public function addOption($attribute, $data) { $model = $this->_getAttribute($attribute); if (!$model->usesSource()) { $this->_fault('invalid_frontend_input'); } /** @var $helperCatalog Mage_Catalog_Helper_Data */ $helperCatalog = Mage::helper('catalog'); $optionLabels = array(); foreach ($data['label'] as $label) { $storeId = $label['store_id']; $labelText = $helperCatalog->stripTags($label['value']); if (is_array($storeId)) { foreach ($storeId as $multiStoreId) { $optionLabels[$multiStoreId] = $labelText; } } else { $optionLabels[$storeId] = $labelText; } } $modelData = array( 'option' => array( 'value' => array( 'option_1' => $optionLabels ), 'order' => array( 'option_1' => (int) $data['order'] ) ) ); $model->addData($modelData); try { $model->save(); } catch (Exception $e) { $this->_fault('unable_to_add_option', $e->getMessage()); } return true; } /** * Remove option from select or multiselect attribute * * @access public * @param integer|string $attribute attribute ID or code * @param integer $optionId option to remove ID * @return bool * {{qwertyuiop}} */ public function removeOption($attribute, $optionId) { $model = $this->_getAttribute($attribute); if (!$model->usesSource()) { $this->_fault('invalid_frontend_input'); } $modelData = array( 'option' => array( 'value' => array( $optionId => array() ), 'delete' => array( $optionId => '1' ) ) ); $model->addData($modelData); try { $model->save(); } catch (Exception $e) { $this->_fault('unable_to_remove_option', $e->getMessage()); } return true; } /** * Prepare request input data for saving * * @access protected * @param array $data input data * @return void * {{qwertyuiop}} */ protected function _prepareDataForSave(&$data) { /** @var $helperCatalog Mage_Catalog_Helper_Data */ $helperCatalog = Mage::helper('catalog'); if ($data['scope'] == 'global') { $data['is_global'] = Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL; } else if ($data['scope'] == 'website') { $data['is_global'] = Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE; } else { $data['is_global'] = Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE; } // set frontend labels array with store_id as keys if (isset($data['frontend_label']) && is_array($data['frontend_label'])) { $labels = array(); foreach ($data['frontend_label'] as $label) { $storeId = $label['store_id']; $labelText = $helperCatalog->stripTags($label['label']); $labels[$storeId] = $labelText; } $data['frontend_label'] = $labels; } // set additional fields if (isset($data['additional_fields']) && is_array($data['additional_fields'])) { $data = array_merge($data, $data['additional_fields']); unset($data['additional_fields']); } //default value if (!empty($data['default_value'])) { $data['default_value'] = $helperCatalog->stripTags($data['default_value']); } } /** * Load model by attribute ID or code * * @param integer|string $attribute * @return Mage_Catalog_Model_Resource_Eav_Attribute * {{qwertyuiop}} */ protected function _getAttribute($attribute) { $model = Mage::getResourceModel('{{namespace}}_{{module}}/eav_attribute') ->setEntityTypeId($this->_entityTypeId); if (is_numeric($attribute)) { $model->load(intval($attribute)); } else { $model->load($attribute, 'attribute_code'); } if (!$model->getId()) { $this->_fault('not_exists'); } return $model; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Api/V2/010_content ================================================ v2AssociativeArrayUnpacker($data); Mage::helper('api')->toArray($data); return parent::create($data); } /** * Update product attribute * * @access public * @param string|integer $attribute attribute code or ID * @param array $data * @return boolean * {{qwertyuiop}} */ public function update($attribute, $data) { $helper = Mage::helper('api'); $helper->v2AssociativeArrayUnpacker($data); Mage::helper('api')->toArray($data); return parent::update($attribute, $data); } /** * Add option to select or multiselect attribute * * @access public * @param integer|string $attribute attribute ID or code * @param array $data * @return bool * {{qwertyuiop}} */ public function addOption($attribute, $data) { Mage::helper('api')->toArray($data); return parent::addOption($attribute, $data); } /** * Get full information about attribute with list of options * * @access public * @param integer|string $attribute attribute ID or code * @return array * {{qwertyuiop}} */ public function info($attribute) { $result = parent::info($attribute); if (!empty($result['additional_fields'])) { $keys = array_keys($result['additional_fields']); foreach ($keys as $key) { $result['additional_fields'][] = array( 'key' => $key, 'value' => $result['additional_fields'][$key] ); unset($result['additional_fields'][$key]); } } return $result; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/File/010_content ================================================ getData($this->getAttribute()->getName()); if (is_array($value) && !empty($value['delete'])) { $object->setData($this->getAttribute()->getName(), ''); $this->getAttribute()->getEntity() ->saveAttribute($object, $this->getAttribute()->getName()); return; } $path = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getFileBaseDir(); try { $uploader = new Varien_File_Uploader($this->getAttribute()->getName()); //set allowed file extensions if you need //$uploader->setAllowedExtensions(array('mp4', 'mov', 'f4v', 'flv')); $uploader->setAllowRenameFiles(true); $uploader->setFilesDispersion(true); $result = $uploader->save($path); $object->setData($this->getAttribute()->getName(), $result['file']); $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName()); } catch (Exception $e) { if ($e->getCode() != 666) { //throw $e; } return; } } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/Image/010_content ================================================ getData($this->getAttribute()->getName()); if (is_array($value) && !empty($value['delete'])) { $object->setData($this->getAttribute()->getName(), ''); $this->getAttribute()->getEntity() ->saveAttribute($object, $this->getAttribute()->getName()); return; } $path = Mage::helper('{{namespace}}_{{module}}/{{entity}}_image')->getImageBaseDir(); try { $uploader = new Varien_File_Uploader($this->getAttribute()->getName()); $uploader->setAllowRenameFiles(true); $uploader->setFilesDispersion(true); $result = $uploader->save($path); $object->setData($this->getAttribute()->getName(), $result['file']); $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName()); } catch (Exception $e) { if ($e->getCode() != 666) { //throw $e; } return; } } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/Urlkey/010_content ================================================ getAttribute()->getName(); $urlKey = $object->getData($attributeName); if ($urlKey == '') { $urlKey = $object->get{{EntityNameMagicCode}}(); } $urlKey = $this->formatUrlKey($urlKey); $validKey = false; while (!$validKey) { $entityId = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}') ->checkUrlKey($urlKey, $object->getStoreId(), false); if ($entityId == $object->getId() || empty($entityId)) { $validKey = true; } else { $parts = explode('-', $urlKey); $last = $parts[count($parts) - 1]; if (!is_numeric($last)) { $urlKey = $urlKey.'-1'; } else { $suffix = '-'.($last + 1); unset($parts[count($parts) - 1]); $urlKey = implode('-', $parts).$suffix; } } } $object->setData($attributeName, $urlKey); return $this; } /** * format url key * * @access public * @param string $str * @return string * {{qwertyuiop}} */ public function formatUrlKey($str) { $urlKey = preg_replace('#[^0-9a-z]+#i', '-', Mage::helper('catalog/product_url')->format($str)); $urlKey = strtolower($urlKey); $urlKey = trim($urlKey, '-'); return $urlKey; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Source/Attributecode/010_content ================================================ getAllOptions($withEmpty) as $option) { $options[$option['value']] = $option['label']; } return $options; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Source/Attributecode/020_eav ================================================ /** * get option text * * @access public * @param mixed $value * @return string * {{qwertyuiop}} */ public function getOptionText($value) { $options = $this->getOptionsArray(); if (!is_array($value)) { $value = explode(',', $value); } $texts = array(); foreach ($value as $v) { if (isset($options[$v])) { $texts[] = $options[$v]; } } return implode(', ', $texts); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Source/Attributecode/030_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Category/010_content ================================================ _init('{{namespace}}_{{module}}/{{entity}}_category'); } /** * Save data for {{entityLabel}}-category relation * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_Category * {{qwertyuiop}} */ public function save{{Entity}}Relation(${{entity}}) { $data = ${{entity}}->getCategoriesData(); if (!is_null($data)) { $this->_getResource()->save{{Entity}}Relation(${{entity}}, $data); } return $this; } /** * get categories for {{entityLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Category_Collection * {{qwertyuiop}} */ public function getCategoryCollection(${{entity}}) { $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_category_collection') ->add{{Entity}}Filter(${{entity}}); return $collection; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Comment/010_content ================================================ _init('{{namespace}}_{{module}}/{{entity}}_comment'); } /** * before save {{entityLabel}} comment * * @access protected * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment * {{qwertyuiop}} */ protected function _beforeSave() { parent::_beforeSave(); $now = Mage::getSingleton('core/date')->gmtDate(); if ($this->isObjectNew()) { $this->setCreatedAt($now); } $this->setUpdatedAt($now); return $this; } /** * validate comment * * @access public * @return array|bool * {{qwertyuiop}} */ public function validate() { $errors = array(); if (!Zend_Validate::is($this->getTitle(), 'NotEmpty')) { $errors[] = Mage::helper('review')->__('Comment title can\'t be empty'); } if (!Zend_Validate::is($this->getName(), 'NotEmpty')) { $errors[] = Mage::helper('review')->__('Your name can\'t be empty'); } if (!Zend_Validate::is($this->getComment(), 'NotEmpty')) { $errors[] = Mage::helper('review')->__('Comment can\'t be empty'); } if (empty($errors)) { return true; } return $errors; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Comment/Api/010_content ================================================ getCollection(); $apiHelper = Mage::helper('api'); $filters = $apiHelper->parseFilters($filters); try { foreach ($filters as $field => $value) { $collection->addFieldToFilter($field, $value); } } catch (Mage_Core_Exception $e) { $this->_fault('filters_invalid', $e->getMessage()); } $result = array(); foreach ($collection as ${{entity}}) { $result[] = ${{entity}}->getData(); } return $result; } /** * update comment status * * @access public * @param mixed $filters * @return bool * {{qwertyuiop}} */ public function updateStatus($commentId, $status) { $comment = Mage::getModel('{{namespace}}_{{module}}/{{entity}}_comment')->load($commentId); if (!$comment->getId()) { $this->_fault('not_exists'); } try { $comment->setStatus($status)->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Comment/Api/V2/010_content ================================================ _init('{{namespace}}_{{module}}/{{entity}}_product'); } /** * Save data for {{entityLabel}}-product relation * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_Product * {{qwertyuiop}} */ public function save{{Entity}}Relation(${{entity}}) { $data = ${{entity}}->getProductsData(); if (!is_null($data)) { $this->_getResource()->save{{Entity}}Relation(${{entity}}, $data); } return $this; } /** * get products for {{entityLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product_Collection * {{qwertyuiop}} */ public function getProductCollection(${{entity}}) { $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_product_collection') ->add{{Entity}}Filter(${{entity}}); return $collection; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Sibling/010_content ================================================ _init('{{namespace}}_{{module}}/{{entity}}_{{sibling}}'); } /** * Save data for {{entityLabel}} - {{siblingLabel}} relation * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return {{Namespace}}_{{Module}}_Model_{{Entity}}_{{Sibling}} * {{qwertyuiop}} */ public function save{{Entity}}Relation(${{entity}}) { $data = ${{entity}}->get{{Siblings}}Data(); if (!is_null($data)) { $this->_getResource()->save{{Entity}}Relation(${{entity}}, $data); } return $this; } /** * get {{siblingsLabel}} for {{entityLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}}_Collection * {{qwertyuiop}} */ public function get{{Siblings}}Collection(${{entity}}) { $collection = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_{{sibling}}_collection') ->add{{Entity}}Filter(${{entity}}); return $collection; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Source/010_top ================================================ _options)) { $this->_options = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_collection') ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Source/020_eav ================================================ ->addAttributeToSelect('{{nameAttributeCode}}') ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Source/030_footer ================================================ ->load() ->toOptionArray(); } $options = $this->_options; if ($withEmpty) { array_unshift($options, array('value'=>'', 'label'=>'')); } return $options; } /** * Get a text for option value * * @access public * @param string|integer $value * @return string * {{qwertyuiop}} */ public function getOptionText($value) { $options = $this->getAllOptions(false); foreach ($options as $item) { if ($item['value'] == $value) { return $item['label']; } } return false; } /** * Convert to options array * * @access public * @return array * {{qwertyuiop}} */ public function toOptionArray() { return $this->getAllOptions(); } /** * Retrieve flat column definition * * @access public * @return array * {{qwertyuiop}} */ public function getFlatColums() { $attributeCode = $this->getAttribute()->getAttributeCode(); $column = array( 'unsigned' => true, 'default' => null, 'extra' => null ); if (Mage::helper('core')->useDbCompatibleMode()) { $column['type'] = 'int'; $column['is_null'] = true; } else { $column['type'] = Varien_Db_Ddl_Table::TYPE_INTEGER; $column['nullable'] = true; $column['comment'] = $attributeCode . ' {{EntityLabel}} column'; } return array($attributeCode => $column); } /** * Retrieve Select for update attribute value in flat table * * @access public * @param int $store * @return Varien_Db_Select|null * {{qwertyuiop}} */ public function getFlatUpdateSelect($store) { return Mage::getResourceModel('eav/entity_attribute_option') ->getFlatUpdateSelect($this->getAttribute(), $store, false); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Observer/010_top ================================================ getMenu(); $tree = $menu->getTree(); $action = Mage::app()->getFrontController()->getAction()->getFullActionName(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Observer/020_entity ================================================ ${{entity}}NodeId = '{{entity}}'; $data = array( 'name' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}'), 'id' => ${{entity}}NodeId, 'url' => Mage::helper('{{namespace}}_{{module}}/{{entity}}')->get{{Entities}}Url(), 'is_active' => ($action == '{{namespace}}_{{module}}_{{entity}}_index' || $action == '{{namespace}}_{{module}}_{{entity}}_view') ); ${{entity}}Node = new Varien_Data_Tree_Node($data, 'id', $tree, $menu); $menu->addChild(${{entity}}Node); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Observer/030_footer ================================================ return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Attribute/010_content ================================================ getEntityTypeId(); $setId = $setup->getDefaultAttributeSetId($entityType); $groupId = $setup->getDefaultAttributeGroupId($entityType); $attributeId = $object->getId(); $sortOrder = $object->getPosition(); $setup->addAttributeToGroup($entityType, $setId, $groupId, $attributeId, $sortOrder); return parent::_afterSave($object); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Eav/Attribute/010_content ================================================ _init('{{namespace}}_{{module}}/attribute'); } /** * check if scope is store view * * @access public * @return void * {{qwertyuiop}} */ public function isScopeStore() { return $this->getIsGlobal() == Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE; } /** * check if scope is website * * @access public * @return void * {{qwertyuiop}} */ public function isScopeWebsite() { return $this->getIsGlobal() == Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE; } /** * check if scope is global * * @access public * @return void * {{qwertyuiop}} */ public function isScopeGlobal() { return (!$this->isScopeStore() && !$this->isScopeWebsite()); } /** * get backend input type * * @access public * @param string $type * @return string * {{qwertyuiop}} */ public function getBackendTypeByInput($type) { switch ($type) { case 'file': //intentional fallthrough case 'image': return 'varchar'; break; case 'multiselect': return 'text'; break; default: return parent::getBackendTypeByInput($type); break; } } /** * don't delete system attributes * * @access public * @param string $type * @return string * {{qwertyuiop}} */ protected function _beforeDelete() { if (!$this->getIsUserDefined()) { throw new Mage_Core_Exception( Mage::helper('{{namespace}}_{{module}}')->__('This attribute is not deletable') ); } return parent::_beforeDelete(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/010_top ================================================ _init('{{namespace}}_{{module}}/{{entity}}', 'entity_id'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/032_eav_construct ================================================ {{RelationsResourceTablesDeclare}} /** * constructor * * @access public * {{qwertyuiop}} */ public function __construct() { $resource = Mage::getSingleton('core/resource'); $this->setType('{{namespace}}_{{module}}_{{entity}}') ->setConnection( $resource->getConnection('{{entity}}_read'), $resource->getConnection('{{entity}}_write') ); {{RelationsResourceTables}} } /** * wrapper for main table getter * * @access public * @return string * {{qwertyuiop}} */ public function getMainTable() { return $this->getEntityTable(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/037_store ================================================ /** * Get store ids to which specified item is assigned * * @access public * @param int ${{entity}}Id * @return array * {{qwertyuiop}} */ public function lookupStoreIds(${{entity}}Id) { $adapter = $this->_getReadAdapter(); $select = $adapter->select() ->from($this->getTable('{{namespace}}_{{module}}/{{entity}}_store'), 'store_id') ->where('{{entity}}_id = ?', (int)${{entity}}Id); return $adapter->fetchCol($select); } /** * Perform operations after object load * * @access public * @param Mage_Core_Model_Abstract $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _afterLoad(Mage_Core_Model_Abstract $object) { if ($object->getId()) { $stores = $this->lookupStoreIds($object->getId()); $object->setData('store_id', $stores); } return parent::_afterLoad($object); } /** * Retrieve select object for load object data * * @param string $field * @param mixed $value * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $object * @return Zend_Db_Select */ protected function _getLoadSelect($field, $value, $object) { $select = parent::_getLoadSelect($field, $value, $object); if ($object->getStoreId()) { $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId()); $select->join( array('{{module}}_{{entity}}_store' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_store')), $this->getMainTable() . '.entity_id = {{module}}_{{entity}}_store.{{entity}}_id', array() ) ->where('{{module}}_{{entity}}_store.store_id IN (?)', $storeIds) ->order('{{module}}_{{entity}}_store.store_id DESC') ->limit(1); } return $select; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/040_not_tree ================================================ /** * Assign {{entityLabel}} to store views * * @access protected * @param Mage_Core_Model_Abstract $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _afterSave(Mage_Core_Model_Abstract $object) { $oldStores = $this->lookupStoreIds($object->getId()); $newStores = (array)$object->getStores(); if (empty($newStores)) { $newStores = (array)$object->getStoreId(); } $table = $this->getTable('{{namespace}}_{{module}}/{{entity}}_store'); $insert = array_diff($newStores, $oldStores); $delete = array_diff($oldStores, $newStores); if ($delete) { $where = array( '{{entity}}_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete ); $this->_getWriteAdapter()->delete($table, $where); } if ($insert) { $data = array(); foreach ($insert as $storeId) { $data[] = array( '{{entity}}_id' => (int) $object->getId(), 'store_id' => (int) $storeId ); } $this->_getWriteAdapter()->insertMultiple($table, $data); } return parent::_afterSave($object); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/045_before_save_multiple ================================================ /** * process multiple select fields * * @access protected * @param Mage_Core_Model_Abstract $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _beforeSave(Mage_Core_Model_Abstract $object) { {{multipleSelectConvert}}return parent::_beforeSave($object); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/050_tree ================================================ /** * Retrieve {{entityLabel}} tree object * * @access protected * @return Varien_Data_Tree_Db * {{qwertyuiop}} */ protected function _getTree() { if (!$this->_tree) { $this->_tree = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_tree')->load(); } return $this->_tree; } /** * Process {{entityLabel}} data before delete * update children count for parent {{entityLabel}} * delete child {{entitiesLabel}} * * @access protected * @param Varien_Object $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _beforeDelete({{beforeSaveParam}} $object) { parent::_beforeDelete($object); /** * Update children count for all parent {{entitiesLabel}} */ $parentIds = $object->getParentIds(); if ($parentIds) { $childDecrease = $object->getChildrenCount() + 1; // +1 is itself $data = array('children_count' => new Zend_Db_Expr('children_count - ' . $childDecrease)); $where = array('entity_id IN(?)' => $parentIds); $this->_getWriteAdapter()->update($this->getMainTable(), $data, $where); } $this->deleteChildren($object); return $this; } /** * Delete children {{entitiesLabel}} of specific {{entityLabel}} * * @access public * @param Varien_Object $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ public function deleteChildren(Varien_Object $object) { $adapter = $this->_getWriteAdapter(); $pathField = $adapter->quoteIdentifier('path'); $select = $adapter->select() ->from($this->getMainTable(), array('entity_id')) ->where($pathField . ' LIKE :c_path'); $childrenIds = $adapter->fetchCol($select, array('c_path' => $object->getPath() . '/%')); if (!empty($childrenIds)) { $adapter->delete( $this->getMainTable(), array('entity_id IN (?)' => $childrenIds) ); } /** * Add deleted children ids to object * This data can be used in after delete event */ $object->setDeletedChildrenIds($childrenIds); return $this; } /** * Process {{entityLabel}} data after save {{entityLabel}} object * * @access protected * @param Varien_Object $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _afterSave({{beforeSaveParam}} $object) { if (substr($object->getPath(), -1) == '/') { $object->setPath($object->getPath() . $object->getId()); $this->_savePath($object); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/052_tree_store ================================================ $oldStores = $this->lookupStoreIds($object->getId()); $newStores = (array)$object->getStores(); if (empty($newStores)) { $newStores = (array)$object->getStoreId(); } $table = $this->getTable('{{namespace}}_{{module}}/{{entity}}_store'); $insert = array_diff($newStores, $oldStores); $delete = array_diff($oldStores, $newStores); if ($delete) { $where = array( '{{entity}}_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete ); $this->_getWriteAdapter()->delete($table, $where); } if ($insert) { $data = array(); foreach ($insert as $storeId) { $data[] = array( '{{entity}}_id' => (int) $object->getId(), 'store_id' => (int) $storeId ); } $this->_getWriteAdapter()->insertMultiple($table, $data); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/053_tree_after ================================================ return parent::_afterSave($object); } /** * Update path field * * @access protected * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _savePath($object) { if ($object->getId()) { $this->_getWriteAdapter()->update( $this->getMainTable(), array('path' => $object->getPath()), array('entity_id = ?' => $object->getId()) ); } return $this; } /** * Get maximum position of child {{entitiesLabel}} by specific tree path * * @access protected * @param string $path * @return int * {{qwertyuiop}} */ protected function _getMaxPosition($path) { $adapter = $this->getReadConnection(); $positionField = $adapter->quoteIdentifier('position'); $level = count(explode('/', $path)); $bind = array( 'c_level' => $level, 'c_path' => $path . '/%' ); $select = $adapter->select() ->from($this->getMainTable(), 'MAX(' . $positionField . ')') ->where($adapter->quoteIdentifier('path') . ' LIKE :c_path') ->where($adapter->quoteIdentifier('level') . ' = :c_level'); $position = $adapter->fetchOne($select, $bind); if (!$position) { $position = 0; } return $position; } /** * Get children {{entitiesLabel}} count * * @access public * @param int ${{entity}}Id * @return int * {{qwertyuiop}} */ public function getChildrenCount(${{entity}}Id) { $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), 'children_count') ->where('entity_id = :entity_id'); $bind = array('entity_id' => ${{entity}}Id); return $this->_getReadAdapter()->fetchOne($select, $bind); } /** * Check if {{entityLabel}} id exist * * @access public * @param int $entityId * @return bool * {{qwertyuiop}} */ public function checkId($entityId) { $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), 'entity_id') ->where('entity_id = :entity_id'); $bind = array('entity_id' => $entityId); return $this->_getReadAdapter()->fetchOne($select, $bind); } /** * Check array of {{entitiesLabel}} identifiers * * @access public * @param array $ids * @return array * {{qwertyuiop}} */ public function verifyIds(array $ids) { if (empty($ids)) { return array(); } $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), 'entity_id') ->where('entity_id IN(?)', $ids); return $this->_getReadAdapter()->fetchCol($select); } /** * Get count of active/not active children {{entitiesLabel}} * * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param bool $isActiveFlag * @return int * {{qwertyuiop}} */ public function getChildrenAmount(${{entity}}, $isActiveFlag = true) { $bind = array( 'active_flag' => $isActiveFlag, 'c_path' => ${{entity}}->getPath() . '/%' ); $select = $this->_getReadAdapter()->select() ->from(array('m' => $this->getMainTable()), array('COUNT(m.entity_id)')) ->where('m.path LIKE :c_path') ->where('status' . ' = :active_flag'); return $this->_getReadAdapter()->fetchOne($select, $bind); } /** * Return parent {{entitiesLabel}} of {{entityLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return array * {{qwertyuiop}} */ public function getParent{{Entities}}(${{entity}}) { $pathIds = array_reverse(explode('/', ${{entity}}->getPath())); ${{entities}} = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_collection') ->addFieldToFilter('entity_id', array('in' => $pathIds)) ->load() ->getItems(); return ${{entities}}; } /** * Return child {{entitiesLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function getChildren{{Entities}}(${{entity}}) { $collection = ${{entity}}->getCollection(); $collection ->addIdFilter(${{entity}}->getChild{{Entities}}()) ->setOrder('position', Varien_Db_Select::SQL_ASC) ->load(); return $collection; } /** * Return children ids of {{entityLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param boolean $recursive * @return array * {{qwertyuiop}} */ public function getChildren(${{entity}}, $recursive = true) { $bind = array( 'c_path' => ${{entity}}->getPath() . '/%' ); $select = $this->_getReadAdapter()->select() ->from(array('m' => $this->getMainTable()), 'entity_id') ->where('status = ?', 1) ->where($this->_getReadAdapter()->quoteIdentifier('path') . ' LIKE :c_path'); if (!$recursive) { $select->where($this->_getReadAdapter()->quoteIdentifier('level') . ' <= :c_level'); $bind['c_level'] = ${{entity}}->getLevel() + 1; } return $this->_getReadAdapter()->fetchCol($select, $bind); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/055_tree_eav ================================================ /** * Retrieve {{entityLabel}} tree object * * @access protected * @return Varien_Data_Tree_Db * {{qwertyuiop}} */ protected function _getTree() { if (!$this->_tree) { $this->_tree = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_tree')->load(); } return $this->_tree; } /** * Process {{entityLabel}} data before delete * update children count for parent {{entityLabel}} * delete child {{entitiesLabel}} * * @access protected * @param Varien_Object $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _beforeDelete({{beforeSaveParam}} $object) { parent::_beforeDelete($object); /** * Update children count for all parent {{entitiesLabel}} */ $parentIds = $object->getParentIds(); if ($parentIds) { $childDecrease = $object->getChildrenCount() + 1; // +1 is itself $data = array('children_count' => new Zend_Db_Expr('children_count - ' . $childDecrease)); $where = array('entity_id IN(?)' => $parentIds); $this->_getWriteAdapter()->update($this->getMainTable(), $data, $where); } $this->deleteChildren($object); return $this; } /** * Delete children {{entitiesLabel}} of specific {{entityLabel}} * * @access public * @param Varien_Object $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ public function deleteChildren(Varien_Object $object) { $adapter = $this->_getWriteAdapter(); $pathField = $adapter->quoteIdentifier('path'); $select = $adapter->select() ->from($this->getMainTable(), array('entity_id')) ->where($pathField . ' LIKE :c_path'); $childrenIds = $adapter->fetchCol($select, array('c_path' => $object->getPath() . '/%')); if (!empty($childrenIds)) { $adapter->delete( $this->getMainTable(), array('entity_id IN (?)' => $childrenIds) ); } /** * Add deleted children ids to object * This data can be used in after delete event */ $object->setDeletedChildrenIds($childrenIds); return $this; } /** * Process {{entityLabel}} data after save {{entityLabel}} object * * @access protected * @param Varien_Object $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _afterSave({{beforeSaveParam}} $object) { if (substr($object->getPath(), -1) == '/') { $object->setPath($object->getPath() . $object->getId()); $this->_savePath($object); } return parent::_afterSave($object); } /** * Update path field * * @access protected * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _savePath($object) { if ($object->getId()) { $this->_getWriteAdapter()->update( $this->getMainTable(), array('path' => $object->getPath()), array('entity_id = ?' => $object->getId()) ); } return $this; } /** * Get maximum position of child {{entitiesLabel}} by specific tree path * * @access protected * @param string $path * @return int * {{qwertyuiop}} */ protected function _getMaxPosition($path) { $adapter = $this->getReadConnection(); $positionField = $adapter->quoteIdentifier('position'); $level = count(explode('/', $path)); $bind = array( 'c_level' => $level, 'c_path' => $path . '/%' ); $select = $adapter->select() ->from($this->getMainTable(), 'MAX(' . $positionField . ')') ->where($adapter->quoteIdentifier('path') . ' LIKE :c_path') ->where($adapter->quoteIdentifier('level') . ' = :c_level'); $position = $adapter->fetchOne($select, $bind); if (!$position) { $position = 0; } return $position; } /** * Get children {{entitiesLabel}} count * * @access public * @param int ${{entity}}Id * @return int * {{qwertyuiop}} */ public function getChildrenCount(${{entity}}Id) { $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), 'children_count') ->where('entity_id = :entity_id'); $bind = array('entity_id' => ${{entity}}Id); return $this->_getReadAdapter()->fetchOne($select, $bind); } /** * Check if {{entityLabel}} id exist * * @access public * @param int $entityId * @return bool * {{qwertyuiop}} */ public function checkId($entityId) { $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), 'entity_id') ->where('entity_id = :entity_id'); $bind = array('entity_id' => $entityId); return $this->_getReadAdapter()->fetchOne($select, $bind); } /** * Check array of {{entitiesLabel}} identifiers * * @access public * @param array $ids * @return array * {{qwertyuiop}} */ public function verifyIds(array $ids) { if (empty($ids)) { return array(); } $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), 'entity_id') ->where('entity_id IN(?)', $ids); return $this->_getReadAdapter()->fetchCol($select); } /** * Get count of active/not active children {{entitiesLabel}} * * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param bool $isActiveFlag * @return int * {{qwertyuiop}} */ public function getChildrenAmount(${{entity}}, $isActiveFlag = true) { $bind = array( 'active_flag' => $isActiveFlag, 'c_path' => ${{entity}}->getPath() . '/%' ); $select = $this->_getReadAdapter()->select() ->from(array('m' => $this->getMainTable()), array('COUNT(m.entity_id)')) ->where('m.path LIKE :c_path') ->where('status' . ' = :active_flag'); return $this->_getReadAdapter()->fetchOne($select, $bind); } /** * Return parent {{entitiesLabel}} of {{entityLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return array * {{qwertyuiop}} */ public function getParent{{Entities}}(${{entity}}) { $pathIds = array_reverse(explode('/', ${{entity}}->getPath())); ${{entities}} = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_collection') ->addAttributeToFilter('entity_id', array('in' => $pathIds)) ->addAttributeToSelect('*'); return ${{entities}}; } /** * Return child {{entitiesLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function getChildren{{Entities}}(${{entity}}) { $collection = ${{entity}}->getCollection(); $collection ->addAttributeToFilter('status', 1) ->addIdFilter(${{entity}}->getChild{{Entities}}()) ->setOrder('position', Varien_Db_Select::SQL_ASC); return $collection; } /** * Return children ids of {{entityLabel}} * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param boolean $recursive * @return array * {{qwertyuiop}} */ public function getChildren(${{entity}}, $recursive = true) { $attributeId = (int)$this->_getStatusAttributeId(); $backendTable = $this->getTable(array($this->getEntityTablePrefix(), 'int')); $adapter = $this->_getReadAdapter(); $checkSql = $adapter->getCheckSql('c.value_id > 0', 'c.value', 'd.value'); $bind = array( 'attribute_id' => $attributeId, 'store_id' => ${{entity}}->getStoreId(), 'scope' => 1, 'c_path' => ${{entity}}->getPath() . '/%' ); $select = $this->_getReadAdapter()->select() ->from(array('m' => $this->getEntityTable()), 'entity_id') ->joinLeft( array('d' => $backendTable), 'd.attribute_id = :attribute_id AND d.store_id = 0 AND d.entity_id = m.entity_id', array() ) ->joinLeft( array('c' => $backendTable), 'c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.entity_id = m.entity_id', array() ) ->where($checkSql . ' = :scope') ->where($adapter->quoteIdentifier('path') . ' LIKE :c_path'); if (!$recursive) { $select->where($adapter->quoteIdentifier('level') . ' <= :c_level'); $bind['c_level'] = ${{entity}}->getLevel() + 1; } return $adapter->fetchCol($select, $bind); } protected $_statusAttributeId = null; /** * Get "is_active" attribute identifier * * @access protected * @return int * {{qwertyuiop}} */ protected function _getStatusAttributeId() { if ($this->_statusAttributeId === null) { $bind = array( '{{namespace}}_{{module}}_{{entity}}' => {{Namespace}}_{{Module}}_Model_{{Entity}}::ENTITY, 'status' => 'status', ); $select = $this->_getReadAdapter()->select() ->from(array('a'=>$this->getTable('eav/attribute')), array('attribute_id')) ->join(array('t'=>$this->getTable('eav/entity_type')), 'a.entity_type_id = t.entity_type_id') ->where('entity_type_code = :{{namespace}}_{{module}}_{{entity}}') ->where('attribute_code = :status'); $this->_statusAttributeId = $this->_getReadAdapter()->fetchOne($select, $bind); } return $this->_statusAttributeId; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/060_tree_before_save_no_url_rewrite ================================================ /** * Process {{entityLabel}} data before saving * prepare path and increment children count for parent {{entitiesLabel}} * * @access protected * @param Varien_Object $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _beforeSave({{beforeSaveParam}} $object) { parent::_beforeSave($object); if (!$object->getChildrenCount()) { $object->setChildrenCount(0); } if ($object->getLevel() === null) { $object->setLevel(1); } if (!$object->getId() && !$object->getInitialSetupFlag()) { $object->setPosition($this->_getMaxPosition($object->getPath()) + 1); $path = explode('/', $object->getPath()); $level = count($path); $object->setLevel($level); if ($level) { $object->setParentId($path[$level - 1]); } $object->setPath($object->getPath() . '/'); $toUpdateChild = explode('/', $object->getPath()); $this->_getWriteAdapter()->update( $this->getMainTable(), array('children_count' => new Zend_Db_Expr('children_count+1')), array('entity_id IN(?)' => $toUpdateChild) ); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/070_eav_tree_before_save_url_rewrite ================================================ /** * Process {{entityLabel}} data before saving * prepare path and increment children count for parent {{entitiesLabel}} * * @access protected * @param Varien_Object $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _beforeSave({{beforeSaveParam}} $object) { parent::_beforeSave($object); if (!$object->getChildrenCount()) { $object->setChildrenCount(0); } if ($object->getLevel() === null) { $object->setLevel(1); } if (!$object->getId() && !$object->getInitialSetupFlag()) { $object->setPosition($this->_getMaxPosition($object->getPath()) + 1); $path = explode('/', $object->getPath()); $level = count($path); $object->setLevel($level); if ($level) { $object->setParentId($path[$level - 1]); } $object->setPath($object->getPath() . '/'); $toUpdateChild = explode('/', $object->getPath()); $this->_getWriteAdapter()->update( $this->getMainTable(), array('children_count' => new Zend_Db_Expr('children_count+1')), array('entity_id IN(?)' => $toUpdateChild) ); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/080_tree_before_save_url_rewrite ================================================ /** * Process {{entityLabel}} data before saving * prepare path and increment children count for parent {{entitiesLabel}} * * @access protected * @param Varien_Object $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _beforeSave({{beforeSaveParam}} $object) { {{multipleSelectConvert}}if (!$object->getInitialSetupFlag()) { $urlKey = $object->getData('url_key'); if ($urlKey == '') { $urlKey = $object->get{{EntityNameMagicCode}}(); } $urlKey = $this->formatUrlKey($urlKey); $validKey = false; while (!$validKey) { $entityId = $this->checkUrlKey($urlKey, $object->getStoreId(), false); if ($entityId == $object->getId() || empty($entityId)) { $validKey = true; } else { $parts = explode('-', $urlKey); $last = $parts[count($parts) - 1]; if (!is_numeric($last)) { $urlKey = $urlKey.'-1'; } else { $suffix = '-'.($last + 1); unset($parts[count($parts) - 1]); $urlKey = implode('-', $parts).$suffix; } } } $object->setData('url_key', $urlKey); } parent::_beforeSave($object); if (!$object->getChildrenCount()) { $object->setChildrenCount(0); } if ($object->getLevel() === null) { $object->setLevel(1); } if (!$object->getId() && !$object->getInitialSetupFlag()) { $object->setPosition($this->_getMaxPosition($object->getPath()) + 1); $path = explode('/', $object->getPath()); $level = count($path); $object->setLevel($level); if ($level) { $object->setParentId($path[$level - 1]); } $object->setPath($object->getPath() . '/'); $toUpdateChild = explode('/', $object->getPath()); $this->_getWriteAdapter()->update( $this->getMainTable(), array('children_count' => new Zend_Db_Expr('children_count+1')), array('entity_id IN(?)' => $toUpdateChild) ); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/090_content ================================================ /** * Retrieve {{entitiesLabel}} * * @access public * @param integer $parent * @param integer $recursionLevel * @param boolean|string $sorted * @param boolean $asCollection * @param boolean $toLoad * @return Varien_Data_Tree_Node_Collection|{{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function get{{Entities}}( $parent, $recursionLevel = 0, $sorted = false, $asCollection = false, $toLoad = true ) { $tree = Mage::getResourceModel('{{namespace}}_{{module}}/{{entity}}_tree'); $nodes = $tree->loadNode($parent) ->loadChildren($recursionLevel) ->getChildren(); $tree->addCollectionData(null, $sorted, $parent, $toLoad, true); if ($asCollection) { return $tree->getCollection(); } return $nodes; } /** * Return all children ids of {{entity}} (with {{entity}} id) * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @return array * {{qwertyuiop}} */ public function getAllChildren(${{entity}}) { $children = $this->getChildren(${{entity}}); $myId = array(${{entity}}->getId()); $children = array_merge($myId, $children); return $children; } /** * Check {{entityLabel}} is forbidden to delete. * * @access public * @param integer ${{entity}}Id * @return boolean * {{qwertyuiop}} */ public function isForbiddenToDelete(${{entity}}Id) { return (${{entity}}Id == Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()); } /** * Get {{entityLabel}} path value by its id * * @access public * @param int ${{entity}}Id * @return string * {{qwertyuiop}} */ public function get{{Entity}}PathById(${{entity}}Id) { $select = $this->getReadConnection()->select() ->from($this->getMainTable(), array('path')) ->where('entity_id = :entity_id'); $bind = array('entity_id' => (int)${{entity}}Id); return $this->getReadConnection()->fetchOne($select, $bind); } /** * Move {{entityLabel}} to another parent node * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $newParent * @param null|int $after{{Entity}}Id * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ public function changeParent( {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}}, {{Namespace}}_{{Module}}_Model_{{Entity}} $newParent, $after{{Entity}}Id = null ) { $childrenCount = $this->getChildrenCount(${{entity}}->getId()) + 1; $table = $this->getMainTable(); $adapter = $this->_getWriteAdapter(); $levelFiled = $adapter->quoteIdentifier('level'); $pathField = $adapter->quoteIdentifier('path'); /** * Decrease children count for all old {{entityLabel}} parent {{entitiesLabel}} */ $adapter->update( $table, array('children_count' => new Zend_Db_Expr('children_count - ' . $childrenCount)), array('entity_id IN(?)' => ${{entity}}->getParentIds()) ); /** * Increase children count for new {{entityLabel}} parents */ $adapter->update( $table, array('children_count' => new Zend_Db_Expr('children_count + ' . $childrenCount)), array('entity_id IN(?)' => $newParent->getPathIds()) ); $position = $this->_processPositions(${{entity}}, $newParent, $after{{Entity}}Id); $newPath = sprintf('%s/%s', $newParent->getPath(), ${{entity}}->getId()); $newLevel = $newParent->getLevel() + 1; $levelDisposition = $newLevel - ${{entity}}->getLevel(); /** * Update children nodes path */ $adapter->update( $table, array( 'path' => new Zend_Db_Expr( 'REPLACE(' . $pathField . ','. $adapter->quote(${{entity}}->getPath() . '/'). ', '.$adapter->quote($newPath . '/').')' ), 'level' => new Zend_Db_Expr($levelFiled . ' + ' . $levelDisposition) ), array($pathField . ' LIKE ?' => ${{entity}}->getPath() . '/%') ); /** * Update moved {{entityLabel}} data */ $data = array( 'path' => $newPath, 'level' => $newLevel, 'position' =>$position, 'parent_id' =>$newParent->getId() ); $adapter->update($table, $data, array('entity_id = ?' => ${{entity}}->getId())); // Update {{entityLabel}} object to new data ${{entity}}->addData($data); return $this; } /** * Process positions of old parent {{entityLabel}} children and new parent {{entityLabel}} children. * Get position for moved {{entityLabel}} * * @access protected * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param {{Namespace}}_{{Module}}_Model_{{Entity}} $newParent * @param null|int $after{{Entity}}Id * @return int * {{qwertyuiop}} */ protected function _processPositions(${{entity}}, $newParent, $after{{Entity}}Id) { $table = $this->getMainTable(); $adapter= $this->_getWriteAdapter(); $positionField = $adapter->quoteIdentifier('position'); $bind = array( 'position' => new Zend_Db_Expr($positionField . ' - 1') ); $where = array( 'parent_id = ?' => ${{entity}}->getParentId(), $positionField . ' > ?' => ${{entity}}->getPosition() ); $adapter->update($table, $bind, $where); /** * Prepare position value */ if ($after{{Entity}}Id) { $select = $adapter->select() ->from($table, 'position') ->where('entity_id = :entity_id'); $position = $adapter->fetchOne($select, array('entity_id' => $after{{Entity}}Id)); $bind = array( 'position' => new Zend_Db_Expr($positionField . ' + 1') ); $where = array( 'parent_id = ?' => $newParent->getId(), $positionField . ' > ?' => $position ); $adapter->update($table, $bind, $where); } elseif ($after{{Entity}}Id !== null) { $position = 0; $bind = array( 'position' => new Zend_Db_Expr($positionField . ' + 1') ); $where = array( 'parent_id = ?' => $newParent->getId(), $positionField . ' > ?' => $position ); $adapter->update($table, $bind, $where); } else { $select = $adapter->select() ->from($table, array('position' => new Zend_Db_Expr('MIN(' . $positionField. ')'))) ->where('parent_id = :parent_id'); $position = $adapter->fetchOne($select, array('parent_id' => $newParent->getId())); } $position += 1; return $position; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/100_url_rewrite ================================================ /** * check url key * * @access public * @param string $urlKey * @param int $storeId * @param bool $active * @return mixed * {{qwertyuiop}} */ public function checkUrlKey($urlKey, $storeId, $active = true) { $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID, $storeId); $select = $this->_initCheckUrlKeySelect($urlKey, $stores); if ($active) { $select->where('e.status = ?', $active); } $select->reset(Zend_Db_Select::COLUMNS) ->columns('e.entity_id') ->limit(1); return $this->_getReadAdapter()->fetchOne($select); } /** * Check for unique URL key * * @access public * @param Mage_Core_Model_Abstract $object * @return bool * {{qwertyuiop}} */ public function getIsUniqueUrlKey(Mage_Core_Model_Abstract $object) { if (Mage::app()->isSingleStoreMode() || !$object->hasStores()) { $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID); } else { $stores = (array)$object->getData('stores'); } $select = $this->_initCheckUrlKeySelect($object->getData('url_key'), $stores); if ($object->getId()) { $select->where('e.entity_id <> ?', $object->getId()); } if ($this->_getWriteAdapter()->fetchRow($select)) { return false; } return true; } /** * Check if the URL key is numeric * * @access public * @param Mage_Core_Model_Abstract $object * @return bool * {{qwertyuiop}} */ protected function isNumericUrlKey(Mage_Core_Model_Abstract $object) { return preg_match('/^[0-9]+$/', $object->getData('url_key')); } /** * Check if the URL key is valid * * @access public * @param Mage_Core_Model_Abstract $object * @return bool * {{qwertyuiop}} */ protected function isValidUrlKey(Mage_Core_Model_Abstract $object) { return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('url_key')); } /** * format string as url key * * @access public * @param string $str * @return string * {{qwertyuiop}} */ public function formatUrlKey($str) { $urlKey = preg_replace('#[^0-9a-z]+#i', '-', Mage::helper('catalog/product_url')->format($str)); $urlKey = strtolower($urlKey); $urlKey = trim($urlKey, '-'); return $urlKey; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/103_url_rewrite_store ================================================ /** * init the check select * * @access protected * @param string $urlKey * @param array $store * @return Zend_Db_Select * {{qwertyuiop}} */ protected function _initCheckUrlKeySelect($urlKey, $store) { $select = $this->_getReadAdapter()->select() ->from(array('e' => $this->getMainTable())) ->join( array('es' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_store')), 'e.entity_id = es.{{entity}}_id', array()) ->where('e.url_key = ?', $urlKey) ->where('es.store_id IN (?)', $store); return $select; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/107_url_rewrite_no_store ================================================ /** * init the check select * * @access protected * @param string $urlKey * @param array $store * @return Zend_Db_Select * {{qwertyuiop}} */ protected function _initCheckUrlKeySelect($urlKey, $store) { $select = $this->_getReadAdapter()->select() ->from(array('e' => $this->getMainTable())) ->where('e.url_key = ?', $urlKey); return $select; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/110_url_rewrite_before_save_not_tree ================================================ /** * validate before saving * * @access protected * @param $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}} * {{qwertyuiop}} */ protected function _beforeSave(Mage_Core_Model_Abstract $object) { {{multipleSelectConvert}}$urlKey = $object->getData('url_key'); if ($urlKey == '') { $urlKey = $object->get{{EntityNameMagicCode}}(); } $urlKey = $this->formatUrlKey($urlKey); $validKey = false; while (!$validKey) { $entityId = $this->checkUrlKey($urlKey, $object->getStoreId(), false); if ($entityId == $object->getId() || empty($entityId)) { $validKey = true; } else { $parts = explode('-', $urlKey); $last = $parts[count($parts) - 1]; if (!is_numeric($last)) { $urlKey = $urlKey.'-1'; } else { $suffix = '-'.($last + 1); unset($parts[count($parts) - 1]); $urlKey = implode('-', $parts).$suffix; } } } $object->setData('url_key', $urlKey); return parent::_beforeSave($object); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/120_url_rewrite_eav ================================================ /** * check url key * * @access public * @param string $urlKey * @param bool $active * @return mixed * {{qwertyuiop}} */ public function checkUrlKey($urlKey, $storeId, $active = true) { $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID, $storeId); $select = $this->_initCheckUrlKeySelect($urlKey, $stores); if (!$select) { return false; } $select->reset(Zend_Db_Select::COLUMNS) ->columns('e.entity_id') ->limit(1); return $this->_getReadAdapter()->fetchOne($select); } /** * init the check select * * @access protected * @param string $urlKey * @param array $store * @return Zend_Db_Select * {{qwertyuiop}} */ protected function _initCheckUrlKeySelect($urlKey, $store) { $urlRewrite = Mage::getModel('eav/config')->getAttribute('{{namespace}}_{{module}}_{{entity}}', 'url_key'); if (!$urlRewrite || !$urlRewrite->getId()) { return false; } $table = $urlRewrite->getBackend()->getTable(); $select = $this->_getReadAdapter()->select() ->from(array('e' => $table)) ->where('e.attribute_id = ?', $urlRewrite->getId()) ->where('e.value = ?', $urlKey) ->where('e.store_id IN (?)', $store) ->order('e.store_id DESC'); return $select; } /** * Check for unique URL key * * @access public * @param Mage_Core_Model_Abstract $object * @return bool * {{qwertyuiop}} */ public function getIsUniqueUrlKey(Mage_Core_Model_Abstract $object) { if (Mage::app()->isSingleStoreMode() || !$object->hasStores()) { $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID); } else { $stores = (array)$object->getData('stores'); } $select = $this->_initCheckUrlKeySelect($object->getData('url_key'), $stores); if ($object->getId()) { $select->where('e.entity_id <> ?', $object->getId()); } if ($this->_getWriteAdapter()->fetchRow($select)) { return false; } return true; } /** * Check if the URL key is numeric * * @access public * @param Mage_Core_Model_Abstract $object * @return bool * {{qwertyuiop}} */ protected function isNumericUrlKey(Mage_Core_Model_Abstract $object) { return preg_match('/^[0-9]+$/', $object->getData('url_key')); } /** * Check if the URL key is valid * * @access public * @param Mage_Core_Model_Abstract $object * @return bool * {{qwertyuiop}} */ protected function isValidUrlKey(Mage_Core_Model_Abstract $object) { return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('url_key')); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/130_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Attribute/Collection/010_content ================================================ getSelect()->from(array('main_table' => $this->getResource()->getMainTable())) ->where( 'main_table.entity_type_id=?', Mage::getModel('eav/entity')->setType('{{namespace}}_{{module}}_{{entity}}')->getTypeId() ) ->join( array('additional_table' => $this->getTable('{{namespace}}_{{module}}/eav_attribute')), 'additional_table.attribute_id=main_table.attribute_id' ); return $this; } /** * set entity type filter * * @access public * @param string $typeId * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Attribute_Collection * {{qwertyuiop}} */ public function setEntityTypeFilter($typeId) { return $this; } /** * Specify filter by "is_visible" field * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Attribute_Collection * {{qwertyuiop}} */ public function addVisibleFilter() { return $this->addFieldToFilter('additional_table.is_visible', 1); } /** * Specify filter by "is_editable" field * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Attribute_Collection * {{qwertyuiop}} */ public function addEditableFilter() { return $this->addFieldToFilter('additional_table.is_editable', 1); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Category/010_top ================================================ _init('{{namespace}}_{{module}}/{{entity}}_category', 'rel_id'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Category/020_not_tree ================================================ /** * Save {{entityLabel}} - category relations * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Category * {{qwertyuiop}} */ public function save{{Entity}}Relation(${{entity}}, $data) { if (!is_array($data)) { $data = array(); } $deleteCondition = $this->_getWriteAdapter()->quoteInto('{{entity}}_id=?', ${{entity}}->getId()); $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition); foreach ($data as $categoryId) { if (!empty($categoryId)) { $insert = array( '{{entity}}_id' => ${{entity}}->getId(), 'category_id' => $categoryId, 'position' => 1 ); $this->_getWriteAdapter()->insertOnDuplicate($this->getMainTable(), $insert, array_keys($insert)); } } return $this; } /** * Save category - {{entityLabel}} relations * * @access public * @param Mage_Catalog_Model_Category $category * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Category * {{qwertyuiop}} */ public function saveCategoryRelation($category, $data) { if (!is_array($data)) { $data = array(); } $deleteCondition = $this->_getWriteAdapter()->quoteInto('category_id=?', $category->getId()); $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition); foreach ($data as ${{entity}}Id => $info) { $this->_getWriteAdapter()->insert( $this->getMainTable(), array( '{{entity}}_id' => ${{entity}}Id, 'category_id' => $category->getId(), 'position' => @$info['position'] ) ); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Category/030_tree ================================================ /** * Save {{entityLabel}} - category relations * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Category * {{qwertyuiop}} */ public function save{{Entity}}Relation(${{entity}}, $data) { if (!is_array($data)) { $data = array(); } $deleteCondition = $this->_getWriteAdapter()->quoteInto('{{entity}}_id=?', ${{entity}}->getId()); $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition); foreach ($data as $categoryId) { if (!empty($categoryId)) { $insert = array( '{{entity}}_id' => ${{entity}}->getId(), 'category_id' => $categoryId, 'position' => 1 ); $this->_getWriteAdapter()->insertOnDuplicate($this->getMainTable(), $insert, array_keys($insert)); } } return $this; } /** * Save category - {{entityLabel}} relations * * @access public * @param Mage_Catalog_Model_Category $category * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Category * {{qwertyuiop}} */ public function saveCategoryRelation($category, ${{entity}}Ids) { $old{{Entities}} = Mage::helper('{{namespace}}_{{module}}/category')->getSelected{{Entities}}($category); $old{{Entity}}Ids = array(); foreach ($old{{Entities}} as ${{entity}}) { $old{{Entity}}Ids[] = ${{entity}}->getId(); } $insert = array_diff(${{entity}}Ids, $old{{Entity}}Ids); $delete = array_diff($old{{Entity}}Ids, ${{entity}}Ids); $write = $this->_getWriteAdapter(); if (!empty($insert)) { $data = array(); foreach ($insert as ${{entity}}Id) { if (empty(${{entity}}Id)) { continue; } $data[] = array( '{{entity}}_id' => (int)${{entity}}Id, 'category_id' => (int)$category->getId(), 'position'=> 1 ); } if ($data) { $write->insertMultiple($this->getMainTable(), $data); } } if (!empty($delete)) { foreach ($delete as ${{entity}}Id) { $where = array( 'category_id = ?' => (int)$category->getId(), '{{entity}}_id = ?' => (int)${{entity}}Id, ); $write->delete($this->getMainTable(), $where); } } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Category/040_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Category/Collection/010_content ================================================ _joinedFields) { $this->getSelect()->join( array('related' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_category')), 'related.category_id = e.entity_id', array('position') ); $this->_joinedFields = true; } return $this; } /** * add {{entityLabel}} filter * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} | int ${{entity}} * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Category_Collection * {{qwertyuiop}} */ public function add{{Entity}}Filter(${{entity}}) { if (${{entity}} instanceof {{Namespace}}_{{Module}}_Model_{{Entity}}) { ${{entity}} = ${{entity}}->getId(); } if (!$this->_joinedFields) { $this->joinFields(); } $this->getSelect()->where('related.{{entity}}_id = ?', ${{entity}}); return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/010_top ================================================ _init('{{namespace}}_{{module}}/{{entity}}'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/020_top_store ================================================ $this->_map['fields']['store'] = 'store_table.store_id'; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/030_content ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/040_store ================================================ /** * Add filter by store * * @access public * @param int|Mage_Core_Model_Store $store * @param bool $withAdmin * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function addStoreFilter($store, $withAdmin = true) { if (!isset($this->_joinedFields['store'])) { if ($store instanceof Mage_Core_Model_Store) { $store = array($store->getId()); } if (!is_array($store)) { $store = array($store); } if ($withAdmin) { $store[] = Mage_Core_Model_App::ADMIN_STORE_ID; } $this->addFilter('store', array('in' => $store), 'public'); $this->_joinedFields['store'] = true; } return $this; } /** * Join store relation table if there is store filter * * @access protected * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ protected function _renderFiltersBefore() { if ($this->getFilter('store')) { $this->getSelect()->join( array('store_table' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_store')), 'main_table.entity_id = store_table.{{entity}}_id', array() ) ->group('main_table.entity_id'); /* * Allow analytic functions usage because of one field grouping */ $this->_useAnalyticFunction = true; } return parent::_renderFiltersBefore(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/050_tree ================================================ /** * Add Id filter * * @access public * @param array ${{entity}}Ids * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function addIdFilter(${{entity}}Ids) { if (is_array(${{entity}}Ids)) { if (empty(${{entity}}Ids)) { $condition = ''; } else { $condition = array('in' => ${{entity}}Ids); } } elseif (is_numeric(${{entity}}Ids)) { $condition = ${{entity}}Ids; } elseif (is_string(${{entity}}Ids)) { $ids = explode(',', ${{entity}}Ids); if (empty($ids)) { $condition = ${{entity}}Ids; } else { $condition = array('in' => $ids); } } $this->addFieldToFilter('entity_id', $condition); return $this; } /** * Add {{entityLabel}} path filter * * @access public * @param string $regexp * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function addPathFilter($regexp) { $this->addFieldToFilter('path', array('regexp' => $regexp)); return $this; } /** * Add {{entityLabel}} path filter * * @access public * @param array|string $paths * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function addPathsFilter($paths) { if (!is_array($paths)) { $paths = array($paths); } $write = $this->getResource()->getWriteConnection(); $cond = array(); foreach ($paths as $path) { $cond[] = $write->quoteInto('e.path LIKE ?', "$path%"); } if ($cond) { $this->getSelect()->where(join(' OR ', $cond)); } return $this; } /** * Add {{entityLabel}} level filter * * @access public * @param int|string $level * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function addLevelFilter($level) { $this->addFieldToFilter('level', array('lteq' => $level)); return $this; } /** * Add root {{entityLabel}} filter * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection */ public function addRootLevelFilter() { $this->addFieldToFilter('path', array('neq' => '1')); $this->addLevelFilter(1); return $this; } /** * Add order field * * @access public * @param string $field * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection */ public function addOrderField($field) { $this->setOrder($field, self::SORT_ORDER_ASC); return $this; } /** * Add active {{entityLabel}} filter * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection */ public function addStatusFilter($status = 1) { $this->addFieldToFilter('status', $status); return $this; } /** * get {{entitiesLabel}} as array * * @access protected * @param string $valueField * @param string $labelField * @param array $additional * @return array * {{qwertyuiop}} */ protected function _toOptionArray($valueField='entity_id', $labelField='{{nameAttributeCode}}', $additional=array()) { $res = array(); $additional['value'] = $valueField; $additional['label'] = $labelField; foreach ($this as $item) { if ($item->getId() == Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()) { continue; } foreach ($additional as $code => $field) { $data[$code] = $item->getData($field); } $res[] = $data; } return $res; } /** * get options hash * * @access protected * @param string $valueField * @param string $labelField * @return array * {{qwertyuiop}} */ protected function _toOptionHash($valueField='entity_id', $labelField='{{nameAttributeCode}}') { $res = array(); foreach ($this as $item) { if ($item->getId() == Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id()) { continue; } $res[$item->getData($valueField)] = $item->getData($labelField); } return $res; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/060_not_tree ================================================ /** * get {{entitiesLabel}} as array * * @access protected * @param string $valueField * @param string $labelField * @param array $additional * @return array * {{qwertyuiop}} */ protected function _toOptionArray($valueField='entity_id', $labelField='{{nameAttributeCode}}', $additional=array()) { {{toOptionAddition}}return parent::_toOptionArray($valueField, $labelField, $additional); } /** * get options hash * * @access protected * @param string $valueField * @param string $labelField * @return array * {{qwertyuiop}} */ protected function _toOptionHash($valueField='entity_id', $labelField='{{nameAttributeCode}}') { {{toOptionAddition}}return parent::_toOptionHash($valueField, $labelField); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/070_product_relation ================================================ /** * add the product filter to collection * * @access public * @param mixed (Mage_Catalog_Model_Product|int) $product * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function addProductFilter($product) { if ($product instanceof Mage_Catalog_Model_Product) { $product = $product->getId(); } if (!isset($this->_joinedFields['product'])) { $this->getSelect()->join( array('related_product' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_product')), 'related_product.{{entity}}_id = {{entityTableAlias}}.entity_id', array('position') ); $this->getSelect()->where('related_product.product_id = ?', $product); $this->_joinedFields['product'] = true; } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/080_category_relation ================================================ /** * add the category filter to collection * * @access public * @param mixed (Mage_Catalog_Model_Category|int) $category * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function addCategoryFilter($category) { if ($category instanceof Mage_Catalog_Model_Category) { $category = $category->getId(); } if (!isset($this->_joinedFields['category'])) { $this->getSelect()->join( array('related_category' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_category')), 'related_category.{{entity}}_id = {{entityTableAlias}}.entity_id', array('position') ); $this->getSelect()->where('related_category.category_id = ?', $category); $this->_joinedFields['category'] = true; } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/090_sibling_relation ================================================ /** * add the {{sibling}} filter to collection * * @access public * @param mixed ({{Namespace}}_{{Module}}_Model_{{Sibling}}|int) ${{sibling}} * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function add{{Sibling}}Filter(${{sibling}}) { if (${{sibling}} instanceof {{Namespace}}_{{Module}}_Model_{{Sibling}}) { ${{sibling}} = ${{sibling}}->getId(); } if (!isset($this->_joinedFields['{{sibling}}'])) { $this->getSelect()->join( array('related_{{sibling}}' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_{{sibling}}')), 'related_{{sibling}}.{{entity}}_id = {{entityTableAlias}}.entity_id', array('position') ); $this->getSelect()->where('related_{{sibling}}.{{sibling}}_id = ?', ${{sibling}}); $this->_joinedFields['{{sibling}}'] = true; } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Collection/100_footer ================================================ /** * Get SQL for get record count. * Extra GROUP BY strip added. * * @access public * @return Varien_Db_Select * {{qwertyuiop}} */ public function getSelectCountSql() { $countSelect = parent::getSelectCountSql(); $countSelect->reset(Zend_Db_Select::GROUP); return $countSelect; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/010_top ================================================ _init('{{namespace}}_{{module}}/{{entity}}_comment', 'comment_id'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/020_store ================================================ /** * Get store ids to which specified item is assigned * * @access public * @param int ${{entity}}Id * @return array * {{qwertyuiop}} */ public function lookupStoreIds($commentId) { $adapter = $this->_getReadAdapter(); $select = $adapter->select() ->from($this->getTable('{{namespace}}_{{module}}/{{entity}}_comment_store'), 'store_id') ->where('comment_id = ?', (int)$commentId); return $adapter->fetchCol($select); } /** * Perform operations after object load * * @access public * @param Mage_Core_Model_Abstract $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment * {{qwertyuiop}} */ protected function _afterLoad(Mage_Core_Model_Abstract $object) { if ($object->getId()) { $stores = $this->lookupStoreIds($object->getId()); $object->setData('store_id', $stores); } return parent::_afterLoad($object); } /** * Retrieve select object for load object data * * @param string $field * @param mixed $value * @param {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment $object * @return Zend_Db_Select */ protected function _getLoadSelect($field, $value, $object) { $select = parent::_getLoadSelect($field, $value, $object); if ($object->getStoreId()) { $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId()); $select->join( array('{{module}}_{{entity}}_comment_store' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_comment_store')), $this->getMainTable() . '.comment_id = {{module}}_{{entity}}_comment_store.comment_id', array() ) ->where('{{module}}_{{entity}}_comment_store.store_id IN (?)', $storeIds) ->order('{{module}}_{{entity}}_comment_store.store_id DESC') ->limit(1); } return $select; } /** * Assign {{entityLabel}} comments to store views * * @access protected * @param Mage_Core_Model_Abstract $object * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment * {{qwertyuiop}} */ protected function _afterSave(Mage_Core_Model_Abstract $object) { $oldStores = $this->lookupStoreIds($object->getId()); $newStores = (array)$object->getStores(); if (empty($newStores)) { $newStores = (array)$object->getStoreId(); } $table = $this->getTable('{{namespace}}_{{module}}/{{entity}}_comment_store'); $insert = array_diff($newStores, $oldStores); $delete = array_diff($oldStores, $newStores); if ($delete) { $where = array( 'comment_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete ); $this->_getWriteAdapter()->delete($table, $where); } if ($insert) { $data = array(); foreach ($insert as $storeId) { $data[] = array( 'comment_id' => (int) $object->getId(), 'store_id' => (int) $storeId ); } $this->_getWriteAdapter()->insertMultiple($table, $data); } return parent::_afterSave($object); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/030_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Collection/010_top ================================================ _init('{{namespace}}_{{module}}/{{entity}}_comment'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Collection/020_top_store ================================================ $this->_map['fields']['store'] = 'store_table.store_id'; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Collection/030_content ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Collection/040_store ================================================ /** * Add filter by store * * @access public * @param int|Mage_Core_Model_Store $store * @param bool $withAdmin * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_Collection * {{qwertyuiop}} */ public function addStoreFilter($store, $withAdmin = true) { if (!isset($this->_joinedFields['store'])) { if ($store instanceof Mage_Core_Model_Store) { $store = array($store->getId()); } if (!is_array($store)) { $store = array($store); } if ($withAdmin) { $store[] = Mage_Core_Model_App::ADMIN_STORE_ID; } $this->addFilter('store', array('in' => $store), 'public'); $this->_joinedFields['store'] = true; } return $this; } /** * Join store relation table if there is store filter * * @access protected * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_Collection * {{qwertyuiop}} */ protected function _renderFiltersBefore() { if ($this->getFilter('store')) { $this->getSelect()->join( array('store_table' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_comment_store')), 'main_table.comment_id = store_table.comment_id', array() ) ->group('main_table.comment_id'); /* * Allow analytic functions usage because of one field grouping */ $this->_useAnalyticFunction = true; } return parent::_renderFiltersBefore(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Collection/050_footer ================================================ /** * Get SQL for get record count. * Extra GROUP BY strip added. * * @access public * @return Varien_Db_Select * {{qwertyuiop}} */ public function getSelectCountSql() { $countSelect = parent::getSelectCountSql(); $countSelect->reset(Zend_Db_Select::GROUP); return $countSelect; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/010_top ================================================ _init('{{namespace}}_{{module}}/{{entity}}'); $this->_setIdFieldName('comment_id'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/040_construct_store ================================================ $this->_commentStoreTable = Mage::getSingleton('core/resource') ->getTableName('{{namespace}}_{{module}}/{{entity}}_comment_store'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/050_content ================================================ } /** * init select * * @access protected * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ protected function _initSelect() { parent::_initSelect(); $this->_joinFields(); return $this; } /** * Add customer filter * * @access public * @param int $customerId * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ public function addCustomerFilter($customerId) { $this->getSelect()->where('ct.customer_id = ?', $customerId); return $this; } /** * Add entity filter * * @access public * @param int $entityId * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ public function addEntityFilter($entityId) { $this->getSelect()->where('ct.{{entity}}_id = ?', $entityId); return $this; } /** * Add status filter * * @access public * @param mixed $status * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ public function addStatusFilter($status = 1) { $this->getSelect()->where('ct.status = ?', $status); return $this; } /** * Set date order * * @access public * @param string $dir * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ public function setDateOrder($dir = 'DESC') { $this->setOrder('ct.created_at', $dir); return $this; } /** * join fields to entity * * @access protected * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ protected function _joinFields() { $commentTable = Mage::getSingleton('core/resource') ->getTableName('{{namespace}}_{{module}}/{{entity}}_comment'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/060_eav_title ================================================ $this->addAttributeToSelect('{{nameAttributeCode}}'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/070_more_content ================================================ $this->getSelect()->join( array('ct' => $commentTable), 'ct.{{entity}}_id = {{entityTableAlias}}.entity_id', array( 'ct_title' => 'title', 'ct_comment_id' => 'comment_id', 'ct_name' => 'name', 'ct_status' => 'status', 'ct_email' => 'email', 'ct_created_at' => 'created_at', 'ct_updated_at' => 'updated_at' ) ); return $this; } /** * Retrieve all ids for collection * * @access public * @param mixed $limit * @param mixed $offset * @return array * {{qwertyuiop}} */ public function getAllIds($limit = null, $offset = null) { $idsSelect = clone $this->getSelect(); $idsSelect->reset(Zend_Db_Select::ORDER); $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT); $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET); $idsSelect->reset(Zend_Db_Select::COLUMNS); $idsSelect->columns('ct.comment_id'); return $this->getConnection()->fetchCol($idsSelect); } /** * Retrieves column values * * @access public * @param string $colName * @return array * {{qwertyuiop}} */ public function getColumnValues($colName) { $col = array(); foreach ($this->getItems() as $item) { $col[] = $item->getData($colName); } return $col; } /** * Render SQL for retrieve product count * * @access public * @return string * {{qwertyuiop}} */ public function getSelectCountSql() { $select = parent::getSelectCountSql(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/073_select_count_store ================================================ $this->_applyStoresFilterToSelect($select); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/075_select_sql ================================================ $select->reset(Zend_Db_Select::COLUMNS) ->columns('COUNT({{entityTableAlias}}.entity_id)') ->reset(Zend_Db_Select::HAVING); return $select; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/080_store_top ================================================ /** * Adds store filter into array * * @access public * @param mixed $storeId * @param bool $withAdmin * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ public function addStoreFilter($storeId = null, $withAdmin = true) { if (is_null($storeId)) { $storeId = $this->getStoreId(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/090_flat_store ================================================ parent::addStoreFilter($storeId, $withAdmin); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/100_store ================================================ if (!is_array($storeId)) { $storeId = array($storeId); } if (!empty($this->_storesIds)) { $this->_storesIds = array_intersect($this->_storesIds, $storeId); } else { $this->_storesIds = $storeId; } return $this; } /** * Adds specific store id into array * * @access public * @param array $storeId * @param bool $withAdmin * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ public function setStoreFilter($storeId, $withAdmin = false) { if (is_array($storeId) && isset($storeId['eq'])) { $storeId = array_shift($storeId); } if (!is_array($storeId)) { $storeId = array($storeId); } if (!empty($this->_storesIds)) { $this->_storesIds = array_intersect($this->_storesIds, $storeId); } else { $this->_storesIds = $storeId; } if ($withAdmin) { $this->_storesIds = array_merge($this->_storesIds, array(0)); } return $this; } /** * Applies all store filters in one place to prevent multiple joins in select * * @access protected * @param null|Zend_Db_Select $select * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ protected function _applyStoresFilterToSelect(Zend_Db_Select $select = null) { $adapter = $this->getConnection(); $storesIds = $this->_storesIds; if (is_null($select)) { $select = $this->getSelect(); } if (is_array($storesIds) && (count($storesIds) == 1)) { $storesIds = array_shift($storesIds); } if (is_array($storesIds) && !empty($storesIds)) { $inCond = $adapter->prepareSqlCondition('store.store_id', array('in' => $storesIds)); $select->join( array('store' => $this->_commentStoreTable), 'ct.comment_id=store.comment_id AND ' . $inCond, array() ) ->group('ct.comment_id'); $this->_useAnalyticFunction = true; } elseif (!empty($storesIds)) { $select->join( array('store' => $this->_commentStoreTable), $adapter->quoteInto('ct.comment_id=store.comment_id AND store.store_id = ?', (int)$storesIds), array() ); } return $this; } /** * Add stores data * * @access public * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ public function addStoreData() { $this->_addStoreDataFlag = true; return $this; } /** * Action after load * * @access protected * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ protected function _afterLoad() { parent::_afterLoad(); if ($this->_addStoreDataFlag) { $this->_addStoreData(); } return $this; } /** * Add store data * * @access protected * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ protected function _addStoreData() { $adapter = $this->getConnection(); $commentIds = $this->getColumnValues('ct_comment_id'); $storesToComments = array(); if (count($commentIds)>0) { $commentIdCondition = $this->_getConditionSql('comment_id', array('in' => $commentIds)); $select = $adapter->select() ->from($this->_commentStoreTable) ->where($commentIdCondition); $result = $adapter->fetchAll($select); foreach ($result as $row) { if (!isset($storesToComments[$row['comment_id']])) { $storesToComments[$row['comment_id']] = array(); } $storesToComments[$row['comment_id']][] = $row['store_id']; } } foreach ($this as $item) { if (isset($storesToComments[$item->getCtCommentId()])) { $item->setData('stores', $storesToComments[$item->getCtCommentId()]); } else { $item->setData('stores', array()); } } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/110_filter ================================================ /** * Add attribute to filter * * @access public * @param Mage_Eav_Model_Entity_Attribute_Abstract|string $attribute * @param array $condition * @param string $joinType * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Comment_{{Entity}}_Collection * {{qwertyuiop}} */ public function {{filterMethod}}($attribute, $condition = null, $joinType = 'inner') { switch($attribute) { case 'ct.comment_id': case 'ct.created_at': case 'ct.status': case 'ct.title': case 'ct.name': case 'ct.email': case 'ct.comment': case 'ct.updated_at': $conditionSql = $this->_getConditionSql($attribute, $condition); $this->getSelect()->where($conditionSql); break; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/120_store_filter ================================================ case 'stores': $this->setStoreFilter($condition); break; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Comment/Entity/Collection/130_footer ================================================ default: parent::{{filterMethod}}($attribute, $condition, $joinType); break; } return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Product/010_top ================================================ _init('{{namespace}}_{{module}}/{{entity}}_product', 'rel_id'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Product/020_not_tree ================================================ /** * Save {{entityLabel}} - product relations * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product * {{qwertyuiop}} */ public function save{{Entity}}Relation(${{entity}}, $data) { if (!is_array($data)) { $data = array(); } $deleteCondition = $this->_getWriteAdapter()->quoteInto('{{entity}}_id=?', ${{entity}}->getId()); $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition); foreach ($data as $productId => $info) { $this->_getWriteAdapter()->insert( $this->getMainTable(), array( '{{entity}}_id' => ${{entity}}->getId(), 'product_id' => $productId, 'position' => @$info['position'] ) ); } return $this; } /** * Save product - {{entityLabel}} relations * * @access public * @param Mage_Catalog_Model_Product $prooduct * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product * {{qwertyuiop}} */ public function saveProductRelation($product, $data) { if (!is_array($data)) { $data = array(); } $deleteCondition = $this->_getWriteAdapter()->quoteInto('product_id=?', $product->getId()); $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition); foreach ($data as ${{entity}}Id => $info) { $this->_getWriteAdapter()->insert( $this->getMainTable(), array( '{{entity}}_id' => ${{entity}}Id, 'product_id' => $product->getId(), 'position' => @$info['position'] ) ); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Product/030_tree ================================================ /** * Save {{entityLabel}} - product relations * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product * {{qwertyuiop}} */ public function save{{Entity}}Relation(${{entity}}, $data) { if (!is_array($data)) { $data = array(); } $deleteCondition = $this->_getWriteAdapter()->quoteInto('{{entity}}_id=?', ${{entity}}->getId()); $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition); foreach ($data as $productId => $info) { $this->_getWriteAdapter()->insert( $this->getMainTable(), array( '{{entity}}_id' => ${{entity}}->getId(), 'product_id' => $productId, 'position' => @$info['position'] ) ); } return $this; } /** * Save product - {{entityLabel}} relations * * @access public * @param Mage_Catalog_Model_Product $prooduct * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product * {{qwertyuiop}} */ public function saveProductRelation($product, ${{entity}}Ids) { $old{{Entities}} = Mage::helper('{{namespace}}_{{module}}/product')->getSelected{{Entities}}($product); $old{{Entity}}Ids = array(); foreach ($old{{Entities}} as ${{entity}}) { $old{{Entity}}Ids[] = ${{entity}}->getId(); } $insert = array_diff(${{entity}}Ids, $old{{Entity}}Ids); $delete = array_diff($old{{Entity}}Ids, ${{entity}}Ids); $write = $this->_getWriteAdapter(); if (!empty($insert)) { $data = array(); foreach ($insert as ${{entity}}Id) { if (empty(${{entity}}Id)) { continue; } $data[] = array( '{{entity}}_id' => (int)${{entity}}Id, 'product_id' => (int)$product->getId(), 'position'=> 1 ); } if ($data) { $write->insertMultiple($this->getMainTable(), $data); } } if (!empty($delete)) { foreach ($delete as ${{entity}}Id) { $where = array( 'product_id = ?' => (int)$product->getId(), '{{entity}}_id = ?' => (int)${{entity}}Id, ); $write->delete($this->getMainTable(), $where); } } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Product/040_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Product/Collection/010_content ================================================ _joinedFields) { $this->getSelect()->join( array('related' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_product')), 'related.product_id = e.entity_id', array('position') ); $this->_joinedFields = true; } return $this; } /** * add {{entityLabel}} filter * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} | int ${{entity}} * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Product_Collection * {{qwertyuiop}} */ public function add{{Entity}}Filter(${{entity}}) { if (${{entity}} instanceof {{Namespace}}_{{Module}}_Model_{{Entity}}) { ${{entity}} = ${{entity}}->getId(); } if (!$this->_joinedFields ) { $this->joinFields(); } $this->getSelect()->where('related.{{entity}}_id = ?', ${{entity}}); return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Sibling/010_top ================================================ _init('{{namespace}}_{{module}}/{{entity}}_{{sibling}}', 'rel_id'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Sibling/020_save_relation ================================================ /** * Save {{entityLabel}} - {{siblingLabel}} relations * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}} * {{qwertyuiop}} */ public function save{{Entity}}Relation(${{entity}}, $data) { if (!is_array($data)) { $data = array(); } $adapter = $this->_getWriteAdapter(); $bind = array( ':{{entity}}_id' => (int)${{entity}}->getId(), ); $select = $adapter->select() ->from($this->getMainTable(), array('rel_id', '{{sibling}}_id')) ->where('{{entity}}_id = :{{entity}}_id'); $related = $adapter->fetchPairs($select, $bind); $deleteIds = array(); foreach ($related as $relId => ${{sibling}}Id) { if (!isset($data[${{sibling}}Id])) { $deleteIds[] = (int)$relId; } } if (!empty($deleteIds)) { $adapter->delete( $this->getMainTable(), array('rel_id IN (?)' => $deleteIds) ); } foreach ($data as ${{sibling}}Id => $info) { $adapter->insertOnDuplicate( $this->getMainTable(), array( '{{entity}}_id' => ${{entity}}->getId(), '{{sibling}}_id' => ${{sibling}}Id, 'position' => @$info['position'] ), array('position') ); } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Sibling/030_save_relation_tree ================================================ /** * Save {{entityLabel}} - {{siblingLabel}} relations * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} ${{entity}} * @param array $data * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}} * {{qwertyuiop}} */ public function save{{Entity}}Relation(${{entity}}, ${{sibling}}Ids) { if (is_null(${{sibling}}Ids)) { return $this; } $old{{Siblings}} = ${{entity}}->getSelected{{Siblings}}(); $old{{Sibling}}Ids = array(); foreach ($old{{Siblings}} as ${{sibling}}) { $old{{Sibling}}Ids[] = ${{sibling}}->getId(); } $insert = array_diff(${{sibling}}Ids, $old{{Sibling}}Ids); $delete = array_diff($old{{Sibling}}Ids, ${{sibling}}Ids); $write = $this->_getWriteAdapter(); if (!empty($insert)) { $data = array(); foreach ($insert as ${{sibling}}Id) { if (empty(${{sibling}}Id)) { continue; } $data[] = array( '{{sibling}}_id' => (int)${{sibling}}Id, '{{entity}}_id' => (int)${{entity}}->getId(), 'position'=> 1 ); } if ($data) { $write->insertMultiple($this->getMainTable(), $data); } } if (!empty($delete)) { foreach ($delete as ${{sibling}}Id) { $where = array( '{{entity}}_id = ?' => (int)${{entity}}->getId(), '{{sibling}}_id = ?' => (int)${{sibling}}Id, ); $write->delete($this->getMainTable(), $where); } } return $this; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Sibling/040_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Sibling/Collection/010_content ================================================ _joinedFields) { $this->getSelect()->join( array('related' => $this->getTable('{{namespace}}_{{module}}/{{entity}}_{{sibling}}')), 'related.{{sibling}}_id = {{siblingTableAlias}}.entity_id', array('position') ); $this->_joinedFields = true; } return $this; } /** * add {{entity}} filter * * @access public * @param {{Namespace}}_{{Module}}_Model_{{Entity}} | int ${{entity}} * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_{{Sibling}}_Collection * {{qwertyuiop}} */ public function add{{Entity}}Filter(${{entity}}) { if (${{entity}} instanceof {{Namespace}}_{{Module}}_Model_{{Entity}}) { ${{entity}} = ${{entity}}->getId(); } if (!$this->_joinedFields) { $this->joinFields(); } $this->getSelect()->where('related.{{entity}}_id = ?', ${{entity}}); return $this; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Tree/010_top ================================================ getConnection('{{namespace}}_{{module}}_write'), $resource->getTableName('{{namespace}}_{{module}}/{{entity}}'), array( Varien_Data_Tree_Dbp::ID_FIELD => 'entity_id', Varien_Data_Tree_Dbp::PATH_FIELD => 'path', Varien_Data_Tree_Dbp::ORDER_FIELD => 'position', Varien_Data_Tree_Dbp::LEVEL_FIELD => 'level', ) ); } /** * Get {{entitiesLabel}} collection * * @access public * @param boolean $sorted * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection * {{qwertyuiop}} */ public function getCollection($sorted = false) { if (is_null($this->_collection)) { $this->_collection = $this->_getDefaultCollection($sorted); } return $this->_collection; } /** * set the collection * * @access public * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree */ public function setCollection($collection) { if (!is_null($this->_collection)) { destruct($this->_collection); } $this->_collection = $collection; return $this; } /** * get the default collection * * @access protected * @param boolean $sorted * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection */ protected function _getDefaultCollection($sorted = false) { $collection = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->getCollection(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Tree/020_eav ================================================ $collection->addAttributeToSelect('{{nameAttributeCode}}'); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Tree/030_content ================================================ if ($sorted) { if (is_string($sorted)) { $collection->setOrder($sorted); } else { $collection->setOrder('{{nameAttributeCode}}'); } } return $collection; } /** * Executing parents move method and cleaning cache after it * * @access public * @param unknown_type ${{entity}} * @param unknown_type $newParent * @param unknown_type $prevNode * {{qwertyuiop}} */ public function move(${{entity}}, $newParent, $prevNode = null) { Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}') ->move(${{entity}}->getId(), $newParent->getId()); parent::move(${{entity}}, $newParent, $prevNode); $this->_afterMove(${{entity}}, $newParent, $prevNode); } /** * Move tree after * * @access protected * @param unknown_type ${{entity}} * @param Varien_Data_Tree_Node $newParent * @param Varien_Data_Tree_Node $prevNode * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree */ protected function _afterMove(${{entity}}, $newParent, $prevNode) { Mage::app()->cleanCache(array({{Namespace}}_{{Module}}_Model_{{Entity}}::CACHE_TAG)); return $this; } /** * Load whole {{entityLabel}} tree, that will include specified {{entitiesLabel}} ids. * * @access public * @param array $ids * @param bool $addCollectionData * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree * {{qwertyuiop}} */ public function loadByIds($ids, $addCollectionData = true) { $levelField = $this->_conn->quoteIdentifier('level'); $pathField = $this->_conn->quoteIdentifier('path'); // load first two levels, if no ids specified if (empty($ids)) { $select = $this->_conn->select() ->from($this->_table, 'entity_id') ->where($levelField . ' <= 2'); $ids = $this->_conn->fetchCol($select); } if (!is_array($ids)) { $ids = array($ids); } foreach ($ids as $key => $id) { $ids[$key] = (int)$id; } // collect paths of specified IDs and prepare to collect all their parents and neighbours $select = $this->_conn->select() ->from($this->_table, array('path', 'level')) ->where('entity_id IN (?)', $ids); $where = array($levelField . '=0' => true); foreach ($this->_conn->fetchAll($select) as $item) { $pathIds = explode('/', $item['path']); $level = (int)$item['level']; while ($level > 0) { $pathIds[count($pathIds) - 1] = '%'; $path = implode('/', $pathIds); $where["$levelField=$level AND $pathField LIKE '$path'"] = true; array_pop($pathIds); $level--; } } $where = array_keys($where); // get all required records if ($addCollectionData) { $select = $this->_createCollectionDataSelect(); } else { $select = clone $this->_select; $select->order($this->_orderField . ' ' . Varien_Db_Select::SQL_ASC); } $select->where(implode(' OR ', $where)); // get array of records and add them as nodes to the tree $arrNodes = $this->_conn->fetchAll($select); if (!$arrNodes) { return false; } $childrenItems = array(); foreach ($arrNodes as $key => $nodeInfo) { $pathToParent = explode('/', $nodeInfo[$this->_pathField]); array_pop($pathToParent); $pathToParent = implode('/', $pathToParent); $childrenItems[$pathToParent][] = $nodeInfo; } $this->addChildNodes($childrenItems, '', null); return $this; } /** * Load array of {{entityLabel}} parents * * @access public * @param string $path * @param bool $addCollectionData * @param bool $withRootNode * @return array * {{qwertyuiop}} */ public function loadBreadcrumbsArray($path, $addCollectionData = true, $withRootNode = false) { $pathIds = explode('/', $path); if (!$withRootNode) { array_shift($pathIds); } $result = array(); if (!empty($pathIds)) { if ($addCollectionData) { $select = $this->_createCollectionDataSelect(false); } else { $select = clone $this->_select; } $select ->where('{{entityTableAlias}}.entity_id IN(?)', $pathIds) ->order($this->_conn->getLengthSql('{{entityTableAlias}}.path') . ' ' . Varien_Db_Select::SQL_ASC); $result = $this->_conn->fetchAll($select); } return $result; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Tree/040_flat_collection ================================================ /** * Obtain select for {{entitiesLabel}} * By default everything from entity table is selected * + name * * @access public * @param bool $sorted * @param array $optionalAttributes * @return Zend_Db_Select * {{qwertyuiop}} */ protected function _createCollectionDataSelect($sorted = true) { $select = $this->_getDefaultCollection($sorted ? $this->_orderField : false)->getSelect(); ${{entities}}Table = Mage::getSingleton('core/resource') ->getTableName('{{namespace}}_{{module}}/{{entity}}'); $subConcat = $this->_conn->getConcatSql(array('{{entityTableAlias}}.path', $this->_conn->quote('/%'))); $subSelect = $this->_conn->select() ->from(array('see' => ${{entities}}Table), null) ->where('see.entity_id = {{entityTableAlias}}.entity_id') ->orWhere('see.path LIKE ?', $subConcat); return $select; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Tree/050_eav_collection ================================================ /** * Obtain select for {{entitiesLabel}} with attributes. * By default everything from entity table is selected * + name, status * * @param bool $sorted * @param array $optionalAttributes * @return Zend_Db_Select * {{qwertyuiop}} */ protected function _createCollectionDataSelect($sorted = true, $optionalAttributes = array()) { $select = $this->_getDefaultCollection($sorted ? $this->_orderField : false) ->getSelect(); // add attributes to select $attributes = array('{{nameAttributeCode}}', 'status'); if ($optionalAttributes) { $attributes = array_unique(array_merge($attributes, $optionalAttributes)); } foreach ($attributes as $attributeCode) { /* @var $attribute Mage_Eav_Model_Entity_Attribute */ $attribute = Mage::getResourceSingleton('{{namespace}}_{{module}}/{{entity}}')->getAttribute($attributeCode); // join non-static attribute table if (!$attribute->getBackend()->isStatic()) { $tableDefault = sprintf('d_%s', $attributeCode); $tableStore = sprintf('s_%s', $attributeCode); $valueExpr = $this->_conn ->getCheckSql("{$tableStore}.value_id > 0", "{$tableStore}.value", "{$tableDefault}.value"); $select ->joinLeft( array($tableDefault => $attribute->getBackend()->getTable()), sprintf( '%1$s.entity_id=e.entity_id AND %1$s.attribute_id=%2$d'. ' AND %1$s.entity_type_id=e.entity_type_id AND %1$s.store_id=%3$d', $tableDefault, $attribute->getId(), Mage_Core_Model_App::ADMIN_STORE_ID ), array($attributeCode => 'value') ) ->joinLeft( array($tableStore => $attribute->getBackend()->getTable()), sprintf( '%1$s.entity_id=e.entity_id AND %1$s.attribute_id=%2$d'. ' AND %1$s.entity_type_id=e.entity_type_id AND %1$s.store_id=%3$d', $tableStore, $attribute->getId(), $this->getStoreId() ), array($attributeCode => $valueExpr) ); } } return $select; } /** * Set store Id * * @access public * @param integer $storeId * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree * {{qwertyuiop}} */ public function setStoreId($storeId) { $this->_storeId = $storeId; return $this; } /** * Return store id * * @access public * @return integer * {{qwertyuiop}} */ public function getStoreId() { if ($this->_storeId === null) { return Mage::app()->getStore()->getId(); } return $this->_storeId; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Entity/Tree/060_footer ================================================ /** * Get real existing {{entityLabel}} ids by specified ids * * @access public * @param array $ids * @return array * {{qwertyuiop}} */ public function getExisting{{Entity}}IdsBySpecifiedIds($ids) { if (empty($ids)) { return array(); } if (!is_array($ids)) { $ids = array($ids); } $select = $this->_conn->select() ->from($this->_table, array('entity_id')) ->where('entity_id IN (?)', $ids); return $this->_conn->fetchCol($select); } /** * add collection data * * @access public * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection * @param boolean $sorted * @param array $exclude * @param boolean $toLoad * @param boolean $onlyActive * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree * {{qwertyuiop}} */ public function addCollectionData( $collection = null, $sorted = false, $exclude = array(), $toLoad = true, $onlyActive = false ) { if (is_null($collection)) { $collection = $this->getCollection($sorted); } else { $this->setCollection($collection); } if (!is_array($exclude)) { $exclude = array($exclude); } $nodeIds = array(); foreach ($this->getNodes() as $node) { if (!in_array($node->getId(), $exclude)) { $nodeIds[] = $node->getId(); } } $collection->addIdFilter($nodeIds); if ($onlyActive) { $disabledIds = $this->_getDisabledIds($collection); if ($disabledIds) { $collection->{{filterMethod}}('entity_id', array('nin' => $disabledIds)); } $collection->{{filterMethod}}('status', 1); } if ($toLoad) { $collection->load(); foreach ($collection as ${{entity}}) { if ($this->getNodeById(${{entity}}->getId())) { $this->getNodeById(${{entity}}->getId())->addData(${{entity}}->getData()); } } foreach ($this->getNodes() as $node) { if (!$collection->getItemById($node->getId()) && $node->getParent()) { $this->removeNode($node); } } } return $this; } /** * Add inactive {{entitiesLabel}} ids * * @access public * @param unknown_type $ids * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree * {{qwertyuiop}} */ public function addInactive{{Entity}}Ids($ids) { if (!is_array($this->_inactive{{Entity}}Ids)) { $this->_initInactive{{Entity}}Ids(); } $this->_inactive{{Entity}}Ids = array_merge($ids, $this->_inactive{{Entity}}Ids); return $this; } /** * Retrieve inactive {{entitiesLabel}} ids * * @access protected * @return {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Tree * {{qwertyuiop}} */ protected function _initInactive{{Entity}}Ids() { $this->_inactive{{Entity}}Ids = array(); return $this; } /** * Retrieve inactive {{entitiesLabel}} ids * * @access public * @return array * {{qwertyuiop}} */ public function getInactive{{Entity}}Ids() { if (!is_array($this->_inactive{{Entity}}Ids)) { $this->_initInactive{{Entity}}Ids(); } return $this->_inactive{{Entity}}Ids; } /** * Return disable {{entityLabel}} ids * * @access protected * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection * @return array * {{qwertyuiop}} */ protected function _getDisabledIds($collection) { $this->_inactiveItems = $this->getInactive{{Entity}}Ids(); $this->_inactiveItems = array_merge( $this->_getInactiveItemIds($collection), $this->_inactiveItems ); $allIds = $collection->getAllIds(); $disabledIds = array(); foreach ($allIds as $id) { $parents = $this->getNodeById($id)->getPath(); foreach ($parents as $parent) { if (!$this->_getItemIsActive($parent->getId())) { $disabledIds[] = $id; continue; } } } return $disabledIds; } /** * Retrieve inactive {{entityLabel}} item ids * * @access protecte * @param {{Namespace}}_{{Module}}_Model_Resource_{{Entity}}_Collection $collection * @return array * {{qwertyuiop}} */ protected function _getInactiveItemIds($collection) { $filter = $collection->getAllIdsSql(); $table = Mage::getSingleton('core/resource')->getTable('{{namespace}}_{{module}}/{{entity}}'); $bind = array( 'cond' => 0, ); $select = $this->_conn->select() ->from(array('d'=>$table), array('d.entity_id')) ->where('d.entity_id IN (?)', new Zend_Db_Expr($filter)) ->where('status = :cond'); return $this->_conn->fetchCol($select, $bind); } /** * Check is {{entityLabel}} items active * * @access protecte * @param int $id * @return boolean * {{qwertyuiop}} */ protected function _getItemIsActive($id) { if (!in_array($id, $this->_inactiveItems)) { return true; } return false; } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Setup/010_top ================================================ '{{namespace}}_{{module}}/{{entity}}', 'attribute_model' => '{{namespace}}_{{module}}/resource_eav_attribute', 'table' => '{{namespace}}_{{module}}/{{entity}}', 'additional_attribute_table' => '{{namespace}}_{{module}}/eav_attribute', 'entity_attribute_collection' => '{{namespace}}_{{module}}/{{entity}}_attribute_collection', 'attributes' => array( {{entityAttributesSetup}} ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Setup/040_eav_footer ================================================ return $entities; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Resource/Setup/050_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/AttributeController/010_content ================================================ _entityTypeId = Mage::getModel('eav/entity') ->setType({{Namespace}}_{{Module}}_Model_{{Entity}}::ENTITY) ->getTypeId(); } /** * init action * * @accees protected * @return {{Namespace}}_{{Module}}_Adminhtml_{{Entity}}_AttributeController * {{qwertyuiop}} */ protected function _initAction() { $this->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}')) ->_title(Mage::helper('{{namespace}}_{{module}}')->__('Attributes')) ->_title(Mage::helper('{{namespace}}_{{module}}')->__('Manage Attributes')); $this->loadLayout() ->_setActiveMenu('{{selectedMenuPath}}_attributes') ->_addBreadcrumb( Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}'), Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}}') ) ->_addBreadcrumb( Mage::helper('{{namespace}}_{{module}}')->__('Manage {{EntityLabel}} Attributes'), Mage::helper('{{namespace}}_{{module}}')->__('Manage {{EntityLabel}} Attributes') ); return $this; } /** * default action * * @accees public * @return void * {{qwertyuiop}} */ public function indexAction() { $this->_initAction()->renderLayout(); } /** * add attribute action * * @accees public * @return void * {{qwertyuiop}} */ public function newAction() { $this->_forward('edit'); } /** * edit attribute action * * @accees public * @return void * {{qwertyuiop}} */ public function editAction() { $id = $this->getRequest()->getParam('attribute_id'); $model = Mage::getModel('{{namespace}}_{{module}}/resource_eav_attribute') ->setEntityTypeId($this->_entityTypeId); if ($id) { $model->load($id); if (! $model->getId()) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('This {{entityLabel}} attribute no longer exists') ); $this->_redirect('*/*/'); return; } // entity type check if ($model->getEntityTypeId() != $this->_entityTypeId) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('This {{entityLabel}} attribute cannot be edited.') ); $this->_redirect('*/*/'); return; } } // set entered data if was error when we do save $data = Mage::getSingleton('adminhtml/session')->getAttributeData(true); if (! empty($data)) { $model->addData($data); } Mage::register('entity_attribute', $model); $this->_initAction(); $this->_title($id ? $model->getName() : Mage::helper('{{namespace}}_{{module}}')->__('New {{EntityLabel}} Attribute')); $item = $id ? Mage::helper('{{namespace}}_{{module}}')->__('Edit {{EntityLabel}} Attribute') : Mage::helper('{{namespace}}_{{module}}')->__('New {{EntityLabel}} Attribute'); $this->_addBreadcrumb($item, $item); $this->renderLayout(); } /** * validate attribute action * * @accees public * @return void * {{qwertyuiop}} */ public function validateAction() { $response = new Varien_Object(); $response->setError(false); $attributeCode = $this->getRequest()->getParam('attribute_code'); $attributeId = $this->getRequest()->getParam('attribute_id'); $attribute = Mage::getModel('{{namespace}}_{{module}}/attribute') ->loadByCode($this->_entityTypeId, $attributeCode); if ($attribute->getId() && !$attributeId) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Attribute with the same code already exists') ); $this->_initLayoutMessages('adminhtml/session'); $response->setError(true); $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml()); } $this->getResponse()->setBody($response->toJson()); } /** * Filter post data * * @access protected * @param array $data * @return array * {{qwertyuiop}} */ protected function _filterPostData($data) { if ($data) { $helper = Mage::helper('{{namespace}}_{{module}}'); //labels foreach ($data['frontend_label'] as & $value) { if ($value) { $value = $helper->stripTags($value); } } //options if (!empty($data['option']['value'])) { foreach ($data['option']['value'] as &$options) { foreach ($options as &$label) { $label = $helper->stripTags($label); } } } //default value if (!empty($data['default_value'])) { $data['default_value'] = $helper->stripTags($data['default_value']); } if (!empty($data['default_value_text'])) { $data['default_value_text'] = $helper->stripTags($data['default_value_text']); } if (!empty($data['default_value_textarea'])) { $data['default_value_textarea'] = $helper->stripTags($data['default_value_textarea']); } } return $data; } /** * save attribute action * * @access public * @return void * {{qwertyuiop}} */ public function saveAction() { $data = $this->getRequest()->getPost(); if ($data) { $session = Mage::getSingleton('adminhtml/session'); $redirectBack = $this->getRequest()->getParam('back', false); $model = Mage::getModel('{{namespace}}_{{module}}/resource_eav_attribute'); $helper = Mage::helper('{{namespace}}_{{module}}/{{entity}}'); $id = $this->getRequest()->getParam('attribute_id'); //validate attribute_code if (isset($data['attribute_code'])) { $validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^[a-z_0-9]{1,255}$/')); if (!$validatorAttrCode->isValid($data['attribute_code'])) { $session->addError( Mage::helper('{{namespace}}_{{module}}')->__( 'Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.' ) ); $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true)); return; } } if ($id) { $model->load($id); if (!$model->getId()) { $session->addError( Mage::helper('{{namespace}}_{{module}}')->__('This attribute no longer exists') ); $this->_redirect('*/*/'); return; } // entity type check if ($model->getEntityTypeId() != $this->_entityTypeId) { $session->addError( Mage::helper('{{namespace}}_{{module}}')->__('This attribute cannot be updated.') ); $session->setAttributeData($data); $this->_redirect('*/*/'); return; } $data['attribute_code'] = $model->getAttributeCode(); $data['is_user_defined'] = $model->getIsUserDefined(); $data['frontend_input'] = $model->getFrontendInput(); } else { $data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']); $data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']); } if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) { $data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']); } $defaultValueField = $model->getDefaultValueByInput($data['frontend_input']); if ($defaultValueField) { $data['default_value'] = $this->getRequest()->getParam($defaultValueField); } //filter $data = $this->_filterPostData($data); $model->addData($data); if (!$id) { $model->setEntityTypeId($this->_entityTypeId); $model->setIsUserDefined(1); $model->setIsVisible(1); } try { $model->save(); $session->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('The {{entityLabel}} attribute has been saved.') ); /** * Clear translation cache because attribute labels are stored in translation */ Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG)); $session->setAttributeData(false); if ($redirectBack) { $this->_redirect('*/*/edit', array('attribute_id' => $model->getId(), '_current'=>true)); } else { $this->_redirect('*/*/', array()); } return; } catch (Exception $e) { $session->addError($e->getMessage()); $session->setAttributeData($data); $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true)); return; } } $this->_redirect('*/*/'); } /** * delete attribute action * * @access public * @return void * {{qwertyuiop}} */ public function deleteAction() { if ($id = $this->getRequest()->getParam('attribute_id')) { $model = Mage::getModel('{{namespace}}_{{module}}/resource_eav_attribute'); // entity type check $model->load($id); if ($model->getEntityTypeId() != $this->_entityTypeId) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('This attribute cannot be deleted.') ); $this->_redirect('*/*/'); return; } try { $model->delete(); Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('The {{entityLabel}} attribute has been deleted.') ); $this->_redirect('*/*/'); return; } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); $this->_redirect('*/*/edit', array('attribute_id' => $this->getRequest()->getParam('attribute_id'))); return; } } Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Unable to find an attribute to delete.') ); $this->_redirect('*/*/'); } /** * check access * * @access protected * @return bool * {{qwertyuiop}} */ protected function _isAllowed() { return Mage::getSingleton('admin/session')->isAllowed('{{selectedMenuPath}}_attributes'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/Catalog/CategoryController/010_top ================================================ setUsedModuleName('{{Namespace}}_{{Module}}'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/Catalog/CategoryController/020_not_tree ================================================ /** * {{entities}} grid in the catalog page * * @access public * @return void * {{qwertyuiop}} */ public function {{entities}}gridAction() { $this->_initCategory(); $this->loadLayout(); $this->getLayout()->getBlock('category.edit.tab.{{entity}}') ->setCategory{{Entities}}($this->getRequest()->getPost('category_{{entities}}', null)); $this->renderLayout(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/Catalog/CategoryController/030_tree ================================================ /** * get child {{entitiesLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function {{entities}}JsonAction() { $this->_initCategory(); $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_catalog_category_edit_{{entity}}') ->get{{Entity}}ChildrenJson($this->getRequest()->getParam('{{entity}}')) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/Catalog/CategoryController/040_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/Catalog/ProductController/010_top ================================================ setUsedModuleName('{{Namespace}}_{{Module}}'); } /** * {{entitiesLabel}} in the catalog page * * @access public * @return void * {{qwertyuiop}} */ public function {{entities}}Action() { $this->_initProduct(); $this->loadLayout(); $this->getLayout()->getBlock('product.edit.tab.{{entity}}') ->setProduct{{Entities}}($this->getRequest()->getPost('product_{{entities}}', null)); $this->renderLayout(); } /** * {{entitiesLabel}} grid in the catalog page * * @access public * @return void * {{qwertyuiop}} */ public function {{entities}}GridAction() { $this->_initProduct(); $this->loadLayout(); $this->getLayout()->getBlock('product.edit.tab.{{entity}}') ->setProduct{{Entities}}($this->getRequest()->getPost('product_{{entities}}', null)); $this->renderLayout(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/Catalog/ProductController/030_tree ================================================ /** * {{entitiesLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function {{entities}}Action() { $this->_initProduct(); $this->loadLayout(); $this->renderLayout(); } /** * {{entitiesLabel}} json action * * @access public * @return void * {{qwertyuiop}} */ public function {{entities}}JsonAction() { $product = $this->_initProduct(); $this->getResponse()->setBody( $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_catalog_product_edit_tab_{{entity}}' ) ->get{{Entity}}ChildrenJson($this->getRequest()->getParam('{{entity}}')) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/Catalog/ProductController/040_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/CommentController/010_content ================================================ getRequest()->getParam('id'); $comment = Mage::getModel('{{namespace}}_{{module}}/{{entity}}_comment'); if ($commentId) { $comment->load($commentId); } Mage::register('current_comment', $comment); return $comment; } /** * default action * * @access public * @return void * {{qwertyuiop}} */ public function indexAction() { $this->loadLayout(); $this->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{module_menu}}')) ->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}')) ->_title(Mage::helper('{{namespace}}_{{module}}')->__('Comments')); $this->renderLayout(); } /** * grid action * * @access public * @return void * {{qwertyuiop}} */ public function gridAction() { $this->loadLayout()->renderLayout(); } /** * edit comment - action * * @access public * @return void * {{qwertyuiop}} */ public function editAction() { $commentId = $this->getRequest()->getParam('id'); $comment = $this->_initComment(); if (!$comment->getId()) { $this->_getSession()->addError( Mage::helper('{{namespace}}_{{module}}')->__('This comment no longer exists.') ); $this->_redirect('*/*/'); return; } $data = Mage::getSingleton('adminhtml/session')->getFormData(true); if (!empty($data)) { $comment->setData($data); } Mage::register('comment_data', $comment); ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($comment->get{{Entity}}Id()); Mage::register('current_{{entity}}', ${{entity}}); $this->loadLayout(); $this->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{module_menu}}')) ->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}')) ->_title(Mage::helper('{{namespace}}_{{module}}')->__('Comments')) ->_title($comment->getTitle()); $this->renderLayout(); } /** * save {{entityLabel}} - action * * @access public * @return void * {{qwertyuiop}} */ public function saveAction() { if ($data = $this->getRequest()->getPost('comment')) { try { $comment = $this->_initComment(); $comment->addData($data); if (!$comment->getCustomerId()) { $comment->unsCustomerId(); } $comment->save(); Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('Comment was successfully saved') ); Mage::getSingleton('adminhtml/session')->setFormData(false); if ($this->getRequest()->getParam('back')) { $this->_redirect('*/*/edit', array('id' => $comment->getId())); return; } $this->_redirect('*/*/'); return; } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); Mage::getSingleton('adminhtml/session')->setFormData($data); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); return; } catch (Exception $e) { Mage::logException($e); Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was a problem saving the comment.') ); Mage::getSingleton('adminhtml/session')->setFormData($data); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); return; } } Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Unable to find comment to save.') ); $this->_redirect('*/*/'); } /** * delete comment - action * * @access public * @return void * {{qwertyuiop}} */ public function deleteAction() { if ( $this->getRequest()->getParam('id') > 0) { try { $comment = Mage::getModel('{{namespace}}_{{module}}/{{entity}}_comment'); $comment->setId($this->getRequest()->getParam('id'))->delete(); Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('Comment was successfully deleted.') ); $this->_redirect('*/*/'); return; } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); } catch (Exception $e) { Mage::logException($e); Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error deleting the comment.') ); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); return; } } Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Could not find comment to delete.') ); $this->_redirect('*/*/'); } /** * mass delete comments - action * * @access public * @return void * {{qwertyuiop}} */ public function massDeleteAction() { $commentIds = $this->getRequest()->getParam('comment'); if (!is_array($commentIds)) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Please select comments to delete.') ); } else { try { foreach ($commentIds as $commentId) { $comment = Mage::getModel('{{namespace}}_{{module}}/{{entity}}_comment'); $comment->setId($commentId)->delete(); } Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__( 'Total of %d comments were successfully deleted.', count($commentIds) ) ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::logException($e); Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error deleting comments.') ); } } $this->_redirect('*/*/index'); } /** * mass status change - action * * @access public * @return void * {{qwertyuiop}} */ public function massStatusAction() { $commentIds = $this->getRequest()->getParam('comment'); if (!is_array($commentIds)) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Please select comments.') ); } else { try { foreach ($commentIds as $commentId) { $comment = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}_comment')->load($commentId) ->setStatus($this->getRequest()->getParam('status')) ->setIsMassupdate(true) ->save(); } $this->_getSession()->addSuccess( $this->__('Total of %d comments were successfully updated.', count($commentIds)) ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error updating comments.') ); Mage::logException($e); } } $this->_redirect('*/*/index'); } /** * export as csv - action * * @access public * @return void * {{qwertyuiop}} */ public function exportCsvAction() { $fileName = '{{entity}}_comments.csv'; $content = $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_comment_grid' ) ->getCsv(); $this->_prepareDownloadResponse($fileName, $content); } /** * export as MsExcel - action * * @access public * @return void * {{qwertyuiop}} */ public function exportExcelAction() { $fileName = '{{entity}}_comments.xls'; $content = $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_comment_grid' ) ->getExcelFile(); $this->_prepareDownloadResponse($fileName, $content); } /** * export as xml - action * * @access public * @return void * {{qwertyuiop}} */ public function exportXmlAction() { $fileName = '{{entity}}_comments.xml'; $content = $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_comment_grid' ) ->getXml(); $this->_prepareDownloadResponse($fileName, $content); } /** * check access * * @access protected * @return bool * {{qwertyuiop}} */ protected function _isAllowed() { return Mage::getSingleton('admin/session')->isAllowed('{{selectedMenuPath}}_comments'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/WidgetController/010_top ================================================ getRequest()->getParam('uniq_id'); $grid = $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_widget_chooser', '', array( 'id' => $uniqId, ) ); $this->getResponse()->setBody($grid->toHtml()); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/WidgetController/020_tree ================================================ /** * {{entitiesLabel}} json action * * @access public * @return void * {{qwertyuiop}} */ public function {{entities}}JsonAction() { if (${{entity}}Id = (int) $this->getRequest()->getPost('id')) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id); if (${{entity}}->getId()) { Mage::register('{{entity}}', ${{entity}}); Mage::register('current_{{entity}}', ${{entity}}); } $this->getResponse()->setBody( $this->_get{{Entity}}TreeBlock()->getTreeJson(${{entity}}) ); } } /** * get {{entityLabel}} tree block * * @access protected * @return {{Namespace}}_{{Module}}_Block_Adminhtml_{{Entity}}_Widget_Chooser * {{qwertyuiop}} */ protected function _get{{Entity}}TreeBlock() { return $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_widget_chooser', '', array( 'id' => $this->getRequest()->getParam('uniq_id'), 'use_massaction' => $this->getRequest()->getParam('use_massaction', false) ) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/Entity/WidgetController/030_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/010_top ================================================ setUsedModuleName('{{Namespace}}_{{Module}}'); } /** * init the {{entityLabel}} * * @access protected * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ protected function _init{{Entity}}() { $this->_title($this->__('{{module_menu}}')) ->_title($this->__('Manage {{EntitiesLabel}}')); ${{entity}}Id = (int) $this->getRequest()->getParam('id'); ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}') ->setStoreId($this->getRequest()->getParam('store', 0)); if (${{entity}}Id) { ${{entity}}->load(${{entity}}Id); } Mage::register('current_{{entity}}', ${{entity}}); return ${{entity}}; } /** * default action for {{entity}} controller * * @access public * @return void * {{qwertyuiop}} */ public function indexAction() { $this->_title($this->__('{{module_menu}}')) ->_title($this->__('Manage {{EntitiesLabel}}')); $this->loadLayout(); $this->renderLayout(); } /** * new {{entity}} action * * @access public * @return void * {{qwertyuiop}} */ public function newAction() { $this->_forward('edit'); } /** * edit {{entity}} action * * @access public * @return void * {{qwertyuiop}} */ public function editAction() { ${{entity}}Id = (int) $this->getRequest()->getParam('id'); ${{entity}} = $this->_init{{Entity}}(); if (${{entity}}Id && !${{entity}}->getId()) { $this->_getSession()->addError( Mage::helper('{{namespace}}_{{module}}')->__('This {{entityLabel}} no longer exists.') ); $this->_redirect('*/*/'); return; } if ($data = Mage::getSingleton('adminhtml/session')->get{{Entity}}Data(true)) { ${{entity}}->setData($data); } $this->_title(${{entity}}->get{{EntityNameMagicCode}}()); Mage::dispatchEvent( '{{namespace}}_{{module}}_{{entity}}_edit_action', array('{{entity}}' => ${{entity}}) ); $this->loadLayout(); if (${{entity}}->getId()) { if (!Mage::app()->isSingleStoreMode() && ($switchBlock = $this->getLayout()->getBlock('store_switcher'))) { $switchBlock->setDefaultStoreName(Mage::helper('{{namespace}}_{{module}}')->__('Default Values')) ->setWebsiteIds(${{entity}}->getWebsiteIds()) ->setSwitchUrl( $this->getUrl( '*/*/*', array( '_current'=>true, 'active_tab'=>null, 'tab' => null, 'store'=>null ) ) ); } } else { $this->getLayout()->getBlock('left')->unsetChild('store_switcher'); } $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $this->renderLayout(); } /** * save {{entityLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function saveAction() { $storeId = $this->getRequest()->getParam('store'); $redirectBack = $this->getRequest()->getParam('back', false); ${{entity}}Id = $this->getRequest()->getParam('id'); $isEdit = (int)($this->getRequest()->getParam('id') != null); $data = $this->getRequest()->getPost(); if ($data) { ${{entity}} = $this->_init{{Entity}}(); ${{entity}}Data = $this->getRequest()->getPost('{{entity}}', array()); ${{entity}}->addData(${{entity}}Data); ${{entity}}->setAttributeSetId(${{entity}}->getDefaultAttributeSetId()); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/020_save_product_relation ================================================ $products = $this->getRequest()->getPost('products', -1); if ($products != -1) { ${{entity}}->setProductsData( Mage::helper('adminhtml/js')->decodeGridSerializedInput($products) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/030_save_category_relation ================================================ $categories = $this->getRequest()->getPost('category_ids', -1); if ($categories != -1) { $categories = explode(',', $categories); $categories = array_unique($categories); ${{entity}}->setCategoriesData($categories); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/040_sibling_save ================================================ if (isset($data['{{siblings}}'])) { ${{entity}}->set{{Siblings}}Data( Mage::helper('adminhtml/js')->decodeGridSerializedInput($data['{{siblings}}']) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/045_sibling_save_tree ================================================ ${{siblings}} = $this->getRequest()->getPost('{{sibling}}_ids', -1); if (${{siblings}} != -1) { ${{siblings}} = explode(',', ${{siblings}}); ${{siblings}} = array_unique(${{siblings}}); ${{entity}}->set{{Siblings}}Data(${{siblings}}); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/050_middle ================================================ if ($useDefaults = $this->getRequest()->getPost('use_default')) { foreach ($useDefaults as $attributeCode) { ${{entity}}->setData($attributeCode, false); } } try { ${{entity}}->save(); ${{entity}}Id = ${{entity}}->getId(); $this->_getSession()->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} was saved') ); } catch (Mage_Core_Exception $e) { Mage::logException($e); $this->_getSession()->addError($e->getMessage()) ->set{{Entity}}Data(${{entity}}Data); $redirectBack = true; } catch (Exception $e) { Mage::logException($e); $this->_getSession()->addError( Mage::helper('{{namespace}}_{{module}}')->__('Error saving {{entityLabel}}') ) ->set{{Entity}}Data(${{entity}}Data); $redirectBack = true; } } if ($redirectBack) { $this->_redirect( '*/*/edit', array( 'id' => ${{entity}}Id, '_current'=>true ) ); } else { $this->_redirect('*/*/', array('store'=>$storeId)); } } /** * delete {{entityLabel}} * * @access public * @return void * {{qwertyuiop}} */ public function deleteAction() { if ($id = $this->getRequest()->getParam('id')) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($id); try { ${{entity}}->delete(); $this->_getSession()->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('The {{entitiesLabel}} has been deleted.') ); } catch (Exception $e) { $this->_getSession()->addError($e->getMessage()); } } $this->getResponse()->setRedirect( $this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store'))) ); } /** * mass delete {{entitiesLabel}} * * @access public * @return void * {{qwertyuiop}} */ public function massDeleteAction() { ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}'); if (!is_array(${{entity}}Ids)) { $this->_getSession()->addError($this->__('Please select {{entitiesLabel}}.')); } else { try { foreach (${{entity}}Ids as ${{entity}}Id) { ${{entity}} = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id); Mage::dispatchEvent( '{{namespace}}_{{module}}_controller_{{entity}}_delete', array('{{entity}}' => ${{entity}}) ); ${{entity}}->delete(); } $this->_getSession()->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('Total of %d record(s) have been deleted.', count(${{entity}}Ids)) ); } catch (Exception $e) { $this->_getSession()->addError($e->getMessage()); } } $this->_redirect('*/*/index'); } /** * mass status change - action * * @access public * @return void * {{qwertyuiop}} */ public function massStatusAction() { ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}'); if (!is_array(${{entity}}Ids)) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Please select {{entitiesLabel}}.') ); } else { try { foreach (${{entity}}Ids as ${{entity}}Id) { ${{entity}} = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id) ->setStatus($this->getRequest()->getParam('status')) ->setIsMassupdate(true) ->save(); } $this->_getSession()->addSuccess( $this->__('Total of %d {{entitiesLabel}} were successfully updated.', count(${{entity}}Ids)) ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error updating {{entitiesLabel}}.') ); Mage::logException($e); } } $this->_redirect('*/*/index'); } /** * grid action * * @access public * @return void * {{qwertyuiop}} */ public function gridAction() { $this->loadLayout(); $this->renderLayout(); } /** * restrict access * * @access protected * @return bool * @see Mage_Adminhtml_Controller_Action::_isAllowed() * {{qwertyuiop}} */ protected function _isAllowed() { return Mage::getSingleton('admin/session')->isAllowed('{{selectedMenuPath}}'); } /** * Export {{entities}} in CSV format * * @access public * @return void * {{qwertyuiop}} */ public function exportCsvAction() { $fileName = '{{entities}}.csv'; $content = $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_grid') ->getCsvFile(); $this->_prepareDownloadResponse($fileName, $content); } /** * Export {{entitiesLabel}} in Excel format * * @access public * @return void * {{qwertyuiop}} */ public function exportExcelAction() { $fileName = '{{entity}}.xls'; $content = $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_grid') ->getExcelFile(); $this->_prepareDownloadResponse($fileName, $content); } /** * Export {{entitiesLabel}} in XML format * * @access public * @return void * {{qwertyuiop}} */ public function exportXmlAction() { $fileName = '{{entity}}.xml'; $content = $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_grid') ->getXml(); $this->_prepareDownloadResponse($fileName, $content); } /** * wysiwyg editor action * * @access public * @return void * {{qwertyuiop}} */ public function wysiwygAction() { $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); $storeId = $this->getRequest()->getParam('store_id', 0); $storeMediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); $content = $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{module}}_helper_form_wysiwyg_content', '', array( 'editor_element_id' => $elementId, 'store_id' => $storeId, 'store_media_url' => $storeMediaUrl, ) ); $this->getResponse()->setBody($content->toHtml()); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/060_mass_action ================================================ /** * mass {{attributeLabel}} change * * @access public * @return void * {{qwertyuiop}} */ public function mass{{AttributeMagicCode}}Action() { ${{entity}}Ids = (array)$this->getRequest()->getParam('{{entity}}'); $storeId = (int)$this->getRequest()->getParam('store', 0); $flag = (int)$this->getRequest()->getParam('flag_{{attributeCode}}'); if ($flag == 2) { $flag = 0; } try { foreach (${{entity}}Ids as ${{entity}}Id) { ${{entity}} = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}') ->setStoreId($storeId) ->load(${{entity}}Id); ${{entity}}->set{{AttributeMagicCode}}($flag)->save(); } $this->_getSession()->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('Total of %d record(s) have been updated.', count(${{entity}}Ids)) ); } catch (Mage_Core_Model_Exception $e) { $this->_getSession()->addError($e->getMessage()); } catch (Mage_Core_Exception $e) { $this->_getSession()->addError($e->getMessage()); } catch (Exception $e) { $this->_getSession()->addException( $e, Mage::helper('{{namespace}}_{{module}}')->__('An error occurred while updating the {{entitiesLabel}}.') ); } $this->_redirect('*/*/', array('store'=> $storeId)); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/065_mass_parents ================================================ /** * mass {{siblingLabel}} change - action * * @access public * @return void * {{qwertyuiop}} */ public function mass{{Sibling}}IdAction() { ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}'); if (!is_array(${{entity}}Ids)) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Please select {{entitiesLabel}}.') ); } else { try { foreach (${{entity}}Ids as ${{entity}}Id) { ${{entity}} = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id) ->set{{Sibling}}Id($this->getRequest()->getParam('flag_{{sibling}}_id')) ->setIsMassupdate(true) ->save(); } $this->_getSession()->addSuccess( $this->__('Total of %d {{entitiesLabel}} were successfully updated.', count(${{entity}}Ids)) ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error updating {{entitiesLabel}}.') ); Mage::logException($e); } } $this->_redirect('*/*/index'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/070_product_relation_actions ================================================ /** * get grid of products action * * @access public * @return void * {{qwertyuiop}} */ public function productsAction() { $this->_init{{Entity}}(); $this->loadLayout(); $this->getLayout()->getBlock('{{entity}}.edit.tab.product') ->set{{Entity}}Products($this->getRequest()->getPost('{{entity}}_products', null)); $this->renderLayout(); } /** * get grid of products action * * @access public * @return void * {{qwertyuiop}} */ public function productsgridAction() { $this->_init{{Entity}}(); $this->loadLayout(); $this->getLayout()->getBlock('{{entity}}.edit.tab.product') ->set{{Entity}}Products($this->getRequest()->getPost('{{entity}}_products', null)); $this->renderLayout(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/080_category_relation_actions ================================================ /** * get categories action * * @access public * @return void * {{qwertyuiop}} */ public function categoriesAction() { $this->_init{{Entity}}(); $this->loadLayout(); $this->renderLayout(); } /** * get child categories action * * @access public * @return void * {{qwertyuiop}} */ public function categoriesJsonAction() { $this->_init{{Entity}}(); $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_categories') ->getCategoryChildrenJson($this->getRequest()->getParam('category')) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/090_sibling_grid ================================================ /** * {{siblingsLabel}} on the current {{entityLabel}} * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}Action() { $this->_init{{Entity}}(); $this->loadLayout(); $this->getLayout()->getBlock('{{namespace}}_{{module}}.{{entity}}.edit.tab.{{sibling}}') ->set{{Entity}}{{Siblings}}($this->getRequest()->getPost('{{siblings}}', null)); $this->renderLayout(); } /** * {{siblingsLabel}} on the current {{entityLabel}} * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}GridAction() { $this->_init{{Entity}}(); $this->loadLayout(); $this->getLayout()->getBlock('{{namespace}}_{{module}}.{{entity}}.edit.tab.{{sibling}}') ->set{{Entity}}{{Siblings}}($this->getRequest()->getPost('{{siblings}}', null)); $this->renderLayout(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/100_sibling_actions_tree ================================================ /** * get {{siblingsLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}Action() { $this->_init{{Entity}}(); $this->loadLayout(); $this->renderLayout(); } /** * get child {{siblingsLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}JsonAction() { $this->_init{{Entity}}(); $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_{{sibling}}') ->get{{Sibling}}ChildrenJson($this->getRequest()->getParam('{{sibling}}')) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavNotTree/110_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/010_top ================================================ _title($this->__('{{module_menu}}')) ->_title($this->__('Manage {{EntitiesLabel}}')); ${{entity}}Id = (int) $this->getRequest()->getParam('id', false); $storeId = (int) $this->getRequest()->getParam('store'); ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}'); ${{entity}}->setStoreId($storeId); if (${{entity}}Id) { ${{entity}}->load(${{entity}}Id); if ($storeId) { $rootId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); if (!in_array($rootId, ${{entity}}->getPathIds())) { // load root {{entityLabel}} instead wrong one if ($getRootInstead) { ${{entity}}->load($rootId); } else { $this->_redirect('*/*/', array('_current'=>true, 'id'=>null)); return false; } } } } if ($activeTabId = (string) $this->getRequest()->getParam('active_tab_id')) { Mage::getSingleton('admin/session')->set{{Entity}}ActiveTabId($activeTabId); } Mage::register('{{entity}}', ${{entity}}); Mage::register('current_{{entity}}', ${{entity}}); Mage::getSingleton('cms/wysiwyg_config')->setStoreId($this->getRequest()->getParam('store')); return ${{entity}}; } /** * index action * * @access public * {{qwertyuiop}} */ public function indexAction() { $this->_forward('edit'); } /** * Add new {{entityLabel}} form * * @access public * {{qwertyuiop}} */ public function addAction() { Mage::getSingleton('admin/session')->uns{{Entity}}ActiveTabId(); $this->_forward('edit'); } /** * Edit {{entityLabel}} page * * @access public * {{qwertyuiop}} */ public function editAction() { $params['_current'] = true; $redirect = false; $storeId = (int) $this->getRequest()->getParam('store'); $parentId = (int) $this->getRequest()->getParam('parent'); $_prevStoreId = Mage::getSingleton('admin/session') ->get{{Entity}}LastViewedStore(true); if (!empty($_prevStoreId) && !$this->getRequest()->getQuery('isAjax')) { $params['store'] = $_prevStoreId; $redirect = true; } ${{entity}}Id = (int) $this->getRequest()->getParam('id'); $_prev{{Entity}}Id = Mage::getSingleton('admin/session') ->getLastEdited{{Entity}}(true); if ($_prev{{Entity}}Id && !$this->getRequest()->getQuery('isAjax') && !$this->getRequest()->getParam('clear')) { $this->getRequest()->setParam('id', $_prev{{Entity}}Id); } if ($redirect) { $this->_redirect('*/*/edit', $params); return; } if ($storeId && !${{entity}}Id && !$parentId) { $store = Mage::app()->getStore($storeId); $_prev{{Entity}}Id = (int)Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); $this->getRequest()->setParam('id', $_prev{{Entity}}Id); } if (!(${{entity}} = $this->_init{{Entity}}())) { return; } $this->_title(${{entity}}Id ? ${{entity}}->getName() : $this->__('New {{EntityLabel}}')); $data = Mage::getSingleton('adminhtml/session')->get{{Entity}}Data(true); if (isset($data['{{entity}}'])) { ${{entity}}->addData($data['{{entity}}']); } /** * Build response for ajax request */ if ($this->getRequest()->getQuery('isAjax')) { $breadcrumbsPath = ${{entity}}->getPath(); if (empty($breadcrumbsPath)) { $breadcrumbsPath = Mage::getSingleton('admin/session')->get{{Entity}}DeletedPath(true); if (!empty($breadcrumbsPath)) { $breadcrumbsPath = explode('/', $breadcrumbsPath); if (count($breadcrumbsPath) <= 1) { $breadcrumbsPath = ''; } else { array_pop($breadcrumbsPath); $breadcrumbsPath = implode('/', $breadcrumbsPath); } } } Mage::getSingleton('admin/session') ->set{{Entity}}LastViewedStore($this->getRequest()->getParam('store')); Mage::getSingleton('admin/session') ->setLastEdited{{Entity}}(${{entity}}->getId()); $this->loadLayout(); $eventResponse = new Varien_Object( array( 'content' => $this->getLayout()->getBlock('{{entity}}.edit')->getFormHtml() . $this->getLayout()->getBlock('{{entity}}.tree') ->getBreadcrumbsJavascript($breadcrumbsPath, 'editing{{Entity}}Breadcrumbs'), 'messages' => $this->getLayout()->getMessagesBlock()->getGroupedHtml(), ) ); Mage::dispatchEvent( '{{entity}}_prepare_ajax_response', array( 'response' => $eventResponse, 'controller' => $this ) ); $this->getResponse()->setBody( Mage::helper('core')->jsonEncode($eventResponse->getData()) ); return; } $this->loadLayout(); $this->_setActiveMenu('{{selectedMenuPath}}'); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true) ->setContainerCssClass('{{entities}}'); $this->_addBreadcrumb( Mage::helper('{{namespace}}_{{module}}')->__('Manage {{EntitiesLabel}}'), Mage::helper('catalog')->__('Manage {{EntitiesLabel}}') ); $block = $this->getLayout()->getBlock('catalog.wysiwyg.js'); if ($block) { $block->setStoreId($storeId); } $this->renderLayout(); } /** * WYSIWYG editor action for ajax request * * @access public * {{qwertyuiop}} */ public function wysiwygAction() { $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); $storeId = $this->getRequest()->getParam('store_id', 0); $storeMediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); $content = $this->getLayout()->createBlock( 'adminhtml/catalog_helper_form_wysiwyg_content', '', array( 'editor_element_id' => $elementId, 'store_id' => $storeId, 'store_media_url' => $storeMediaUrl, ) ); $this->getResponse()->setBody($content->toHtml()); } /** * Get tree node (Ajax version) * * @access public * {{qwertyuiop}} */ public function {{entities}}JsonAction() { if ($this->getRequest()->getParam('expand_all')) { Mage::getSingleton('admin/session')->set{{Entity}}IsTreeWasExpanded(true); } else { Mage::getSingleton('admin/session')->set{{Entity}}IsTreeWasExpanded(false); } if (${{entity}}Id = (int) $this->getRequest()->getPost('id')) { $this->getRequest()->setParam('id', ${{entity}}Id); if (!${{entity}} = $this->_init{{Entity}}()) { return; } $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_tree') ->getTreeJson(${{entity}}) ); } } /** * {{EntityLabel}} save * * @access public * {{qwertyuiop}} */ public function saveAction() { if (!${{entity}} = $this->_init{{Entity}}()) { return; } $storeId = $this->getRequest()->getParam('store'); $refreshTree = 'false'; if ($data = $this->getRequest()->getPost()) { ${{entity}}->addData($data['{{entity}}']); if (!${{entity}}->getId()) { $parentId = $this->getRequest()->getParam('parent'); if (!$parentId) { $parentId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); } $parent{{Entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($parentId); ${{entity}}->setPath($parent{{Entity}}->getPath()); } /** * Process "Use Config Settings" checkboxes */ if ($useConfig = $this->getRequest()->getPost('use_config')) { foreach ($useConfig as $attributeCode) { ${{entity}}->setData($attributeCode, null); } } ${{entity}}->setAttributeSetId(${{entity}}->getDefaultAttributeSetId()); Mage::dispatchEvent( '{{namespace}}_{{module}}_{{entity}}_prepare_save', array( '{{entity}}' => ${{entity}}, 'request' => $this->getRequest() ) ); ${{entity}}->setData("use_post_data_config", $this->getRequest()->getPost('use_config')); try { ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/020_product_data ================================================ $products = $this->getRequest()->getPost('{{entity}}_products', -1); if ($products != -1) { $productData = array(); parse_str($products, $productData); $products = array(); foreach ($productData as $id => $position) { $products[$id]['position'] = $position; } ${{entity}}->setProductsData($productData); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/030_category_data ================================================ $categories = $this->getRequest()->getPost('category_ids', -1); if ($categories != -1) { $categories = explode(',', $categories); $categories = array_unique($categories); ${{entity}}->setCategoriesData($categories); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/040_sibling_data ================================================ ${{siblings}} = $this->getRequest()->getPost('{{entity}}_{{siblings}}', -1); if (${{siblings}} != -1) { ${{sibling}}Data = array(); parse_str(${{siblings}}, ${{sibling}}Data); foreach (${{sibling}}Data as $id => $position) { ${{sibling}}[$id]['position'] = $position; } ${{entity}}->set{{Siblings}}Data(${{sibling}}Data); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/045_sibling_data_tree ================================================ ${{siblings}} = $this->getRequest()->getPost('{{sibling}}_ids', -1); if (${{siblings}} != -1) { ${{siblings}} = explode(',', ${{siblings}}); ${{siblings}} = array_unique(${{siblings}}); ${{entity}}->set{{Siblings}}Data(${{siblings}}); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/050_real_save ================================================ /** * Check "Use Default Value" checkboxes values */ if ($useDefaults = $this->getRequest()->getPost('use_default')) { foreach ($useDefaults as $attributeCode) { ${{entity}}->setData($attributeCode, false); } } /** * Unset $_POST['use_config'] before save */ ${{entity}}->unsetData('use_post_data_config'); ${{entity}}->save(); Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('The {{entityLabel}} has been saved.') ); $refreshTree = 'true'; } catch (Exception $e) { $this->_getSession()->addError($e->getMessage()) ->set{{Entity}}Data($data); $refreshTree = 'false'; } } $url = $this->getUrl('*/*/edit', array('_current' => true, 'id' => ${{entity}}->getId())); $this->getResponse()->setBody( '' ); } /** * Move {{entityLabel}} action * * @access public * {{qwertyuiop}} */ public function moveAction() { ${{entity}} = $this->_init{{Entity}}(); if (!${{entity}}) { $this->getResponse()->setBody( Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} move error') ); return; } $parentNodeId = $this->getRequest()->getPost('pid', false); $prevNodeId = $this->getRequest()->getPost('aid', false); try { ${{entity}}->move($parentNodeId, $prevNodeId); $this->getResponse()->setBody("SUCCESS"); } catch (Mage_Core_Exception $e) { $this->getResponse()->setBody($e->getMessage()); } catch (Exception $e) { $this->getResponse()->setBody( Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} move error') ); Mage::logException($e); } } /** * Delete {{entityLabel}} action * * @access public * {{qwertyuiop}} */ public function deleteAction() { if ($id = (int) $this->getRequest()->getParam('id')) { try { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($id); Mage::dispatchEvent( '{{namespace}}_{{module}}_controller_{{entity}}_delete', array('{{entity}}' => ${{entity}}) ); Mage::getSingleton('admin/session')->set{{Entity}}DeletedPath(${{entity}}->getPath()); ${{entity}}->delete(); Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('The {{entityLabel}} has been deleted.') ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true))); return; } catch (Exception $e) { Mage::logException($e); Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('An error occurred while trying to delete the {{entityLabel}}.') ); $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true))); return; } } $this->getResponse()->setRedirect($this->getUrl('*/*/', array('_current'=>true, 'id'=>null))); } /** * Tree Action * Retrieve {{entityLabel}} tree * * @access public * {{qwertyuiop}} */ public function treeAction() { $storeId = (int) $this->getRequest()->getParam('store'); ${{entity}}Id = (int) $this->getRequest()->getParam('id'); if ($storeId) { if (!${{entity}}Id) { $store = Mage::app()->getStore($storeId); $rootId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); $this->getRequest()->setParam('id', $rootId); } } ${{entity}} = $this->_init{{Entity}}(); $block = $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_tree'); $root = $block->getRoot(); $this->getResponse()->setBody( Mage::helper('core')->jsonEncode( array( 'data' => $block->getTree(), 'parameters' => array( 'text' => $block->buildNodeName($root), 'draggable' => false, 'allowDrop' => ($root->getIsVisible()) ? true : false, 'id' => (int) $root->getId(), 'expanded' => (int) $block->getIsWasExpanded(), 'store_id' => (int) $block->getStore()->getId(), '{{entity}}_id' => (int) ${{entity}}->getId(), 'root_visible' => (int) $root->getIsVisible() ) ) ) ); } /** * Build response for refresh input element 'path' in form * * @access public * {{qwertyuiop}} */ public function refreshPathAction() { if ($id = (int) $this->getRequest()->getParam('id')) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($id); $this->getResponse()->setBody( Mage::helper('core')->jsonEncode( array( 'id' => $id, 'path' => ${{entity}}->getPath(), ) ) ); } } /** * Check if admin has permissions to visit related pages * * @access protected * @return boolean * {{qwertyuiop}} */ protected function _isAllowed() { return Mage::getSingleton('admin/session')->isAllowed('{{selectedMenuPath}}'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/060_product_relation_action ================================================ /** * get the products grid * * @access public * @return void * {{qwertyuiop}} */ public function productsgridAction() { if (!${{entity}} = $this->_init{{Entity}}()) { return; } $this->getResponse()->setBody( $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_product', '{{entity}}.product.grid' ) ->toHtml() ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/070_category_relation_action ================================================ /** * get child categories action * * @access public * @return void * {{qwertyuiop}} */ public function categoriesJsonAction() { $this->_init{{Entity}}(); $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_categories') ->getCategoryChildrenJson($this->getRequest()->getParam('category')) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/080_sibling_actions ================================================ /** * get child {{siblingsLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}gridAction() { if (!${{entity}} = $this->_init{{Entity}}()) { return; } $this->getResponse()->setBody( $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_{{sibling}}', '{{entity}}.{{sibling}}.grid' ) ->toHtml() ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerEavTree/090_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/010_top ================================================ getRequest()->getParam('id'); ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}'); if (${{entity}}Id) { ${{entity}}->load(${{entity}}Id); } Mage::register('current_{{entity}}', ${{entity}}); return ${{entity}}; } /** * default action * * @access public * @return void * {{qwertyuiop}} */ public function indexAction() { $this->loadLayout(); $this->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{module_menu}}')) ->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}')); $this->renderLayout(); } /** * grid action * * @access public * @return void * {{qwertyuiop}} */ public function gridAction() { $this->loadLayout()->renderLayout(); } /** * edit {{entityLabel}} - action * * @access public * @return void * {{qwertyuiop}} */ public function editAction() { ${{entity}}Id = $this->getRequest()->getParam('id'); ${{entity}} = $this->_init{{Entity}}(); if (${{entity}}Id && !${{entity}}->getId()) { $this->_getSession()->addError( Mage::helper('{{namespace}}_{{module}}')->__('This {{entityLabel}} no longer exists.') ); $this->_redirect('*/*/'); return; } $data = Mage::getSingleton('adminhtml/session')->get{{Entity}}Data(true); if (!empty($data)) { ${{entity}}->setData($data); } Mage::register('{{entity}}_data', ${{entity}}); $this->loadLayout(); $this->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{module_menu}}')) ->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}')); if (${{entity}}->getId()) { $this->_title(${{entity}}->get{{EntityNameMagicCode}}()); } else { $this->_title(Mage::helper('{{namespace}}_{{module}}')->__('Add {{entityLabel}}')); } if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); } $this->renderLayout(); } /** * new {{entityLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function newAction() { $this->_forward('edit'); } /** * save {{entityLabel}} - action * * @access public * @return void * {{qwertyuiop}} */ public function saveAction() { if ($data = $this->getRequest()->getPost('{{entity}}')) { try {{{filterEntityDates}} ${{entity}} = $this->_init{{Entity}}(); ${{entity}}->addData($data); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/020_upload_image ================================================ ${{attributeMagicCode}}Name = $this->_uploadAndGetName( '{{attributeCode}}', Mage::helper('{{namespace}}_{{module}}/{{entity}}_image')->getImageBaseDir(), $data ); ${{entity}}->setData('{{attributeCode}}', ${{attributeMagicCode}}Name); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/030_upload_files ================================================ ${{attributeMagicCode}}Name = $this->_uploadAndGetName( '{{attributeCode}}', Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getFileBaseDir(), $data ); ${{entity}}->setData('{{attributeCode}}', ${{attributeMagicCode}}Name); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/040_save_product_relation ================================================ $products = $this->getRequest()->getPost('products', -1); if ($products != -1) { ${{entity}}->setProductsData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($products)); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/050_save_category_relation ================================================ $categories = $this->getRequest()->getPost('category_ids', -1); if ($categories != -1) { $categories = explode(',', $categories); $categories = array_unique($categories); ${{entity}}->setCategoriesData($categories); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/060_save_sibling_relation ================================================ ${{siblings}} = $this->getRequest()->getPost('{{siblings}}', -1); if (${{siblings}} != -1) { ${{entity}}->set{{Siblings}}Data( Mage::helper('adminhtml/js')->decodeGridSerializedInput(${{siblings}}) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/070_save_sibling_relation_tree ================================================ ${{siblings}} = $this->getRequest()->getPost('{{sibling}}_ids', -1); if (${{siblings}} != -1) { ${{siblings}} = explode(',', ${{siblings}}); ${{siblings}} = array_unique(${{siblings}}); ${{entity}}->set{{Siblings}}Data(${{siblings}}); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/080_save ================================================ ${{entity}}->save(); Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} was successfully saved') ); Mage::getSingleton('adminhtml/session')->setFormData(false); if ($this->getRequest()->getParam('back')) { $this->_redirect('*/*/edit', array('id' => ${{entity}}->getId())); return; } $this->_redirect('*/*/'); return; } catch (Mage_Core_Exception $e) { ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/090_exception_upload ================================================ if (isset($data['{{attributeCode}}']['value'])) { $data['{{attributeCode}}'] = $data['{{attributeCode}}']['value']; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/100_exception ================================================ Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); Mage::getSingleton('adminhtml/session')->set{{Entity}}Data($data); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); return; } catch (Exception $e) { Mage::logException($e); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/110_center ================================================ Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was a problem saving the {{entityLabel}}.') ); Mage::getSingleton('adminhtml/session')->set{{Entity}}Data($data); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); return; } } Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Unable to find {{entityLabel}} to save.') ); $this->_redirect('*/*/'); } /** * delete {{entityLabel}} - action * * @access public * @return void * {{qwertyuiop}} */ public function deleteAction() { if ( $this->getRequest()->getParam('id') > 0) { try { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}'); ${{entity}}->setId($this->getRequest()->getParam('id'))->delete(); Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} was successfully deleted.') ); $this->_redirect('*/*/'); return; } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error deleting {{entityLabel}}.') ); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); Mage::logException($e); return; } } Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Could not find {{entityLabel}} to delete.') ); $this->_redirect('*/*/'); } /** * mass delete {{entityLabel}} - action * * @access public * @return void * {{qwertyuiop}} */ public function massDeleteAction() { ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}'); if (!is_array(${{entity}}Ids)) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Please select {{entitiesLabel}} to delete.') ); } else { try { foreach (${{entity}}Ids as ${{entity}}Id) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}'); ${{entity}}->setId(${{entity}}Id)->delete(); } Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('Total of %d {{entitiesLabel}} were successfully deleted.', count(${{entity}}Ids)) ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error deleting {{entitiesLabel}}.') ); Mage::logException($e); } } $this->_redirect('*/*/index'); } /** * mass status change - action * * @access public * @return void * {{qwertyuiop}} */ public function massStatusAction() { ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}'); if (!is_array(${{entity}}Ids)) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Please select {{entitiesLabel}}.') ); } else { try { foreach (${{entity}}Ids as ${{entity}}Id) { ${{entity}} = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id) ->setStatus($this->getRequest()->getParam('status')) ->setIsMassupdate(true) ->save(); } $this->_getSession()->addSuccess( $this->__('Total of %d {{entitiesLabel}} were successfully updated.', count(${{entity}}Ids)) ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error updating {{entitiesLabel}}.') ); Mage::logException($e); } } $this->_redirect('*/*/index'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/120_mass_update ================================================ /** * mass {{attributeLabel}} change - action * * @access public * @return void * {{qwertyuiop}} */ public function mass{{AttributeMagicCode}}Action() { ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}'); if (!is_array(${{entity}}Ids)) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Please select {{entitiesLabel}}.') ); } else { try { foreach (${{entity}}Ids as ${{entity}}Id) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id) ->set{{AttributeMagicCode}}($this->getRequest()->getParam('flag_{{attributeCode}}')) ->setIsMassupdate(true) ->save(); } $this->_getSession()->addSuccess( $this->__('Total of %d {{entitiesLabel}} were successfully updated.', count(${{entity}}Ids)) ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error updating {{entitiesLabel}}.') ); Mage::logException($e); } } $this->_redirect('*/*/index'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/130_mass_parents ================================================ /** * mass {{siblingLabel}} change - action * * @access public * @return void * {{qwertyuiop}} */ public function mass{{Sibling}}IdAction() { ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}'); if (!is_array(${{entity}}Ids)) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('Please select {{entitiesLabel}}.') ); } else { try { foreach (${{entity}}Ids as ${{entity}}Id) { ${{entity}} = Mage::getSingleton('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id) ->set{{Sibling}}Id($this->getRequest()->getParam('flag_{{sibling}}_id')) ->setIsMassupdate(true) ->save(); } $this->_getSession()->addSuccess( $this->__('Total of %d {{entitiesLabel}} were successfully updated.', count(${{entity}}Ids)) ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('There was an error updating {{entitiesLabel}}.') ); Mage::logException($e); } } $this->_redirect('*/*/index'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/140_product_relation_actions ================================================ /** * get grid of products action * * @access public * @return void * {{qwertyuiop}} */ public function productsAction() { $this->_init{{Entity}}(); $this->loadLayout(); $this->getLayout()->getBlock('{{entity}}.edit.tab.product') ->set{{Entity}}Products($this->getRequest()->getPost('{{entity}}_products', null)); $this->renderLayout(); } /** * get grid of products action * * @access public * @return void * {{qwertyuiop}} */ public function productsgridAction() { $this->_init{{Entity}}(); $this->loadLayout(); $this->getLayout()->getBlock('{{entity}}.edit.tab.product') ->set{{Entity}}Products($this->getRequest()->getPost('{{entity}}_products', null)); $this->renderLayout(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/150_category_relation_actions ================================================ /** * get categories action * * @access public * @return void * {{qwertyuiop}} */ public function categoriesAction() { $this->_init{{Entity}}(); $this->loadLayout(); $this->renderLayout(); } /** * get child categories action * * @access public * @return void * {{qwertyuiop}} */ public function categoriesJsonAction() { $this->_init{{Entity}}(); $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_categories') ->getCategoryChildrenJson($this->getRequest()->getParam('category')) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/160_sibling_actions ================================================ /** * get {{siblingsLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}Action() { $this->_init{{Entity}}(); $this->loadLayout(); $this->getLayout()->getBlock('{{namespace}}_{{module}}.{{entity}}.edit.tab.{{sibling}}') ->set{{Entity}}{{Siblings}}($this->getRequest()->getPost('{{entity}}_{{siblings}}', null)); $this->renderLayout(); } /** * get {{siblingsLabel}} grid action * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}gridAction() { $this->_init{{Entity}}(); $this->loadLayout(); $this->getLayout()->getBlock('{{namespace}}_{{module}}.{{entity}}.edit.tab.{{sibling}}') ->set{{Entity}}{{Siblings}}($this->getRequest()->getPost('{{entity}}_{{siblings}}', null)); $this->renderLayout(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/170_sibling_actions_tree ================================================ /** * get {{siblingsLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}Action() { $this->_init{{Entity}}(); $this->loadLayout(); $this->renderLayout(); } /** * get child {{siblingsLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}JsonAction() { $this->_init{{Entity}}(); $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_{{sibling}}') ->get{{Sibling}}ChildrenJson($this->getRequest()->getParam('{{sibling}}')) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/180_footer ================================================ /** * export as csv - action * * @access public * @return void * {{qwertyuiop}} */ public function exportCsvAction() { $fileName = '{{entity}}.csv'; $content = $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_grid') ->getCsv(); $this->_prepareDownloadResponse($fileName, $content); } /** * export as MsExcel - action * * @access public * @return void * {{qwertyuiop}} */ public function exportExcelAction() { $fileName = '{{entity}}.xls'; $content = $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_grid') ->getExcelFile(); $this->_prepareDownloadResponse($fileName, $content); } /** * export as xml - action * * @access public * @return void * {{qwertyuiop}} */ public function exportXmlAction() { $fileName = '{{entity}}.xml'; $content = $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_grid') ->getXml(); $this->_prepareDownloadResponse($fileName, $content); } /** * Check if admin has permissions to visit related pages * * @access protected * @return boolean * {{qwertyuiop}} */ protected function _isAllowed() { return Mage::getSingleton('admin/session')->isAllowed('{{selectedMenuPath}}'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/010_top ================================================ getRequest()->getParam('id', false); ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}'); if (${{entity}}Id) { ${{entity}}->load(${{entity}}Id); } else { ${{entity}}->setData(${{entity}}->getDefaultValues()); } if ($activeTabId = (string) $this->getRequest()->getParam('active_tab_id')) { Mage::getSingleton('admin/session')->set{{Entity}}ActiveTabId($activeTabId); } Mage::register('{{entity}}', ${{entity}}); Mage::register('current_{{entity}}', ${{entity}}); return ${{entity}}; } /** * default action * * @access public * @return void * {{qwertyuiop}} */ public function indexAction() { $this->_forward('edit'); } /** * Add new {{entityLabel}} form * * @access public * @return void * {{qwertyuiop}} */ public function addAction() { Mage::getSingleton('admin/session')->uns{{Entity}}ActiveTabId(); $this->_forward('edit'); } /** * Edit {{entityLabel}} page * * @access public * @return void * {{qwertyuiop}} */ public function editAction() { $params['_current'] = true; $redirect = false; $parentId = (int) $this->getRequest()->getParam('parent'); ${{entity}}Id = (int) $this->getRequest()->getParam('id'); $_prev{{Entity}}Id = Mage::getSingleton('admin/session')->getLastEdited{{Entity}}(true); if ($_prev{{Entity}}Id && !$this->getRequest()->getQuery('isAjax') && !$this->getRequest()->getParam('clear')) { $this->getRequest()->setParam('id', $_prev{{Entity}}Id); } if ($redirect) { $this->_redirect('*/*/edit', $params); return; } if (!(${{entity}} = $this->_init{{Entity}}())) { return; } $this->_title(${{entity}}Id ? ${{entity}}->get{{EntityNameMagicCode}}() : $this->__('New {{EntityLabel}}')); $data = Mage::getSingleton('adminhtml/session')->get{{Entity}}Data(true); if (isset($data['{{entity}}'])) { ${{entity}}->addData($data['{{entity}}']); } if ($this->getRequest()->getQuery('isAjax')) { $breadcrumbsPath = ${{entity}}->getPath(); if (empty($breadcrumbsPath)) { $breadcrumbsPath = Mage::getSingleton('admin/session')->get{{Entity}}DeletedPath(true); if (!empty($breadcrumbsPath)) { $breadcrumbsPath = explode('/', $breadcrumbsPath); if (count($breadcrumbsPath) <= 1) { $breadcrumbsPath = ''; } else { array_pop($breadcrumbsPath); $breadcrumbsPath = implode('/', $breadcrumbsPath); } } } Mage::getSingleton('admin/session')->setLastEdited{{Entity}}(${{entity}}->getId()); $this->loadLayout(); $eventResponse = new Varien_Object( array( 'content' => $this->getLayout()->getBlock('{{entity}}.edit')->getFormHtml(). $this->getLayout()->getBlock('{{entity}}.tree')->getBreadcrumbsJavascript( $breadcrumbsPath, 'editing{{Entity}}Breadcrumbs' ), 'messages' => $this->getLayout()->getMessagesBlock()->getGroupedHtml(), ) ); $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($eventResponse->getData())); return; } $this->loadLayout(); $this->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{module_menu}}')) ->_title(Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}')); $this->_setActiveMenu('{{selectedMenuPath}}'); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true) ->setContainerCssClass('{{entity}}'); $this->_addBreadcrumb( Mage::helper('{{namespace}}_{{module}}')->__('Manage {{EntitiesLabel}}'), Mage::helper('{{namespace}}_{{module}}')->__('Manage {{EntitiesLabel}}') ); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); } $this->renderLayout(); } /** * Get tree node (Ajax version) * * @access public * @return void * {{qwertyuiop}} */ public function {{entities}}JsonAction() { if ($this->getRequest()->getParam('expand_all')) { Mage::getSingleton('admin/session')->set{{Entity}}IsTreeWasExpanded(true); } else { Mage::getSingleton('admin/session')->set{{Entity}}IsTreeWasExpanded(false); } if (${{entity}}Id = (int) $this->getRequest()->getPost('id')) { $this->getRequest()->setParam('id', ${{entity}}Id); if (!${{entity}} = $this->_init{{Entity}}()) { return; } $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_tree') ->getTreeJson(${{entity}}) ); } } /** * Move {{entityLabel}} action * @access public * {{qwertyuiop}} */ public function moveAction() { ${{entity}} = $this->_init{{Entity}}(); if (!${{entity}}) { $this->getResponse()->setBody( Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} move error') ); return; } $parentNodeId = $this->getRequest()->getPost('pid', false); $prevNodeId = $this->getRequest()->getPost('aid', false); try { ${{entity}}->move($parentNodeId, $prevNodeId); $this->getResponse()->setBody("SUCCESS"); } catch (Mage_Core_Exception $e) { $this->getResponse()->setBody($e->getMessage()); } catch (Exception $e) { $this->getResponse()->setBody( Mage::helper('{{namespace}}_{{module}}')->__('{{EntityLabel}} move error') ); Mage::logException($e); } } /** * Tree Action * Retrieve {{entityLabel}} tree * * @access public * @return void * {{qwertyuiop}} */ public function treeAction() { ${{entity}}Id = (int) $this->getRequest()->getParam('id'); ${{entity}} = $this->_init{{Entity}}(); $block = $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_tree'); $root = $block->getRoot(); $this->getResponse()->setBody( Mage::helper('core')->jsonEncode( array( 'data' => $block->getTree(), 'parameters' => array( 'text' => $block->buildNodeName($root), 'draggable' => false, 'allowDrop' => ($root->getIsVisible()) ? true : false, 'id' => (int) $root->getId(), 'expanded' => (int) $block->getIsWasExpanded(), '{{entity}}_id' => (int) ${{entity}}->getId(), 'root_visible' => (int) $root->getIsVisible() ) ) ) ); } /** * Build response for refresh input element 'path' in form * * @access public * @return void * {{qwertyuiop}} */ public function refreshPathAction() { if ($id = (int) $this->getRequest()->getParam('id')) { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($id); $this->getResponse()->setBody( Mage::helper('core')->jsonEncode( array( 'id' => $id, 'path' => ${{entity}}->getPath(), ) ) ); } } /** * Delete {{entityLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function deleteAction() { if ($id = (int) $this->getRequest()->getParam('id')) { try { ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($id); Mage::getSingleton('admin/session')->set{{Entity}}DeletedPath(${{entity}}->getPath()); ${{entity}}->delete(); Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('The {{entityLabel}} has been deleted.') ); } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true))); return; } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('{{namespace}}_{{module}}')->__('An error occurred while trying to delete the {{entityLabel}}.') ); $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true))); Mage::logException($e); return; } } $this->getResponse()->setRedirect($this->getUrl('*/*/', array('_current'=>true, 'id'=>null))); } /** * Check if admin has permissions to visit related pages * * @access protected * @return boolean * {{qwertyuiop}} */ protected function _isAllowed() { return Mage::getSingleton('admin/session')->isAllowed('{{selectedMenuPath}}'); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/020_wysiwyg ================================================ /** * wyisiwyg action * * @access public * @return void * {{qwertyuiop}} */ public function wysiwygAction() { $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); $storeMediaUrl = Mage::app()->getStore(0)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); $content = $this->getLayout()->createBlock( 'adminhtml/catalog_helper_form_wysiwyg_content', '', array( 'editor_element_id' => $elementId, 'store_id' => 0, 'store_media_url' => $storeMediaUrl, ) ); $this->getResponse()->setBody($content->toHtml()); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/030_save ================================================ /** * {{EntityLabel}} save action * * @access public * @return void * {{qwertyuiop}} */ public function saveAction() { if (!${{entity}} = $this->_init{{Entity}}()) { return; } $refreshTree = 'false'; if ($data = $this->getRequest()->getPost('{{entity}}')) {{{filterEntityDates3}} ${{entity}}->addData($data); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/040_upload_image ================================================ ${{attributeMagicCode}}Name = $this->_uploadAndGetName( '{{attributeCode}}', Mage::helper('{{namespace}}_{{module}}/{{entity}}_image')->getImageBaseDir(), $data ); ${{entity}}->setData('{{attributeCode}}', ${{attributeMagicCode}}Name); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/050_upload_file ================================================ ${{attributeMagicCode}}Name = $this->_uploadAndGetName( '{{attributeCode}}', Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getFileBaseDir(), $data ); ${{entity}}->setData('{{attributeCode}}', ${{attributeMagicCode}}Name); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/060_save_continue ================================================ if (!${{entity}}->getId()) { $parentId = $this->getRequest()->getParam('parent'); if (!$parentId) { $parentId = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id(); } $parent{{Entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load($parentId); ${{entity}}->setPath($parent{{Entity}}->getPath()); } try { ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/070_product_data ================================================ $products = $this->getRequest()->getPost('{{entity}}_products', -1); if ($products != -1) { $productData = array(); parse_str($products, $productData); $products = array(); foreach ($productData as $id => $position) { $products[$id]['position'] = $position; } ${{entity}}->setProductsData($productData); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/080_category_data ================================================ $categories = $this->getRequest()->getPost('category_ids', -1); if ($categories != -1) { $categories = explode(',', $categories); $categories = array_unique($categories); ${{entity}}->setCategoriesData($categories); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/090_sibling_data ================================================ ${{siblings}} = $this->getRequest()->getPost('{{entity}}_{{siblings}}', -1); if (${{siblings}} != -1) { ${{sibling}}Data = array(); parse_str(${{siblings}}, ${{sibling}}Data); foreach (${{sibling}}Data as $id => $position) { ${{sibling}}[$id]['position'] = $position; } ${{entity}}->set{{Siblings}}Data(${{sibling}}Data); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/095_sibling_data_tree ================================================ ${{siblings}} = $this->getRequest()->getPost('{{sibling}}_ids', -1); if (${{siblings}} != -1) { ${{siblings}} = explode(',', ${{siblings}}); ${{siblings}} = array_unique(${{siblings}}); ${{entity}}->set{{Siblings}}Data(${{siblings}}); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/100_real_save ================================================ ${{entity}}->save(); Mage::getSingleton('adminhtml/session')->addSuccess( Mage::helper('{{namespace}}_{{module}}')->__('The {{entityLabel}} has been saved.') ); $refreshTree = 'true'; } catch (Exception $e) { $this->_getSession()->addError($e->getMessage())->set{{Entity}}Data($data); Mage::logException($e); $refreshTree = 'false'; } } $url = $this->getUrl('*/*/edit', array('_current' => true, 'id' => ${{entity}}->getId())); $this->getResponse()->setBody( '' ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/110_product_relation_action ================================================ /** * get the products grid * * @access public * @return void * {{qwertyuiop}} */ public function productsgridAction() { if (!${{entity}} = $this->_init{{Entity}}()) { return; } $this->getResponse()->setBody( $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_product', '{{entity}}.product.grid' ) ->toHtml() ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/120_category_relation_action ================================================ /** * get child categories action * * @access public * @return void * {{qwertyuiop}} */ public function categoriesJsonAction() { $this->_init{{Entity}}(); $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_categories') ->getCategoryChildrenJson($this->getRequest()->getParam('category')) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/130_sibling_actions ================================================ /** * get {{siblingsLabel}} grid action * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}gridAction() { if (!${{entity}} = $this->_init{{Entity}}()) { return; } $this->getResponse()->setBody( $this->getLayout()->createBlock( '{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_{{sibling}}', '{{entity}}.{{sibling}}.grid' ) ->toHtml() ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/135_sibling_actions_tree ================================================ /** * get {{siblingsLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}Action() { $this->_init{{Entity}}(); $this->loadLayout(); $this->renderLayout(); } /** * get child {{siblingsLabel}} action * @access public * @return void * {{qwertyuiop}} */ public function {{siblings}}JsonAction() { $this->_init{{Entity}}(); $this->getResponse()->setBody( $this->getLayout()->createBlock('{{namespace}}_{{module}}/adminhtml_{{entity}}_edit_tab_{{sibling}}') ->get{{Sibling}}ChildrenJson($this->getRequest()->getParam('{{sibling}}')) ); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatTree/140_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Entity/Customer/CommentController/010_top ================================================ authenticate($this)) { $this->setFlag('', self::FLAG_NO_DISPATCH, true); } } /** * List comments * * @access public * {{qwertyuiop}} */ public function indexAction() { $this->loadLayout(); $this->_initLayoutMessages('catalog/session'); $this->_initLayoutMessages('customer/session'); $this->_initLayoutMessages('checkout/session'); if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) { $navigationBlock->setActive('{{namespace}}_{{module}}/{{entity}}_customer_comment/'); } if ($block = $this->getLayout()->getBlock('{{entity}}_customer_comment_list')) { $block->setRefererUrl($this->_getRefererUrl()); } $this->getLayout()->getBlock('head')->setTitle($this->__('My {{EntityLabel}} Comments')); $this->renderLayout(); } /** * View comment * * @access public * {{qwertyuiop}} */ public function viewAction() { $commentId = $this->getRequest()->getParam('id'); $comment = Mage::getModel('{{namespace}}_{{module}}/{{entity}}_comment')->load($commentId); if (!$comment->getId() || $comment->getCustomerId() != Mage::getSingleton('customer/session')->getCustomerId() || $comment->getStatus() != {{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_APPROVED) { $this->_forward('no-route'); return; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Entity/Customer/CommentController/020_entity_eav ================================================ ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}') ->setStoreId(Mage::app()->getStore()->getId()) ->load($comment->get{{Entity}}Id()); if (!${{entity}}->getId() || ${{entity}}->getStatus() != 1) { $this->_forward('no-route'); return; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Entity/Customer/CommentController/030_entity_flat ================================================ ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}') ->load($comment->get{{Entity}}Id()); if (!${{entity}}->getId() || ${{entity}}->getStatus() != 1) { $this->_forward('no-route'); return; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Entity/Customer/CommentController/040_store ================================================ $stores = array(Mage::app()->getStore()->getId(), 0); if (count(array_intersect($stores, $comment->getStoreId())) == 0) { $this->_forward('no-route'); return; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Entity/Customer/CommentController/050_entity_flat_store ================================================ if (count(array_intersect($stores, ${{entity}}->getStoreId())) == 0) { $this->_forward('no-route'); return; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Entity/Customer/CommentController/060_footer ================================================ Mage::register('current_comment', $comment); Mage::register('current_{{entity}}', ${{entity}}); $this->loadLayout(); $this->_initLayoutMessages('catalog/session'); $this->_initLayoutMessages('customer/session'); $this->_initLayoutMessages('checkout/session'); if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) { $navigationBlock->setActive('{{namespace}}_{{module}}/{{entity}}_customer_comment/'); } if ($block = $this->getLayout()->getBlock('customer_{{entity}}_comment')) { $block->setRefererUrl($this->_getRefererUrl()); } $this->getLayout()->getBlock('head')->setTitle($this->__('My {{EntityLabel}} Comments')); $this->renderLayout(); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/010_top ================================================ loadLayout(); $this->_initLayoutMessages('catalog/session'); $this->_initLayoutMessages('customer/session'); $this->_initLayoutMessages('checkout/session'); if (Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getUseBreadcrumbs()) { if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')) { $breadcrumbBlock->addCrumb( 'home', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Home'), 'link' => Mage::getUrl(), ) ); $breadcrumbBlock->addCrumb( '{{entities}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}'), 'link' => '', ) ); } } $headBlock = $this->getLayout()->getBlock('head'); if ($headBlock) { $headBlock->addLinkRel('canonical', Mage::helper('{{namespace}}_{{module}}/{{entity}}')->get{{Entities}}Url()); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/030_list_seo ================================================ if ($headBlock) { $headBlock->setTitle(Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/meta_title')); $headBlock->setKeywords(Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/meta_keywords')); $headBlock->setDescription(Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/meta_description')); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/040_list_footer ================================================ $this->renderLayout(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/050_view ================================================ /** * init {{EntityLabel}} * * @access protected * @return {{Namespace}}_{{Module}}_Model_{{Entity}} * {{qwertyuiop}} */ protected function _init{{Entity}}() { ${{entity}}Id = $this->getRequest()->getParam('id', 0); ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}') ->setStoreId(Mage::app()->getStore()->getId()) ->load(${{entity}}Id); if (!${{entity}}->getId()) { return false; } elseif (!${{entity}}->getStatus()) { return false; } return ${{entity}}; } /** * view {{entityLabel}} action * * @access public * @return void * {{qwertyuiop}} */ public function viewAction() { ${{entity}} = $this->_init{{Entity}}(); if (!${{entity}}) { $this->_forward('no-route'); return; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/060_view_tree ================================================ if (!${{entity}}->getStatusPath()) { $this->_forward('no-route'); return; } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/070_view2 ================================================ Mage::register('current_{{entity}}', ${{entity}}); $this->loadLayout(); $this->_initLayoutMessages('catalog/session'); $this->_initLayoutMessages('customer/session'); $this->_initLayoutMessages('checkout/session'); if ($root = $this->getLayout()->getBlock('root')) { $root->addBodyClass('{{module}}-{{entity}} {{module}}-{{entity}}' . ${{entity}}->getId()); } if (Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getUseBreadcrumbs()) { if ($breadcrumbBlock = $this->getLayout()->getBlock('breadcrumbs')) { $breadcrumbBlock->addCrumb( 'home', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Home'), 'link' => Mage::getUrl(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/080_breadcrumbs ================================================ $breadcrumbBlock->addCrumb( '{{entities}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}'), 'link' => Mage::helper('{{namespace}}_{{module}}/{{entity}}')->get{{Entities}}Url(), ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/090_breadcrumbs_tree ================================================ $breadcrumbBlock->addCrumb( '{{entities}}', array( 'label' => Mage::helper('{{namespace}}_{{module}}')->__('{{EntitiesLabel}}'), 'link' => Mage::helper('{{namespace}}_{{module}}/{{entity}}')->get{{Entities}}Url(), ) ); $parents = ${{entity}}->getParent{{Entities}}(); foreach ($parents as $parent) { if ($parent->getId() != Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getRoot{{Entity}}Id() && $parent->getId() != ${{entity}}->getId()) { $breadcrumbBlock->addCrumb( '{{entity}}-'.$parent->getId(), array( 'label' => $parent->get{{EntityNameMagicCode}}(), 'link' => $link = $parent->get{{Entity}}Url(), ) ); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/100_breadcrumbs_footer ================================================ $breadcrumbBlock->addCrumb( '{{entity}}', array( 'label' => ${{entity}}->get{{EntityNameMagicCode}}(), 'link' => '', ) ); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/105_view_canonical ================================================ $headBlock = $this->getLayout()->getBlock('head'); if ($headBlock) { $headBlock->addLinkRel('canonical', ${{entity}}->get{{Entity}}Url()); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/110_view_seo ================================================ if ($headBlock) { if (${{entity}}->getMetaTitle()) { $headBlock->setTitle(${{entity}}->getMetaTitle()); } else { $headBlock->setTitle(${{entity}}->get{{EntityNameMagicCode}}()); } $headBlock->setKeywords(${{entity}}->getMetaKeywords()); $headBlock->setDescription(${{entity}}->getMetaDescription()); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/120_view_footer ================================================ $this->renderLayout(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/130_rss ================================================ /** * {{entitiesLabel}} rss list action * * @access public * @return void * {{qwertyuiop}} */ public function rssAction() { if (Mage::helper('{{namespace}}_{{module}}/{{entity}}')->isRssEnabled()) { $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); $this->loadLayout(false); $this->renderLayout(); } else { $this->getResponse()->setHeader('HTTP/1.1', '404 Not Found'); $this->getResponse()->setHeader('Status', '404 File not found'); $this->_forward('nofeed', 'index', 'rss'); } } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/140_comment ================================================ /** * Submit new comment action * @access public * {{qwertyuiop}} */ public function commentpostAction() { $data = $this->getRequest()->getPost(); ${{entity}} = $this->_init{{Entity}}(); $session = Mage::getSingleton('core/session'); if (${{entity}}) { if (${{entity}}->getAllowComments()) { if ((Mage::getSingleton('customer/session')->isLoggedIn() || Mage::getStoreConfigFlag('{{namespace}}_{{module}}/{{entity}}/allow_guest_comment'))) { $comment = Mage::getModel('{{namespace}}_{{module}}/{{entity}}_comment')->setData($data); $validate = $comment->validate(); if ($validate === true) { try { $comment->set{{Entity}}Id(${{entity}}->getId()) ->setStatus({{Namespace}}_{{Module}}_Model_{{Entity}}_Comment::STATUS_PENDING) ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId()) ->setStores(array(Mage::app()->getStore()->getId())) ->save(); $session->addSuccess($this->__('Your comment has been accepted for moderation.')); } catch (Exception $e) { $session->set{{Entity}}CommentData($data); $session->addError($this->__('Unable to post the comment.')); } } else { $session->set{{Entity}}CommentData($data); if (is_array($validate)) { foreach ($validate as $errorMessage) { $session->addError($errorMessage); } } else { $session->addError($this->__('Unable to post the comment.')); } } } else { $session->addError($this->__('Guest comments are not allowed')); } } else { $session->addError($this->__('This {{entityLabel}} does not allow comments')); } } $this->_redirectReferer(); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/150_footer ================================================ } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/data/namespace_module_setup/data-install/010_top ================================================ load(1) ->setParentId(0) ->setPath(1) ->setLevel(0) ->setPosition(0) ->setChildrenCount(0) ->set{{EntityNameMagicCode}}('ROOT') ->setInitialSetupFlag(true){{EntityAttributeSetId}} ->save(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/adminhtml/010_content ================================================ {{License}} <{{namespace}}_{{module}} translate="title" module="{{namespace}}_{{module}}"> {{Module}} {{menuAcl}} {{menuItemsXml}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api/010_top ================================================ {{License}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api/020_entity_api ================================================ <{{module}}_{{entity}} translate="title" module="{{namespace}}_{{module}}"> {{EntityLabel}} API {{namespace}}_{{module}}/{{entity}}_api {{module}}/{{entity}} Retrieve list of {{entitiesLabel}} items {{module}}/{{entity}}/list Retrieve {{entityLabel}} info {{module}}/{{entity}}/info Add {{entityLabel}} {{module}}/{{entity}}/add Update {{entityLabel}} {{module}}/{{entity}}/update Remove {{entityLabel}} {{module}}/{{entity}}/remove {{entityApiAdditional}} <{{entity}}_not_exists> 101 Requested {{entityLabel}} does not exist. 102 Provided data is invalid. 103 Error while saving {{entityLabel}}. Details in error message. 104 Error while removing {{entityLabel}}. Details in error message. {{entityApiFaults}} {{entityApiAdditionalSettings}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api/030_resource_alias ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api/040_entity_resource_alias ================================================ <{{entity}}>{{module}}_{{entity}}{{entityApiResourcesAlias}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api/050_v2 ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api/060_v2_entity ================================================ <{{entity}}>{{module}}{{Entity}}{{entityApiResourcesAliasV2}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api/070_acl ================================================ <{{namespace}}_{{module}} translate="title" module="{{namespace}}_{{module}}"> {{Module}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api/080_acl_entity ================================================ <{{entity}} translate="title" module="{{namespace}}_{{module}}"> {{EntityLabel}} {{position}} List Info Add Update Remove {{entityAdditionalApiAcl}}{{subEntitiesAcl}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api/090_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/api2/010_content ================================================ {{License}} <{{namespace}}_{{module}} translate="title" module="{{namespace}}_{{module}}"> {{Module}} 120 {{RestResourceGroupsChildren}} {{RestResources}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/010_top ================================================ {{License}} <{{Namespace}}_{{Module}}> {{version}} <{{namespace}}_{{module}}_setup> {{Namespace}}_{{Module}} {{Namespace}}_{{Module}}_Model_Resource_Setup <{{namespace}}_{{module}}> {{Namespace}}_{{Module}}_Block <{{namespace}}_{{module}}> {{Namespace}}_{{Module}}_Helper <{{namespace}}_{{module}}> {{Namespace}}_{{Module}}_Model {{namespace}}_{{module}}_resource <{{namespace}}_{{module}}_resource> {{Namespace}}_{{Module}}_Model_Resource ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/020_tables ================================================ <{{entity}}> {{namespace}}_{{module}}_{{entity}}
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/030_store_tables ================================================ <{{entity}}_store> {{namespace}}_{{module}}_{{entity}}_store
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/040_siblings_table ================================================ <{{entity}}_{{sibling}}> {{namespace}}_{{module}}_{{entity}}_{{sibling}}
    <{{sibling}}_{{entity}}> {{namespace}}_{{module}}_{{entity}}_{{sibling}}
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/050_product_relation_table ================================================ <{{entity}}_product> {{namespace}}_{{module}}_{{entity}}_product
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/060_category_relation_table ================================================ <{{entity}}_category> {{namespace}}_{{module}}_{{entity}}_category
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/070_comment_table ================================================ <{{entity}}_comment> {{namespace}}_{{module}}_{{entity}}_comment
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/080_comment_store_table ================================================ <{{entity}}_comment_store> {{namespace}}_{{module}}_{{entity}}_comment_store
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/090_eav_attribute ================================================ {{namespace}}_{{module}}_eav_attribute
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/100_global ================================================
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/110_url_rewrite ================================================ <{{namespace}}_{{module}}> {{Namespace}}_{{Module}}_Controller_Router initControllerRouters ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/120_adminhtml ================================================
    <{{namespace}}_{{module}}> {{namespace}}_{{module}}.xml <{{Namespace}}_{{Module}}> {{Namespace}}_{{Module}}.csv ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/130_relation_events_top ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/140_relation_product_top ================================================ <{{namespace}}_{{module}}_{{entity}}_product> singleton {{namespace}}_{{module}}/adminhtml_observer addProduct{{Entity}}Block ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/150_relation_events_middle ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/160_relation_category_top ================================================ <{{namespace}}_{{module}}_{{entity}}_category> singleton {{namespace}}_{{module}}/adminhtml_observer addCategory{{Entity}}Block ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/170_relation_product_bottom_start ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/180_relation_product_bottom ================================================ <{{namespace}}_{{module}}_{{entity}}_product> singleton {{namespace}}_{{module}}/adminhtml_observer saveProduct{{Entity}}Data ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/190_relation_product_bottom_end ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/200_relation_category_bottom_start ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/210_relation_category_bottom ================================================ <{{namespace}}_{{module}}_{{entity}}_category> singleton {{namespace}}_{{module}}/adminhtml_observer saveCategory{{Entity}}Data ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/220_relation_category_bottom_end ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/230_relation_events_bottom ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/240_global_search_top ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/250_global_search_entity ================================================ <{{entity}}> {{namespace}}_{{module}}/adminhtml_search_{{entity}} {{namespace}}_{{module}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/260_global_search_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/270_admin ================================================ <{{Namespace}}_{{Module}} before="Mage_Adminhtml">{{Namespace}}_{{Module}}_Adminhtml ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/280_frontend ================================================ {{categoryMenuEvent}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/284_router ================================================ <{{namespace}}_{{module}}> standard {{Namespace}}_{{Module}} {{frontKey}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/287_frontend_footer ================================================ <{{namespace}}_{{module}}> {{namespace}}_{{module}}.xml <{{Namespace}}_{{Module}}> {{Namespace}}_{{Module}}.csv ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/290_default_top ================================================ <{{namespace}}_{{module}}> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/300_default ================================================ {{entity_default_config}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/310_default_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/config/320_footer ================================================
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/system/010_top ================================================ {{License}} <{{namespace}} translate="label" module="{{namespace}}_{{module}}"> {{systemTabPosition}} <{{namespace}}_{{module}} translate="label" module="{{namespace}}_{{module}}"> separator-top {{namespace}} text 100 1 1 1 ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/system/020_entity ================================================ <{{entity}} translate="label" module="{{namespace}}_{{module}}"> text {{position}} 1 1 1 {{systemAttributes}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/system/030_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/widget/010_top ================================================ {{License}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/widget/020_entity ================================================ <{{module}}_{{entity}}_view type="{{namespace}}_{{module}}/{{entity}}_widget_view" translate="name description" module="{{namespace}}_{{module}}"> {{EntityLabel}} view {{EntityLabel}} view widget 0 <{{entity}}_id type="complex" translate="label"> 1 1 label {{namespace}}_{{module}}/adminhtml_{{entity}}_widget_chooser 120 <{{module}}_{{entity}}_link type="{{namespace}}_{{module}}/{{entity}}_widget_link" translate="name description" module="{{namespace}}_{{module}}"> {{EntityLabel}} link {{EntityLabel}} link widget 0 <{{entity}}_id type="complex" translate="label"> 1 1 label {{namespace}}_{{module}}/adminhtml_{{entity}}_widget_chooser 130 ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/widget/030_tree ================================================ <{{module}}_{{entity}}_subtree type="{{namespace}}_{{module}}/{{entity}}_widget_subtree" translate="name description" module="{{namespace}}_{{module}}"> {{EntityLabel}} subtree {{EntityLabel}} subtree widget 0 <{{entity}}_id type="complex" translate="label"> 1 1 label {{namespace}}_{{module}}/adminhtml_{{entity}}_widget_chooser 10 1 1 0 text 20 ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/widget/040_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/010_top ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/020_entity_types ================================================ {{entityWsdlAttributes}} {{entityWsdlAttributesForAdd}} {{entityWsdlAttributesForAdd}} {{entityWsdlAttributes}} {{entityWsdlRelationTypes}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/023_entity_comment_types ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/026_entity_attribute_types ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/030_schema_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/040_entity_messages ================================================ {{entityWsdlMessages}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/043_entity_comment_messages ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/046_entity_attribute_messages ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/050_porttype_top ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/060_porttype_entity ================================================ Retrieve list of {{entityLabel}} Retrieve {{entityLabel}} info Add {{entityLabel}} Update {{entityLabel}} Remove {{entityLabel}} {{entityWsdlPortTypeRelation}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/063_porttype_entity_comment ================================================ Retrieve list of {{entityLabel}} comments Change {{entityLabel}} comment status ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/066_porttype_entity_attribute ================================================ Get list of additional attributes which are not in default create/update list Set/Get current store view Get list of additional attributes which are not in default create/update list Retrieve {{entityLabel}} attribute list Retrieve {{entityLabel}} attribute options Get list of possible {{entityLabel}} attribute types Create new {{entityLabel}} attribute Delete {{entityLabel}} attribute Get full information about {{entityLabel}} attribute with list of options Update {{entityLabel}} attribute Add option to {{entityLabel}} attribute Remove option from {{entityLabel}} attribute ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/070_porttype_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/080_binding_top ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/090_entity_binding ================================================ {{entityWsdlRelationBinding}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/093_entity_binding_comment ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/096_entity_binding_attribute ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsdl/100_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/010_top ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/020_entity_types ================================================ {{entityWsiAttributes}} {{entityWsiAttributesForAdd}} {{entityWsiAttributesForAdd}} {{entityWsiAttributes}} {{entityWsiRelationTypes}} {{entityWsiRelationParamTypes}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/023_entity_comment_types ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/026_entity_attribute_types ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/030_schema_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/040_entity_messages ================================================ {{entityWsiRelationMessages}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/043_entity_comment_messages ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/046_entity_attribute_messages ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/050_porttype_top ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/060_porttype_entity ================================================ Retrieve list of {{entitiesLabel}} Retrieve {{entityLabel}} info Add {{entityLabel}} Update {{entityLabel}} Remove {{entityLabel}} {{entityWsiPortTypeRelation}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/063_porttype_entity_comment ================================================ Retrieve list of {{entityLabel}} comments Change {{entityLabel}} comment status ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/066_porttype_entity_attribute ================================================ Get list of additional attributes which are not in default create/update list Set/Get current store view Get list of additional attributes which are not in default create/update list Retrieve {{entityLabel}} attribute list Retrieve {{entityLabel}} attribute options Get list of possible {{entityLabel}} attribute types Create new {{entityLabel}} attribute Delete {{entityLabel}} attribute Get full information about {{entityLabel}} attribute with list of options Update {{entityLabel}} attribute Add option to {{entityLabel}} attribute Remove option from {{entityLabel}} attribute ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/070_porttype_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/080_binding_top ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/090_entity_binding ================================================ {{entityWsiRelationBinding}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/093_entity_binding_comment ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/096_entity_binding_attribute ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/etc/wsi/100_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/010_top ================================================ startSetup(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/020_entity_flat ================================================ $table = $this->getConnection() ->newTable($this->getTable('{{namespace}}_{{module}}/{{entity}}')) ->addColumn( 'entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'identity' => true, 'nullable' => false, 'primary' => true, ), '{{EntityLabel}} ID' ) {{attributeDdlSql}} ->addColumn( 'updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), '{{EntityLabel}} Modification Time' ) ->addColumn( 'created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), '{{EntityLabel}} Creation Time' ) {{fksDdl}} ->setComment('{{EntityLabel}} Table'); $this->getConnection()->createTable($table); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/030_entity_store ================================================ $table = $this->getConnection() ->newTable($this->getTable('{{namespace}}_{{module}}/{{entity}}_store')) ->addColumn( '{{entity}}_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'nullable' => false, 'primary' => true, ), '{{EntityLabel}} ID' ) ->addColumn( 'store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, 'primary' => true, ), 'Store ID' ) ->addIndex( $this->getIdxName( '{{namespace}}_{{module}}/{{entity}}_store', array('store_id') ), array('store_id') ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_store', '{{entity}}_id', '{{namespace}}_{{module}}/{{entity}}', 'entity_id' ), '{{entity}}_id', $this->getTable('{{namespace}}_{{module}}/{{entity}}'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_store', 'store_id', 'core/store', 'store_id' ), 'store_id', $this->getTable('core/store'), 'store_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->setComment('{{EntitiesLabel}} To Store Linkage Table'); $this->getConnection()->createTable($table); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/040_entity_eav ================================================ $table = $this->getConnection() ->newTable($this->getTable('{{namespace}}_{{module}}/{{entity}}')) ->addColumn( 'entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true, ), 'Entity ID' ) ->addColumn( 'entity_type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), 'Entity Type ID' ) ->addColumn( 'attribute_set_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), 'Attribute Set ID' ) {{attributeDdlSql}} ->addColumn( 'created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), 'Creation Time' ) ->addColumn( 'updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), 'Update Time' ) ->addIndex( $this->getIdxName( '{{namespace}}_{{module}}/{{entity}}', array('entity_type_id') ), array('entity_type_id') ) ->addIndex( $this->getIdxName( '{{namespace}}_{{module}}/{{entity}}', array('attribute_set_id') ), array('attribute_set_id') ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}', 'attribute_set_id', 'eav/attribute_set', 'attribute_set_id' ), 'attribute_set_id', $this->getTable('eav/attribute_set'), 'attribute_set_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}', 'entity_type_id', 'eav/entity_type', 'entity_type_id' ), 'entity_type_id', $this->getTable('eav/entity_type'), 'entity_type_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->setComment('{{EntityLabel}} Table'); $this->getConnection()->createTable($table); ${{entity}}Eav = array(); ${{entity}}Eav['int'] = array( 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, 'length' => null, 'comment' => '{{EntityLabel}} Datetime Attribute Backend Table' ); ${{entity}}Eav['varchar'] = array( 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'length' => 255, 'comment' => '{{EntityLabel}} Varchar Attribute Backend Table' ); ${{entity}}Eav['text'] = array( 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'length' => '64k', 'comment' => '{{EntityLabel}} Text Attribute Backend Table' ); ${{entity}}Eav['datetime'] = array( 'type' => Varien_Db_Ddl_Table::TYPE_DATETIME, 'length' => null, 'comment' => '{{EntityLabel}} Datetime Attribute Backend Table' ); ${{entity}}Eav['decimal'] = array( 'type' => Varien_Db_Ddl_Table::TYPE_DECIMAL, 'length' => '12,4', 'comment' => '{{EntityLabel}} Datetime Attribute Backend Table' ); foreach (${{entity}}Eav as $type => $options) { $table = $this->getConnection() ->newTable($this->getTable(array('{{namespace}}_{{module}}/{{entity}}', $type))) ->addColumn( 'value_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'identity' => true, 'nullable' => false, 'primary' => true, ), 'Value ID' ) ->addColumn( 'entity_type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), 'Entity Type ID' ) ->addColumn( 'attribute_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), 'Attribute ID' ) ->addColumn( 'store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), 'Store ID' ) ->addColumn( 'entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), 'Entity ID' ) ->addColumn( 'value', $options['type'], $options['length'], array(), 'Value' ) ->addIndex( $this->getIdxName( array('{{namespace}}_{{module}}/{{entity}}', $type), array('entity_id', 'attribute_id', 'store_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ), array('entity_id', 'attribute_id', 'store_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) ) ->addIndex( $this->getIdxName( array('{{namespace}}_{{module}}/{{entity}}', $type), array('store_id') ), array('store_id') ) ->addIndex( $this->getIdxName( array('{{namespace}}_{{module}}/{{entity}}', $type), array('entity_id') ), array('entity_id') ) ->addIndex( $this->getIdxName( array('{{namespace}}_{{module}}/{{entity}}', $type), array('attribute_id') ), array('attribute_id') ) ->addForeignKey( $this->getFkName( array('{{namespace}}_{{module}}/{{entity}}', $type), 'attribute_id', 'eav/attribute', 'attribute_id' ), 'attribute_id', $this->getTable('eav/attribute'), 'attribute_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addForeignKey( $this->getFkName( array('{{namespace}}_{{module}}/{{entity}}', $type), 'entity_id', '{{namespace}}_{{module}}/{{entity}}', 'entity_id' ), 'entity_id', $this->getTable('{{namespace}}_{{module}}/{{entity}}'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addForeignKey( $this->getFkName( array('{{namespace}}_{{module}}/{{entity}}', $type), 'store_id', 'core/store', 'store_id' ), 'store_id', $this->getTable('core/store'), 'store_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->setComment($options['comment']); $this->getConnection()->createTable($table); } ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/050_product_relation ================================================ $table = $this->getConnection() ->newTable($this->getTable('{{namespace}}_{{module}}/{{entity}}_product')) ->addColumn( 'rel_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'identity' => true, 'nullable' => false, 'primary' => true, ), 'Relation ID' ) ->addColumn( '{{entity}}_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), '{{EntityLabel}} ID' ) ->addColumn( 'product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), 'Product ID' ) ->addColumn( 'position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'nullable' => false, 'default' => '0', ), 'Position' ) ->addIndex( $this->getIdxName( '{{namespace}}_{{module}}/{{entity}}_product', array('product_id') ), array('product_id') ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_product', '{{entity}}_id', '{{namespace}}_{{module}}/{{entity}}', 'entity_id' ), '{{entity}}_id', $this->getTable('{{namespace}}_{{module}}/{{entity}}'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_product', 'product_id', 'catalog/product', 'entity_id' ), 'product_id', $this->getTable('catalog/product'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addIndex( $this->getIdxName( '{{namespace}}_{{module}}/{{entity}}_product', array('{{entity}}_id', 'product_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ), array('{{entity}}_id', 'product_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) ) ->setComment('{{EntityLabel}} to Product Linkage Table'); $this->getConnection()->createTable($table); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/060_category_relation ================================================ $table = $this->getConnection() ->newTable($this->getTable('{{namespace}}_{{module}}/{{entity}}_category')) ->addColumn( 'rel_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'identity' => true, 'nullable' => false, 'primary' => true, ), 'Relation ID' ) ->addColumn( '{{entity}}_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), '{{EntityLabel}} ID' ) ->addColumn( 'category_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), 'Category ID' ) ->addColumn( 'position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'nullable' => false, 'default' => '0', ), 'Position' ) ->addIndex( $this->getIdxName( '{{namespace}}_{{module}}/{{entity}}_category', array('category_id') ), array('category_id') ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_category', '{{entity}}_id', '{{namespace}}_{{module}}/{{entity}}', 'entity_id' ), '{{entity}}_id', $this->getTable('{{namespace}}_{{module}}/{{entity}}'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_category', 'category_id', 'catalog/category', 'entity_id' ), 'category_id', $this->getTable('catalog/category'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addIndex( $this->getIdxName( '{{namespace}}_{{module}}/{{entity}}_category', array('{{entity}}_id', 'category_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ), array('{{entity}}_id', 'category_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) ) ->setComment('{{EntityLabel}} to Category Linkage Table'); $this->getConnection()->createTable($table); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/070_comments ================================================ $table = $this->getConnection() ->newTable($this->getTable('{{namespace}}_{{module}}/{{entity}}_comment')) ->addColumn( 'comment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'identity' => true, 'nullable' => false, 'primary' => true, ), '{{EntityLabel}} Comment ID' ) ->addColumn( '{{entity}}_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('nullable' => false), '{{EntityLabel}} ID' ) ->addColumn( 'title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array('nullable' => false), 'Comment Title' ) ->addColumn( 'comment', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array('nullable' => false), 'Comment' ) ->addColumn( 'status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array('nullable' => false), 'Comment status' ) ->addColumn( 'customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('nullable' => true), 'Customer id' ) ->addColumn( 'name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array('nullable' => false), 'Customer name' ) ->addColumn( 'email', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array('nullable' => false), 'Customer email' ) ->addColumn( 'updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), '{{EntityLabel}} Comment Modification Time' ) ->addColumn( 'created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), '{{EntityLabel}} Comment Creation Time' ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_comment', '{{entity}}_id', '{{namespace}}_{{module}}/{{entity}}', 'entity_id' ), '{{entity}}_id', $this->getTable('{{namespace}}_{{module}}/{{entity}}'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_comment', 'customer_id', 'customer/entity', 'entity_id' ), 'customer_id', $this->getTable('customer/entity'), 'entity_id', Varien_Db_Ddl_Table::ACTION_SET_NULL, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->setComment('{{EntityLabel}} Comments Table'); $this->getConnection()->createTable($table); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/080_comments_store ================================================ $table = $this->getConnection() ->newTable($this->getTable('{{namespace}}_{{module}}/{{entity}}_comment_store')) ->addColumn( 'comment_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'nullable' => false, 'primary' => true, ), 'Comment ID' ) ->addColumn( 'store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, 'primary' => true, ), 'Store ID' ) ->addIndex( $this->getIdxName( '{{namespace}}_{{module}}/{{entity}}_comment_store', array('store_id') ), array('store_id') ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_comment_store', 'comment_id', '{{namespace}}_{{module}}/{{entity}}_comment', 'comment_id' ), 'comment_id', $this->getTable('{{namespace}}_{{module}}/{{entity}}_comment'), 'comment_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_comment_store', 'store_id', 'core/store', 'store_id' ), 'store_id', $this->getTable('core/store'), 'store_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->setComment('{{EntitiesLabel}} Comments To Store Linkage Table'); $this->getConnection()->createTable($table); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/090_sibling_relation ================================================ $table = $this->getConnection() ->newTable($this->getTable('{{namespace}}_{{module}}/{{entity}}_{{sibling}}')) ->addColumn( 'rel_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'identity' => true, 'nullable' => false, 'primary' => true, ), 'Relation ID' ) ->addColumn( '{{entity}}_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), '{{EntityLabel}} ID' ) ->addColumn( '{{sibling}}_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'nullable' => false, 'default' => '0', ), '{{SiblingLabel}} ID' ) ->addColumn( 'position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'nullable' => false, 'default' => '0', ), 'Position' ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_{{sibling}}', '{{entity}}_id', '{{namespace}}_{{module}}/{{entity}}', 'entity_id' ), '{{entity}}_id', $this->getTable('{{namespace}}_{{module}}/{{entity}}'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addForeignKey( $this->getFkName( '{{namespace}}_{{module}}/{{entity}}_{{sibling}}', '{{sibling}}_id', '{{namespace}}_{{module}}/{{entity}}', 'entity_id' ), '{{sibling}}_id', $this->getTable('{{namespace}}_{{module}}/{{sibling}}'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE ) ->addIndex( $this->getIdxName( '{{namespace}}_{{module}}/{{entity}}_{{sibling}}', array('{{entity}}_id', '{{sibling}}_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ), array('{{entity}}_id', '{{sibling}}_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) ) ->setComment('{{EntityLabel}} to {{SiblingLabel}} Linkage Table'); $this->getConnection()->createTable($table); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/100_has_eav ================================================ $table = $this->getConnection() ->newTable($this->getTable('{{namespace}}_{{module}}/eav_attribute')) ->addColumn( 'attribute_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'identity' => true, 'nullable' => false, 'primary' => true, ), 'Attribute ID' ) ->addColumn( 'is_global', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(), 'Attribute scope' ) ->addColumn( 'position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(), 'Attribute position' ) ->addColumn( 'is_wysiwyg_enabled', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(), 'Attribute uses WYSIWYG' ) ->addColumn( 'is_visible', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(), 'Attribute is visible' ) ->setComment('{{Module}} attribute table'); $this->getConnection()->createTable($table); $this->installEntities(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/110_product_attribute ================================================ $this->addAttribute( 'catalog_product', '{{productAttributeCode}}', array( {{productAttributeGroup}}'backend' => '', 'frontend' => '', 'class' => '', 'default' => '', 'label' => '{{EntityLabel}}', 'input' => 'select', 'type' => 'int', 'source' => '{{namespace}}_{{module}}/{{entity}}_source', 'global' => {{entityProductAttributeScope}}, 'is_visible' => 1, 'required' => 0, 'searchable' => 0, 'filterable' => 0, 'unique' => 0, 'comparable' => 0, 'visible_on_front' => 0, 'user_defined' => 1, ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/120_category_attribute ================================================ $this->addAttribute( 'catalog_category', '{{categoryAttributeCode}}', array( {{categoryAttributeGroup}}'backend' => '', 'frontend' => '', 'class' => '', 'default' => '', 'label' => '{{EntityLabel}}', 'input' => 'select', 'type' => 'int', 'source' => '{{namespace}}_{{module}}/{{entity}}_source', 'global' => {{entityCategoryAttributeScope}}, 'required' => 0, 'unique' => 0, 'user_defined' => 1, ) ); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/125_eav_options_default ================================================ {{eavOptionsDefaults}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/code/sql/namespace_module_setup/install/130_footer ================================================ $this->endSetup(); ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/010_top ================================================ {{License}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/020_entity_not_tree ================================================ {{selectedMenuPath}} {{adminIndexContent}} {{selectedMenuPath}} {{entityEditLayoutLeft}} {{entityLayoutAdditional}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/023_eav ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/027_entity_not_tree_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/028_entity_edit_eav ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/029_edit_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/030_relation_product ================================================ product.edit.tab.{{entity}} getSelected{{Entities}} {{entities}} product_{{entities}} position {{entity}}.edit.tab.product getSelectedProducts products {{entity}}_products position ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/040_relation_category ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/050_relation_sibling ================================================ {{namespace}}_{{module}}.{{entity}}.edit.tab.{{sibling}} getSelected{{Siblings}} {{siblings}} {{entity}}_{{siblings}} position ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/060_entity_tree ================================================ {{entityLayoutAdditional}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/070_relation_product_tree ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/080_relation_category_tree ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/090_relation_sibling_tree ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/100_eav_attribute_edit ================================================ {{entity}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/110_comment ================================================ {{selectedMenuPath}}_comment {{selectedMenuPath}}_comment ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/layout/namespace_module/120_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/attribute/js/010_content ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/catalog/category/tab/entities/010_content ================================================

    __('{{EntitiesLabel}}') ?>

    getRootNode() && $this->getRootNode()->hasChildren()): ?> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/catalog/product/edit/tab/entity/010_content ================================================

    __('{{EntitiesLabel}}') ?>

    getRootNode() && $this->getRootNode()->hasChildren()): ?> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/edit/010_content ================================================
    getChildHtml('form') ?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/edit/form/010_top ================================================

    escapeHtml($this->getHeader()) . ($this->get{{Entity}}Id() ? ' (' . Mage::helper('{{namespace}}_{{module}}')->__('ID: %s', $this->get{{Entity}}Id()) . ')' : '') ?>

    getResetButtonHtml() ?> get{{Entity}}Id()): ?> getDeleteButtonHtml() ?> getAdditionalButtonsHtml(); ?> getSaveButtonHtml() ?>

    getTabsHtml() ?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/edit/form/020_product_hidden ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/edit/form/030_category_hidden ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/edit/form/040_sibling_hidden ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/edit/form/050_content ================================================
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/edit/tab/categories/010_content ================================================

    __('Categories') ?>

    getRootNode() && $this->getRootNode()->hasChildren()): ?> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/edit/tab/sibling/010_content ================================================

    __('{{SiblingsLabel}}') ?>

    getRootNode() && $this->getRootNode()->hasChildren()): ?> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/tree/010_not_eav ================================================

    __('{{EntitiesLabel}}') ?>

    getRoot()): ?> getAddRootButtonHtml() ?>
    getAddSubButtonHtml() ?>
    getRoot()): ?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/tree/020_eav ================================================

    __('{{EntitiesLabel}}') ?>

    getRoot()): ?> getAddRootButtonHtml() ?>
    getAddSubButtonHtml() ?>
    getStoreSwitcherHtml();?> getRoot()): ?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/entity/widget/tree/010_content ================================================ getId() ?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/form/renderer/fieldset/element/010_content ================================================ getElement() ?> checkFieldDisable() ?> getType()=='hidden'): ?> getElementHtml()) ?> getElementLabelHtml()) ?> getElementHtml()) ?> getNote()) : ?>

    getNote() ?>

    getScopeLabel() ?> canDisplayUseDefault()): ?> getReadonly()):?> disabled="disabled" type="checkbox" name="use_default[]" id="getHtmlId() ?>_default"usedDefault()): ?> checked="checked" onclick="toggleValueElements(this, this.parentNode.parentNode)" value="getAttributeCode() ?>"/> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/adminhtml/template/namespace_module/grid/010_content ================================================

    getHeaderText(); ?>

    getButtonsHtml() ?>
    isSingleStoreMode() ): ?> getChildHtml('store_switcher');?>
    getGridHtml() ?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/010_top ================================================ {{License}} {{defaultLayoutHandle}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/020_comment ================================================ {{customerCommentLinks}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/060_list ================================================ <{{namespace}}_{{module}}_{{entity}}_index translate="label" module="{{namespace}}_{{module}}"> {{referenceHead}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/070_view ================================================ <{{namespace}}_{{module}}_{{entity}}_view translate="label" module="{{namespace}}_{{module}}"> {{referenceHead}} {{EntityViewRelationLayout}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/080_entity_rss ================================================ <{{namespace}}_{{module}}_{{entity}}_rss translate="label" module="{{namespace}}_{{module}}"> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/090_rss_top ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/100_rss ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/110_rss_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/120_relation_product ================================================ {{productViewLayout}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/130_relation_category ================================================ <{{namespace}}_{{module}}_category> {{categoryViewLayout}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/135_entity_comment ================================================ <{{namespace}}_{{module}}_{{entity}}_customer_comment_index translate="label" module="{{namespace}}_{{module}}"> <{{namespace}}_{{module}}_{{entity}}_customer_comment_view translate="label" module="{{namespace}}_{{module}}"> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/layout/namespace_module/140_footer ================================================ ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/catalog/category/list/entity/010_content ================================================ get{{Entity}}Collection();?> count() > 0) :?>

    {{EntitiesLabel}}

    {{entityHtmlLink}}
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/catalog/product/list/entity/010_content ================================================ get{{Entity}}Collection();?> count() > 0) :?>
    {{entityHtmlLink}}
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/catalog/category/list/010_content ================================================ getCategoryCollection();?> count() > 0) :?>

    __('Categories');?>

    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/catalog/product/list/010_content ================================================ getProductCollection();?> count() > 0) :?>

    __('Products');?>

    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/child/list/010_content ================================================ get{{Siblings}}(); ?> getSize() > 0) :?>

    __('{{SiblingsLabel}}') ?>

    {{SiblingListItem}}
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/children/010_content ================================================ get{{Entities}}(); ?> getSize() > 0) :?>

    getCurrent{{Entity}}()->get{{EntityNameMagicCode}}(); ?>:__('Children')?>

    _getDisplayMode() == 0) : ?>
      draw{{Entity}}($_{{entity}});?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/comment/form/010_content ================================================ getCommentData();?>

    __('Write Your Comment') ?>

    getAllowWriteCommentFlag()): ?>

    __('Only registered users can write comments. Please, log in or register', $this->getLoginLink(), Mage::helper('customer')->getRegisterUrl()) ?>

    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/comment/list/010_content ================================================ get{{Entity}}()?> getAllowComments()) : ?> getComments(); ?>

    __('Comments for: %s', $_{{entity}}->get{{EntityNameMagicCode}}()) ?>

    getPagerHtml() ?>
    __('On %s %s wrote:', $this->formatDate($_comment->getCreatedAt(), 'long'), $this->escapeHtml($_comment->getName()))?>
    escapeHtml($_comment->getTitle()) ?>
    escapeHtml($_comment->getComment())) ?>
    getPagerHtml() ?>
    getChildHtml('comment_form') ?> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/customer/comment/list/010_content ================================================ getMessagesBlock()->getGroupedHtml() ?>

    __('My {{EntitiesLabel}} Comments') ?>

    getCollection() && $this->count()): ?> getToolbarHtml() ?> getCollection() as $_comment): ?>
    dateFormat($_comment->getCtCreatedAt()); ?>

    escapeHtml($_comment->get{{EntityNameMagicCode}}()) ?>

    escapeHtml($_comment->getCtTitle()) ?> __('View Details') ?>
    getToolbarHtml() ?>

    __('You have submitted no comments for {{entitiesLabel}}.') ?>

    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/customer/comment/view/010_content ================================================ getMessagesBlock()->getGroupedHtml() ?>

    getComment()->getTitle() ?>

    get{{Entity}}()->get{{EntityNameMagicCode}}()?>

    __('On %s you wrote:', $this->formatDate($this->getComment()->getCreatedAt(), Mage_Core_Model_Locale::FORMAT_TYPE_FULL))?>
    escapeHtml($this->getComment()->getComment());?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/list/010_top ================================================ getMessagesBlock()->getGroupedHtml() ?> get{{Entities}}(); ?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/list/020_rss_link ================================================ isRssEnabled()) : ?> __('Subscribe to RSS Feed')?> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/list/030_footer ================================================

    __('{{EntitiesLabel}}') ?>

    getSize() > 0) :?> getPagerHtml(); ?>
    {{entityHtmlLink}}
    getPagerHtml(); ?> __('There are no {{entitiesLabel}} at this moment');?> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/list/040_footer_is_tree ================================================

    __('{{EntitiesLabel}}') ?>

    getSize() > 0) :?> _getDisplayMode() == 0) : ?> getPagerHtml(); ?>
    {{entityHtmlLink}}
    getPagerHtml(); ?>
      draw{{Entity}}($_{{entity}});?>
    __('There are no {{entitiesLabel}} at this moment');?> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/sibling/list/010_content ================================================ get{{Siblings}}(); ?> getSize() > 0) :?>

    __('{{SiblingsLabel}}') ?>

    {{SiblingListItem}}
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/view/010_content ================================================ getCurrent{{Entity}}();?> getMessagesBlock()->getGroupedHtml() ?>

    get{{EntityNameMagicCode}}(); ?>

    {{EntityViewAttributes}}
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/widget/link/010_content ================================================ getCurrent{{Entity}}();?> ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/widget/subtree/010_content ================================================ get{{Entities}}(); ?> getSize() > 0) :?>
      draw{{Entity}}($_{{entity}});?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/entity/widget/view/010_content ================================================ getCurrent{{Entity}}();?>

    get{{EntityNameMagicCode}}()?>

    {{EntityViewWidgetAttributes}}
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/design/frontend/template/namespace_module/rss/010_content ================================================ getFeeds();?>
    __('{{Module}} Feeds') ?>
    getLabel() ?> __('Get Feed'); ?>
    ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/etc/modules/Namespace_Module/010_content ================================================ {{License}} <{{Namespace}}_{{Module}}> true {{codepool}} {{depends}} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/010_global ================================================ "Yes","Yes" "No","No" "Save And Continue Edit","Save And Continue Edit" "Id","Id" "Action","Action" "Edit","Edit" "CSV","CSV" "Excel","Excel" "XML","XML" "Delete","Delete" "Are you sure?","Are you sure?" "Home","Home" "None","None" "Store views","Store views" "Status","Status" "Enabled","Enabled" "Disabled","Disabled" "Change status","Change status" "Reset","Reset" "Created at","Created at" "Updated at","Updated at" "Total of %d record(s) have been deleted.","Total of %d record(s) have been deleted." "Total of %d record(s) have been updated.","Total of %d record(s) have been updated." "Home","Home" "WYSIWYG Editor","WYSIWYG Editor" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/020_entity ================================================ "{{EntityLabel}}","{{EntityLabel}}" "Save {{EntityLabel}}","Save {{EntityLabel}}" "Delete {{EntityLabel}}","Delete {{EntityLabel}}" "Edit {{EntityLabel}} '%s'","Edit {{EntityLabel}} '%s'" "Add {{EntityLabel}}","Add {{EntityLabel}}" "{{EntitiesLabel}}","{{EntitiesLabel}}" "This {{entityLabel}} no longer exists.","This {{entityLabel}} no longer exists." "{{EntityLabel}} was successfully saved","{{EntityLabel}} was successfully saved" "There was a problem saving the {{entityLabel}}.","There was a problem saving the {{entityLabel}}." "Unable to find {{entityLabel}} to save.","Unable to find {{entityLabel}} to save." "{{EntityLabel}} was successfully deleted.","{{EntityLabel}} was successfully deleted." "There was an error deleting {{entityLabel}}.","There was an error deleting {{entityLabel}}." "Could not find {{entityLabel}} to delete.","Could not find {{entityLabel}} to delete." "Please select {{entitiesLabel}} to delete.","Please select {{entitiesLabel}} to delete." "Total of %d {{entitiesLabel}} were successfully deleted.","Total of %d {{entitiesLabel}} were successfully deleted." "There was an error deleting {{entitiesLabel}}.","There was an error deleting {{entitiesLabel}}." "Total of %d {{entitiesLabel}} were successfully updated.","Total of %d {{entitiesLabel}} were successfully updated." "There was an error updating {{entitiesLabel}}.","There was an error updating {{entitiesLabel}}." "Please select {{entitiesLabel}}.","Please select {{entitiesLabel}}." "{{nameAttributeLabel}}","{{nameAttributeLabel}}" "{{EntityLabel}} was saved","{{EntityLabel}} was saved" "Error saving {{entityLabel}}","Error saving {{entityLabel}}" "The {{entitiesLabel}} has been deleted.","The {{entitiesLabel}} has been deleted." "An error occurred while updating the {{entitiesLabel}}.","An error occurred while updating the {{entitiesLabel}}." "There was an error deleting {{entitiesLabel}}.","There was an error deleting {{entitiesLabel}}." ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/030_attribute ================================================ "{{attributeLabel}}","{{attributeLabel}}" "{{attributeNote}}","{{attributeNote}}" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/040_rss ================================================ "Show in rss","Show in rss" "Enable rss","Enable rss" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/050_seo ================================================ "Meta-title","Meta-title" "Meta-description","Meta-description" "Meta-keywords","Meta-keywords" "Meta information","Meta information" "Meta","Meta" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/060_attribute_yesno ================================================ "Change {{attributeLabel}}","Change {{attributeLabel}}" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/070_file ================================================ "Delete File","Delete File" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/080_product_relation ================================================ "Associated products","Associated products" "Position","Position" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/090_category_relation ================================================ "Associated categories","Associated categories" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/100_relations ================================================ "Position","Position" "Change {{SiblingLabel}}","Change {{SiblingLabel}}" " - Edit"," - Edit" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/110_tree ================================================ "Collapse All","Collapse All" "Expand All","Expand All" "ID: %s","ID: %s" "Display as tree","Display as tree" "Root","Root" "Levels to show (0 for all)","Levels to show (0 for all)" "Recursion level","Recursion level" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/120_tree_entity ================================================ "New Root {{EntityLabel}}","New Root {{EntityLabel}}" "Add Child {{EntityLabel}}","Add Child {{EntityLabel}}" "Add Root {{EntityLabel}}","Add Root {{EntityLabel}}" "New {{EntityLabel}}","New {{EntityLabel}}" "Manage {{EntitiesLabel}}","Manage {{EntitiesLabel}}" "{{EntityLabel}} move error","{{EntityLabel}} move error" "An error occurred while trying to delete the {{entityLabel}}.","An error occurred while trying to delete the {{entityLabel}}." "The {{entityLabel}} has been saved.","The {{entityLabel}} has been saved." "{{EntityLabel}} move operation is not possible: the new parent {{entityLabel}} was not found.","{{EntityLabel}} move operation is not possible: the new parent {{entityLabel}} was not found." "{{EntityLabel}} move operation is not possible: the current {{entityLabel}} was not found.","{{EntityLabel}} move operation is not possible: the current {{entityLabel}} was not found." "{{EntityLabel}} move operation is not possible: parent {{entityLabel}} is equal to child {{entityLabel}}.","{{EntityLabel}} move operation is not possible: parent {{entityLabel}} is equal to child {{entityLabel}}." "Can't delete root {{entityLabel}}.","Can't delete root {{entityLabel}}." "{{EntityLabel}} subtree","{{EntityLabel}} subtree" "{{EntityLabel}} subtree widget","{{EntityLabel}} subtree widget" "Select {{EntityLabel}}","Select {{EntityLabel}}" "{{EntityLabel}} move operation is not possible: the new parent {{entityLabel}} was not found.","{{EntityLabel}} move operation is not possible: the new parent {{entityLabel}} was not found." "{{EntityLabel}} move operation is not possible: the current {{entityLabel}} was not found.","{{EntityLabel}} move operation is not possible: the current {{entityLabel}} was not found." "{{EntityLabel}} move operation is not possible: parent {{entityLabel}} is equal to child {{entityLabel}}.","{{EntityLabel}} move operation is not possible: parent {{entityLabel}} is equal to child {{entityLabel}}." "Can't delete root {{entityLabel}}.","Can't delete root {{entityLabel}}." "An error occurred while trying to delete the {{entityLabel}}.","An error occurred while trying to delete the {{entityLabel}}." ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/130_url_rewrite ================================================ "Relative to Website Base URL","Relative to Website Base URL" "URL key already exists.","URL key already exists." "The URL key contains capital letters or disallowed symbols.","The URL key contains capital letters or disallowed symbols." "URL key","URL key" "The URL key cannot consist only of numbers.","The URL key cannot consist only of numbers." "URL prefix","URL prefix" "Leave empty for no prefix","Leave empty for no prefix" "What goes after the dot. Leave empty for no suffix.","What goes after the dot. Leave empty for no suffix." "URL suffix","URL suffix" "URL key for list page","URL key for list page" "Leave empty to use default URL module/controller/action","Leave empty to use default URL module/controller/action" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/140_api ================================================ "List","List" "Info","Info" "Add","Add" "Update","Update" "Remove","Remove" "Data cannot be null","Data cannot be null" "Product does not exist.","Product does not exist." "Provided data is invalid.","Provided data is invalid." ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/150_api_entity ================================================ "{{EntityLabel}} API","{{EntityLabel}} API" "Retrieve list of {{entitiesLabel}}","Retrieve list of {{entitiesLabel}}" "Retrieve {{entity}} info","Retrieve {{entity}} info" "Add {{entityLabel}}","Add {{entityLabel}}" "Update {{entityLabel}}","Update {{entityLabel}}" "Remove {{entityLabel}}","Remove {{entityLabel}}" "Requested {{entityLabel}} does not exist.","Requested {{entityLabel}} does not exist." "Error while saving {{entityLabel}}. Details in error message.","Error while saving {{entityLabel}}. Details in error message." "Error while removing {{entityLabel}}. Details in error message.","Error while removing {{entityLabel}}. Details in error message." "{{EntityLabel}}","{{EntityLabel}}" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/160_api_product_related ================================================ "Product does not exist.","Product does not exist." "Remove product from {{entityLabel}}","Remove product from {{entityLabel}}" "Assign product to {{entityLabel}}","Assign product to {{entityLabel}}" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/170_api_category_related ================================================ "Category does not exist.","Category does not exist." "Remove category from {{entityLabel}}","Remove category from {{entityLabel}}" "Assign category to {{entityLabel}}","Assign category to {{entityLabel}}" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/180_api_tree ================================================ "Retrieve one level of {{entitiesLabel}}","Retrieve one level of {{entitiesLabel}}" "Move {{entityLabel}} in tree","Move {{entityLabel}} in tree" "Cannot move parent inside {{entityLabel}}","Cannot move parent inside {{entityLabel}}" "{{EntityLabel}} not moved. Details in error message.","{{EntityLabel}} not moved. Details in error message." ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/190_api_sibling ================================================ "Assign {{siblingLabel}} to {{entityLabel}}","Assign {{siblingLabel}} to {{entityLabel}}" "Remove {{siblingLabel}} from {{entityLabel}}","Remove {{siblingLabel}} from {{entityLabel}}" "{{SiblingLabel}} does not exist.","{{SiblingLabel}} does not exist." ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/200_entity_eav ================================================ "Manage {{EntityLabel}} Attributes","Manage {{EntityLabel}} Attributes" "Add New {{EntityLabel}} Attribute","Add New {{EntityLabel}} Attribute" "Save {{EntityLabel}} Attribute","Save {{EntityLabel}} Attribute" "Delete {{EntityLabel}} Attribute","Delete {{EntityLabel}} Attribute" "Edit {{EntityLabel}} Attribute ""%s""","Edit {{EntityLabel}} Attribute ""%s""" "Edit {{EntityLabel}} Attribute","Edit {{EntityLabel}} Attribute" "New {{EntityLabel}} Attribute","New {{EntityLabel}} Attribute" "{{EntityLabel}} Information","{{EntityLabel}} Information" "This {{entityLabel}} attribute no longer exists","This {{entityLabel}} attribute no longer exists" "This {{entityLabel}} attribute cannot be edited.","This {{entityLabel}} attribute cannot be edited." "The {{entityLabel}} attribute has been saved.","The {{entityLabel}} attribute has been saved." "The {{entityLabel}} attribute has been deleted.","The {{entityLabel}} attribute has been deleted." ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/210_eav ================================================ "Image","Image" "File","File" "Store View","Store View" "Website","Website" "Global","Global" "Scope","Scope" "Declare attribute value saving scope","Declare attribute value saving scope" "Position","Position" "Position in the admin form","Position in the admin form" "Frontend Properties","Frontend Properties" "Enable WYSIWYG","Enable WYSIWYG" "Attribute Information","Attribute Information" "Properties","Properties" "Manage Label / Options","Manage Label / Options" "[GLOBAL]","[GLOBAL]" "[WEBSITE]","[WEBSITE]" "[STORE VIEW]","[STORE VIEW]" "Attributes","Attributes" "Manage Attributes","Manage Attributes" "Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.","Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter." "This attribute no longer exists","This attribute no longer exists" "This attribute cannot be updated.","This attribute cannot be updated." "This attribute cannot be deleted.","This attribute cannot be deleted." "Unable to find an attribute to delete.","Unable to find an attribute to delete." "Default Values","Default Values" "Attribute ""%s"" is required.","Attribute ""%s"" is required." "This attribute is not deletable","This attribute is not deletable" "Text to appear below the input.","Text to appear below the input." "Note","Note" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/220_entity_comment ================================================ "{{EntityLabel}} Comments","{{EntityLabel}} Comments" "Save {{EntityLabel}} comment","Save {{EntityLabel}} comment" "Delete {{EntityLabel}} comment","Delete {{EntityLabel}} comment" "Edit {{EntityLabel}} comment '%s'","Edit {{EntityLabel}} comment '%s'" "{{EntityLabel}} Comment","{{EntityLabel}} Comment" "{{EntityLabel}} comment","{{EntityLabel}} comment" "This {{entityLabel}} does not allow comments","This {{entityLabel}} does not allow comments" "My {{EntityLabel}} Comments","My {{EntityLabel}} Comments" "You have submitted no comments for {{entitiesLabel}}.","You have submitted no comments for {{entitiesLabel}}." "My {{EntitiesLabel}} comment view","My {{EntitiesLabel}} comment view" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/230_comment ================================================ "Comment","Comment" "Comments","Comments" "Title","Title" "Status","Status" "Pending","Pending" "Approved","Approved" "Rejected","Rejected" "Poster name","Poster name" "Customer profile","Customer profile" "Poster e-mail","Poster e-mail" "Allow Comments","Allow Comments" "Allow guest comments","Allow guest comments" "This comment no longer exists.","This comment no longer exists." "Comment was successfully saved","Comment was successfully saved" "There was a problem saving the comment.","There was a problem saving the comment." "Unable to find comment to save.","Unable to find comment to save." "Comment was successfully deleted.","Comment was successfully deleted." "There was an error deleting the comment.","There was an error deleting the comment." "Could not find comment to delete.","Could not find comment to delete." "Please select comments to delete.","Please select comments to delete." "Total of %d comments were successfully deleted.","Total of %d comments were successfully deleted." "There was an error deleting comments.","There was an error deleting comments." "Please select comments.","Please select comments." "Total of %d comments were successfully updated.","Total of %d comments were successfully updated." "There was an error updating comments.","There was an error updating comments." "Your comment has been accepted for moderation.","Your comment has been accepted for moderation." "Unable to post the comment.","Unable to post the comment." "Guest comments are not allowed","Guest comments are not allowed" "Use default config","Use default config" "Comment title can't be empty","Comment title can't be empty" "Your name can't be empty","Your name can't be empty" "Comment can't be empty","Comment can't be empty" "View Details","View Details" "On %s you wrote:","On %s you wrote:" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/240_comment_store ================================================ "Store views","Store views" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/250_api_comment ================================================ "Update {{EntityLabel}} Status","Update {{EntityLabel}} Status" "List","List" "Update status","Update status" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/260_eav_api ================================================ "Set/Get current store view","Set/Get current store view" "Retrieve attribute list","Retrieve attribute list" "Retrieve attribute options","Retrieve attribute options" "Get list of possible attribute types","Get list of possible attribute types" "Create new attribute","Create new attribute" "Update attribute","Update attribute" "Delete attribute","Delete attribute" "Get full information about attribute with list of options","Get full information about attribute with list of options" "Add option","Add option" "Remove option","Remove option" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/270_frontend ================================================ "Use Breadcrumbs","Use Breadcrumbs" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/280_entity_seo ================================================ "Meta title for {{entitiesLabel}} list page","Meta title for {{entitiesLabel}} list page" "Meta description for {{entitiesLabel}} list page","Meta description for {{entitiesLabel}} list page" "Meta keywords for {{entitiesLabel}} list page","Meta keywords for {{entitiesLabel}} list page" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/290_rest ================================================ "{{Module}}","{{Module}}" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/300_rest_entity ================================================ "{{Entity}}","{{Entity}}" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/app/locale/310_parent ================================================ "View {#name}","View {#name}" ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/skin/css/namespace_module/tree/010_content ================================================ {{License}} .tree,.tree ul,.tree li{list-style:none;margin:0;padding:0;} .tree{background:url(../../images/{{namespace}}_{{module}}/line1.png) repeat-y;} .tree li{line-height:20px;margin-top:1px;position:relative;width:100%;} * html .tree li{float:left;display:inline;} .tree li a{padding-left:28px;} .tree li span{cursor:auto;float:left;font-size:0;height:13px;left:5px;position:absolute;top:5px;width:13px;} .tree li span,.tree li span.collapsed{background:url(../../images/{{namespace}}_{{module}}/collapsed.png) no-repeat 0 0;} .tree li span.expanded{background:url(../../images/{{namespace}}_{{module}}/expanded.png) no-repeat 0 0;} .tree li ul{margin-left:28px;background:url(../../images/{{namespace}}_{{module}}/line1.png) repeat-y;} .tree li li{background:url(../../images/{{namespace}}_{{module}}/line2.png) no-repeat 0 0;} .tree:after,.tree ul:after{clear:both;content:".";display:block;height:0;visibility:hidden;} .tree,.tree ul{display:block;} .tree li.map-category{font-weight:bold;} .tree li.map-product{font-weight:normal;} .tree li.map-product a{color:#203548;} /* \*/ .tree,.tree ul{min-height:1%;} * html .tree,* html .tree ul{height:1%;} ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/source/skin/js/namespace_module/tree/010_content ================================================ {{License}} function {{module}}Tree(treeId) { var tree = $(treeId); if (tree) { tree.addClassName('tree'); tree.select('ul').each(function(list) { $(list).hide(); }) tree.select('li').each(function(item) { var children = $(item).childElements().grep(new Selector('ul')); if (children.length > 0) { var span = new Element('span').addClassName('collapsed'); span.observe('click', function(el) { if ($(this).hasClassName('collapsed')) { this.addClassName('expanded'); this.removeClassName('collapsed'); $(item).childElements().grep(new Selector('ul')).each(function(list) { $(list).show(); }); } else { this.removeClassName('expanded'); this.addClassName('collapsed'); $(item).childElements().grep(new Selector('ul')).each(function(list) { $(list).hide(); }); } }); $(item).insert({top:span}); } }); }; }; ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/system.xml ================================================ 500 separator-top umc text 100 1 0 0 5 1 0 0 select adminhtml/system_config_source_yesno 10 1 0 0 After you get the hang of it you can disable the help tab to make it a little faster. select adminhtml/system_config_source_yesno 15 1 0 0 After you get the hang of it you can disable the field tooltips to make it a little faster. select adminhtml/system_config_source_yesno 20 1 0 0 modulecreator/adminhtml_modulecreator_system_config_form_fieldset_settings 10 1 0 0 modulecreator/adminhtml_modulecreator_system_config_form_fieldset_entity 20 1 0 0 modulecreator/adminhtml_modulecreator_system_config_form_fieldset_attribute 30 1 0 0 ================================================ FILE: app/code/community/Ultimate/ModuleCreator/etc/umc.xml ================================================ This tab allows you to fill in the general data about your module text 1 10 1 umc-validate-class-name This is the folder name of your new extension. Your company name should go here. Use only letters and numbers. Start with a capital letter. text 1 20 umc-validate-class-name Try to use a noun in singular form. Start with a capital letter.]]> For security reasons, to avoid module name collisions with the Magento core you cannot name a module just like an existing one even in a different namespace: "Catalog", "Sales", "Checkout"... select modulecreator/source_codepool 1 25 1 select 1 modulecreator/source_install 30 1 Warning:The zip is not compatible with Magento Connect. It's just a simple archive with the files of the module.
    If you choose to install the module directly no file will be overwritten. If by a human error or UMC error a file should be overwritten then the 'Action' is changed to 'Create an archive. I will install it later.' and you will be notified of the files that were not overwritten.]]>
    text 1 35 1 text 1 40 This is the title that will be added to the menu. text menu 0 50 1 menu-parent-id This is the parent menu id of the module menu. Leave empty to add in top menu. Select menu parent and position]]> text sort_order 1 60 menu-sort-order 1 This is the sort order in the menu. Select menu parent and position]]> text system_tab 0 70 0 Configuration will be created. Fill in the tab name here. Leave empty to use the namespace.]]> text system_tab 0 70 1 Configuration will be created. Fill in the tab position. The higher the number the lower it will appear in the list.]]> textarea license 0 70 1 Use {{Namespace}} as a placeholder for namespace, {{Module}} as a placeholder for the module name and {{Y}} as placeholder for current year.
    If you don't want any License text on your files just leave this field empty.]]>
    text front_key 0 80 0
    Settings regarding the entity name and code 1 text 1 label-singular 10 This is the singular form of the label. For example in a blog module, the post entity will have the label in singular form 'Post']]> Info:Try to use English words for this label. It's not mandatory, but it makes the taxonomy more readable. UMC will create a language file for the modules it generates and you can translate your module.
    Info:I recommend the first letter to be uppercase.]]>
    text 1 20 This is the plural form of the label above. It will be used for lists. (For example: 'Posts') Info:Try to use English words for this label. It's not mandatory, but it makes the taxonomy more readable. UMC will create a language file for the modules it generates and you can translate your module.
    Info:I recommend the first letter to be uppercase.]]>
    text 1 validate-alphanum validate-code 30 For example it's easier to read foreach ($_posts as $_post){...} or $_post->getTags() than foreach ($_list as $_item){...} or $_entity->getRelated('tags');
    The value you fill in here will be used for variable names, file names and table names.]]>
    Info:Use only letters. No numbers, no underscores, all in lowercase.
    Info::There are some restrictions to these values, because there are reserved strings that might make the code not function properly. For example: 'resource', 'setup'. For a complete list of restrictions see Ultimate_ModuleCreator_Helper_Data::$_restrictedEntityNames]]>
    text 1 validate-alphanum validate-code 40 Info:Use only letters. No numbers, no underscores, all in lowercase.]]>
    Backend settings for you entity 1 select modulecreator/source_entity_type 1 10 type 1 EAV and Flat (all fields in one table). Choose yours]]> select adminhtml/system_config_source_yesno 1 20 is_tree 1 If this is set to 'Yes' then your entity will behave as the default Magento categories. It will have the same UI as the categories module have. The fields 'parent_id', 'position' 'children_count' & 'level' will be added automatically to the entity. select adminhtml/system_config_source_yesno 1 25 store-specific 1 If this is set to 'Yes' it will allow you to assign your entity to specific store views (just like pages or static block). select adminhtml/system_config_source_yesno 1 30 use-not-tree 1 If this is set to 'Yes' the 'Created at' field will be added to the admin grid.]]> select adminhtml/system_config_source_yesno 1 40 use-not-tree 1 If this is set to 'Yes' the 'Updated at' field will be added to the admin grid.]]> select adminhtml/system_config_source_yesno 1 50 use-not-tree 1 If you set this to 'Yes' than it will search in your entity also.]]> select adminhtml/system_config_source_yesno 1 60 1 If this is set to 'Yes', then your entity will also be available for managing through the SOAP API.
    It generates the classes and xml files needed for API V1, API V2 and API V2 with WSI compliance.]]>
    select adminhtml/system_config_source_yesno 1 60 1 If this is set to 'Yes', then your entity will also be available for managing through the REST API.
    It generates the classes and xml files needed.]]>
    Frontend settings for your entity 1 select adminhtml/system_config_source_yesno 1 10 create-frontend 1 If this is set to 'No', all the other fields in this section will not be available.]]> select adminhtml/system_config_source_yesno 1 20 create-list use-frontend 1 If this is set to 'Yes', a link will be added to the footer to a page where your entity instances will be listed. The page has a toolbar for pagination, and it will list the titles of the entity instances. select modulecreator/source_entity_layout 1 30 use-frontend use-create-list 1 From this dropdown you can select the layout of your entity list page from the available page formats. If you have any other page layout it will appear here.]]> select modulecreator/source_entity_menu 0 35 use-frontend use-create-list 1 Select the menu where you want to add the link to your entities. It may not work on very custom themes. select adminhtml/system_config_source_yesno 1 40 create-view use-frontend 1 select modulecreator/source_entity_layout 1 50 use-frontend use-create-view 1 If you have any other page layout it will appear here.]]> select adminhtml/system_config_source_yesno 1 60 use-frontend use-create-view 1 select adminhtml/system_config_source_yesno 1 70 use-frontend use-create-view url-rewrite 1 This will allow you to use SEF url's for your entity view pages. Example: http://mysite.com/some-key-here.html]]> warningThis field is available only if 'Create entity view page' is set to 'Yes'.]]> text 0 71 use-frontend use-create-list use-url-rewrite 0 text 0 73 use-frontend use-create-view use-url-rewrite 1 text 0 77 use-frontend use-create-view use-url-rewrite 1 select adminhtml/system_config_source_yesno 1 80 rss use-frontend 1 Also a new fields called 'in_rss' will be added to your entity. This will allow you to filter the entities listed in the RSS feed.
    You can disable the RSS feature later from the configuration section of your module.]]>
    Known issue:If all the default Magento RSS feeds are disabled, but the general RSS feed is enabled and the RSS feed for your entity is also enabled a message will apprear on the RSS list page: 'There are no Rss Feeds'. This happens because Magento RSS list functionality does not allow adding custom RSS feeds without overriding a block.]]>
    select adminhtml/system_config_source_yesno 1 90 widget use-frontend 1 One widget will allow you to add a link to your entity instance and one will allow you to add a few details about your entity in CMS page or block.]]> select adminhtml/system_config_source_yesno 1 100 allow-comment use-frontend use-create-view 1 warning:This option is available only if "Create frontend view" is set to 'Yes'.]]> select adminhtml/system_config_source_yesno 1 110 use-frontend use-allow-comment use-create-view 1 warning:This option is available only if "Allow comments" is set to 'Yes'.]]>
    Entity links with products 1 select adminhtml/system_config_source_yesno 10 link-product 1 Also on your entity add/edit page a similar tab listing all the products will be added.]]> select adminhtml/system_config_source_yesno 20 use-link-product 1 Info: This field is available only if 'Link "many to many" with products' is set to 'Yes'.]]> select adminhtml/system_config_source_yesno 30 use-frontend use-create-view use-link-product 1 Info: This field is available only if 'Link "many to many" with products' is set to 'Yes'.]]> select adminhtml/system_config_source_yesno 40 product-attribute 1 This will add a new dropdown attribute to the product where the options will be your entity instances. text 50 1 use-product-attribute validate-code Fill in the dropdown attribute code. select modulecreator/source_attribute_scope 60 use-product-attribute 1 Select the product attribute scope. text 60 use-product-attribute 1 The name of the attribute group where the attribute will be added. If you leave it empty the attribute will not be added to the attribute sets. If the group does not exist it will be created. Entity links with catalog categories 1 select adminhtml/system_config_source_yesno 10 link-category 1 Also on your entity add/edit page a similar tab listing all the categories will be added.]]> select adminhtml/system_config_source_yesno 20 use-link-category 1 select adminhtml/system_config_source_yesno 30 use-frontend use-create-view use-link-category 1 Info: This field is available only if 'Link "many to many" with categories' is set to 'Yes'.]]> select adminhtml/system_config_source_yesno 40 category-attribute 1 This will add a new dropdown attribute to the category where the options will be your entity instances. text 1 50 use-category-attribute validate-code Fill in the dropdown attribute code. select modulecreator/source_attribute_scope 60 use-category-attribute 1 Select the category attribute scope. text 60 use-category-attribute 1 The name of the attribute group where the attribute will be added. If you leave it empty the attribute will not be added to the category attribute set. If the group does not exist it will be created.
    Configure the field / attribute assigned to the entity 1 1 text 1 10 validate-code There are some naming restriction. For example the code cannot be: "data", "child]]> select 1 modulecreator/source_attribute_type 30 attribute-type 1 This is the attribute type. This wil determine the table column type for this field/attribute and its behavior. select 1 modulecreator/source_attribute_scope 40 1 attribute-scope This is the attribute scope. It is available only for EAV entities. It works similar to the product attribute scope. text 0 50 This will be added as a comment under the field in the admin add/edit form. hidden 0 60 position This is the sort order of the field in the add/edit form. radio 0 70 validate-one-required-by-name is_name type-text type-int type-signedint type-decimal type-timestamp select 1 80 adminhtml/system_config_source_yesno 1 This sets the attribute as required in the admin add/edit form. Is available for all the attribute types. select 1 90 adminhtml/system_config_source_yesno type-textarea 1 This allows you to use a WYSIWYG editor for the attribute. It is available only for Textarea attributes. select 1 100 adminhtml/system_config_source_yesno 1 type-text type-yesno type-timestamp type-int type-signedint type-decimal type-website type-dropdown type-country select 1 110 adminhtml/system_config_source_yesno type-all use-create-view use-frontend 1 select 1 120 adminhtml/system_config_source_yesno type-all use-widget use-frontend 1 select 1 130 adminhtml/system_config_source_yesno type-all use-rss use-frontend 1 select 1 140 modulecreator/source_attribute_value_source type-dropdown type-multiselect is-source 1 For dropdown and multiselect attributes you can set the values manually or use the values from a product attribute, a category attribute or a customer attribute. text 1 160 type-dropdown type-multiselect not-custom-source If you choose to use the values of an attribute as values for the dropdown field enter here the attribute code to use. If the product (or category or customer) attribute does not have values or does not support values you will not see any options. textarea 1 170 type-dropdown type-multiselect custom-source One option on each row If you choose to enter the values for the dropdown or multiselect manually, input them here. Separate the options with | (pipe). If you want an empty option at the begining start with a | (pipe) symbol. textarea 0 180 type-text type-textarea type-timestamp type-dropdown type-multiselect type-decimal type-int type-yesno type-country dropdown-custom-source Fill in a default value for the attribute. Leave empty for no value. For dropdown and multiselect attributes the value, must be a valid value. not valid ones will be removed. For the multiselect attributes add one default value on each line. For Yes/No attribtues enter 1 for Yes, 0 for No. For country attributes fill in the country ISO2 code. You cannot set a default value for dropdown and multiselect attributes that use a source model and on image and file attributes.
    modulecreator/entity_type_flat modulecreator/entity_type_eav modulecreator/attribute_type_country dropdown 0 1 modulecreator/attribute_type_decimal text 1 0 modulecreator/attribute_type_dropdown dropdown 0 1 modulecreator/attribute_type_file file 0 0 modulecreator/attribute_type_image file 0 0 modulecreator/attribute_type_int text 1 0 modulecreator/attribute_type_signedint text 1 0 modulecreator/attribute_type_multiselect dropdown 0 0 modulecreator/attribute_type_text text 1 0 modulecreator/attribute_type_yesno dropdown 0 1 modulecreator/attribute_type_timestamp date 0 0 modulecreator/attribute_type_dropdown_custom modulecreator/attribute_type_dropdown_product modulecreator/attribute_type_dropdown_category modulecreator/attribute_type_dropdown_customer The entities are not related in any way. . A field will be added to the second entity table as a reference to the first entity.]]> . A field will be added to the first entity table as a reference to the first entity.]]> The entities are in a many to many relation. A new table will be created to support this relation containing the ids of each entity.