From 3330e258c428b08d5e5e64a4fedbd2acb0cf1396 Mon Sep 17 00:00:00 2001 From: mage2-team Date: Tue, 3 Jul 2012 12:39:35 -0700 Subject: [PATCH] Update as of 7/3/2012 * Refactored backend (admin) menu generation: * Menu is separated from `adminhtml.xml` files into `menu.xml` files * Rendering menu became responsibility of `Mage_Backend` instead of `Mage_Adminhtml` module * Implemented XML-Schema for `menu.xml` * Actions with menu items defined in schema: add, remove, move, update, change parent and position * Refactored customers import feature. New ability to provide import data in 3 files: master file (key customer information) + address file (customer id + address info) + financial file (customer id + reward points & store credit) * Optimized memory consumption in integration tests: * Found and eliminated memory leaks in `Mage_Core_Model_App_Area`, `Mage_Core_Model_Layout` * Manually unset objects from PHPUnit test case object in `tearDown()` in integration tests. Garbage collector didn't purge them because of these references * Disabled running `integrity` test suite by default in integration tests * Improvements in visual design editor JavaScript: * eliminated dependency of code on HTML-literals, reduced code coupling between templates and JavaScript files * implemented blocking unwanted JavaScript activity in visual design editor mode * Various fixes in UX, code stability, modularity * GitHub requests: * [#23](https://github.com/magento/magento2/pull/23) -- added `Mage_Customer_Block_Account_Navigation::removeLink()` --- CHANGELOG.markdown | 25 +- app/code/core/Mage/Admin/Model/Config.php | 16 - .../Mage/AdminNotification/etc/adminhtml.xml | 11 - .../AdminNotification/etc/adminhtml/menu.xml | 32 + .../Block/Report/Product/Viewed/Grid.php | 2 +- .../Block/System/Email/Template/Edit.php | 8 +- .../Adminhtml/Controller/Sales/Creditmemo.php | 2 +- .../Adminhtml/Controller/Sales/Invoice.php | 2 +- .../Adminhtml/Controller/Sales/Shipment.php | 2 +- .../Model/System/Config/Source/Admin/Page.php | 161 ++--- .../controllers/Api/RoleController.php | 2 +- .../controllers/Api/UserController.php | 2 +- .../Adminhtml/controllers/CacheController.php | 2 +- .../Catalog/CategoryController.php | 2 +- .../Catalog/Product/AttributeController.php | 2 +- .../Catalog/Product/ReviewController.php | 8 +- .../Catalog/Product/SetController.php | 6 +- .../controllers/Catalog/ProductController.php | 4 +- .../controllers/Catalog/SearchController.php | 2 +- .../Checkout/AgreementController.php | 2 +- .../controllers/Cms/BlockController.php | 2 +- .../controllers/Cms/PageController.php | 2 +- .../controllers/Customer/GroupController.php | 4 +- .../controllers/Customer/OnlineController.php | 2 +- .../controllers/CustomerController.php | 4 +- .../controllers/DashboardController.php | 2 +- .../Newsletter/ProblemController.php | 2 +- .../Newsletter/QueueController.php | 4 +- .../Newsletter/SubscriberController.php | 2 +- .../Newsletter/TemplateController.php | 4 +- .../controllers/NotificationController.php | 2 +- .../controllers/Poll/AnswerController.php | 2 +- .../Adminhtml/controllers/PollController.php | 4 +- .../controllers/Promo/CatalogController.php | 2 +- .../controllers/Promo/QuoteController.php | 2 +- .../Adminhtml/controllers/PromoController.php | 2 +- .../controllers/RatingController.php | 4 +- .../controllers/Report/CustomerController.php | 6 +- .../controllers/Report/ProductController.php | 8 +- .../controllers/Report/ReviewController.php | 6 +- .../controllers/Report/SalesController.php | 14 +- .../controllers/Report/ShopcartController.php | 6 +- .../Report/StatisticsController.php | 2 +- .../controllers/Report/TagController.php | 12 +- .../controllers/ReportController.php | 58 +- .../Sales/Billing/AgreementController.php | 4 +- .../Sales/Order/CreateController.php | 2 +- .../Sales/Order/CreditmemoController.php | 4 +- .../Sales/Order/EditController.php | 2 +- .../Sales/Order/InvoiceController.php | 4 +- .../Sales/Order/ShipmentController.php | 4 +- .../Sales/Order/StatusController.php | 2 +- .../controllers/Sales/OrderController.php | 2 +- .../Sales/Recurring/ProfileController.php | 4 +- .../Sales/TransactionsController.php | 4 +- .../controllers/SitemapController.php | 2 +- .../controllers/System/AccountController.php | 2 +- .../controllers/System/BackupController.php | 2 +- .../controllers/System/ConfigController.php | 2 +- .../System/Convert/GuiController.php | 4 +- .../System/Convert/ProfileController.php | 4 +- .../controllers/System/CurrencyController.php | 2 +- .../controllers/System/DesignController.php | 4 +- .../System/Email/TemplateController.php | 4 +- .../controllers/System/StoreController.php | 2 +- .../controllers/System/VariableController.php | 2 +- .../controllers/SystemController.php | 2 +- .../Adminhtml/controllers/TagController.php | 6 +- .../Tax/Class/CustomerController.php | 2 +- .../Tax/Class/ProductController.php | 2 +- .../controllers/Tax/RateController.php | 4 +- .../controllers/Tax/RuleController.php | 2 +- .../controllers/UrlrewriteController.php | 4 +- .../core/Mage/Adminhtml/etc/adminhtml.xml | 80 --- .../Mage/Adminhtml/etc/adminhtml/menu.xml | 46 ++ .../Adminhtml/view/adminhtml/admin/page.phtml | 2 +- .../view/adminhtml/admin/popup.phtml | 2 +- .../Mage/Adminhtml/view/adminhtml/catalog.xml | 3 +- .../Adminhtml/view/adminhtml/customer.xml | 1 + .../Mage/Adminhtml/view/adminhtml/main.xml | 1 - .../Mage/Adminhtml/view/adminhtml/tag.xml | 2 + app/code/core/Mage/Api/etc/adminhtml.xml | 22 - app/code/core/Mage/Api/etc/adminhtml/menu.xml | 34 + .../Adminhtml/Api2/AttributeController.php | 4 +- .../Adminhtml/Api2/RoleController.php | 6 +- app/code/core/Mage/Api2/etc/adminhtml.xml | 20 - .../core/Mage/Api2/etc/adminhtml/menu.xml | 33 + app/code/core/Mage/Backend/Block/Menu.php | 305 ++------ .../Mage/Backend/Block/Menu/Container.php | 99 +++ .../core/Mage/Backend/Block/Menu/Item.php | 115 +++ .../core/Mage/Backend/Block/Widget/Grid.php | 2 +- .../Backend/Controller/ActionAbstract.php | 6 +- app/code/core/Mage/Backend/Model/Menu.php | 239 +++++++ .../core/Mage/Backend/Model/Menu/Builder.php | 124 ++++ .../Model/Menu/Builder/Command/Add.php | 71 ++ .../Model/Menu/Builder/Command/Remove.php | 44 ++ .../Model/Menu/Builder/Command/Update.php | 45 ++ .../Model/Menu/Builder/CommandAbstract.php | 116 +++ .../core/Mage/Backend/Model/Menu/Config.php | 174 +++++ .../Mage/Backend/Model/Menu/Config/Menu.php | 115 +++ .../Backend/Model/Menu/Config/Menu/Dom.php | 47 ++ .../Mage/Backend/Model/Menu/Config/menu.xsd | 169 +++++ .../Mage/Backend/Model/Menu/Director/Dom.php | 153 ++++ .../Backend/Model/Menu/DirectorAbstract.php | 66 ++ .../core/Mage/Backend/Model/Menu/Factory.php | 39 ++ .../Backend/Model/Menu/Filter/Iterator.php | 41 ++ .../core/Mage/Backend/Model/Menu/Item.php | 479 +++++++++++++ .../Mage/Backend/Model/Menu/Item/Factory.php | 150 ++++ .../Backend/Model/Menu/Item/Validator.php | 147 ++++ .../Model/Menu/Iterator.php} | 20 +- .../core/Mage/Backend/Model/Menu/Logger.php | 62 ++ app/code/core/Mage/Backend/Model/Url.php | 73 +- app/code/core/Mage/Backend/etc/config.xml | 7 + .../Mage/Backend/view/adminhtml/layout.xml | 11 + .../Mage/Backend/view/adminhtml/menu.phtml | 6 +- .../view/adminhtml/menu/container.phtml | 32 + .../Backend/view/adminhtml/menu/item.phtml | 37 + app/code/core/Mage/Backup/etc/adminhtml.xml | 14 - .../core/Mage/Backup/etc/adminhtml/menu.xml | 32 + .../core/Mage/Bundle/view/frontend/layout.xml | 18 +- app/code/core/Mage/Captcha/Helper/Data.php | 134 +++- app/code/core/Mage/Captcha/Model/Zend.php | 105 ++- .../Mage/Captcha/view/frontend/layout.xml | 4 +- .../Mage/Captcha/view/frontend/onepage.js | 58 ++ .../Mage/Captcha/view/frontend/zend.phtml | 4 +- .../Catalog/Model/Resource/Category/Flat.php | 46 +- app/code/core/Mage/Catalog/etc/adminhtml.xml | 41 -- .../core/Mage/Catalog/etc/adminhtml/menu.xml | 38 + .../core/Mage/CatalogRule/etc/adminhtml.xml | 13 - .../Mage/CatalogRule/etc/adminhtml/menu.xml | 33 + .../core/Mage/CatalogSearch/etc/adminhtml.xml | 11 - .../Mage/CatalogSearch/etc/adminhtml/menu.xml | 32 + app/code/core/Mage/Checkout/etc/adminhtml.xml | 11 - .../core/Mage/Checkout/etc/adminhtml/menu.xml | 32 + .../Mage/Checkout/view/frontend/layout.xml | 12 - .../view/frontend/onepage/login.phtml | 2 +- app/code/core/Mage/Cms/etc/adminhtml.xml | 18 - app/code/core/Mage/Cms/etc/adminhtml/menu.xml | 34 + .../Adminhtml/Extension/CustomController.php | 2 +- app/code/core/Mage/Connect/etc/adminhtml.xml | 20 - .../core/Mage/Connect/etc/adminhtml/menu.xml | 34 + .../Mage/Connect/view/adminhtml/layout.xml | 5 +- app/code/core/Mage/Core/Block/Abstract.php | 13 + .../Controller/Varien/Router/Abstract.php | 19 +- app/code/core/Mage/Core/Model/App.php | 2 +- app/code/core/Mage/Core/Model/App/Area.php | 19 +- .../core/Mage/Core/Model/Event/Manager.php | 43 ++ app/code/core/Mage/Core/Model/Layout.php | 11 + app/code/core/Mage/Core/Model/Logger.php | 58 ++ .../core/Mage/Core/Model/Store/Config.php | 50 ++ app/code/core/Mage/Core/etc/config.xml | 2 +- app/code/core/Mage/Core/etc/system.xml | 4 +- .../System/CurrencysymbolController.php | 2 +- .../Mage/CurrencySymbol/etc/adminhtml.xml | 22 - .../CurrencySymbol/etc/adminhtml/menu.xml | 34 + .../Customer/Block/Account/Navigation.php | 12 + app/code/core/Mage/Customer/etc/adminhtml.xml | 24 - .../core/Mage/Customer/etc/adminhtml/menu.xml | 35 + .../Customer/view/frontend/widget/name.phtml | 4 +- .../System/Design/EditorController.php | 2 +- .../core/Mage/DesignEditor/etc/adminhtml.xml | 15 - .../Mage/DesignEditor/etc/adminhtml/menu.xml | 32 + .../DesignEditor/view/frontend/js/base.js | 302 ++++---- .../view/frontend/js/design_editor.js | 367 +++++----- .../view/frontend/js/settimeout_override.js | 77 ++ .../DesignEditor/view/frontend/layout.xml | 1 + .../DesignEditor/view/frontend/toolbar.phtml | 48 +- .../core/Mage/Downloadable/etc/adminhtml.xml | 14 - .../Mage/Downloadable/etc/adminhtml/menu.xml | 32 + .../Downloadable/view/frontend/layout.xml | 10 + .../Googleshopping/ItemsController.php | 2 +- .../Googleshopping/TypesController.php | 2 +- .../Mage/GoogleShopping/etc/adminhtml.xml | 20 - .../GoogleShopping/etc/adminhtml/menu.xml | 34 + .../Block/Adminhtml/Export/Edit/Form.php | 2 +- .../Block/Adminhtml/Import/Before.php | 49 ++ .../Block/Adminhtml/Import/Edit/Form.php | 53 +- .../core/Mage/ImportExport/Helper/Data.php | 30 + .../Export/Entity/V2/Eav/Customer/Address.php | 35 +- .../core/Mage/ImportExport/Model/Import.php | 139 +++- .../Model/Import/Entity/Abstract.php | 42 +- .../Model/Import/Entity/V2/Abstract.php | 661 ++++++++++++++++++ .../Model/Import/Entity/V2/Eav/Abstract.php | 195 ++++++ .../Model/Import/Entity/V2/Eav/Customer.php | 362 ++++++++++ .../Entity/V2/Eav/Customer/Abstract.php | 158 +++++ .../Import/Entity/V2/Eav/Customer/Address.php | 504 +++++++++++++ .../Model/Resource/Import/Data.php | 48 +- .../Source/{Export => }/Format/Version.php | 19 +- .../Model/Source/Import/Behavior.php | 4 + .../Model/Source/Import/Customer/Entity.php | 47 ++ .../Model/Source/Import/Entity.php | 11 +- .../Adminhtml/ExportController.php | 2 +- .../Adminhtml/ImportController.php | 19 +- .../core/Mage/ImportExport/etc/adminhtml.xml | 20 - .../Mage/ImportExport/etc/adminhtml/menu.xml | 33 + .../core/Mage/ImportExport/etc/config.xml | 12 +- .../upgrade-1.6.0.2-1.6.0.3.php | 37 + .../view/adminhtml/export/form/before.phtml | 6 +- .../view/adminhtml/import/form/after.phtml | 11 +- .../view/adminhtml/import/form/before.phtml | 130 +++- .../ImportExport/view/adminhtml/layout.xml | 2 +- .../Adminhtml/ProcessController.php | 2 +- app/code/core/Mage/Index/etc/adminhtml.xml | 11 - .../core/Mage/Index/etc/adminhtml/menu.xml | 32 + .../Mage/Install/Model/Installer/Console.php | 16 +- .../Install/Model/Installer/Db/Abstract.php | 8 + .../Install/Model/Installer/Db/Mysql4.php | 18 + .../core/Mage/Newsletter/etc/adminhtml.xml | 24 - .../Mage/Newsletter/etc/adminhtml/menu.xml | 36 + .../Adminhtml/Oauth/Admin/TokenController.php | 14 +- .../Oauth/AuthorizedTokensController.php | 2 +- .../Adminhtml/Oauth/ConsumerController.php | 17 +- app/code/core/Mage/Oauth/etc/adminhtml.xml | 25 - .../core/Mage/Oauth/etc/adminhtml/menu.xml | 34 + .../Adminhtml/Paypal/ReportsController.php | 2 +- app/code/core/Mage/Paypal/etc/adminhtml.xml | 15 - .../core/Mage/Paypal/etc/adminhtml/menu.xml | 32 + .../frontend/checkout/onepage/login.phtml | 2 +- app/code/core/Mage/Poll/etc/adminhtml.xml | 11 - .../core/Mage/Poll/etc/adminhtml/menu.xml | 32 + .../Resource/Product/Ordered/Collection.php | 80 --- .../Resource/Product/Viewed/Collection.php | 124 ---- app/code/core/Mage/Reports/etc/adminhtml.xml | 106 --- .../core/Mage/Reports/etc/adminhtml/menu.xml | 53 ++ app/code/core/Mage/Review/etc/adminhtml.xml | 47 -- .../core/Mage/Review/etc/adminhtml/menu.xml | 39 ++ app/code/core/Mage/Sales/etc/adminhtml.xml | 53 -- .../core/Mage/Sales/etc/adminhtml/menu.xml | 40 ++ .../core/Mage/SalesRule/etc/adminhtml.xml | 11 - .../Mage/SalesRule/etc/adminhtml/menu.xml | 32 + app/code/core/Mage/Sitemap/etc/adminhtml.xml | 11 - .../core/Mage/Sitemap/etc/adminhtml/menu.xml | 32 + app/code/core/Mage/Tag/etc/adminhtml.xml | 46 -- app/code/core/Mage/Tag/etc/adminhtml/menu.xml | 38 + app/code/core/Mage/Tax/etc/adminhtml.xml | 32 - app/code/core/Mage/Tax/etc/adminhtml/menu.xml | 37 + .../Adminhtml/User/RoleController.php | 2 +- .../controllers/Adminhtml/UserController.php | 2 +- app/code/core/Mage/User/etc/adminhtml.xml | 21 - .../core/Mage/User/etc/adminhtml/menu.xml | 34 + .../Adminhtml/Widget/InstanceController.php | 2 +- app/code/core/Mage/Widget/etc/adminhtml.xml | 11 - .../core/Mage/Widget/etc/adminhtml/menu.xml | 32 + .../Adminhtml/MobileController.php | 20 +- .../core/Mage/XmlConnect/etc/adminhtml.xml | 28 - .../Mage/XmlConnect/etc/adminhtml/menu.xml | 36 + .../checkout/onepage/login.phtml | 2 +- app/etc/modules/Mage_Captcha.xml | 1 + .../framework/Magento/Test/Bootstrap.php | 6 + .../Test/TestCase/ControllerAbstract.php | 6 + dev/tests/integration/framework/bootstrap.php | 2 +- dev/tests/integration/phpunit.xml.dist | 1 + .../Customer/Edit/Tab/View/AccordionTest.php | 5 + .../Adminhtml/Block/Dashboard/GraphTest.php | 5 + .../Mage/Adminhtml/Block/Page/HeaderTest.php | 5 + .../Report/Sales/Bestsellers/GridTest.php | 5 + .../Mage/Adminhtml/Controller/ActionTest.php | 5 + .../Model/Sales/Order/CreateTest.php | 5 + .../System/Config/Source/Admin/PageTest.php | 50 ++ .../Mage/Adminhtml/Utility/Controller.php | 3 + .../Mage/Backend/Block/TemplateTest.php | 5 + .../Backend/Controller/Router/DefaultTest.php | 10 +- .../Mage/Backend/Helper/DataTest.php | 16 +- .../Mage/Backend/Model/Auth/SessionTest.php | 7 +- .../testsuite/Mage/Backend/Model/AuthTest.php | 5 + .../testsuite/Mage/Backend/Model/MenuTest.php | 85 +++ .../Mage/Backend/Model/ObserverTest.php | 5 + .../testsuite/Mage/Backend/Model/UrlTest.php | 5 + .../Adminhtml/AuthControllerTest.php | 28 +- .../Adminhtml/IndexControllerTest.php | 6 + .../Mage/Bundle/Model/ProductTest.php | 5 + .../Catalog/Block/Product/AbstractTest.php | 6 + .../Mage/Catalog/Block/Product/ListTest.php | 5 + .../Mage/Catalog/Block/Product/NewTest.php | 5 + .../Mage/Catalog/Block/Product/ViewTest.php | 6 + .../Mage/Catalog/Helper/Category/FlatTest.php | 5 + .../Mage/Catalog/Helper/CategoryTest.php | 5 + .../Mage/Catalog/Helper/DataTest.php | 5 + .../Mage/Catalog/Helper/ImageTest.php | 5 + .../testsuite/Mage/Catalog/Helper/MapTest.php | 5 + .../Mage/Catalog/Helper/OutputTest.php | 5 + .../Catalog/Helper/Product/CompareTest.php | 5 + .../Mage/Catalog/Helper/Product/FlatTest.php | 5 + .../Mage/Catalog/Helper/Product/UrlTest.php | 5 + .../Mage/Catalog/Helper/Product/ViewTest.php | 2 + .../Mage/Catalog/Helper/ProductTest.php | 5 + .../Mage/Catalog/Model/AbstractTest.php | 5 + .../Catalog/Model/Category/Api/V2Test.php | 5 + .../Mage/Catalog/Model/Category/ApiTest.php | 5 + .../Model/Category/Attribute/ApiTest.php | 5 + .../Model/Category/CategoryImageTest.php | 5 + .../Mage/Catalog/Model/CategoryTest.php | 5 + .../Mage/Catalog/Model/CategoryTreeTest.php | 5 + .../Mage/Catalog/Model/DesignTest.php | 5 + .../Model/Layer/Filter/AttributeTest.php | 5 + .../Model/Layer/Filter/CategoryTest.php | 6 + .../Model/Layer/Filter/DecimalTest.php | 5 + .../Catalog/Model/Layer/Filter/ItemTest.php | 5 + .../Filter/Price/AlgorithmAdvancedTest.php | 5 + .../Layer/Filter/Price/AlgorithmBaseTest.php | 7 + .../Catalog/Model/Layer/Filter/PriceTest.php | 5 + .../Mage/Catalog/Model/LayerTest.php | 5 + .../Model/Product/Attribute/ApiTest.php | 5 + .../Product/Attribute/Backend/MediaTest.php | 5 + .../Product/Attribute/Backend/PriceTest.php | 5 + .../Attribute/Backend/TierpriceTest.php | 4 + .../Model/Product/Attribute/Media/ApiTest.php | 5 + .../Attribute/Tierprice/Api/V2Test.php | 5 + .../Product/Attribute/Tierprice/ApiTest.php | 5 + .../Model/Product/Type/AbstractTest.php | 5 + .../Type/Configurable/AttributeTest.php | 4 + .../Model/Product/Type/ConfigurableTest.php | 5 + .../Catalog/Model/Product/Type/PriceTest.php | 5 + .../Mage/Catalog/Model/Product/UrlTest.php | 5 + .../Catalog/Model/ProductExternalTest.php | 5 + .../Mage/Catalog/Model/ProductGettersTest.php | 5 + .../Mage/Catalog/Model/ProductPriceTest.php | 5 + .../Mage/Catalog/Model/ProductTest.php | 5 + .../Model/Resource/Eav/AttributeTest.php | 5 + .../Model/Resource/Product/CollectionTest.php | 5 + .../Mage/Catalog/Model/Resource/UrlTest.php | 5 + .../testsuite/Mage/Catalog/Model/UrlTest.php | 5 + .../CatalogInventory/Model/Stock/ItemTest.php | 5 + .../Mage/CatalogRule/Model/RuleTest.php | 5 +- .../Block/Advanced/ResultTest.php | 6 + .../Mage/CatalogSearch/Block/TermTest.php | 5 + .../Mage/CatalogSearch/Helper/DataTest.php | 5 + .../Checkout/Block/Cart/Item/RendererTest.php | 5 + .../Block/Onepage/Payment/MethodsTest.php | 5 + .../Mage/Cms/Model/Wysiwyg/ConfigTest.php | 5 + .../Mage/Core/Block/AbstractTest.php | 6 + .../testsuite/Mage/Core/Block/FlushTest.php | 6 + .../Mage/Core/Block/TemplateTest.php | 5 + .../Mage/Core/Block/Text/ListTest.php | 6 + .../testsuite/Mage/Core/Block/TextTest.php | 1 - .../Mage/Core/Controller/RequestHttpTest.php | 5 + .../Core/Controller/Varien/ActionTest.php | 5 + .../Mage/Core/Controller/Varien/FrontTest.php | 9 +- .../Controller/Varien/Router/AbstractTest.php | 52 ++ .../Controller/Varien/Router/BaseTest.php | 10 +- .../Mage/Core/Helper/AbstractTest.php | 5 + .../testsuite/Mage/Core/Helper/DataTest.php | 5 + .../testsuite/Mage/Core/Helper/HttpTest.php | 5 + .../testsuite/Mage/Core/Helper/JsTest.php | 5 + .../testsuite/Mage/Core/Helper/StringTest.php | 5 + .../Mage/Core/Helper/Url/RewriteTest.php | 5 + .../testsuite/Mage/Core/Helper/UrlTest.php | 5 + .../Mage/Core/Model/App/AreaTest.php | 11 +- .../testsuite/Mage/Core/Model/AppTest.php | 20 +- .../testsuite/Mage/Core/Model/CacheTest.php | 1 + .../Mage/Core/Model/Config/DataTest.php | 5 + .../Mage/Core/Model/Config/ElementTest.php | 5 + .../Mage/Core/Model/Config/OptionsTest.php | 5 + .../Mage/Core/Model/ConfigFactoryTest.php | 5 + .../testsuite/Mage/Core/Model/ConfigTest.php | 1 - .../Model/Design/Backend/ExceptionsTest.php | 5 + .../Core/Model/Design/PackageFallbackTest.php | 5 + .../Core/Model/Design/PackageMergingTest.php | 1 + .../Model/Design/PackagePublicationTest.php | 1 + .../Mage/Core/Model/Design/PackageTest.php | 5 + .../Core/Model/Design/Source/DesignTest.php | 5 + .../testsuite/Mage/Core/Model/DesignTest.php | 5 + .../Core/Model/Email/Template/FilterTest.php | 5 + .../Mage/Core/Model/Email/TemplateTest.php | 6 + .../Mage/Core/Model/EncryptionTest.php | 5 + .../Mage/Core/Model/Layout/DataTest.php | 5 + .../Mage/Core/Model/Layout/ElementTest.php | 5 + .../Mage/Core/Model/Layout/UpdateTest.php | 5 + .../testsuite/Mage/Core/Model/LayoutTest.php | 13 + .../Mage/Core/Model/Resource/CacheTest.php | 5 + .../Mage/Core/Model/Resource/ConfigTest.php | 5 + .../Core/Model/Resource/Db/AbstractTest.php | 6 + .../Core/Model/Resource/Entity/TableTest.php | 5 + .../Core/Model/Resource/Helper/Mysql4Test.php | 6 + .../Mage/Core/Model/Resource/IteratorTest.php | 5 + .../Mage/Core/Model/Resource/LayoutTest.php | 5 + .../Mage/Core/Model/Resource/SessionTest.php | 5 + .../Mage/Core/Model/Resource/SetupTest.php | 5 + .../Model/Resource/Store/CollectionTest.php | 5 + .../Core/Model/Resource/TransactionTest.php | 5 + .../Mage/Core/Model/ResourceMysqlTest.php | 5 + .../Mage/Core/Model/ResourceTest.php | 5 + .../Mage/Core/Model/Session/AbstractTest.php | 5 + .../testsuite/Mage/Core/Model/StoreTest.php | 5 + .../Mage/Core/Model/Translate/ExprTest.php | 5 + .../Mage/Core/Model/Translate/InlineTest.php | 4 + .../Mage/Core/Model/Translate/StringTest.php | 5 + .../Mage/Core/Model/TranslateTest.php | 5 + .../Mage/Core/Model/Url/RewriteTest.php | 5 + .../testsuite/Mage/Core/Model/UrlTest.php | 5 + .../Mage/Core/Model/Variable/ConfigTest.php | 5 + .../testsuite/Mage/Core/Model/WebsiteTest.php | 5 + .../Mage/Core/Model/_files/_layout_update.xml | 2 +- .../test/default/Mage_Core/layout.xml | 2 +- .../Mage/Core/Utility/LayoutTest.php | 5 + .../Mage/Cron/Model/ObserverTest.php | 5 + .../Mage/Customer/Block/Account/LinkTest.php | 6 + .../Customer/Block/Account/NavigationTest.php | 47 ++ .../Customer/Model/Address/ConfigTest.php | 5 + .../Mage/Customer/Model/FormTest.php | 5 + .../Mage/Customer/Model/GroupTest.php | 5 + .../Block/Toolbar/BreadcrumbsTest.php | 5 + .../DesignEditor/Block/Toolbar/ExitTest.php | 5 + .../Block/Toolbar/HandlesHierarchyTest.php | 5 + .../DesignEditor/Block/Toolbar/SkinTest.php | 5 + .../Mage/DesignEditor/Block/ToolbarTest.php | 5 + .../Mage/DesignEditor/Model/ObserverTest.php | 5 + .../Mage/DesignEditor/Model/SessionTest.php | 5 + .../Entity/Attribute/CollectionTest.php | 5 + .../GiftMessage/Block/Message/InlineTest.php | 5 + .../Block/Adminhtml/Import/Edit/FormTest.php | 71 ++ .../Model/Export/Entity/ProductTest.php | 1 + .../Export/Entity/V2/Eav/AbstractTest.php | 4 +- .../Entity/V2/Eav/Customer/AddressTest.php | 20 +- .../Export/Entity/V2/Eav/CustomerTest.php | 4 +- .../Model/Import/Entity/CustomerTest.php | 30 +- .../Model/Import/Entity/V2/AbstractTest.php | 64 ++ .../Import/Entity/V2/CustomerImportTest.php | 120 ++++ .../Import/Entity/V2/CustomerValidateTest.php | 199 ++++++ .../Import/Entity/V2/Eav/AbstractTest.php | 162 +++++ .../Entity/V2/Eav/Customer/AddressTest.php | 440 ++++++++++++ .../Entity/V2/_files/address_import.csv | 5 + .../_files/customers_for_validation_test.csv | 3 + .../Entity/V2/_files/customers_to_import.csv | 4 + .../Mage/ImportExport/Model/ImportTest.php | 147 ++++ .../Model/Resource/Import/DataTest.php | 93 +++ .../Mage/ImportExport/_files/customer.php | 71 ++ .../_files/customer_with_addresses.php | 3 +- .../Mage/ImportExport/_files/customers.php | 3 +- .../_files/customers_for_address_import.php | 111 +++ .../Mage/ImportExport/_files/import_data.php | 141 ++++ .../Mage/Log/Model/Resource/ShellTest.php | 5 + .../Mage/Newsletter/Model/TemplateTest.php | 5 + .../Mage/Page/Block/Html/BreadcrumbsTest.php | 5 + .../Mage/Page/Block/Html/HeadTest.php | 5 + .../Mage/PageCache/Helper/DataTest.php | 5 + .../Mage/PageCache/Model/ObserverTest.php | 5 + .../testsuite/Mage/Paypal/Model/IpnTest.php | 5 + .../ProductAlert/Block/Email/StockTest.php | 5 + .../Mage/Sales/Block/Order/CommentsTest.php | 5 + .../Block/Order/Creditmemo/ItemsTest.php | 8 + .../Sales/Block/Order/Invoice/ItemsTest.php | 7 + .../Block/Recurring/Profile/ViewTest.php | 3 + .../Sales/Model/Order/Shipment/TrackTest.php | 5 + .../Mage/Shipping/Helper/DataTest.php | 5 + .../Mage/Tag/Block/Customer/ViewTest.php | 5 + .../Mage/Tag/Block/Product/ResultTest.php | 7 + .../testsuite/Mage/Tag/Model/TagTest.php | 5 + .../Mage/User/Block/Role/Grid/UserTest.php | 5 + .../Mage/User/Block/Role/GridTest.php | 5 + .../Mage/User/Block/Role/Tab/EditTest.php | 5 + .../testsuite/Mage/User/Helper/DataTest.php | 5 + .../Model/Resource/Role/CollectionTest.php | 5 + .../Resource/Role/User/CollectionTest.php | 5 + .../Model/Resource/Rules/CollectionTest.php | 5 + .../testsuite/Mage/User/Model/RoleTest.php | 5 + .../testsuite/Mage/User/Model/RulesTest.php | 5 + .../testsuite/Mage/User/Model/UserTest.php | 5 + .../Adminhtml/AuthControllerTest.php | 7 + .../Mage/Weee/Model/ObserverTest.php | 5 + .../Instance/Edit/Chooser/ContainerTest.php | 5 + .../Instance/Edit/Chooser/LayoutTest.php | 5 + .../Instance/Edit/Tab/Main/LayoutTest.php | 5 + .../Mage/Widget/Model/Widget/ConfigTest.php | 5 + .../Mage/Widget/Model/Widget/InstanceTest.php | 5 + .../Mage/Widget/Model/WidgetTest.php | 5 + .../Mage/Wishlist/Block/AbstractTest.php | 5 + .../Customer/Wishlist/Item/ColumnTest.php | 6 + .../Mage/XmlConnect/Helper/DataTest.php | 5 + .../Phoenix/Moneybookers/Block/FormTest.php | 5 + .../Varien/Db/Adapter/InterfaceTest.php | 1 + .../Varien/Db/Adapter/Pdo/MysqlTest.php | 6 + .../Varien/Image/Adapter/InterfaceTest.php | 8 +- .../integrity/modular/MenuConfigFilesTest.php | 128 ++++ .../testsuite/Legacy/ObsoleteCodeTest.php | 5 + .../testsuite/Legacy/ObsoleteMenuTest.php | 54 ++ .../Legacy/_files/obsolete_classes.php | 5 + .../Legacy/_files/obsolete_methods.php | 1 + .../testsuite/Php/Exemplar/CodeStyleTest.php | 19 +- .../System/Config/Source/Admin/PageTest.php | 125 ++++ .../Model/Menu/Builder/Command/AddTest.php | 64 ++ .../Model/Menu/Builder/Command/RemoveTest.php | 50 ++ .../Model/Menu/Builder/Command/UpdateTest.php | 55 ++ .../Menu/Builder/CommandAbstractTest.php | 78 +++ .../Mage/Backend/Model/Menu/BuilderTest.php | 157 +++++ .../Backend/Model/Menu/Config/MenuTest.php | 123 ++++ .../Mage/Backend/Model/Menu/ConfigTest.php | 283 ++++++++ .../Backend/Model/Menu/Director/DomTest.php | 180 +++++ .../Model/Menu/Filter/IteratorTest.php | 154 ++++ .../Backend/Model/Menu/Item/FactoryTest.php | 175 +++++ .../Backend/Model/Menu/Item/ValidatorTest.php | 289 ++++++++ .../Mage/Backend/Model/Menu/ItemTest.php | 309 ++++++++ .../testsuite/Mage/Backend/Model/MenuTest.php | 363 ++++++++++ .../testsuite/Mage/Backend/Model/UrlTest.php | 50 +- .../_files/{adminhtml.xml => menu_1.xml} | 24 +- .../Mage/Backend/Model/_files/menu_2.xml | 36 + .../Mage/Backend/Model/_files/menu_merged.php | 98 +++ .../Mage/Backend/Model/_files/menu_merged.xml | 40 ++ .../Mage/Captcha/Helper/DataTest.php | 211 ++++++ .../testsuite/Mage/Captcha/Model/ZendTest.php | 301 ++++++++ .../Model/Resource/Category/FlatTest.php | 115 +++ .../Mage/Core/Block/AbstractTest.php | 69 ++ .../Block/Adminhtml/Import/BeforeTest.php | 95 +++ .../Mage/ImportExport/Helper/DataTest.php | 49 ++ .../Model/Import/Entity/AbstractTest.php | 138 ++++ .../Model/Import/Entity/V2/AbstractTest.php | 453 ++++++++++++ .../Import/Entity/V2/Eav/AbstractTest.php | 144 ++++ .../Entity/V2/Eav/Customer/AbstractTest.php | 166 +++++ .../Entity/V2/Eav/Customer/AddressTest.php | 381 ++++++++++ .../row_data_absent_required_attribute.php | 52 ++ .../_files/row_data_empty_address_id.php | 53 ++ .../Customer/_files/row_data_empty_email.php | 53 ++ .../_files/row_data_empty_website.php | 53 ++ .../_files/row_data_invalid_email.php | 53 ++ .../_files/row_data_invalid_region.php | 53 ++ .../_files/row_data_invalid_website.php | 53 ++ .../Customer/_files/row_data_no_customer.php | 53 ++ .../Eav/Customer/_files/row_data_no_email.php | 52 ++ .../Customer/_files/row_data_no_website.php | 52 ++ .../V2/Eav/Customer/_files/row_data_valid.php | 53 ++ .../Model/Source/Format/VersionTest.php | 130 ++++ .../Model/Source/Import/BehaviorTest.php | 115 +++ .../Model/Source/Import/EntityTest.php | 160 +++++ .../Varien/Data/Collection/DbTest.php | 53 +- .../unit/testsuite/Varien/Db/SelectTest.php | 69 ++ dev/tools/batch_tests/batch.php | 18 +- lib/Magento/Config/XmlAbstract.php | 60 +- lib/Varien/Data/Collection/Db.php | 25 +- lib/Varien/Db/Select.php | 12 +- pub/js/mage/adminhtml/grid.js | 13 +- pub/js/mage/adminhtml/tools.js | 5 + pub/js/mage/captcha.js | 35 - 532 files changed, 16594 insertions(+), 2446 deletions(-) create mode 100644 app/code/core/Mage/AdminNotification/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Adminhtml/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Api/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Api2/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Backend/Block/Menu/Container.php create mode 100644 app/code/core/Mage/Backend/Block/Menu/Item.php create mode 100644 app/code/core/Mage/Backend/Model/Menu.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Builder.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Builder/Command/Remove.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Builder/Command/Update.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Builder/CommandAbstract.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Config.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Config/Menu.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Config/Menu/Dom.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Config/menu.xsd create mode 100644 app/code/core/Mage/Backend/Model/Menu/Director/Dom.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/DirectorAbstract.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Factory.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Filter/Iterator.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Item.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Item/Factory.php create mode 100644 app/code/core/Mage/Backend/Model/Menu/Item/Validator.php rename app/code/core/Mage/{Adminhtml/Block/Page/Menu.php => Backend/Model/Menu/Iterator.php} (77%) create mode 100644 app/code/core/Mage/Backend/Model/Menu/Logger.php create mode 100644 app/code/core/Mage/Backend/view/adminhtml/menu/container.phtml create mode 100644 app/code/core/Mage/Backend/view/adminhtml/menu/item.phtml create mode 100644 app/code/core/Mage/Backup/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Captcha/view/frontend/onepage.js create mode 100644 app/code/core/Mage/Catalog/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Checkout/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Cms/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Connect/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Core/Model/Event/Manager.php create mode 100644 app/code/core/Mage/Core/Model/Logger.php create mode 100644 app/code/core/Mage/Core/Model/Store/Config.php create mode 100644 app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Customer/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/DesignEditor/view/frontend/js/settimeout_override.js create mode 100644 app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Before.php create mode 100644 app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Abstract.php create mode 100644 app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Abstract.php create mode 100644 app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer.php create mode 100644 app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/Abstract.php create mode 100644 app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/Address.php rename app/code/core/Mage/ImportExport/Model/Source/{Export => }/Format/Version.php (81%) create mode 100644 app/code/core/Mage/ImportExport/Model/Source/Import/Customer/Entity.php create mode 100644 app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.2-1.6.0.3.php create mode 100644 app/code/core/Mage/Index/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Newsletter/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Oauth/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Paypal/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Poll/etc/adminhtml/menu.xml delete mode 100755 app/code/core/Mage/Reports/Model/Resource/Product/Ordered/Collection.php delete mode 100755 app/code/core/Mage/Reports/Model/Resource/Product/Viewed/Collection.php create mode 100644 app/code/core/Mage/Reports/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Review/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Sales/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/SalesRule/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Sitemap/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Tag/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Tax/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/User/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/Widget/etc/adminhtml/menu.xml create mode 100644 app/code/core/Mage/XmlConnect/etc/adminhtml/menu.xml create mode 100644 dev/tests/integration/testsuite/Mage/Adminhtml/Model/System/Config/Source/Admin/PageTest.php create mode 100644 dev/tests/integration/testsuite/Mage/Backend/Model/MenuTest.php create mode 100644 dev/tests/integration/testsuite/Mage/Core/Controller/Varien/Router/AbstractTest.php create mode 100644 dev/tests/integration/testsuite/Mage/Customer/Block/Account/NavigationTest.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Block/Adminhtml/Import/Edit/FormTest.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/V2/AbstractTest.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/V2/CustomerImportTest.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/V2/CustomerValidateTest.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/AbstractTest.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/AddressTest.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/V2/_files/address_import.csv create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/V2/_files/customers_for_validation_test.csv create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/Import/Entity/V2/_files/customers_to_import.csv create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/ImportTest.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/Model/Resource/Import/DataTest.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/_files/customer.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/_files/customers_for_address_import.php create mode 100644 dev/tests/integration/testsuite/Mage/ImportExport/_files/import_data.php create mode 100644 dev/tests/integration/testsuite/integrity/modular/MenuConfigFilesTest.php create mode 100644 dev/tests/static/testsuite/Legacy/ObsoleteMenuTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Adminhtml/Model/System/Config/Source/Admin/PageTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Builder/Command/AddTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Builder/Command/RemoveTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Builder/Command/UpdateTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Builder/CommandAbstractTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/BuilderTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Config/MenuTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ConfigTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Director/DomTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Filter/IteratorTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/FactoryTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/ValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ItemTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/MenuTest.php rename dev/tests/unit/testsuite/Mage/Backend/Model/_files/{adminhtml.xml => menu_1.xml} (58%) create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_2.xml create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.xml create mode 100644 dev/tests/unit/testsuite/Mage/Captcha/Helper/DataTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Captcha/Model/ZendTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Catalog/Model/Resource/Category/FlatTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Core/Block/AbstractTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Block/Adminhtml/Import/BeforeTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Helper/DataTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/AbstractTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/AbstractTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/AbstractTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/AbstractTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/AddressTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_absent_required_attribute.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_empty_address_id.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_empty_email.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_empty_website.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_invalid_email.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_invalid_region.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_invalid_website.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_no_customer.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_no_email.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_no_website.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/_files/row_data_valid.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Source/Format/VersionTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Source/Import/BehaviorTest.php create mode 100644 dev/tests/unit/testsuite/Mage/ImportExport/Model/Source/Import/EntityTest.php create mode 100644 dev/tests/unit/testsuite/Varien/Db/SelectTest.php diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index e56e622bf96d5..f7190d6f899f6 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,3 +1,22 @@ +Update as of 7/3/2012 +===================== +* Refactored backend (admin) menu generation: + * Menu is separated from `adminhtml.xml` files into `menu.xml` files + * Rendering menu became responsibility of `Mage_Backend` instead of `Mage_Adminhtml` module + * Implemented XML-Schema for `menu.xml` + * Actions with menu items defined in schema: add, remove, move, update, change parent and position +* Refactored customers import feature. New ability to provide import data in 3 files: master file (key customer information) + address file (customer id + address info) + financial file (customer id + reward points & store credit) +* Optimized memory consumption in integration tests: + * Found and eliminated memory leaks in `Mage_Core_Model_App_Area`, `Mage_Core_Model_Layout` + * Manually unset objects from PHPUnit test case object in `tearDown()` in integration tests. Garbage collector didn't purge them because of these references + * Disabled running `integrity` test suite by default in integration tests +* Improvements in visual design editor JavaScript: + * eliminated dependency of code on HTML-literals, reduced code coupling between templates and JavaScript files + * implemented blocking unwanted JavaScript activity in visual design editor mode +* Various fixes in UX, code stability, modularity +* GitHub requests: + * [#23](https://github.com/magento/magento2/pull/23) -- added `Mage_Customer_Block_Account_Navigation::removeLink()` + Update as of 6/20/2012 ===================== * Implemented locale translation inheritance @@ -8,7 +27,7 @@ Update as of 6/20/2012 * Implemented optional tracking of changes in view files fallback - cached by default, tracked in developer mode * Introduced `@magentoDbIsolation` annotation in integration tests - isolates DB modifications made by tests * Started refactoring of Visual Design Editor Javascript architecture -* Github requests: +* GitHub requests: * [#25](https://github.com/magento/magento2/issues/25) Removed unused `Mage_Core_Block_Abstract::getHelper()` method * Fixed: * "$_FILES array is empty" messages in exception log upon installation @@ -26,8 +45,8 @@ Update as of 6/7/2012 * Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework * Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests * Removed HTML-report feature of copy-paste detector which never worked anyway (`dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt` and all related code) -* Github requests: -** [#19](https://github.com/magento/magento2/pull/19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests +* GitHub requests: + * [#19](https://github.com/magento/magento2/pull/19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests Update as of 5/31/2012 ====================== diff --git a/app/code/core/Mage/Admin/Model/Config.php b/app/code/core/Mage/Admin/Model/Config.php index 4e064fdc7e28f..941e6a73f89d1 100644 --- a/app/code/core/Mage/Admin/Model/Config.php +++ b/app/code/core/Mage/Admin/Model/Config.php @@ -333,20 +333,4 @@ public function getAdminhtmlConfig() { return $this->_adminhtmlConfig; } - - /** - * Get menu item label by item path - * - * @param string $path - * @return string - */ - public function getMenuItemLabel($path) - { - $moduleName = 'Mage_Adminhtml_Helper_Data'; - $menuNode = $this->getAdminhtmlConfig()->getNode('menu/' . str_replace('/', '/children/', trim($path, '/'))); - if ($menuNode->getAttribute('module')) { - $moduleName = (string)$menuNode->getAttribute('module'); - } - return $this->_getHelper($moduleName)->__((string)$menuNode->title); - } } diff --git a/app/code/core/Mage/AdminNotification/etc/adminhtml.xml b/app/code/core/Mage/AdminNotification/etc/adminhtml.xml index 5b832ebd0e77f..053695bdc3975 100644 --- a/app/code/core/Mage/AdminNotification/etc/adminhtml.xml +++ b/app/code/core/Mage/AdminNotification/etc/adminhtml.xml @@ -60,15 +60,4 @@ - - - - - Notifications - adminhtml/notification - 15 - - - - diff --git a/app/code/core/Mage/AdminNotification/etc/adminhtml/menu.xml b/app/code/core/Mage/AdminNotification/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..a2d90079d57db --- /dev/null +++ b/app/code/core/Mage/AdminNotification/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php index 44f3d36e28296..73b80875ba618 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php @@ -45,7 +45,7 @@ class Mage_Adminhtml_Block_Report_Product_Viewed_Grid extends Mage_Adminhtml_Blo * * @var string */ - protected $_resourceCollectionName = 'Mage_Reports_Model_Resource_Product_Viewed_Collection'; + protected $_resourceCollectionName = 'Mage_Reports_Model_Resource_Report_Product_Viewed_Collection'; /** * Init grid parameters diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit.php index 44d3eab20dbfd..893d9d445d0ab 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit.php @@ -350,12 +350,16 @@ protected function _getSystemConfigPathsParts($paths) $result = $urlParams = $prefixParts = array(); $scopeLabel = Mage::helper('Mage_Adminhtml_Helper_Data')->__('GLOBAL'); if ($paths) { + /** @var $menu Mage_Backend_Model_Menu */ + $menu = Mage::getSingleton('Mage_Backend_Model_Menu_Config')->getMenu(); + $item = $menu->get('Mage_Adminhtml::system'); // create prefix path parts $prefixParts[] = array( - 'title' => Mage::getSingleton('Mage_Admin_Model_Config')->getMenuItemLabel('system'), + 'title' => $item->getModuleHelper()->__($item->getTitle()), ); + $item = $menu->get('Mage_Adminhtml::system_config'); $prefixParts[] = array( - 'title' => Mage::getSingleton('Mage_Admin_Model_Config')->getMenuItemLabel('system/config'), + 'title' => $item->getModuleHelper()->__($item->getTitle()), 'url' => $this->getUrl('adminhtml/system_config/'), ); diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php index d01031cae914b..c36b0384ae255 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php +++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php @@ -48,7 +48,7 @@ protected function _construct() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/order') + ->_setActiveMenu('Mage_Sales::sales_order') ->_addBreadcrumb($this->__('Sales'), $this->__('Sales')) ->_addBreadcrumb($this->__('Credit Memos'),$this->__('Credit Memos')); return $this; diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php index 4862a09e050f8..3199448d9c04a 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php +++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php @@ -48,7 +48,7 @@ protected function _construct() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/order') + ->_setActiveMenu('Mage_Sales::sales_order') ->_addBreadcrumb($this->__('Sales'), $this->__('Sales')) ->_addBreadcrumb($this->__('Invoices'),$this->__('Invoices')); return $this; diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php index 3ef138463c650..cc82fbf1a013c 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php +++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php @@ -48,7 +48,7 @@ protected function _construct() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/order') + ->_setActiveMenu('Mage_Sales::sales_order') ->_addBreadcrumb($this->__('Sales'), $this->__('Sales')) ->_addBreadcrumb($this->__('Shipments'),$this->__('Shipments')); return $this; diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php index 97818fd3ff5ae..39864b4de5327 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php @@ -34,136 +34,87 @@ */ class Mage_Adminhtml_Model_System_Config_Source_Admin_Page { - protected $_url; + /** + * Menu model + * + * @var Mage_Backend_Model_Menu + */ + protected $_menu; + + /** + * Object factory + * + * @var Mage_Core_Model_Config + */ + protected $_objectFactory; + + /** + * Default construct + */ + public function __construct(array $data = array()) + { + $this->_menu = isset($data['menu']) ? + $data['menu'] : + Mage::getSingleton('Mage_Backend_Model_Menu_Config')->getMenu(); + + $this->_objectFactory = isset($data['objectFactory']) ? $data['objectFactory'] : Mage::getConfig(); + } public function toOptionArray() { $options = array(); - $menu = $this->_buildMenuArray(); - - $this->_createOptions($options, $menu); - + $this->_createOptions($options, $this->_menu); return $options; } - protected function _createOptions(&$optionArray, $menuNode) + /** + * Get menu filter iterator + * + * @param Mage_Backend_Model_Menu $menu menu model + * @return Mage_Backend_Model_Menu_Filter_Iterator + */ + protected function _getMenuIterator(Mage_Backend_Model_Menu $menu) + { + return $this->_objectFactory->getModelInstance('Mage_Backend_Model_Menu_Filter_Iterator', $menu->getIterator()); + } + + /** + * Create options array + * + * @param array $optionArray + * @param Mage_Backend_Model_Menu $menu + * @param int $level + */ + protected function _createOptions(&$optionArray, Mage_Backend_Model_Menu $menu, $level = 0) { $nonEscapableNbspChar = html_entity_decode(' ', ENT_NOQUOTES, 'UTF-8'); + $paddingString = str_repeat($nonEscapableNbspChar, ($level * 4)); - foreach ($menuNode as $menu) { + foreach ($this->_getMenuIterator($menu) as $menuItem) { - if (!empty($menu['url'])) { + /**@var $menuItem Mage_Backend_Model_Menu_Item */ + if ($menuItem->getAction()) { $optionArray[] = array( - 'label' => str_repeat($nonEscapableNbspChar, ($menu['level'] * 4)) . $menu['label'], - 'value' => $menu['path'], + 'label' => $paddingString . $menuItem->getTitle(), + 'value' => $menuItem->getId(), ); - if (isset($menu['children'])) { - $this->_createOptions($optionArray, $menu['children']); + if ($menuItem->hasChildren()) { + $this->_createOptions($optionArray, $menuItem->getChildren(), $level + 1); } } else { $children = array(); - if(isset($menu['children'])) { - $this->_createOptions($children, $menu['children']); + if($menuItem->hasChildren()) { + $this->_createOptions($children, $menuItem->getChildren(), $level + 1); } $optionArray[] = array( - 'label' => str_repeat($nonEscapableNbspChar, ($menu['level'] * 4)) . $menu['label'], + 'label' => $paddingString . $menuItem->getTitle(), 'value' => $children, ); } } } - - protected function _getUrlModel() - { - if (is_null($this->_url)) { - $this->_url = Mage::getModel('Mage_Adminhtml_Model_Url'); - } - return $this->_url; - } - - protected function _buildMenuArray(Varien_Simplexml_Element $parent=null, $path='', $level=0) - { - if (is_null($parent)) { - $parent = Mage::getSingleton('Mage_Admin_Model_Config')->getAdminhtmlConfig()->getNode('menu'); - } - - $parentArr = array(); - $sortOrder = 0; - foreach ($parent->children() as $childName=>$child) { - if ((1 == $child->disabled) - || ($child->depends && !$this->_checkDepends($child->depends)) - ) { - continue; - } - - $menuArr = array(); - $menuArr['label'] = $this->_getHelperValue($child); - - $menuArr['sort_order'] = $child->sort_order ? (int)$child->sort_order : $sortOrder; - - if ($child->action) { - $menuArr['url'] = (string)$child->action; - } else { - $menuArr['url'] = ''; - } - - $menuArr['level'] = $level; - $menuArr['path'] = $path . $childName; - - if ($child->children) { - $menuArr['children'] = $this->_buildMenuArray($child->children, $path.$childName.'/', $level+1); - } - $parentArr[$childName] = $menuArr; - - $sortOrder++; - } - - uasort($parentArr, array($this, '_sortMenu')); - - while (list($key, $value) = each($parentArr)) { - $last = $key; - } - if (isset($last)) { - $parentArr[$last]['last'] = true; - } - - return $parentArr; - } - - protected function _sortMenu($a, $b) - { - return $a['sort_order']<$b['sort_order'] ? -1 : ($a['sort_order']>$b['sort_order'] ? 1 : 0); - } - - protected function _checkDepends(Varien_Simplexml_Element $depends) - { - if ($depends->module) { - $modulesConfig = Mage::getConfig()->getNode('modules'); - foreach ($depends->module as $module) { - if (!$modulesConfig->$module || !$modulesConfig->$module->is('active')) { - return false; - } - } - } - - return true; - } - - protected function _getHelperValue(Varien_Simplexml_Element $child) - { - $helperName = 'Mage_Adminhtml_Helper_Data'; - $titleNodeName = 'title'; - $childAttributes = $child->attributes(); - if (isset($childAttributes['module'])) { - $helperName = (string)$childAttributes['module']; - } - - $titleNodeName = 'title'; - - return Mage::helper($helperName)->__((string)$child->$titleNodeName); - } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php index 210c73f52ab07..de1076af2e027 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php @@ -37,7 +37,7 @@ class Mage_Adminhtml_Api_RoleController extends Mage_Adminhtml_Controller_Action protected function _initAction() { $this->loadLayout(); - $this->_setActiveMenu('system/services/roles'); + $this->_setActiveMenu('Mage_Api::system_api_roles'); $this->_addBreadcrumb($this->__('Web services'), $this->__('Web services')); $this->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions')); $this->_addBreadcrumb($this->__('Roles'), $this->__('Roles')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php index 057b53a0d075c..2c53eec41c26d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php @@ -29,7 +29,7 @@ class Mage_Adminhtml_Api_UserController extends Mage_Adminhtml_Controller_Action protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('system/services/users') + ->_setActiveMenu('Mage_Api::system_api_users') ->_addBreadcrumb($this->__('Web Services'), $this->__('Web Services')) ->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions')) ->_addBreadcrumb($this->__('Users'), $this->__('Users')) diff --git a/app/code/core/Mage/Adminhtml/controllers/CacheController.php b/app/code/core/Mage/Adminhtml/controllers/CacheController.php index ef5498b742441..e446ac275306c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/CacheController.php +++ b/app/code/core/Mage/Adminhtml/controllers/CacheController.php @@ -44,7 +44,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('Cache Management')); $this->loadLayout() - ->_setActiveMenu('system/cache') + ->_setActiveMenu('Mage_Adminhtml::system_cache') ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php index b2d1f7f359671..926beb68ae97f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php @@ -199,7 +199,7 @@ public function editAction() } $this->loadLayout(); - $this->_setActiveMenu('catalog/categories'); + $this->_setActiveMenu('Mage_Catalog::catalog_categories'); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true) ->setContainerCssClass('catalog-categories'); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php index abedfe7fcd09d..8c4ac365d727d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php @@ -53,7 +53,7 @@ protected function _initAction() $this->loadLayout('popup'); } else { $this->loadLayout() - ->_setActiveMenu('catalog/attributes') + ->_setActiveMenu('Mage_Catalog::catalog_attributes') ->_addBreadcrumb(Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog'), Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog')) ->_addBreadcrumb( Mage::helper('Mage_Catalog_Helper_Data')->__('Manage Product Attributes'), diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php index 399cc90c7ef9e..31ae0ca6ec47d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php @@ -54,7 +54,7 @@ public function indexAction() } $this->loadLayout(); - $this->_setActiveMenu('catalog/review'); + $this->_setActiveMenu('Mage_Review::catalog_reviews_ratings_reviews_all'); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Main')); @@ -75,7 +75,7 @@ public function pendingAction() } $this->loadLayout(); - $this->_setActiveMenu('catalog/review'); + $this->_setActiveMenu('Mage_Review::catalog_reviews_ratings_reviews_pending'); Mage::register('usePendingFilter', true); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Main')); @@ -92,7 +92,7 @@ public function editAction() $this->_title($this->__('Edit Review')); $this->loadLayout(); - $this->_setActiveMenu('catalog/review'); + $this->_setActiveMenu('Mage_Review::catalog_reviews_ratings_reviews_all'); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Review_Edit')); @@ -108,7 +108,7 @@ public function newAction() $this->_title($this->__('New Review')); $this->loadLayout(); - $this->_setActiveMenu('catalog/review'); + $this->_setActiveMenu('Mage_Review::catalog_reviews_ratings_reviews_all'); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php index 75e92f9a2f681..09f33632970e1 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php @@ -43,7 +43,7 @@ public function indexAction() $this->_setTypeId(); $this->loadLayout(); - $this->_setActiveMenu('catalog/sets'); + $this->_setActiveMenu('Mage_Catalog::catalog_attributes_sets'); $this->_addBreadcrumb(Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog'), Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog')); $this->_addBreadcrumb( @@ -80,7 +80,7 @@ public function editAction() Mage::register('current_attribute_set', $attributeSet); $this->loadLayout(); - $this->_setActiveMenu('catalog/sets'); + $this->_setActiveMenu('Mage_Catalog::catalog_attributes_sets'); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $this->_addBreadcrumb(Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog'), Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog')); @@ -189,7 +189,7 @@ public function addAction() $this->_setTypeId(); $this->loadLayout(); - $this->_setActiveMenu('catalog/sets'); + $this->_setActiveMenu('Mage_Catalog::catalog_attributes_sets'); $this->_addContent( $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Add') diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php index b5c98932e3a3a..363e7a44887c8 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php @@ -206,7 +206,7 @@ public function newAction() strtolower($this->getFullActionName()), 'adminhtml_catalog_product_'.$product->getTypeId() . $_additionalLayoutPart )); - $this->_setActiveMenu('catalog/products'); + $this->_setActiveMenu('Mage_Catalog::catalog_products'); } $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); @@ -250,7 +250,7 @@ public function editAction() 'adminhtml_catalog_product_'.$product->getTypeId() . $_additionalLayoutPart )); - $this->_setActiveMenu('catalog/products'); + $this->_setActiveMenu('Mage_Catalog::catalog_products'); if (!Mage::app()->isSingleStoreMode() && ($switchBlock = $this->getLayout()->getBlock('store_switcher'))) { $switchBlock->setDefaultStoreName($this->__('Default Values')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php index a1dea614b5edd..63de802a118dd 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php @@ -30,7 +30,7 @@ class Mage_Adminhtml_Catalog_SearchController extends Mage_Adminhtml_Controller_ protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('catalog/search') + ->_setActiveMenu('Mage_CatalogSearch::catalog_search') ->_addBreadcrumb(Mage::helper('Mage_Catalog_Helper_Data')->__('Search'), Mage::helper('Mage_Catalog_Helper_Data')->__('Search')) ; return $this; diff --git a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php index f42466fdf8060..4b1a34fdf7187 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php @@ -153,7 +153,7 @@ public function deleteAction() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/checkoutagreement') + ->_setActiveMenu('Mage_Checkout::sales_checkoutagreement') ->_addBreadcrumb(Mage::helper('Mage_Checkout_Helper_Data')->__('Sales'), Mage::helper('Mage_Checkout_Helper_Data')->__('Sales')) ->_addBreadcrumb(Mage::helper('Mage_Checkout_Helper_Data')->__('Checkout Conditions'), Mage::helper('Mage_Checkout_Helper_Data')->__('Checkout Terms and Conditions')) ; diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php index 6851e455f27c4..b499d7c940e2b 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php @@ -43,7 +43,7 @@ protected function _initAction() { // load layout, set active menu and breadcrumbs $this->loadLayout() - ->_setActiveMenu('cms/block') + ->_setActiveMenu('Mage_Cms::cms_block') ->_addBreadcrumb(Mage::helper('Mage_Cms_Helper_Data')->__('CMS'), Mage::helper('Mage_Cms_Helper_Data')->__('CMS')) ->_addBreadcrumb(Mage::helper('Mage_Cms_Helper_Data')->__('Static Blocks'), Mage::helper('Mage_Cms_Helper_Data')->__('Static Blocks')) ; diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php index 96afce8b73035..c54ae4f4ecc26 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php @@ -44,7 +44,7 @@ protected function _initAction() { // load layout, set active menu and breadcrumbs $this->loadLayout() - ->_setActiveMenu('cms/page') + ->_setActiveMenu('Mage_Cms::cms_page') ->_addBreadcrumb(Mage::helper('Mage_Cms_Helper_Data')->__('CMS'), Mage::helper('Mage_Cms_Helper_Data')->__('CMS')) ->_addBreadcrumb(Mage::helper('Mage_Cms_Helper_Data')->__('Manage Pages'), Mage::helper('Mage_Cms_Helper_Data')->__('Manage Pages')) ; diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php index d401df57f1b9b..60cb929a6450c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php @@ -52,7 +52,7 @@ public function indexAction() $this->_title($this->__('Customers'))->_title($this->__('Customer Groups')); $this->loadLayout(); - $this->_setActiveMenu('customer/group'); + $this->_setActiveMenu('Mage_Customer::customer_group'); $this->_addBreadcrumb(Mage::helper('Mage_Customer_Helper_Data')->__('Customers'), Mage::helper('Mage_Customer_Helper_Data')->__('Customers')); $this->_addBreadcrumb(Mage::helper('Mage_Customer_Helper_Data')->__('Customer Groups'), Mage::helper('Mage_Customer_Helper_Data')->__('Customer Groups')); $this->renderLayout(); @@ -65,7 +65,7 @@ public function newAction() { $this->_initGroup(); $this->loadLayout(); - $this->_setActiveMenu('customer/group'); + $this->_setActiveMenu('Mage_Customer::customer_group'); $this->_addBreadcrumb(Mage::helper('Mage_Customer_Helper_Data')->__('Customers'), Mage::helper('Mage_Customer_Helper_Data')->__('Customers')); $this->_addBreadcrumb(Mage::helper('Mage_Customer_Helper_Data')->__('Customer Groups'), Mage::helper('Mage_Customer_Helper_Data')->__('Customer Groups'), $this->getUrl('*/customer_group')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php index 18a3c4701571f..c31a80ebb29e0 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php @@ -37,7 +37,7 @@ public function indexAction() $this->loadLayout(); - $this->_setActiveMenu('customer/online'); + $this->_setActiveMenu('Mage_Customer::customer_online'); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Customer_Online', 'customers')); diff --git a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php index b2bdca970cdd5..15b3cfc448ab4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php @@ -65,7 +65,7 @@ public function indexAction() /** * Set active menu item */ - $this->_setActiveMenu('customer/manage'); + $this->_setActiveMenu('Mage_Customer::customer_manage'); /** * Append customers block to content @@ -146,7 +146,7 @@ public function editAction() /** * Set active menu item */ - $this->_setActiveMenu('customer/new'); + $this->_setActiveMenu('Mage_Customer::customer'); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php index 41cda09b36e00..b5da784d369b8 100644 --- a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php +++ b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php @@ -38,7 +38,7 @@ public function indexAction() $this->_title($this->__('Dashboard')); $this->loadLayout(); - $this->_setActiveMenu('dashboard'); + $this->_setActiveMenu('Mage_Adminhtml::dashboard'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Dashboard'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Dashboard')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php index 4af483ab86aa1..25fc01fb8e33f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php @@ -47,7 +47,7 @@ public function indexAction() ); $this->loadLayout(); - $this->_setActiveMenu('newsletter/problem'); + $this->_setActiveMenu('Mage_Newsletter::newsletter_problem'); $this->_addBreadcrumb(Mage::helper('Mage_Newsletter_Helper_Data')->__('Newsletter Problem Reports'), Mage::helper('Mage_Newsletter_Helper_Data')->__('Newsletter Problem Reports')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php index 07506ff12846c..904938164e874 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php @@ -47,7 +47,7 @@ public function indexAction() $this->loadLayout(); - $this->_setActiveMenu('newsletter/queue'); + $this->_setActiveMenu('Mage_Newsletter::newsletter_queue'); $this->_addContent( $this->getLayout()->createBlock('Mage_Adminhtml_Block_Newsletter_Queue', 'queue') @@ -203,7 +203,7 @@ public function editAction() $this->loadLayout(); - $this->_setActiveMenu('newsletter/queue'); + $this->_setActiveMenu('Mage_Newsletter::newsletter_queue'); $this->_addBreadcrumb( Mage::helper('Mage_Newsletter_Helper_Data')->__('Newsletter Queue'), diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php index 6db51db1cab71..90ba5a7a2ebd4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php @@ -45,7 +45,7 @@ public function indexAction() $this->loadLayout(); - $this->_setActiveMenu('newsletter/subscriber'); + $this->_setActiveMenu('Mage_Newsletter::newsletter_subscriber'); $this->_addBreadcrumb(Mage::helper('Mage_Newsletter_Helper_Data')->__('Newsletter'), Mage::helper('Mage_Newsletter_Helper_Data')->__('Newsletter')); $this->_addBreadcrumb(Mage::helper('Mage_Newsletter_Helper_Data')->__('Subscribers'), Mage::helper('Mage_Newsletter_Helper_Data')->__('Subscribers')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php index b2ecf192f0669..43467934ac29d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php @@ -66,7 +66,7 @@ public function indexAction () return; } $this->loadLayout(); - $this->_setActiveMenu('newsletter/template'); + $this->_setActiveMenu('Mage_Newsletter::newsletter_template'); $this->_addBreadcrumb(Mage::helper('Mage_Newsletter_Helper_Data')->__('Newsletter Templates'), Mage::helper('Mage_Newsletter_Helper_Data')->__('Newsletter Templates')); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Newsletter_Template', 'template')); $this->renderLayout(); @@ -109,7 +109,7 @@ public function editAction () Mage::register('_current_template', $model); $this->loadLayout(); - $this->_setActiveMenu('newsletter/template'); + $this->_setActiveMenu('Mage_Newsletter::newsletter_template'); if ($model->getId()) { $breadcrumbTitle = Mage::helper('Mage_Newsletter_Helper_Data')->__('Edit Template'); diff --git a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php index 5ffc283b20953..5b8f705ec1dd4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php +++ b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php @@ -39,7 +39,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('Notifications')); $this->loadLayout() - ->_setActiveMenu('system/notification') + ->_setActiveMenu('Mage_AdminNotification::system_adminnotification') ->_addBreadcrumb(Mage::helper('Mage_AdminNotification_Helper_Data')->__('Messages Inbox'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Messages Inbox')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Notification_Inbox')) ->renderLayout(); diff --git a/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php b/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php index 9ce9aa159683b..22e15c5e004af 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php @@ -38,7 +38,7 @@ public function editAction() { $this->loadLayout(); - $this->_setActiveMenu('cms/poll'); + $this->_setActiveMenu('Mage_Poll::cms_poll'); $this->_addBreadcrumb(Mage::helper('Mage_Poll_Helper_Data')->__('Poll Manager'), Mage::helper('Mage_Poll_Helper_Data')->__('Poll Manager'), $this->getUrl('*/*/')); $this->_addBreadcrumb(Mage::helper('Mage_Poll_Helper_Data')->__('Edit Poll Answer'), diff --git a/app/code/core/Mage/Adminhtml/controllers/PollController.php b/app/code/core/Mage/Adminhtml/controllers/PollController.php index 5d5a52e201bff..8a08775d8b8d4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/PollController.php +++ b/app/code/core/Mage/Adminhtml/controllers/PollController.php @@ -39,7 +39,7 @@ public function indexAction() $this->_title($this->__('CMS'))->_title($this->__('Polls')); $this->loadLayout(); - $this->_setActiveMenu('cms/poll'); + $this->_setActiveMenu('Mage_Poll::cms_poll'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Poll Manager'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Poll Manager')); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Poll_Poll')); @@ -59,7 +59,7 @@ public function editAction() Mage::register('poll_data', $pollModel); $this->loadLayout(); - $this->_setActiveMenu('cms/poll'); + $this->_setActiveMenu('Mage_Poll::cms_poll'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Poll Manager'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Poll Manager'), $this->getUrl('*/*/')); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Edit Poll'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Edit Poll')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php index db127fd529f49..e663edffe28ed 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php @@ -43,7 +43,7 @@ class Mage_Adminhtml_Promo_CatalogController extends Mage_Adminhtml_Controller_A protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('promo/catalog') + ->_setActiveMenu('Mage_CatalogRule::promo_catalog') ->_addBreadcrumb( Mage::helper('Mage_CatalogRule_Helper_Data')->__('Promotions'), Mage::helper('Mage_CatalogRule_Helper_Data')->__('Promotions') diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php index 09dfceb15a507..fc1ff2416c3a6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php @@ -46,7 +46,7 @@ protected function _initRule() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('promo/quote') + ->_setActiveMenu('Mage_SalesRule::promo_quote') ->_addBreadcrumb(Mage::helper('Mage_SalesRule_Helper_Data')->__('Promotions'), Mage::helper('Mage_SalesRule_Helper_Data')->__('Promotions')) ; return $this; diff --git a/app/code/core/Mage/Adminhtml/controllers/PromoController.php b/app/code/core/Mage/Adminhtml/controllers/PromoController.php index c614c06831d51..fb21b4a656e1e 100644 --- a/app/code/core/Mage/Adminhtml/controllers/PromoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/PromoController.php @@ -37,7 +37,7 @@ class Mage_Adminhtml_PromoController extends Mage_Adminhtml_Controller_Action public function indexAction() { $this->loadLayout(); - $this->_setActiveMenu('promo'); + $this->_setActiveMenu('Mage_CatalogRule::promo'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Promotions'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Promo')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/RatingController.php b/app/code/core/Mage/Adminhtml/controllers/RatingController.php index b778c00991e3b..d5f8610f5e426 100644 --- a/app/code/core/Mage/Adminhtml/controllers/RatingController.php +++ b/app/code/core/Mage/Adminhtml/controllers/RatingController.php @@ -39,7 +39,7 @@ public function indexAction() $this->_initEnityId(); $this->loadLayout(); - $this->_setActiveMenu('catalog/ratings'); + $this->_setActiveMenu('Mage_Review::catalog_reviews_ratings_ratings'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Manage Ratings'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Manage Ratings')); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Rating_Rating')); @@ -58,7 +58,7 @@ public function editAction() $this->_title($ratingModel->getId() ? $ratingModel->getRatingCode() : $this->__('New Rating')); - $this->_setActiveMenu('catalog/ratings'); + $this->_setActiveMenu('Mage_Review::catalog_reviews_ratings_ratings'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Manage Ratings'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Manage Ratings')); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Rating_Edit')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php index a858fa8e892f5..5357a6467bc6a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php @@ -53,7 +53,7 @@ public function accountsAction() ->_title($this->__('New Accounts')); $this->_initAction() - ->_setActiveMenu('report/customer/accounts') + ->_setActiveMenu('Mage_Reports::report_customers_accounts') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('New Accounts'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('New Accounts')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Customer_Accounts')) ->renderLayout(); @@ -90,7 +90,7 @@ public function ordersAction() ->_title($this->__('Customers by Number of Orders')); $this->_initAction() - ->_setActiveMenu('report/customer/orders') + ->_setActiveMenu('Mage_Reports::report_customers_orders') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Customers by Number of Orders'), Mage::helper('Mage_Reports_Helper_Data')->__('Customers by Number of Orders')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Customer_Orders')) @@ -128,7 +128,7 @@ public function totalsAction() ->_title($this->__('Customers by Orders Total')); $this->_initAction() - ->_setActiveMenu('report/customer/totals') + ->_setActiveMenu('Mage_Reports::report_customers_totals') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Customers by Orders Total'), Mage::helper('Mage_Reports_Helper_Data')->__('Customers by Orders Total')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Customer_Totals')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php index cfa8c7175582b..10e35459ca9d0 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php @@ -57,7 +57,7 @@ public function soldAction() ->_title($this->__('Products Ordered')); $this->_initAction() - ->_setActiveMenu('report/product/sold') + ->_setActiveMenu('Mage_Reports::report_products_sold') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Products Ordered'), Mage::helper('Mage_Reports_Helper_Data')->__('Products Ordered')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Product_Sold')) ->renderLayout(); @@ -102,7 +102,7 @@ public function viewedAction() $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_PRODUCT_VIEWED_FLAG_CODE, 'viewed'); $this->_initAction() - ->_setActiveMenu('report/products/viewed') + ->_setActiveMenu('Mage_Reports::report_products_viewed') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Products Most Viewed Report'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Products Most Viewed Report')); $gridBlock = $this->getLayout()->getBlock('report_product_viewed.grid'); @@ -151,7 +151,7 @@ public function lowstockAction() ->_title($this->__('Low Stock')); $this->_initAction() - ->_setActiveMenu('report/product/lowstock') + ->_setActiveMenu('Mage_Reports::report_products_lowstock') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Low Stock'), Mage::helper('Mage_Reports_Helper_Data')->__('Low Stock')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Product_Lowstock')) ->renderLayout(); @@ -196,7 +196,7 @@ public function downloadsAction() ->_title($this->__('Downloads')); $this->_initAction() - ->_setActiveMenu('report/product/downloads') + ->_setActiveMenu('Mage_Downloadable::report_products_downloads') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Downloads'), Mage::helper('Mage_Reports_Helper_Data')->__('Downloads')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Product_Downloads')) ->renderLayout(); diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php index 893b50399a9b5..845906dcb80c1 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php @@ -52,7 +52,7 @@ public function customerAction() ->_title($this->__('Customer Reviews')); $this->_initAction() - ->_setActiveMenu('report/review/customer') + ->_setActiveMenu('Mage_Review::report_review_customer') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Review_Customer')) ->renderLayout(); @@ -89,7 +89,7 @@ public function productAction() ->_title($this->__('Product Reviews')); $this->_initAction() - ->_setActiveMenu('report/review/product') + ->_setActiveMenu('Mage_Review::report_review_product') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Products Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Products Report')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Review_Product')) ->renderLayout(); @@ -127,7 +127,7 @@ public function productDetailAction() ->_title($this->__('Details')); $this->_initAction() - ->_setActiveMenu('report/review/productDetail') + ->_setActiveMenu('Mage_Review::report_review') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Products Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Products Report')) ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Product Reviews'), Mage::helper('Mage_Reports_Helper_Data')->__('Product Reviews')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Review_Detail')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php index 0b2b0f0e41f72..1814539c6796a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php @@ -52,7 +52,7 @@ public function salesAction() $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_ORDER_FLAG_CODE, 'sales'); $this->_initAction() - ->_setActiveMenu('report/sales/sales') + ->_setActiveMenu('Mage_Reports::report_salesroot_sales') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Sales Report'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Sales Report')); $gridBlock = $this->getLayout()->getBlock('report_sales_sales.grid'); @@ -73,7 +73,7 @@ public function bestsellersAction() $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_BESTSELLERS_FLAG_CODE, 'bestsellers'); $this->_initAction() - ->_setActiveMenu('report/products/bestsellers') + ->_setActiveMenu('Mage_Reports::report_products_bestsellers') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Products Bestsellers Report'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Products Bestsellers Report')); $gridBlock = $this->getLayout()->getBlock('report_sales_bestsellers.grid'); @@ -158,7 +158,7 @@ public function taxAction() $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_TAX_FLAG_CODE, 'tax'); $this->_initAction() - ->_setActiveMenu('report/sales/tax') + ->_setActiveMenu('Mage_Reports::report_salesroot_tax') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Tax'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Tax')); $gridBlock = $this->getLayout()->getBlock('report_sales_tax.grid'); @@ -201,7 +201,7 @@ public function shippingAction() $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_SHIPPING_FLAG_CODE, 'shipping'); $this->_initAction() - ->_setActiveMenu('report/sales/shipping') + ->_setActiveMenu('Mage_Reports::report_salesroot_shipping') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Shipping'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Shipping')); $gridBlock = $this->getLayout()->getBlock('report_sales_shipping.grid'); @@ -244,7 +244,7 @@ public function invoicedAction() $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_INVOICE_FLAG_CODE, 'invoiced'); $this->_initAction() - ->_setActiveMenu('report/sales/invoiced') + ->_setActiveMenu('Mage_Reports::report_salesroot_invoiced') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Total Invoiced'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Total Invoiced')); $gridBlock = $this->getLayout()->getBlock('report_sales_invoiced.grid'); @@ -287,7 +287,7 @@ public function refundedAction() $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_REFUNDED_FLAG_CODE, 'refunded'); $this->_initAction() - ->_setActiveMenu('report/sales/refunded') + ->_setActiveMenu('Mage_Reports::report_salesroot_refunded') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Total Refunded'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Total Refunded')); $gridBlock = $this->getLayout()->getBlock('report_sales_refunded.grid'); @@ -330,7 +330,7 @@ public function couponsAction() $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_COUPONS_FLAG_CODE, 'coupons'); $this->_initAction() - ->_setActiveMenu('report/sales/coupons') + ->_setActiveMenu('Mage_Reports::report_salesroot_coupons') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Coupons'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Coupons')); $gridBlock = $this->getLayout()->getBlock('report_sales_coupons.grid'); diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php index b52cf7286a561..e8957c6278a49 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php @@ -49,7 +49,7 @@ public function customerAction() ->_title($this->__('Customer Shopping Carts')); $this->_initAction() - ->_setActiveMenu('report/shopcart/customer') + ->_setActiveMenu('Mage_Reports::report_shopcart_customer') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Shopcart_Customer')) ->renderLayout(); @@ -86,7 +86,7 @@ public function productAction() ->_title($this->__('Products in Carts')); $this->_initAction() - ->_setActiveMenu('report/shopcart/product') + ->_setActiveMenu('Mage_Reports::report_shopcart_product') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Products Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Products Report')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Shopcart_Product')) ->renderLayout(); @@ -123,7 +123,7 @@ public function abandonedAction() ->_title($this->__('Abandoned Carts')); $this->_initAction() - ->_setActiveMenu('report/shopcart/abandoned') + ->_setActiveMenu('Mage_Reports::report_shopcart_abandoned') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Abandoned Carts'), Mage::helper('Mage_Reports_Helper_Data')->__('Abandoned Carts')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Shopcart_Abandoned')) ->renderLayout(); diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php b/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php index 64fb57d14b1b0..7b6cc54066d23 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php @@ -179,7 +179,7 @@ public function indexAction() $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Refresh Statistics')); $this->_initAction() - ->_setActiveMenu('report/statistics/refreshstatistics') + ->_setActiveMenu('Mage_Reports::report_statistics') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Refresh Statistics'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Refresh Statistics')) ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php b/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php index ad5ff358a25d0..e73513b1ef224 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php @@ -52,7 +52,7 @@ public function customerAction() ->_title($this->__('Customers')); $this->_initAction() - ->_setActiveMenu('report/tag/customer') + ->_setActiveMenu('Mage_Tag::report_tags_customer') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Tag_Customer')) ->renderLayout(); @@ -89,7 +89,7 @@ public function productAction() ->_title($this->__('Products')); $this->_initAction() - ->_setActiveMenu('report/tag/product') + ->_setActiveMenu('Mage_Tag::report_tags_product') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Poducts Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Products Report')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Tag_Product')) ->renderLayout(); @@ -127,7 +127,7 @@ public function popularAction() ->_title($this->__('Popular')); $this->_initAction() - ->_setActiveMenu('report/tag/popular') + ->_setActiveMenu('Mage_Tag::report_tags_popular') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Popular Tags'), Mage::helper('Mage_Reports_Helper_Data')->__('Popular Tags')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Tag_Popular')) ->renderLayout(); @@ -167,7 +167,7 @@ public function customerDetailAction() ->_title($detailBlock->getHeaderText()); $this->_initAction() - ->_setActiveMenu('report/tag/customerDetail') + ->_setActiveMenu('Mage_Tag::report_tags') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Customers Report')) ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Customer Tags'), Mage::helper('Mage_Reports_Helper_Data')->__('Customer Tags')) ->_addContent($detailBlock) @@ -208,7 +208,7 @@ public function productDetailAction() ->_title($detailBlock->getHeaderText()); $this->_initAction() - ->_setActiveMenu('report/tag/productDetail') + ->_setActiveMenu('Mage_Tag::report_tags') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Products Report'), Mage::helper('Mage_Reports_Helper_Data')->__('Products Report')) ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Product Tags'), Mage::helper('Mage_Reports_Helper_Data')->__('Product Tags')) ->_addContent($detailBlock) @@ -249,7 +249,7 @@ public function tagDetailAction() ->_title($detailBlock->getHeaderText()); $this->_initAction() - ->_setActiveMenu('report/tag/tagDetail') + ->_setActiveMenu('Mage_Tag::report_tags') ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Popular Tags'), Mage::helper('Mage_Reports_Helper_Data')->__('Popular Tags')) ->_addBreadcrumb(Mage::helper('Mage_Reports_Helper_Data')->__('Tag Detail'), Mage::helper('Mage_Reports_Helper_Data')->__('Tag Detail')) ->_addContent($detailBlock) diff --git a/app/code/core/Mage/Adminhtml/controllers/ReportController.php b/app/code/core/Mage/Adminhtml/controllers/ReportController.php index 91ecd1d96ae8a..0b65e32fc4665 100644 --- a/app/code/core/Mage/Adminhtml/controllers/ReportController.php +++ b/app/code/core/Mage/Adminhtml/controllers/ReportController.php @@ -41,40 +41,6 @@ public function _initAction() } -/* - public function wishlistAction() - { - $this->_initAction() - ->_setActiveMenu('report/wishlist') - ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Wishlist Report'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Wishlist Report')) - ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Wishlist')) - ->renderLayout(); - } - - /** - * Export wishlist report grid to CSV format - * / - public function exportWishlistCsvAction() - { - $fileName = 'wishlist.csv'; - $content = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Wishlist_Grid') - ->getCsvFile(); - - $this->_prepareDownloadResponse($fileName, $content); - } - - /** - * Export wishlist report to Excel XML format - * / - public function exportWishlistExcelAction() - { - $fileName = 'wishlist.xml'; - $content = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Wishlist_Grid') - ->getExcelFile($fileName); - - $this->_prepareDownloadResponse($fileName, $content); - } -*/ public function searchAction() { $this->_title($this->__('Reports'))->_title($this->__('Search Terms')); @@ -82,7 +48,7 @@ public function searchAction() Mage::dispatchEvent('on_view_report', array('report' => 'search')); $this->_initAction() - ->_setActiveMenu('report/search') + ->_setActiveMenu('Mage_Reports::report_search') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Search Terms'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Search Terms')) ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Report_Search')) ->renderLayout(); @@ -111,23 +77,6 @@ public function exportSearchExcelAction() $this->_prepareDownloadResponse($fileName, $content); } -/* - public function ordersAction() - { - $this->_initAction() - ->_setActiveMenu('report/orders') - ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Recent Orders'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Recent Orders')) - ->renderLayout(); - } - - public function totalsAction() - { - $this->_initAction() - ->_setActiveMenu('report/totals') - ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Order Totals'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Order Totals')) - ->renderLayout(); - } -*/ protected function _isAllowed() { @@ -135,11 +84,6 @@ protected function _isAllowed() case 'search': return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/search'); break; - /* - case 'customers': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/shopcart'); - break; - */ default: return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report'); break; diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php index f19f87e3e7018..bc6f667566fe3 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php @@ -41,7 +41,7 @@ public function indexAction() ->_title($this->__('Billing Agreements')); $this->loadLayout() - ->_setActiveMenu('sales/billing_agreement') + ->_setActiveMenu('Mage_Sales::sales_billing_agreement') ->renderLayout(); } @@ -69,7 +69,7 @@ public function viewAction() ->_title(sprintf("#%s", $agreementModel->getReferenceId())); $this->loadLayout() - ->_setActiveMenu('sales/billing_agreement') + ->_setActiveMenu('Mage_Sales::sales_billing_agreement') ->renderLayout(); return; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php index c6f1d222ec70a..78db2720b6379 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php @@ -332,7 +332,7 @@ public function indexAction() $this->_initSession(); $this->loadLayout(); - $this->_setActiveMenu('sales/order') + $this->_setActiveMenu('Mage_Sales::sales_order') ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php index 780d64da8dd9f..8021b0dbc0b7c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php @@ -196,7 +196,7 @@ public function viewAction() $this->loadLayout(); $this->getLayout()->getBlock('sales_creditmemo_view') ->updateBackButtonUrl($this->getRequest()->getParam('come_from')); - $this->_setActiveMenu('sales/order') + $this->_setActiveMenu('Mage_Sales::sales_order') ->renderLayout(); } else { $this->_forward('noRoute'); @@ -231,7 +231,7 @@ public function newAction() } $this->loadLayout() - ->_setActiveMenu('sales/order') + ->_setActiveMenu('Mage_Sales::sales_order') ->renderLayout(); } else { $this->_forward('noRoute'); diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php index 3084cca7ba09a..b09ee4c5c65b7 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php @@ -70,7 +70,7 @@ public function indexAction() $this->loadLayout(); $this->_initSession() - ->_setActiveMenu('sales/order') + ->_setActiveMenu('Mage_Sales::sales_order') ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php index 05278cf0fbf88..5cd3552f2193f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php @@ -147,7 +147,7 @@ public function viewAction() $this->_title(sprintf("#%s", $invoice->getIncrementId())); $this->loadLayout() - ->_setActiveMenu('sales/order'); + ->_setActiveMenu('Mage_Sales::sales_order'); $this->getLayout()->getBlock('sales_invoice_view') ->updateBackButtonUrl($this->getRequest()->getParam('come_from')); $this->renderLayout(); @@ -183,7 +183,7 @@ public function newAction() } $this->loadLayout() - ->_setActiveMenu('sales/order') + ->_setActiveMenu('Mage_Sales::sales_order') ->renderLayout(); } else { $this->_redirect('*/sales_order/view', array('order_id'=>$this->getRequest()->getParam('order_id'))); diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php index 3d6514ccc524f..60fa60fbe9652 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php @@ -133,7 +133,7 @@ public function viewAction() $this->loadLayout(); $this->getLayout()->getBlock('sales_shipment_view') ->updateBackButtonUrl($this->getRequest()->getParam('come_from')); - $this->_setActiveMenu('sales/order') + $this->_setActiveMenu('Mage_Sales::sales_order') ->renderLayout(); } else { $this->_forward('noRoute'); @@ -165,7 +165,7 @@ public function newAction() } $this->loadLayout() - ->_setActiveMenu('sales/order') + ->_setActiveMenu('Mage_Sales::sales_order') ->renderLayout(); } else { $this->_redirect('*/sales_order/view', array('order_id'=>$this->getRequest()->getParam('order_id'))); diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php index 7bd27423c3e5c..8c18a3db18980 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php @@ -64,7 +64,7 @@ protected function _initStatus() public function indexAction() { $this->_title($this->__('Sales'))->_title($this->__('Order Statuses')); - $this->loadLayout()->_setActiveMenu('system')->renderLayout(); + $this->loadLayout()->_setActiveMenu('Mage_Adminhtml::system')->renderLayout(); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php index e002da16ffbd2..e891015d4e8d0 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php @@ -57,7 +57,7 @@ protected function _construct() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/order') + ->_setActiveMenu('Mage_Sales::sales_order') ->_addBreadcrumb($this->__('Sales'), $this->__('Sales')) ->_addBreadcrumb($this->__('Orders'), $this->__('Orders')); return $this; diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php index 5ef0e55d88128..42eccc7657c1e 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php @@ -40,7 +40,7 @@ public function indexAction() { $this->_title(Mage::helper('Mage_Sales_Helper_Data')->__('Sales'))->_title(Mage::helper('Mage_Sales_Helper_Data')->__('Recurring Profiles')) ->loadLayout() - ->_setActiveMenu('sales/recurring_profile') + ->_setActiveMenu('Mage_Sales::sales_recurring_profile') ->renderLayout(); return $this; } @@ -54,7 +54,7 @@ public function viewAction() $this->_title(Mage::helper('Mage_Sales_Helper_Data')->__('Sales'))->_title(Mage::helper('Mage_Sales_Helper_Data')->__('Recurring Profiles')); $profile = $this->_initProfile(); $this->loadLayout() - ->_setActiveMenu('sales/recurring_profile') + ->_setActiveMenu('Mage_Sales::sales_recurring_profile') ->_title(Mage::helper('Mage_Sales_Helper_Data')->__('Profile #%s', $profile->getReferenceId())) ->renderLayout() ; diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php index 71898097a2846..2dfeb908ab419 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php @@ -65,7 +65,7 @@ public function indexAction() ->_title($this->__('Transactions')); $this->loadLayout() - ->_setActiveMenu('sales/transactions') + ->_setActiveMenu('Mage_Sales::sales_transactions') ->renderLayout(); } @@ -92,7 +92,7 @@ public function viewAction() ->_title(sprintf("#%s", $txn->getTxnId())); $this->loadLayout() - ->_setActiveMenu('sales/transactions') + ->_setActiveMenu('Mage_Sales::sales_transactions') ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php index a4df76346ebc0..05d8328ebf910 100644 --- a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php +++ b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php @@ -42,7 +42,7 @@ protected function _initAction() { // load layout, set active menu and breadcrumbs $this->loadLayout() - ->_setActiveMenu('catalog/system_sitemap') + ->_setActiveMenu('Mage_Sitemap::catalog_sitemap') ->_addBreadcrumb( Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog'), Mage::helper('Mage_Catalog_Helper_Data')->__('Catalog')) diff --git a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php index 13f5b14b8db97..892fc1fcb5d27 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php @@ -39,7 +39,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('My Account')); $this->loadLayout(); - $this->_setActiveMenu('system/account'); + $this->_setActiveMenu('Mage_Adminhtml::system_myaccount'); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_System_Account_Edit')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php b/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php index 1a9f3d6bdfc46..4faf5d8d066c3 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php @@ -46,7 +46,7 @@ public function indexAction() } $this->loadLayout(); - $this->_setActiveMenu('system'); + $this->_setActiveMenu('Mage_Adminhtml::system'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('System'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('System')); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Tools'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Tools')); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Backups'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Backup')); diff --git a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php index 99ef8106e1c55..0b92fd06a2832 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php @@ -89,7 +89,7 @@ public function editAction() $this->loadLayout(); - $this->_setActiveMenu('system/config'); + $this->_setActiveMenu('Mage_Adminhtml::system_config'); $this->getLayout()->getBlock('menu')->setAdditionalCacheKeyInfo(array($current)); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('System'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('System'), diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php index d022f2c9bbd90..09283bbe0d3e0 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php @@ -53,7 +53,7 @@ public function indexAction() /** * Set active menu item */ - $this->_setActiveMenu('system/convert'); + $this->_setActiveMenu('Mage_Adminhtml::system_convert'); /** * Append profiles block to content @@ -97,7 +97,7 @@ public function editAction() $this->_title($profile->getId() ? $profile->getName() : $this->__('New Profile')); - $this->_setActiveMenu('system/convert'); + $this->_setActiveMenu('Mage_Adminhtml::system_convert'); $this->_addContent( diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php index 4accb1a76181e..dba0670af3dd0 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php @@ -75,7 +75,7 @@ public function indexAction() /** * Set active menu item */ - $this->_setActiveMenu('system/convert'); + $this->_setActiveMenu('Mage_Adminhtml::system_convert'); /** * Append profiles block to content @@ -123,7 +123,7 @@ public function editAction() $this->_title($profile->getId() ? $profile->getName() : $this->__('New Profile')); - $this->_setActiveMenu('system/convert'); + $this->_setActiveMenu('Mage_Adminhtml::system_convert'); $this->_addContent( $this->getLayout()->createBlock('Mage_Adminhtml_Block_System_Convert_Profile_Edit') diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php index 344b1287fb341..9776f9fd69f69 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php @@ -56,7 +56,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('Manage Currency Rates')); $this->loadLayout(); - $this->_setActiveMenu('system/currency'); + $this->_setActiveMenu('Mage_Adminhtml::system_currency'); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_System_Currency')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php index 86fa2d9daf57d..f2bf325e81456 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php @@ -32,7 +32,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('Design')); $this->loadLayout(); - $this->_setActiveMenu('system'); + $this->_setActiveMenu('Mage_Adminhtml::system'); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_System_Design')); $this->renderLayout(); } @@ -54,7 +54,7 @@ public function editAction() $this->_title($this->__('System'))->_title($this->__('Design')); $this->loadLayout(); - $this->_setActiveMenu('system'); + $this->_setActiveMenu('Mage_Adminhtml::system'); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $id = (int) $this->getRequest()->getParam('id'); diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php index f8a1192ff0312..dfc174fe571a3 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php @@ -43,7 +43,7 @@ public function indexAction() } $this->loadLayout(); - $this->_setActiveMenu('system/email_template'); + $this->_setActiveMenu('Mage_Adminhtml::system_email_template'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Transactional Emails'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Transactional Emails')); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_System_Email_Template', 'template')); @@ -75,7 +75,7 @@ public function editAction() { $this->loadLayout(); $template = $this->_initTemplate('id'); - $this->_setActiveMenu('system/email_template'); + $this->_setActiveMenu('Mage_Adminhtml::system_email_template'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Transactional Emails'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Transactional Emails'), $this->getUrl('*/*')); if ($this->getRequest()->getParam('id')) { diff --git a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php index 6c9081a33af12..cde7f64768859 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php @@ -43,7 +43,7 @@ protected function _initAction() { // load layout, set active menu and breadcrumbs $this->loadLayout() - ->_setActiveMenu('system/store') + ->_setActiveMenu('Mage_Adminhtml::system_store') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('System'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('System')) ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Manage Stores'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Manage Stores')) ; diff --git a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php index c31223a50fe33..f7bd4ac0d5c75 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php @@ -41,7 +41,7 @@ class Mage_Adminhtml_System_VariableController extends Mage_Adminhtml_Controller protected function _initLayout() { $this->loadLayout() - ->_setActiveMenu('system/variable') + ->_setActiveMenu('Mage_Adminhtml::system_variable') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Custom Variables'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Custom Variables')); return $this; } diff --git a/app/code/core/Mage/Adminhtml/controllers/SystemController.php b/app/code/core/Mage/Adminhtml/controllers/SystemController.php index 4c4f7536f6c8e..3050961dc91f7 100644 --- a/app/code/core/Mage/Adminhtml/controllers/SystemController.php +++ b/app/code/core/Mage/Adminhtml/controllers/SystemController.php @@ -36,7 +36,7 @@ class Mage_Adminhtml_SystemController extends Mage_Adminhtml_Controller_Action public function indexAction() { $this->loadLayout(); - $this->_setActiveMenu('system'); + $this->_setActiveMenu('Mage_Adminhtml::system'); $this->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('System'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('System')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/TagController.php b/app/code/core/Mage/Adminhtml/controllers/TagController.php index 9fcb912d04012..aa903c7911673 100644 --- a/app/code/core/Mage/Adminhtml/controllers/TagController.php +++ b/app/code/core/Mage/Adminhtml/controllers/TagController.php @@ -37,7 +37,7 @@ class Mage_Adminhtml_TagController extends Mage_Adminhtml_Controller_Action protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('catalog/tag') + ->_setActiveMenu('Mage_Tag::catalog_tag') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Catalog'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Catalog')) ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Tags'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Tags')); @@ -81,7 +81,7 @@ public function indexAction() $this->_initAction() ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('All Tags'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('All Tags')) - ->_setActiveMenu('catalog/tag/all') + ->_setActiveMenu('Mage_Tag::catalog_tag_all') ->renderLayout(); } @@ -234,7 +234,7 @@ public function pendingAction() $this->_initAction() ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Pending Tags'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Pending Tags')) - ->_setActiveMenu('catalog/tag/pending') + ->_setActiveMenu('Mage_Tag::catalog_tag_pending') ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php index 601d50ed87762..7990e9279c81f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php @@ -167,7 +167,7 @@ public function deleteAction() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/tax/tax_class_customer') + ->_setActiveMenu('Mage_Tax::sales_tax_classes_customer') ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Sales'), Mage::helper('Mage_Tax_Helper_Data')->__('Sales')) ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Tax'), Mage::helper('Mage_Tax_Helper_Data')->__('Tax')) ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Manage Customer Tax Classes'), Mage::helper('Mage_Tax_Helper_Data')->__('Manage Customer Tax Classes')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php index bdf1604187d6d..5283f137a8f1f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php @@ -166,7 +166,7 @@ public function deleteAction() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/tax/tax_class_product') + ->_setActiveMenu('Mage_Tax::sales_tax_classes_product') ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Sales'), Mage::helper('Mage_Tax_Helper_Data')->__('Sales')) ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Tax'), Mage::helper('Mage_Tax_Helper_Data')->__('Tax')) ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Manage Product Tax Classes'), Mage::helper('Mage_Tax_Helper_Data')->__('Manage Product Tax Classes')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php index 9c135427fda18..0fa4530dc2c12 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php @@ -228,7 +228,7 @@ public function exportXmlAction() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/tax_rates') + ->_setActiveMenu('Mage_Tax::sales_tax_rates') ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Sales'), Mage::helper('Mage_Tax_Helper_Data')->__('Sales')) ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Tax'), Mage::helper('Mage_Tax_Helper_Data')->__('Tax')); return $this; @@ -247,7 +247,7 @@ public function importExportAction() $this->_title($this->__('Import and Export Tax Rates')); $this->loadLayout() - ->_setActiveMenu('sales/tax_importExport') + ->_setActiveMenu('Mage_Tax::sales_tax_import_export') ->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Tax_Rate_ImportExport')) ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php index e50d8d6c8b6df..e67fb5ac75bb7 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php @@ -156,7 +156,7 @@ public function deleteAction() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/tax/rule') + ->_setActiveMenu('Mage_Tax::sales_tax_rules') ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Tax'), Mage::helper('Mage_Tax_Helper_Data')->__('Tax')) ->_addBreadcrumb(Mage::helper('Mage_Tax_Helper_Data')->__('Tax Rules'), Mage::helper('Mage_Tax_Helper_Data')->__('Tax Rules')) ; diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php index 8109c88570663..febbaa15a306e 100644 --- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php @@ -67,7 +67,7 @@ public function indexAction() { $this->_initRegistry(); $this->loadLayout(); - $this->_setActiveMenu('catalog/urlrewrite'); + $this->_setActiveMenu('Mage_Catalog::catalog_urlrewrite'); $this->_addContent( $this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite') ); @@ -85,7 +85,7 @@ public function editAction() $this->_title($this->__('URL Rewrite')); $this->loadLayout(); - $this->_setActiveMenu('catalog/urlrewrite'); + $this->_setActiveMenu('Mage_Catalog::catalog_urlrewrite'); $this->_addContent($this->getLayout()->createBlock('Mage_Adminhtml_Block_Urlrewrite_Edit')); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $this->renderLayout(); diff --git a/app/code/core/Mage/Adminhtml/etc/adminhtml.xml b/app/code/core/Mage/Adminhtml/etc/adminhtml.xml index 5e1b47ace4308..c69a3c1a37a1d 100644 --- a/app/code/core/Mage/Adminhtml/etc/adminhtml.xml +++ b/app/code/core/Mage/Adminhtml/etc/adminhtml.xml @@ -26,86 +26,6 @@ */ --> - - - Dashboard - 10 - adminhtml/dashboard - - - System - 90 - - - - My Account - adminhtml/system_account - 10 - - - Tools - 20 - - - Design - 30 - - - Schedule - adminhtml/system_design - 10 - - - - - Import/Export - 40 - - - Dataflow - Profiles - adminhtml/system_convert_gui - 30 - - - Dataflow - Advanced Profiles - adminhtml/system_convert_profile - 40 - - - - - Manage Currency Rates - adminhtml/system_currency - 50 - - - Transactional Emails - adminhtml/system_email_template - 60 - - - Custom Variables - adminhtml/system_variable - 65 - - - Cache Management - adminhtml/cache - 90 - - - Manage Stores - adminhtml/system_store/ - 100 - - - Configuration - adminhtml/system_config - 110 - - - - diff --git a/app/code/core/Mage/Adminhtml/etc/adminhtml/menu.xml b/app/code/core/Mage/Adminhtml/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..a2dc5c9837e1b --- /dev/null +++ b/app/code/core/Mage/Adminhtml/etc/adminhtml/menu.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/admin/page.phtml b/app/code/core/Mage/Adminhtml/view/adminhtml/admin/page.phtml index 30e0a13f8d910..021c45ac96226 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/admin/page.phtml +++ b/app/code/core/Mage/Adminhtml/view/adminhtml/admin/page.phtml @@ -29,7 +29,7 @@ "type":"Mage_Core_Block_Template", "children":{ "header":{ "label":"Header", "type":"Mage_Adminhtml_Block_Page_Header" }, - "menu":{ "label":"Top navigation", "type":"Mage_Adminhtml_Block_Page_Menu" }, + "menu":{ "label":"Top navigation", "type":"Mage_Backend_Block_Menu" }, "breadcrumbs":{ "label":"Breadcrumbs", "type":"Mage_Adminhtml_Block_Widget_Breadcrumbs" }, "content":{ "label":"Content block", "type":"Mage_Core_Block_Template" }, "left":{ "label":"Left navigation", "type":"Mage_Core_Block_Template" }, diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/admin/popup.phtml b/app/code/core/Mage/Adminhtml/view/adminhtml/admin/popup.phtml index 69c93163f2e85..a6f78781e9f3d 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/admin/popup.phtml +++ b/app/code/core/Mage/Adminhtml/view/adminhtml/admin/popup.phtml @@ -29,7 +29,7 @@ "type":"Mage_Core_Block_Template", "children":{ "header":{ "label":"Header", "type":"Mage_Adminhtml_Block_Page_Header" }, - "menu":{ "label":"Top navigation", "type":"Mage_Adminhtml_Block_Page_Menu" }, + "menu":{ "label":"Top navigation", "type":"Mage_Backend_Block_Menu" }, "breadcrumbs":{ "label":"Breadcrumbs", "type":"Mage_Adminhtml_Block_Widget_Breadcrumbs" }, "content":{ "label":"Content block", "type":"Mage_Core_Block_Template" }, "left":{ "label":"Left navigation", "type":"Mage_Core_Block_Template" }, diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog.xml b/app/code/core/Mage/Adminhtml/view/adminhtml/catalog.xml index 11e0b210671f2..322b246279db9 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/catalog.xml +++ b/app/code/core/Mage/Adminhtml/view/adminhtml/catalog.xml @@ -32,7 +32,7 @@ Catalog - catalog/products + Mage_Catalog::catalog_products @@ -103,6 +103,7 @@ + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/customer.xml b/app/code/core/Mage/Adminhtml/view/adminhtml/customer.xml index 1ba7c6ef4dc12..8bb788e47c46c 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/customer.xml +++ b/app/code/core/Mage/Adminhtml/view/adminhtml/customer.xml @@ -113,6 +113,7 @@ + diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/main.xml b/app/code/core/Mage/Adminhtml/view/adminhtml/main.xml index 40d34fc4b0790..8e7fae386d95d 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/main.xml +++ b/app/code/core/Mage/Adminhtml/view/adminhtml/main.xml @@ -101,7 +101,6 @@ Supported layout update handles (special): - diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/tag.xml b/app/code/core/Mage/Adminhtml/view/adminhtml/tag.xml index 67c0e7f7aa5e8..1ff60f7434ed6 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/tag.xml +++ b/app/code/core/Mage/Adminhtml/view/adminhtml/tag.xml @@ -63,12 +63,14 @@ + + diff --git a/app/code/core/Mage/Api/etc/adminhtml.xml b/app/code/core/Mage/Api/etc/adminhtml.xml index 601041d27104e..5dfb93fdc5095 100644 --- a/app/code/core/Mage/Api/etc/adminhtml.xml +++ b/app/code/core/Mage/Api/etc/adminhtml.xml @@ -59,26 +59,4 @@ - - - - - Web Services - 25 - - - SOAP/XML-RPC - Users - adminhtml/api_user - 10 - - - SOAP/XML-RPC - Roles - adminhtml/api_role - 20 - - - - - - diff --git a/app/code/core/Mage/Api/etc/adminhtml/menu.xml b/app/code/core/Mage/Api/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..722de4b537e56 --- /dev/null +++ b/app/code/core/Mage/Api/etc/adminhtml/menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php index bf6b66a620bec..67faba015776e 100644 --- a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php +++ b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php @@ -42,7 +42,7 @@ public function indexAction() ->_title($this->__('Web Services')) ->_title($this->__('REST Attributes')); - $this->loadLayout()->_setActiveMenu('system/services/attributes'); + $this->loadLayout()->_setActiveMenu('Mage_Api2::system_api_rest_attributes'); $this->_addBreadcrumb($this->__('Web services'), $this->__('Web services')) ->_addBreadcrumb($this->__('REST Attributes'), $this->__('REST Attributes')) @@ -57,7 +57,7 @@ public function indexAction() public function editAction() { $this->loadLayout() - ->_setActiveMenu('system/services/attributes'); + ->_setActiveMenu('Mage_Api2::system_api_rest_attributes'); $type = $this->getRequest()->getParam('type'); diff --git a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php index a6e5470c52ee5..2551cc242a1e4 100644 --- a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php +++ b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php @@ -42,7 +42,7 @@ public function indexAction() ->_title($this->__('Web Services')) ->_title($this->__('REST Roles')); - $this->loadLayout()->_setActiveMenu('system/services/roles'); + $this->loadLayout()->_setActiveMenu('Mage_Api2::system_api_rest_roles'); $this->_addBreadcrumb($this->__('Web services'), $this->__('Web services')); $this->_addBreadcrumb($this->__('REST Roles'), $this->__('REST Roles')); $this->_addBreadcrumb($this->__('Roles'), $this->__('Roles')); @@ -83,7 +83,7 @@ public function newAction() ->_title($this->__('Web Services')) ->_title($this->__('Rest Roles')); - $this->loadLayout()->_setActiveMenu('system/services/roles'); + $this->loadLayout()->_setActiveMenu('Mage_Api2::system_api_rest_roles'); $this->_addBreadcrumb($this->__('Web services'), $this->__('Web services')); $this->_addBreadcrumb($this->__('REST Roles'), $this->__('REST Roles')); $this->_addBreadcrumb($this->__('Roles'), $this->__('Roles')); @@ -112,7 +112,7 @@ public function editAction() return; } - $this->loadLayout()->_setActiveMenu('system/services/roles'); + $this->loadLayout()->_setActiveMenu('Mage_Api2::system_api_rest_roles'); $this->_title($this->__('System')) ->_title($this->__('Web Services')) diff --git a/app/code/core/Mage/Api2/etc/adminhtml.xml b/app/code/core/Mage/Api2/etc/adminhtml.xml index 4b0ff88c5997a..7b210ceb892bb 100644 --- a/app/code/core/Mage/Api2/etc/adminhtml.xml +++ b/app/code/core/Mage/Api2/etc/adminhtml.xml @@ -70,24 +70,4 @@ - - - - - - - REST - Roles - 30 - adminhtml/api2_role - - - REST - Attributes - 40 - adminhtml/api2_attribute - - - - - - diff --git a/app/code/core/Mage/Api2/etc/adminhtml/menu.xml b/app/code/core/Mage/Api2/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..a020f71a2937c --- /dev/null +++ b/app/code/core/Mage/Api2/etc/adminhtml/menu.xml @@ -0,0 +1,33 @@ + + + + + + + + diff --git a/app/code/core/Mage/Backend/Block/Menu.php b/app/code/core/Mage/Backend/Block/Menu.php index b1d730e8d2dd9..53e902fae5692 100644 --- a/app/code/core/Mage/Backend/Block/Menu.php +++ b/app/code/core/Mage/Backend/Block/Menu.php @@ -38,6 +38,17 @@ class Mage_Backend_Block_Menu extends Mage_Backend_Block_Template { const CACHE_TAGS = 'BACKEND_MAINMENU'; + + /** + * @var string + */ + protected $_containerRendererBlock; + + /** + * @var string + */ + protected $_itemRendererBlock; + /** * Backend URL instance * @@ -45,6 +56,13 @@ class Mage_Backend_Block_Menu extends Mage_Backend_Block_Template */ protected $_url; + /** + * Current selected item + * + * @var Mage_Backend_Model_Menu_Item|null|bool + */ + protected $_activeItemModel = null; + /** * Initialize template and cache settings * @@ -52,7 +70,6 @@ class Mage_Backend_Block_Menu extends Mage_Backend_Block_Template protected function _construct() { parent::_construct(); - $this->setTemplate('Mage_Backend::menu.phtml'); $this->_url = Mage::getModel('Mage_Backend_Model_Url'); $this->setCacheTags(array(self::CACHE_TAGS)); } @@ -89,285 +106,111 @@ public function getCacheKeyInfo() } /** - * Retrieve Adminhtml Menu array - * - * @return array - */ - public function getMenuArray() - { - return $this->_buildMenuArray(); - } - - /** - * Retrieve Title value for menu node - * - * @param Varien_Simplexml_Element $child - * @return string - */ - protected function _getHelperValue(Varien_Simplexml_Element $child) - { - $helperName = 'Mage_Backend_Helper_Data'; - $titleNodeName = 'title'; - $childAttributes = $child->attributes(); - if (isset($childAttributes['module'])) { - $helperName = (string)$childAttributes['module']; - } -// if (isset($childAttributes['translate'])) { -// $titleNodeName = (string)$childAttributes['translate']; -// } - - return Mage::helper($helperName)->__((string)$child->$titleNodeName); - } - - /** - * Recursive Build Menu array + * Processing block html after rendering * - * @param Varien_Simplexml_Element $parent - * @param string $path - * @param int $level - * @return array + * @param string $html + * @return string */ - protected function _buildMenuArray(Varien_Simplexml_Element $parent=null, $path='', $level=0) + protected function _afterToHtml($html) { - if (is_null($parent)) { - $parent = Mage::getSingleton('Mage_Admin_Model_Config')->getAdminhtmlConfig()->getNode('menu'); - } - - $parentArr = array(); - $sortOrder = 0; - foreach ($parent->children() as $childName => $child) { - if (1 == $child->disabled) { - continue; - } - - $aclResource = 'admin/' . ($child->resource ? (string)$child->resource : $path . $childName); - if (!$this->_checkAcl($aclResource) || !$this->_isEnabledModuleOutput($child)) { - continue; - } - - if ($child->depends && !$this->_checkDepends($child->depends)) { - continue; - } - - $menuArr = array(); - - $menuArr['label'] = $this->_getHelperValue($child); - - $menuArr['sort_order'] = $child->sort_order ? (int)$child->sort_order : $sortOrder; - - if ($child->action) { - $menuArr['url'] = $this->_url->getUrl((string)$child->action, array('_cache_secret_key' => true)); - } else { - $menuArr['url'] = '#'; - $menuArr['click'] = 'return false'; - } - - $menuArr['active'] = ($this->getActive()==$path.$childName) - || (strpos($this->getActive(), $path.$childName.'/')===0); - - $menuArr['level'] = $level; - - if ($child->children) { - $menuArr['children'] = $this->_buildMenuArray($child->children, $path.$childName.'/', $level+1); - } - $parentArr[$childName] = $menuArr; - - $sortOrder++; - } - - uasort($parentArr, array($this, '_sortMenu')); - - while (list($key, $value) = each($parentArr)) { - $last = $key; - } - if (isset($last)) { - $parentArr[$last]['last'] = true; - } + $html = preg_replace_callback( + '#'.Mage_Backend_Model_Url::SECRET_KEY_PARAM_NAME.'/\$([^\/].*)/([^\$].*)\$#U', + array($this, '_callbackSecretKey'), + $html + ); - return $parentArr; + return $html; } /** - * Sort menu comparison function + * Replace Callback Secret Key * - * @param int $a - * @param int $b - * @return int + * @param array $match + * @return string */ - protected function _sortMenu($a, $b) + protected function _callbackSecretKey($match) { - return $a['sort_order']<$b['sort_order'] ? -1 : ($a['sort_order']>$b['sort_order'] ? 1 : 0); + return Mage_Backend_Model_Url::SECRET_KEY_PARAM_NAME . '/' + . $this->_url->getSecretKey($match[1], $match[2]); } /** - * Check Depends - * - * @param Varien_Simplexml_Element $depends - * @return bool + * Get menu config model + * @return Mage_Backend_Model_Menu */ - protected function _checkDepends(Varien_Simplexml_Element $depends) + public function getMenuModel() { - if ($depends->module) { - $modulesConfig = Mage::getConfig()->getNode('modules'); - foreach ($depends->module as $module) { - if (!$modulesConfig->$module || !$modulesConfig->$module->is('active')) { - return false; - } - } - } - - if ($depends->config) { - foreach ($depends->config as $path) { - if (!Mage::getStoreConfigFlag((string)$path)) { - return false; - } - } - } - - return true; + return Mage::getSingleton('Mage_Backend_Model_Menu_Config')->getMenu(); } /** - * Check is Allow menu item for admin user - * - * @param string $resource - * @return bool + * Render menu container + * @param $menu + * @param $level + * @return string HTML */ - protected function _checkAcl($resource) + public function renderMenuContainer($menu, $level = 0) { - try { - $res = Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resource); - } catch (Exception $e) { - return false; - } - return $res; + $block = $this->getChildBlock($this->getContainerRendererBlock()); + $block->setMenu($menu); + $block->setLevel($level); + $block->setMenuBlock($this); + return $block->toHtml(); } /** - * Processing block html after rendering - * - * @param string $html - * @return string + * Set container renderer block name + * @param string $renderer + * @return Mage_Backend_Block_Menu */ - protected function _afterToHtml($html) + public function setContainerRendererBlock($renderer) { - $html = preg_replace_callback('#'.Mage_Backend_Model_Url::SECRET_KEY_PARAM_NAME.'/\$([^\/].*)/([^\$].*)\$#U', array($this, '_callbackSecretKey'), $html); - - return $html; + $this->_containerRendererBlock = $renderer; + return $this; } /** - * Replace Callback Secret Key - * - * @param array $match + * Get container renderer block name * @return string */ - protected function _callbackSecretKey($match) + public function getContainerRendererBlock() { - return Mage_Backend_Model_Url::SECRET_KEY_PARAM_NAME . '/' - . $this->_url->getSecretKey($match[1], $match[2]); + return $this->_containerRendererBlock; } /** - * Render HTML menu recursively starting from the specified level - * - * @param array $menu - * @param int $level - * @return string + * Set item renderer block name + * @param string $renderer + * @return Mage_Backend_Block_Menu */ - protected function _renderMenuLevel(array $menu, $level = 0) + public function setItemRendererBlock($renderer) { - $result = ''; - foreach ($menu as $item) { - $hasChildren = !empty($item['children']); - $cssClasses = array('level' . $level); - if (!$level && !empty($item['active'])) { - $cssClasses[] = 'active'; - } - if ($hasChildren) { - $cssClasses[] = 'parent'; - } - if (!empty($level) && !empty($item['last'])) { - $cssClasses[] = 'last'; - } - $result .= '' - . '' - . '' . Mage::helper('Mage_Backend_Helper_Data')->escapeHtml($item['label']) . '' - . '' - ; - if ($hasChildren) { - $result .= $this->_renderMenuLevel($item['children'], $level + 1); - } - $result .= ''; - } - $result .= ''; - return $result; + $this->_itemRendererBlock = $renderer; + return $this; } /** - * Render HTML menu - * + * Get item renderer block name * @return string */ - public function renderMenu() + public function getItemRendererBlock() { - return $this->_renderMenuLevel($this->_buildMenuArray()); + return $this->_itemRendererBlock; } /** - * Get menu level HTML code + * Get current selected menu item * - * @param array $menu - * @param int $level - * @return string + * @return Mage_Backend_Model_Menu_Item|null|bool */ - public function getMenuLevel($menu, $level = 0) + public function getActiveItemModel() { - $html = '
    ' . PHP_EOL; - foreach ($menu as $item) { - $html .= '
  • ' - . $this->escapeHtml($item['label']) . '' . PHP_EOL; - - if (!empty($item['children'])) { - $html .= $this->getMenuLevel($item['children'], $level + 1); + if (is_null($this->_activeItemModel)) { + $this->_activeItemModel = $this->getMenuModel()->get($this->getActive()); + if (false == ($this->_activeItemModel instanceof Mage_Backend_Model_Menu_Item)) { + $this->_activeItemModel = false; } - $html .= '
  • ' . PHP_EOL; } - $html .= '
' . PHP_EOL; - - return $html; - } - - /** - * Check is module output enabled - * - * @param Varien_Simplexml_Element $child - * @return bool - */ - protected function _isEnabledModuleOutput(Varien_Simplexml_Element $child) - { - $helperName = 'Mage_Backend_Helper_Data'; - $childAttributes = $child->attributes(); - if (isset($childAttributes['module'])) { - $helperName = (string)$childAttributes['module']; - } - - return Mage::helper($helperName)->isModuleOutputEnabled(); + return $this->_activeItemModel; } } diff --git a/app/code/core/Mage/Backend/Block/Menu/Container.php b/app/code/core/Mage/Backend/Block/Menu/Container.php new file mode 100644 index 0000000000000..9b7ba884a71ac --- /dev/null +++ b/app/code/core/Mage/Backend/Block/Menu/Container.php @@ -0,0 +1,99 @@ + + */ +class Mage_Backend_Block_Menu_Container extends Mage_Backend_Block_Template +{ + /** + * @var Mage_Backend_Model_Menu + */ + protected $_menu; + + /** + * Set menu model + * @return Mage_Backend_Model_Menu + */ + public function getMenu() + { + return $this->_menu; + } + + /** + * Get menu filter iterator + * @return Mage_Backend_Model_Menu_Filter_Iterator + */ + public function getMenuIterator() + { + return Mage::getModel('Mage_Backend_Model_Menu_Filter_Iterator', $this->getMenu()->getIterator()); + } + + /** + * Get menu model + * + * @param Mage_Backend_Model_Menu $menu + * @return Mage_Backend_Block_Menu_Container + */ + public function setMenu(Mage_Backend_Model_Menu $menu) + { + $this->_menu = $menu; + return $this; + } + + /** + * Render menu item element + * @param Mage_Backend_Model_Menu_Item $menuItem + * @return string + */ + public function renderMenuItem(Mage_Backend_Model_Menu_Item $menuItem) + { + /** + * Save current level + */ + $currentLevel = $this->getLevel(); + + /** + * Render child blocks + * @var Mage_Backend_Block_Menu_Item + */ + $block = $this->getMenuBlock()->getChildBlock($this->getMenuBlock()->getItemRendererBlock()); + $block->setMenuItem($menuItem); + $block->setLevel($currentLevel); + $block->setContainerRenderer($this->getMenuBlock()); + $output = $block->toHtml(); + + /** + * Set current level, because it will be changed in child block + */ + $this->setLevel($currentLevel); + return $output; + } +} diff --git a/app/code/core/Mage/Backend/Block/Menu/Item.php b/app/code/core/Mage/Backend/Block/Menu/Item.php new file mode 100644 index 0000000000000..ab3a5eb989b14 --- /dev/null +++ b/app/code/core/Mage/Backend/Block/Menu/Item.php @@ -0,0 +1,115 @@ + + */ +class Mage_Backend_Block_Menu_Item extends Mage_Backend_Block_Template +{ + /** + * @var Mage_Backend_Block_Menu + */ + protected $_containerRenderer; + + /** + * @var Mage_Backend_Model_Menu_Item + */ + protected $_menuItem; + + /** + * Set menu model + * @return Mage_Backend_Model_Menu_Item + */ + public function getMenuItem() + { + return $this->_menuItem; + } + + /** + * Get menu item model + * + * @param Mage_Backend_Model_Menu_Item $menuItem + * @return Mage_Backend_Block_Menu_Item + */ + public function setMenuItem(Mage_Backend_Model_Menu_Item $menuItem) + { + $this->_menuItem = $menuItem; + return $this; + } + + /** + * Check whether given item is currently selected + * + * @param Mage_Backend_Model_Menu_Item $item + * @return bool + */ + public function isItemActive(Mage_Backend_Model_Menu_Item $item) + { + $itemModel = $this->getContainerRenderer()->getActiveItemModel(); + $output = false; + + if ($this->getLevel() == 0 + && $itemModel instanceof Mage_Backend_Model_Menu_Item + && ($itemModel->getId() == $item->getId() + || (strpos($itemModel->getFullPath(), $item->getFullPath() . '/') === 0)) + ) { + $output = true; + } + return $output; + } + + /** + * Current menu item is last + * @return bool + */ + public function isLast() + { + return ($this->getLevel() == 0 + && (bool)$this->getContainerRenderer()->getMenuModel()->isLast($this->getMenuItem())); + } + + /** + * @return Mage_Backend_Block_Menu + */ + public function getContainerRenderer() + { + return $this->_containerRenderer; + } + + /** + * @param Mage_Backend_Block_Menu $block + * @return Mage_Backend_Block_Menu_Item + */ + public function setContainerRenderer(Mage_Backend_Block_Menu $block) + { + $this->_containerRenderer = $block; + return $this; + } +} diff --git a/app/code/core/Mage/Backend/Block/Widget/Grid.php b/app/code/core/Mage/Backend/Block/Widget/Grid.php index 8ab34a8db0927..3ac090d4241a3 100644 --- a/app/code/core/Mage/Backend/Block/Widget/Grid.php +++ b/app/code/core/Mage/Backend/Block/Widget/Grid.php @@ -464,7 +464,7 @@ protected function _addColumnFilterToCollection($column) } else { $cond = $column->getFilter()->getCondition(); if ($field && isset($cond)) { - $this->getCollection()->addFieldToFilter($field , $cond); + $this->getCollection()->addFieldToFilter($field, $cond); } } } diff --git a/app/code/core/Mage/Backend/Controller/ActionAbstract.php b/app/code/core/Mage/Backend/Controller/ActionAbstract.php index 786a348181fd8..2ddebd4da089b 100644 --- a/app/code/core/Mage/Backend/Controller/ActionAbstract.php +++ b/app/code/core/Mage/Backend/Controller/ActionAbstract.php @@ -80,12 +80,12 @@ protected function _getHelper() /** * Define active menu item in menu block - * @param $menuPath + * @param string $itemId current active menu item * @return Mage_Backend_Controller_ActionAbstract */ - protected function _setActiveMenu($menuPath) + protected function _setActiveMenu($itemId) { - $this->getLayout()->getBlock('menu')->setActive($menuPath); + $this->getLayout()->getBlock('menu')->setActive($itemId); return $this; } diff --git a/app/code/core/Mage/Backend/Model/Menu.php b/app/code/core/Mage/Backend/Model/Menu.php new file mode 100644 index 0000000000000..9f96e86368f09 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu.php @@ -0,0 +1,239 @@ +_path = $array['path'] . '/'; + unset($array['path']); + } + if (isset($array['logger'])) { + $this->_logger = $array['logger']; + unset($array['logger']); + } else { + throw new InvalidArgumentException('Logger object is a required parameter'); + } + $this->setIteratorClass('Mage_Backend_Model_Menu_Iterator'); + parent::__construct($array); + } + + /** + * Add child to menu item + * + * @param Mage_Backend_Model_Menu_Item $item + * @param string $parentId + * @param int $index + * @throws InvalidArgumentException + */ + public function add(Mage_Backend_Model_Menu_Item $item, $parentId = null, $index = null) + { + if (!is_null($parentId)) { + $parentItem = $this->get($parentId); + if ($parentItem === null) { + throw new InvalidArgumentException("Item with identifier {$parentId} does not exist"); + } + $parentItem->getChildren()->add($item, null, $index); + } else { + $index = intval($index); + if (!isset($this[$index])) { + $this->offsetSet($index, $item); + $item->setPath($this->getFullPath()); + $this->_logger->log(sprintf('Add of item with id %s was processed', $item->getId())); + } else { + $this->add($item, $parentId, $index + 1); + } + } + } + + /** + * Retrieve menu item by id + * + * @param string $itemId + * @return Mage_Backend_Model_Menu_Item|null + */ + public function get($itemId) + { + $result = null; + foreach ($this as $item) { + /** @var $item Mage_Backend_Model_Menu_Item */ + if ($item->getId() == $itemId) { + $result = $item; + break; + } + + if ($item->hasChildren() && ($result = $item->getChildren()->get($itemId))) { + break; + } + } + return $result; + } + + /** + * Move menu item + * + * @param string $itemId + * @param string $toItemId + * @param int $sortIndex + */ + public function move($itemId, $toItemId, $sortIndex = null) + { + $item = $this->get($itemId); + if ($item === null) { + throw new InvalidArgumentException("Item with identifier {$itemId} does not exist"); + } + $this->remove($itemId); + $this->add($item, $toItemId, $sortIndex); + } + + /** + * Remove menu item by id + * + * @param string $itemId + * @return bool + */ + public function remove($itemId) + { + $result = false; + foreach ($this as $key => $item) { + /** @var $item Mage_Backend_Model_Menu_Item */ + if ($item->getId() == $itemId) { + unset($this[$key]); + $result = true; + $this->_logger->log(sprintf('Remove on item with id %s was processed', $item->getId())); + break; + } + + if ($item->hasChildren() && ($result = $item->getChildren()->remove($itemId))) { + break; + } + } + return $result; + } + + /** + * Change order of an item in its parent menu + * + * @param string $itemId + * @param int $position + * @return bool + */ + public function reorder($itemId, $position) + { + $result = false; + foreach ($this as $key => $item) { + /** @var $item Mage_Backend_Model_Menu_Item */ + if ($item->getId() == $itemId) { + unset($this[$key]); + $this->add($item, null, $position); + $result = true; + break; + } else if ($item->hasChildren() && $result = $item->getChildren()->reorder($itemId, $position)) { + break; + } + } + return $result; + } + + /** + * Check whether provided item is last in list + * + * @param Mage_Backend_Model_Menu_Item $item + * @return bool + */ + public function isLast(Mage_Backend_Model_Menu_Item $item) + { + return $this->offsetGet(max(array_keys($this->getArrayCopy())))->getId() == $item->getId(); + } + + /** + * Set path in tree + * + * @param $path + */ + public function setPath($path) + { + $this->_path = $path . '/'; + /** @var $child Mage_Backend_Model_Menu_Item */ + foreach ($this as $child) { + $child->setPath($this->getFullPath()); + } + } + + /** + * Retrieve full path to node in tree + * + * @return string + */ + public function getFullPath() + { + return $this->_path; + } + + /** + * Find first menu item that user is able to access + * + * @return Mage_Backend_Model_Menu_Item|null + */ + public function getFirstAvailable() + { + $result = null; + /** @var $item Mage_Backend_Model_Menu_Item */ + foreach ($this as $item) { + if ($item->isAllowed() && !$item->isDisabled()) { + if ($item->hasChildren()) { + $result = $item->getChildren()->getFirstAvailable(); + if (false == is_null($result)) { + break; + } + } else { + $result = $item; + break; + } + } + } + return $result; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder.php b/app/code/core/Mage/Backend/Model/Menu/Builder.php new file mode 100644 index 0000000000000..573ac181931f9 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Builder.php @@ -0,0 +1,124 @@ +_itemFactory = $data['itemFactory']; + + if (!isset($data['menu']) || !($data['menu'] instanceof Mage_Backend_Model_Menu)) { + throw new InvalidArgumentException(); + } + $this->_menu = $data['menu']; + } + + /** + * Process provided command object + * + * @param Mage_Backend_Model_Menu_Builder_CommandAbstract $command + * @return Mage_Backend_Model_Menu_Builder + */ + public function processCommand(Mage_Backend_Model_Menu_Builder_CommandAbstract $command) + { + if (!isset($this->_commands[$command->getId()])) { + $this->_commands[$command->getId()] = $command; + } else { + $this->_commands[$command->getId()]->chain($command); + } + return $this; + } + + /** + * @return Mage_Backend_Model_Menu + * @throws OutOfRangeException in case given parent id does not exists + */ + public function getResult() + { + /** @var $items Mage_Backend_Model_Menu_Item[] */ + $params = array(); + $items = array(); + + // Create menu items + foreach ($this->_commands as $id => $command) { + $params[$id] = $command->execute(); + $item = $this->_itemFactory->createFromArray($params[$id]); + $items[$id] = $item; + } + + // Build menu tree based on "parent" param + foreach($items as $id => $item) { + $sortOrder = isset($params[$id]['sortOrder']) ? $params[$id]['sortOrder'] : null; + $parentId = isset($params[$id]['parent']) ? $params[$id]['parent'] : null; + $isRemoved = isset($params[$id]['removed']); + + if ($isRemoved) { + continue; + } + if (!$parentId) { + $this->_menu->add($item, null, $sortOrder); + } else { + if (!isset($items[$parentId])) { + throw new OutOfRangeException(sprintf('Specified invalid parent id (%s)', $parentId)); + } + if (isset($params[$parentId]['removed'])) { + continue; + } + $items[$parentId]->getChildren()->add($item, null, $sortOrder); + } + } + + return $this->_menu; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php b/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php new file mode 100644 index 0000000000000..ea6bcfd907ade --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php @@ -0,0 +1,71 @@ +getId() . ")"); + } + return parent::chain($command); + } + + /** + * Add missing data to item + * + * @param array $itemParams + * @return array + */ + protected function _execute(array $itemParams) + { + foreach($this->_data as $key => $value) { + $itemParams[$key] = isset($itemParams[$key]) ? $itemParams[$key] : $value; + } + return $itemParams; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Remove.php b/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Remove.php new file mode 100644 index 0000000000000..86fe1e49bd175 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Remove.php @@ -0,0 +1,44 @@ +getId(); + $itemParams['removed'] = true; + return $itemParams; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Update.php b/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Update.php new file mode 100644 index 0000000000000..e69c56a6f2cc1 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Update.php @@ -0,0 +1,45 @@ +_data as $key => $value) { + $itemParams[$key] = $value; + } + return $itemParams; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder/CommandAbstract.php b/app/code/core/Mage/Backend/Model/Menu/Builder/CommandAbstract.php new file mode 100644 index 0000000000000..d97e8162d8adf --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Builder/CommandAbstract.php @@ -0,0 +1,116 @@ +_requiredParams as $param) { + if (!isset($data[$param]) || is_null($data[$param])) { + throw new InvalidArgumentException("Missing required param " . $param); + } + } + $this->_data = $data; + } + + /** + * Retreive id of element to apply command to + * + * @return int + */ + public function getId() + { + return $this->_data['id']; + } + + /** + * Add command as last in the list of callbacks + * + * @param Mage_Backend_Model_Menu_Builder_CommandAbstract $command + * @return Mage_Backend_Model_Menu_Builder_CommandAbstract + * @throws InvalidArgumentException if invalid chaining command is supplied + */ + public function chain(Mage_Backend_Model_Menu_Builder_CommandAbstract $command) + { + if (is_null($this->_next)) { + $this->_next = $command; + } else { + $this->_next->chain($command); + } + return $this; + } + + /** + * Execute command and pass control to chained commands + * + * @param array $itemParams + * @return array + */ + public function execute(array $itemParams = array()) + { + $itemParams = $this->_execute($itemParams); + if (!is_null($this->_next)) { + $itemParams = $this->_next->execute($itemParams); + } + return $itemParams; + } + + /** + * Execute internal command actions + * + * @param array $itemParams + * @return array + */ + protected abstract function _execute(array $itemParams); +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Config.php b/app/code/core/Mage/Backend/Model/Menu/Config.php new file mode 100644 index 0000000000000..b3c56f3c741bb --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Config.php @@ -0,0 +1,174 @@ +_cache = isset($arguments['cache']) ? $arguments['cache'] : Mage::app()->getCacheInstance(); + $this->_appConfig = isset($arguments['appConfig']) ? $arguments['appConfig'] : Mage::getConfig(); + $this->_eventManager = isset($arguments['eventManager']) + ? $arguments['eventManager'] + : Mage::getSingleton('Mage_Core_Model_Event_Manager'); + + $this->_logger = isset($arguments['logger']) + ? $arguments['logger'] + : Mage::getSingleton('Mage_Backend_Model_Menu_Logger'); + + $this->_menuBuilder = isset($arguments['menuBuilder']) + ? $arguments['menuBuilder'] + : Mage::getSingleton('Mage_Backend_Model_Menu_Builder', array( + 'menu' => Mage::getSingleton('Mage_Backend_Model_Menu_Factory')->getMenuInstance(), + 'itemFactory' => Mage::getSingleton('Mage_Backend_Model_Menu_Item_Factory'), + )); + } + + /** + * Build menu model from config + * + * @return Mage_Backend_Model_Menu + * @throws InvalidArgumentException|BadMethodCallException|OutOfRangeException|Exception + */ + public function getMenu() + { + try { + $this->_initMenu(); + return $this->_menu; + } catch (InvalidArgumentException $e) { + $this->_logger->logException($e); + throw $e; + } catch (BadMethodCallException $e) { + $this->_logger->logException($e); + throw $e; + } catch (OutOfRangeException $e) { + $this->_logger->logException($e); + throw $e; + } catch (Exception $e) { + throw $e; + } + } + + /** + * Initialize menu object + * + * @return void + */ + protected function _initMenu() + { + if (!$this->_menu) { + /* @var $director Mage_Backend_Model_Menu_Director_Dom */ + $director = $this->_appConfig->getModelInstance( + 'Mage_Backend_Model_Menu_Director_Dom', + array( + 'config' => $this->_getDom(), + 'factory' => $this->_appConfig, + 'logger' => $this->_logger + ) + ); + $director->buildMenu($this->_menuBuilder); + $this->_menu = $this->_menuBuilder->getResult(); + $this->_eventManager->dispatch('backend_menu_load_after', array('menu' => $this->_menu)); + } + } + + /** + * @return DOMDocument + */ + protected function _getDom() + { + $mergedConfigXml = $this->_loadCache(); + if ($mergedConfigXml) { + $mergedConfig = new DOMDocument(); + $mergedConfig->loadXML($mergedConfigXml); + } else { + $fileList = $this->getMenuConfigurationFiles(); + $mergedConfig = $this->_appConfig + ->getModelInstance('Mage_Backend_Model_Menu_Config_Menu', $fileList)->getMergedConfig(); + $this->_saveCache($mergedConfig->saveXML()); + } + return $mergedConfig; + } + + protected function _loadCache() + { + if ($this->_cache->canUse('config')) { + return $this->_cache->load(self::CACHE_ID); + } + return false; + } + + protected function _saveCache($xml) + { + if ($this->_cache->canUse('config')) { + $this->_cache->save($xml, self::CACHE_ID, array(Mage_Core_Model_Config::CACHE_TAG)); + } + return $this; + } + + /** + * Return array menu configuration files + * + * @return array + */ + public function getMenuConfigurationFiles() + { + $files = $this->_appConfig + ->getModuleConfigurationFiles('adminhtml' . DIRECTORY_SEPARATOR . 'menu.xml'); + return (array) $files; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Config/Menu.php b/app/code/core/Mage/Backend/Model/Menu/Config/Menu.php new file mode 100644 index 0000000000000..5d38d46701bcc --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Config/Menu.php @@ -0,0 +1,115 @@ +'; + } + + /** + * Variables are identified by module and name + * + * @return array + */ + protected function _getIdAttributes() + { + return array(); + } + + /** + * Get merged configuration + * @return DOMDocument + */ + public function getMergedConfig() + { + return $this->_getDomConfigModel()->getDom(); + } + + /** + * Get Dom configuration model + * @return Mage_Backend_Model_Menu_Config_Menu_Dom + */ + protected function _getDomConfigModel() + { + if (is_null($this->_domConfig)) { + $this->_domConfig = new Mage_Backend_Model_Menu_Config_Menu_Dom( + $this->_getInitialXml(), + $this->_getIdAttributes() + ); + } + return $this->_domConfig; + } + + /** + * Perform xml validation + * @return Magento_Config_XmlAbstract + * @throws Magento_Exception if invalid XML-file passed + */ + public function validate() + { + return $this->_performValidate(); + } + + /** + * Get if xml files must be runtime validated + * @return boolean + */ + protected function _isRuntimeValidated() + { + return false; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Config/Menu/Dom.php b/app/code/core/Mage/Backend/Model/Menu/Config/Menu/Dom.php new file mode 100644 index 0000000000000..200cb2924c09f --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Config/Menu/Dom.php @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + Action designed for adding new item to existing items as a child + + + + + + + + + + + + + + + + + + + Action designed for updating existing menu items attributes + + + + + + + + + + + + + + + + + + + Action designed for removing existing menu item with its children + + + + + + + + + + + + + + Attribute id is unique under add actions + + + + + + + + + + + + + + Item id attribute can has only [a-z0-9/_]. Minimal length 3 symbol. Case insensitive. + + + + + + + + + + + Item action attribute can has only [a-zA-Z0-9/_]. Minimal length 3 symbol + + + + + + + + + + + Item title attribute minimal length 3 symbol + + + + + + + + + + + + Item module attribute can has only [a-z0-9_]. Minimal length 3 symbol. Case insensitive. + + + + + + + + + + + Item resource attribute can has only [a-z0-9_]. Minimal length 3 symbol. Case insensitive. + + + + + + + + + + + Item resource attribute can has only [a-z0-9_]. Minimal length 3 symbol. Case insensitive. + + + + + + + diff --git a/app/code/core/Mage/Backend/Model/Menu/Director/Dom.php b/app/code/core/Mage/Backend/Model/Menu/Director/Dom.php new file mode 100644 index 0000000000000..ba42ba13d3dee --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Director/Dom.php @@ -0,0 +1,153 @@ +_configModel instanceof DOMDocument)) { + throw new InvalidArgumentException('Configuration storage model is not instance of DOMDocument'); + } + + if (isset($data['logger'])) { + $this->_logger = $data['logger']; + } else { + throw new InvalidArgumentException("Logger model is required parameter"); + } + + if (false == ($this->_logger instanceof Mage_Backend_Model_Menu_Logger)) { + throw new InvalidArgumentException('Logger model is not an instance of Mage_Core_Model_Log'); + } + + $this->_extractData(); + } + + /** + * Extract data from DOMDocument + * @return Mage_Backend_Model_Menu_Director_Dom + */ + protected function _extractData() + { + $attributeNamesList = array( + 'id', + 'title', + 'toolTip', + 'module', + 'sortOrder', + 'action', + 'parent', + 'resource', + 'dependsOnModule', + 'dependsOnConfig', + ); + $xpath = new DOMXPath($this->_configModel); + $nodeList = $xpath->query('/config/menu/*'); + for ($i = 0; $i < $nodeList->length; $i++) { + $item = array(); + $node = $nodeList->item($i); + $item['type'] = $node->nodeName; + foreach ($attributeNamesList as $name) { + if ($node->hasAttribute($name)) { + $item[$name] = $node->getAttribute($name); + } + } + $this->_extractedData[] = $item; + } + } + + /** + * Get data that were extracted from config storage + * @return array + */ + public function getExtractedData() + { + return $this->_extractedData; + } + + /** + * Get command object + * @param array $data command params + * @return Mage_Backend_Model_Menu_Builder_CommandAbstract + */ + protected function _getCommand($data) + { + switch ($data['type']) { + case 'update': + $command = $this->_factory->getModelInstance( + 'Mage_Backend_Model_Menu_Builder_Command_Update', + $data + ); + $this->_logger->log(sprintf('Update on item with id %s was processed', $command->getId())); + break; + + case 'remove': + $command = $this->_factory->getModelInstance( + 'Mage_Backend_Model_Menu_Builder_Command_Remove', + $data + ); + $this->_logger->log(sprintf('Remove on item with id %s was processed', $command->getId())); + break; + + default: + $command = $this->_factory->getModelInstance( + 'Mage_Backend_Model_Menu_Builder_Command_Add', + $data + ); + break; + } + return $command; + } + + /** + * + * @param Mage_Backend_Model_Menu_Builder $builder + * @throws InvalidArgumentException if invalid builder object + * @return Mage_Backend_Model_Menu_DirectorAbstract + */ + public function buildMenu(Mage_Backend_Model_Menu_Builder $builder) + { + foreach ($this->getExtractedData() as $data) { + $command = $this->_getCommand($data); + $builder->processCommand($command); + } + return $this; + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/DirectorAbstract.php b/app/code/core/Mage/Backend/Model/Menu/DirectorAbstract.php new file mode 100644 index 0000000000000..ee252525e331a --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/DirectorAbstract.php @@ -0,0 +1,66 @@ +_configModel = $data['config']; + } else { + throw new InvalidArgumentException('Configuration storage model is required parameter'); + } + + if (isset($data['factory'])) {//} && $data['factory'] instanceof Mage_Core_Model_Config) { + $this->_factory = $data['factory']; + } else { + throw new InvalidArgumentException('Configuration factory model is required parameter'); + } + } + + /** + * Apply menu commands to builder object + * @abstract + * @param Mage_Backend_Model_Menu_Builder $builder + * @return Mage_Backend_Model_Menu_DirectorAbstract + */ + abstract public function buildMenu(Mage_Backend_Model_Menu_Builder $builder); +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Factory.php b/app/code/core/Mage/Backend/Model/Menu/Factory.php new file mode 100644 index 0000000000000..efbab6de6cebe --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Factory.php @@ -0,0 +1,39 @@ + Mage::getSingleton('Mage_Backend_Model_Menu_Logger')), $arguments); + return Mage::getModel('Mage_Backend_Model_Menu', $arguments); + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Filter/Iterator.php b/app/code/core/Mage/Backend/Model/Menu/Filter/Iterator.php new file mode 100644 index 0000000000000..ba7d33a879cf1 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Filter/Iterator.php @@ -0,0 +1,41 @@ +current()->isDisabled() || !($this->current()->isAllowed())); + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Item.php b/app/code/core/Mage/Backend/Model/Menu/Item.php new file mode 100644 index 0000000000000..edadaedca971e --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Item.php @@ -0,0 +1,479 @@ +_validator = $data['validator']; + $this->_validator->validate($data); + + $this->_acl = $data['acl']; + $this->_appConfig = $data['appConfig']; + $this->_storeConfig = $data['storeConfig']; + $this->_menuFactory = $data['menuFactory']; + $this->_urlModel = $data['urlModel']; + + $this->_id = $data['id']; + $this->_title = $data['title']; + $this->_moduleHelper = $data['module']; + $this->_action = isset($data['action']) ? $data['action'] : null; + $this->_resource = isset($data['resource']) ? $data['resource'] : null; + $this->_dependsOnModule = isset($data['dependsOnModule']) ? $data['dependsOnModule'] : null; + $this->_dependsOnConfig = isset($data['dependsOnConfig']) ? $data['dependsOnConfig'] : null; + $this->_tooltip = isset($data['toolTip']) ? $data['toolTip'] : ''; + } + + /** + * Retrieve item id + * + * @return string + */ + public function getId() + { + return $this->_id; + } + + /** + * Check whether item has subnodes + * + * @return bool + */ + public function hasChildren() + { + return !is_null($this->_submenu) && (bool) $this->_submenu->count(); + } + + /** + * Retrieve submenu + * + * @return Mage_Backend_Model_Menu + */ + public function getChildren() + { + if (!$this->_submenu) { + $this->_submenu = $this->_menuFactory + ->getMenuInstance( + array('path' => $this->getFullPath()) + ); + } + return $this->_submenu; + } + + /** + * Retrieve full path from root element + * + * @return string + */ + public function getFullPath() + { + /* + * TODO: Remove id manipulation after acl is transfered to ids + */ + $id = $this->_id; + $start = strrpos($this->_id, ':'); + if ($start) { + if ($this->_path) { + $path = str_replace('/', '_', $this->_path); + $start = strpos($this->_id, $path) + strlen($path); + } else { + if ($start) { + $start++; + } + } + $id = substr($this->_id, $start); + } + return $this->_path . $id; + } + + /** + * Retrieve menu item url + * + * @return string + */ + public function getUrl() + { + if ((bool) $this->_action) { + return $this->_urlModel->getUrl((string)$this->_action, array('_cache_secret_key' => true)); + } + return '#'; + } + + /** + * Retrieve menu item action + * + * @return string + */ + public function getAction() + { + return $this->_action; + } + + /** + * Set Item action + * + * @param string $action + * @return Mage_Backend_Model_Menu_Item + * @throws InvalidArgumentException + */ + public function setAction($action) + { + $this->_validator->validateParam('action', $action); + $this->_action = $action; + return $this; + } + + /** + * Chechk whether item has javascript callback on click + * + * @return bool + */ + public function hasClickCallback() + { + return $this->getUrl() == '#'; + } + + /** + * Retrieve item click callback + * + * @return bool + */ + public function getClickCallback() + { + if ($this->getUrl() == '#') { + return 'return false;'; + } + return ''; + } + + /** + * Retrieve tooltip text title + * + * @return string + */ + public function getTitle() + { + return $this->_title; + } + + /** + * Set Item title + * + * @param string $title + * @return Mage_Backend_Model_Menu_Item + * @throws InvalidArgumentException + */ + public function setTitle($title) + { + $this->_validator->validateParam('title', $title); + $this->_title = $title; + return $this; + } + + /** + * Check whether item has tooltip text + * + * @return bool + */ + public function hasTooltip() + { + return (bool) $this->_tooltip; + } + + /** + * Retrieve item tooltip text + * + * @return string + */ + public function getTooltip() + { + return $this->_tooltip; + } + + /** + * Set Item tooltip + * + * @param string $tooltip + * @return Mage_Backend_Model_Menu_Item + * @throws InvalidArgumentException + */ + public function setTooltip($tooltip) + { + $this->_validator->validateParam('toolTip', $tooltip); + $this->_tooltip = $tooltip; + return $this; + } + + /** + * Retrieve module helper object linked to item. + * Should be used to translate item labels + * + * @return Mage_Core_Helper_Abstract + */ + public function getModuleHelper() + { + return $this->_moduleHelper; + } + + /** + * Set Item module + * + * @param Mage_Core_Helper_Abstract $helper + * @return Mage_Backend_Model_Menu_Item + * @throws InvalidArgumentException + */ + public function setModuleHelper(Mage_Core_Helper_Abstract $helper) + { + $this->_validator->validateParam('module', $helper); + $this->_moduleHelper = $helper; + return $this; + } + + /** + * Set Item module dependency + * + * @param string $moduleName + * @return Mage_Backend_Model_Menu_Item + * @throws InvalidArgumentException + */ + public function setModuleDependency($moduleName) + { + $this->_validator->validateParam('dependsOnModule', $moduleName); + $this->_dependsOnModule = $moduleName; + return $this; + } + + /** + * Set Item config dependency + * + * @param string $configPath + * @return Mage_Backend_Model_Menu_Item + * @throws InvalidArgumentException + */ + public function setConfigDependency($configPath) + { + $this->_validator->validateParam('depenedsOnConfig', $configPath); + $this->_dependsOnConfig = $configPath; + return $this; + } + + /** + * Check whether item is disabled. Disabled items are not shown to user + * + * @return bool + */ + public function isDisabled() + { + return !$this->_moduleHelper->isModuleOutputEnabled() + || !$this->_isModuleDependenciesAvailable() + || !$this->_isConfigDependenciesAvailable(); + } + + /** + * Check whether module that item depends on is active + * + * @return bool + */ + protected function _isModuleDependenciesAvailable() + { + if ($this->_dependsOnModule) { + $module = $this->_dependsOnModule; + $modulesConfig = $this->_appConfig->getNode('modules'); + return ($modulesConfig->$module && $modulesConfig->$module->is('active')); + } + return true; + } + + /** + * Check whether config dependency is available + * + * @return bool + */ + protected function _isConfigDependenciesAvailable() + { + if ($this->_dependsOnConfig) { + return $this->_storeConfig->getConfigFlag((string)$this->_dependsOnConfig); + } + return true; + } + + /** + * Check whether item is allowed to the user + * + * @return bool + */ + public function isAllowed() + { + try { + $aclResource = 'admin/' . ($this->_resource ? (string)$this->_resource : $this->getFullPath()); + return $this->_acl->isAllowed($aclResource); + } catch (Exception $e) { + return false; + } + } + + /** + * Set path in structure + * + * @param string $path + */ + public function setPath($path) + { + $this->_path = $path; + if ($this->_submenu) { + $this->_submenu->setPath($this->getFullPath()); + } + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Item/Factory.php b/app/code/core/Mage/Backend/Model/Menu/Item/Factory.php new file mode 100644 index 0000000000000..57b8a15273053 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Item/Factory.php @@ -0,0 +1,150 @@ +_acl = isset($data['acl']) ? $data['acl'] : Mage::getSingleton('Mage_Backend_Model_Auth_Session'); + if (!($this->_acl instanceof Mage_Backend_Model_Auth_Session)) { + throw new InvalidArgumentException('Wrong acl object provided'); + } + + $this->_objectFactory = isset($data['objectFactory']) ? $data['objectFactory'] : Mage::getConfig(); + if (!($this->_objectFactory instanceof Mage_Core_Model_Config)) { + throw new InvalidArgumentException('Wrong object factory provided'); + } + + $this->_menuFactory = isset($data['menuFactory']) + ? $data['menuFactory'] + : Mage::getModel('Mage_Backend_Model_Menu_Factory'); + if (!($this->_menuFactory instanceof Mage_Backend_Model_Menu_Factory)) { + throw new InvalidArgumentException('Wrong menu factory provided'); + } + + $this->_appConfig = isset($data['appConfig']) ? $data['appConfig']: Mage::getConfig(); + if (!($this->_appConfig instanceof Mage_Core_Model_Config)) { + throw new InvalidArgumentException('Wrong application config provided'); + } + + $this->_storeConfig = isset($data['storeConfig']) + ? $data['storeConfig'] + : Mage::getSingleton('Mage_Core_Model_Store_Config'); + if (!($this->_storeConfig instanceof Mage_Core_Model_Store_Config)) { + throw new InvalidArgumentException('Wrong store config provided'); + } + + $this->_urlModel = isset($data['urlModel']) ? $data['urlModel'] : Mage::getSingleton('Mage_Backend_Model_Url'); + if (!($this->_urlModel instanceof Mage_Backend_Model_Url)) { + throw new InvalidArgumentException('Wrong url model provided'); + } + + $this->_validator = isset($data['validator']) + ? $data['validator'] + : Mage::getSingleton('Mage_Backend_Model_Menu_Item_Validator'); + if (!($this->_validator instanceof Mage_Backend_Model_Menu_Item_Validator)) { + throw new InvalidArgumentException('Wrong item validator model provided'); + } + + if (isset($data['helpers'])) { + $this->_helpers = $data['helpers']; + } + } + + /** + * Create menu item from array + * + * @param array $data + * @return Mage_Backend_Model_Menu_Item + */ + public function createFromArray(array $data = array()) + { + $module = 'Mage_Backend_Helper_Data'; + if (isset($data['module'])) { + $module = $data['module']; + } + + $data['module'] = isset($this->_helpers[$module]) ? $this->_helpers[$module] : Mage::helper($module); + $data['acl'] = $this->_acl; + $data['appConfig'] = $this->_appConfig; + $data['storeConfig'] = $this->_storeConfig; + $data['menuFactory'] = $this->_menuFactory; + $data['urlModel'] = $this->_urlModel; + $data['validator'] = $this->_validator; + return $this->_objectFactory->getModelInstance('Mage_Backend_Model_Menu_Item', $data); + } +} diff --git a/app/code/core/Mage/Backend/Model/Menu/Item/Validator.php b/app/code/core/Mage/Backend/Model/Menu/Item/Validator.php new file mode 100644 index 0000000000000..605d75e8efca2 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Item/Validator.php @@ -0,0 +1,147 @@ + 'Mage_Backend_Model_Auth_Session', + 'appConfig' => 'Mage_Core_Model_Config', + 'menuFactory' => 'Mage_Backend_Model_Menu_Factory', + 'urlModel' => 'Mage_Backend_Model_Url', + 'storeConfig' => 'Mage_Core_Model_Store_Config', + 'module' => 'Mage_Core_Helper_Abstract' + ); + + /** + * List of created item ids + * + * @var array + */ + protected $_ids = array(); + + /** + * The list of primitive validators + * + * @var Zend_Validate[] + */ + protected $_validators = array(); + + public function __construct() + { + $idValidator = new Zend_Validate(); + $idValidator->addValidator(new Zend_Validate_StringLength(array('min' => 3))); + $idValidator->addValidator(new Zend_Validate_Regex('/^[A-Za-z0-9\/:_]+$/')); + + $attributeValidator = new Zend_Validate(); + $attributeValidator->addValidator(new Zend_Validate_StringLength(array('min' => 3))); + $attributeValidator->addValidator(new Zend_Validate_Regex('/^[A-Za-z0-9\/_]+$/')); + + $textValidator = new Zend_Validate_StringLength(array('min' => 3, 'max' => 50)); + + $titleValidator = $tooltipValidator = $textValidator; + $actionValidator = $resourceValidator = $resourceValidator = $moduleDependencyValidator + = $configDependencyValidator = $attributeValidator; + + $this->_validators['id'] = $idValidator; + $this->_validators['title'] = $titleValidator; + $this->_validators['action'] = $actionValidator; + $this->_validators['resource'] = $resourceValidator; + $this->_validators['dependsOnModule'] = $moduleDependencyValidator; + $this->_validators['dependsOnConfig'] = $configDependencyValidator; + $this->_validators['toolTip'] = $tooltipValidator; + } + /** + * Validate menu item params + * + * @param $data + * @throws InvalidArgumentException + * @throws BadMethodCallException + */ + public function validate($data) + { + foreach ($this->_required as $param) { + if (!isset($data[$param])) { + throw new BadMethodCallException('Missing required param ' . $param); + } + } + + if (array_search($data['id'], $this->_ids) !== false) { + throw new InvalidArgumentException('Item with id ' . $data ['id'] . ' already exists'); + } + + foreach ($data as $param => $value) { + if (isset($this->_requiredTypes[$param]) && !($data[$param] instanceof $this->_requiredTypes[$param])) { + throw new InvalidArgumentException( + 'Wrong param ' . $param . ': Expected ' . $this->_requiredTypes[$param] . ', received ' + . get_class($data[$param]) + ); + } elseif (!is_null($data[$param]) + && isset($this->_validators[$param]) + && !$this->_validators[$param]->isValid($value) + ) { + throw new InvalidArgumentException( + "Param " . $param . " doesn't pass validation: " + . implode('; ', $this->_validators[$param]->getMessages()) + ); + } + } + $this->_ids[] = $data['id']; + } + + /** + * Validate incoming param + * + * @param string $param + * @param mixed $value + * @throws InvalidArgumentException + */ + public function validateParam($param, $value) + { + if (in_array($param, $this->_required) && is_null($value)) { + throw new InvalidArgumentException('Param ' . $param . ' is required'); + } + + if (!is_null($value) && isset($this->_validators[$param]) && !$this->_validators[$param]->isValid($value)) { + throw new InvalidArgumentException( + 'Param ' . $param . ' doesn\'t pass validation: ' + . implode('; ', $this->_validators[$param]->getMessages()) + ); + } + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php b/app/code/core/Mage/Backend/Model/Menu/Iterator.php similarity index 77% rename from app/code/core/Mage/Adminhtml/Block/Page/Menu.php rename to app/code/core/Mage/Backend/Model/Menu/Iterator.php index 0683372009590..82a57f5d4b43d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php +++ b/app/code/core/Mage/Backend/Model/Menu/Iterator.php @@ -19,20 +19,22 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Adminhtml + * @package Mage_Backend * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * Adminhtml menu block - * - * @category Mage - * @package Mage_Adminhtml - * @author Magento Core Team - * @deprecated Moved to module Mage_Backend + * Menu iterator */ -class Mage_Adminhtml_Block_Page_Menu extends Mage_Backend_Block_Menu +class Mage_Backend_Model_Menu_Iterator extends ArrayIterator { - + /** + * Rewind to first element + */ + public function rewind() + { + $this->ksort(); + parent::rewind(); + } } diff --git a/app/code/core/Mage/Backend/Model/Menu/Logger.php b/app/code/core/Mage/Backend/Model/Menu/Logger.php new file mode 100644 index 0000000000000..c4cedbbc5cbcc --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Menu/Logger.php @@ -0,0 +1,62 @@ + + */ +class Mage_Backend_Model_Menu_Logger extends Mage_Core_Model_Logger +{ + const MENU_DEBUG_FILE = 'menu-debug.log'; + + /** + * Log wrapper + * + * @param string $message + * @param int $level + * @param string $file + * @param bool $forceLog + * @return void + */ + public function log($message, $level = null, $file = '', $forceLog = false) + { + if (empty($file)) { + $file = self::MENU_DEBUG_FILE; + } + parent::log($message, $level, $file, $forceLog); + } + + /** + * Log exception wrapper + * + * @param Exception $e + */ + public function logException(Exception $e) + { + $this->log("\n" . $e->__toString(), Zend_Log::ERR); + } +} diff --git a/app/code/core/Mage/Backend/Model/Url.php b/app/code/core/Mage/Backend/Model/Url.php index 3ea1cd02eba8f..a79426ca003f1 100644 --- a/app/code/core/Mage/Backend/Model/Url.php +++ b/app/code/core/Mage/Backend/Model/Url.php @@ -33,7 +33,7 @@ class Mage_Backend_Model_Url extends Mage_Core_Model_Url /** * xpath to startup page in configuration */ - const XML_PATH_STARTUP_PAGE = 'admin/startup/page'; + const XML_PATH_STARTUP_MENU_ITEM = 'admin/startup/menu_item_id'; /** * Authentication session @@ -43,26 +43,24 @@ class Mage_Backend_Model_Url extends Mage_Core_Model_Url protected $_session; /** - * @var Mage_Admin_Model_Config + * @var Mage_Backend_Model_Menu */ - protected $_adminConfig; + protected $_menu; /** * Startup page url from config * @var string */ - protected $_startupPageUrl; + protected $_startupMenuItemId; public function __construct(array $data = array()) { parent::__construct($data); - $this->_adminConfig = isset($data['adminConfig']) ? - $data['adminConfig'] : - Mage::getSingleton('Mage_Admin_Model_Config'); + $this->_startupMenuItemId = isset($data['startupMenuItemId']) ? + $data['startupMenuItemId'] : + Mage::getStoreConfig(self::XML_PATH_STARTUP_MENU_ITEM); - $this->_startupPageUrl = isset($data['startupPageUrl']) ? - $data['startupPageUrl'] : - Mage::getStoreConfig(self::XML_PATH_STARTUP_PAGE); + $this->_menu = isset($data['menu']) ? $data['menu'] : null; } @@ -212,12 +210,11 @@ public function renewSecretUrls() */ public function getStartupPageUrl() { - $aclResource = 'admin/' . $this->_startupPageUrl; + $aclResource = 'admin/' . $this->_startupMenuItemId; if ($this->_getSession()->isAllowed($aclResource)) { - $nodePath = 'menu/' . join('/children/', explode('/', $this->_startupPageUrl)) . '/action'; - $url = $this->_adminConfig->getAdminhtmlConfig()->getNode($nodePath); - if ($url) { - return $url; + $menuItem = $this->_getMenu()->get($this->_startupMenuItemId); + if ($menuItem && $menuItem->getAction()) { + return $menuItem->getAction(); } } return $this->findFirstAvailableMenu(); @@ -226,35 +223,37 @@ public function getStartupPageUrl() /** * Find first menu item that user is able to access * - * @param Mage_Core_Model_Config_Element $parent - * @param string $path - * @param integer $level * @return string */ - public function findFirstAvailableMenu($parent = null, $path = '', $level = 0) + public function findFirstAvailableMenu() { - if ($parent == null) { - $parent = $this->_adminConfig->getAdminhtmlConfig()->getNode('menu'); - } - foreach ($parent->children() as $childName => $child) { - $aclResource = 'admin/' . $path . $childName; - if ($this->_getSession()->isAllowed($aclResource)) { - if (!$child->children) { - return (string)$child->action; - } else if ($child->children) { - $action = $this->findFirstAvailableMenu($child->children, $path . $childName . '/', $level + 1); - return $action ? $action : (string)$child->action; - } + /* @var $menu Mage_Backend_Model_Menu_Item */ + $menu = $this->_getMenu(); + $item = $menu->getFirstAvailable(); + $action = $item ? $item->getAction() : null; + if (!$item) { + $user = $this->_getSession()->getUser(); + if ($user) { + $user->setHasAvailableResources(false); } + $action = '*/*/denied'; } - $user = $this->_getSession()->getUser(); - if ($user) { - $user->setHasAvailableResources(false); - } - return '*/*/denied'; - } + return $action; + } + /** + * Get Menu model + * + * @return Mage_Backend_Model_Menu + */ + protected function _getMenu() + { + if (is_null($this->_menu)) { + $this->_menu = Mage::getSingleton('Mage_Backend_Model_Menu_Config')->getMenu(); + } + return $this->_menu; + } /** * Set custom auth session diff --git a/app/code/core/Mage/Backend/etc/config.xml b/app/code/core/Mage/Backend/etc/config.xml index d412b7ed01c70..18e03544134ee 100644 --- a/app/code/core/Mage/Backend/etc/config.xml +++ b/app/code/core/Mage/Backend/etc/config.xml @@ -46,6 +46,13 @@ + + + + System(config.xml, local.xml) and modules configuration files(config.xml, menu.xml). + + + diff --git a/app/code/core/Mage/Backend/view/adminhtml/layout.xml b/app/code/core/Mage/Backend/view/adminhtml/layout.xml index 32165c2527bc9..d06896a6ca19f 100644 --- a/app/code/core/Mage/Backend/view/adminhtml/layout.xml +++ b/app/code/core/Mage/Backend/view/adminhtml/layout.xml @@ -26,6 +26,17 @@ */ --> + + + + + + menu_container_renderer + menu_item_renderer + + + + diff --git a/app/code/core/Mage/Backend/view/adminhtml/menu.phtml b/app/code/core/Mage/Backend/view/adminhtml/menu.phtml index 93bafd3c362b2..c3ff88c590386 100644 --- a/app/code/core/Mage/Backend/view/adminhtml/menu.phtml +++ b/app/code/core/Mage/Backend/view/adminhtml/menu.phtml @@ -26,11 +26,7 @@ ?> diff --git a/app/code/core/Mage/Backend/view/adminhtml/menu/container.phtml b/app/code/core/Mage/Backend/view/adminhtml/menu/container.phtml new file mode 100644 index 0000000000000..6947fadefabc0 --- /dev/null +++ b/app/code/core/Mage/Backend/view/adminhtml/menu/container.phtml @@ -0,0 +1,32 @@ + + +
    getLevel() ? 'id="nav"' : '') ?>> + getMenuIterator() as $menuItem) : ?> + renderMenuItem($menuItem); ?> + +
diff --git a/app/code/core/Mage/Backend/view/adminhtml/menu/item.phtml b/app/code/core/Mage/Backend/view/adminhtml/menu/item.phtml new file mode 100644 index 0000000000000..1c7c463090bc0 --- /dev/null +++ b/app/code/core/Mage/Backend/view/adminhtml/menu/item.phtml @@ -0,0 +1,37 @@ + + +
  • getMenuItem()->hasChildren() ? 'onmouseover="Element.addClassName(this,\'over\')" onmouseout="Element.removeClassName(this,\'over\')"' : ''); ?> + class="isItemActive($this->getMenuItem()) ? 'active' : '') . ' ' . ($this->getMenuItem()->hasChildren() ? 'parent' : '') . ' ' . ($this->isLast() ? 'last' : '') . ' ' . ('level' . $this->getLevel()); ?>"> + getMenuItem()->hasTooltip() ? 'title="' . $this->getMenuItem()->getModuleHelper()->__($this->getMenuItem()->getTooltip()) . '"' : '') . ($this->getMenuItem()->hasClickCallback() ? ' onclick="' . $this->getMenuItem()->getClickCallback() . '"' : ''); ?> class="isItemActive($this->getMenuItem()) ? 'active' : ''); ?>"> + escapeHtml($this->getMenuItem()->getModuleHelper()->__($this->getMenuItem()->getTitle())); ?> + + getMenuItem()->hasChildren()) : ?> + getContainerRenderer()->renderMenuContainer($this->getMenuItem()->getChildren(), $this->getLevel() + 1); ?> + +
  • + diff --git a/app/code/core/Mage/Backup/etc/adminhtml.xml b/app/code/core/Mage/Backup/etc/adminhtml.xml index a8c2bccf7fadd..6f5360658999d 100644 --- a/app/code/core/Mage/Backup/etc/adminhtml.xml +++ b/app/code/core/Mage/Backup/etc/adminhtml.xml @@ -26,20 +26,6 @@ */ --> - - - - - - - Backups - adminhtml/system_backup - - - - - - diff --git a/app/code/core/Mage/Backup/etc/adminhtml/menu.xml b/app/code/core/Mage/Backup/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..940e89ea1e1dd --- /dev/null +++ b/app/code/core/Mage/Backup/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Bundle/view/frontend/layout.xml b/app/code/core/Mage/Bundle/view/frontend/layout.xml index f20d6d5a921b0..757a2ac2b78cc 100644 --- a/app/code/core/Mage/Bundle/view/frontend/layout.xml +++ b/app/code/core/Mage/Bundle/view/frontend/layout.xml @@ -90,7 +90,7 @@ Adding custom product price block Partof block for simple products --> - + bundleMage_Bundle_Block_Catalog_Product_Price bundle4 @@ -120,6 +120,22 @@ Shopping cart item renderer + + + + + + + + + + + + + + + + diff --git a/app/code/core/Mage/Captcha/Helper/Data.php b/app/code/core/Mage/Captcha/Helper/Data.php index bb6dbee4f2c50..a44f380aa0cc1 100755 --- a/app/code/core/Mage/Captcha/Helper/Data.php +++ b/app/code/core/Mage/Captcha/Helper/Data.php @@ -59,6 +59,118 @@ class Mage_Captcha_Helper_Data extends Mage_Core_Helper_Abstract */ protected $_captcha = array(); + /** + * @var Mage_Core_Model_Config_Options + */ + protected $_option; + + /** + * @var Mage_Core_Model_Store + */ + protected $_store; + + /** + * @var Mage_Core_Model_Config + */ + protected $_config; + + /** + * @var Mage_Core_Model_Website + */ + protected $_website; + + /** + * Get Config + * @return Mage_Core_Model_Config + */ + public function getConfig() + { + if (empty($this->_config)) { + $this->_config = Mage::getConfig(); + } + return $this->_config; + } + + /** + * Set config + * + * @param Mage_Core_Model_Config $config + */ + public function setConfig($config) + { + $this->_config = $config; + } + + /** + * Set store + * + * @param Mage_Core_Model_Store $store + */ + public function setStore($store) + { + $this->_store = $store; + } + + /** + * Get store + * + * @param null|string|bool|int|Mage_Core_Model_Store $storeName + * @return Mage_Core_Model_Store + * @throws Mage_Core_Model_Store_Exception + */ + public function getStore($storeName = null) + { + if (empty($this->_store)) { + $this->_store = Mage::app()->getStore($storeName); + } + return $this->_store; + } + + /** + * Set option + * + * @param Mage_Core_Model_Config_Options $option + */ + public function setOption($option) + { + $this->_option = $option; + } + + /** + * Get option + * + * @return Mage_Core_Model_Config_Options + */ + public function getOption() + { + if (empty($this->_option)) { + $this->_option = $this->getConfig()->getOptions(); + } + return $this->_option; + } + + /** + * Set website + * @param Mage_Core_Model_Website $website + */ + public function setWebsite($website) + { + $this->_website = $website; + } + + /** + * Get website + * @param string $websiteCode + * @return Mage_Core_Model_Website + */ + public function getWebsite($websiteCode) + { + if (empty($this->_website)) { + $this->_website = Mage::app()->getWebsite($websiteCode); + } + return $this->_website; + } + /** * Get Captcha * @@ -69,7 +181,10 @@ public function getCaptcha($formId) { if (!array_key_exists($formId, $this->_captcha)) { $type = ucfirst($this->getConfigNode('type')); - $this->_captcha[$formId] = Mage::getModel('Mage_Captcha_Model_' . $type, array('formId' => $formId)); + $this->_captcha[$formId] = $this->getConfig()->getModelInstance( + 'Mage_Captcha_Model_' . $type, + array('formId' => $formId, 'helper' => $this) + ); } return $this->_captcha[$formId]; } @@ -83,10 +198,12 @@ public function getCaptcha($formId) */ public function getConfigNode($id, $store = null) { - $areaCode = Mage::app()->getStore($store)->isAdmin() ? 'admin' : 'customer'; - return Mage::getStoreConfig( $areaCode . '/captcha/' . $id, $store); + $areaCode = $this->getStore($store)->isAdmin() ? 'admin' : 'customer'; + return $this->getStore($store)->getConfig( $areaCode . '/captcha/' . $id, $store); } + + /** * Get list of available fonts * Return format: @@ -96,13 +213,13 @@ public function getConfigNode($id, $store = null) */ public function getFonts() { - $node = Mage::getConfig()->getNode(Mage_Captcha_Helper_Data::XML_PATH_CAPTCHA_FONTS); + $node = $this->getConfig()->getNode(Mage_Captcha_Helper_Data::XML_PATH_CAPTCHA_FONTS); $fonts = array(); if ($node) { foreach ($node->children() as $fontName => $fontNode) { $fonts[$fontName] = array( 'label' => (string)$fontNode->label, - 'path' => Mage::getBaseDir('base') . DS . $fontNode->path + 'path' => $this->getOption()->getDir('base') . DIRECTORY_SEPARATOR . $fontNode->path ); } } @@ -117,8 +234,8 @@ public function getFonts() */ public function getImgDir($website = null) { - $websiteCode = Mage::app()->getWebsite($website)->getCode(); - $captchaDir = Mage::getBaseDir('media') . DS . 'captcha' . DS . $websiteCode . DS; + $captchaDir = $this->getOption()->getDir('media') . DIRECTORY_SEPARATOR . 'captcha' . DIRECTORY_SEPARATOR + . $this->getWebsite($website)->getCode() . DIRECTORY_SEPARATOR; $io = new Varien_Io_File(); $io->checkAndCreateFolder($captchaDir, 0755); return $captchaDir; @@ -132,7 +249,6 @@ public function getImgDir($website = null) */ public function getImgUrl($website = null) { - $websiteCode = Mage::app()->getWebsite($website)->getCode(); - return Mage::getBaseUrl('media') . 'captcha' . '/' . $websiteCode . '/'; + return $this->getStore()->getBaseUrl('media') . 'captcha' . '/' . $this->getWebsite($website)->getCode() . '/'; } } diff --git a/app/code/core/Mage/Captcha/Model/Zend.php b/app/code/core/Mage/Captcha/Model/Zend.php index 0ad8c42d2182d..b39431114a7b3 100755 --- a/app/code/core/Mage/Captcha/Model/Zend.php +++ b/app/code/core/Mage/Captcha/Model/Zend.php @@ -73,6 +73,17 @@ class Mage_Captcha_Model_Zend extends Zend_Captcha_Image implements Mage_Captcha */ protected $_formId; + + /** + * @var Mage_Captcha_Model_Resource_Log + */ + protected $_resourceModel; + + /** + * @var + */ + protected $_session; + /** * Zend captcha constructor * @@ -80,11 +91,14 @@ class Mage_Captcha_Model_Zend extends Zend_Captcha_Image implements Mage_Captcha */ public function __construct($params) { - if (!isset($params['formId'])) { + if (!is_array($params) || !isset($params['formId'])) { throw new Exception('formId is mandatory'); } + $this->_formId = $params['formId']; - $this->setExpiration($this->getTimeout()); + $this->_helper = isset($params['helper']) ? $params['helper'] : null; + $this->_resourceModel = isset($params['resourceModel']) ? $params['resourceModel'] : null; + $this->_session = isset($params['session']) ? $params['session'] : null; } /** @@ -164,7 +178,7 @@ protected function _getAllowedAttemptsFromSameIp() */ protected function _isOverLimitIpAttempt() { - $countAttemptsByIp = Mage::getResourceModel('Mage_Captcha_Model_Resource_Log')->countAttemptsByRemoteAddress(); + $countAttemptsByIp = $this->_getResourceModel()->countAttemptsByRemoteAddress(); return $countAttemptsByIp >= $this->_getAllowedAttemptsFromSameIp(); } @@ -177,7 +191,7 @@ protected function _isOverLimitIpAttempt() protected function _isOverLimitLoginAttempts($login) { if ($login != false) { - $countAttemptsByLogin = Mage::getResourceModel('Mage_Captcha_Model_Resource_Log')->countAttemptsByUserLogin($login); + $countAttemptsByLogin = $this->_getResourceModel()->countAttemptsByUserLogin($login); return ($countAttemptsByLogin >= $this->_getAllowedAttemptsForSameLogin()); } return false; @@ -190,9 +204,7 @@ protected function _isOverLimitLoginAttempts($login) */ protected function _isUserAuth() { - return Mage::app()->getStore()->isAdmin() - ? Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isLoggedIn() - : Mage::getSingleton('Mage_Customer_Model_Session')->isLoggedIn(); + return $this->getSession()->isLoggedIn(); } /** @@ -212,7 +224,17 @@ public function isCaseSensitive() */ public function getFont() { - return $this->_getFontPath(); + $font = (string)$this->_getHelper()->getConfigNode('font'); + $fonts = $this->_getHelper()->getFonts(); + + if (isset($fonts[$font])) { + $fontPath = $fonts[$font]['path']; + } else { + $fontData = array_shift($fonts); + $fontPath = $fontData['path']; + } + + return $fontPath; } /** @@ -220,7 +242,7 @@ public function getFont() * * @return int */ - public function getTimeout() + public function getExpiration() { if (!$this->_expiration) { /** @@ -232,6 +254,16 @@ public function getTimeout() return $this->_expiration; } + /** + * Get timeout for session token + * + * @return int + */ + public function getTimeout() + { + return $this->getExpiration(); + } + /** * Get captcha image directory * @@ -239,7 +271,7 @@ public function getTimeout() */ public function getImgDir() { - return $this->_helper->getImgDir(); + return $this->_getHelper()->getImgDir(); } /** @@ -249,7 +281,7 @@ public function getImgDir() */ public function getImgUrl() { - return $this->_helper->getImgUrl(); + return $this->_getHelper()->getImgUrl(); } /** @@ -271,17 +303,22 @@ public function isCorrect($word) $storedWord = strtolower($storedWord); $word = strtolower($word); } - return $word == $storedWord; + return $word === $storedWord; } /** * Returns session instance * - * @return Mage_Customer_Model_Session + * @return Mage_Customer_Model_Session|Mage_Backend_Model_Auth_Session */ public function getSession() { - return Mage::getSingleton('Mage_Customer_Model_Session'); + if (empty($this->_session)) { + $this->_session = Mage::app()->getStore()->isAdmin() + ? Mage::getSingleton('Mage_Backend_Model_Auth_Session') + : Mage::getSingleton('Mage_Customer_Model_Session'); + } + return $this->_session; } /** @@ -303,7 +340,7 @@ public function getImgSrc() public function logAttempt($login) { if ($this->_isEnabled() && in_array($this->_formId, $this->_getTargetForms())) { - Mage::getResourceModel('Mage_Captcha_Model_Resource_Log')->logAttempt($login); + $this->_getResourceModel()->logAttempt($login); if ($this->_isOverLimitLoginAttempts($login)) { $this->getSession()->setData($this->_getFormIdKey('show_captcha'), 1); } @@ -311,26 +348,6 @@ public function logAttempt($login) return $this; } - /** - * Returns path for the font file, chosen to generate captcha - * - * @return string - */ - protected function _getFontPath() - { - $font = (string)$this->_getHelper()->getConfigNode('font'); - $fonts = $this->_getHelper()->getFonts(); - - if (isset($fonts[$font])) { - $fontPath = $fonts[$font]['path']; - } else { - $fontData = array_shift($fonts); - $fontPath = $fontData['path']; - } - - return $fontPath; - } - /** * Returns captcha helper * @@ -409,6 +426,12 @@ protected function _isShowAlways() return true; } + if ((string)$this->_getHelper()->getConfigNode('mode') == Mage_Captcha_Helper_Data::MODE_AFTER_FAIL + && $this->_getAllowedAttemptsForSameLogin() == 0 + ) { + return true; + } + $alwaysFor = $this->_getHelper()->getConfigNode('always_for'); foreach ($alwaysFor as $nodeFormId => $isAlwaysFor) { if ($isAlwaysFor && $this->_formId == $nodeFormId) { @@ -501,4 +524,16 @@ protected function _gc() { //do nothing } + + /** + * Get Resource Model + * @return Mage_Captcha_Model_Resource_Log + */ + protected function _getResourceModel() + { + if (empty($this->_resourceModel)) { + $this->_resourceModel = Mage::getResourceModel('Mage_Captcha_Model_Resource_Log'); + } + return $this->_resourceModel; + } } diff --git a/app/code/core/Mage/Captcha/view/frontend/layout.xml b/app/code/core/Mage/Captcha/view/frontend/layout.xml index a3a1d146576dd..a78ea9ed014aa 100644 --- a/app/code/core/Mage/Captcha/view/frontend/layout.xml +++ b/app/code/core/Mage/Captcha/view/frontend/layout.xml @@ -70,7 +70,7 @@ - + mage/captcha.js @@ -86,6 +86,7 @@ mage/captcha.js + Mage_Captcha::onepage.js guest_checkout 230 @@ -94,6 +95,7 @@ mage/captcha.js + Mage_Captcha::onepage.js register_during_checkout 230 diff --git a/app/code/core/Mage/Captcha/view/frontend/onepage.js b/app/code/core/Mage/Captcha/view/frontend/onepage.js new file mode 100644 index 0000000000000..f0e337ed57e6b --- /dev/null +++ b/app/code/core/Mage/Captcha/view/frontend/onepage.js @@ -0,0 +1,58 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category design + * @package base_default + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +document.observe('billing-request:completed', function(event) { + if (typeof window.checkout != 'undefined') { + if (window.checkout.method == 'guest' && $('guest_checkout')){ + $('guest_checkout').captcha.refresh() + } + if (window.checkout.method == 'register' && $('register_during_checkout')){ + $('register_during_checkout').captcha.refresh() + } + } +}); + + +document.observe('login:setMethod', function(event) { + var switchCaptchaElement = function(shown, hidden) { + var inputPrefix = 'captcha-input-box-', imagePrefix = 'captcha-image-box-'; + if ($(inputPrefix + hidden)) { + $(inputPrefix + hidden).hide(); + $(imagePrefix + hidden).hide(); + } + if ($(inputPrefix + shown)) { + $(inputPrefix + shown).show(); + $(imagePrefix + shown).show(); + } + }; + + switch (event.memo.method) { + case 'guest': + switchCaptchaElement('guest_checkout', 'register_during_checkout'); + break; + case 'register': + switchCaptchaElement('register_during_checkout', 'guest_checkout'); + break; + } +}); diff --git a/app/code/core/Mage/Captcha/view/frontend/zend.phtml b/app/code/core/Mage/Captcha/view/frontend/zend.phtml index 00110e6253a37..2eb9620dd6290 100644 --- a/app/code/core/Mage/Captcha/view/frontend/zend.phtml +++ b/app/code/core/Mage/Captcha/view/frontend/zend.phtml @@ -34,8 +34,8 @@ -
  • -
    +
  • +
    <?php echo $this->__('Reload captcha') ?> isCaseSensitive()) :?> diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php index 776d5b752045f..fde80299b6ba2 100755 --- a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php @@ -470,12 +470,25 @@ public function rebuild($stores = null) $stores = array($stores); } + $this->_createTables($stores); + $this->_populateFlatTables($stores); + + return $this; + } + + /** + * Populate category flat tables with data + * + * @param array $stores + * @return Mage_Catalog_Model_Resource_Category_Flat + */ + protected function _populateFlatTables($stores) + { $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID; $categories = array(); $categoriesIds = array(); /* @var $store Mage_Core_Model_Store */ foreach ($stores as $store) { - $this->_createTable($store->getId()); if (!isset($categories[$store->getRootCategoryId()])) { $select = $this->_getWriteAdapter()->select() @@ -528,20 +541,25 @@ protected function _prepareValuesToInsert($data) } /** - * Create Flate Table(s) + * Create category flat table for specified store. + * Table is created only if DDL operations are allowed * - * @param array|int $stores + * @param int $store * @return Mage_Catalog_Model_Resource_Category_Flat */ - public function createTable($stores) + public function createTable($store) { - return $this->_createTable($stores); + if ($this->_getWriteAdapter()->getTransactionLevel() > 0) { + return $this; + } + return $this->_createTable($store); } /** - * Creating table and adding attributes as fields to table + * Create table and add attributes as fields for specified store. + * This routine assumes that DDL operations are allowed * - * @param array|integer $store + * @param int $store * @return Mage_Catalog_Model_Resource_Category_Flat */ protected function _createTable($store) @@ -1409,13 +1427,21 @@ public function getStoresRootCategories($storeIds = null) } /** - * Creating table and adding attributes as fields to table for all stores + * Create category flat tables and add attributes as fields. + * Tables are created only if DDL operations are allowed * + * @param array $stores if empty, create tables for all stores of the application * @return Mage_Catalog_Model_Resource_Category_Flat */ - protected function _createTables() + protected function _createTables($stores = array()) { - foreach (Mage::app()->getStores() as $store) { + if ($this->_getWriteAdapter()->getTransactionLevel() > 0) { + return $this; + } + if (empty($stores)) { + $stores = Mage::app()->getStores(); + } + foreach ($stores as $store) { $this->_createTable($store->getId()); } return $this; diff --git a/app/code/core/Mage/Catalog/etc/adminhtml.xml b/app/code/core/Mage/Catalog/etc/adminhtml.xml index 5986aa3a0348f..8c62c0c41ff83 100644 --- a/app/code/core/Mage/Catalog/etc/adminhtml.xml +++ b/app/code/core/Mage/Catalog/etc/adminhtml.xml @@ -26,47 +26,6 @@ */ --> - - - Catalog - 30 - - - Mage_Catalog - - - - Manage Products - adminhtml/catalog_product/ - 0 - - - Manage Categories - adminhtml/catalog_category/ - 10 - - - Attributes - - - Manage Attributes - adminhtml/catalog_product_attribute/ - - - Manage Attribute Sets - adminhtml/catalog_product_set/ - - - 20 - - - URL Rewrite Management - adminhtml/urlrewrite/index - 30 - - - - diff --git a/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml b/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..6d49646a8953f --- /dev/null +++ b/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + diff --git a/app/code/core/Mage/CatalogRule/etc/adminhtml.xml b/app/code/core/Mage/CatalogRule/etc/adminhtml.xml index 94b8a61f86665..6d0738acb89ad 100644 --- a/app/code/core/Mage/CatalogRule/etc/adminhtml.xml +++ b/app/code/core/Mage/CatalogRule/etc/adminhtml.xml @@ -26,19 +26,6 @@ */ --> - - - Promotions - 50 - - - Catalog Price Rules - adminhtml/promo_catalog/ - Mage_Catalog - - - - diff --git a/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml b/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..4373d055e6406 --- /dev/null +++ b/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml @@ -0,0 +1,33 @@ + + + + + + + + diff --git a/app/code/core/Mage/CatalogSearch/etc/adminhtml.xml b/app/code/core/Mage/CatalogSearch/etc/adminhtml.xml index e35d35a25a851..579d150d9c709 100644 --- a/app/code/core/Mage/CatalogSearch/etc/adminhtml.xml +++ b/app/code/core/Mage/CatalogSearch/etc/adminhtml.xml @@ -26,17 +26,6 @@ */ --> - - - - - Search Terms - adminhtml/catalog_search/ - 40 - - - - diff --git a/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml b/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..7c8241008ce4a --- /dev/null +++ b/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Checkout/etc/adminhtml.xml b/app/code/core/Mage/Checkout/etc/adminhtml.xml index 78e1cd654b4da..1c93d6959546c 100644 --- a/app/code/core/Mage/Checkout/etc/adminhtml.xml +++ b/app/code/core/Mage/Checkout/etc/adminhtml.xml @@ -26,17 +26,6 @@ */ --> - - - - - 100 - Terms and conditions - adminhtml/checkout_agreement/ - - - - diff --git a/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml b/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..4a1abe1c98f02 --- /dev/null +++ b/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Checkout/view/frontend/layout.xml b/app/code/core/Mage/Checkout/view/frontend/layout.xml index d305505866b4f..a59790d00d956 100644 --- a/app/code/core/Mage/Checkout/view/frontend/layout.xml +++ b/app/code/core/Mage/Checkout/view/frontend/layout.xml @@ -103,23 +103,11 @@ Default layout, loads most of the pages - - - - - - - - - - - - - - - CMS - 70 - - - Pages - adminhtml/cms_page - 0 - - - Static Blocks - adminhtml/cms_block - 10 - - - - diff --git a/app/code/core/Mage/Cms/etc/adminhtml/menu.xml b/app/code/core/Mage/Cms/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..e3c332a385872 --- /dev/null +++ b/app/code/core/Mage/Cms/etc/adminhtml/menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php b/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php index de1b09d1037a6..bf0451f87bc59 100644 --- a/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php +++ b/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php @@ -58,7 +58,7 @@ public function editAction() ->_title($this->__('Edit Extension')); $this->loadLayout(); - $this->_setActiveMenu('system/extension/custom'); + $this->_setActiveMenu('Mage_Connect::system_extensions_custom'); $this->renderLayout(); } diff --git a/app/code/core/Mage/Connect/etc/adminhtml.xml b/app/code/core/Mage/Connect/etc/adminhtml.xml index c969d6f53c6ad..393c6a8062bc2 100644 --- a/app/code/core/Mage/Connect/etc/adminhtml.xml +++ b/app/code/core/Mage/Connect/etc/adminhtml.xml @@ -26,24 +26,4 @@ */ --> - - - - - Magento Connect - 80 - - - Magento Connect Manager - adminhtml/extension_local - - - Package Extensions - adminhtml/extension_custom - - - - - - diff --git a/app/code/core/Mage/Connect/etc/adminhtml/menu.xml b/app/code/core/Mage/Connect/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..e470289d19cbd --- /dev/null +++ b/app/code/core/Mage/Connect/etc/adminhtml/menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/core/Mage/Connect/view/adminhtml/layout.xml b/app/code/core/Mage/Connect/view/adminhtml/layout.xml index 298618bf5ede2..979838fbdd2fc 100644 --- a/app/code/core/Mage/Connect/view/adminhtml/layout.xml +++ b/app/code/core/Mage/Connect/view/adminhtml/layout.xml @@ -56,7 +56,7 @@ - + @@ -65,9 +65,8 @@ - + - diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php index b8142be8cd9eb..2fa391e118af2 100644 --- a/app/code/core/Mage/Core/Block/Abstract.php +++ b/app/code/core/Mage/Core/Block/Abstract.php @@ -614,6 +614,19 @@ protected function _toHtml() return ''; } + /** + * Retrieve data-ui-id attribute which will distinguish link/input/container/anything else in template among others + * Function takes an arbitrary amount of parameters + * + * @return string + */ + public function getUiId() + { + $rawId = $this->_nameInLayout . '-' . implode('-', func_get_args()); + $normalizedId = trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($rawId)), '-'); + return ' data-ui-id="' . $normalizedId . '" '; + } + /** * Returns url model class name * diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Abstract.php b/app/code/core/Mage/Core/Controller/Varien/Router/Abstract.php index 3d305c09f93cb..234873f6ffb9c 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Router/Abstract.php +++ b/app/code/core/Mage/Core/Controller/Varien/Router/Abstract.php @@ -24,16 +24,33 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +/** + * Abstract router class + */ abstract class Mage_Core_Controller_Varien_Router_Abstract { + /** + * @var Mage_Core_Controller_Varien_Front + */ protected $_front; - public function setFront($front) + /** + * Assign front controller instance + * + * @param $front Mage_Core_Controller_Varien_Front + * @return Mage_Core_Controller_Varien_Router_Abstract + */ + public function setFront(Mage_Core_Controller_Varien_Front $front) { $this->_front = $front; return $this; } + /** + * Retrieve front controller instance + * + * @return Mage_Core_Controller_Varien_Front + */ public function getFront() { return $this->_front; diff --git a/app/code/core/Mage/Core/Model/App.php b/app/code/core/Mage/Core/Model/App.php index 5dba29a1ed08f..7783bd92af773 100644 --- a/app/code/core/Mage/Core/Model/App.php +++ b/app/code/core/Mage/Core/Model/App.php @@ -805,7 +805,7 @@ public function loadAreaPart($area, $part) public function getArea($code) { if (!isset($this->_areas[$code])) { - $this->_areas[$code] = new Mage_Core_Model_App_Area($code, $this); + $this->_areas[$code] = new Mage_Core_Model_App_Area($code); } return $this->_areas[$code]; } diff --git a/app/code/core/Mage/Core/Model/App/Area.php b/app/code/core/Mage/Core/Model/App/Area.php index 71439e6fcc956..09c68ac703bc9 100644 --- a/app/code/core/Mage/Core/Model/App/Area.php +++ b/app/code/core/Mage/Core/Model/App/Area.php @@ -56,26 +56,13 @@ class Mage_Core_Model_App_Area protected $_code; /** - * Area application + * Constructor * - * @var Mage_Core_Model_App + * @param string $areaCode */ - protected $_application; - - public function __construct($areaCode, $application) + public function __construct($areaCode) { $this->_code = $areaCode; - $this->_application = $application; - } - - /** - * Retrieve area application - * - * @return Mage_Core_Model_App - */ - public function getApplication() - { - return $this->_application; } /** diff --git a/app/code/core/Mage/Core/Model/Event/Manager.php b/app/code/core/Mage/Core/Model/Event/Manager.php new file mode 100644 index 0000000000000..9d509bae00f82 --- /dev/null +++ b/app/code/core/Mage/Core/Model/Event/Manager.php @@ -0,0 +1,43 @@ +_renderingOutput = new Varien_Object; } + /** + * Cleanup circular references between layout & blocks + * + * Destructor should be called explicitly in order to work around the PHP bug + * https://bugs.php.net/bug.php?id=62468 + */ + public function __destruct() + { + $this->_blocks = array(); + } + /** * Retrieve the layout update instance * diff --git a/app/code/core/Mage/Core/Model/Logger.php b/app/code/core/Mage/Core/Model/Logger.php new file mode 100644 index 0000000000000..152791760b619 --- /dev/null +++ b/app/code/core/Mage/Core/Model/Logger.php @@ -0,0 +1,58 @@ + + */ +class Mage_Core_Model_Logger +{ + /** + * Log wrapper + * + * @param string $message + * @param int $level + * @param string $file + * @param bool $forceLog + * @return void + */ + public function log($message, $level = null, $file = '', $forceLog = false) + { + Mage::log($message, $level, $file, $forceLog); + } + + /** + * Log exception wrapper + * + * @param Exception $e + * @return void + */ + public function logException(Exception $e) + { + Mage::logException($e); + } +} diff --git a/app/code/core/Mage/Core/Model/Store/Config.php b/app/code/core/Mage/Core/Model/Store/Config.php new file mode 100644 index 0000000000000..964c7f281aadd --- /dev/null +++ b/app/code/core/Mage/Core/Model/Store/Config.php @@ -0,0 +1,50 @@ + - dashboard + dashboard 0 diff --git a/app/code/core/Mage/Core/etc/system.xml b/app/code/core/Mage/Core/etc/system.xml index 15e869cf54426..e23646333fde2 100644 --- a/app/code/core/Mage/Core/etc/system.xml +++ b/app/code/core/Mage/Core/etc/system.xml @@ -955,7 +955,7 @@ 0 0 - + select Mage_Adminhtml_Model_System_Config_Source_Admin_Page @@ -963,7 +963,7 @@ 1 0 0 - + diff --git a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php b/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php index 81ba0dff773d3..a1e9e974aad56 100644 --- a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php +++ b/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php @@ -40,7 +40,7 @@ public function indexAction() { // set active menu and breadcrumbs $this->loadLayout() - ->_setActiveMenu('system/currency') + ->_setActiveMenu('Mage_Adminhtml::system_currency') ->_addBreadcrumb( Mage::helper('Mage_CurrencySymbol_Helper_Data')->__('System'), Mage::helper('Mage_CurrencySymbol_Helper_Data')->__('System') diff --git a/app/code/core/Mage/CurrencySymbol/etc/adminhtml.xml b/app/code/core/Mage/CurrencySymbol/etc/adminhtml.xml index 2c98705e055e7..6563150b5776f 100644 --- a/app/code/core/Mage/CurrencySymbol/etc/adminhtml.xml +++ b/app/code/core/Mage/CurrencySymbol/etc/adminhtml.xml @@ -26,28 +26,6 @@ */ --> - - - - - Manage Currency - - - Rates - adminhtml/system_currency - 50 - - - Symbols - adminhtml/system_currencysymbol - 100 - - - 50 - - - - diff --git a/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml b/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..ab42b57f7b0e5 --- /dev/null +++ b/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/core/Mage/Customer/Block/Account/Navigation.php b/app/code/core/Mage/Customer/Block/Account/Navigation.php index 2a5e403a31ee3..e6d342df4ed49 100644 --- a/app/code/core/Mage/Customer/Block/Account/Navigation.php +++ b/app/code/core/Mage/Customer/Block/Account/Navigation.php @@ -50,6 +50,18 @@ public function addLink($name, $path, $label, $urlParams=array()) return $this; } + /** + * Removes a link from the navigation + * + * @param string $name + * @return Mage_Customer_Block_Account_Navigation + */ + public function removeLink($name) + { + unset($this->_links[$name]); + return $this; + } + public function setActive($path) { $this->_activeLink = $this->_completePath($path); diff --git a/app/code/core/Mage/Customer/etc/adminhtml.xml b/app/code/core/Mage/Customer/etc/adminhtml.xml index f028fb122d06e..e665b98ccdc7a 100644 --- a/app/code/core/Mage/Customer/etc/adminhtml.xml +++ b/app/code/core/Mage/Customer/etc/adminhtml.xml @@ -26,30 +26,6 @@ */ --> - - - Customers - 40 - - - - Manage Customers - adminhtml/customer/ - 0 - - - Customer Groups - adminhtml/customer_group/ - 10 - - - Online Customers - adminhtml/customer_online/ - 100 - - - - diff --git a/app/code/core/Mage/Customer/etc/adminhtml/menu.xml b/app/code/core/Mage/Customer/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..eb32bb0456eb6 --- /dev/null +++ b/app/code/core/Mage/Customer/etc/adminhtml/menu.xml @@ -0,0 +1,35 @@ + + + + + + + + + + diff --git a/app/code/core/Mage/Customer/view/frontend/widget/name.phtml b/app/code/core/Mage/Customer/view/frontend/widget/name.phtml index 440903405a00c..f95b75f4d4419 100644 --- a/app/code/core/Mage/Customer/view/frontend/widget/name.phtml +++ b/app/code/core/Mage/Customer/view/frontend/widget/name.phtml @@ -64,7 +64,7 @@ For checkout/onepage/shipping.phtml:
    - getFieldParams() ?> /> + getFieldParams() ?> />
    showMiddlename()): ?> @@ -79,7 +79,7 @@ For checkout/onepage/shipping.phtml:
    - getFieldParams() ?> /> + getFieldParams() ?> />
    showSuffix()): ?> diff --git a/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php b/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php index 5be3c40936a9e..30da890e3afbf 100644 --- a/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php +++ b/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php @@ -36,7 +36,7 @@ public function indexAction() { $this->_title($this->__('System'))->_title($this->__('Design'))->_title($this->__('Editor')); $this->loadLayout(); - $this->_setActiveMenu('system/design/editor'); + $this->_setActiveMenu('Mage_DesignEditor::system_design_editor'); $this->renderLayout(); } diff --git a/app/code/core/Mage/DesignEditor/etc/adminhtml.xml b/app/code/core/Mage/DesignEditor/etc/adminhtml.xml index e563d313fe0c5..23b9c5bbe2d11 100644 --- a/app/code/core/Mage/DesignEditor/etc/adminhtml.xml +++ b/app/code/core/Mage/DesignEditor/etc/adminhtml.xml @@ -26,21 +26,6 @@ */ --> - - - - - - - Editor - adminhtml/system_design_editor - 20 - - - - - - diff --git a/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml b/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..8a46113f28a6f --- /dev/null +++ b/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/DesignEditor/view/frontend/js/base.js b/app/code/core/Mage/DesignEditor/view/frontend/js/base.js index 020f8f70a9ab1..1931a09386241 100644 --- a/app/code/core/Mage/DesignEditor/view/frontend/js/base.js +++ b/app/code/core/Mage/DesignEditor/view/frontend/js/base.js @@ -1,4 +1,4 @@ -/** +/** * Magento * * NOTICE OF LICENSE @@ -15,168 +15,138 @@ * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_DesignEditor - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -( function ( $ ) { - - /** - * Widget tree - */ - $.widget( "Mage.tree" , { - options:{ - ui: { - select_limit: 1, - selected_parent_close: false - }, - themes: { - dots: false, - icons: false - }, - callback: { - onselect: function( e, data ) { - var leaf = $( data.rslt.obj ), - cellElement = $( this ).parents( '.vde_toolbar_cell' ); - if ( cellElement.hasClass( 'active' ) ){ - cellElement.removeClass( 'active' ); - $( this ).trigger( 'changetitle.menu', [ $.trim( leaf.find( 'a:first' ).text() ) ] ); - window.location = leaf.find( 'a:first' ).attr( 'href' ); - } - } - } - }, - _create: function() { - var self = this; - this.element.on( 'loaded.jstree' , function ( e, data ) { - self.element.data( 'selected' ) ? - self.element.jstree( 'select_node' , self.element.find( self.element.data( 'selected' ) ) ): - $.noop(); - }); - this.element.jstree( this.options ); - this.element.on( 'select_node.jstree', this.options.callback.onselect ); - } - }); - - /** - * Widget sScroll - */ - $.widget( "Mage.sScroll", { - options:{ - color: '#cccccc', - alwaysVisible: true, - opacity: 1, - height: 'auto', - size: 9 - }, - _create: function() { - this.element.slimScroll( this.options ); - } - }); - - /** - * Widget menu - */ - $.widget( "Mage.menu", { - options:{ - type: 'popup', - titleSelector: ':first-child', - titleTextSelector : '.vde_toolbar_cell_value', - activeClass : 'active', - activeEventName: 'activate_toolbar_cell.vde' - }, - _create: function() { - this._bind(); - }, - _bind: function(){ - var self = this; - this.element - .on( 'hide.menu', function( e ){self.hide( e )} ) - .on( 'changetitle.menu', function( e, title ) { - self.element.find( self.options.titleTextSelector ).text( title ); - }) - .find( this.options.titleSelector ).first() - .on( 'click.menu', function( e ){ - self.element.hasClass( self.options.activeClass ) ? - self.hide( e ): - self.show( e ); - }) - $( 'body' ).on( 'click', function( e ) { - $( ':'+self.namespace+'-'+self.widgetName ).not( $( e.target ) - .parents( ':'+self.namespace+'-'+self.widgetName ).first()).menu( 'hide' ); - }) - }, - show: function( e ){ - this.element.addClass( this.options.activeClass ).trigger( this.options.activeEventName ); - }, - hide:function( e ){ - this.element.removeClass( this.options.activeClass ); - } - }); - - /** - * Widget menu - tree view - */ - var menuBasePrototype = $.Mage.menu.prototype; - $.widget( "Mage.menu", $.extend({}, menuBasePrototype, { - _create: function() { - menuBasePrototype._create.apply(this, arguments); - if ( this.options.treeSelector ) { - this.element.find( this.options.treeSelector ).size() ? - this.element.find( this.options.treeSelector ).tree() : - $.noop(); - } - } - })); - - /** - * Widget menu - slimScroll view - */ - var menuTreePrototype = $.Mage.menu.prototype; - $.widget( "Mage.menu", $.extend({}, menuTreePrototype, { - _create: function() { - var self = this; - menuTreePrototype._create.apply(this, arguments); - if(this.options.slimScroll) { - this.options.treeSelector && this.element.find( this.options.treeSelector ).size() ? - this.element - .one( 'activate_toolbar_cell.vde', function () { - self.element.find( ':Mage-tree' ).sScroll(); - }) : - $.noop(); - } - } - })); - - /** - * Widget checkbox - */ - $.widget( "Mage.checkbox", { - options:{ - checkedClass : 'checked' - }, - _create: function() { - this._bind(); - }, - _bind: function(){ - var self = this; - this.element.on( 'click', function(){ - self._click(); - }) - }, - _click: function(){ - if ( this.element.hasClass( this.options.checkedClass ) ) { - this.element.removeClass( this.options.checkedClass ); - this.options.unCheckedEvent ? this.element.trigger(this.options.unCheckedEvent) : $.noop(); - } else { - this.element.addClass( this.options.checkedClass ); - this.options.checkedEvent ? this.element.trigger(this.options.checkedEvent) : $.noop(); - } - } - }); - -})( jQuery ); \ No newline at end of file + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_DesignEditor + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +(function($) { + + /** + * Widget tree + */ + $.widget('vde.vde_tree', { + options: { + ui: { + select_limit: 1, + selected_parent_close: false + }, + themes: { + dots: false, + icons: false + } + }, + _create: function () { + this._bind(); + this.element.jstree(this.options); + }, + _bind: function() { + var self = this; + this.element + .on('loaded.jstree', function (e, data) { + var selectNode = self.element.data('selected'); + if (selectNode) { + self.element.jstree('select_node', self.element.find(selectNode)); + } + }) + .on('select_node.jstree', function (e, data) { + var link = $(data.rslt.obj).find('a:first'); + $(this).trigger('link_selected.' + self.widgetName, [link]); + if (data.rslt.e) { // User clicked the link, not just tree initialization + window.location = link.attr('href'); + } + }); + } + }); + + /** + * Widget menu + */ + $.widget('vde.vde_menu', { + options: { + type: 'popup', + titleSelector: '.vde_toolbar_cell_title', + titleTextSelector: '.vde_toolbar_cell_value', + activeClass: 'active' + }, + _create: function () { + this._bind(); + if (this.options.treeSelector) { + var tree = this.element.find(this.options.treeSelector); + if (tree.size()) { + tree.vde_tree(); + if (this.options.slimScroll) { + var self = this; + this.element + .one('activate_toolbar_cell.' + self.widgetName, function () { + self.element.find(self.options.treeSelector).slimScroll({ + color: '#cccccc', + alwaysVisible: true, + opacity: 1, + height: 'auto', + size: 9 + }); + }) + } + } + } + }, + _bind: function () { + var self = this, + titleText = self.element.find(self.options.titleTextSelector); + this.element + .on('change_title.' + self.widgetName, function(e, title) { + titleText.text(title); + }) + .on('link_selected.vde_tree', function(e, link) { + titleText.text(link.text()); + }) + .find(this.options.titleSelector) + .on('click.' + self.widgetName, function(e) { + self.element.hasClass(self.options.activeClass) ? + self.hide(e): + self.show(e); + }) + $('body').on('click', function(e) { + var widgetInstancesSelector = ':' + self.namespace + '-' + self.widgetName; + $(widgetInstancesSelector).not($(e.target).parents(widgetInstancesSelector)).vde_menu('hide'); + }) + }, + show: function(e) { + this.element.addClass(this.options.activeClass).trigger('activate_toolbar_cell.' + this.widgetName); + }, + hide: function(e) { + this.element.removeClass(this.options.activeClass); + } + }); + + /** + * Widget checkbox + */ + $.widget('vde.vde_checkbox', { + options: { + checkedClass: 'checked' + }, + _create: function () { + this._bind(); + }, + _bind: function () { + var self = this; + this.element.on('click', function () { + self._click(); + }) + }, + _click: function () { + if (this.element.hasClass(this.options.checkedClass)) { + this.element.removeClass(this.options.checkedClass); + this.element.trigger('unchecked.' + this.widgetName); + } else { + this.element.addClass(this.options.checkedClass); + this.element.trigger('checked.' + this.widgetName); + } + } + }); +})(jQuery); \ No newline at end of file diff --git a/app/code/core/Mage/DesignEditor/view/frontend/js/design_editor.js b/app/code/core/Mage/DesignEditor/view/frontend/js/design_editor.js index ee5db01b53725..03ac8d4589680 100644 --- a/app/code/core/Mage/DesignEditor/view/frontend/js/design_editor.js +++ b/app/code/core/Mage/DesignEditor/view/frontend/js/design_editor.js @@ -1,4 +1,4 @@ -/** +/** * Magento * * NOTICE OF LICENSE @@ -15,188 +15,183 @@ * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_DesignEditor - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -( function ( $ ) { - - /** - * Widget block - */ - $.widget( "vde.block", { _create: function(){}} ); - - /** - * Widget container - */ - $.widget( "vde.container", $.ui.sortable, { - options : { - tolerance: 'pointer', - revert: true, - connectWithSelector : '.vde_element_wrapper.vde_container', - placeholder: 'vde_placeholder', - hoverClass: 'vde_container_hover', - items: '.vde_element_wrapper.vde_draggable', - helper: 'clone', - appendTo: 'body' - }, - _create: function() { - var self = this; - this.element.data( "sortable", this ); - self.options = $.extend( {}, self.options, { - start: function( event, ui ) { - ui.placeholder.css( { height: $( ui.helper ).outerHeight( true ) } ); - $(this).sortable('option', 'connectWith', $(self.options.connectWithSelector).not(ui.item)) - .sortable('refresh'); - }, - over: function( event, ui ) { - self.element.addClass( self.options.hoverClass ); - }, - out: function( event, ui ) { - self.element.removeClass( self.options.hoverClass ); - } - }); - $.ui.sortable.prototype._create.apply( this, arguments ); - } - }); - - /** - * Widget panel - */ - $.widget( "vde.panel" , { - options:{ - cellSelector : '.vde_toolbar_cell', - handlesHierarchySelector : '#vde_handles_hierarchy', - treeSelector : '#vde_handles_tree' - }, - _create: function() { - this._initCells(); - }, - _initCells : function(){ - var self = this; - this.element.find( this.options.cellSelector ).each( function(){ - $( this ).is( self.options.handlesHierarchySelector ) ? - $( this ).menu( {treeSelector : self.options.treeSelector, slimScroll:true } ) : - $( this ).menu(); - }); - this.element.find( this.options.cellSelector ).menu(); - } - }); - - /** - * Widget page - */ - $.widget( "vde.page", { - options:{ - containerSelector : '.vde_element_wrapper.vde_container', - panelSelector : '#vde_toolbar', - highlightElementSelector : '.vde_element_wrapper', - highlightElementTitleSelector : '.vde_element_title', - highlightCheckboxSelector : '#vde_highlighting', - cookieHighlightingName : 'vde_highlighting' - }, - _create: function() { - this._initContainers(); - this._initPanel(); - }, - _initContainers : function(){ - $( this.options.containerSelector ) - .container().disableSelection(); - }, - _initPanel : function(){ - $( this.options.panelSelector ).panel(); - } - }); - - /** - * Widget page highlight functionality - */ - var pageBasePrototype = $.vde.page.prototype; - $.widget( "vde.page", $.extend({}, pageBasePrototype, { - _create: function() { - pageBasePrototype._create.apply( this, arguments ); - if( this.options.highlightElementSelector ) { - this._initHighlighting(); - this._bind(); - } - }, - _bind: function(){ - var self = this; - this.element - .on( 'highlightelements.vde', function(){ self._highlight(); }) - .on( 'unhighlightelements.vde', function(){ self._unhighlight(); }); - }, - _initHighlighting: function(){ - this.options.highlightCheckboxSelector ? - $( this.options.highlightCheckboxSelector ) - .checkbox({checkedEvent:'highlightelements.vde', unCheckedEvent:'unhighlightelements.vde'}) : - $.noop(); - this.highlightBlocks = {}; - if (Mage.Cookies.get(this.options.cookieHighlightingName) == 'off') { - this._processMarkers(); - } - - }, - _highlight: function(){ - var self = this; - Mage.Cookies.clear( this.options.cookieHighlightingName ); - $( this.options.highlightElementSelector ).each(function () { - $( this ) - .append( self._getChildren( $( this ).attr( 'id' ) ) ) - .show() - .children( self.options.highlightElementTitleSelector ).slideDown( 'fast' ); - }); - this.highlightBlocks = {}; - }, - _unhighlight: function(){ - var self = this; - Mage.Cookies.set( this.options.cookieHighlightingName, "off" ); - $( this.options.highlightElementSelector ).each( function () { - var elem = $( this ); - elem.children( self.options.highlightElementTitleSelector ).slideUp( 'fast', function () { - var children = elem.contents( ':not('+self.options.highlightElementTitleSelector+')' ); - var parentId = elem.attr( 'id' ); - children.each( function(){ - self._storeChild( parentId, this ); - }); - elem.after( children ).hide(); - }); - }); - }, - _processMarkers : function () { - var self = this, - parentsIdsStack = [], - currentParentId; - $('*').contents().each(function(){ - if ( this.nodeType == Node.COMMENT_NODE ) { - if ( this.data.substr(0, 9) == 'start_vde' ) { - currentParentId = this.data.substr( 6, this.data.length ); - parentsIdsStack.push( currentParentId ); - this.parentNode.removeChild( this ); - } else if ( this.data.substr( 0, 7 ) == 'end_vde' ) { - if ( this.data.substr( 4, this.data.length ) !== currentParentId ) { - throw "Could not find closing element for opened '" + currentParentId + "' element"; - } - parentsIdsStack.pop(); - currentParentId = parentsIdsStack[ parentsIdsStack.length - 1 ]; - this.parentNode.removeChild( this ); - } - } else if ( currentParentId ) { - self._storeChild( currentParentId, this ); - } - }) - }, - _storeChild : function ( parentId, child ) { - ( !this.highlightBlocks[ parentId ] ) ? this.highlightBlocks[ parentId ] = [] : $.noop(); - this.highlightBlocks[ parentId ].push( child ); - }, - _getChildren : function ( parentId ) { - return ( !this.highlightBlocks[parentId] ) ? [] : this.highlightBlocks[ parentId ]; - } - })); - -})( jQuery ); + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_DesignEditor + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +(function($) { + + /** + * Widget container + */ + $.widget('vde.vde_container', $.ui.sortable, { + options: { + tolerance: 'pointer', + revert: true, + connectWithSelector: '.vde_element_wrapper.vde_container', + placeholder: 'vde_placeholder', + hoverClass: 'vde_container_hover', + items: '.vde_element_wrapper.vde_draggable', + helper: 'clone', + appendTo: 'body' + }, + _create: function () { + this.element.data('sortable', this); + var self = this; + this.options = $.extend({}, this.options, { + start: function(event, ui) { + ui.placeholder.css({height: $(ui.helper).outerHeight(true)}); + $(this).sortable('option', 'connectWith', $(self.options.connectWithSelector).not(ui.item)) + .sortable('refresh'); + }, + over: function(event, ui) { + self.element.addClass(self.options.hoverClass); + }, + out: function(event, ui) { + self.element.removeClass(self.options.hoverClass); + } + }); + $.ui.sortable.prototype._create.apply(this, arguments); + } + }); + + /** + * Widget panel + */ + $.widget('vde.vde_panel', { + options: { + cellSelector: '.vde_toolbar_cell', + handlesHierarchySelector: '#vde_handles_hierarchy', + treeSelector: '#vde_handles_tree' + }, + _create: function () { + var self = this; + this.element.find(this.options.cellSelector).each(function () { + var params = $(this).is(self.options.handlesHierarchySelector) ? {treeSelector: self.options.treeSelector, slimScroll: true } : {}; + $(this).vde_menu(params); + }); + } + }); + + /** + * Widget page + */ + $.widget('vde.vde_page', { + options: { + containerSelector: '.vde_element_wrapper.vde_container', + panelSelector: '#vde_toolbar', + highlightElementSelector: '.vde_element_wrapper', + highlightElementTitleSelector: '.vde_element_title', + highlightCheckboxSelector: '#vde_highlighting', + cookieHighlightingName: 'vde_highlighting' + }, + _create: function () { + this._initContainers(); + this._initPanel(); + }, + _initContainers: function () { + $(this.options.containerSelector) + .vde_container().disableSelection(); + }, + _initPanel: function () { + $(this.options.panelSelector).vde_panel(); + } + }); + + /** + * Widget page highlight functionality + */ + var pageBasePrototype = $.vde.vde_page.prototype; + $.widget('vde.vde_page', $.extend({}, pageBasePrototype, { + _create: function () { + pageBasePrototype._create.apply(this, arguments); + if (this.options.highlightElementSelector) { + this._initHighlighting(); + this._bind(); + } + }, + _bind: function () { + var self = this; + this.element + .on('checked.vde_checkbox', function () { + self._highlight(); + }) + .on('unchecked.vde_checkbox', function () { + self._unhighlight(); + }); + }, + _initHighlighting: function () { + if (this.options.highlightCheckboxSelector) { + $(this.options.highlightCheckboxSelector) + .vde_checkbox(); + } + this.highlightBlocks = {}; + if (Mage.Cookies.get(this.options.cookieHighlightingName) == 'off') { + this._processMarkers(); + } + + }, + _highlight: function () { + Mage.Cookies.clear(this.options.cookieHighlightingName); + var self = this; + $(this.options.highlightElementSelector).each(function () { + $(this) + .append(self._getChildren($(this).attr('id'))) + .show() + .children(self.options.highlightElementTitleSelector).slideDown('fast'); + }); + this.highlightBlocks = {}; + }, + _unhighlight: function () { + Mage.Cookies.set(this.options.cookieHighlightingName, 'off'); + var self = this; + $(this.options.highlightElementSelector).each(function () { + var elem = $(this); + elem.children(self.options.highlightElementTitleSelector).slideUp('fast', function () { + var children = elem.contents(':not(' + self.options.highlightElementTitleSelector + ')'); + var parentId = elem.attr('id'); + children.each(function () { + self._storeChild(parentId, this); + }); + elem.after(children).hide(); + }); + }); + }, + _processMarkers: function () { + var self = this, + parentsIdsStack = [], + currentParentId; + $('*').contents().each(function () { + if (this.nodeType == Node.COMMENT_NODE) { + if (this.data.substr(0, 9) == 'start_vde') { + currentParentId = this.data.substr(6, this.data.length); + parentsIdsStack.push(currentParentId); + this.parentNode.removeChild(this); + } else if (this.data.substr(0, 7) == 'end_vde') { + if (this.data.substr(4, this.data.length) !== currentParentId) { + throw "Could not find closing element for opened '" + currentParentId + "' element"; + } + parentsIdsStack.pop(); + currentParentId = parentsIdsStack[parentsIdsStack.length - 1]; + this.parentNode.removeChild(this); + } + } else if (currentParentId) { + self._storeChild(currentParentId, this); + } + }) + }, + _storeChild: function(parentId, child) { + if (!this.highlightBlocks[parentId]) { + this.highlightBlocks[parentId] = []; + } + this.highlightBlocks[parentId].push(child); + }, + _getChildren: function(parentId) { + return (!this.highlightBlocks[parentId]) ? [] : this.highlightBlocks[parentId]; + } + })); +})( jQuery ); diff --git a/app/code/core/Mage/DesignEditor/view/frontend/js/settimeout_override.js b/app/code/core/Mage/DesignEditor/view/frontend/js/settimeout_override.js new file mode 100644 index 0000000000000..721f635abfb4f --- /dev/null +++ b/app/code/core/Mage/DesignEditor/view/frontend/js/settimeout_override.js @@ -0,0 +1,77 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_DesignEditor + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +(function() { + + var bindBeforeUnload = function() { + window.onbeforeunload = function(e) { + var e = e || window.event; + var messageText = 'Automatic redirect has been triggered.'; + // For IE and Firefox + if (e) { + e.returnValue = messageText; + } + // For Chrome and Safari + return messageText; + }; + } + + var unbindBeforeUnload = function () { + window.onbeforeunload = null; + } + + window.setTimeout = (function(oldSetTimeout) { + return function(func, delay) { + return oldSetTimeout(function() { + try { + bindBeforeUnload(); + func(); + unbindBeforeUnload(); + } + catch (exception) { + unbindBeforeUnload(); + throw exception; + } + }, delay); + }; + })(window.setTimeout); + + window.setInterval = (function(oldSetInterval) { + return function(func, delay) { + return oldSetInterval(function() { + try { + bindBeforeUnload(); + func(); + unbindBeforeUnload(); + } + catch (exception) { + unbindBeforeUnload(); + throw exception; + } + }, delay); + }; + })(window.setInterval); + +})(); diff --git a/app/code/core/Mage/DesignEditor/view/frontend/layout.xml b/app/code/core/Mage/DesignEditor/view/frontend/layout.xml index 1ac3fa7b6cc86..38448fbd8b775 100644 --- a/app/code/core/Mage/DesignEditor/view/frontend/layout.xml +++ b/app/code/core/Mage/DesignEditor/view/frontend/layout.xml @@ -28,6 +28,7 @@ + Mage_DesignEditor::js/settimeout_override.js jquery/jquery-1.7.1.min.js mage/jquery-no-conflict.js jquery/jquery-ui-1.8.18.custom.min.js diff --git a/app/code/core/Mage/DesignEditor/view/frontend/toolbar.phtml b/app/code/core/Mage/DesignEditor/view/frontend/toolbar.phtml index 686c14c6978b8..ccdfd5089cf1b 100644 --- a/app/code/core/Mage/DesignEditor/view/frontend/toolbar.phtml +++ b/app/code/core/Mage/DesignEditor/view/frontend/toolbar.phtml @@ -1,5 +1,5 @@ - - -
    - getMessages(); ?> - -

    escapeHtml($message->getCode()) ?>

    - - getChildHtml(); ?> -
    - - + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category design + * @package Mage_DesignEditor + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> + +
    + getMessages(); ?> + +

    escapeHtml($message->getCode()) ?>

    + + getChildHtml(); ?> +
    + + diff --git a/app/code/core/Mage/Downloadable/etc/adminhtml.xml b/app/code/core/Mage/Downloadable/etc/adminhtml.xml index 3d0068bcfead3..87cc34e2acf17 100644 --- a/app/code/core/Mage/Downloadable/etc/adminhtml.xml +++ b/app/code/core/Mage/Downloadable/etc/adminhtml.xml @@ -45,18 +45,4 @@
    - - - - - - - Downloads - adminhtml/report_product/downloads - - - - - -
    diff --git a/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml b/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..88bb9ce02f3ca --- /dev/null +++ b/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/code/core/Mage/Downloadable/view/frontend/layout.xml b/app/code/core/Mage/Downloadable/view/frontend/layout.xml index 657ea17cbdcee..41ee32913efe6 100644 --- a/app/code/core/Mage/Downloadable/view/frontend/layout.xml +++ b/app/code/core/Mage/Downloadable/view/frontend/layout.xml @@ -51,6 +51,16 @@ + + + + + + + + + + downloadableMage_Downloadable_Block_Checkout_Cart_Item_Renderer diff --git a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php b/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php index 55eee8341f92e..05e93e3901ea1 100644 --- a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php +++ b/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php @@ -42,7 +42,7 @@ class Mage_GoogleShopping_Adminhtml_Googleshopping_ItemsController extends Mage_ protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('catalog/googleshopping/items') + ->_setActiveMenu('Mage_GoogleShopping::catalog_googleshopping_items') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Catalog'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Catalog')) ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Google Content'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Google Content')); return $this; diff --git a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php b/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php index eab4b06f09ed7..e194491fc4d2a 100644 --- a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php +++ b/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php @@ -73,7 +73,7 @@ protected function _initItemType() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('catalog/googleshopping/types') + ->_setActiveMenu('Mage_GoogleShopping::catalog_googleshopping_types') ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Catalog'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Catalog')) ->_addBreadcrumb(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Google Content'), Mage::helper('Mage_Adminhtml_Helper_Data')->__('Google Content')); return $this; diff --git a/app/code/core/Mage/GoogleShopping/etc/adminhtml.xml b/app/code/core/Mage/GoogleShopping/etc/adminhtml.xml index 1232cea22b275..5909846a6c2ed 100644 --- a/app/code/core/Mage/GoogleShopping/etc/adminhtml.xml +++ b/app/code/core/Mage/GoogleShopping/etc/adminhtml.xml @@ -26,26 +26,6 @@ */ --> - - - - - Google Content - - - Manage Attributes - adminhtml/googleshopping_types - - - Manage Items - adminhtml/googleshopping_items - - - 70 - - - - diff --git a/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml b/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..06f4f8ba44668 --- /dev/null +++ b/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit/Form.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit/Form.php index 6bb9a4c7adaec..0485c72a80c77 100644 --- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit/Form.php +++ b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit/Form.php @@ -75,7 +75,7 @@ protected function _prepareForm() 'label' => $helper->__('Export Format Version'), 'required' => false, 'onchange' => 'editForm.handleExportFormatVersionSelector();', - 'values' => Mage::getModel('Mage_ImportExport_Model_Source_Export_Format_Version')->toOptionArray() + 'values' => Mage::getModel('Mage_ImportExport_Model_Source_Format_Version')->toOptionArray() )); $fieldsets['customer'] = $form->addFieldset('customer_entity_fieldset', array( diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Before.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Before.php new file mode 100644 index 0000000000000..6b215c54d3fe9 --- /dev/null +++ b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Before.php @@ -0,0 +1,49 @@ + + */ +class Mage_ImportExport_Block_Adminhtml_Import_Before extends Mage_Backend_Block_Template +{ + /** + * Get JS array string of allowed customer behaviours + * + * @param string $importVersion + * @return string + */ + public function getJsAllowedCustomerBehaviours($importVersion) + { + /** @var $helper Mage_ImportExport_Helper_Data */ + $helper = Mage::helper('Mage_ImportExport_Helper_Data'); + $allowedBehaviours = $helper->getAllowedCustomerBehaviours($importVersion); + return Zend_Json::encode($allowedBehaviours); + } +} diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php index d41bfd57b49b6..25c611084c12f 100644 --- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php +++ b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit/Form.php @@ -34,7 +34,7 @@ class Mage_ImportExport_Block_Adminhtml_Import_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { /** - * Add fieldset + * Add fieldsets * * @return Mage_ImportExport_Block_Adminhtml_Import_Edit_Form */ @@ -47,22 +47,65 @@ protected function _prepareForm() 'method' => 'post', 'enctype' => 'multipart/form-data' )); - $fieldset = $form->addFieldset('base_fieldset', array('legend' => $helper->__('Import Settings'))); - $fieldset->addField('entity', 'select', array( + + // base fieldset + $fieldsets['base'] = $form->addFieldset('base_fieldset', array('legend' => $helper->__('Import Settings'))); + $fieldsets['base']->addField('entity', 'select', array( 'name' => 'entity', 'title' => $helper->__('Entity Type'), 'label' => $helper->__('Entity Type'), 'required' => true, + 'onchange' => 'editForm.handleEntityTypeSelector();', 'values' => Mage::getModel('Mage_ImportExport_Model_Source_Import_Entity')->toOptionArray() )); - $fieldset->addField('behavior', 'select', array( + $fieldsets['base']->addField('behavior', 'select', array( 'name' => 'behavior', 'title' => $helper->__('Import Behavior'), 'label' => $helper->__('Import Behavior'), 'required' => true, 'values' => Mage::getModel('Mage_ImportExport_Model_Source_Import_Behavior')->toOptionArray() )); - $fieldset->addField(Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, 'file', array( + + // fieldset for format version + $fieldsets['version'] = $form->addFieldset('import_format_version_fieldset', + array( + 'legend' => $helper->__('Import Format Version'), + 'style' => 'display:none' + ) + ); + $fieldsets['version']->addField('file_format_version', 'select', array( + 'name' => 'file_format_version', + 'title' => $helper->__('Import Format Version'), + 'label' => $helper->__('Import Format Version'), + 'required' => true, + 'onchange' => 'editForm.handleImportFormatVersionSelector();', + 'values' => Mage::getModel('Mage_ImportExport_Model_Source_Format_Version')->toOptionArray() + )); + + // fieldset for customer entity + $fieldsets['customer'] = $form->addFieldset('customer_entity_fieldset', + array( + 'legend' => $helper->__('Customer Entity Type'), + 'style' => 'display:none' + ) + ); + $fieldsets['customer']->addField('customer_entity', 'select', array( + 'name' => 'customer_entity', + 'title' => $helper->__('Customer Entity Type'), + 'label' => $helper->__('Customer Entity Type'), + 'required' => false, + 'disabled' => true, + 'values' => Mage::getModel('Mage_ImportExport_Model_Source_Import_Customer_Entity')->toOptionArray() + )); + + // fieldset for file uploading + $fieldsets['upload'] = $form->addFieldset('upload_file_fieldset', + array( + 'legend' => $helper->__('File to Import'), + 'style' => 'display:none' + ) + ); + $fieldsets['upload']->addField(Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, 'file', array( 'name' => Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, 'label' => $helper->__('Select File to Import'), 'title' => $helper->__('Select File to Import'), diff --git a/app/code/core/Mage/ImportExport/Helper/Data.php b/app/code/core/Mage/ImportExport/Helper/Data.php index f714b36fd495e..713cbb8d9753a 100644 --- a/app/code/core/Mage/ImportExport/Helper/Data.php +++ b/app/code/core/Mage/ImportExport/Helper/Data.php @@ -39,6 +39,22 @@ class Mage_ImportExport_Helper_Data extends Mage_Core_Helper_Data const XML_PATH_EXPORT_LOCAL_VALID_PATH = 'general/file/importexport_local_valid_paths'; const XML_PATH_BUNCH_SIZE = 'general/file/bunch_size'; + /** + * Array of allowed customer behaviours for import + * + * @var array + */ + protected $_allowedCustomerBehaviours = array( + Mage_ImportExport_Model_Source_Format_Version::VERSION_1 => array( + Mage_ImportExport_Model_Import::BEHAVIOR_APPEND, + Mage_ImportExport_Model_Import::BEHAVIOR_REPLACE, + Mage_ImportExport_Model_Import::BEHAVIOR_DELETE, + ), + Mage_ImportExport_Model_Source_Format_Version::VERSION_2 => array( + Mage_ImportExport_Model_Import::BEHAVIOR_APPEND, + ), + ); + /** * Maximum size of uploaded files. * @@ -69,4 +85,18 @@ public function getBunchSize() { return (int)Mage::getStoreConfig(self::XML_PATH_BUNCH_SIZE); } + + /** + * Get array of allowed customer behaviours for defined import version + * + * @param $importVersion + * @return array + */ + public function getAllowedCustomerBehaviours($importVersion) + { + if (isset($this->_allowedCustomerBehaviours[$importVersion])) { + return $this->_allowedCustomerBehaviours[$importVersion]; + } + return array(); + } } diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/V2/Eav/Customer/Address.php b/app/code/core/Mage/ImportExport/Model/Export/Entity/V2/Eav/Customer/Address.php index 7f22fdd4bf4bf..a6eb0c0013081 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Entity/V2/Eav/Customer/Address.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Entity/V2/Eav/Customer/Address.php @@ -35,7 +35,7 @@ class Mage_ImportExport_Model_Export_Entity_V2_Eav_Customer_Address extends Mage_ImportExport_Model_Export_Entity_V2_Eav_Abstract { /**#@+ - * Permanent column names. + * Permanent column names * * Names that begins with underscore is not an attribute. * This name convention is for to avoid interference with same attribute name. @@ -45,6 +45,23 @@ class Mage_ImportExport_Model_Export_Entity_V2_Eav_Customer_Address const COL_ADDRESS_ID = '_entity_id'; /**#@-*/ + /**#@+ + * Particular columns that contains of customer default addresses + */ + const COLUMN_NAME_DEFAULT_BILLING = '_address_default_billing_'; + const COLUMN_NAME_DEFAULT_SHIPPING = '_address_default_shipping_'; + /**#@-*/ + + /** + * Default addresses column names to appropriate customer attribute code + * + * @var array + */ + protected static $_defaultAddressAttributeMapping = array( + self::COLUMN_NAME_DEFAULT_BILLING => 'default_billing', + self::COLUMN_NAME_DEFAULT_SHIPPING => 'default_shipping' + ); + /** * Constructor * @@ -57,10 +74,22 @@ public function __construct() $this->_permanentAttributes = array(self::COL_WEBSITE, self::COL_EMAIL, self::COL_ADDRESS_ID); $this->_initWebsites(true); + $this->setFileName($this->getEntityTypeCode()); + } + + /** + * Customer default addresses column name to customer attribute mapping array + * + * @static + * @return array + */ + public static function getDefaultAddressAttributeMapping() + { + return self::$_defaultAddressAttributeMapping; } /** - * Export process. + * Export process * * @return string */ @@ -87,7 +116,7 @@ public function export() $customerCollection = $exportCustomer->filterEntityCollection($customerCollection); // Get customer default addresses column name to customer attribute mapping array. - $defaultAddressMap = Mage_ImportExport_Model_Import_Entity_Customer_Address::getDefaultAddressAttrMapping(); + $defaultAddressMap = self::getDefaultAddressAttributeMapping(); $customerCollection->addAttributeToSelect($defaultAddressMap); $customers = $customerCollection->getItems(); diff --git a/app/code/core/Mage/ImportExport/Model/Import.php b/app/code/core/Mage/ImportExport/Model/Import.php index bb57c009e75d4..5eabcfaa08c17 100644 --- a/app/code/core/Mage/ImportExport/Model/Import.php +++ b/app/code/core/Mage/ImportExport/Model/Import.php @@ -30,16 +30,21 @@ * @category Mage * @package Mage_ImportExport * @author Magento Core Team + * + * @method string getEntitySubtype() getEntitySubtype() + * @method string getBehavior() getBehavior() */ class Mage_ImportExport_Model_Import extends Mage_ImportExport_Model_Abstract { - /** - * Key in config with entities. + /**#@+ + * Config keys */ - const CONFIG_KEY_ENTITIES = 'global/importexport/import_entities'; + const CONFIG_KEY_ENTITIES = 'global/importexport/import_entities'; + const CONFIG_KEY_CUSTOMER_ENTITIES = 'global/importexport/import_customer_entities'; + /**#@-*/ /** - * Import behavior. + * Import behavior */ const BEHAVIOR_APPEND = 'append'; const BEHAVIOR_REPLACE = 'replace'; @@ -83,36 +88,72 @@ class Mage_ImportExport_Model_Import extends Mage_ImportExport_Model_Abstract * Create instance of entity adapter and returns it. * * @throws Mage_Core_Exception - * @return Mage_ImportExport_Model_Import_Entity_Abstract + * @return Mage_ImportExport_Model_Import_Entity_Abstract|Mage_ImportExport_Model_Import_Entity_V2_Abstract */ protected function _getEntityAdapter() { if (!$this->_entityAdapter) { - $validTypes = Mage_ImportExport_Model_Config::getModels(self::CONFIG_KEY_ENTITIES); + $entityTypes = Mage_ImportExport_Model_Config::getModels(self::CONFIG_KEY_ENTITIES); + $customerEntityTypes = Mage_ImportExport_Model_Config::getModels(self::CONFIG_KEY_CUSTOMER_ENTITIES); + + $entitySubtype = $this->getEntitySubtype(); + if (!empty($entitySubtype)) { + if (isset($customerEntityTypes[$entitySubtype])) { + try { + $this->_entityAdapter = Mage::getModel($customerEntityTypes[$entitySubtype]['model']); + } catch (Exception $e) { + Mage::logException($e); + Mage::throwException( + Mage::helper('Mage_ImportExport_Helper_Data')->__('Invalid entity model') + ); + } + if (!$this->_entityAdapter instanceof Mage_ImportExport_Model_Import_Entity_V2_Abstract) { + Mage::throwException( + Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Entity adapter object must be an instance of %s', + 'Mage_ImportExport_Model_Import_Entity_V2_Abstract' + ) + ); + } - if (isset($validTypes[$this->getEntity()])) { + // check for entity codes integrity + if ($this->getEntitySubtype() != $this->_entityAdapter->getEntityTypeCode()) { + Mage::throwException( + Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Input entity code is not equal to entity adapter code') + ); + } + } else { + Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Invalid entity')); + } + } elseif (isset($entityTypes[$this->getEntity()])) { try { - $this->_entityAdapter = Mage::getModel($validTypes[$this->getEntity()]['model']); + $this->_entityAdapter = Mage::getModel($entityTypes[$this->getEntity()]['model']); } catch (Exception $e) { Mage::logException($e); Mage::throwException( Mage::helper('Mage_ImportExport_Helper_Data')->__('Invalid entity model') ); } - if (!($this->_entityAdapter instanceof Mage_ImportExport_Model_Import_Entity_Abstract)) { + if (!$this->_entityAdapter instanceof Mage_ImportExport_Model_Import_Entity_Abstract) { + Mage::throwException( + Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Entity adapter object must be an instance of %s', + 'Mage_ImportExport_Model_Import_Entity_Abstract' + ) + ); + } + + // check for entity codes integrity + if ($this->getEntity() != $this->_entityAdapter->getEntityTypeCode()) { Mage::throwException( - Mage::helper('Mage_ImportExport_Helper_Data')->__('Entity adapter object must be an instance of Mage_ImportExport_Model_Import_Entity_Abstract') + Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Input entity code is not equal to entity adapter code') ); } } else { Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Invalid entity')); } - // check for entity codes integrity - if ($this->getEntity() != $this->_entityAdapter->getEntityTypeCode()) { - Mage::throwException( - Mage::helper('Mage_ImportExport_Helper_Data')->__('Input entity code is not equal to entity adapter code') - ); - } $this->_entityAdapter->setParameters($this->getData()); } return $this->_entityAdapter; @@ -141,16 +182,20 @@ public function getOperationResultMessages($validationResult) if ($this->getProcessedRowsCount()) { if (!$validationResult) { if ($this->getProcessedRowsCount() == $this->getInvalidRowsCount()) { - $messages[] = Mage::helper('Mage_ImportExport_Helper_Data')->__('File is totally invalid. Please fix errors and re-upload file'); + $messages[] = Mage::helper('Mage_ImportExport_Helper_Data') + ->__('File is totally invalid. Please fix errors and re-upload file'); } elseif ($this->getErrorsCount() >= $this->getErrorsLimit()) { - $messages[] = Mage::helper('Mage_ImportExport_Helper_Data')->__('Errors limit (%d) reached. Please fix errors and re-upload file', - $this->getErrorsLimit() - ); + $messages[] = Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Errors limit (%d) reached. Please fix errors and re-upload file', + $this->getErrorsLimit() + ); } else { if ($this->isImportAllowed()) { - $messages[] = Mage::helper('Mage_ImportExport_Helper_Data')->__('Please fix errors and re-upload file'); + $messages[] = Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Please fix errors and re-upload file'); } else { - $messages[] = Mage::helper('Mage_ImportExport_Helper_Data')->__('File is partially valid, but import is not possible'); + $messages[] = Mage::helper('Mage_ImportExport_Helper_Data') + ->__('File is partially valid, but import is not possible'); } } // errors info @@ -162,19 +207,22 @@ public function getOperationResultMessages($validationResult) } } else { if ($this->isImportAllowed()) { - $messages[] = Mage::helper('Mage_ImportExport_Helper_Data')->__('Validation finished successfully'); + $messages[] = Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Validation finished successfully'); } else { - $messages[] = Mage::helper('Mage_ImportExport_Helper_Data')->__('File is valid, but import is not possible'); + $messages[] = Mage::helper('Mage_ImportExport_Helper_Data') + ->__('File is valid, but import is not possible'); } } $notices = $this->getNotices(); if (is_array($notices)) { $messages = array_merge($messages, $notices); } - $messages[] = Mage::helper('Mage_ImportExport_Helper_Data')->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', - $this->getProcessedRowsCount(), $this->getProcessedEntitiesCount(), - $this->getInvalidRowsCount(), $this->getErrorsCount() - ); + $messages[] = Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', + $this->getProcessedRowsCount(), $this->getProcessedEntitiesCount(), + $this->getInvalidRowsCount(), $this->getErrorsCount() + ); } else { $messages[] = Mage::helper('Mage_ImportExport_Helper_Data')->__('File does not contain data.'); } @@ -322,19 +370,35 @@ public static function getWorkingDir() */ public function importSource() { + $entitySubtype = self::getDataSourceModel()->getUniqueColumnData('entity_subtype'); $this->setData(array( - 'entity' => self::getDataSourceModel()->getEntityTypeCode(), - 'behavior' => self::getDataSourceModel()->getBehavior() + 'entity' => self::getDataSourceModel()->getEntityTypeCode(), + 'behavior' => self::getDataSourceModel()->getBehavior(), + 'entity_subtype' => $entitySubtype )); - $this->addLogComment(Mage::helper('Mage_ImportExport_Helper_Data')->__('Begin import of "%s" with "%s" behavior', $this->getEntity(), $this->getBehavior())); + + $this->addLogComment( + Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Begin import of "%s" "%s" with "%s" behavior', + $this->getEntity(), + $entitySubtype, + $this->getBehavior() + ) + ); + $result = $this->_getEntityAdapter()->importData(); + $this->addLogComment(array( - Mage::helper('Mage_ImportExport_Helper_Data')->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', - $this->getProcessedRowsCount(), $this->getProcessedEntitiesCount(), - $this->getInvalidRowsCount(), $this->getErrorsCount() - ), + Mage::helper('Mage_ImportExport_Helper_Data') + ->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', + $this->getProcessedRowsCount(), + $this->getProcessedEntitiesCount(), + $this->getInvalidRowsCount(), + $this->getErrorsCount() + ), Mage::helper('Mage_ImportExport_Helper_Data')->__('Import has been done successfuly.') )); + return $result; } @@ -355,6 +419,7 @@ public function isImportAllowed() */ public function expandSource() { + /** @var $writer Mage_ImportExport_Model_Export_Adapter_Csv */ $writer = Mage::getModel('Mage_ImportExport_Model_Export_Adapter_Csv', self::getWorkingDir() . "big0.csv"); $regExps = array('last' => '/(.*?)(\d+)$/', 'middle' => '/(.*?)(\d+)(.*)$/'); $colReg = array( @@ -406,6 +471,7 @@ public function expandSource() public function uploadSource() { $entity = $this->getEntity(); + /** @var $uploader Mage_Core_Model_File_Uploader */ $uploader = Mage::getModel('Mage_Core_Model_File_Uploader', self::FIELD_NAME_SOURCE_FILE); $uploader->skipDbProcessing(true); $result = $uploader->save(self::getWorkingDir()); @@ -420,7 +486,7 @@ public function uploadSource() $sourceFile .= '.' . $extension; - if(strtolower($uploadedFile) != strtolower($sourceFile)) { + if (strtolower($uploadedFile) != strtolower($sourceFile)) { if (file_exists($sourceFile)) { unlink($sourceFile); } @@ -482,4 +548,3 @@ public function invalidateIndex() return $this; } } - diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php index 5bf6590da91f8..44c5c96a1aa66 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php @@ -664,32 +664,46 @@ public function setSource(Mage_ImportExport_Model_Import_Adapter_Abstract $sourc public function validateData() { if (!$this->_dataValidated) { - // does all permanent columns exists? - if (($colsAbsent = array_diff($this->_permanentAttributes, $this->_getSource()->getColNames()))) { + /** @var $helper Mage_ImportExport_Helper_Data */ + $helper = Mage::helper('Mage_ImportExport_Helper_Data'); + + // do all permanent columns exist? + if ($absentColumns = array_diff($this->_permanentAttributes, $this->getSource()->getColNames())) { Mage::throwException( - Mage::helper('Mage_ImportExport_Helper_Data')->__('Can not find required columns: %s', implode(', ', $colsAbsent)) + $helper->__('Can not find required columns: %s', implode(', ', $absentColumns)) ); } - // initialize validation related attributes - $this->_errors = array(); - $this->_invalidRows = array(); - // check attribute columns names validity - $invalidColumns = array(); - - foreach ($this->_getSource()->getColNames() as $colName) { - if (!preg_match('/^[a-z][a-z0-9_]*$/', $colName) && !$this->isAttributeParticular($colName)) { - $invalidColumns[] = $colName; + $columnNumber = 0; + $emptyHeaderColumns = array(); + $invalidColumns = array(); + foreach ($this->getSource()->getColNames() as $columnName) { + $columnNumber++; + if (!$this->isAttributeParticular($columnName)) { + if (trim($columnName) == '') { + $emptyHeaderColumns[] = $columnNumber; + } elseif (!preg_match('/^[a-z][a-z0-9_]*$/', $columnName)) { + $invalidColumns[] = $columnName; + } } } + + if ($emptyHeaderColumns) { + Mage::throwException( + $helper->__('Columns number: "%s" have empty headers', implode('", "', $emptyHeaderColumns)) + ); + } if ($invalidColumns) { Mage::throwException( - Mage::helper('Mage_ImportExport_Helper_Data')->__('Column names: "%s" are invalid', implode('", "', $invalidColumns)) + $helper->__('Column names: "%s" are invalid', implode('", "', $invalidColumns)) ); } - $this->_saveValidatedBunches(); + // initialize validation related attributes + $this->_errors = array(); + $this->_invalidRows = array(); + $this->_saveValidatedBunches(); $this->_dataValidated = true; } return $this; diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Abstract.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Abstract.php new file mode 100644 index 0000000000000..be3b9e9328db5 --- /dev/null +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Abstract.php @@ -0,0 +1,661 @@ + + */ +abstract class Mage_ImportExport_Model_Import_Entity_V2_Abstract +{ + /**#@+ + * Database constants + */ + const DB_MAX_PACKET_COEFFICIENT = 900000; + const DB_MAX_PACKET_DATA = 1048576; + const DB_MAX_VARCHAR_LENGTH = 256; + const DB_MAX_TEXT_LENGTH = 65536; + /**#@-*/ + + /** + * DB connection + * + * @var Varien_Db_Adapter_Interface + */ + protected $_connection; + + /** + * Has data process validation done? + * + * @var bool + */ + protected $_dataValidated = false; + + /** + * DB data source model + * + * @var Mage_ImportExport_Model_Resource_Import_Data + */ + protected $_dataSourceModel; + + /** + * Error codes with arrays of corresponding row numbers + * + * @var array + */ + protected $_errors = array(); + + /** + * Error counter + * + * @var int + */ + protected $_errorsCount = 0; + + /** + * Limit of errors after which pre-processing will exit + * + * @var int + */ + protected $_errorsLimit = 100; + + /** + * Flag to disable import + * + * @var bool + */ + protected $_importAllowed = true; + + /** + * Array of invalid rows numbers + * + * @var array + */ + protected $_invalidRows = array(); + + /** + * Validation failure message template definitions + * + * @var array + */ + protected $_messageTemplates = array(); + + /** + * Notice messages + * + * @var array + */ + protected $_notices = array(); + + /** + * Entity model parameters + * + * @var array + */ + protected $_parameters = array(); + + /** + * Column names that holds values with particular meaning + * + * @var array + */ + protected $_particularAttributes = array(); + + /** + * Permanent entity columns + * + * @var array + */ + protected $_permanentAttributes = array(); + + /** + * Number of entities processed by validation + * + * @var int + */ + protected $_processedEntitiesCount = 0; + + /** + * Number of rows processed by validation + * + * @var int + */ + protected $_processedRowsCount = 0; + + /** + * Rows which will be skipped during import + * + * [Row number 1] => true, + * ... + * [Row number N] => true + * + * @var array + */ + protected $_skippedRows = array(); + + /** + * Array of numbers of validated rows as keys and boolean TRUE as values + * + * @var array + */ + protected $_validatedRows = array(); + + /** + * Source model + * + * @var Mage_ImportExport_Model_Import_Adapter_Abstract + */ + protected $_source; + + /** + * Array of unique attributes + * + * @var array + */ + protected $_uniqueAttributes = array(); + + /** + * List of available behaviors + * + * @var array + */ + protected $_availableBehaviors = array(); + + /** + * Constructor + */ + public function __construct() + { + $this->_dataSourceModel = Mage_ImportExport_Model_Import::getDataSourceModel(); + /** @var $coreResourceModel Mage_Core_Model_Resource */ + $coreResourceModel = Mage::getSingleton('Mage_Core_Model_Resource'); + $this->_connection = $coreResourceModel->getConnection('write'); + + $this->_availableBehaviors = array( + Mage_ImportExport_Model_Import::BEHAVIOR_APPEND, + Mage_ImportExport_Model_Import::BEHAVIOR_REPLACE, + Mage_ImportExport_Model_Import::BEHAVIOR_DELETE, + ); + } + + /** + * Import data rows + * + * @abstract + * @return boolean + */ + abstract protected function _importData(); + + /** + * Imported entity type code getter + * + * @abstract + * @return string + */ + abstract public function getEntityTypeCode(); + + /** + * Imported entity type code getter + * + * @return string + */ + public function getEntitySubtype() + { + return !empty($this->_parameters['entity_subtype']) ? $this->_parameters['entity_subtype'] : null; + } + + /** + * Change row data before saving in DB table + * + * @param array $rowData + * @return array + */ + protected function _prepareRowForDb(array $rowData) + { + /** + * Convert all empty strings to null values, as + * a) we don't use empty string in DB + * b) empty strings instead of numeric values will product errors in Sql Server + */ + foreach ($rowData as $key => $val) { + if ($val === '') { + $rowData[$key] = null; + } + } + return $rowData; + } + + /** + * Validate data rows and save bunches to DB + * + * @return Mage_ImportExport_Model_Import_Entity_V2_Abstract + */ + protected function _saveValidatedBunches() + { + $source = $this->getSource(); + $processedDataSize = 0; + $bunchRows = array(); + $startNewBunch = false; + $nextRowBackup = array(); + + /** @var $resourceHelper Mage_ImportExport_Model_Resource_Helper_Mysql4 */ + $resourceHelper = Mage::getResourceHelper('Mage_ImportExport'); + /** @var $dataHelper Mage_ImportExport_Helper_Data */ + $dataHelper = Mage::helper('Mage_ImportExport_Helper_Data'); + $bunchSize = $dataHelper->getBunchSize(); + + $source->rewind(); + $this->_dataSourceModel->cleanBunches(); + + while ($source->valid() || $bunchRows) { + if ($startNewBunch || !$source->valid()) { + $this->_dataSourceModel->saveBunch( + $this->getEntityTypeCode(), + $this->getBehavior(), + $bunchRows, + $this->getEntitySubtype() + ); + + $bunchRows = $nextRowBackup; + $processedDataSize = strlen(serialize($bunchRows)); + $startNewBunch = false; + $nextRowBackup = array(); + } + if ($source->valid()) { + // errors limit check + if ($this->_errorsCount >= $this->_errorsLimit) { + return $this; + } + $rowData = $source->current(); + // add row to bunch for save + if ($this->validateRow($rowData, $source->key())) { + $rowData = $this->_prepareRowForDb($rowData); + $rowSize = strlen(Mage::helper('Mage_Core_Helper_Data')->jsonEncode($rowData)); + + $isBunchSizeExceeded = ($bunchSize > 0 && count($bunchRows) >= $bunchSize); + + if (($processedDataSize + $rowSize) >= $resourceHelper->getMaxDataSize() || $isBunchSizeExceeded) { + $startNewBunch = true; + $nextRowBackup = array($source->key() => $rowData); + } else { + $bunchRows[$source->key()] = $rowData; + $processedDataSize += $rowSize; + } + } + $this->_processedRowsCount++; + $source->next(); + } + } + return $this; + } + + /** + * Add error with corresponding current data source row number + * + * @param string $errorCode Error code or simply column name + * @param int $errorRowNum Row number + * @param string $columnName OPTIONAL Column name + * @return Mage_ImportExport_Model_Import_Entity_V2_Abstract + */ + public function addRowError($errorCode, $errorRowNum, $columnName = null) + { + $this->_errors[$errorCode][] = array($errorRowNum + 1, $columnName); // one added for human readability + $this->_invalidRows[$errorRowNum] = true; + $this->_errorsCount++; + + return $this; + } + + /** + * Add message template for specific error code from outside + * + * @param string $errorCode Error code + * @param string $message Message template + * @return Mage_ImportExport_Model_Import_Entity_V2_Abstract + */ + public function addMessageTemplate($errorCode, $message) + { + $this->_messageTemplates[$errorCode] = $message; + + return $this; + } + + /** + * Import behavior getter + * + * @return string + */ + public function getBehavior() + { + if (isset($this->_parameters['behavior']) + && in_array($this->_parameters['behavior'], $this->_availableBehaviors) + ) { + return $this->_parameters['behavior']; + } + return Mage_ImportExport_Model_Import::getDefaultBehavior(); + } + + /** + * Returns error information grouped by error types and translated (if possible) + * + * @return array + */ + public function getErrorMessages() + { + $translator = Mage::helper('Mage_ImportExport_Helper_Data'); + $messages = array(); + + foreach ($this->_errors as $errorCode => $errorRows) { + if (isset($this->_messageTemplates[$errorCode])) { + $errorCode = $translator->__($this->_messageTemplates[$errorCode]); + } + foreach ($errorRows as $errorRowData) { + $key = $errorRowData[1] ? sprintf($errorCode, $errorRowData[1]) : $errorCode; + $messages[$key][] = $errorRowData[0]; + } + } + return $messages; + } + + /** + * Returns error counter value + * + * @return int + */ + public function getErrorsCount() + { + return $this->_errorsCount; + } + + /** + * Returns error limit value + * + * @return int + */ + public function getErrorsLimit() + { + return $this->_errorsLimit; + } + + /** + * Returns invalid rows count + * + * @return int + */ + public function getInvalidRowsCount() + { + return count($this->_invalidRows); + } + + /** + * Returns model notices + * + * @return array + */ + public function getNotices() + { + return $this->_notices; + } + + /** + * Returns number of checked entities + * + * @return int + */ + public function getProcessedEntitiesCount() + { + return $this->_processedEntitiesCount; + } + + /** + * Returns number of checked rows + * + * @return int + */ + public function getProcessedRowsCount() + { + return $this->_processedRowsCount; + } + + /** + * Source object getter + * + * @throws Exception + * @return Mage_ImportExport_Model_Import_Adapter_Abstract + */ + public function getSource() + { + if (!$this->_source) { + Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Source is not set')); + } + return $this->_source; + } + + /** + * Import process start + * + * @return bool Result of operation + */ + public function importData() + { + return $this->_importData(); + } + + /** + * Is attribute contains particular data (not plain entity attribute) + * + * @param string $attrCode + * @return bool + */ + public function isAttributeParticular($attrCode) + { + return in_array($attrCode, $this->_particularAttributes); + } + + /** + * Check one attribute can be overridden in child + * + * @param string $attributeCode Attribute code + * @param array $attributeParams Attribute params + * @param array $rowData Row data + * @param int $rowNumber + * @return boolean + */ + public function isAttributeValid($attributeCode, array $attributeParams, array $rowData, $rowNumber) + { + /** @var $stringHelper Mage_Core_Helper_String */ + $stringHelper = Mage::helper('Mage_Core_Helper_String'); + + switch ($attributeParams['type']) { + case 'varchar': + $value = $stringHelper->cleanString($rowData[$attributeCode]); + $valid = $stringHelper->strlen($value) < self::DB_MAX_VARCHAR_LENGTH; + break; + case 'decimal': + $value = trim($rowData[$attributeCode]); + $valid = ((float)$value == $value) && is_numeric($value); + break; + case 'select': + case 'multiselect': + $valid = isset($attributeParams['options'][strtolower($rowData[$attributeCode])]); + break; + case 'int': + $value = trim($rowData[$attributeCode]); + $valid = ((int)$value == $value) && is_numeric($value); + break; + case 'datetime': + $value = trim($rowData[$attributeCode]); + $valid = strtotime($value) !== false + || preg_match('/^\d{2}.\d{2}.\d{2,4}(?:\s+\d{1,2}.\d{1,2}(?:.\d{1,2})?)?$/', $value); + break; + case 'text': + $value = $stringHelper->cleanString($rowData[$attributeCode]); + $valid = $stringHelper->strlen($value) < self::DB_MAX_TEXT_LENGTH; + break; + default: + $valid = true; + break; + } + + /** @var $dataHelper Mage_ImportExport_Helper_Data */ + $dataHelper = Mage::helper('Mage_ImportExport_Helper_Data'); + + if (!$valid) { + $this->addRowError($dataHelper->__("Invalid value for '%s'"), $rowNumber, $attributeCode); + } elseif (!empty($attributeParams['is_unique'])) { + if (isset($this->_uniqueAttributes[$attributeCode][$rowData[$attributeCode]])) { + $this->addRowError($dataHelper->__("Duplicate Unique Attribute for '%s'"), $rowNumber, $attributeCode); + return false; + } + $this->_uniqueAttributes[$attributeCode][$rowData[$attributeCode]] = true; + } + return (bool) $valid; + } + + /** + * Check that is all of data valid + * + * @return bool + */ + public function isDataValid() + { + $this->validateData(); + return 0 == $this->_errorsCount; + } + + /** + * Import possibility getter + * + * @return bool + */ + public function isImportAllowed() + { + return $this->_importAllowed; + } + + /** + * Returns TRUE if row is valid and not in skipped rows array + * + * @param array $rowData + * @param int $rowNumber + * @return bool + */ + public function isRowAllowedToImport(array $rowData, $rowNumber) + { + return $this->validateRow($rowData, $rowNumber) && !isset($this->_skippedRows[$rowNumber]); + } + + /** + * Validate data row + * + * @param array $rowData + * @param int $rowNumber + * @return boolean + */ + abstract public function validateRow(array $rowData, $rowNumber); + + /** + * Set data from outside to change behavior + * + * @param array $parameters + * @return Mage_ImportExport_Model_Import_Entity_V2_Abstract + */ + public function setParameters(array $parameters) + { + $this->_parameters = $parameters; + return $this; + } + + /** + * Source model setter + * + * @param Mage_ImportExport_Model_Import_Adapter_Abstract $source + * @return Mage_ImportExport_Model_Import_Entity_V2_Abstract + */ + public function setSource(Mage_ImportExport_Model_Import_Adapter_Abstract $source) + { + $this->_source = $source; + $this->_dataValidated = false; + + return $this; + } + + /** + * Validate data + * + * @throws Exception + * @return Mage_ImportExport_Model_Import_Entity_V2_Abstract + */ + public function validateData() + { + if (!$this->_dataValidated) { + /** @var $helper Mage_ImportExport_Helper_Data */ + $helper = Mage::helper('Mage_ImportExport_Helper_Data'); + + // do all permanent columns exist? + if ($absentColumns = array_diff($this->_permanentAttributes, $this->getSource()->getColNames())) { + Mage::throwException( + $helper->__('Can not find required columns: %s', implode(', ', $absentColumns)) + ); + } + + // check attribute columns names validity + $columnNumber = 0; + $emptyHeaderColumns = array(); + $invalidColumns = array(); + foreach ($this->getSource()->getColNames() as $columnName) { + $columnNumber++; + if (!$this->isAttributeParticular($columnName)) { + if (trim($columnName) == '') { + $emptyHeaderColumns[] = $columnNumber; + } elseif (!preg_match('/^[a-z][a-z0-9_]*$/', $columnName)) { + $invalidColumns[] = $columnName; + } + } + } + + if ($emptyHeaderColumns) { + Mage::throwException( + $helper->__('Columns number: "%s" have empty headers', implode('", "', $emptyHeaderColumns)) + ); + } + if ($invalidColumns) { + Mage::throwException( + $helper->__('Column names: "%s" are invalid', implode('", "', $invalidColumns)) + ); + } + + // initialize validation related attributes + $this->_errors = array(); + $this->_invalidRows = array(); + $this->_saveValidatedBunches(); + $this->_dataValidated = true; + } + return $this; + } +} diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Abstract.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Abstract.php new file mode 100644 index 0000000000000..0b98b3c65338a --- /dev/null +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Abstract.php @@ -0,0 +1,195 @@ + + */ +abstract class Mage_ImportExport_Model_Import_Entity_V2_Eav_Abstract + extends Mage_ImportExport_Model_Import_Entity_V2_Abstract +{ + /** + * Entity type id + * + * @var int + */ + protected $_entityTypeId; + + /** + * Attributes with index (not label) value + * + * @var array + */ + protected $_indexValueAttributes = array(); + + /** + * Website code-to-ID + * + * @var array + */ + protected $_websiteCodeToId = array(); + + /** + * All stores code-ID pairs. + * + * @var array + */ + protected $_storeCodeToId = array(); + + /** + * Entity attributes parameters + * + * [attr_code_1] => array( + * 'options' => array(), + * 'type' => 'text', 'price', 'textarea', 'select', etc. + * 'id' => .. + * ), + * ... + * + * @var array + */ + protected $_attributes = array(); + + /** + * Initialize website values + * + * @param bool $withDefault + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Abstract + */ + protected function _initWebsites($withDefault = false) + { + /** @var $website Mage_Core_Model_Website */ + foreach (Mage::app()->getWebsites($withDefault) as $website) { + $this->_websiteCodeToId[$website->getCode()] = $website->getId(); + } + return $this; + } + + /** + * Initialize stores data + * + * @param bool $withDefault + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Abstract + */ + protected function _initStores($withDefault = false) + { + /** @var $store Mage_Core_Model_Store */ + foreach (Mage::app()->getStores($withDefault) as $store) { + $this->_storeCodeToId[$store->getCode()] = $store->getId(); + } + return $this; + } + + /** + * Initialize entity attributes + * + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Abstract + */ + protected function _initAttributes() + { + $collection = $this->_getAttributeCollection(); + /** @var $attribute Mage_Eav_Model_Attribute */ + foreach ($collection as $attribute) { + $this->_attributes[$attribute->getAttributeCode()] = array( + 'id' => $attribute->getId(), + 'code' => $attribute->getAttributeCode(), + 'table' => $attribute->getBackend()->getTable(), + 'is_required' => $attribute->getIsRequired(), + 'is_static' => $attribute->isStatic(), + 'rules' => $attribute->getValidateRules() ? unserialize($attribute->getValidateRules()) : null, + 'type' => Mage_ImportExport_Model_Import::getAttributeType($attribute), + 'options' => $this->getAttributeOptions($attribute) + ); + } + return $this; + } + + /** + * Retrieve entity attribute EAV collection + * + * @abstract + * @return Mage_Eav_Model_Resource_Attribute_Collection + */ + abstract protected function _getAttributeCollection(); + + /** + * Entity type ID getter + * + * @return int + */ + public function getEntityTypeId() + { + if ($this->_entityTypeId == null) { + /** @var $eavConfig Mage_Eav_Model_Config */ + $eavConfig = Mage::getSingleton('Mage_Eav_Model_Config'); + $entityType = $eavConfig->getEntityType($this->getEntityTypeCode()); + $this->_entityTypeId = $entityType->getEntityTypeId(); + } + + return $this->_entityTypeId; + } + + /** + * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased + * + * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute + * @param array $indexAttributes OPTIONAL Additional attribute codes with index values. + * @return array + */ + public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, + array $indexAttributes = array() + ) { + $options = array(); + + if ($attribute->usesSource()) { + // merge global entity index value attributes + $indexAttributes = array_merge($indexAttributes, $this->_indexValueAttributes); + + // should attribute has index (option value) instead of a label? + $index = in_array($attribute->getAttributeCode(), $indexAttributes) ? 'value' : 'label'; + + // only default (admin) store values used + $attribute->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID); + + try { + foreach ($attribute->getSource()->getAllOptions(false) as $option) { + $value = is_array($option['value']) ? $option['value'] : array($option); + foreach ($value as $innerOption) { + if (strlen($innerOption['value'])) { // skip ' -- Please Select -- ' option + $options[strtolower($innerOption[$index])] = $innerOption['value']; + } + } + } + } catch (Exception $e) { + // ignore exceptions connected with source models + } + } + return $options; + } +} diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer.php new file mode 100644 index 0000000000000..b1eafbab1900e --- /dev/null +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer.php @@ -0,0 +1,362 @@ + + */ +class Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer + extends Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Abstract +{ + /**#@+ + * Permanent column names + * + * Names that begins with underscore is not an attribute. This name convention is for + * to avoid interference with same attribute name. + */ + const COLUMN_EMAIL = 'email'; + const COLUMN_STORE = '_store'; + /**#@-*/ + + /**#@+ + * Error codes + */ + const ERROR_DUPLICATE_EMAIL_SITE = 'duplicateEmailSite'; + const ERROR_ROW_IS_ORPHAN = 'rowIsOrphan'; + const ERROR_INVALID_STORE = 'invalidStore'; + const ERROR_EMAIL_SITE_NOT_FOUND = 'emailSiteNotFound'; + const ERROR_PASSWORD_LENGTH = 'passwordLength'; + /**#@-*/ + + /** + * Minimum password length + */ + const MIN_PASSWORD_LENGTH = 6; + + /** + * Default customer group + */ + const DEFAULT_GROUP_ID = 1; + + /** + * Customers information from import file + * + * @var array + */ + protected $_newCustomers = array(); + + /** + * Array of attribute codes which will be ignored in validation and import procedures. + * For example, when entity attribute has own validation and import procedures + * or just to deny this attribute processing. + * + * @var array + */ + protected $_ignoredAttributes = array('website_id', 'store_id'); + + /** + * Customer entity DB table name. + * + * @var string + */ + protected $_entityTable; + + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); + + $this->_particularAttributes[] = self::COLUMN_WEBSITE; + $this->_particularAttributes[] = self::COLUMN_STORE; + $this->_permanentAttributes[] = self::COLUMN_EMAIL; + $this->_permanentAttributes[] = self::COLUMN_WEBSITE; + $this->_indexValueAttributes[] = 'group_id'; + + /** @var $helper Mage_ImportExport_Helper_Data */ + $helper = Mage::helper('Mage_ImportExport_Helper_Data'); + + $this->addMessageTemplate(self::ERROR_DUPLICATE_EMAIL_SITE, $helper->__('E-mail is duplicated in import file')); + $this->addMessageTemplate(self::ERROR_ROW_IS_ORPHAN, + $helper->__('Orphan rows that will be skipped due default row errors') + ); + $this->addMessageTemplate(self::ERROR_INVALID_STORE, + $helper->__('Invalid value in Store column (store does not exists?)') + ); + $this->addMessageTemplate(self::ERROR_EMAIL_SITE_NOT_FOUND, + $helper->__('E-mail and website combination is not found') + ); + $this->addMessageTemplate(self::ERROR_PASSWORD_LENGTH, $helper->__('Invalid password length')); + + $this->_initStores(true) + ->_initAttributes(); + + /** @var $customerResource Mage_Customer_Model_Resource_Customer */ + $customerResource = Mage::getModel('Mage_Customer_Model_Customer')->getResource(); + $this->_entityTable = $customerResource->getEntityTable(); + } + + /** + * Gather and save information about customer entities. + * + * @return Mage_ImportExport_Model_Import_Entity_Customer + */ + protected function _saveCustomers() + { + /** @var $resource Mage_Customer_Model_Customer */ + $resource = Mage::getModel('Mage_Customer_Model_Customer'); + + $passwordAttribute = $resource->getAttribute('password_hash'); + $passwordAttributeId = $passwordAttribute->getId(); + $passwordStorageTable = $passwordAttribute->getBackend()->getTable(); + + $dateTimeFormat = Varien_Date::convertZendToStrftime(Varien_Date::DATETIME_INTERNAL_FORMAT, true, true); + + $nextEntityId = Mage::getResourceHelper('Mage_ImportExport')->getNextAutoincrement($this->_entityTable); + + while ($bunch = $this->_dataSourceModel->getNextBunch()) { + $entitiesToCreate = array(); + $entitiesToUpdate = array(); + $attributes = array(); + + foreach ($bunch as $rowNumber => $rowData) { + if (!$this->validateRow($rowData, $rowNumber)) { + continue; + } + + // entity table data + $entityRow = array( + 'group_id' => empty($rowData['group_id']) + ? self::DEFAULT_GROUP_ID : $rowData['group_id'], + + 'store_id' => empty($rowData[self::COLUMN_STORE]) + ? 0 : $this->_storeCodeToId[$rowData[self::COLUMN_STORE]], + + 'created_at' => empty($rowData['created_at']) + ? now() : gmstrftime($dateTimeFormat, strtotime($rowData['created_at'])), + + 'updated_at' => now() + ); + + $emailInLowercase = strtolower($rowData[self::COLUMN_EMAIL]); + if ($entityId = $this->_getCustomerId($emailInLowercase, $rowData[self::COLUMN_WEBSITE])) { // edit + $entityRow['entity_id'] = $entityId; + $entitiesToUpdate[] = $entityRow; + } else { // create + $entityId = $nextEntityId++; + $entityRow['entity_id'] = $entityId; + $entityRow['entity_type_id'] = $this->getEntityTypeId(); + $entityRow['attribute_set_id'] = 0; + $entityRow['website_id'] = $this->_websiteCodeToId[$rowData[self::COLUMN_WEBSITE]]; + $entityRow['email'] = $emailInLowercase; + $entityRow['is_active'] = 1; + $entitiesToCreate[] = $entityRow; + + $this->_newCustomers[$emailInLowercase][$rowData[self::COLUMN_WEBSITE]] = $entityId; + } + + // attribute values + foreach (array_intersect_key($rowData, $this->_attributes) as $attributeCode => $value) { + if (!$this->_attributes[$attributeCode]['is_static'] && strlen($value)) { + /** @var $attribute Mage_Customer_Model_Attribute */ + $attribute = $resource->getAttribute($attributeCode); + $backendModel = $attribute->getBackendModel(); + $attributeParameters = $this->_attributes[$attributeCode]; + + if ('select' == $attributeParameters['type']) { + $value = $attributeParameters['options'][strtolower($value)]; + } elseif ('datetime' == $attributeParameters['type']) { + $value = gmstrftime($dateTimeFormat, strtotime($value)); + } elseif ($backendModel) { + $attribute->getBackend()->beforeSave($resource->setData($attributeCode, $value)); + $value = $resource->getData($attributeCode); + } + $attributes[$attribute->getBackend()->getTable()][$entityId][$attributeParameters['id']] + = $value; + + // restore 'backend_model' to avoid default setting + $attribute->setBackendModel($backendModel); + } + } + + // password change/set + if (isset($rowData['password']) && strlen($rowData['password'])) { + $attributes[$passwordStorageTable][$entityId][$passwordAttributeId] + = $resource->hashPassword($rowData['password']); + } + } + + $this->_saveCustomerEntity($entitiesToCreate, $entitiesToUpdate) + ->_saveCustomerAttributes($attributes); + } + return $this; + } + + /** + * Update and insert data in entity table. + * + * @param array $entitiesToCreate Rows for insert + * @param array $entitiesToUpdate Rows for update + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer + */ + protected function _saveCustomerEntity(array $entitiesToCreate, array $entitiesToUpdate) + { + if ($entitiesToCreate) { + $this->_connection->insertMultiple($this->_entityTable, $entitiesToCreate); + } + + if ($entitiesToUpdate) { + $this->_connection->insertOnDuplicate( + $this->_entityTable, + $entitiesToUpdate, + array('group_id', 'store_id', 'updated_at', 'created_at') + ); + } + + return $this; + } + + /** + * Save customer attributes. + * + * @param array $attributesData + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer + */ + protected function _saveCustomerAttributes(array $attributesData) + { + foreach ($attributesData as $tableName => $data) { + $tableData = array(); + + foreach ($data as $customerId => $attrData) { + foreach ($attrData as $attributeId => $value) { + $tableData[] = array( + 'entity_id' => $customerId, + 'entity_type_id' => $this->getEntityTypeId(), + 'attribute_id' => $attributeId, + 'value' => $value + ); + } + } + $this->_connection->insertOnDuplicate($tableName, $tableData, array('value')); + } + return $this; + } + + /** + * Import data rows + * + * @return boolean + */ + protected function _importData() + { + $this->_saveCustomers(); + + return true; + } + + /** + * EAV entity type code getter + * + * @abstract + * @return string + */ + public function getEntityTypeCode() + { + return $this->_getAttributeCollection()->getEntityTypeCode(); + } + + /** + * Retrieve customer attribute EAV collection + * + * @return Mage_Customer_Model_Resource_Attribute_Collection + */ + protected function _getAttributeCollection() + { + /** @var $collection Mage_Customer_Model_Resource_Attribute_Collection */ + $collection = Mage::getResourceModel('Mage_Customer_Model_Resource_Attribute_Collection'); + $collection->addSystemHiddenFilterWithPasswordHash(); + return $collection; + } + + /** + * Validate data row + * + * @param array $rowData + * @param int $rowNumber + * @return boolean + */ + public function validateRow(array $rowData, $rowNumber) + { + if (isset($this->_validatedRows[$rowNumber])) { // check that row is already validated + return !isset($this->_invalidRows[$rowNumber]); + } + $this->_validatedRows[$rowNumber] = true; + + $this->_processedEntitiesCount++; + $email = strtolower($rowData[self::COLUMN_EMAIL]); + $website = $rowData[self::COLUMN_WEBSITE]; + + if (!Zend_Validate::is($email, 'EmailAddress')) { + $this->addRowError(self::ERROR_INVALID_EMAIL, $rowNumber); + } elseif (!isset($this->_websiteCodeToId[$website])) { + $this->addRowError(self::ERROR_INVALID_WEBSITE, $rowNumber); + } else { + if (isset($this->_newCustomers[strtolower($rowData[self::COLUMN_EMAIL])][$website])) { + $this->addRowError(self::ERROR_DUPLICATE_EMAIL_SITE, $rowNumber); + } + $this->_newCustomers[$email][$website] = false; + + if (!empty($rowData[self::COLUMN_STORE]) && !isset($this->_storeCodeToId[$rowData[self::COLUMN_STORE]])) { + $this->addRowError(self::ERROR_INVALID_STORE, $rowNumber); + } + // check password + /** @var $stringHelper Mage_Core_Helper_String */ + $stringHelper = Mage::helper('Mage_Core_Helper_String'); + if (isset($rowData['password']) && strlen($rowData['password']) + && $stringHelper->strlen($rowData['password']) < self::MIN_PASSWORD_LENGTH + ) { + $this->addRowError(self::ERROR_PASSWORD_LENGTH, $rowNumber); + } + // check simple attributes + foreach ($this->_attributes as $attributeCode => $attributeParams) { + if (in_array($attributeCode, $this->_ignoredAttributes)) { + continue; + } + if (isset($rowData[$attributeCode]) && strlen($rowData[$attributeCode])) { + $this->isAttributeValid($attributeCode, $attributeParams, $rowData, $rowNumber); + } elseif ($attributeParams['is_required'] && !$this->_getCustomerId($email, $website)) { + $this->addRowError(self::ERROR_VALUE_IS_REQUIRED, $rowNumber, $attributeCode); + } + } + } + + return !isset($this->_invalidRows[$rowNumber]); + } +} diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/Abstract.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/Abstract.php new file mode 100644 index 0000000000000..811f233b82144 --- /dev/null +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/Abstract.php @@ -0,0 +1,158 @@ + + */ +abstract class Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Abstract + extends Mage_ImportExport_Model_Import_Entity_V2_Eav_Abstract +{ + /**#@+ + * Permanent column names + * + * Names that begins with underscore is not an attribute. This name convention is for + * to avoid interference with same attribute name. + */ + const COLUMN_WEBSITE = '_website'; + /**#@-*/ + + /**#@+ + * Error codes + */ + const ERROR_WEBSITE_IS_EMPTY = 'websiteIsEmpty'; + const ERROR_EMAIL_IS_EMPTY = 'emailIsEmpty'; + const ERROR_INVALID_WEBSITE = 'invalidWebsite'; + const ERROR_INVALID_EMAIL = 'invalidEmail'; + const ERROR_VALUE_IS_REQUIRED = 'valueIsRequired'; + const ERROR_CUSTOMER_NOT_FOUND = 'customerNotFound'; + /**#@-*/ + + /** + * Existing customers information. In form of: + * + * [customer e-mail] => array( + * [website id 1] => customer_id 1, + * [website id 2] => customer_id 2, + * ... => ... , + * [website id n] => customer_id n, + * ) + * + * @var array + */ + protected $_customers = array(); + + /** + * Array of attribute codes which will be ignored in validation and import procedures. + * For example, when entity attribute has own validation and import procedures + * or just to deny this attribute processing. + * + * @var array + */ + protected $_ignoredAttributes = array('website_id', 'store_id', 'default_billing', 'default_shipping'); + + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); + + /** @var $helper Mage_ImportExport_Helper_Data */ + $helper = Mage::helper('Mage_ImportExport_Helper_Data'); + + $this->addMessageTemplate(self::ERROR_WEBSITE_IS_EMPTY, $helper->__('Website is not specified')); + $this->addMessageTemplate(self::ERROR_EMAIL_IS_EMPTY, $helper->__('E-mail is not specified')); + $this->addMessageTemplate(self::ERROR_INVALID_WEBSITE, + $helper->__('Invalid value in Website column (website does not exists?)') + ); + $this->addMessageTemplate(self::ERROR_INVALID_EMAIL, $helper->__('E-mail is invalid')); + $this->addMessageTemplate(self::ERROR_VALUE_IS_REQUIRED, + $helper->__("Required attribute '%s' has an empty value") + ); + $this->addMessageTemplate(self::ERROR_CUSTOMER_NOT_FOUND, + $helper->__("Customer with such email and website code doesn't exist") + ); + + $this->_initCustomers() + ->_initWebsites(true); + } + + /** + * Initialize existent customers data + * + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Abstract + */ + protected function _initCustomers() + { + $collection = $this->_getCustomerCollection(); + /** @var $customer Mage_Customer_Model_Customer */ + foreach ($collection->getItems() as $customer) { + $email = strtolower($customer->getEmail()); + if (!isset($this->_customers[$email])) { + $this->_customers[$email] = array(); + } + $this->_customers[$email][$customer->getWebsiteId()] = $customer->getId(); + } + + return $this; + } + + /** + * Get customer collection + * + * @return Mage_Customer_Model_Resource_Customer_Collection + */ + protected function _getCustomerCollection() + { + /** @var $collection Mage_Customer_Model_Resource_Customer_Collection */ + $collection = Mage::getResourceModel('Mage_Customer_Model_Resource_Customer_Collection'); + return $collection; + } + + /** + * Get customer id if customer is present in database + * + * @param string $email + * @param string $websiteCode + * @return bool|int + */ + protected function _getCustomerId($email, $websiteCode) + { + $email = strtolower(trim($email)); + if (isset($this->_websiteCodeToId[$websiteCode])) { + $websiteId = $this->_websiteCodeToId[$websiteCode]; + if (isset($this->_customers[$email][$websiteId])) { + return $this->_customers[$email][$websiteId]; + } + } + + return false; + } +} diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/Address.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/Address.php new file mode 100644 index 0000000000000..948d42e044a12 --- /dev/null +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/V2/Eav/Customer/Address.php @@ -0,0 +1,504 @@ + + */ +class Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Address + extends Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Abstract +{ + /**#@+ + * Permanent column names + * + * Names that begins with underscore is not an attribute. + * This name convention is for to avoid interference with same attribute name. + */ + const COLUMN_EMAIL = '_email'; + const COLUMN_ADDRESS_ID = '_entity_id'; + /**#@-*/ + + /**#@+ + * Required column names + */ + const COLUMN_REGION = 'region'; + const COLUMN_COUNTRY_ID = 'country_id'; + /**#@-*/ + + /**#@+ + * Particular columns that contains of customer default addresses + */ + const COLUMN_DEFAULT_BILLING = '_address_default_billing_'; + const COLUMN_DEFAULT_SHIPPING = '_address_default_shipping_'; + /**#@-*/ + + /**#@+ + * Error codes + */ + const ERROR_ADDRESS_ID_IS_EMPTY = 'addressIdIsEmpty'; + const ERROR_INVALID_REGION = 'invalidRegion'; + /**#@-*/ + + /** + * Default addresses column names to appropriate customer attribute code + * + * @var array + */ + protected static $_defaultAddressAttributeMapping = array( + self::COLUMN_DEFAULT_BILLING => 'default_billing', + self::COLUMN_DEFAULT_SHIPPING => 'default_shipping' + ); + + /** + * Permanent entity columns + * + * @var array + */ + protected $_permanentAttributes = array(self::COLUMN_WEBSITE, self::COLUMN_EMAIL, self::COLUMN_ADDRESS_ID); + + /** + * Existing addresses + * + * [customer ID] => array( + * address ID 1, + * address ID 2, + * ... + * address ID N + * ) + * + * @var array + */ + protected $_addresses = array(); + + /** + * Attributes with index (not label) value + * + * @var array + */ + protected $_indexValueAttributes = array(self::COLUMN_COUNTRY_ID); + + /** + * Customer entity DB table name + * + * @var string + */ + protected $_entityTable; + + /** + * Countries and regions + * + * array( + * [country_id_lowercased_1] => array( + * [region_code_lowercased_1] => region_id_1, + * [region_default_name_lowercased_1] => region_id_1, + * ..., + * [region_code_lowercased_n] => region_id_n, + * [region_default_name_lowercased_n] => region_id_n + * ), + * ... + * ) + * + * @var array + */ + protected $_countryRegions = array(); + + /** + * Region ID to region default name pairs + * + * @var array + */ + protected $_regions = array(); + + /** + * Column names that holds values with particular meaning + * + * @var array + */ + protected $_particularAttributes = array( + self::COLUMN_WEBSITE, + self::COLUMN_EMAIL, + self::COLUMN_ADDRESS_ID, + self::COLUMN_DEFAULT_BILLING, + self::COLUMN_DEFAULT_SHIPPING + ); + + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); + + $this->_entityTable = Mage::getModel('Mage_Customer_Model_Address')->getResource()->getEntityTable(); + + /** @var $helper Mage_ImportExport_Helper_Data */ + $helper = Mage::helper('Mage_ImportExport_Helper_Data'); + $this->addMessageTemplate(self::ERROR_ADDRESS_ID_IS_EMPTY, + $helper->__('Customer address id column is not specified') + ); + $this->addMessageTemplate(self::ERROR_INVALID_REGION, $helper->__('Region is invalid')); + + $this->_initAttributes(); + $this->_initAddresses() + ->_initCountryRegions(); + } + + /** + * Initialize existent addresses data + * + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Address + */ + protected function _initAddresses() + { + /** @var $address Mage_Customer_Model_Address */ + foreach (Mage::getResourceModel('Mage_Customer_Model_Resource_Address_Collection') as $address) { + $customerId = $address->getParentId(); + if (!isset($this->_addresses[$customerId])) { + $this->_addresses[$customerId] = array(); + } + $addressId = $address->getId(); + if (!in_array($addressId, $this->_addresses[$customerId])) { + $this->_addresses[$customerId][] = $addressId; + } + } + + return $this; + } + + /** + * Get region collection + * + * @return Mage_Customer_Model_Resource_Customer_Collection + */ + protected function _getRegionCollection() + { + /** @var $collection Mage_Directory_Model_Resource_Region_Collection */ + $collection = Mage::getResourceModel('Mage_Directory_Model_Resource_Region_Collection'); + return $collection; + } + + /** + * Initialize country regions hash for clever recognition + * + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Address + */ + protected function _initCountryRegions() + { + $collection = $this->_getRegionCollection(); + /** @var $region Mage_Directory_Model_Region */ + foreach ($collection->getItems() as $region) { + $countryNormalized = strtolower($region->getCountryId()); + $regionCode = strtolower($region->getCode()); + $regionName = strtolower($region->getDefaultName()); + $this->_countryRegions[$countryNormalized][$regionCode] = $region->getId(); + $this->_countryRegions[$countryNormalized][$regionName] = $region->getId(); + $this->_regions[$region->getId()] = $region->getDefaultName(); + } + return $this; + } + + /** + * Import data rows + * + * @abstract + * @return boolean + */ + protected function _importData() + { + /** @var $customer Mage_Customer_Model_Customer */ + $customer = Mage::getModel('Mage_Customer_Model_Customer'); + $dateTimeFormat = Varien_Date::convertZendToStrftime(Varien_Date::DATETIME_INTERNAL_FORMAT, true, true); + $addressModel = Mage::getModel('Mage_Customer_Model_Address'); + $table = $addressModel->getResource()->getEntityTable(); + $nextEntityId = Mage::getResourceHelper('Mage_ImportExport')->getNextAutoincrement($table); + + /** @var $regionConfig Mage_Eav_Model_Config */ + $regionConfig = Mage::getSingleton('Mage_Eav_Model_Config'); + /** @var $regionIdAttribute Mage_Customer_Model_Attribute */ + $regionIdAttribute = $regionConfig->getAttribute($this->getEntityTypeCode(), 'region_id'); + $regionIdTable = $regionIdAttribute->getBackend()->getTable(); + $regionIdAttributeId = $regionIdAttribute->getId(); + + while ($bunch = $this->_dataSourceModel->getNextBunch()) { + $entityRows = array(); + $attributes = array(); + $defaults = array(); // customer default addresses (billing/shipping) data + + foreach ($bunch as $rowNumber => $rowData) { + // check row data + if (!$this->validateRow($rowData, $rowNumber)) { + continue; + } + + $email = strtolower($rowData[self::COLUMN_EMAIL]); + $websiteId = $this->_websiteCodeToId[$rowData[self::COLUMN_WEBSITE]]; + $customerId = $this->_customers[$email][$websiteId]; + + // get address attributes + $addressAttributes = array(); + foreach ($this->_attributes as $attributeAlias => $attributeParams) { + if (isset($rowData[$attributeAlias]) && strlen($rowData[$attributeAlias])) { + if ('select' == $attributeParams['type']) { + $value = $attributeParams['options'][strtolower($rowData[$attributeAlias])]; + } elseif ('datetime' == $attributeParams['type']) { + $value = gmstrftime($dateTimeFormat, strtotime($rowData[$attributeAlias])); + } else { + $value = $rowData[$attributeAlias]; + } + $addressAttributes[$attributeParams['id']] = $value; + } + } + + // get address id + if (isset($this->_addresses[$customerId]) + && in_array($rowData[self::COLUMN_ADDRESS_ID], $this->_addresses[$customerId]) + ) { + $addressId = $rowData[self::COLUMN_ADDRESS_ID]; + } else { + $addressId = $nextEntityId++; + } + + // entity table data + $entityRows[] = array( + 'entity_id' => $addressId, + 'entity_type_id' => $this->getEntityTypeId(), + 'parent_id' => $customerId, + 'created_at' => now(), + 'updated_at' => now() + ); + + // attribute values + foreach ($this->_attributes as $attributeParams) { + if (isset($addressAttributes[$attributeParams['id']])) { + $attributes[$attributeParams['table']][$addressId][$attributeParams['id']] + = $addressAttributes[$attributeParams['id']]; + } + } + + // customer default addresses + foreach (self::getDefaultAddressAttributeMapping() as $columnName => $attributeCode) { + if (!empty($rowData[$columnName])) { + /** @var $attribute Mage_Eav_Model_Entity_Attribute_Abstract */ + $attribute = $customer->getAttribute($attributeCode); + $defaults[$attribute->getBackend()->getTable()][$customerId][$attribute->getId()] = $addressId; + } + } + + // let's try to find region ID + if (!empty($rowData[self::COLUMN_REGION])) { + $countryNormalized = strtolower($rowData[self::COLUMN_COUNTRY_ID]); + $regionNormalized = strtolower($rowData[self::COLUMN_REGION]); + + if (isset($this->_countryRegions[$countryNormalized][$regionNormalized])) { + $regionId = $this->_countryRegions[$countryNormalized][$regionNormalized]; + $attributes[$regionIdTable][$addressId][$regionIdAttributeId] = $regionId; + $tableName = $this->_attributes[self::COLUMN_REGION]['table']; + $regionColumnNameId = $this->_attributes[self::COLUMN_REGION]['id']; + $attributes[$tableName][$addressId][$regionColumnNameId] = $this->_regions[$regionId]; + } + } + } + + $this->_saveAddressEntities($entityRows) + ->_saveAddressAttributes($attributes) + ->_saveCustomerDefaults($defaults); + } + return true; + } + + /** + * Update and insert data in entity table + * + * @param array $entityRows Rows for insert + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Address + */ + protected function _saveAddressEntities(array $entityRows) + { + if ($entityRows) { + $this->_connection->insertOnDuplicate($this->_entityTable, $entityRows, array('updated_at')); + } + return $this; + } + + /** + * Save customer address attributes + * + * @param array $attributesData + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Address + */ + protected function _saveAddressAttributes(array $attributesData) + { + foreach ($attributesData as $tableName => $data) { + $tableData = array(); + foreach ($data as $addressId => $attributeData) { + foreach ($attributeData as $attributeId => $value) { + $tableData[] = array( + 'entity_id' => $addressId, + 'entity_type_id' => $this->getEntityTypeId(), + 'attribute_id' => $attributeId, + 'value' => $value + ); + } + } + $this->_connection->insertOnDuplicate($tableName, $tableData, array('value')); + } + return $this; + } + + /** + * Save customer default addresses + * + * @param array $defaults + * @return Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Address + */ + protected function _saveCustomerDefaults(array $defaults) + { + /** @var $entity Mage_Customer_Model_Customer */ + $entity = Mage::getModel('Mage_Customer_Model_Customer'); + $entityTypeId = $entity->getEntityTypeId(); + + foreach ($defaults as $tableName => $data) { + $tableData = array(); + foreach ($data as $customerId => $attributeData) { + foreach ($attributeData as $attributeId => $value) { + $tableData[] = array( + 'entity_id' => $customerId, + 'entity_type_id' => $entityTypeId, + 'attribute_id' => $attributeId, + 'value' => $value + ); + } + } + $this->_connection->insertOnDuplicate($tableName, $tableData, array('value')); + } + return $this; + } + + /** + * EAV entity type code getter + * + * @abstract + * @return string + */ + public function getEntityTypeCode() + { + return 'customer_address'; + } + + /** + * Customer default addresses column name to customer attribute mapping array + * + * @static + * @return array + */ + public static function getDefaultAddressAttributeMapping() + { + return self::$_defaultAddressAttributeMapping; + } + + /** + * Validate data row + * + * @param array $rowData + * @param int $rowNumber + * @return boolean + */ + public function validateRow(array $rowData, $rowNumber) + { + if (isset($this->_validatedRows[$rowNumber])) { // check that row is already validated + return !isset($this->_invalidRows[$rowNumber]); + } + $this->_validatedRows[$rowNumber] = true; + $this->_processedEntitiesCount++; + + if (empty($rowData[self::COLUMN_WEBSITE])) { + $this->addRowError(self::ERROR_WEBSITE_IS_EMPTY, $rowNumber, self::COLUMN_WEBSITE); + } elseif (empty($rowData[self::COLUMN_EMAIL])) { + $this->addRowError(self::ERROR_EMAIL_IS_EMPTY, $rowNumber, self::COLUMN_EMAIL); + } else { + $email = strtolower($rowData[self::COLUMN_EMAIL]); + $website = $rowData[self::COLUMN_WEBSITE]; + $addressId = $rowData[self::COLUMN_ADDRESS_ID]; + + if (!Zend_Validate::is($email, 'EmailAddress')) { + $this->addRowError(self::ERROR_INVALID_EMAIL, $rowNumber, self::COLUMN_EMAIL); + } elseif (!isset($this->_websiteCodeToId[$website])) { + $this->addRowError(self::ERROR_INVALID_WEBSITE, $rowNumber, self::COLUMN_WEBSITE); + } elseif (!$this->_getCustomerId($email, $website)) { + $this->addRowError(self::ERROR_CUSTOMER_NOT_FOUND, $rowNumber); + } else { + $websiteId = $this->_websiteCodeToId[$rowData[self::COLUMN_WEBSITE]]; + $customerId = $this->_customers[$email][$websiteId]; + + // check simple attributes + foreach ($this->_attributes as $attributeCode => $attributeParams) { + if (in_array($attributeCode, $this->_ignoredAttributes)) { + continue; + } + if (isset($rowData[$attributeCode]) && strlen($rowData[$attributeCode])) { + $this->isAttributeValid($attributeCode, $attributeParams, $rowData, $rowNumber); + } elseif ($attributeParams['is_required'] && (!isset($this->_addresses[$customerId]) + || !in_array($addressId, $this->_addresses[$customerId])) + ) { + $this->addRowError(self::ERROR_VALUE_IS_REQUIRED, $rowNumber, $attributeCode); + } + } + + if (isset($rowData[self::COLUMN_COUNTRY_ID]) && isset($rowData[self::COLUMN_REGION])) { + $countryRegions = isset($this->_countryRegions[strtolower($rowData[self::COLUMN_COUNTRY_ID])]) + ? $this->_countryRegions[strtolower($rowData[self::COLUMN_COUNTRY_ID])] + : array(); + + if (!empty($rowData[self::COLUMN_REGION]) + && !empty($countryRegions) + && !isset($countryRegions[strtolower($rowData[self::COLUMN_REGION])]) + ) { + $this->addRowError(self::ERROR_INVALID_REGION, $rowNumber, self::COLUMN_REGION); + } + } + } + } + + return !isset($this->_invalidRows[$rowNumber]); + } + + /** + * Retrieve entity attribute EAV collection + * + * @return Mage_Eav_Model_Resource_Attribute_Collection + */ + protected function _getAttributeCollection() + { + /** @var $addressCollection Mage_Customer_Model_Resource_Address_Attribute_Collection */ + $addressCollection = Mage::getResourceModel('Mage_Customer_Model_Resource_Address_Attribute_Collection'); + $addressCollection->addSystemHiddenFilter() + ->addExcludeHiddenFrontendFilter(); + return $addressCollection; + } +} diff --git a/app/code/core/Mage/ImportExport/Model/Resource/Import/Data.php b/app/code/core/Mage/ImportExport/Model/Resource/Import/Data.php index 721d8dda9f3fd..5decb5c4a6a8e 100644 --- a/app/code/core/Mage/ImportExport/Model/Resource/Import/Data.php +++ b/app/code/core/Mage/ImportExport/Model/Resource/Import/Data.php @@ -86,39 +86,45 @@ public function cleanBunches() /** * Return behavior from import data table. * - * @throws Exception * @return string */ public function getBehavior() { - $adapter = $this->_getReadAdapter(); - $behaviors = array_unique($adapter->fetchCol( - $adapter->select() - ->from($this->getMainTable(), array('behavior')) - )); - if (count($behaviors) != 1) { - Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Error in data structure: behaviors are mixed')); - } - return $behaviors[0]; + return $this->getUniqueColumnData('behavior'); } /** * Return entity type code from import data table. * - * @throws Exception * @return string */ public function getEntityTypeCode() + { + return $this->getUniqueColumnData('entity'); + } + + /** + * Return request data from import data table + * + * @throws Mage_Core_Exception + * + * @param string $code parameter name + * @return string + */ + public function getUniqueColumnData($code) { $adapter = $this->_getReadAdapter(); - $entityCodes = array_unique($adapter->fetchCol( + $values = array_unique($adapter->fetchCol( $adapter->select() - ->from($this->getMainTable(), array('entity')) + ->from($this->getMainTable(), array($code)) )); - if (count($entityCodes) != 1) { - Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Error in data structure: entity codes are mixed')); + + if (count($values) != 1) { + Mage::throwException( + Mage::helper('Mage_ImportExport_Helper_Data')->__('Error in data structure: %s values are mixed', $code) + ); } - return $entityCodes[0]; + return $values[0]; } /** @@ -149,13 +155,19 @@ public function getNextBunch() * @param string $entity * @param string $behavior * @param array $data + * @param string|null $entitySubtype * @return int */ - public function saveBunch($entity, $behavior, array $data) + public function saveBunch($entity, $behavior, array $data, $entitySubtype = null) { return $this->_getWriteAdapter()->insert( $this->getMainTable(), - array('behavior' => $behavior, 'entity' => $entity, 'data' => Mage::helper('Mage_Core_Helper_Data')->jsonEncode($data)) + array( + 'behavior' => $behavior, + 'entity' => $entity, + 'entity_subtype' => $entitySubtype, + 'data' => Mage::helper('Mage_Core_Helper_Data')->jsonEncode($data) + ) ); } } diff --git a/app/code/core/Mage/ImportExport/Model/Source/Export/Format/Version.php b/app/code/core/Mage/ImportExport/Model/Source/Format/Version.php similarity index 81% rename from app/code/core/Mage/ImportExport/Model/Source/Export/Format/Version.php rename to app/code/core/Mage/ImportExport/Model/Source/Format/Version.php index 4f789c0aa474f..8995952a0a561 100644 --- a/app/code/core/Mage/ImportExport/Model/Source/Export/Format/Version.php +++ b/app/code/core/Mage/ImportExport/Model/Source/Format/Version.php @@ -25,23 +25,24 @@ */ /** - * Source model of export format versions + * Source model of import/export format versions * * @category Mage * @package Mage_ImportExport * @author Magento Core Team */ -class Mage_ImportExport_Model_Source_Export_Format_Version + +class Mage_ImportExport_Model_Source_Format_Version { /**#@+ - * Export versions + * Import versions */ - const EXPORT_VERSION_1 = 1; - const EXPORT_VERSION_2 = 2; + const VERSION_1 = 1; + const VERSION_2 = 2; /**#@-*/ /** - * Prepare and return array of available export version file formats + * Prepare and return array of available version file formats * * @return array */ @@ -66,7 +67,7 @@ public function toOptionArray() } /** - * Get possible export format versions + * Get possible format versions * * @return array */ @@ -75,8 +76,8 @@ public function toArray() $helper = Mage::helper('Mage_ImportExport_Helper_Data'); return array( - self::EXPORT_VERSION_1 => $helper->__('Magento 1.7 format'), - self::EXPORT_VERSION_2 => $helper->__('Magento 2.0 format'), + self::VERSION_1 => $helper->__('Magento 1.7 format'), + self::VERSION_2 => $helper->__('Magento 2.0 format'), ); } } diff --git a/app/code/core/Mage/ImportExport/Model/Source/Import/Behavior.php b/app/code/core/Mage/ImportExport/Model/Source/Import/Behavior.php index 4459c24a577a8..ec826155c4cd8 100644 --- a/app/code/core/Mage/ImportExport/Model/Source/Import/Behavior.php +++ b/app/code/core/Mage/ImportExport/Model/Source/Import/Behavior.php @@ -43,6 +43,10 @@ public function toOptionArray() $helper = Mage::helper('Mage_ImportExport_Helper_Data'); return array( + array( + 'value' => '', + 'label' => $helper->__('-- Please Select --') + ), array( 'value' => Mage_ImportExport_Model_Import::BEHAVIOR_APPEND, 'label' => $helper->__('Append Complex Data') diff --git a/app/code/core/Mage/ImportExport/Model/Source/Import/Customer/Entity.php b/app/code/core/Mage/ImportExport/Model/Source/Import/Customer/Entity.php new file mode 100644 index 0000000000000..2d9a9d88d24c9 --- /dev/null +++ b/app/code/core/Mage/ImportExport/Model/Source/Import/Customer/Entity.php @@ -0,0 +1,47 @@ + + */ +class Mage_ImportExport_Model_Source_Import_Customer_Entity +{ + /** + * Prepare and return array of import customer entities ids and their names + * + * @return array + */ + public function toOptionArray() + { + return Mage_ImportExport_Model_Config::getModelsComboOptions( + Mage_ImportExport_Model_Import::CONFIG_KEY_CUSTOMER_ENTITIES + ); + } +} diff --git a/app/code/core/Mage/ImportExport/Model/Source/Import/Entity.php b/app/code/core/Mage/ImportExport/Model/Source/Import/Entity.php index 1396aaf09b4d8..dec677d94cdc4 100644 --- a/app/code/core/Mage/ImportExport/Model/Source/Import/Entity.php +++ b/app/code/core/Mage/ImportExport/Model/Source/Import/Entity.php @@ -40,13 +40,8 @@ class Mage_ImportExport_Model_Source_Import_Entity */ public function toOptionArray() { - $options = array(); - $entities = Mage_ImportExport_Model_Import::CONFIG_KEY_ENTITIES; - $comboOptions = Mage_ImportExport_Model_Config::getModelsComboOptions($entities); - - foreach ($comboOptions as $option) { - $options[] = $option; - } - return $options; + return Mage_ImportExport_Model_Config::getModelsComboOptions( + Mage_ImportExport_Model_Import::CONFIG_KEY_ENTITIES, true + ); } } diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php index 476c57524be20..1f2cc3bbf5490 100644 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php +++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php @@ -53,7 +53,7 @@ protected function _initAction() { $this->_title($this->__('Import/Export')) ->loadLayout() - ->_setActiveMenu('system/importexport'); + ->_setActiveMenu('Mage_ImportExport::system_convert_export'); return $this; } diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php index 2b6787282a768..c3284de20fa6a 100644 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php +++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php @@ -53,7 +53,7 @@ protected function _initAction() { $this->_title($this->__('Import/Export')) ->loadLayout() - ->_setActiveMenu('system/importexport'); + ->_setActiveMenu('Mage_ImportExport::system_convert_import'); return $this; } @@ -121,7 +121,7 @@ public function startAction() } /** - * Validate uploaded files action. + * Validate uploaded files action * * @return void */ @@ -139,6 +139,10 @@ public function validateAction() Mage_ImportExport_Model_Import::FIELD_NAME_IMG_ARCHIVE_FILE) ); + if (!empty($data['customer_entity'])) { + $data['entity_subtype'] = $data['customer_entity']; + } + try { /** @var $import Mage_ImportExport_Model_Import */ $import = Mage::getModel('Mage_ImportExport_Model_Import'); @@ -154,7 +158,9 @@ public function validateAction() ); } elseif ($import->getErrorsCount() >= $import->getErrorsLimit()) { $resultBlock->addNotice( - $this->__('Errors limit (%d) reached. Please fix errors and re-upload file', $import->getErrorsLimit()) + $this->__('Errors limit (%d) reached. Please fix errors and re-upload file', + $import->getErrorsLimit() + ) ); } else { if ($import->isImportAllowed()) { @@ -185,7 +191,12 @@ public function validateAction() } } $resultBlock->addNotice($import->getNotices()); - $resultBlock->addNotice($this->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', $import->getProcessedRowsCount(), $import->getProcessedEntitiesCount(), $import->getInvalidRowsCount(), $import->getErrorsCount())); + $resultBlock->addNotice( + $this->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', + $import->getProcessedRowsCount(), $import->getProcessedEntitiesCount(), + $import->getInvalidRowsCount(), $import->getErrorsCount() + ) + ); } } catch (Exception $e) { $resultBlock->addNotice($this->__('Please fix errors and re-upload file')) diff --git a/app/code/core/Mage/ImportExport/etc/adminhtml.xml b/app/code/core/Mage/ImportExport/etc/adminhtml.xml index bd47e5fe2681e..51d33a0c95d04 100644 --- a/app/code/core/Mage/ImportExport/etc/adminhtml.xml +++ b/app/code/core/Mage/ImportExport/etc/adminhtml.xml @@ -26,26 +26,6 @@ */ --> - - - - - - - Import - adminhtml/import - 10 - - - Export - adminhtml/export - 20 - - - - - - diff --git a/app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml b/app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000..cba1090c9528c --- /dev/null +++ b/app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml @@ -0,0 +1,33 @@ + + + + + + + + diff --git a/app/code/core/Mage/ImportExport/etc/config.xml b/app/code/core/Mage/ImportExport/etc/config.xml index de968597f6e5c..9660a8b4e4060 100644 --- a/app/code/core/Mage/ImportExport/etc/config.xml +++ b/app/code/core/Mage/ImportExport/etc/config.xml @@ -28,7 +28,7 @@ - 1.6.0.2 + 1.6.0.3 @@ -61,6 +61,16 @@ + + + Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer + + + + Mage_ImportExport_Model_Import_Entity_V2_Eav_Customer_Address + + + Mage_ImportExport_Model_Export_Entity_V2_Eav_Customer diff --git a/app/code/core/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/core/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.2-1.6.0.3.php new file mode 100644 index 0000000000000..cba8852b21342 --- /dev/null +++ b/app/code/core/Mage/ImportExport/sql/importexport_setup/upgrade-1.6.0.2-1.6.0.3.php @@ -0,0 +1,37 @@ +getConnection()->addColumn( + $installer->getTable('importexport_importdata'), 'entity_subtype', + array( + 'TYPE' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'LENGTH' => 50, + 'COMMENT' => 'Defines entity subtype to have ability import entity data partially' + ) +); diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/export/form/before.phtml b/app/code/core/Mage/ImportExport/view/adminhtml/export/form/before.phtml index 331ced49c2c28..19018a863f388 100644 --- a/app/code/core/Mage/ImportExport/view/adminhtml/export/form/before.phtml +++ b/app/code/core/Mage/ImportExport/view/adminhtml/export/form/before.phtml @@ -25,7 +25,7 @@ */ ?> diff --git a/app/code/core/Mage/ImportExport/view/adminhtml/import/form/before.phtml b/app/code/core/Mage/ImportExport/view/adminhtml/import/form/before.phtml index 80a5973c8a779..f5a382691108c 100644 --- a/app/code/core/Mage/ImportExport/view/adminhtml/import/form/before.phtml +++ b/app/code/core/Mage/ImportExport/view/adminhtml/import/form/before.phtml @@ -33,6 +33,131 @@ */ varienForm.prototype.ifrElemName = 'import_post_target_frame'; + /** + * Handle value change in entity type selector + * + * @return void + */ + varienForm.prototype.handleEntityTypeSelector = function() + { + if ($('entity') && $F('entity')) { + $('head-import_format_version_fieldset').hide(); + $('import_format_version_fieldset').hide(); + $('file_format_version').selectedIndex = 0; + $('head-customer_entity_fieldset').hide(); + $('customer_entity_fieldset').hide(); + $('customer_entity').disable(); + $('customer_entity').selectedIndex = 0; + $('head-upload_file_fieldset').hide(); + $('upload_file_fieldset').hide(); + this.showAllBehaviours(); + + switch ($F('entity')) { + case 'customer': + $('head-import_format_version_fieldset').show(); + $('import_format_version_fieldset').show(); + $('file_format_version').addClassName('required-entry'); + break; + case 'catalog_product': + $('head-upload_file_fieldset').show(); + $('upload_file_fieldset').show(); + $('file_format_version').removeClassName('required-entry'); + break; + default: + break; + } + } else { + $('head-import_format_version_fieldset').hide(); + $('import_format_version_fieldset').hide(); + $('file_format_version').selectedIndex = 0; + $('head-customer_entity_fieldset').hide(); + $('customer_entity_fieldset').hide(); + $('customer_entity').disable(); + $('customer_entity').selectedIndex = 0; + $('head-upload_file_fieldset').hide(); + $('upload_file_fieldset').hide(); + this.showAllBehaviours(); + } + }; + + /** + * Handle value change in import format version selector + * + * @return void + */ + varienForm.prototype.handleImportFormatVersionSelector = function() + { + if ($('file_format_version') && $F('file_format_version')) { + var allowedBehaviours = []; + Mage_ImportExport_Model_Source_Format_Version::VERSION_1, + 2 => Mage_ImportExport_Model_Source_Format_Version::VERSION_2, + ); + ?> + switch ($F('file_format_version')) { + case '': + $('head-customer_entity_fieldset').hide(); + $('customer_entity_fieldset').hide(); + $('customer_entity').disable(); + $('customer_entity').selectedIndex = 0; + allowedBehaviours = getJsAllowedCustomerBehaviours($importVersion[1]) ?>; + break; + case '': + $('head-customer_entity_fieldset').show(); + $('customer_entity_fieldset').show(); + $('customer_entity').enable(); + allowedBehaviours = getJsAllowedCustomerBehaviours($importVersion[2]) ?>; + break; + default: + break; + } + + // hide not allowed behaviours + if ($('behavior')) { + var behaviourLength = $('behavior').length; + var behaviourOptions = $('behavior').options; + + for (var i = 0; i < behaviourLength; i++) { + if (allowedBehaviours.include(behaviourOptions[i].value)) { + behaviourOptions[i].show(); + } else if (behaviourOptions[i].value != '') { + behaviourOptions[i].hide(); + if (behaviourOptions[i].selected) { + $('behavior').selectedIndex = 0; + } + } + } + } + + $('head-upload_file_fieldset').show(); + $('upload_file_fieldset').show(); + } else { + $('head-customer_entity_fieldset').hide(); + $('customer_entity_fieldset').hide(); + $('customer_entity').disable(); + $('customer_entity').selectedIndex = 0; + $('head-upload_file_fieldset').hide(); + $('upload_file_fieldset').hide(); + } + }; + + /** + * Show all available behaviours + * + * @return void + */ + varienForm.prototype.showAllBehaviours = function() + { + if ($('behavior')) { + var behaviourLength = $('behavior').length; + var behaviourOptions = $('behavior').options; + for (var i = 0; i < behaviourLength; i++) { + behaviourOptions[i].show(); + } + } + }; + /** * Post form data to dynamic iframe. * @@ -45,7 +170,8 @@ // create dynamic frame if (!$(this.ifrElemName)) { $('html-body').insert({ - bottom:'