From 613dacef60ee3522884565c79ccba6108077cdd4 Mon Sep 17 00:00:00 2001 From: Lee Saferite Date: Sun, 3 Jul 2011 20:46:40 +0200 Subject: [PATCH] Import Magento Release 1.6.0.0-rc1 --- RELEASE_NOTES.txt | 226 ++++++++ app/Mage.php | 10 +- .../Catalog/Product/Edit/Tab/Crosssell.php | 1 - .../Product/Helper/Form/Msrp/Enabled.php | 14 +- .../Product/Helper/Form/Msrp/Price.php | 14 +- .../Block/Customer/Edit/Tab/View/Wishlist.php | 34 +- .../Adminhtml/Block/Report/Sales/Tax/Grid.php | 23 + .../Sales/Order/Create/Shipping/Address.php | 13 +- .../Block/Sales/Order/Shipment/Packaging.php | 19 + .../Adminhtml/Block/Widget/Grid/Container.php | 8 +- .../Model/Customer/Renderer/Region.php | 4 +- .../Adminhtml/controllers/CacheController.php | 3 + .../Adminhtml/controllers/PollController.php | 15 +- .../Sales/Order/CreateController.php | 7 +- .../Sales/Order/ShipmentController.php | 2 +- .../core/Mage/Bundle/Model/Product/Price.php | 191 +++---- .../core/Mage/Bundle/Model/Product/Type.php | 1 + app/code/core/Mage/Catalog/Helper/Data.php | 22 +- .../Model/Product/Attribute/Backend/Media.php | 23 +- .../Product/Attribute/Source/Msrp/Type.php | 3 +- .../Attribute/Source/Msrp/Type/Enabled.php | 116 ++++ .../Attribute/Source/Msrp/Type/Price.php | 93 ++++ .../Catalog/Model/Product/Compare/Item.php | 2 +- .../Model/Product/Option/Type/File.php | 41 +- .../Model/Resource/Category/Collection.php | 29 +- .../Catalog/Model/Resource/Eav/Attribute.php | 3 + .../Mage/Catalog/Model/Resource/Product.php | 36 ++ .../Model/Resource/Product/Collection.php | 6 +- .../Product/Link/Product/Collection.php | 37 ++ app/code/core/Mage/Catalog/etc/config.xml | 2 +- .../upgrade-1.6.0.0.3-1.6.0.0.4.php | 56 ++ .../CatalogInventory/Model/Stock/Item.php | 2 +- .../core/Mage/CatalogSearch/Block/Layer.php | 2 +- .../Mage/Centinel/Model/State/Mastercard.php | 9 +- .../Checkout/Model/Resource/Agreement.php | 1 + app/code/core/Mage/Checkout/Model/Session.php | 3 + app/code/core/Mage/Cms/Block/Widget/Block.php | 17 + app/code/core/Mage/Core/Block/Messages.php | 29 + app/code/core/Mage/Core/Block/Template.php | 12 +- .../Mage/Core/Controller/Request/Http.php | 1 + .../Mage/Core/Controller/Varien/Action.php | 1 + app/code/core/Mage/Core/Helper/String.php | 20 + app/code/core/Mage/Core/Helper/Url.php | 10 +- app/code/core/Mage/Core/Model/App.php | 63 ++- app/code/core/Mage/Core/Model/Cache.php | 7 + app/code/core/Mage/Core/Model/Resource.php | 54 +- app/code/core/Mage/Core/Model/Store.php | 3 +- app/code/core/Mage/Core/Model/Website.php | 2 + app/code/core/Mage/Core/etc/config.xml | 3 +- app/code/core/Mage/Core/etc/system.xml | 9 - .../Mage/Customer/Block/Form/Register.php | 4 +- app/code/core/Mage/Customer/Model/Address.php | 22 + .../core/Mage/Customer/Model/Customer.php | 4 +- .../controllers/AccountController.php | 2 +- app/code/core/Mage/Customer/etc/config.xml | 16 + .../Dataflow/Model/Convert/Parser/Csv.php | 8 +- .../Model/Convert/Parser/Xml/Excel.php | 2 +- app/code/core/Mage/Directory/Block/Data.php | 2 +- app/code/core/Mage/Directory/Helper/Data.php | 59 ++- .../Model/Resource/Country/Collection.php | 2 +- .../Directory/Model/Resource/Currency.php | 6 +- .../Downloadable/Product/EditController.php | 1 + .../Mage/Eav/Model/Attribute/Data/Text.php | 2 +- .../Eav/Model/Entity/Collection/Abstract.php | 1 + .../sql/giftmessage_setup/install-1.6.0.0.php | 9 +- .../GoogleCheckout/Model/Api/Xml/Callback.php | 9 +- .../Model/Export/Entity/Product.php | 2 +- .../core/Mage/ImportExport/Model/Import.php | 17 +- .../Model/Import/Entity/Product.php | 153 ++++-- .../Import/Entity/Product/Type/Grouped.php | 28 +- .../ImportExport/Model/Import/Uploader.php | 223 ++++++++ .../Model/Resource/Helper/Mysql4.php | 2 +- .../Mage/Install/Block/Db/Type/Mysql4.php | 2 +- app/code/core/Mage/Log/Model/Cron.php | 5 + .../core/Mage/Newsletter/Model/Subscriber.php | 21 +- .../core/Mage/Page/Block/Template/Links.php | 29 +- app/code/core/Mage/Paypal/Model/Api/Nvp.php | 8 +- app/code/core/Mage/Paypal/Model/Express.php | 13 +- app/code/core/Mage/Paypal/Model/Info.php | 40 ++ app/code/core/Mage/Paypal/Model/Ipn.php | 5 +- .../core/Mage/Paypal/Model/Payflowlink.php | 2 +- app/code/core/Mage/Persistent/Helper/Data.php | 20 + .../core/Mage/Persistent/Model/Observer.php | 151 ++++-- .../Persistent/Model/Observer/Session.php | 8 +- .../Persistent/Model/Persistent/Config.php | 45 +- app/code/core/Mage/Persistent/etc/config.xml | 18 +- .../core/Mage/Persistent/etc/persistent.xml | 12 + app/code/core/Mage/Poll/Block/ActivePoll.php | 160 +++++- .../Mage/Poll/controllers/VoteController.php | 13 + .../Model/Resource/Order/Collection.php | 46 +- .../Model/Resource/Report/Abstract.php | 101 +++- .../core/Mage/Rss/Block/Catalog/Special.php | 25 +- app/code/core/Mage/Rss/Block/Catalog/Tag.php | 1 + app/code/core/Mage/Rss/Block/Wishlist.php | 59 ++- app/code/core/Mage/Sales/Model/Order.php | 4 +- .../core/Mage/Sales/Model/Order/Address.php | 5 + .../Sales/Model/Order/Creditmemo/Item.php | 26 +- .../Model/Order/Creditmemo/Total/Tax.php | 24 +- .../core/Mage/Sales/Model/Order/Payment.php | 5 +- .../Model/Order/Pdf/Shipment/Packaging.php | 90 ++-- .../core/Mage/Sales/Model/Order/Shipment.php | 14 + .../Model/Quote/Address/Total/Subtotal.php | 4 +- .../Model/Resource/Report/Bestsellers.php | 10 +- .../Sales/Model/Resource/Report/Invoiced.php | 19 +- .../Sales/Model/Resource/Report/Order.php | 7 +- .../Sales/Model/Resource/Report/Refunded.php | 17 +- .../Sales/Model/Resource/Report/Shipping.php | 17 +- .../core/Mage/Sales/Model/Service/Quote.php | 6 + .../Sales/controllers/DownloadController.php | 1 + .../sales_setup/upgrade-1.6.0.2-1.6.0.3.php | 2 +- .../SalesRule/Model/Resource/Report/Rule.php | 7 +- .../Mage/Shipping/Model/Carrier/Abstract.php | 2 + .../core/Mage/Shipping/Model/Shipping.php | 8 +- app/code/core/Mage/Tag/Model/Resource/Tag.php | 2 +- .../Mage/Tax/Model/Resource/Calculation.php | 14 +- .../Mage/Tax/Model/Resource/Report/Tax.php | 10 +- .../Tax/sql/tax_setup/install-1.6.0.0.php | 3 +- app/code/core/Mage/Usa/Helper/Data.php | 4 + .../Usa/Model/Shipping/Carrier/Abstract.php | 6 + .../Mage/Usa/Model/Shipping/Carrier/Dhl.php | 64 ++- .../Mage/Usa/Model/Shipping/Carrier/Fedex.php | 41 +- .../Mage/Usa/Model/Shipping/Carrier/Ups.php | 150 +++++- .../Mage/Usa/Model/Shipping/Carrier/Usps.php | 105 ++-- .../Model/Resource/Item/Collection.php | 13 +- .../sql/wishlist_setup/install-1.6.0.0.php | 2 +- .../Block/Adminhtml/Mobile/Edit/Tab/Cache.php | 3 +- .../Edit/Tab/Design/Accordion/Images.php | 9 +- .../Mobile/Edit/Tab/Design/Themes.php | 10 + .../Adminhtml/Mobile/Edit/Tab/General.php | 4 +- .../Adminhtml/Mobile/Edit/Tab/Payment.php | 67 ++- .../Adminhtml/Mobile/Edit/Tab/Social.php | 36 +- app/code/core/Mage/XmlConnect/Block/Cart.php | 44 +- .../Mage/XmlConnect/Block/Cart/Crosssell.php | 56 +- .../core/Mage/XmlConnect/Block/Cart/Info.php | 27 +- .../Block/Cart/Paypal/Mep/Totals.php | 4 +- .../Mage/XmlConnect/Block/Cart/Totals.php | 30 +- .../core/Mage/XmlConnect/Block/Catalog.php | 6 +- .../XmlConnect/Block/Catalog/Category.php | 24 +- .../Block/Catalog/Category/Info.php | 8 +- .../Mage/XmlConnect/Block/Catalog/Filters.php | 9 +- .../Mage/XmlConnect/Block/Catalog/Product.php | 12 +- .../Block/Catalog/Product/Attributes.php | 24 +- .../Block/Catalog/Product/Gallery.php | 10 +- .../XmlConnect/Block/Catalog/Product/List.php | 9 +- .../Block/Catalog/Product/Options.php | 10 +- .../Catalog/Product/Options/Giftcard.php | 2 +- .../Block/Catalog/Product/Options/Grouped.php | 9 +- .../Block/Catalog/Product/Price.php | 8 +- .../Block/Catalog/Product/Related.php | 8 +- .../Block/Catalog/Product/Review.php | 9 +- .../Block/Catalog/Product/Review/List.php | 7 +- .../Mage/XmlConnect/Block/Catalog/Search.php | 15 +- .../Block/Catalog/Search/Suggest.php | 27 +- .../Block/Checkout/Address/Billing.php | 9 +- .../Block/Checkout/Address/Shipping.php | 9 +- .../XmlConnect/Block/Checkout/Agreements.php | 9 +- .../Block/Checkout/Order/Review.php | 16 +- .../Block/Checkout/Order/Review/Info.php | 11 +- .../Checkout/Payment/Method/Authorizenet.php | 27 +- .../Block/Checkout/Payment/Method/Ccsave.php | 8 +- .../Payment/Method/Info/Authorizenet.php | 75 +++ .../Checkout/Payment/Method/Info/Ccsave.php | 62 +++ .../Checkout/Payment/Method/Info/Checkmo.php | 71 +++ .../Payment/Method/Info/Purchaseorder.php | 58 ++ .../Block/Checkout/Payment/Method/List.php | 14 +- .../Payment/Method/Paypal/Payflow.php | 8 +- .../Payment/Method/Pbridge/Abstract.php | 13 +- .../Checkout/Payment/Method/Purchaseorder.php | 8 +- .../Method/{Avaliable.php => Available.php} | 35 +- .../Mage/XmlConnect/Block/Configuration.php | 8 +- .../Block/Customer/Address/Form.php | 22 +- .../Block/Customer/Address/List.php | 13 +- .../Mage/XmlConnect/Block/Customer/Form.php | 9 +- .../Block/Customer/Order/Details.php | 155 ++++++ .../Customer/Order/Item/Renderer/Bundle.php | 468 +++++++++++++++++ .../Customer/Order/Item/Renderer/Default.php | 406 ++++++++++++++ .../Order/Item/Renderer/Downloadable.php | 451 ++++++++++++++++ .../Customer/Order/Item/Renderer/Giftcard.php | 78 +++ .../Customer/Order/Item/Renderer/Grouped.php | 61 +++ .../XmlConnect/Block/Customer/Order/Items.php | 111 ++++ .../XmlConnect/Block/Customer/Order/List.php | 39 +- .../Block/Customer/Order/Totals.php | 146 +++++ .../Customer/Order/Totals/Customerbalance.php | 65 +++ .../Order/Totals/Customerbalance/Refunded.php | 65 +++ .../Block/Customer/Order/Totals/Giftcards.php | 77 +++ .../Block/Customer/Order/Totals/Tax.php | 92 ++++ app/code/core/Mage/XmlConnect/Block/Home.php | 35 +- .../Mage/XmlConnect/Block/Review/Form.php | 73 ++- .../core/Mage/XmlConnect/Block/Wishlist.php | 27 +- .../Mage/XmlConnect/Controller/Action.php | 11 +- .../core/Mage/XmlConnect/Helper/Android.php | 94 ++-- .../Helper/Catalog/Category/Image.php | 30 +- app/code/core/Mage/XmlConnect/Helper/Data.php | 47 +- .../core/Mage/XmlConnect/Helper/Image.php | 91 +++- app/code/core/Mage/XmlConnect/Helper/Ipad.php | 75 +-- .../core/Mage/XmlConnect/Helper/Iphone.php | 188 ++++--- .../core/Mage/XmlConnect/Helper/Theme.php | 178 ++++++- .../Mage/XmlConnect/Model/Application.php | 260 +++++++-- .../core/Mage/XmlConnect/Model/ConfigData.php | 221 ++++++++ .../Collection.php => ConfigData.php} | 6 +- .../Model/Mysql4/ConfigData/Collection.php} | 24 +- .../Model/Payment/Method/Paypal/Mep.php | 21 +- .../XmlConnect/Model/Paypal/Mep/Checkout.php | 31 +- .../Mage/XmlConnect/Model/Preview/Ipad.php | 35 +- app/code/core/Mage/XmlConnect/Model/Queue.php | 16 - .../XmlConnect/Model/Resource/Application.php | 2 +- .../Model/Resource/Category/Collection.php | 96 ---- .../XmlConnect/Model/Resource/ConfigData.php | 107 ++++ .../Model/Resource/ConfigData/Collection.php | 177 +++++++ app/code/core/Mage/XmlConnect/Model/Theme.php | 136 ++++- .../Adminhtml/MobileController.php | 134 +++-- .../XmlConnect/controllers/CartController.php | 8 +- .../controllers/CheckoutController.php | 10 +- .../controllers/CustomerController.php | 98 +++- .../controllers/Paypal/MepController.php | 81 ++- .../controllers/WishlistController.php | 6 +- app/code/core/Mage/XmlConnect/etc/config.xml | 12 +- .../sql/xmlconnect_setup/install-1.6.0.0.php | 42 +- .../mysql4-data-upgrade-1.4.0.13-1.4.0.14.php | 78 +++ .../mysql4-upgrade-1.4.0.13-1.4.0.14.php | 84 +++ .../mysql4-upgrade-1.5.9.9-1.6.0.0.php | 68 ++- .../adminhtml/default/default/layout/main.xml | 2 +- .../sales/order/shipment/packaging/grid.phtml | 9 +- .../order/shipment/packaging/packed.phtml | 36 +- .../order/shipment/packaging/popup.phtml | 8 +- .../edit/tab/design/preview/home_iphone.phtml | 21 +- .../edit/tab/design/preview_ipad.phtml | 3 +- .../form/element/country/androidmarket.phtml | 6 +- .../form/element/country/istore.phtml | 4 +- .../xmlconnect/form/element/themes.phtml | 497 ++++++++++++++---- .../mobile/notification_helper.phtml | 24 +- .../frontend/base/default/layout/bundle.xml | 51 ++ .../base/default/layout/catalog_msrp.xml | 4 + .../base/default/layout/downloadable.xml | 41 +- .../frontend/base/default/layout/page.xml | 3 +- .../base/default/layout/persistent.xml | 9 - .../frontend/base/default/layout/rss.xml | 11 +- .../base/default/layout/xmlconnect.xml | 27 +- .../bundle/catalog/product/price.phtml | 9 +- .../catalog/product/price_msrp_item.phtml | 3 +- .../catalog/product/price_msrp_rss.phtml | 19 +- .../template/checkout/cart/sidebar.phtml | 2 +- .../template/checkout/cart/totals.phtml | 2 +- .../persistent/checkout/onepage/billing.phtml | 13 +- .../persistent/customer/form/register.phtml | 2 +- .../wishlist/render/item/price_msrp_rss.phtml | 38 ++ .../frontend/default/iphone/layout/page.xml | 2 - .../frontend/default/modern/layout/page.xml | 1 - app/locale/en_US/Mage_Adminhtml.csv | 11 +- app/locale/en_US/Mage_Api.csv | 11 +- app/locale/en_US/Mage_Catalog.csv | 2 +- app/locale/en_US/Mage_Checkout.csv | 3 +- app/locale/en_US/Mage_Core.csv | 1 - app/locale/en_US/Mage_Eav.csv | 1 + app/locale/en_US/Mage_Paypal.csv | 4 + app/locale/en_US/Mage_Rss.csv | 1 - app/locale/en_US/Mage_Sales.csv | 8 +- app/locale/en_US/Mage_Usa.csv | 5 +- app/locale/en_US/Mage_Wishlist.csv | 1 + app/locale/en_US/Mage_XmlConnect.csv | 56 +- downloader/Maged/Connect.php | 66 ++- downloader/Maged/Controller.php | 56 +- downloader/Maged/Model/Connect/Request.php | 2 +- get.php | 10 +- js/extjs/ext-tree.js | 272 ++++++++-- js/extjs/ext-tree.orig.js | 243 --------- js/mage/adminhtml/sales/packaging.js | 7 +- js/prototype/deprecation.js | 374 ------------- lib/Varien/Db/Adapter/Pdo/Mysql.php | 41 +- lib/Varien/Db/Ddl/Table.php | 22 +- lib/Varien/File/Uploader.php | 17 +- lib/Varien/Image/Adapter/Gd2.php | 8 +- .../design_default/banner_ipad_l.png | Bin 0 -> 43342 bytes .../mobile_preview/ipad/banner_image_l.png | Bin 0 -> 14091 bytes .../images/xmlconnect/swatch_user_custom.gif | Bin 0 -> 209 bytes .../default/xmlconnect/mobile-ipad-home.css | 4 +- .../default/default/xmlconnect/styles.css | 27 +- skin/frontend/base/default/js/msrp.js | 7 +- ....1.0-beta1.xml => Find_Feed-1.1.0-rc1.xml} | 10 +- ...terface_Adminhtml_Default-1.6.0.0-rc1.xml} | 12 +- ...ace_Frontend_Base_Default-1.6.0.0-rc1.xml} | 12 +- ...nterface_Frontend_Default-1.6.0.0-rc1.xml} | 10 +- ...Interface_Install_Default-1.6.0.0-rc1.xml} | 10 +- var/package/Lib_Js_Ext-1.6.0.0-rc1.xml | 18 + ...-beta1.xml => Lib_Js_Mage-1.6.0.0-rc1.xml} | 10 +- ...0.0-beta1.xml => Lib_Mage-1.6.0.0-rc1.xml} | 8 +- ...0-beta1.xml => Lib_Varien-1.6.0.0-rc1.xml} | 10 +- var/package/Mage_All_Latest-1.6.0.0-beta1.xml | 18 - var/package/Mage_All_Latest-1.6.0.0-rc1.xml | 18 + ...eta1.xml => Mage_Centinel-1.6.0.0-rc1.xml} | 12 +- ...eta1.xml => Mage_Compiler-1.6.0.0-rc1.xml} | 10 +- ...ml => Mage_Core_Adminhtml-1.6.0.0-rc1.xml} | 12 +- .../Mage_Core_Modules-1.6.0.0-beta1.xml | 18 - var/package/Mage_Core_Modules-1.6.0.0-rc1.xml | 18 + ...a1.xml => Mage_Downloader-1.6.0.0-rc1.xml} | 10 +- ....xml => Mage_Locale_en_US-1.6.0.0-rc1.xml} | 10 +- var/package/Magento_Mobile-1.5.0.0.21.0.xml | 19 + ...xml => Phoenix_Moneybookers-1.3.0-rc1.xml} | 10 +- 298 files changed, 8923 insertions(+), 2569 deletions(-) create mode 100644 app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type/Enabled.php create mode 100644 app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type/Price.php create mode 100644 app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.3-1.6.0.0.4.php create mode 100644 app/code/core/Mage/ImportExport/Model/Import/Uploader.php create mode 100755 app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Authorizenet.php create mode 100755 app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Ccsave.php create mode 100755 app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Checkmo.php create mode 100755 app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Purchaseorder.php rename app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/{Avaliable.php => Available.php} (61%) create mode 100755 app/code/core/Mage/XmlConnect/Block/Customer/Order/Details.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Bundle.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Default.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Downloadable.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Giftcard.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Grouped.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Items.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance/Refunded.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Giftcards.php create mode 100644 app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Tax.php create mode 100644 app/code/core/Mage/XmlConnect/Model/ConfigData.php rename app/code/core/Mage/XmlConnect/Model/Mysql4/{Category/Collection.php => ConfigData.php} (85%) rename app/code/core/Mage/{Wishlist/Model/Resource/Helper/Mysql4.php => XmlConnect/Model/Mysql4/ConfigData/Collection.php} (59%) delete mode 100755 app/code/core/Mage/XmlConnect/Model/Resource/Category/Collection.php create mode 100644 app/code/core/Mage/XmlConnect/Model/Resource/ConfigData.php create mode 100644 app/code/core/Mage/XmlConnect/Model/Resource/ConfigData/Collection.php create mode 100644 app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-data-upgrade-1.4.0.13-1.4.0.14.php create mode 100644 app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-upgrade-1.4.0.13-1.4.0.14.php create mode 100644 app/design/frontend/base/default/template/wishlist/render/item/price_msrp_rss.phtml delete mode 100644 js/extjs/ext-tree.orig.js delete mode 100644 js/prototype/deprecation.js create mode 100644 skin/adminhtml/default/default/images/xmlconnect/design_default/banner_ipad_l.png create mode 100644 skin/adminhtml/default/default/images/xmlconnect/mobile_preview/ipad/banner_image_l.png create mode 100644 skin/adminhtml/default/default/images/xmlconnect/swatch_user_custom.gif rename var/package/{Find_Feed-1.1.0-beta1.xml => Find_Feed-1.1.0-rc1.xml} (94%) rename var/package/{Interface_Adminhtml_Default-1.6.0.0-beta1.xml => Interface_Adminhtml_Default-1.6.0.0-rc1.xml} (98%) rename var/package/{Interface_Frontend_Base_Default-1.6.0.0-beta1.xml => Interface_Frontend_Base_Default-1.6.0.0-rc1.xml} (89%) rename var/package/{Interface_Frontend_Default-1.6.0.0-beta1.xml => Interface_Frontend_Default-1.6.0.0-rc1.xml} (98%) rename var/package/{Interface_Install_Default-1.6.0.0-beta1.xml => Interface_Install_Default-1.6.0.0-rc1.xml} (94%) create mode 100644 var/package/Lib_Js_Ext-1.6.0.0-rc1.xml rename var/package/{Lib_Js_Mage-1.6.0.0-beta1.xml => Lib_Js_Mage-1.6.0.0-rc1.xml} (96%) rename var/package/{Lib_Mage-1.6.0.0-beta1.xml => Lib_Mage-1.6.0.0-rc1.xml} (97%) rename var/package/{Lib_Varien-1.6.0.0-beta1.xml => Lib_Varien-1.6.0.0-rc1.xml} (96%) delete mode 100644 var/package/Mage_All_Latest-1.6.0.0-beta1.xml create mode 100644 var/package/Mage_All_Latest-1.6.0.0-rc1.xml rename var/package/{Mage_Centinel-1.6.0.0-beta1.xml => Mage_Centinel-1.6.0.0-rc1.xml} (93%) rename var/package/{Mage_Compiler-1.6.0.0-beta1.xml => Mage_Compiler-1.6.0.0-rc1.xml} (88%) rename var/package/{Mage_Core_Adminhtml-1.6.0.0-beta1.xml => Mage_Core_Adminhtml-1.6.0.0-rc1.xml} (97%) delete mode 100644 var/package/Mage_Core_Modules-1.6.0.0-beta1.xml create mode 100644 var/package/Mage_Core_Modules-1.6.0.0-rc1.xml rename var/package/{Mage_Downloader-1.6.0.0-beta1.xml => Mage_Downloader-1.6.0.0-rc1.xml} (95%) rename var/package/{Mage_Locale_en_US-1.6.0.0-beta1.xml => Mage_Locale_en_US-1.6.0.0-rc1.xml} (86%) create mode 100644 var/package/Magento_Mobile-1.5.0.0.21.0.xml rename var/package/{Phoenix_Moneybookers-1.3.0-beta1.xml => Phoenix_Moneybookers-1.3.0-rc1.xml} (97%) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 8cd4892816..92bf8499c9 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,3 +1,229 @@ +==== 1.6.0.0-rc1 ==== + +=== Major Highlights === +Minimum Advertised Price +Persistent Shopping Cart + +=== Improvements === +XmlConnect package release v21 +Order Payment Action for Express Checkout (PayPal) +- Added settings Authorization Honor Period and Order Valid Period into EC tab in the backend +- Automatically new authorize transaction created after order transaction +- Automatically cancel order after the expiration of Order Valid Period +- Automatically authorize transaction void\create after the expiration of Authorization Honor Period +Implemented Authorize.Net 'hold for review' status shows up as 'declined' in Magento. +Add Dynamic sku option for configurable products +Moneybookers Multistore System Configuration +Moneybookers OBT Defaults +PrototypeJS upgraded to 1.7 + +=== Changes === +Removed deprecation.js because its not compatible with prototype 1.7 +Relations between models and resource models were revised for better support of multiple databases +* Varien_Db_Adapter_Pdo_Mysql revised +* Introduced Varien_Db_Adapter_Interface, Varien_Db_Ddl_Table +* Introduced new classes named resource helpers +* Backwards comatibility and known issues +** Flat attribute definition is not backward compatible +** Old columns names are not fully mapped to new ones +** Error appears after Customer Group saving with name length more than 32 +** Caching config in Database results in endless recursion +** There's no sql upgrade for media storage tables +Deprecated GoogleBase module (http://googlemerchantblog.blogspot.com/2010/12/new-shopping-apis-and-deprecation-of.html) + +=== Fixes === +Fixed Upgrade checking after cache flushed +Fixed Frontend: Tier price not always applied to Mini Shopping Cart +Fixed A message for the case when shipping label is created from the order should be modified +Fixed Spelling mistake in abbreviations unit of mass measurement (lbs, kgs) +Fixed FedEx Ground Shipping Method unavailable (if others FedEx Shipping Methods unavailable) +Fixed Incorrect Signature Confirmation options in the drop-down (in case with UPS) +Fixed Frontend: Catalog Price Rule does not apply to Mini Shopping Cart after login current customer +- add recollect total prices for quote on customer register +Fixed Fatal error when requesting non-existent file from Media directory +Fixed Button "Add to Cart" located in JS-popup (with Display Actual Price = On Gesture) doesn't work. +Fixed Headers sent twice or three times when file downloading +Fixed Shipping method is calculating based on default shipping address instead of 'Same as billing' setting in backend +Fixed No ability to create more that one online Partial Invoice with Google Checkout +- parent transaction will be closed on payment model level; +- fixed exception error in Mage_Tax_Model_Resource_Calculation +Fixed Cross Sell Sorting Not Working +Fixed No ability to create Shipping Label for USPS - First-Class Mail International Package +Fixed Notification remove link in admin redirects to homepage on frontend in IE8 +Fixed Incorrect behavior of image gallery +Fixed 'On Gesture' option is not applied on products' level +Fixed The message that appears instead or totals in the shopping cart and mini shopping cart should be modified +Fixed Void button present when order is fully invoiced +Fixed No ability to create Shipping Label with package type "Flat-Rate Box" (in case with USPS International) +Fixed MAP behavior for RSS feed pages should be changed (only "Click for price" link should be present) +Fixed PayflowLink doesn't work (error "Payment has been declined. Please try again." is shown, Order is canceled) +Fixed Incorrect Online Refund amount in Magento, when Adjustment Fee is specified (Google Checkout) +Fixed Brazil PayPal requirements upgrade +Fixed No ability to create Shipping Label with package type "Flat-Rate Box" (in case with USPS International) +Fixed Issue with add to cart action, possible to add to cart a quantity of N+1 for a product. +Fixed No ability to create Shipping Label if "ship to" in Canada (in case with UPS) +Fixed Wrong content in export file (all export types) +Fixed "Mysql" must be renamed to "MySQL" in installer +Fixed File overwriting during Import/Export. +Fixed Reuse of adapter utilities in helper +Fixed MAP behavior for RSS feed pages should be changed (only "Click for price" link should be present) +Fixed When changing locale that has Unicode characters, the countries are not sorting correctly +Fixed Importing customers via csv +Fixed Two void transactions created when using Payment Action = Order in PayPal Express +Fixed Issue with newsletter subscriptions and logged in customers +Fixed Frontend: Long-term cookie session is not over after click on "(Not..?)" link +Fixed Mismatch counts of products for different scope +Fixed Wrong config setting are implemented for MAP functionality in admin on product's level +Fixed Street Address and Street Address 2 are mixed up in request to shipping carrier (in case with USPS International) +Fixed No ability to create Shipping Label if "ship to" in Canada (in case with UPS) +- fixed MonetaryValue to be whole number +Fixed Package Types that not available for current Shipping Method displayed in Create Packages pop-up +Fixed Add verification into predispatch observers used in persistent shopping cart +Fixed Canceled orders should be excluded from Tax Reports +Fixed No ability to create Shipping Label with package type "Flat-Rate Box" (in case with USPS International) +Fixed Import/Export: Append Complex Data works incorrect with grouped products +- check behavior was added +Fixed Fatal error appears on get shipping rates for UPS if system base currency <> merchant country currency +Fixed Map in the frontend link has "Click to see price" name, but must be "Click for price" +Fixed Taxes are not displayed in the catalog from frontend for Bundle products +Fixed Available to delete dropdown attribute which used in configurable product +Fixed MySQL error with "max_allowed_packet" during check data step for a huge .csv file +- Changed value for constant DB_MAX_PACKET_COEFFICIENT in Mage_ImportExport_Model_Resource_Helper_Mysql4 +Fixed Invalid requests to USPS API +Fixed No ability to input some value in dimensions field in case for package type with non-standard dimensions +Fixed Packages Pop-up looks incorrectly +Fixed Caching config in Database results in endless recursion +Fixed Shipping origin address used instead of the one specified in the RMA setting for Use Store Address = No +Fixed No Signature Confirmation in Packages pop-up +Fixed Package Types that not available for current Shipping Method displayed in Create Packages pop-up +Fixed "NaN" instead of two dashes in Package pop-up (in case with disabled Length, Width and Height fields) +Fixed Prefix and suffix aren't visible in Register Form +- Modified persistent customer templates +Fixed Unable to Checkout with Multiple Addresses with Registration +Fixed Not work shipping methods Fedex & DHL +- Re-factored DHL, Fedex, Ups, Usps +- Fixed minor bugs for frontend(package.phtml, view.phtml) and backend(popup.phtml, shippingmethod.phtml) +Fixed When we do reindex from console, folder var/log changes permissions from 0777 to 0775 +Fixed Package Types that not available for current Shipping Method displayed in Create Packages pop-up +Fixed Orders placed through PayPal marked as "Suspected Fraud" +- Added formatting amount into comparing +Fixed Enable Log Cleaning option is not working properly +Fixed Impossible to do online refund for "CyberSource" payment method +Fixed Incorrect transparency of PNG image in indexed non-alpha mode +Fixed Value from Total Weight field is not passed to shipping carrier (in case with DHL and UPS) +Fixed After enabling dashboard chart admin user is unable to login to admin panel +Fixed Sorting on Please Select products to Add doesn't work +Fixed Catalog Price Rules - the rule is saved but not applied +Fixed Package Types that not available for current Shipping Method displayed in Create Packages pop-up +Fixed Cross Sell Sorting Not Working +Fixed Error when obtaining missed file over get.php +Fixed Package Types that not available for current Shipping Method displayed in Create Packages pop-up +Fixed Unable to save Poll for more than one Store. +Fixed Mage_Directory_Helper_Data::getRegionJson doesn't translate region names +Fixed Static block in the Main Content Area overlaps border of the catalog of products +Fixed 3D secure with Saved CC works incorrectly +Fixed Shipping origin address used instead of the one specified in the RMA setting for Use Store Address = No +Fixed Unable add Gift Options for Individual Items +Fixed Customer Reports +- avoid selections group by null customer id. +Fixed Mysql4 install error +Fixed "What's this?" link is absent, "Click for price" link doesn't work for shared Wishlist page. +Fixed Incorrect Row Total Calculation in Refund +- changed tax counting algorithm(now it counts tax for single item) +Fixed Incorrect recipient name of Shipping Label +Fixed Missing "Street Address Line 2" in Shipping Label (in case with DHL) +Fixed After upgrading Magento website left in the maintenance mode +Fixed Frontend: JavaScript error appears if user registered on Checkout Page. +Fixed Added items to the Wishlist in the "Manage Shopping Cart" are not shown +Fixed Information is not saved in DB after placing order during checkout +Fixed Reports data wrong even after refreshing lifetime statistics +Fixed Frontend can be broken by recursion +Fixed Sub items are not displayed for the order for bundles, if user use Return and Orders link +- added renderers for non-simple product types +Fixed Error message for the case when store information is incomplete should be changed +Fixed MAP behavior for RSS feed pages should be changed accordingly to SRS (only "Click for price" link should be present) +Fixed Exception after upgrade Magento via diff files +Fixed Frontend: The block "Compare Products" is empty after relogin +Fixed Frontend: Catalog Price Rule does not apply to Mini Shopping Cart after login current customer +- remove checking if customerGroupId exists because quote is loaded with existed customerGroupId as guest +Fixed Unable to delete product with tag in pending status +Fixed Images not imported using new Import/Export + + + +==== 1.6.x-devel-112177 ==== + +=== Improvements === +XmlConnect package release v21 + +=== Changes === +Removed deprecation.js because its not compatible with prototype 1.7 + +=== Fixes === +Fixed MySQL error with "max_allowed_packet" during check data step for a huge .csv file +- Changed value for constant DB_MAX_PACKET_COEFFICIENT in Mage_ImportExport_Model_Resource_Helper_Mysql4 +Fixed Invalid requests to USPS API +Fixed No ability to input some value in dimensions field in case for package type with non-standard dimensions +Fixed Packages Pop-up looks incorrectly +Fixed Caching config in Database results in endless recursion +Fixed Shipping origin address used instead of the one specified in the RMA setting for Use Store Address = No +Fixed No Signature Confirmation in Packages pop-up +Fixed Package Types that not available for current Shipping Method displayed in Create Packages pop-up +Fixed "NaN" instead of two dashes in Package pop-up (in case with disabled Length, Width and Height fields) +Fixed Prefix and suffix aren't visible in Register Form +- Modified persistent customer templates +Fixed Unable to Checkout with Multiple Addresses with Registration +Fixed Not work shipping methods Fedex & DHL +- Re-factored DHL, Fedex, Ups, Usps +- Fixed minor bugs for frontend(package.phtml, view.phtml) and backend(popup.phtml, shippingmethod.phtml) +Fixed When we do reindex from console, folder var/log changes permissions from 0777 to 0775 +Fixed Package Types that not available for current Shipping Method displayed in Create Packages pop-up +Fixed Orders placed through PayPal marked as "Suspected Fraud" +- Added formatting amount into comparing +Fixed Enable Log Cleaning option is not working properly +Fixed Impossible to do online refund for "CyberSource" payment method +Fixed Incorrect transparency of PNG image in indexed non-alpha mode +Fixed Value from Total Weight field is not passed to shipping carrier (in case with DHL and UPS) +Fixed After enabling dashboard chart admin user is unable to login to admin panel +Fixed Sorting on Please Select products to Add doesn't work +Fixed Catalog Price Rules - the rule is saved but not applied +Fixed Package Types that not available for current Shipping Method displayed in Create Packages pop-up +Fixed Cross Sell Sorting Not Working +Fixed Error when obtaining missed file over get.php +Fixed Package Types that not available for current Shipping Method displayed in Create Packages pop-up +Fixed Unable to save Poll for more than one Store. +Fixed Mage_Directory_Helper_Data::getRegionJson doesn't translate region names +Fixed Static block in the Main Content Area overlaps border of the catalog of products +Fixed 3D secure with Saved CC works incorrectly +Fixed Shipping origin address used instead of the one specified in the RMA setting for Use Store Address = No +Fixed Unable add Gift Options for Individual Items +Fixed Customer Reports +- avoid selections group by null customer id. +Fixed Mysql4 install error +Fixed "What's this?" link is absent, "Click for price" link doesn't work for shared Wishlist page. +Fixed Incorrect Row Total Calculation in Refund +- changed tax counting algorithm(now it counts tax for single item) +Fixed Incorrect recipient name of Shipping Label +Fixed Missing "Street Address Line 2" in Shipping Label (in case with DHL) +Fixed After upgrading Magento website left in the maintenance mode +Fixed Frontend: JavaScript error appears if user registered on Checkout Page. +Fixed Added items to the Wishlist in the "Manage Shopping Cart" are not shown +Fixed Information is not saved in DB after placing order during checkout +Fixed Reports data wrong even after refreshing lifetime statistics +Fixed Frontend can be broken by recursion +Fixed Sub items are not displayed for the order for bundles, if user use Return and Orders link +- added renderers for non-simple product types +Fixed Error message for the case when store information is incomplete should be changed +Fixed MAP behavior for RSS feed pages should be changed accordingly to SRS (only "Click for price" link should be present) +Fixed Exception after upgrade Magento via diff files +Fixed Frontend: The block "Compare Products" is empty after relogin +Fixed Frontend: Catalog Price Rule does not apply to Mini Shopping Cart after login current customer +- remove checking if customerGroupId exists because quote is loaded with existed customerGroupId as guest +Fixed Unable to delete product with tag in pending status +Fixed Images not imported using new Import/Export + + + ==== 1.6.0.0-beta1 ==== === Major Highlights === diff --git a/app/Mage.php b/app/Mage.php index 9ab464fe6b..d8ee0c2353 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -154,7 +154,7 @@ public static function getVersionInfo() 'minor' => '6', 'revision' => '0', 'patch' => '0', - 'stability' => 'beta', + 'stability' => 'rc', 'number' => '1', ); } @@ -731,10 +731,12 @@ public static function log($message, $level = null, $file = '', $forceLog = fals try { if (!isset($loggers[$file])) { - $logFile = self::getBaseDir('var') . DS . 'log' . DS . $file; + $logDir = self::getBaseDir('var') . DS . 'log'; + $logFile = $logDir . DS . $file; - if (!is_dir(self::getBaseDir('var').DS.'log')) { - mkdir(self::getBaseDir('var').DS.'log', 0777); + if (!is_dir($logDir)) { + mkdir($logDir); + chmod($logDir, 0777); } if (!file_exists($logFile)) { diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php index 615aed8412..831a00f87b 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php @@ -99,7 +99,6 @@ protected function _prepareCollection() $collection = Mage::getModel('catalog/product_link')->useCrossSellLinks() ->getProductCollection() ->setProduct($this->_getProduct()) - ->setPositionOrder() ->addAttributeToSelect('*'); if ($this->isReadonly()) { diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php index f687ae41ba..02358d5e42 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Enabled.php @@ -31,17 +31,19 @@ * @package Mage_Adminhtml * @author Magento Core Team */ -class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Msrp_Enabled - extends Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Config +class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Msrp_Enabled extends Varien_Data_Form_Element_Select { /** - * Get config value data + * Retrieve Element HTML fragment * - * @return bool + * @return string */ - protected function _getValueFromConfig() + public function getElementHtml() { - return Mage::helper('catalog')->isMsrpApplyToAll(); + if (is_null($this->getValue())) { + $this->setValue(Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Enabled::MSRP_ENABLE_USE_CONFIG); + } + return parent::getElementHtml(); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php index 35b7721e23..af67119cdf 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Msrp/Price.php @@ -31,17 +31,19 @@ * @package Mage_Adminhtml * @author Magento Core Team */ -class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Msrp_Price - extends Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Config +class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Msrp_Price extends Varien_Data_Form_Element_Select { /** - * Get config value data + * Retrieve Element HTML fragment * - * @return null|string + * @return string */ - protected function _getValueFromConfig() + public function getElementHtml() { - return Mage::helper('catalog')->getMsrpDisplayActualPriceType(); + if (is_null($this->getValue())) { + $this->setValue(Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Price::TYPE_USE_CONFIG); + } + return parent::getElementHtml(); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php index 954ed105df..5913958086 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php @@ -29,11 +29,15 @@ * * @category Mage * @package Mage_Adminhtml - * @author Magento Core Team + * @author Magento Core Team */ class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Wishlist extends Mage_Adminhtml_Block_Widget_Grid { - + /** + * Initial settings + * + * @return void + */ public function __construct() { parent::__construct(); @@ -44,6 +48,11 @@ public function __construct() $this->setEmptyText(Mage::helper('customer')->__("There are no items in customer's wishlist at the moment")); } + /** + * Prepare collection + * + * @return Mage_Adminhtml_Block_Customer_Edit_Tab_View_Wishlist + */ protected function _prepareCollection() { $wishlist = Mage::getModel('wishlist/wishlist'); @@ -59,6 +68,11 @@ protected function _prepareCollection() return parent::_prepareCollection(); } + /** + * Prepare columns + * + * @return Mage_Adminhtml_Block_Customer_Edit_Tab_View_Wishlist + */ protected function _prepareColumns() { $this->addColumn('product_id', array( @@ -70,7 +84,8 @@ protected function _prepareColumns() $this->addColumn('product_name', array( 'header' => Mage::helper('customer')->__('Product Name'), - 'index' => 'product_name' + 'index' => 'product_name', + 'renderer' => 'adminhtml/customer_edit_tab_view_grid_renderer_item' )); if (!Mage::app()->isSingleStoreMode()) { @@ -99,15 +114,24 @@ protected function _prepareColumns() return parent::_prepareColumns(); } + /** + * Get headers visibility + * + * @return bool + */ public function getHeadersVisibility() { return ($this->getCollection()->getSize() > 0); } + /** + * Get row url + * + * @param Mage_Wishlist_Model_Item $item + * @return string + */ public function getRowUrl($row) { return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId())); } - } - diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php index 47a3274b3c..874715ff1f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php @@ -105,4 +105,27 @@ protected function _prepareColumns() return parent::_prepareColumns(); } + + /** + * Preparing collection + * Filter canceled statuses for orders in taxes + * + *@return Mage_Adminhtml_Block_Report_Sales_Tax_Grid + */ + protected function _prepareCollection() + { + $filterData = $this->getFilterData(); + if(!$filterData->hasData('order_statuses')) { + $orderConfig = Mage::getModel('sales/order_config'); + $statusValues = array(); + $canceledStatuses = $orderConfig->getStateStatuses(Mage_Sales_Model_Order::STATE_CANCELED); + foreach ($orderConfig->getStatuses() as $code => $label) { + if (!isset($canceledStatuses[$code])) { + $statusValues[] = $code; + } + } + $filterData->setOrderStatuses($statusValues); + } + return parent::_prepareCollection(); + } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php index 66943f9a97..944e307d8e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php @@ -98,7 +98,7 @@ public function getIsAsBilling() */ public function getFormValues() { - return $this->getCreateOrderModel()->getShippingAddress()->getData(); + return $this->getAddress()->getData(); } /** @@ -108,17 +108,22 @@ public function getFormValues() */ public function getAddressId() { - return $this->getCreateOrderModel()->getShippingAddress()->getCustomerAddressId(); + return $this->getAddress()->getCustomerAddressId(); } /** - * Return billing address object + * Return address object * * @return Mage_Customer_Model_Address */ public function getAddress() { - return $this->getCreateOrderModel()->getShippingAddress(); + if ($this->getIsAsBilling()) { + $address = $this->getCreateOrderModel()->getBillingAddress(); + } else { + $address = $this->getCreateOrderModel()->getShippingAddress(); + } + return $address; } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php index eb85728c03..d7bfe807f7 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php @@ -141,6 +141,7 @@ protected function _getCustomizableContainers() /** * Return name of container type by its code * + * @param string $code * @return string */ public function getContainerTypeByCode($code) @@ -154,6 +155,24 @@ public function getContainerTypeByCode($code) return ''; } + /** + * Return name of delivery confirmation type by its code + * + * @param string $code + * @return string + */ + public function getDeliveryConfirmationTypeByCode($code) + { + $countryId = $this->getShipment()->getOrder()->getShippingAddress()->getCountryId(); + $carrier = $this->getShipment()->getOrder()->getShippingCarrier(); + if ($carrier) { + $confirmationTypes = $carrier->getDeliveryConfirmationTypes($countryId); + $confirmationType = !empty($confirmationTypes[$code]) ? $confirmationTypes[$code] : ''; + return $confirmationType; + } + return ''; + } + /** * Get packed products in packages * diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php index fd2e9e04c4..7835ae7c65 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php @@ -41,8 +41,12 @@ class Mage_Adminhtml_Block_Widget_Grid_Container extends Mage_Adminhtml_Block_Wi public function __construct() { - $this->_addButtonLabel = $this->__('Add New'); - $this->_backButtonLabel = $this->__('Back'); + if (is_null($this->_addButtonLabel)) { + $this->_addButtonLabel = $this->__('Add New'); + } + if(is_null($this->_backButtonLabel)) { + $this->_backButtonLabel = $this->__('Back'); + } parent::__construct(); diff --git a/app/code/core/Mage/Adminhtml/Model/Customer/Renderer/Region.php b/app/code/core/Mage/Adminhtml/Model/Customer/Renderer/Region.php index 7df04959a3..7380416424 100644 --- a/app/code/core/Mage/Adminhtml/Model/Customer/Renderer/Region.php +++ b/app/code/core/Mage/Adminhtml/Model/Customer/Renderer/Region.php @@ -64,7 +64,7 @@ public function render(Varien_Data_Form_Element_Abstract $element) $regionCollection = self::$_regionCollections[$countryId]; } - $regionId = $element->getForm()->getElement('region_id')->getValue(); + $regionId = intval($element->getForm()->getElement('region_id')->getValue()); $htmlAttributes = $element->getHtmlAttributes(); foreach ($htmlAttributes as $key => $attribute) { @@ -92,7 +92,7 @@ public function render(Varien_Data_Form_Element_Abstract $element) . $element->serialize($htmlAttributes) .'>' . "\n"; foreach ($regionCollection as $region) { $selected = ($regionId==$region['value']) ? ' selected="selected"' : ''; - $html.= ''; + $html.= ''; } $html.= '' . "\n"; diff --git a/app/code/core/Mage/Adminhtml/controllers/CacheController.php b/app/code/core/Mage/Adminhtml/controllers/CacheController.php index af4b01d7d3..f054b59eab 100644 --- a/app/code/core/Mage/Adminhtml/controllers/CacheController.php +++ b/app/code/core/Mage/Adminhtml/controllers/CacheController.php @@ -54,6 +54,7 @@ public function indexAction() public function flushAllAction() { Mage::app()->getCacheInstance()->flush(); + Mage::dispatchEvent('adminhtml_cache_flush_all'); $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("The cache storage has been flushed.")); $this->_redirect('*/*'); } @@ -64,6 +65,7 @@ public function flushAllAction() public function flushSystemAction() { Mage::app()->cleanCache(); + Mage::dispatchEvent('adminhtml_cache_flush_system'); $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("The Magento cache storage has been flushed.")); $this->_redirect('*/*'); } @@ -123,6 +125,7 @@ public function massRefreshAction() if (!empty($types)) { foreach ($types as $type) { $tags = Mage::app()->getCacheInstance()->cleanType($type); + Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => $type)); $updatedTypes++; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/PollController.php b/app/code/core/Mage/Adminhtml/controllers/PollController.php index 38e1e4a868..a380ee944e 100644 --- a/app/code/core/Mage/Adminhtml/controllers/PollController.php +++ b/app/code/core/Mage/Adminhtml/controllers/PollController.php @@ -143,8 +143,19 @@ public function validateAction() if (is_array($stores)) { $storeIds = array(); - foreach ($stores as $storeId) { - $storeIds[] = $storeId; + foreach ($stores as $storeIdList) { + $storeIdList = explode(',', $storeIdList); + if(!$storeIdList) { + continue; + } + foreach($storeIdList as $storeId) { + if( $storeId > 0 ) { + $storeIds[] = $storeId; + } + } + } + if (count($storeIds) === 0) { + Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.')); } $pollModel->setStoreIds($storeIds); } 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 cc15a01a5d..78fe6831fa 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php @@ -153,7 +153,12 @@ protected function _processActionData($action = null) */ if (!$this->_getOrderCreateModel()->getQuote()->isVirtual()) { $syncFlag = $this->getRequest()->getPost('shipping_as_billing'); - if (!is_null($syncFlag)) { + if (is_null($syncFlag) + && $this->_getOrderCreateModel()->getShippingAddress()->getSameAsBilling() + && is_null($this->_getOrderCreateModel()->getShippingMethod()) + ) { + $this->_getOrderCreateModel()->setShippingAsBilling(1); + } else { $this->_getOrderCreateModel()->setShippingAsBilling((int)$syncFlag); } } 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 4b2beea24f..77916fa02b 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php @@ -215,7 +215,7 @@ public function saveAction() if ($isNeedCreateLabel) { if ($this->_createShippingLabel($shipment)) { $this->_getSession() - ->addSuccess($this->__('The shipment has been created. The shipping label has been created')); + ->addSuccess($this->__('The shipment has been created. The shipping label has been created.')); $responseAjax->setOk(true); } } else { diff --git a/app/code/core/Mage/Bundle/Model/Product/Price.php b/app/code/core/Mage/Bundle/Model/Product/Price.php index 63dde5d5ce..7fe4a5f512 100644 --- a/app/code/core/Mage/Bundle/Model/Product/Price.php +++ b/app/code/core/Mage/Bundle/Model/Product/Price.php @@ -38,21 +38,21 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr /** * Flag wich indicates - is min/max prices have been calculated by index - * + * * @var bool */ protected $_isPricesCalculatedByIndex; /** * Is min/max prices have been calculated by index - * + * * @return bool */ public function getIsPricesCalculatedByIndex() { return $this->_isPricesCalculatedByIndex; - } - + } + /** * Return product base price * @@ -81,6 +81,7 @@ public function getFinalPrice($qty=null, $product) } $finalPrice = $product->getPrice(); + $basePrice = $finalPrice; /** * Just product with fixed price calculation has price @@ -97,6 +98,7 @@ public function getFinalPrice($qty=null, $product) $basePrice = $finalPrice; if ($product->hasCustomOptions()) { + $customOption = $product->getCustomOption('bundle_option_ids'); $customOption = $product->getCustomOption('bundle_selection_ids'); $selectionIds = unserialize($customOption->getValue()); $selections = $product->getTypeInstance(true)->getSelectionsByIds($selectionIds, $product); @@ -109,11 +111,25 @@ public function getFinalPrice($qty=null, $product) if ($selection->isSalable()) { $selectionQty = $product->getCustomOption('selection_qty_' . $selection->getSelectionId()); if ($selectionQty) { - $finalPrice += $this->getSelectionFinalPrice($product, $selection, $qty, - $selectionQty->getValue()); + $finalPrice = $finalPrice + $this->getSelectionFinalPrice($product, $selection, $qty, $selectionQty->getValue()); } } } + } else { +// if ($options = $this->getOptions($product)) { +// /* some strange thing +// foreach ($options as $option) { +// $selectionCount = count($option->getSelections()); +// if ($selectionCount) { +// foreach ($option->getSelections() as $selection) { +// if ($selection->isSalable() && ($selection->getIsDefault() || ($option->getRequired() &&)) { +// $finalPrice = $finalPrice + $this->getSelectionPrice($product, $selection); +// } +// } +// } +// } +// */ +// } } $finalPrice = $finalPrice + $this->_applyOptionsPrice($product, $qty, $basePrice) - $basePrice; @@ -130,48 +146,27 @@ public function getChildFinalPrice($product, $productQty, $childProduct, $childP /** * Retrieve Price * - * @deprecated after 1.10.1.1 - * @see Mage_Bundle_Model_Product_Price::getPricesTierPrice() - * - * @param Mage_Catalog_Model_Product $product - * @param string $which - * @return decimal|array + * @param unknown_type $product + * @param unknown_type $which + * @return unknown */ public function getPrices($product, $which = null) { - return $this->getPricesTierPrice($product, $which); + return $this->getPricesDependingOnTax($product, $which); } /** * Retrieve Prices depending on tax * - * @deprecated after 1.10.1.1 - * @see Mage_Bundle_Model_Product_Price::getPricesTierPrice() - * - * @param Mage_Catalog_Model_Product $product - * @param string $which - * @param bool|null $includeTax - * @return decimal|array + * @param unknown_type $product + * @param unknown_type $which + * @return unknown */ public function getPricesDependingOnTax($product, $which = null, $includeTax = null) - { - return $this->getPricesTierPrice($product, $which, $includeTax); - } - - /** - * Retrieve Price - * with take into account tier price - * - * @param Mage_Catalog_Model_Product $product - * @param string $which - * @param bool|null $includeTax - * @param bool $takeTierPrice - * @return decimal|array - */ - public function getPricesTierPrice($product, $which = null, $includeTax = null, $takeTierPrice = true) { // check calculated price index - if ($product->getData('min_price') && $product->getData('max_price')) { + if ($product->getData('min_price') && + $product->getData('max_price')) { $minimalPrice = Mage::helper('tax')->getPrice($product, $product->getData('min_price'), $includeTax); $maximalPrice = Mage::helper('tax')->getPrice($product, $product->getData('max_price'), $includeTax); $this->_isPricesCalculatedByIndex = true; @@ -211,18 +206,8 @@ public function getPricesTierPrice($product, $which = null, $includeTax = null, $qty = min(1, $qty); } - $selectionMinimalPrices[] = Mage::helper('tax')->getPrice( - $selection, - $this->getSelectionFinalPriceTierPrice($product, $selection, 1, $qty, $takeTierPrice), - $includeTax, - $takeTierPrice - ); - $selectionMaximalPrices[] = Mage::helper('tax')->getPrice( - $selection, - $this->getSelectionFinalPriceTierPrice($product, $selection, 1, null, $takeTierPrice), - $includeTax, - $takeTierPrice - ); + $selectionMinimalPrices[] = Mage::helper('tax')->getPrice($selection, $this->getSelectionFinalPrice($product, $selection, 1, $qty), $includeTax); + $selectionMaximalPrices[] = Mage::helper('tax')->getPrice($selection, $this->getSelectionFinalPrice($product, $selection, 1), $includeTax); } if (count($selectionMinimalPrices)) { @@ -232,9 +217,7 @@ public function getPricesTierPrice($product, $which = null, $includeTax = null, $minPriceFounded = true; } elseif (true !== $minPriceFounded) { $selMinPrice += $minimalPrice; - $minPriceFounded = (false === $minPriceFounded) - ? $selMinPrice - : min($minPriceFounded, $selMinPrice); + $minPriceFounded = false === $minPriceFounded ? $selMinPrice : min($minPriceFounded, $selMinPrice); } if ($option->isMultiSelection()) { @@ -247,7 +230,7 @@ public function getPricesTierPrice($product, $which = null, $includeTax = null, } } // condition is TRUE when all product options are NOT required - if (!is_bool($minPriceFounded)) { + if (! is_bool($minPriceFounded)) { $minimalPrice = $minPriceFounded; } @@ -274,10 +257,10 @@ public function getPricesTierPrice($product, $which = null, $includeTax = null, Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX, Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE ); - + if (in_array($customOption->getType(), $multiTypes)) { $maximalValue = array_sum($prices); - } else { + } else { $maximalValue = max($prices); } $maximalPrice += Mage::helper('tax')->getPrice($product, $maximalValue, $includeTax); @@ -307,12 +290,12 @@ public function getPricesTierPrice($product, $which = null, $includeTax = null, /** * Calculate Minimal price of bundle (counting all required options) * - * @param Mage_Catalog_Model_Product $product + * @param Mage_Catalog_Model_Product $product * @return decimal */ public function getMinimalPrice($product) { - return $this->getPricesTierPrice($product, 'min'); + return $this->getPrices($product, 'min'); } /** @@ -323,7 +306,7 @@ public function getMinimalPrice($product) */ public function getMaximalPrice($product) { - return $this->getPricesTierPrice($product, 'max'); + return $this->getPrices($product, 'max'); } /** @@ -389,56 +372,29 @@ public function getSelectionPrice($bundleProduct, $selectionProduct, $selectionQ */ public function getSelectionPreFinalPrice($bundleProduct, $selectionProduct, $qty = null) { - return $this->_applySpecialPrice( - $bundleProduct, - $this->getSelectionPrice($bundleProduct, $selectionProduct, $qty) - ); + return $this->_applySpecialPrice($bundleProduct, $this->getSelectionPrice($bundleProduct, $selectionProduct, $qty)); } - /** - * Calculate final price of selection - * - * @param Mage_Catalog_Model_Product $bundleProduct - * @param Mage_Catalog_Model_Product $selectionProduct - * @param decimal $bundleQty - * @param decimal $selectionQty - * @param bool $multiplyQty - * @return decimal - */ - public function getSelectionFinalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty = null, - $multiplyQty = true) - { - return $this->getSelectionFinalPriceTierPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty, - $multiplyQty); - } /** * Calculate final price of selection - * with take into account tier price * - * @param Mage_Catalog_Model_Product $bundleProduct - * @param Mage_Catalog_Model_Product $selectionProduct - * @param decimal $bundleQty - * @param decimal $selectionQty - * @param bool $multiplyQty - * @param bool $takeTierPrice + * @param Mage_Catalog_Model_Product $bundleProduct + * @param Mage_Catalog_Model_Product $selectionProduct + * @param decimal $bundleQty + * @param decimal $selectionQty * @return decimal */ - public function getSelectionFinalPriceTierPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty, - $multiplyQty = true, $takeTierPrice = true) + public function getSelectionFinalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty = null, $multiplyQty = true) { $selectionPrice = $this->getSelectionPrice($bundleProduct, $selectionProduct, $selectionQty, $multiplyQty); + // apply bundle tier price + $tierPrice = $this->_applyTierPrice($bundleProduct, $bundleQty, $selectionPrice); // apply bundle special price $specialPrice = $this->_applySpecialPrice($bundleProduct, $selectionPrice); - if ($takeTierPrice) { - // apply bundle tier price - $tierPrice = $this->_applyTierPrice($bundleProduct, $bundleQty, $selectionPrice); - return min(array($tierPrice, $specialPrice)); - } else { - return $specialPrice; - } + return min(array($tierPrice, $specialPrice)); } /** @@ -461,7 +417,6 @@ protected function _applyTierPrice($product, $qty, $finalPrice) $tierPrice = $finalPrice - ($finalPrice * ($tierPrice / 100)); $finalPrice = min($finalPrice, $tierPrice); } - return $finalPrice; } @@ -492,7 +447,7 @@ public function getTierPrice($qty=null, $product) 'price' => $product->getPrice(), 'website_price' => $product->getPrice(), 'price_qty' => 1, - 'cust_group' => $allGroups + 'cust_group' => $allGroups, )); } @@ -563,8 +518,7 @@ public function getTierPrice($qty=null, $product) * @param null|int $productId * @return float */ - public static function calculatePrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo, - $rulePrice = false, $wId = null, $gId = null, $productId = null) + public static function calculatePrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo, $rulePrice = false, $wId = null, $gId = null, $productId = null) { $resource = Mage::getResourceSingleton('bundle/bundle'); $selectionResource = Mage::getResourceSingleton('bundle/selection'); @@ -576,6 +530,7 @@ public static function calculatePrice($basePrice, $specialPrice, $specialPriceFr } else { $store = Mage::app()->getStore($wId)->getId(); $wId = Mage::app()->getStore($wId)->getWebsiteId(); + //$store = Mage::app()->getWebsite($wId)->getDefaultGroup()->getDefaultStoreId(); } if (!$gId) { @@ -600,16 +555,13 @@ public static function calculatePrice($basePrice, $specialPrice, $specialPriceFr continue; } - if ($result['selection_can_change_qty'] && $result['type'] != 'multi' - && $result['type'] != 'checkbox' - ) { + if ($result['selection_can_change_qty'] && $result['type'] != 'multi' && $result['type'] != 'checkbox') { $qty = 1; } else { $qty = $result['selection_qty']; } - $result['final_price'] = $selectionResource->getPriceFromIndex($result['product_id'], $qty, $store, - $gId); + $result['final_price'] = $selectionResource->getPriceFromIndex($result['product_id'], $qty, $store, $gId); $selectionPrice = $result['final_price']*$qty; @@ -620,7 +572,8 @@ public static function calculatePrice($basePrice, $specialPrice, $specialPriceFr } } $basePrice = array_sum($options); - } else { + } + else { //fixed foreach ($results as $result) { if (!$result['product_id']) { continue; @@ -631,9 +584,7 @@ public static function calculatePrice($basePrice, $specialPrice, $specialPriceFr $selectionPrice = $result['selection_price_value']; } - if ($result['selection_can_change_qty'] && $result['type'] != 'multi' - && $result['type'] != 'checkbox' - ) { + if ($result['selection_can_change_qty'] && $result['type'] != 'multi' && $result['type'] != 'checkbox') { $qty = 1; } else { $qty = $result['selection_qty']; @@ -651,8 +602,7 @@ public static function calculatePrice($basePrice, $specialPrice, $specialPriceFr $basePrice = $basePrice + array_sum($options); } - $finalPrice = self::calculateSpecialPrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo, - $store); + $finalPrice = self::calculateSpecialPrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo, $store); /** * adding customer defined options price @@ -678,8 +628,7 @@ public static function calculatePrice($basePrice, $specialPrice, $specialPriceFr } if ($rulePrice === false) { - $rulePrice = Mage::getResourceModel('catalogrule/rule') - ->getRulePrice(Mage::app()->getLocale()->storeTimeStamp($store), $wId, $gId, $productId); + $rulePrice = Mage::getResourceModel('catalogrule/rule')->getRulePrice(Mage::app()->getLocale()->storeTimeStamp($store), $wId, $gId, $productId); } if ($rulePrice !== null && $rulePrice !== false) { @@ -701,8 +650,7 @@ public static function calculatePrice($basePrice, $specialPrice, $specialPriceFr * @param mixed $store * @return float */ - public static function calculateSpecialPrice($finalPrice, $specialPrice, $specialPriceFrom, $specialPriceTo, - $store = null) + public static function calculateSpecialPrice($finalPrice, $specialPrice, $specialPriceFrom, $specialPriceTo, $store = null) { if (!is_null($specialPrice) && $specialPrice != false) { if (Mage::app()->getLocale()->isStoreDateInInterval($store, $specialPriceFrom, $specialPriceTo)) { @@ -710,7 +658,6 @@ public static function calculateSpecialPrice($finalPrice, $specialPrice, $specia $finalPrice = min($finalPrice, $specialPrice); } } - return $finalPrice; } @@ -723,4 +670,22 @@ public function isTierPriceFixed() { return false; } + + /* + public function getCustomOptionPrices($productId, $storeId, $which = null) { + + $optionsCollection = Mage::getResourceModel('catalog/product_option_collection') + ->addProductToFilter($productId) + ->; + + if (is_null($which)) { + return array($minimalPrice, $maximalPrice); + } else if ($which = 'max') { + return $maximalPrice; + } else if ($which = 'min') { + return $minimalPrice; + } + return 0; + } + */ } diff --git a/app/code/core/Mage/Bundle/Model/Product/Type.php b/app/code/core/Mage/Bundle/Model/Product/Type.php index ac0ba93d89..4068dc6ef8 100644 --- a/app/code/core/Mage/Bundle/Model/Product/Type.php +++ b/app/code/core/Mage/Bundle/Model/Product/Type.php @@ -388,6 +388,7 @@ public function getSelectionsCollection($optionIds, $product = null) $storeId = $this->getProduct($product)->getStoreId(); $selectionsCollection = Mage::getResourceModel('bundle/selection_collection') ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) + ->addAttributeToSelect('tax_class_id') //used for calculation item taxes in Bundle with Dynamic Price ->setFlag('require_stock_items', true) ->setFlag('product_children', true) ->setPositionOrder() diff --git a/app/code/core/Mage/Catalog/Helper/Data.php b/app/code/core/Mage/Catalog/Helper/Data.php index df24b48126..ad4d3629c4 100644 --- a/app/code/core/Mage/Catalog/Helper/Data.php +++ b/app/code/core/Mage/Catalog/Helper/Data.php @@ -307,7 +307,7 @@ public function getOldFieldMap() */ public function isMsrpEnabled() { - return (bool)Mage::getStoreConfig(self::XML_PATH_MSRP_ENABLED); + return (bool)Mage::getStoreConfig(self::XML_PATH_MSRP_ENABLED, $this->_storeId); } /** @@ -317,7 +317,7 @@ public function isMsrpEnabled() */ public function getMsrpDisplayActualPriceType() { - return Mage::getStoreConfig(self::XML_PATH_MSRP_DISPLAY_ACTUAL_PRICE_TYPE); + return Mage::getStoreConfig(self::XML_PATH_MSRP_DISPLAY_ACTUAL_PRICE_TYPE, $this->_storeId); } /** @@ -327,7 +327,7 @@ public function getMsrpDisplayActualPriceType() */ public function isMsrpApplyToAll() { - return (bool)Mage::getStoreConfig(self::XML_PATH_MSRP_APPLY_TO_ALL); + return (bool)Mage::getStoreConfig(self::XML_PATH_MSRP_APPLY_TO_ALL, $this->_storeId); } /** @@ -337,7 +337,9 @@ public function isMsrpApplyToAll() */ public function getMsrpExplanationMessage() { - return Mage::getStoreConfig(self::XML_PATH_MSRP_EXPLANATION_MESSAGE); + return $this->escapeHtml( + Mage::getStoreConfig(self::XML_PATH_MSRP_EXPLANATION_MESSAGE, $this->_storeId) + ); } /** @@ -347,7 +349,9 @@ public function getMsrpExplanationMessage() */ public function getMsrpExplanationMessageWhatsThis() { - return Mage::getStoreConfig(self::XML_PATH_MSRP_EXPLANATION_MESSAGE_WHATS_THIS); + return $this->escapeHtml( + Mage::getStoreConfig(self::XML_PATH_MSRP_EXPLANATION_MESSAGE_WHATS_THIS, $this->_storeId) + ); } /** @@ -376,16 +380,20 @@ public function canApplyMsrp($product, $visibility = null, $checkAssociatedItems } $result = $product->getMsrpEnabled(); + if ($result == Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Enabled::MSRP_ENABLE_USE_CONFIG) { + $result = $this->isMsrpApplyToAll(); + } + if (!$product->hasMsrpEnabled() && $this->isMsrpApplyToAll()) { $result = true; } if ($result && $visibility !== null) { $productVisibility = $product->getMsrpDisplayActualPriceType(); - if ($productVisibility === null) { + if ($productVisibility == Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Price::TYPE_USE_CONFIG) { $productVisibility = $this->getMsrpDisplayActualPriceType(); } - $result = $productVisibility == $visibility; + $result = ($productVisibility == $visibility); } if ($product->getTypeInstance(true)->isComposite($product) diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php index 077bfdc04d..39dbbaa77c 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php @@ -150,7 +150,7 @@ public function beforeSave($object) $attrData = $object->getData($mediaAttrCode); if (in_array($attrData, $clearImages)) { - $object->setData($mediaAttrCode, false); + $object->setData($mediaAttrCode, 'no_selection'); } if (in_array($attrData, array_keys($newImages))) { @@ -195,11 +195,30 @@ public function afterSave($object) if (!is_array($value) || !isset($value['images']) || $object->isLockedAttribute($attrCode)) { return; } + + $storeId = $object->getStoreId(); + + $storeIds = $object->getStoreIds(); + $storeIds[] = Mage_Core_Model_App::ADMIN_STORE_ID; + + // remove current storeId + $storeIds = array_flip($storeIds); + unset($storeIds[$storeId]); + $storeIds = array_keys($storeIds); + + $images = Mage::getResourceModel('catalog/product') + ->getAssignedImages($object, $storeIds); + + $picturesInOtherStores = array(); + foreach ($images as $image) { + $picturesInOtherStores[$image['filepath']] = true; + } + $toDelete = array(); $filesToValueIds = array(); foreach ($value['images'] as &$image) { if(!empty($image['removed'])) { - if(isset($image['value_id'])) { + if(isset($image['value_id']) && !isset($picturesInOtherStores[$image['file']])) { $toDelete[] = $image['value_id']; } continue; diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type.php index 487140da76..782e464581 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type.php @@ -31,7 +31,8 @@ * @package Mage_Catalog * @author Magento Core Team */ -class Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type extends Mage_Eav_Model_Entity_Attribute_Source_Abstract +class Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type + extends Mage_Eav_Model_Entity_Attribute_Source_Abstract { /** * Display Product Price on gesture diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type/Enabled.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type/Enabled.php new file mode 100644 index 0000000000..30dcf7e6b0 --- /dev/null +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type/Enabled.php @@ -0,0 +1,116 @@ + + */ +class Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Enabled + extends Mage_Eav_Model_Entity_Attribute_Source_Abstract +{ + /** + * Enable MAP + */ + const MSRP_ENABLE_YES = 1; + + /** + * Disable MAP + */ + const MSRP_ENABLE_NO = 0; + + /** + * Get value from the store configuration settings + */ + const MSRP_ENABLE_USE_CONFIG = 2; + + /** + * Retrieve all attribute options + * + * @return array + */ + public function getAllOptions() + { + if (!$this->_options) { + $this->_options = array( + array( + 'label' => Mage::helper('catalog')->__('Yes'), + 'value' => self::MSRP_ENABLE_YES + ), + array( + 'label' => Mage::helper('catalog')->__('No'), + 'value' => self::MSRP_ENABLE_NO + ), + array( + 'label' => Mage::helper('catalog')->__('Use config'), + 'value' => self::MSRP_ENABLE_USE_CONFIG + ) + ); + } + return $this->_options; + } + + /** + * Retrieve flat column definition + * + * @return array + */ + public function getFlatColums() + { + $attributeCode = $this->getAttribute()->getAttributeCode(); + $column = array( + 'unsigned' => false, + 'default' => null, + 'extra' => null + ); + + if (Mage::helper('core')->useDbCompatibleMode()) { + $column['type'] = 'tinyint(1)'; + $column['is_null'] = true; + } else { + $column['type'] = Varien_Db_Ddl_Table::TYPE_SMALLINT; + $column['length'] = 1; + $column['nullable'] = true; + $column['comment'] = $attributeCode . ' column'; + } + + return array($attributeCode => $column); + } + + /** + * Retrieve Select For Flat Attribute update + * + * @param int $store + * @return Varien_Db_Select|null + */ + public function getFlatUpdateSelect($store) + { + return Mage::getResourceModel('eav/entity_attribute') + ->getFlatUpdateSelect($this->getAttribute(), $store); + } +} diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type/Price.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type/Price.php new file mode 100644 index 0000000000..34d13f5fe6 --- /dev/null +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Source/Msrp/Type/Price.php @@ -0,0 +1,93 @@ + + */ +class Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Price + extends Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type +{ + /** + * Get value from the store configuration settings + */ + const TYPE_USE_CONFIG = '4'; + + /** + * Get all options + * + * @return array + */ + public function getAllOptions() + { + if (!$this->_options) { + $this->_options = parent::getAllOptions(); + $this->_options[self::TYPE_USE_CONFIG] = Mage::helper('catalog')->__('Use config'); + } + return $this->_options; + } + + /** + * Retrieve flat column definition + * + * @return array + */ + public function getFlatColums() + { + $attributeType = $this->getAttribute()->getBackendType(); + $attributeCode = $this->getAttribute()->getAttributeCode(); + $column = array( + 'unsigned' => false, + 'default' => null, + 'extra' => null + ); + + if (Mage::helper('core')->useDbCompatibleMode()) { + $column['type'] = $attributeType; + $column['is_null'] = true; + } else { + $column['type'] = Mage::getResourceHelper('eav')->getDdlTypeByColumnType($attributeType); + $column['nullable'] = true; + } + + return array($attributeCode => $column); + } + + /** + * Retrieve select for flat attribute update + * + * @param int $store + * @return Varien_Db_Select|null + */ + public function getFlatUpdateSelect($store) + { + return Mage::getResourceModel('eav/entity_attribute') + ->getFlatUpdateSelect($this->getAttribute(), $store); + } +} diff --git a/app/code/core/Mage/Catalog/Model/Product/Compare/Item.php b/app/code/core/Mage/Catalog/Model/Product/Compare/Item.php index 9d81cf3007..5312af5c93 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Compare/Item.php +++ b/app/code/core/Mage/Catalog/Model/Product/Compare/Item.php @@ -172,7 +172,7 @@ public function bindCustomerLogin() { $this->_getResource()->updateCustomerFromVisitor($this); - Mage::helper('catalog/product_compare')->calculate(); + Mage::helper('catalog/product_compare')->setCustomerId($this->getCustomerId())->calculate(); return $this; } diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php b/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php index e61201af65..0e45a3aa44 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php @@ -53,8 +53,11 @@ public function isCustomizedView() public function getCustomizedView($optionInfo) { try { - $result = $this->_getOptionHtml($optionInfo['option_value']); - return $result; + if (isset($optionInfo['option_value'])) { + return $this->_getOptionHtml($optionInfo['option_value']); + } elseif (isset($optionInfo['value'])) { + return $optionInfo['value']; + } } catch (Exception $e) { return $optionInfo['value']; } @@ -508,20 +511,21 @@ public function getFormattedOptionValue($optionValue) */ protected function _getOptionHtml($optionValue) { + $value = $this->_unserializeValue($optionValue); try { - $value = unserialize($optionValue); - } catch (Exception $e) { - $value = $optionValue; - } - try { - if ($value['width'] > 0 && $value['height'] > 0) { + if (isset($value) && isset($value['width']) && isset($value['height']) && $value['width'] > 0 && $value['height'] > 0) { $sizes = $value['width'] . ' x ' . $value['height'] . ' ' . Mage::helper('catalog')->__('px.'); } else { $sizes = ''; } + + $urlRoute = !empty($value['url']['route']) ? $value['url']['route'] : ''; + $urlParams = !empty($value['url']['params']) ? $value['url']['params'] : ''; + $title = !empty($value['title']) ? $value['title'] : ''; + return sprintf('%s %s', - $this->_getOptionDownloadUrl($value['url']['route'], $value['url']['params']), - Mage::helper('core')->htmlEscape($value['title']), + $this->_getOptionDownloadUrl($urlRoute, $urlParams), + Mage::helper('core')->htmlEscape($title), $sizes ); } catch (Exception $e) { @@ -529,6 +533,23 @@ protected function _getOptionHtml($optionValue) } } + /** + * Create a value from a storable representation + * + * @param mixed $value + * @return array + */ + protected function _unserializeValue($value) + { + if (is_array($value)) { + return $value; + } elseif (is_string($value) && !empty($value)) { + return unserialize($value); + } else { + return array(); + } + } + /** * Return printable option value * diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Category/Collection.php index 9bf1451843..ddbbcb0985 100755 --- a/app/code/core/Mage/Catalog/Model/Resource/Category/Collection.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Collection.php @@ -226,6 +226,7 @@ public function loadProductCount($items, $countRegular = true, $countAnchor = tr { $anchor = array(); $regular = array(); + $websiteId = Mage::app()->getStore($this->getProductStoreId())->getWebsiteId(); foreach ($items as $item) { if ($item->getIsAnchor()) { @@ -246,6 +247,13 @@ public function loadProductCount($items, $countRegular = true, $countAnchor = tr ) ->where($this->_conn->quoteInto('main_table.category_id IN(?)', $regularIds)) ->group('main_table.category_id'); + if ($websiteId) { + $select->join( + array('w' => $this->_productWebsiteTable), + 'main_table.product_id = w.product_id', array() + ) + ->where('w.website_id = ?', $websiteId); + } $counts = $this->_conn->fetchPairs($select); foreach ($regular as $item) { if (isset($counts[$item->getId()])) { @@ -277,6 +285,13 @@ public function loadProductCount($items, $countRegular = true, $countAnchor = tr ) ->where('e.entity_id = :entity_id') ->orWhere('e.path LIKE :c_path'); + if ($websiteId) { + $select->join( + array('w' => $this->_productWebsiteTable), + 'main_table.product_id = w.product_id', array() + ) + ->where('w.website_id = ?', $websiteId); + } $item->setProductCount((int) $this->_conn->fetchOne($select, $bind)); } else { $item->setProductCount(0); @@ -365,15 +380,13 @@ public function addPathsFilter($paths) if (!is_array($paths)) { $paths = array($paths); } - $select = $this->getSelect(); - $orWhere = false; + $write = $this->getResource()->getWriteConnection(); + $cond = array(); foreach ($paths as $path) { - if ($orWhere) { - $select->orWhere('e.path LIKE ?', "$path%"); - } else { - $select->where('e.path LIKE ?', "$path%"); - $orWhere = true; - } + $cond[] = $write->quoteInto('e.path LIKE ?', "$path%"); + } + if ($cond) { + $this->getSelect()->where(join(' OR ', $cond)); } return $this; } diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php index 5a159dd360..84298c835b 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php @@ -174,6 +174,9 @@ public function afterCommitCallback() */ protected function _beforeDelete() { + if ($this->_getResource()->isUsedBySuperProducts($this)) { + Mage::throwException(Mage::helper('catalog')->__('This attribute is used in configurable products.')); + } Mage::getSingleton('index/indexer')->logEvent( $this, self::ENTITY, Mage_Index_Model_Event::TYPE_DELETE ); diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product.php b/app/code/core/Mage/Catalog/Model/Resource/Product.php index e9f6d33c06..41aa3f26f1 100755 --- a/app/code/core/Mage/Catalog/Model/Resource/Product.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product.php @@ -652,4 +652,40 @@ public function getProductEntitiesInfo($columns = null) ->from($this->getTable('catalog/product'), $columns); return $this->_getReadAdapter()->fetchAll($select); } + + /** + * Return assigned images for specific stores + * + * @param Mage_Catalog_Model_Product $product + * @param int|array $storeIds + * @return array + * + */ + public function getAssignedImages($product, $storeIds) + { + if (!is_array($storeIds)) { + $storeIds = array($storeIds); + } + + $mainTable = $product->getResource()->getAttribute('image') + ->getBackend() + ->getTable(); + $read = $this->_getReadAdapter(); + $select = $read->select() + ->from( + array('images' => $mainTable), + array('value as filepath', 'store_id') + ) + ->joinLeft( + array('attr' => $this->getTable('eav/attribute')), + 'images.attribute_id = attr.attribute_id', + array('attribute_code') + ) + ->where('entity_id = ?', $product->getId()) + ->where('store_id IN (?)', $storeIds) + ->where('attribute_code IN (?)', array('small_image', 'thumbnail', 'image')); + + $images = $read->fetchAll($select); + return $images; + } } diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php index b144371c09..8a9404bc2a 100755 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php @@ -774,7 +774,7 @@ public function getProductCountSelect() ->join(array('count_table' => $this->getTable('catalog/category_product_index')), 'count_table.product_id = e.entity_id', array( - 'count_table.category_id', + 'count_table.category_id', 'product_count' => new Zend_Db_Expr('COUNT(DISTINCT count_table.product_id)') ) ) @@ -818,7 +818,7 @@ public function addCountToCategories($categoryCollection) $select = $this->getProductCountSelect(); Mage::dispatchEvent( - 'catalog_product_collection_before_add_count_to_categories', + 'catalog_product_collection_before_add_count_to_categories', array('collection' => $this) ); @@ -1577,7 +1577,7 @@ public function applyFrontendPriceLimitations() $this->_productLimitationFilters['use_price_index'] = true; if (!isset($this->_productLimitationFilters['customer_group_id'])) { $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); - $this->_productLimitationFilters['customer_group_id'] = $customerGroupId; + $this->_productLimitationFilters['customer_group_id'] = $customerGroupId; } if (!isset($this->_productLimitationFilters['website_id'])) { $websiteId = Mage::app()->getStore($this->getStoreId())->getWebsiteId(); diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Link/Product/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Link/Product/Collection.php index 79a3a29511..6353f56781 100755 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Link/Product/Collection.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Link/Product/Collection.php @@ -263,6 +263,24 @@ public function setPositionOrder($dir = self::SORT_ORDER_ASC) return $this; } + /** + * Enable sorting products by its attribute set name + * + * @param string $dir sort type asc|desc + * @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection + */ + public function setAttributeSetIdOrder($dir = self::SORT_ORDER_ASC) + { + $this->getSelect() + ->joinLeft( + array('set' => $this->getTable('eav/attribute_set')), + 'e.attribute_set_id = set.attribute_set_id', + array('attribute_set_name') + ) + ->order('set.attribute_set_name ' . $dir); + return $this; + } + /** * Join attributes * @@ -293,4 +311,23 @@ public function joinAttributes() return $this; } + + /** + * Set sorting order + * + * $attribute can also be an array of attributes + * + * @param string|array $attribute + * @param string $dir + * @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection + */ + public function setOrder($attribute, $dir = self::SORT_ORDER_ASC) + { + if ($attribute == 'position') { + return $this->setPositionOrder($dir); + } elseif ($attribute == 'attribute_set_id') { + return $this->setAttributeSetIdOrder($dir); + } + return parent::setOrder($attribute, $dir); + } } diff --git a/app/code/core/Mage/Catalog/etc/config.xml b/app/code/core/Mage/Catalog/etc/config.xml index 6b49a70eca..8860e09d5f 100644 --- a/app/code/core/Mage/Catalog/etc/config.xml +++ b/app/code/core/Mage/Catalog/etc/config.xml @@ -28,7 +28,7 @@ - 1.6.0.0.3 + 1.6.0.0.4 diff --git a/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.3-1.6.0.0.4.php b/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.3-1.6.0.0.4.php new file mode 100644 index 0000000000..4ecfda9f4a --- /dev/null +++ b/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.3-1.6.0.0.4.php @@ -0,0 +1,56 @@ +updateAttribute( + Mage_Catalog_Model_Product::ENTITY, + 'msrp_enabled', + 'source_model', + 'catalog/product_attribute_source_msrp_type_enabled' +); + +$installer->updateAttribute( + Mage_Catalog_Model_Product::ENTITY, + 'msrp_enabled', + 'default_value', + Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Enabled::MSRP_ENABLE_USE_CONFIG +); + +$installer->updateAttribute( + Mage_Catalog_Model_Product::ENTITY, + 'msrp_display_actual_price_type', + 'source_model', + 'catalog/product_attribute_source_msrp_type_price' +); + +$installer->updateAttribute( + Mage_Catalog_Model_Product::ENTITY, + 'msrp_display_actual_price_type', + 'default_value', + Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Price::TYPE_USE_CONFIG +); diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php index cf27cc5c3d..e746cbe96f 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php +++ b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php @@ -583,7 +583,7 @@ public function checkQuoteItemQty($qty, $summaryQty, $origQty = 0) return $result; } - if (!$this->checkQty($summaryQty)) { + if (!$this->checkQty($summaryQty) || !$this->checkQty($qty)) { $message = $_helper->__('The requested quantity for "%s" is not available.', $this->getProductName()); $result->setHasError(true) ->setMessage($message) diff --git a/app/code/core/Mage/CatalogSearch/Block/Layer.php b/app/code/core/Mage/CatalogSearch/Block/Layer.php index 0f6d272bb0..e646a1a1ac 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Layer.php +++ b/app/code/core/Mage/CatalogSearch/Block/Layer.php @@ -36,7 +36,7 @@ class Mage_CatalogSearch_Block_Layer extends Mage_Catalog_Block_Layer_View protected function _construct() { parent::_construct(); - Mage::register('current_layer', $this->getLayer()); + Mage::register('current_layer', $this->getLayer(), true); } /** diff --git a/app/code/core/Mage/Centinel/Model/State/Mastercard.php b/app/code/core/Mage/Centinel/Model/State/Mastercard.php index d9cd1c37f4..ef72d14450 100644 --- a/app/code/core/Mage/Centinel/Model/State/Mastercard.php +++ b/app/code/core/Mage/Centinel/Model/State/Mastercard.php @@ -86,12 +86,9 @@ public function isAuthenticateSuccessful() //Test case 10 if ($paResStatus == '' && $signatureVerification == '' && $eciFlag == '01' && - $xid == '' && $cavv == '' && $errorNo == '1050') { - if ($this->getIsModeStrict()) { - return false; - } else { - return true; - } + $xid == '' && $cavv == '' && $errorNo == '1050' + ) { + return false; } } diff --git a/app/code/core/Mage/Checkout/Model/Resource/Agreement.php b/app/code/core/Mage/Checkout/Model/Resource/Agreement.php index 4056ff857d..6e08caac19 100755 --- a/app/code/core/Mage/Checkout/Model/Resource/Agreement.php +++ b/app/code/core/Mage/Checkout/Model/Resource/Agreement.php @@ -53,6 +53,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object) { // format height $height = $object->getContentHeight(); + $height = Mage::helper('checkout')->stripTags($height); if (!$height) { $height = ''; } diff --git a/app/code/core/Mage/Checkout/Model/Session.php b/app/code/core/Mage/Checkout/Model/Session.php index 58686bade4..d2549ff4c3 100644 --- a/app/code/core/Mage/Checkout/Model/Session.php +++ b/app/code/core/Mage/Checkout/Model/Session.php @@ -214,7 +214,10 @@ public function loadCustomerQuote() } $this->_quote = $customerQuote; } else { + $this->getQuote()->getBillingAddress(); + $this->getQuote()->getShippingAddress(); $this->getQuote()->setCustomer(Mage::getSingleton('customer/session')->getCustomer()) + ->collectTotals() ->save(); } return $this; diff --git a/app/code/core/Mage/Cms/Block/Widget/Block.php b/app/code/core/Mage/Cms/Block/Widget/Block.php index b3dd565397..f7d573e118 100644 --- a/app/code/core/Mage/Cms/Block/Widget/Block.php +++ b/app/code/core/Mage/Cms/Block/Widget/Block.php @@ -34,8 +34,16 @@ */ class Mage_Cms_Block_Widget_Block extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface { + /** + * Storage for used widgets + * + * @var array + */ + static protected $_widgetUsageMap = array(); + /** * Prepare block text and determine whether block output enabled or not + * Prevent blocks recursion if needed * * @return Mage_Cms_Block_Widget_Block */ @@ -43,6 +51,13 @@ protected function _beforeToHtml() { parent::_beforeToHtml(); $blockId = $this->getData('block_id'); + $blockHash = get_class($this) . $blockId; + + if (isset(self::$_widgetUsageMap[$blockHash])) { + return $this; + } + self::$_widgetUsageMap[$blockHash] = true; + if ($blockId) { $block = Mage::getModel('cms/block') ->setStoreId(Mage::app()->getStore()->getId()) @@ -54,6 +69,8 @@ protected function _beforeToHtml() $this->setText($processor->filter($block->getContent())); } } + + unset(self::$_widgetUsageMap[$blockHash]); return $this; } } diff --git a/app/code/core/Mage/Core/Block/Messages.php b/app/code/core/Mage/Core/Block/Messages.php index 701aed0cea..68c00662b1 100644 --- a/app/code/core/Mage/Core/Block/Messages.php +++ b/app/code/core/Mage/Core/Block/Messages.php @@ -68,6 +68,13 @@ class Mage_Core_Block_Messages extends Mage_Core_Block_Template */ protected $_escapeMessageFlag = false; + /** + * Storage for used types of message storages + * + * @var array + */ + protected $_usedStorageTypes = array('core/session'); + public function _prepareLayout() { $this->addMessages(Mage::getSingleton('core/session')->getMessages(true)); @@ -277,4 +284,26 @@ public function setMessagesSecondLevelTagName($tagName) { $this->_messagesSecondLevelTagName = $tagName; } + + /** + * Get cache key informative items + * + * @return array + */ + public function getCacheKeyInfo() + { + return array( + 'storage_types' => serialize($this->_usedStorageTypes) + ); + } + + /** + * Add used storage type + * + * @param string $type + */ + public function addStorageType($type) + { + $this->_usedStorageTypes[] = $type; + } } diff --git a/app/code/core/Mage/Core/Block/Template.php b/app/code/core/Mage/Core/Block/Template.php index 426cdac9ad..d0d1d626a1 100644 --- a/app/code/core/Mage/Core/Block/Template.php +++ b/app/code/core/Mage/Core/Block/Template.php @@ -160,19 +160,25 @@ public function assign($key, $value=null) } /** - * Set template location dire + * Set template location directory * * @param string $dir * @return Mage_Core_Block_Template */ public function setScriptPath($dir) { - $this->_viewDir = $dir; + $scriptPath = realpath($dir); + if (strpos($scriptPath, realpath(Mage::getBaseDir('design'))) === 0 || $this->_getAllowSymlinks()) { + $this->_viewDir = $dir; + } else { + Mage::log('Not valid script path:' . $dir, Zend_Log::CRIT, null, null, true); + } return $this; } /** - * Check if dirrect output is allowed for block + * Check if direct output is allowed for block + * * @return bool */ public function getDirectOutput() diff --git a/app/code/core/Mage/Core/Controller/Request/Http.php b/app/code/core/Mage/Core/Controller/Request/Http.php index 0f983c89e8..d8680479ad 100644 --- a/app/code/core/Mage/Core/Controller/Request/Http.php +++ b/app/code/core/Mage/Core/Controller/Request/Http.php @@ -36,6 +36,7 @@ class Mage_Core_Controller_Request_Http extends Zend_Controller_Request_Http { const XML_NODE_DIRECT_FRONT_NAMES = 'global/request/direct_front_name'; const DEFAULT_HTTP_PORT = 80; + const DEFAULT_HTTPS_PORT = 443; /** * ORIGINAL_PATH_INFO diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php index 14b85de1f9..805864ec54 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Action.php +++ b/app/code/core/Mage/Core/Controller/Varien/Action.php @@ -627,6 +627,7 @@ protected function _initLayoutMessages($messagesStorage) $block = $this->getLayout()->getMessagesBlock(); $block->addMessages($storage->getMessages(true)); $block->setEscapeMessageFlag($storage->getEscapeMessages(true)); + $block->addStorageType($storageName); } else { Mage::throwException( diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php index 8d47a31797..6e9d49b529 100644 --- a/app/code/core/Mage/Core/Helper/String.php +++ b/app/code/core/Mage/Core/Helper/String.php @@ -279,4 +279,24 @@ public function strpos($haystack, $needle, $offset = null) { return iconv_strpos($haystack, $needle, $offset, self::ICONV_CHARSET); } + + /** + * Sorts array with multibyte string keys + * + * @param array $sort + * @return array + */ + public function ksortMultibyte(array &$sort) + { + if (empty($sort)) { + return false; + } + $oldLocale = setlocale(LC_COLLATE, "0"); + setlocale(LC_COLLATE, Mage::app()->getLocale()->getLocaleCode() . '.UTF8'); + ksort($sort, SORT_LOCALE_STRING); + setlocale(LC_COLLATE, $oldLocale); + + return $sort; + } + } diff --git a/app/code/core/Mage/Core/Helper/Url.php b/app/code/core/Mage/Core/Helper/Url.php index f3151f0b5d..cb68a47bf7 100644 --- a/app/code/core/Mage/Core/Helper/Url.php +++ b/app/code/core/Mage/Core/Helper/Url.php @@ -44,11 +44,11 @@ public function getCurrentUrl() $request = Mage::app()->getRequest(); $port = $request->getServer('SERVER_PORT'); if ($port) { - if ($port == Mage_Core_Controller_Request_Http::DEFAULT_HTTP_PORT) { - $port = ''; - } else { - $port = ':' . $port; - } + $defaultPorts = array( + Mage_Core_Controller_Request_Http::DEFAULT_HTTP_PORT, + Mage_Core_Controller_Request_Http::DEFAULT_HTTPS_PORT + ); + $port = (in_array($port, $defaultPorts)) ? '' : ':' . $port; } $url = $request->getScheme() . '://' . $request->getHttpHost() . $port . $request->getServer('REQUEST_URI'); return $url; diff --git a/app/code/core/Mage/Core/Model/App.php b/app/code/core/Mage/Core/Model/App.php index 35770a9ca2..ffd9a848ff 100644 --- a/app/code/core/Mage/Core/Model/App.php +++ b/app/code/core/Mage/Core/Model/App.php @@ -38,6 +38,8 @@ class Mage_Core_Model_App const XML_PATH_INSTALL_DATE = 'global/install/date'; + const XML_PATH_SKIP_PROCESS_MODULES_UPDATES = 'global/skip_process_modules_updates'; + const DEFAULT_ERROR_HANDLER = 'mageCoreErrorHandler'; const DISTRO_LOCALE_CODE = 'en_US'; @@ -226,6 +228,11 @@ class Mage_Core_Model_App */ protected $_useSessionVar = false; + /** + * Cache locked flag + * + * @var null|bool + */ protected $_isCacheLocked = null; /** @@ -375,6 +382,7 @@ protected function _initBaseConfig() */ protected function _initCache() { + $this->_isCacheLocked = true; $options = $this->_config->getNode('global/cache'); if ($options) { $options = $options->asArray(); @@ -382,6 +390,7 @@ protected function _initCache() $options = array(); } $this->_cache = Mage::getModel('core/cache', $options); + $this->_isCacheLocked = false; return $this; } @@ -394,7 +403,7 @@ protected function _initModules() { if (!$this->_config->loadModulesCache()) { $this->_config->loadModules(); - if ($this->_config->isLocalConfigLoaded()) { + if ($this->_config->isLocalConfigLoaded() && !$this->_shouldSkipProcessModulesUpdates()) { Varien_Profiler::start('mage::app::init::apply_db_schema_updates'); Mage_Core_Model_Resource_Setup::applyAllUpdates(); Varien_Profiler::stop('mage::app::init::apply_db_schema_updates'); @@ -405,6 +414,24 @@ protected function _initModules() return $this; } + /** + * Check whether modules updates processing should be skipped + * + * @return bool + */ + protected function _shouldSkipProcessModulesUpdates() + { + if (!Mage::isInstalled()) { + return false; + } + + if (Mage::getIsDeveloperMode()) { + return false; + } + + return (bool)(string)$this->_config->getNode(self::XML_PATH_SKIP_PROCESS_MODULES_UPDATES); + } + /** * Init request object * @@ -1461,4 +1488,38 @@ public function prepareCacheId($id) $id = preg_replace('/([^a-zA-Z0-9_]{1,1})/', '_', $id); return $id; } + + /** + * Get is cache locked + * + * @return bool + */ + public function getIsCacheLocked() + { + return (bool)$this->_isCacheLocked; + } + + /** + * Unset website by id from app cache + * + * @param null|bool|int|string|Mage_Core_Model_Website $id + * @return void + */ + public function clearWebsiteCache($id = null) + { + if (is_null($id)) { + $id = $this->getStore()->getWebsiteId(); + } elseif ($id instanceof Mage_Core_Model_Website) { + $id = $id->getId(); + } elseif ($id === true) { + $id = $this->_website->getId(); + } + + if (!empty($this->_websites[$id])) { + $website = $this->_websites[$id]; + + unset($this->_websites[$website->getWebsiteId()]); + unset($this->_websites[$website->getCode()]); + } + } } diff --git a/app/code/core/Mage/Core/Model/Cache.php b/app/code/core/Mage/Core/Model/Cache.php index 71471a394f..9bb3eb643a 100644 --- a/app/code/core/Mage/Core/Model/Cache.php +++ b/app/code/core/Mage/Core/Model/Cache.php @@ -441,6 +441,13 @@ protected function _initOptions() } else { $this->_allowedCacheOptions = unserialize($options); } + + if (Mage::getConfig()->getOptions()->getData('global_ban_use_cache')) { + foreach ($this->_allowedCacheOptions as $key => $val) { + $this->_allowedCacheOptions[$key] = false; + } + } + return $this; } diff --git a/app/code/core/Mage/Core/Model/Resource.php b/app/code/core/Mage/Core/Model/Resource.php index 06bd75861e..c4ce790f78 100644 --- a/app/code/core/Mage/Core/Model/Resource.php +++ b/app/code/core/Mage/Core/Model/Resource.php @@ -45,21 +45,28 @@ class Mage_Core_Model_Resource * * @var array */ - protected $_connectionTypes = array(); + protected $_connectionTypes = array(); /** * Instances of actual connections * * @var array */ - protected $_connections = array(); + protected $_connections = array(); + + /** + * Names of actual connections that wait to set cache + * + * @var array + */ + protected $_skippedConnections = array(); /** * Registry of resource entities * * @var array */ - protected $_entities = array(); + protected $_entities = array(); /** * Mapped tables cache array @@ -77,7 +84,12 @@ class Mage_Core_Model_Resource public function getConnection($name) { if (isset($this->_connections[$name])) { - return $this->_connections[$name]; + $connection = $this->_connections[$name]; + if (isset($this->_skippedConnections[$name]) && !Mage::app()->getIsCacheLocked()) { + $connection->setCacheAdapter(Mage::app()->getCache()); + unset($this->_skippedConnections[$name]); + } + return $connection; } $connConfig = Mage::getConfig()->getResourceConnectionConfig($name); @@ -97,15 +109,21 @@ public function getConnection($name) $connection = $this->_newConnection((string)$connConfig->type, $connConfig); if ($connection) { - $connection->setCacheAdapter(Mage::app()->getCache()); + if (Mage::app()->getIsCacheLocked()) { + $this->_skippedConnections[$name] = true; + } else { + $connection->setCacheAdapter(Mage::app()->getCache()); + } } $this->_connections[$name] = $connection; if ($origName !== $name) { $this->_connections[$origName] = $connection; } + return $connection; } + /** * Retrieve connection adapter class name by connection type * @@ -165,7 +183,6 @@ protected function _newConnection($type, $config) } return $connection; - } /** @@ -250,7 +267,6 @@ public function getTableName($modelEntity) } if ($entityConfig && !empty($entityConfig->table)) { - $tableName = (string)$entityConfig->table; } else { Mage::throwException(Mage::helper('core')->__('Can\'t retrieve entity config: %s', $modelEntity)); @@ -266,7 +282,6 @@ public function getTableName($modelEntity) 'table_suffix' => $tableSuffix )); - $mappedTableName = $this->getMappedTableName($tableName); if ($mappedTableName) { $tableName = $mappedTableName; @@ -278,17 +293,28 @@ public function getTableName($modelEntity) if (!is_null($tableSuffix)) { $tableName .= '_' . $tableSuffix; } - return $this->getConnection(self::DEFAULT_READ_RESOURCE)->getTableName($tableName); - } + /** + * Set mapped table name + * + * @param string $tableName + * @param string $mappedName + * @return Mage_Core_Model_Resource + */ public function setMappedTableName($tableName, $mappedName) { $this->_mappedTableNames[$tableName] = $mappedName; return $this; } + /** + * Get mapped table name + * + * @param string $tableName + * @return bool|string + */ public function getMappedTableName($tableName) { if (isset($this->_mappedTableNames[$tableName])) { @@ -298,11 +324,17 @@ public function getMappedTableName($tableName) } } + /** + * Clean db row + * + * @param array $row + * @return Mage_Core_Model_Resource + */ public function cleanDbRow(&$row) { if (!empty($row) && is_array($row)) { foreach ($row as $key=>&$value) { - if (is_string($value) && $value==='0000-00-00 00:00:00') { + if (is_string($value) && $value === '0000-00-00 00:00:00') { $value = ''; } } diff --git a/app/code/core/Mage/Core/Model/Store.php b/app/code/core/Mage/Core/Model/Store.php index c4fbb01abf..06fc61f507 100644 --- a/app/code/core/Mage/Core/Model/Store.php +++ b/app/code/core/Mage/Core/Model/Store.php @@ -46,7 +46,8 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract { const ENTITY = 'core_store'; - const XML_PATH_STORE_STORE_NAME = 'general/store_information/name'; + const XML_PATH_STORE_STORE_NAME = 'general/store_information/name'; + const XML_PATH_STORE_STORE_PHONE = 'general/store_information/phone'; const XML_PATH_STORE_IN_URL = 'web/url/use_store'; const XML_PATH_USE_REWRITES = 'web/seo/use_rewrites'; diff --git a/app/code/core/Mage/Core/Model/Website.php b/app/code/core/Mage/Core/Model/Website.php index 71862910e5..076f146106 100644 --- a/app/code/core/Mage/Core/Model/Website.php +++ b/app/code/core/Mage/Core/Model/Website.php @@ -480,6 +480,8 @@ protected function _beforeDelete() */ protected function _afterDelete() { + Mage::app()->clearWebsiteCache($this->getId()); + parent::_afterDelete(); Mage::getConfig()->removeCache(); return $this; diff --git a/app/code/core/Mage/Core/etc/config.xml b/app/code/core/Mage/Core/etc/config.xml index d0a2e65ebd..782a0b8ae9 100644 --- a/app/code/core/Mage/Core/etc/config.xml +++ b/app/code/core/Mage/Core/etc/config.xml @@ -28,7 +28,7 @@ - 1.6.0.0 + 1.6.0.1 @@ -258,7 +258,6 @@ 0 - 0 diff --git a/app/code/core/Mage/Core/etc/system.xml b/app/code/core/Mage/Core/etc/system.xml index 2ab89f1eca..ea16205dff 100644 --- a/app/code/core/Mage/Core/etc/system.xml +++ b/app/code/core/Mage/Core/etc/system.xml @@ -605,15 +605,6 @@ 1 1 - - - select - adminhtml/system_config_source_yesno - 50 - 1 - 1 - 1 - diff --git a/app/code/core/Mage/Customer/Block/Form/Register.php b/app/code/core/Mage/Customer/Block/Form/Register.php index c2a4c78b90..18ee03acad 100644 --- a/app/code/core/Mage/Customer/Block/Form/Register.php +++ b/app/code/core/Mage/Customer/Block/Form/Register.php @@ -83,7 +83,9 @@ public function getFormData() $data->addData($formData); $data->setCustomerData(1); } - + if (isset($data['region_id'])) { + $data['region_id'] = (int)$data['region_id']; + } $this->setData('form_data', $data); } return $data; diff --git a/app/code/core/Mage/Customer/Model/Address.php b/app/code/core/Mage/Customer/Model/Address.php index f6ffc58cd4..20697c933a 100644 --- a/app/code/core/Mage/Customer/Model/Address.php +++ b/app/code/core/Mage/Customer/Model/Address.php @@ -150,4 +150,26 @@ public function getEntityTypeId() } return $entityTypeId; } + + /** + * Return Region ID + * + * @return int + */ + public function getRegionId() + { + return (int)$this->getData('region_id'); + } + + /** + * Set Region ID. $regionId is automatically converted to integer + * + * @param int $regionId + * @return Mage_Customer_Model_Address + */ + public function setRegionId($regionId) + { + $this->setData('region_id', (int)$regionId); + return $this; + } } diff --git a/app/code/core/Mage/Customer/Model/Customer.php b/app/code/core/Mage/Customer/Model/Customer.php index f1ca797b60..df079f90ac 100644 --- a/app/code/core/Mage/Customer/Model/Customer.php +++ b/app/code/core/Mage/Customer/Model/Customer.php @@ -849,7 +849,7 @@ public function importFromTextArray(array $row) $regions->addRegionNameFilter($row['billing_region'])->load(); if ($regions) foreach($regions as $region) { - $regionId = $region->getId(); + $regionId = intval($region->getId()); } $billingAddress->setFirstname($row['firstname']); @@ -891,7 +891,7 @@ public function importFromTextArray(array $row) $regions->addRegionNameFilter($row['shipping_region'])->load(); if ($regions) foreach($regions as $region) { - $regionId = $region->getId(); + $regionId = intval($region->getId()); } $shippingAddress->setFirstname($row['firstname']); diff --git a/app/code/core/Mage/Customer/controllers/AccountController.php b/app/code/core/Mage/Customer/controllers/AccountController.php index d958c3ecbf..4f2c60e1d5 100644 --- a/app/code/core/Mage/Customer/controllers/AccountController.php +++ b/app/code/core/Mage/Customer/controllers/AccountController.php @@ -575,7 +575,7 @@ public function editAction() } $this->getLayout()->getBlock('head')->setTitle($this->__('Account Information')); - + $this->getLayout()->getBlock('messages')->setEscapeMessageFlag(true); $this->renderLayout(); } diff --git a/app/code/core/Mage/Customer/etc/config.xml b/app/code/core/Mage/Customer/etc/config.xml index bdee3ffe8c..a7d0f26592 100644 --- a/app/code/core/Mage/Customer/etc/config.xml +++ b/app/code/core/Mage/Customer/etc/config.xml @@ -122,27 +122,43 @@ 1 + 1 + 1 1 + 1 + 1 1 + 1 + 1 1 + 1 + 1 1 + 1 + 1 1 + 1 + 1 1 + 1 + 1 1 + 1 + 1 1 diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php index ad638bd62a..bf67499de7 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php @@ -194,13 +194,15 @@ public function unparse() $fieldList = $this->getBatchModel()->getFieldList(); $batchExportIds = $batchExport->getIdCollection(); + $io = $this->getBatchModel()->getIoAdapter(); + $io->open(); + if (!$batchExportIds) { + $io->write(""); + $io->close(); return $this; } - $io = $this->getBatchModel()->getIoAdapter(); - $io->open(); - if ($this->getVar('fieldnames')) { $csvData = $this->getCsvString($fieldList); $io->write($csvData); diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php index 9eb49874f6..80abebc3cd 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php @@ -343,7 +343,7 @@ public function unparse() $fieldList = $this->getBatchModel()->getFieldList(); $batchExportIds = $batchExport->getIdCollection(); - if (!$batchExportIds) { + if (!is_array($batchExportIds)) { return $this; } diff --git a/app/code/core/Mage/Directory/Block/Data.php b/app/code/core/Mage/Directory/Block/Data.php index 34edefe382..47ca563bca 100644 --- a/app/code/core/Mage/Directory/Block/Data.php +++ b/app/code/core/Mage/Directory/Block/Data.php @@ -109,7 +109,7 @@ public function getRegionHtmlSelect() ->setTitle(Mage::helper('directory')->__('State/Province')) ->setId('state') ->setClass('required-entry validate-state') - ->setValue($this->getRegionId()) + ->setValue(intval($this->getRegionId())) ->setOptions($options) ->getHtml(); Varien_Profiler::start('TEST: '.__METHOD__); diff --git a/app/code/core/Mage/Directory/Helper/Data.php b/app/code/core/Mage/Directory/Helper/Data.php index 6a486729ae..f11270da7b 100644 --- a/app/code/core/Mage/Directory/Helper/Data.php +++ b/app/code/core/Mage/Directory/Helper/Data.php @@ -31,12 +31,51 @@ */ class Mage_Directory_Helper_Data extends Mage_Core_Helper_Abstract { + /** + * Config value that lists ISO2 country codes which have optional Zip/Postal pre-configured + */ + const OPTIONAL_ZIP_COUNTRIES_CONFIG_PATH = 'general/country/optional_zip_countries'; + + /** + * Country collection + * + * @var Mage_Directory_Model_Resource_Country_Collection + */ protected $_countryCollection; + + /** + * Region collection + * + * @var Mage_Directory_Model_Resource_Region_Collection + */ protected $_regionCollection; + + /** + * Json representation of regions data + * + * @var string + */ protected $_regionJson; + + /** + * Currency cache + * + * @var array + */ protected $_currencyCache = array(); + + /** + * ISO2 country codes which have optional Zip/Postal pre-configured + * + * @var array + */ protected $_optionalZipCountries = null; + /** + * Retrieve region collection + * + * @return Mage_Directory_Model_Resource_Region_Collection + */ public function getRegionCollection() { if (!$this->_regionCollection) { @@ -47,6 +86,11 @@ public function getRegionCollection() return $this->_regionCollection; } + /** + * Retrieve country collection + * + * @return Mage_Directory_Model_Resource_Country_Collection + */ public function getCountryCollection() { if (!$this->_countryCollection) { @@ -101,7 +145,15 @@ public function getRegionJson() return $this->_regionJson; } - public function currencyConvert($amount, $from, $to=null) + /** + * Convert currency + * + * @param float $amount + * @param string $from + * @param string $to + * @return float + */ + public function currencyConvert($amount, $from, $to = null) { if (empty($this->_currencyCache[$from])) { $this->_currencyCache[$from] = Mage::getModel('directory/currency')->load($from); @@ -117,13 +169,13 @@ public function currencyConvert($amount, $from, $to=null) * Return ISO2 country codes, which have optional Zip/Postal pre-configured * * @param bool $asJson - * @return array + * @return array|string */ public function getCountriesWithOptionalZip($asJson = false) { if (null === $this->_optionalZipCountries) { $this->_optionalZipCountries = preg_split('/\,/', - Mage::getStoreConfig('general/country/optional_zip_countries'), 0, PREG_SPLIT_NO_EMPTY); + Mage::getStoreConfig(self::OPTIONAL_ZIP_COUNTRIES_CONFIG_PATH), 0, PREG_SPLIT_NO_EMPTY); } if ($asJson) { return Mage::helper('core')->jsonEncode($this->_optionalZipCountries); @@ -135,6 +187,7 @@ public function getCountriesWithOptionalZip($asJson = false) * Check whether zip code is optional for specified country code * * @param string $countryCode + * @return boolean */ public function isZipCodeOptional($countryCode) { diff --git a/app/code/core/Mage/Directory/Model/Resource/Country/Collection.php b/app/code/core/Mage/Directory/Model/Resource/Country/Collection.php index 9db0c52f85..0bccc427f5 100755 --- a/app/code/core/Mage/Directory/Model/Resource/Country/Collection.php +++ b/app/code/core/Mage/Directory/Model/Resource/Country/Collection.php @@ -147,7 +147,7 @@ public function toOptionArray($emptyLabel = ' ') } } - ksort($sort); + Mage::helper('core/string')->ksortMultibyte($sort); $options = array(); foreach ($sort as $label=>$value) { $options[] = array( diff --git a/app/code/core/Mage/Directory/Model/Resource/Currency.php b/app/code/core/Mage/Directory/Model/Resource/Currency.php index 958f15c9e5..7bb4e3926e 100755 --- a/app/code/core/Mage/Directory/Model/Resource/Currency.php +++ b/app/code/core/Mage/Directory/Model/Resource/Currency.php @@ -131,7 +131,7 @@ public function getAnyRate($currencyFrom, $currencyTo) $rate = $adapter->fetchOne($select, $bind); if ($rate === false) { $select = $adapter->select() - ->from($this->_currencyRateTable, "1/rate") + ->from($this->_currencyRateTable, new Zend_Db_Expr('1/rate')) ->where('currency_to = :currency_from') ->where('currency_from = :currency_to'); $rate = $adapter->fetchOne($select, $bind); @@ -178,7 +178,7 @@ public function saveRates($rates) * * @param Mage_Directory_Model_Currency $model * @param string $path - * + * * @return array */ public function getConfigCurrencies($model, $path) @@ -203,7 +203,7 @@ public function getConfigCurrencies($model, $path) * * @param string|array $currency * @param array $toCurrencies - * + * * @return array */ public function getCurrencyRates($currency, $toCurrencies = null) diff --git a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php b/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php index 03cbaa7503..c002eeb678 100644 --- a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php +++ b/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php @@ -124,6 +124,7 @@ public function linkAction() $this->_getCustomerSession()->addError(Mage::helper('downloadable')->__('An error occurred while getting the requested content.')); } } + exit(0); } } diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Text.php b/app/code/core/Mage/Eav/Model/Attribute/Data/Text.php index 0428564b39..6650a85b78 100644 --- a/app/code/core/Mage/Eav/Model/Attribute/Data/Text.php +++ b/app/code/core/Mage/Eav/Model/Attribute/Data/Text.php @@ -82,7 +82,7 @@ public function validateValue($value) } if (!empty($validateRules['max_text_length']) && $length > $validateRules['max_text_length']) { $v = $validateRules['max_text_length']; - $errors[] = Mage::helper('eav')->__('"%s" length must be equal or greater than %s characters.', $label, $v); + $errors[] = Mage::helper('eav')->__('"%s" length must be equal or less than %s characters.', $label, $v); } $result = $this->_validateInputRule($value); diff --git a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php index 4878f6329c..8022ec9869 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php @@ -1170,6 +1170,7 @@ protected function _getAttributeTableAlias($attributeCode) */ protected function _getAttributeFieldName($attributeCode) { + $attributeCode = trim($attributeCode); if (isset($this->_joinAttributes[$attributeCode]['condition_alias'])) { return $this->_joinAttributes[$attributeCode]['condition_alias']; } diff --git a/app/code/core/Mage/GiftMessage/sql/giftmessage_setup/install-1.6.0.0.php b/app/code/core/Mage/GiftMessage/sql/giftmessage_setup/install-1.6.0.0.php index 6a671fa540..820c558b50 100644 --- a/app/code/core/Mage/GiftMessage/sql/giftmessage_setup/install-1.6.0.0.php +++ b/app/code/core/Mage/GiftMessage/sql/giftmessage_setup/install-1.6.0.0.php @@ -79,8 +79,10 @@ /** * Add 'gift_message_available' attributes for entities */ -$installer->addAttribute('order_item', 'gift_message_available', $options) - ->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'gift_message_available', array( +$installer->addAttribute('order_item', 'gift_message_available', $options); +Mage::getResourceModel('catalog/setup', 'catalog_setup')->addAttribute( + Mage_Catalog_Model_Product::ENTITY, 'gift_message_available', + array( 'group' => 'Gift Options', 'backend' => 'catalog/product_attribute_backend_boolean', 'frontend' => '', @@ -97,6 +99,7 @@ 'input_renderer' => 'giftmessage/adminhtml_product_helper_form_config', 'is_configurable' => 0, 'visible_on_front' => false - )); + ) +); $installer->endSetup(); diff --git a/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php b/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php index 449f879aa9..91adab65b3 100644 --- a/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php +++ b/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php @@ -885,7 +885,11 @@ protected function _responseRefundAmountNotification() $totalRefunded = $this->getData('root/total-refund-amount/VALUE'); $order = $this->getOrder(); - $amountRefundLeft = $order->getBaseGrandTotal() - $order->getBaseTotalRefunded(); + $amountRefundLeft = $order->getBaseGrandTotal() - $order->getBaseTotalRefunded() + - $order->getBaseAdjustmentNegative(); + if (abs($amountRefundLeft) < .0001) { + return; + } if ($amountRefundLeft < $latestRefunded) { $latestRefunded = $amountRefundLeft; $totalRefunded = $order->getBaseGrandTotal(); @@ -972,9 +976,6 @@ protected function _addChildTransaction($typeTarget, $typeParent = Mage_Sales_Mo $payment->setParentTransactionId($parentTransactionId) ->setTransactionId($googleOrderId . '-' . $typeTarget) ->addTransaction($typeTarget); - - $parentTransaction->setIsClosed(true) - ->save(); } return $this; diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php index b77329700f..206b62fafd 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php @@ -266,7 +266,7 @@ protected function _prepareMediaGallery(array $productIds) ) ->joinLeft( array('mgv' => $resource->getTableName('catalog/product_attribute_media_gallery_value')), - '(mg.value_id = mgv.value_id)', + '(mg.value_id = mgv.value_id AND mgv.store_id = 0)', array() ) ->where('entity_id IN(?)', $productIds); diff --git a/app/code/core/Mage/ImportExport/Model/Import.php b/app/code/core/Mage/ImportExport/Model/Import.php index 72f294ee49..2a0b9bd2e8 100644 --- a/app/code/core/Mage/ImportExport/Model/Import.php +++ b/app/code/core/Mage/ImportExport/Model/Import.php @@ -404,25 +404,28 @@ public function expandSource() public function uploadSource() { $entity = $this->getEntity(); - $uploader = new Mage_Core_Model_File_Uploader(self::FIELD_NAME_SOURCE_FILE); + $uploader = Mage::getModel('core/file_uploader', self::FIELD_NAME_SOURCE_FILE); $uploader->skipDbProcessing(true); $result = $uploader->save(self::getWorkingDir()); $extension = pathinfo($result['file'], PATHINFO_EXTENSION); + $uploadedFile = $result['path'] . $result['file']; if (!$extension) { - unlink($result['path'] . $result['file']); + unlink($uploadedFile); Mage::throwException(Mage::helper('importexport')->__('Uploaded file has no extension')); } $sourceFile = self::getWorkingDir() . $entity; $sourceFile .= '.' . $extension; - if (file_exists($sourceFile)) { - unlink($sourceFile); - } + if(strtolower($uploadedFile) != strtolower($sourceFile)) { + if (file_exists($sourceFile)) { + unlink($sourceFile); + } - if (!@rename($result['path'] . $result['file'], $sourceFile)) { - Mage::throwException(Mage::helper('importexport')->__('Source file moving failed')); + if (!@rename($uploadedFile, $sourceFile)) { + Mage::throwException(Mage::helper('importexport')->__('Source file moving failed')); + } } // trying to create source adapter for file and catch possible exception to be convinced in its adequacy try { diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php index 51740a4201..80304dfd0b 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php @@ -217,6 +217,15 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo '_media_position', '_media_is_disabled' ); + /** + * Column names that holds images files names + * + * @var array + */ + protected $_imagesArrayKeys = array( + '_media_image', 'image', 'small_image', 'thumbnail' + ); + /** * Permanent entity columns. * @@ -259,6 +268,13 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo */ protected $_websiteCodeToStoreIds = array(); + /** + * Media files uploader + * + * @var Mage_ImportExport_Model_Import_Uploader + */ + protected $_fileUploader; + /** * Constructor. * @@ -1036,6 +1052,7 @@ protected function _saveProducts() $categories = array(); $tierPrices = array(); $mediaGallery = array(); + $uploadedGalleryFiles = array(); foreach ($bunch as $rowNum => $rowData) { if (!$this->validateRow($rowData, $rowNum)) { @@ -1094,19 +1111,24 @@ protected function _saveProducts() 0 : $this->_websiteCodeToId[$rowData['_tier_price_website']] ); } - if (!empty($rowData['_media_image'])) { // 5. Media gallery phase - $mediaGallery['file'][$rowSku][] = array( + foreach ($this->_imagesArrayKeys as $imageCol) { + if (!empty($rowData[$imageCol])) { // 5. Media gallery phase + if (!array_key_exists($rowData[$imageCol], $uploadedGalleryFiles)) { + $uploadedGalleryFiles[$rowData[$imageCol]] = $this->_uploadMediaFiles($rowData[$imageCol]); + } + $rowData[$imageCol] = $uploadedGalleryFiles[$rowData[$imageCol]]; + } + } + if (!empty($rowData['_media_image'])) { + $mediaGallery[$rowSku][] = array( 'attribute_id' => $rowData['_media_attribute_id'], - 'value' => $rowData['_media_image'] - ); - $mediaGallery['value'][$rowSku][] = array( 'label' => $rowData['_media_lable'], 'position' => $rowData['_media_position'], 'disabled' => $rowData['_media_is_disabled'], 'value' => $rowData['_media_image'] ); } - // 5. Attributes phase + // 6. Attributes phase if (self::SCOPE_NULL == $rowScope) { continue; // skip attribute processing for SCOPE_NULL rows } @@ -1193,6 +1215,45 @@ protected function _saveProductTierPrices(array $tierPriceData) return $this; } + /** + * Returns an object for upload a media files + */ + protected function _getUploader() + { + if (is_null($this->_fileUploader)) { + $this->_fileUploader = new Mage_ImportExport_Model_Import_Uploader(); + + $this->_fileUploader->init(); + + $tmpDir = Mage::getConfig()->getOptions()->getMediaDir() . '/import'; + $destDir = Mage::getConfig()->getOptions()->getMediaDir() . '/catalog/product'; + if (!$this->_fileUploader->setTmpDir($tmpDir)) { + Mage::throwException("File directory '{$tmpDir}' is not readable."); + } + if (!$this->_fileUploader->setDestDir($destDir)) { + Mage::throwException("File directory '{$destDir}' is not writable."); + } + } + return $this->_fileUploader; + } + + /** + * Uploading files into the "catalog/product" media folder. + * Return a new file name if the same file is already exists. + * + * @param string $fileName + * @return string + */ + protected function _uploadMediaFiles($fileName) + { + try { + $res = $this->_getUploader()->move($fileName); + return $res['file']; + } catch (Exception $e) { + return ''; + } + } + /** * Save product media gallery. * @@ -1219,49 +1280,57 @@ protected function _saveMediaGallery(array $mediaGalleryData) ->getTable('catalog/product_attribute_media_gallery_value'); } - $mediaGalleryIn = array(); - $delProductId = array(); - - foreach ($mediaGalleryData['file'] as $delSku => $mediaGalleryRows) { - $productId = $this->_newSku[$delSku]['entity_id']; - $delProductId[] = $productId; + foreach ($mediaGalleryData as $productSku => $mediaGalleryRows) { + $productId = $this->_newSku[$productSku]['entity_id']; + $insertedGalleryImgs = array(); - foreach ($mediaGalleryRows as $row) { - $row['entity_id'] = $productId; - $mediaGalleryIn['file'][] = $row; + if (Mage_ImportExport_Model_Import::BEHAVIOR_APPEND != $this->getBehavior()) { + $this->_connection->delete( + $mediaGalleryTableName, + $this->_connection->quoteInto('entity_id IN (?)', $productId) + ); } - } - $mediaGalleryIn['value'] = array_shift($mediaGalleryData['value']); - if (Mage_ImportExport_Model_Import::BEHAVIOR_APPEND != $this->getBehavior()) { - $this->_connection->delete( - $tableName, - $this->_connection->quoteInto('entity_id IN (?)', $delProductId) - ); - } - if ($mediaGalleryIn['file']) { - $this->_connection - ->insertOnDuplicate($mediaGalleryTableName, $mediaGalleryIn['file'], array('entity_id')); + foreach ($mediaGalleryRows as $insertValue) { - $newMediaValues = $this->_connection->fetchPairs($this->_connection->select() - ->from($mediaGalleryTableName, array('value', 'value_id')) - ->where('entity_id IN (?)', $productId) - ); + if (!in_array($insertValue['value'], $insertedGalleryImgs)) { + $valueArr = array( + 'attribute_id' => $insertValue['attribute_id'], + 'entity_id' => $productId, + 'value' => $insertValue['value'] + ); - $mediaGalleryValueKeys = array_keys($mediaGalleryIn['value']); - foreach ($mediaGalleryValueKeys as $valueKey) { - $fileName = $mediaGalleryIn['value'][$valueKey]['value']; - unset($mediaGalleryIn['value'][$valueKey]['value']); - $mediaGalleryIn['value'][$valueKey]['value_id'] = $newMediaValues[$fileName]; - } + $this->_connection + ->insertOnDuplicate($mediaGalleryTableName, $valueArr, array('entity_id')); - try { - $this->_connection - ->insertOnDuplicate($mediaValueTableName, $mediaGalleryIn['value'], array('value_id')); - } catch (Exception $e) { - $this->_connection->delete( - $mediaGalleryTableName, $this->_connection->quoteInto('value_id IN (?)', $newMediaValues) + $insertedGalleryImgs[] = $insertValue['value']; + } + + $newMediaValues = $this->_connection->fetchPairs($this->_connection->select() + ->from($mediaGalleryTableName, array('value', 'value_id')) + ->where('entity_id IN (?)', $productId) ); + + if (array_key_exists($insertValue['value'], $newMediaValues)) { + $insertValue['value_id'] = $newMediaValues[$insertValue['value']]; + } + + $valueArr = array( + 'value_id' => $insertValue['value_id'], + 'store_id' => Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID, + 'label' => $insertValue['label'], + 'position' => $insertValue['position'], + 'disabled' => $insertValue['disabled'] + ); + + try { + $this->_connection + ->insertOnDuplicate($mediaValueTableName, $valueArr, array('value_id')); + } catch (Exception $e) { + $this->_connection->delete( + $mediaGalleryTableName, $this->_connection->quoteInto('value_id IN (?)', $newMediaValues) + ); + } } } diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php index 0937eff0ff..8361417c30 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php @@ -43,6 +43,26 @@ class Mage_ImportExport_Model_Import_Entity_Product_Type_Grouped '_associated_sku', '_associated_default_qty', '_associated_position' ); + /** + * Import model behavior + * + * @var string + */ + protected $_behavior; + + /** + * Retrive model behavior + * + * @return string + */ + public function getBehavior() + { + if (is_null($this->_behavior)) { + $this->_behavior = Mage_ImportExport_Model_Import::getDataSourceModel()->getBehavior(); + } + return $this->_behavior; + } + /** * Save product type specific data. * @@ -130,7 +150,7 @@ public function saveData() } } // save links and relations - if ($linksData['product_ids']) { + if ($linksData['product_ids'] && $this->getBehavior() != Mage_ImportExport_Model_Import::BEHAVIOR_APPEND) { $connection->delete( $mainTable, $connection->quoteInto( @@ -151,7 +171,7 @@ public function saveData() ); } } - $connection->insertMultiple($mainTable, $mainData); + $connection->insertOnDuplicate($mainTable, $mainData); $connection->insertOnDuplicate($relationTable, $linksData['relation']); } // save positions and default quantity @@ -174,10 +194,10 @@ public function saveData() } } if ($linksData['position']) { - $connection->insertMultiple($attributes['position']['table'], $linksData['position']); + $connection->insertOnDuplicate($attributes['position']['table'], $linksData['position']); } if ($linksData['qty']) { - $connection->insertMultiple($attributes['qty']['table'], $linksData['qty']); + $connection->insertOnDuplicate($attributes['qty']['table'], $linksData['qty']); } } } diff --git a/app/code/core/Mage/ImportExport/Model/Import/Uploader.php b/app/code/core/Mage/ImportExport/Model/Import/Uploader.php new file mode 100644 index 0000000000..8900ed1ffd --- /dev/null +++ b/app/code/core/Mage/ImportExport/Model/Import/Uploader.php @@ -0,0 +1,223 @@ + + */ +class Mage_ImportExport_Model_Import_Uploader extends Mage_Core_Model_File_Uploader +{ + protected $_tmpDir = ''; + protected $_destDir = ''; + protected $_allowedMimeTypes = array( + 'jpg' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'gif' => 'image/gif', + 'png' => 'image/png' + ); + const DEFAULT_FILE_TYPE = 'application/octet-stream'; + + function __construct($filePath = null) + { + if (!is_null($filePath)) { + $this->_setUploadFile($filePath); + } + } + + /** + * Initiate uploader defoult settings + */ + public function init() + { + $this->setAllowRenameFiles(true); + $this->setAllowCreateFolders(true); + $this->setFilesDispersion(true); + $this->setAllowedExtensions(array_keys($this->_allowedMimeTypes)); + $this->addValidateCallback('catalog_product_image', + Mage::helper('catalog/image'), 'validateUploadFile'); + $this->_uploadType = self::SINGLE_STYLE; + } + + /** + * Proceed moving a file from TMP to destination folder + * + * @param string $fileName + * @return array + */ + public function move($fileName) + { + $filePath = realpath($this->getTmpDir() . DS . $fileName); + $this->_setUploadFile($filePath); + $result = $this->save($this->getDestDir()); + $result['name'] = self::getCorrectFileName($result['name']); + return $result; + } + + /** + * Prepare information about the file for moving + * + * @param string $filePath + */ + protected function _setUploadFile($filePath) + { + if (!is_readable($filePath)) { + Mage::throwException("File '{$filePath}' was not found or has read restriction."); + } + $this->_file = $this->_readFileInfo($filePath); + + $this->_validateFile(); + } + + /** + * Reads file info + * + * @param string $filePath + * @return array + */ + protected function _readFileInfo($filePath) + { + $fileInfo = pathinfo($filePath); + + return array( + 'name' => $fileInfo['basename'], + 'type' => $this->_getMimeTypeByExt($fileInfo['extension']), + 'tmp_name' => $filePath, + 'error' => 0, + 'size' => filesize($filePath) + ); + } + + /** + * Validate uploaded file by type and etc. + */ + protected function _validateFile() + { + $filePath = $this->_file['tmp_name']; + if (is_readable($filePath)) { + $this->_fileExists = true; + } else { + $this->_fileExists = false; + } + + $fileExtension = pathinfo($filePath, PATHINFO_EXTENSION); + if (!$this->checkAllowedExtension($fileExtension)) { + throw new Exception('Disallowed file type.'); + } + //run validate callbacks + foreach ($this->_validateCallbacks as $params) { + if (is_object($params['object']) && method_exists($params['object'], $params['method'])) { + $params['object']->$params['method']($filePath); + } + } + } + + /** + * Returns file MIME type by extension + * + * @param string $ext + * @return string + */ + protected function _getMimeTypeByExt($ext) + { + if (array_key_exists($ext, $this->_allowedMimeTypes)) { + return $this->_allowedMimeTypes[$ext]; + } + return ''; + } + + /** + * Obtain TMP file path prefix + * + * @return string + */ + public function getTmpDir() + { + return $this->_tmpDir; + } + + /** + * Set TMP file path prefix + * + * @param type $path + * @return bool + */ + public function setTmpDir($path) + { + if (is_string($path) && is_readable($path)) { + $this->_tmpDir = $path; + return true; + } + return false; + } + + /** + * Obtain destination file path prefix + * + * @return string + */ + public function getDestDir() + { + return $this->_destDir; + } + + /** + * Set destination file path prefix + * + * @param type $path + * @return bool + */ + public function setDestDir($path) + { + if (is_string($path) && is_writable($path)) { + $this->_destDir = $path; + return true; + } + return false; + } + + /** + * Move files from TMP folder into destination folder + * + * @param string $tmpPath + * @param string $destPath + * @return bool + */ + protected function _moveFile($tmpPath, $destPath = null) + { + $sourceFile = realpath($tmpPath); + $destPath = is_null($destPath) ? $tmpPath : $destPath; + $destinationFile = $destPath; + if ($sourceFile !== false) { + return copy($sourceFile, $destinationFile); + } else { + return false; + } + } + +} diff --git a/app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php b/app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php index dd0a904bd9..40facc25ce 100644 --- a/app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php +++ b/app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php @@ -38,7 +38,7 @@ class Mage_ImportExport_Model_Resource_Helper_Mysql4 extends Mage_Core_Model_Res * Constants to be used for DB */ const DB_MAX_PACKET_SIZE = 1048576; // Maximal packet length by default in MySQL - const DB_MAX_PACKET_COEFFICIENT = 0.9; // The coefficient of useful data from maximum packet length + const DB_MAX_PACKET_COEFFICIENT = 0.85; // The coefficient of useful data from maximum packet length /** * Returns maximum size of packet, that we can send to DB diff --git a/app/code/core/Mage/Install/Block/Db/Type/Mysql4.php b/app/code/core/Mage/Install/Block/Db/Type/Mysql4.php index e42bc05a6f..c0afd264de 100644 --- a/app/code/core/Mage/Install/Block/Db/Type/Mysql4.php +++ b/app/code/core/Mage/Install/Block/Db/Type/Mysql4.php @@ -36,5 +36,5 @@ class Mage_Install_Block_Db_Type_Mysql4 extends Mage_Install_Block_Db_Type * * @var string */ - protected $_title = 'Mysql'; + protected $_title = 'MySQL'; } diff --git a/app/code/core/Mage/Log/Model/Cron.php b/app/code/core/Mage/Log/Model/Cron.php index 1094a01376..ee6cd561af 100644 --- a/app/code/core/Mage/Log/Model/Cron.php +++ b/app/code/core/Mage/Log/Model/Cron.php @@ -37,6 +37,7 @@ class Mage_Log_Model_Cron extends Mage_Core_Model_Abstract const XML_PATH_EMAIL_LOG_CLEAN_TEMPLATE = 'system/log/error_email_template'; const XML_PATH_EMAIL_LOG_CLEAN_IDENTITY = 'system/log/error_email_identity'; const XML_PATH_EMAIL_LOG_CLEAN_RECIPIENT = 'system/log/error_email'; + const XML_PATH_LOG_CLEAN_ENABLED = 'system/log/enabled'; /** * Error messages @@ -86,6 +87,10 @@ protected function _sendLogCleanEmail() */ public function logClean() { + if (!Mage::getStoreConfigFlag(self::XML_PATH_LOG_CLEAN_ENABLED)) { + return $this; + } + $this->_errors = array(); try { diff --git a/app/code/core/Mage/Newsletter/Model/Subscriber.php b/app/code/core/Mage/Newsletter/Model/Subscriber.php index 9f3a78900d..b62834027b 100644 --- a/app/code/core/Mage/Newsletter/Model/Subscriber.php +++ b/app/code/core/Mage/Newsletter/Model/Subscriber.php @@ -313,23 +313,23 @@ public function subscribe($email) $this->setSubscriberConfirmCode($this->randomSequence()); } - $isConfirmNeed = (Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1) ? true : false; + $isConfirmNeed = (Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1) ? true : false; $isOwnSubscribes = false; + $ownerId = Mage::getModel('customer/customer') + ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()) + ->loadByEmail($email) + ->getId(); + $isSubscribeOwnEmail = $customerSession->isLoggedIn() && $ownerId == $customerSession->getId(); if (!$this->getId() || $this->getStatus() == self::STATUS_UNSUBSCRIBED || $this->getStatus() == self::STATUS_NOT_ACTIVE ) { if ($isConfirmNeed === true) { // if user subscribes own login email - confirmation is not needed - $ownerId = Mage::getModel('customer/customer') - ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()) - ->loadByEmail($email) - ->getId(); - $isOwnSubscribes = ($customerSession->isLoggedIn() && $ownerId == $customerSession->getId()); + $isOwnSubscribes = $isSubscribeOwnEmail; if ($isOwnSubscribes == true){ $this->setStatus(self::STATUS_SUBSCRIBED); - } - else { + } else { $this->setStatus(self::STATUS_NOT_ACTIVE); } } else { @@ -338,7 +338,7 @@ public function subscribe($email) $this->setSubscriberEmail($email); } - if ($customerSession->isLoggedIn()) { + if ($isSubscribeOwnEmail) { $this->setStoreId($customerSession->getCustomer()->getStoreId()); $this->setCustomerId($customerSession->getCustomerId()); } else { @@ -359,8 +359,7 @@ public function subscribe($email) } return $this->getStatus(); - } - catch (Exception $e) { + } catch (Exception $e) { throw new Exception($e->getMessage()); } } diff --git a/app/code/core/Mage/Page/Block/Template/Links.php b/app/code/core/Mage/Page/Block/Template/Links.php index 5b240d12f0..e34d6a6bb4 100644 --- a/app/code/core/Mage/Page/Block/Template/Links.php +++ b/app/code/core/Mage/Page/Block/Template/Links.php @@ -42,6 +42,13 @@ class Mage_Page_Block_Template_Links extends Mage_Core_Block_Template */ protected $_links = array(); + /** + * Cache key info + * + * @var null|array + */ + protected $_cacheKeyInfo = null; + /** * Set default template * @@ -138,18 +145,22 @@ public function removeLinkByUrl($url) */ public function getCacheKeyInfo() { - $links = array(); - if (!empty($this->_links)) { - foreach ($this->_links as $position => $link) { - if ($link instanceof Varien_Object) { - $links[$position] = $link->getData(); + if (is_null($this->_cacheKeyInfo)) { + $links = array(); + if (!empty($this->_links)) { + foreach ($this->_links as $position => $link) { + if ($link instanceof Varien_Object) { + $links[$position] = $link->getData(); + } } } + $this->_cacheKeyInfo = parent::getCacheKeyInfo() + array( + 'links' => base64_encode(serialize($links)), + 'name' => $this->getNameInLayout() + ); } - return parent::getCacheKeyInfo() + array( - 'links' => base64_encode(serialize($links)), - 'name' => $this->getNameInLayout() - ); + + return $this->_cacheKeyInfo; } /** diff --git a/app/code/core/Mage/Paypal/Model/Api/Nvp.php b/app/code/core/Mage/Paypal/Model/Api/Nvp.php index 14194e3264..efec35ae8e 100644 --- a/app/code/core/Mage/Paypal/Model/Api/Nvp.php +++ b/app/code/core/Mage/Paypal/Model/Api/Nvp.php @@ -169,6 +169,10 @@ class Mage_Paypal_Model_Api_Nvp extends Mage_Paypal_Model_Api_Abstract 'PROFILESTATUS' => 'recurring_profile_status', 'STATUS' => 'status', + //Next two fields are used for Brazil only + 'TAXID' => 'buyer_tax_id', + 'TAXIDTYPE' => 'buyer_tax_id_type', + 'BILLINGAGREEMENTID' => 'billing_agreement_id', 'REFERENCEID' => 'reference_id', 'BILLINGAGREEMENTSTATUS' => 'billing_agreement_status', @@ -413,7 +417,7 @@ class Mage_Paypal_Model_Api_Nvp extends Mage_Paypal_Model_Api_Abstract */ protected $_paymentInformationResponse = array( 'PAYERID', 'PAYERSTATUS', 'CORRELATIONID', 'ADDRESSID', 'ADDRESSSTATUS', - 'PAYMENTSTATUS', 'PENDINGREASON', 'PROTECTIONELIGIBILITY', 'EMAIL', 'SHIPPINGOPTIONNAME' + 'PAYMENTSTATUS', 'PENDINGREASON', 'PROTECTIONELIGIBILITY', 'EMAIL', 'SHIPPINGOPTIONNAME', 'TAXID', 'TAXIDTYPE' ); /** @@ -554,7 +558,7 @@ public function getApiEndpoint() */ public function getVersion() { - return '65.2'; + return '72.0'; } /** diff --git a/app/code/core/Mage/Paypal/Model/Express.php b/app/code/core/Mage/Paypal/Model/Express.php index b2675bd16b..ffa472411b 100644 --- a/app/code/core/Mage/Paypal/Model/Express.php +++ b/app/code/core/Mage/Paypal/Model/Express.php @@ -318,13 +318,24 @@ public function capture(Varien_Object $payment, $amount) $payment->setParentTransactionId($api->getTransactionId()); $isAuthorizationCreated = true; } + //close order transaction if needed + if ($payment->getShouldCloseParentTransaction()) { + $orderTransaction = $payment->lookupTransaction( + false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER + ); + + if ($orderTransaction) { + $orderTransaction->setIsClosed(true); + $order->addRelatedObject($orderTransaction); + } + } } if (false === $this->_pro->capture($payment, $amount)) { $this->_placeOrder($payment, $amount); } - if ($isAuthorizationCreated && $transaction) { + if ($isAuthorizationCreated && isset($transaction)) { $transaction->setIsClosed(true); } diff --git a/app/code/core/Mage/Paypal/Model/Info.php b/app/code/core/Mage/Paypal/Model/Info.php index 7bc009b38d..d7ee29aaf5 100644 --- a/app/code/core/Mage/Paypal/Model/Info.php +++ b/app/code/core/Mage/Paypal/Model/Info.php @@ -51,6 +51,10 @@ class Mage_Paypal_Model_Info const CENTINEL_VPAS = 'centinel_vpas_result'; const CENTINEL_ECI = 'centinel_eci_result'; + // Next two fields are required for Brazil + const BUYER_TAX_ID = 'buyer_tax_id'; + const BUYER_TAX_ID_TYPE = 'buyer_tax_id_type'; + const PAYMENT_STATUS = 'payment_status'; const PENDING_REASON = 'pending_reason'; const IS_FRAUD = 'is_fraud_detected'; @@ -58,6 +62,12 @@ class Mage_Paypal_Model_Info const PENDING_REASON_GLOBAL = 'paypal_pending_reason'; const IS_FRAUD_GLOBAL = 'paypal_is_fraud_detected'; + /** + * Possible buyer's tax id types (Brazil only) + */ + const BUYER_TAX_ID_TYPE_CPF = 'BR_CPF'; + const BUYER_TAX_ID_TYPE_CNPJ = 'BR_CNPJ'; + /** * All payment information map * @@ -76,6 +86,8 @@ class Mage_Paypal_Model_Info self::CVV2_MATCH => 'paypal_cvv2_match', self::CENTINEL_VPAS => self::CENTINEL_VPAS, self::CENTINEL_ECI => self::CENTINEL_ECI, + self::BUYER_TAX_ID => self::BUYER_TAX_ID, + self::BUYER_TAX_ID_TYPE => self::BUYER_TAX_ID_TYPE, ); /** @@ -115,6 +127,8 @@ class Mage_Paypal_Model_Info */ protected $_paymentPublicMap = array( 'paypal_payer_email', + self::BUYER_TAX_ID, + self::BUYER_TAX_ID_TYPE ); /** @@ -425,6 +439,10 @@ protected function _getLabel($key) return Mage::helper('paypal')->__('Address Verification System Response'); case 'paypal_cvv2_match': return Mage::helper('paypal')->__('CVV2 Check Result by PayPal'); + case self::BUYER_TAX_ID : + return Mage::helper('paypal')->__('Buyer\'s Tax ID'); + case self::BUYER_TAX_ID_TYPE : + return Mage::helper('paypal')->__('Buyer\'s Tax ID Type'); case self::CENTINEL_VPAS: return Mage::helper('paypal')->__('PayPal/Centinel Visa Payer Authentication Service Result'); case self::CENTINEL_ECI: @@ -456,6 +474,8 @@ protected function _getValue($value, $key) case self::CENTINEL_ECI: $label = $this->_getCentinelEciLabel($value); break; + case self::BUYER_TAX_ID_TYPE : + $value = $this->_getBuyerIdTypeValue($value); default: return $value; } @@ -620,4 +640,24 @@ private function _getCentinelEciLabel($value) return $value; } } + + /** + * Retrieve buyer id type value based on code received from PayPal (Brazil only) + * + * @param string $code + * @return string + */ + protected function _getBuyerIdTypeValue($code) + { + $value = ''; + switch ($code) { + case self::BUYER_TAX_ID_TYPE_CNPJ : + $value = Mage::helper('paypal')->__('CNPJ'); + break; + case self::BUYER_TAX_ID_TYPE_CPF : + $value = Mage::helper('paypal')->__('CPF'); + break; + } + return $value; + } } diff --git a/app/code/core/Mage/Paypal/Model/Ipn.php b/app/code/core/Mage/Paypal/Model/Ipn.php index 398d6cccb2..f7353161bd 100644 --- a/app/code/core/Mage/Paypal/Model/Ipn.php +++ b/app/code/core/Mage/Paypal/Model/Ipn.php @@ -536,9 +536,12 @@ protected function _registerPaymentVoid() { $this->_importPaymentInformation(); + $parentTrxId = $this->getRequestData('parent_txn_id') ? $this->getRequestData('parent_txn_id') + : $this->getRequestData('txn_id'); + $this->_order->getPayment() ->setPreparedMessage($this->_createIpnComment('')) - ->setParentTransactionId($this->getRequestData('txn_id')) // this is the authorization transaction ID + ->setParentTransactionId($parentTrxId) ->registerVoidNotification(); $this->_order->save(); } diff --git a/app/code/core/Mage/Paypal/Model/Payflowlink.php b/app/code/core/Mage/Paypal/Model/Payflowlink.php index cec352841d..81cc5bb6e9 100644 --- a/app/code/core/Mage/Paypal/Model/Payflowlink.php +++ b/app/code/core/Mage/Paypal/Model/Payflowlink.php @@ -211,7 +211,7 @@ protected function _processOrder(Mage_Sales_Model_Order $order) $payment->setAdditionalInformation('paypal_cvv2_match', $response->getCvv2match()); } - switch ($response->getType()){ + switch ($response->getTrxtype()){ case self::TRXTYPE_AUTH_ONLY: $payment->registerAuthorizationNotification($payment->getBaseAmountAuthorized()); break; diff --git a/app/code/core/Mage/Persistent/Helper/Data.php b/app/code/core/Mage/Persistent/Helper/Data.php index b461147120..e05aab2cff 100644 --- a/app/code/core/Mage/Persistent/Helper/Data.php +++ b/app/code/core/Mage/Persistent/Helper/Data.php @@ -146,4 +146,24 @@ public function getPersistentConfigFilePath() { return Mage::getConfig()->getModuleDir('etc', $this->_getModuleName()) . DS . $this->_configFileName; } + + /** + * Check whether specified action should be processed + * + * @param Varien_Event_Observer $observer + * @return bool + */ + public function canProcess($observer) + { + $action = $observer->getEvent()->getAction(); + $controllerAction = $observer->getEvent()->getControllerAction(); + + if ($action instanceof Mage_Core_Controller_Varien_Action) { + return !$action->getFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION); + } + if ($controllerAction instanceof Mage_Core_Controller_Varien_Action) { + return !$controllerAction->getFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION); + } + return true; + } } diff --git a/app/code/core/Mage/Persistent/Model/Observer.php b/app/code/core/Mage/Persistent/Model/Observer.php index 36e6429928..5504722a49 100644 --- a/app/code/core/Mage/Persistent/Model/Observer.php +++ b/app/code/core/Mage/Persistent/Model/Observer.php @@ -49,7 +49,8 @@ class Mage_Persistent_Model_Observer */ public function applyPersistentData($observer) { - if (!$this->_getPersistentHelper()->isPersistent() || Mage::getSingleton('customer/session')->isLoggedIn()) { + if (!Mage::helper('persistent')->canProcess($observer) + || !$this->_getPersistentHelper()->isPersistent() || Mage::getSingleton('customer/session')->isLoggedIn()) { return $this; } Mage::getModel('persistent/persistent_config') @@ -58,6 +59,42 @@ public function applyPersistentData($observer) return $this; } + /** + * Apply persistent data to specific block + * + * @param Varien_Event_Observer $observer + * @return Mage_Persistent_Model_Observer + */ + public function applyBlockPersistentData($observer) + { + if (!$this->_getPersistentHelper()->isPersistent() || Mage::getSingleton('customer/session')->isLoggedIn()) { + return $this; + } + + /** @var $block Mage_Core_Block_Abstract */ + $block = $observer->getEvent()->getBlock(); + $placeholder = $observer->getEvent()->getPlaceholder(); + + if (!$block || !$placeholder) { + return $this; + } + + $xPath = '//instances/blocks/*[block_type="' . get_class($block) . '"]'; + $configFilePath = $observer->getEvent()->getConfigFilePath(); + + /** @var $persistentConfig Mage_Persistent_Model_Persistent_Config */ + $persistentConfig = Mage::getModel('persistent/persistent_config') + ->setConfigFilePath( + $configFilePath ? $configFilePath : Mage::helper('persistent')->getPersistentConfigFilePath() + ); + + foreach ($persistentConfig->getXmlConfig()->xpath($xPath) as $persistentConfigInfo) { + $persistentConfig->fireOne($persistentConfigInfo->asArray(), $block); + } + + return $this; + } + /** * Emulate 'welcome' block with persistent data * @@ -70,15 +107,54 @@ public function emulateWelcomeBlock($block) Mage::helper('persistent')->__('Welcome, %s!', Mage::helper('core')->escapeHtml($this->_getPersistentCustomer()->getName(), null)) ); - $additionalBlock = $block->getLayout()->getBlock('header.additional'); - if ($additionalBlock) { - $block->setAdditionalHtml($additionalBlock->toHtml()); - } - $block->getLayout()->getBlock('top.links')->removeLinkByUrl(Mage::getUrl('customer/account/login')); + $this->_applyAccountLinksPersistentData(); + $block->setAdditionalHtml(Mage::app()->getLayout()->getBlock('header.additional')->toHtml()); return $this; } + /** + * Emulate 'account links' block with persistent data + */ + protected function _applyAccountLinksPersistentData() + { + if (!Mage::app()->getLayout()->getBlock('header.additional')) { + Mage::app()->getLayout()->addBlock('persistent/header_additional', 'header.additional'); + } + } + + /** + * Emulate 'account links' block with persistent data + * + * @param Mage_Core_Block_Abstract $block + */ + public function emulateAccountLinks($block) + { + $this->_applyAccountLinksPersistentData(); + $block->getCacheKeyInfo(); + $block->addLink( + Mage::helper('persistent')->getPersistentName(), + Mage::helper('persistent')->getUnsetCookieUrl(), + Mage::helper('persistent')->getPersistentName(), + false, + array(), + 110 + ); + $block->removeLinkByUrl(Mage::helper('customer')->getRegisterUrl()); + $block->removeLinkByUrl(Mage::helper('customer')->getLoginUrl()); + } + + /** + * Emulate 'top links' block with persistent data + * + * @param Mage_Core_Block_Abstract $block + */ + public function emulateTopLinks($block) + { + $this->_applyAccountLinksPersistentData(); + $block->removeLinkByUrl(Mage::getUrl('customer/account/login')); + } + /** * Emulate quote by persistent data * @@ -91,7 +167,8 @@ public function emulateQuote($observer) 'customer_account_createpost' ); - if (!$this->_getPersistentHelper()->isPersistent() || Mage::getSingleton('customer/session')->isLoggedIn()) { + if (!Mage::helper('persistent')->canProcess($observer) + || !$this->_getPersistentHelper()->isPersistent() || Mage::getSingleton('customer/session')->isLoggedIn()) { return; } @@ -225,38 +302,19 @@ public function customerAuthenticatedEvent($observer) */ public function removePersistentCookie($observer) { - if (!$this->_isPersistent()) { + if (!Mage::helper('persistent')->canProcess($observer) || !$this->_isPersistent()) { return; } - /** @var $action Mage_Checkout_OnepageController */ - $action = $observer->getEvent()->getControllerAction(); - - if ($action->getRequest()->getPost('method') == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER) { - $this->_getPersistentHelper()->getSession()->removePersistentCookie(); - /** @var $customerSession Mage_Customer_Model_Session */ - $customerSession = Mage::getSingleton('customer/session'); - if (!$customerSession->isLoggedIn()) { - $customerSession->setCustomerId(null) - ->setCustomerGroupId(null); - } - - $this->_setQuoteGuest(); + $this->_getPersistentHelper()->getSession()->removePersistentCookie(); + /** @var $customerSession Mage_Customer_Model_Session */ + $customerSession = Mage::getSingleton('customer/session'); + if (!$customerSession->isLoggedIn()) { + $customerSession->setCustomerId(null) + ->setCustomerGroupId(null); } - } - /** - * Clear persistent data - * - * @param Varien_Event_Observer $observer - */ - public function clearPersistent($observer) - { - $this->_getPersistentHelper()->getSession()->removePersistentCookie(); - Mage::getSingleton('checkout/session')->unsetAll(); - Mage::getSingleton('customer/session') - ->setCustomerId(null) - ->setCustomerGroupId(null); + $this->_setQuoteGuest(); } /** @@ -406,6 +464,10 @@ protected function _setQuoteGuest($checkQuote = false) */ public function checkExpirePersistentQuote(Varien_Event_Observer $observer) { + if (!Mage::helper('persistent')->canProcess($observer)) { + return; + } + /** @var $checkoutSession Mage_Checkout_Model_Session */ $checkoutSession = Mage::getSingleton('checkout/session'); @@ -460,7 +522,7 @@ public function createPersistentHandleLayout(Varien_Event_Observer $observer) { /** @var $layout Mage_Core_Model_Layout */ $layout = $observer->getEvent()->getLayout(); - if ($layout && Mage::helper('persistent')->isEnabled() + if (Mage::helper('persistent')->canProcess($observer) && $layout && Mage::helper('persistent')->isEnabled() && Mage::helper('persistent/session')->isPersistent() ) { $handle = (Mage::getSingleton('customer/session')->isLoggedIn()) @@ -469,4 +531,23 @@ public function createPersistentHandleLayout(Varien_Event_Observer $observer) $layout->getUpdate()->addHandle($handle); } } + + /** + * Update customer id and customer group id if user is in persistent session + * + * @param Varien_Event_Observer $observer + */ + public function updateCustomerCookies(Varien_Event_Observer $observer) + { + if (!$this->_isPersistent()) { + return; + } + + $customerCookies = $observer->getEvent()->getCustomerCookies(); + if ($customerCookies instanceof Varien_Object) { + $persistentCustomer = $this->_getPersistentCustomer(); + $customerCookies->setCustomerId($persistentCustomer->getId()); + $customerCookies->setCustomerGroupId($persistentCustomer->getGroupId()); + } + } } diff --git a/app/code/core/Mage/Persistent/Model/Observer/Session.php b/app/code/core/Mage/Persistent/Model/Observer/Session.php index 5c710e8304..ce651315b1 100644 --- a/app/code/core/Mage/Persistent/Model/Observer/Session.php +++ b/app/code/core/Mage/Persistent/Model/Observer/Session.php @@ -139,7 +139,9 @@ public function synchronizePersistentInfo(Varien_Event_Observer $observer) */ public function setRememberMeCheckedStatus(Varien_Event_Observer $observer) { - if (!Mage::helper('persistent')->isEnabled() || !Mage::helper('persistent')->isRememberMeEnabled()) { + if (!Mage::helper('persistent')->canProcess($observer) + || !Mage::helper('persistent')->isEnabled() || !Mage::helper('persistent')->isRememberMeEnabled() + ) { return; } @@ -163,7 +165,9 @@ public function setRememberMeCheckedStatus(Varien_Event_Observer $observer) */ public function renewCookie(Varien_Event_Observer $observer) { - if (!Mage::helper('persistent')->isEnabled() || !Mage::helper('persistent/session')->isPersistent()) { + if (!Mage::helper('persistent')->canProcess($observer) + || !Mage::helper('persistent')->isEnabled() || !Mage::helper('persistent/session')->isPersistent() + ) { return; } diff --git a/app/code/core/Mage/Persistent/Model/Persistent/Config.php b/app/code/core/Mage/Persistent/Model/Persistent/Config.php index cc884337b0..703b8ef2e2 100644 --- a/app/code/core/Mage/Persistent/Model/Persistent/Config.php +++ b/app/code/core/Mage/Persistent/Model/Persistent/Config.php @@ -102,30 +102,41 @@ public function fire() continue; } foreach ($elements as $info) { - if (!isset($info['class']) || !isset($info['method'])) { - continue; - } - $object = Mage::getModel($info['class']); - $method = $info['method']; - $instance = false; - switch ($type) { case 'blocks': - $instance = Mage::getSingleton('core/layout')->getBlock($info['name_in_layout']); + $this->fireOne($info, Mage::getSingleton('core/layout')->getBlock($info['name_in_layout'])); break; } + } + } + return $this; + } - if (!$instance || (isset($info['block_type']) && !($instance instanceof $info['block_type']))) { - continue; - } + /** + * Run one method by given method info + * + * @param array $info + * @param bool $instance + * @return Mage_Persistent_Model_Persistent_Config + */ + public function fireOne($info, $instance = false) + { + if (!$instance + || (isset($info['block_type']) && !($instance instanceof $info['block_type'])) + || !isset($info['class']) + || !isset($info['method']) + ) { + return $this; + } + $object = Mage::getModel($info['class']); + $method = $info['method']; - if (method_exists($object, $method)) { - $object->$method($instance); - } elseif (Mage::getIsDeveloperMode()) { - Mage::throwException('Method "' . $method.'" is not defined in "' . get_class($object) . '"'); - } - } + if (method_exists($object, $method)) { + $object->$method($instance); + } elseif (Mage::getIsDeveloperMode()) { + Mage::throwException('Method "' . $method.'" is not defined in "' . get_class($object) . '"'); } + return $this; } } diff --git a/app/code/core/Mage/Persistent/etc/config.xml b/app/code/core/Mage/Persistent/etc/config.xml index d9a4f67268..197b24ecc2 100644 --- a/app/code/core/Mage/Persistent/etc/config.xml +++ b/app/code/core/Mage/Persistent/etc/config.xml @@ -216,7 +216,7 @@ persistent/observer - clearPersistent + removePersistentCookie @@ -236,6 +236,22 @@ + + + + persistent/observer + applyBlockPersistentData + + + + + + + persistent/observer + updateCustomerCookies + + + diff --git a/app/code/core/Mage/Persistent/etc/persistent.xml b/app/code/core/Mage/Persistent/etc/persistent.xml index 5790c556c1..d0acf654b8 100644 --- a/app/code/core/Mage/Persistent/etc/persistent.xml +++ b/app/code/core/Mage/Persistent/etc/persistent.xml @@ -34,6 +34,18 @@ emulateWelcomeBlock Mage_Page_Block_Html_Header + + account.links + persistent/observer + emulateAccountLinks + Mage_Page_Block_Template_Links + + + top.links + persistent/observer + emulateTopLinks + Mage_Page_Block_Template_Links + diff --git a/app/code/core/Mage/Poll/Block/ActivePoll.php b/app/code/core/Mage/Poll/Block/ActivePoll.php index b165d848e1..eabc9db237 100755 --- a/app/code/core/Mage/Poll/Block/ActivePoll.php +++ b/app/code/core/Mage/Poll/Block/ActivePoll.php @@ -33,26 +33,125 @@ class Mage_Poll_Block_ActivePoll extends Mage_Core_Block_Template { - protected $_templates, $_voted; + /** + * Poll templates + * + * @var array + */ + protected $_templates; + + /** + * Current Poll Id + * + * @var int + */ + protected $_pollId = null; + + /** + * Already voted by current visitor Poll Ids array + * + * @var array|null + */ + protected $_votedIds = null; + + /** + * Poll model + * + * @var Mage_Poll_Model_Poll + */ + protected $_pollModel; public function __construct() { parent::__construct(); + $this->_pollModel = Mage::getModel('poll/poll'); + } + + /** + * Set current Poll Id + * + * @param int $pollId + * @return Mage_Poll_Block_ActivePoll + */ + public function setPollId($pollId) + { + $this->_pollId = $pollId; + return $this; + } + + /** + * Get current Poll Id + * + * @return int|null + */ + public function getPollId() + { + return $this->_pollId; + } + + /** + * Retrieve already voted Poll Ids + * + * @return array|null + */ + public function getVotedPollsIds() + { + if ($this->_votedIds === null) { + $this->_votedIds = $this->_pollModel->getVotedPollsIds(); + } + return $this->_votedIds; + } + + /** + * Get Ids of all active Polls + * + * @return array + */ + public function getActivePollsIds() + { + return $this->_pollModel + ->setExcludeFilter($this->getVotedPollsIds()) + ->setStoreFilter(Mage::app()->getStore()->getId()) + ->getCollection()->getAllIds(); + } - $pollModel = Mage::getModel('poll/poll'); + /** + * Get Poll Id to show + * + * @return int + */ + public function getPollToShow() + { + if ($this->getPollId()) { + return $this->getPollId(); + } // get last voted poll (from session only) $pollId = Mage::getSingleton('core/session')->getJustVotedPoll(); if (empty($pollId)) { // get random not voted yet poll - $votedIds = $pollModel->getVotedPollsIds(); - $pollId = $pollModel->setExcludeFilter($votedIds) + $votedIds = $this->getVotedPollsIds(); + $pollId = $this->_pollModel + ->setExcludeFilter($votedIds) ->setStoreFilter(Mage::app()->getStore()->getId()) ->getRandomId(); } + $this->setPollId($pollId); + + return $pollId; + } + + /** + * Get Poll related data + * + * @param int $pollId + * @return array|bool + */ + public function getPollData($pollId) + { if (empty($pollId)) { return false; } - $poll = $pollModel->load($pollId); + $poll = $this->_pollModel->load($pollId); $pollAnswers = Mage::getModel('poll/poll_answer') ->getResourceCollection() @@ -77,27 +176,64 @@ public function __construct() $answersArr[$key]->setPercent($value + 100 - $total); } - $this->assign('poll', $poll) - ->assign('poll_answers', $pollAnswers) - ->assign('action', Mage::getUrl('poll/vote/add', array('poll_id' => $pollId, '_secure' => true))); - - $this->_voted = Mage::getModel('poll/poll')->isVoted($pollId); - Mage::getSingleton('core/session')->setJustVotedPoll(false); + return array( + 'poll' => $poll, + 'poll_answers' => $pollAnswers, + 'action' => Mage::getUrl('poll/vote/add', array('poll_id' => $pollId, '_secure' => true)) + ); } + + /** + * Add poll template + * + * @param string $template + * @param string $type + * @return Mage_Poll_Block_ActivePoll + */ public function setPollTemplate($template, $type) { $this->_templates[$type] = $template; return $this; } + /** + * Render block HTML + * + * @return string + */ protected function _toHtml() { - if( $this->_voted === true ) { + $pollId = $this->getPollToShow(); + $data = $this->getPollData($pollId); + $this->assign($data); + + Mage::getSingleton('core/session')->setJustVotedPoll(false); + + if ($this->_pollModel->isVoted($pollId) === true) { $this->setTemplate($this->_templates['results']); } else { $this->setTemplate($this->_templates['poll']); } return parent::_toHtml(); } + + + /** + * Get cache key informative items that must be preserved in cache placeholders + * for block to be rerendered by placeholder + * + * @return array + */ + public function getCacheKeyInfo() + { + $items = array( + 'templates' => serialize($this->_templates) + ); + + $items = parent::getCacheKeyInfo() + $items; + + return $items; + } + } diff --git a/app/code/core/Mage/Poll/controllers/VoteController.php b/app/code/core/Mage/Poll/controllers/VoteController.php index 8c0ec30814..d287c32f82 100644 --- a/app/code/core/Mage/Poll/controllers/VoteController.php +++ b/app/code/core/Mage/Poll/controllers/VoteController.php @@ -40,11 +40,17 @@ class Mage_Poll_VoteController extends Mage_Core_Controller_Front_Action */ protected $_cookieCheckActions = array('add'); + /** + * Add Vote to Poll + * + * @return void + */ public function addAction() { $pollId = intval($this->getRequest()->getParam('poll_id')); $answerId = intval($this->getRequest()->getParam('vote')); + /** @var $poll Mage_Poll_Model_Poll */ $poll = Mage::getModel('poll/poll')->load($pollId); /** @@ -58,6 +64,13 @@ public function addAction() $poll->addVote($vote); Mage::getSingleton('core/session')->setJustVotedPoll($pollId); + Mage::dispatchEvent( + 'poll_vote_add', + array( + 'poll' => $poll, + 'vote' => $vote + ) + ); } $this->_redirectReferer(); } diff --git a/app/code/core/Mage/Reports/Model/Resource/Order/Collection.php b/app/code/core/Mage/Reports/Model/Resource/Order/Collection.php index fbd6eff82f..706bda5c7c 100755 --- a/app/code/core/Mage/Reports/Model/Resource/Order/Collection.php +++ b/app/code/core/Mage/Reports/Model/Resource/Order/Collection.php @@ -125,23 +125,25 @@ protected function _prepareSummaryLive($range, $customStart, $customEnd, $isFilt )); } - $rangeCreatedAt = $this->_getTZRangeExpressionForAttribute($range, 'created_at'); - $rangeCreatedAt2 = str_replace($this->getConnection()->quoteIdentifier('created_at'), - 'MIN(created_at)', $rangeCreatedAt); + $dateRange = $this->getDateRange($range, $customStart, $customEnd); + + $tzRangeOffsetExpression = $this->_getTZRangeOffsetExpression( + $range, 'created_at', $dateRange['from'], $dateRange['to'] + ); $this->getSelect() ->columns(array( 'quantity' => 'COUNT(main_table.entity_id)', - 'range' => $rangeCreatedAt2, + 'range' => $tzRangeOffsetExpression, )) - ->order('range', Zend_Db_Select::SQL_ASC) - ->group($rangeCreatedAt) ->where('main_table.state NOT IN (?)', array( Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_NEW) - ); + ) + ->order('range', Zend_Db_Select::SQL_ASC) + ->group($tzRangeOffsetExpression); - $this->addFieldToFilter('created_at', $this->getDateRange($range, $customStart, $customEnd)); + $this->addFieldToFilter('created_at', $dateRange); return $this; } @@ -200,7 +202,10 @@ protected function _getRangeExpression($range) switch ($range) { case '24h': - $expression = $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m-%d %H:00'); + $expression = $this->getConnection()->getConcatSql(array( + $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m-%d %H:'), + $this->getConnection()->quote('00') + )); break; case '7d': case '1m': @@ -230,6 +235,25 @@ protected function _getRangeExpressionForAttribute($range, $attribute) return str_replace('{{attribute}}', $this->getConnection()->quoteIdentifier($attribute), $expression); } + /** + * Retrieve query for attribute with timezone conversion + * + * @param string $range + * @param string $attribute + * @param mixed $from + * @param mixed $to + * @return string + */ + protected function _getTZRangeOffsetExpression($range, $attribute, $from = null, $to = null) + { + return str_replace( + '{{attribute}}', + Mage::getResourceModel('sales/report_order') + ->getStoreTZOffsetQuery($this->getMainTable(), $attribute, $from, $to), + $this->_getRangeExpression($range) + ); + } + /** * Retrieve range expression with timezone conversion adapted for attribute * @@ -583,7 +607,9 @@ public function setStoreIds($storeIds) */ public function groupByCustomer() { - $this->getSelect()->group('main_table.customer_id'); + $this->getSelect() + ->where('main_table.customer_id IS NOT NULL') + ->group('main_table.customer_id'); /* * Allow Analytic functions usage diff --git a/app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php b/app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php index 521eb7b915..50c98eb514 100755 --- a/app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php +++ b/app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php @@ -165,7 +165,9 @@ protected function _getTableDateRangeSelect($table, $column, $whereColumn, $from $select = $adapter->select() ->from( array($alias => $table), - $adapter->getDatePartSql($adapter->quoteIdentifier($alias . '.' . $column)) + $adapter->getDatePartSql( + $this->getStoreTZOffsetQuery(array($alias => $table), $alias . '.' . $column, $from, $to) + ) ) ->distinct(true); @@ -229,8 +231,7 @@ protected function _makeConditionFromDateRangeSelect($select, $periodColumn) $adapter = $this->_getReadAdapter(); foreach ($selectResult as $date) { $date = substr($date, 0, 10); // to fix differences in oracle - $whereCondition[] = sprintf("%s BETWEEN '%s' AND '%s'", - $periodColumn, "{$date} 00:00:00", "{$date} 23:59:59"); + $whereCondition[] = $adapter->prepareSqlCondition($periodColumn, array('like' => $date)); } $whereCondition = implode(' OR ', $whereCondition); if ($whereCondition == '') { @@ -330,6 +331,100 @@ protected function _checkDates(&$from, &$to) return $this; } + /** + * Retrieve query for attribute with timezone conversion + * + * @param string|array $table + * @param string $column + * @param mixed $from + * @param mixed $to + * @param int|string|Mage_Core_Model_Store|null $store + * @return string + */ + public function getStoreTZOffsetQuery($table, $column, $from = null, $to = null, $store = null) + { + $column = $this->_getWriteAdapter()->quoteIdentifier($column); + + if (is_null($from)) { + $selectOldest = $this->_getWriteAdapter()->select() + ->from( + $table, + array("MIN($column)") + ); + $from = $this->_getWriteAdapter()->fetchOne($selectOldest); + } + + $periods = $this->_getTZOffsetTransitions( + Mage::app()->getLocale()->storeDate($store)->toString(Zend_Date::TIMEZONE_NAME), $from, $to + ); + if (empty($periods)) { + return $column; + } + + $query = ""; + $periodsCount = count($periods); + + $i = 0; + foreach ($periods as $offset => $timestamps) { + $subParts = array(); + foreach ($timestamps as $ts) { + $subParts[] = "($column between '{$ts['from']}' and '{$ts['to']}')"; + } + + $then = $this->_getWriteAdapter() + ->getDateAddSql($column, $offset, Varien_Db_Adapter_Interface::INTERVAL_SECOND); + + $query .= (++$i == $periodsCount) ? $then : "CASE WHEN " . join(" OR ", $subParts) . " THEN $then ELSE "; + } + + return $query . str_repeat('END ', count($periods) - 1); + } + + /** + * Retrieve transitions for offsets of given timezone + * + * @param string $timezone + * @param mixed $from + * @param mixed $to + * @return array + */ + protected function _getTZOffsetTransitions($timezone, $from = null, $to = null) + { + $tzTransitions = array(); + try { + if (!empty($from)) { + $from = new Zend_Date($from, 'Y-m-d H:i:s'); + $from = $from->getTimestamp(); + } + + $to = new Zend_Date($to); + $nextPeriod = $to->toString('c'); + $to = $to->getTimestamp(); + + $dtz = new DateTimeZone($timezone); + $transitions = $dtz->getTransitions(); + + for ($i = count($transitions) - 1; $i >= 0; $i--) { + $tr = $transitions[$i]; + if ($tr['ts'] > $to) { + continue; + } + + $tzTransitions[$tr['offset']][] = array('from' => $tr['time'], 'to' => $nextPeriod); + + if (!empty($from) && $tr['ts'] < $from) { + break; + } + $nextPeriod = $tr['time']; + } + } catch (Exception $e) { + Mage::logException($e); + } + + return $tzTransitions; + } + + /** * Retrieve store timezone offset from UTC in the form acceptable by SQL's CONVERT_TZ() * diff --git a/app/code/core/Mage/Rss/Block/Catalog/Special.php b/app/code/core/Mage/Rss/Block/Catalog/Special.php index 0fb9a2ead1..8706b8b815 100644 --- a/app/code/core/Mage/Rss/Block/Catalog/Special.php +++ b/app/code/core/Mage/Rss/Block/Catalog/Special.php @@ -31,7 +31,7 @@ * @package Mage_Rss * @author Magento Core Team */ -class Mage_Rss_Block_Catalog_Special extends Mage_Rss_Block_Abstract +class Mage_Rss_Block_Catalog_Special extends Mage_Rss_Block_Catalog_Abstract { /** * Zend_Date object for date comparsions @@ -120,25 +120,14 @@ protected function _toHtml() // add price data if needed if ($product->getAllowedPriceInRss()) { - $special = ''; - if ($result['use_special']) { - $special = '
' . Mage::helper('catalog')->__('Special Expires On: %s', $this->formatDate($result['special_to_date'], Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM)); - } if (Mage::helper('catalog')->canApplyMsrp($product)) { - $msrpPrice = $product->getMsrp(); - if ($msrpPrice) { - $html .= '

'; - $msrpPrice = $this->helper('core')->currency($msrpPrice, true, true); - $html .= '' . $this->__('Regular Price:') . '' - . ' ' . $msrpPrice . ' '; - } - if ($this->helper('catalog')->isShowPriceOnGesture($product)) { - $html .= '' - . $this->__('Click for price') . ''; - } else { - $html .= $this->helper('catalog')->getMsrpPriceMessage($product); - } + $html .= '
' + . $this->__('Click for price') . ''; } else { + $special = ''; + if ($result['use_special']) { + $special = '
' . Mage::helper('catalog')->__('Special Expires On: %s', $this->formatDate($result['special_to_date'], Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM)); + } $html .= sprintf('

%s %s%s

', Mage::helper('catalog')->__('Price: %s', Mage::helper('core')->currency($result['price'])), Mage::helper('catalog')->__('Special Price: %s', Mage::helper('core')->currency($result['final_price'])), diff --git a/app/code/core/Mage/Rss/Block/Catalog/Tag.php b/app/code/core/Mage/Rss/Block/Catalog/Tag.php index e3a0516351..f75f4fd23f 100644 --- a/app/code/core/Mage/Rss/Block/Catalog/Tag.php +++ b/app/code/core/Mage/Rss/Block/Catalog/Tag.php @@ -88,6 +88,7 @@ public function addTaggedItemXml($args) $product = $args['product']; $product->setAllowedInRss(true); + $product->setAllowedPriceInRss(true); Mage::dispatchEvent('rss_catalog_tagged_item_xml_callback', $args); if (!$product->getAllowedInRss()) { diff --git a/app/code/core/Mage/Rss/Block/Wishlist.php b/app/code/core/Mage/Rss/Block/Wishlist.php index 752d675121..cd93335c25 100644 --- a/app/code/core/Mage/Rss/Block/Wishlist.php +++ b/app/code/core/Mage/Rss/Block/Wishlist.php @@ -40,6 +40,13 @@ class Mage_Rss_Block_Wishlist extends Mage_Wishlist_Block_Abstract */ protected $_customer; + /** + * Default MAP renderer type + * + * @var string + */ + protected $_mapRenderer = 'msrp_rss'; + /** * Retrieve Wishlist model * @@ -103,24 +110,33 @@ protected function _toHtml() 'language' => $lang )); - /* @var $product Mage_Catalog_Model_Product */ + /** @var $product Mage_Wishlist_Model_Item*/ foreach ($this->getWishlistItems() as $product) { - $description = '' . ' - getCollection() as $item): if ($item->getIsVirtual() || $item->getOrderItem()->getParentItemId() || $item->getOrderItem()->getParentItem()): continue; endif; ?> + getCollection() as $item): ?> + getShipment()->getOrder() ?> + getItemById($item->getOrderItemId()); ?> + getIsVirtual() + || ($_orderItem->isShipSeparately() && !($_orderItem->getParentItemId() || $_orderItem->getParentItem())) + || (!$_orderItem->isShipSeparately() && ($_orderItem->getParentItemId() || $_orderItem->getParentItem()))): ?> + + + + @@ -50,9 +52,19 @@ + getDeliveryConfirmation() != null): ?> + + + + + + displayCustomsValue()): ?> @@ -64,9 +76,14 @@ + + displayCustomsValue()): ?> @@ -78,9 +95,14 @@ + getSize()): ?> @@ -97,6 +119,8 @@ + +
' . $this->helper('catalog/output') ->productAttribute($product, $product->getShortDescription(), 'short_description') . '

'; - if ($product->getPrice() != $product->getFinalPrice()) { - $description .= Mage::helper('catalog')->__('Regular Price:') . ' ' - . Mage::helper('core')->currency($product->getPrice()) . ' ' - . Mage::helper('catalog')->__('Special Price:') . ' ' - . Mage::helper('core')->currency($product->getFinalPrice()).''; - } - else { - $description .= Mage::helper('catalog')->__('Price:') . ' ' - . Mage::helper('core')->currency($product->getFinalPrice()); + + if ($wishlistProduct->getAllowedPriceInRss()) { + $description .= $this->getPriceHtml($wishlistProduct,true); } $description .= '

'; if ($this->hasDescription($product)) { @@ -135,7 +151,7 @@ protected function _toHtml() $rssObj->_addEntry(array( 'title' => $this->helper('catalog/output') ->productAttribute($product, $product->getName(), 'name'), - 'link' => $this->getProductUrl($product), + 'link' => $productUrl, 'description' => $description, )); } @@ -164,4 +180,21 @@ public function getProductUrl($product, $additional = array()) $additional['_rss'] = true; return parent::getProductUrl($product, $additional); } + + /** + * Adding customized price template for product type, used as action in layouts + * + * @param string $type Catalog Product Type + * @param string $block Block Type + * @param string $template Template + */ + public function addPriceBlockType($type, $block = '', $template = '') + { + if ($type) { + $this->_priceBlockTypes[$type] = array( + 'block' => $block, + 'template' => $template + ); + } + } } diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index c550ba1640..fe7079ed03 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -636,7 +636,7 @@ public function canCreditmemo() * We can have problem with float in php (on some server $a=762.73;$b=762.73; $a-$b!=0) * for this we have additional diapason for 0 */ - if (abs($this->getTotalPaid()-$this->getTotalRefunded())<.0001) { + if (abs($this->getTotalPaid() - $this->getTotalRefunded() - $this->getAdjustmentNegative()) < .0001) { return false; } @@ -1052,7 +1052,7 @@ public function addStatusHistoryComment($comment, $status = false) /** * Overrides entity id, which will be saved to comments history status - * + * * @param string $status * @return Mage_Sales_Model_Order */ diff --git a/app/code/core/Mage/Sales/Model/Order/Address.php b/app/code/core/Mage/Sales/Model/Order/Address.php index c5ef65864b..30ffe8ab10 100644 --- a/app/code/core/Mage/Sales/Model/Order/Address.php +++ b/app/code/core/Mage/Sales/Model/Order/Address.php @@ -134,6 +134,11 @@ protected function _beforeSave() $this->setParentId($this->getOrder()->getId()); } + // Init customer address id if customer address is assigned + if ($this->getCustomerAddress()) { + $this->setCustomerAddressId($this->getCustomerAddress()->getId()); + } + return $this; } } diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php index a0bcd4cdd4..4f6c66d4ef 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php @@ -214,13 +214,17 @@ public function setQty($qty) */ public function register() { + $creditmemoObjForTax = clone $this->getCreditmemo(); + /* @var $salesOrderCreditmemoTotalTaxModel Mage_Sales_Model_Order_Creditmemo_Total_Tax */ + $salesOrderCreditmemoTotalTaxModel = Mage::getModel('sales/order_creditmemo_total_tax'); + $salesOrderCreditmemoTotalTaxModel->collect($creditmemoObjForTax); + $this->getOrderItem() + ->setTaxRefunded($this->getOrderItem()->getTaxRefunded() + $creditmemoObjForTax->getBaseTaxAmount()); + unset($creditmemoObjForTax); + $this->getOrderItem()->setQtyRefunded( $this->getOrderItem()->getQtyRefunded() + $this->getQty() ); - $this->getOrderItem()->setTaxRefunded( - $this->getOrderItem()->getTaxRefunded() - + $this->getOrderItem()->getBaseTaxAmount() * $this->getQty() / $this->getOrderItem()->getQtyOrdered() - ); $this->getOrderItem()->setHiddenTaxRefunded( $this->getOrderItem()->getHiddenTaxRefunded() + $this->getOrderItem()->getHiddenTaxAmount() * $this->getQty() / $this->getOrderItem()->getQtyOrdered() @@ -260,8 +264,15 @@ public function calcRowTotal() $rowTotalInclTax = $orderItem->getRowTotalInclTax(); $baseRowTotalInclTax= $orderItem->getBaseRowTotalInclTax(); - $rowTotal = $rowTotal/$orderItemQty*$this->getQty(); - $baseRowTotal = $baseRowTotal/$orderItemQty*$this->getQty(); + if ($this->isLast()) { + $rowTotal = (($rowTotal - $orderItem->getPrice() * $orderItem->getQtyRefunded()) + / ($orderItemQty - $orderItem->getQtyRefunded())) * $this->getQty(); + $baseRowTotal = (($baseRowTotal - $orderItem->getBasePrice() * $orderItem->getQtyRefunded()) + / ($orderItemQty - $orderItem->getQtyRefunded())) * $this->getQty(); + } else { + $rowTotal = $orderItem->getPrice()*$this->getQty(); + $baseRowTotal = $orderItem->getBasePrice()*$this->getQty(); + } $this->setRowTotal($store->roundPrice($rowTotal)); $this->setBaseRowTotal($store->roundPrice($baseRowTotal)); @@ -281,7 +292,8 @@ public function calcRowTotal() public function isLast() { $orderItem = $this->getOrderItem(); - if ((string)(float)$this->getQty() == (string)(float)$orderItem->getQtyToRefund() && !$orderItem->getQtyToInvoice()) { + if ((string)(float)$this->getQty() == (string)(float)$orderItem->getQtyToRefund() + && !$orderItem->getQtyToInvoice()) { return true; } return false; diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Tax.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Tax.php index ac3e75c34f..1b45b0b6f1 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Tax.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Tax.php @@ -38,14 +38,15 @@ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) $order = $creditmemo->getOrder(); + /* @var $item Mage_Sales_Model_Order_Creditmemo_Item */ foreach ($creditmemo->getAllItems() as $item) { if ($item->getOrderItem()->isDummy()) { continue; } $orderItem = $item->getOrderItem(); - $orderItemTax = $item->getOrderItem()->getTaxAmount(); - $baseOrderItemTax = $item->getOrderItem()->getBaseTaxAmount(); - $orderItemQty = $item->getOrderItem()->getQtyOrdered(); + $orderItemTax = $orderItem->getTaxAmount(); + $baseOrderItemTax = $orderItem->getBaseTaxAmount(); + $orderItemQty = $orderItem->getQtyOrdered(); if ($orderItemTax && $orderItemQty) { /** @@ -54,19 +55,16 @@ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) if ($item->isLast()) { - $tax = $orderItemTax - $item->getOrderItem()->getTaxRefunded() - - $item->getOrderItem()->getTaxCanceled(); - $baseTax = $baseOrderItemTax - $item->getOrderItem()->getTaxRefunded() - - $item->getOrderItem()->getTaxCanceled(); + $tax = $orderItemTax - $orderItem->getTaxRefunded() - $orderItem->getTaxCanceled(); + $baseTax = $baseOrderItemTax - $orderItem->getTaxRefunded() - $orderItem->getTaxCanceled(); $hiddenTax = $orderItem->getHiddenTaxAmount() - $orderItem->getHiddenTaxRefunded() - - $item->getOrderItem()->getHiddenTaxCanceled(); + - $orderItem->getHiddenTaxCanceled(); $baseHiddenTax = $orderItem->getBaseHiddenTaxAmount() - $orderItem->getBaseHiddenTaxRefunded() - - $item->getOrderItem()->getHiddenTaxCanceled(); + - $orderItem->getHiddenTaxCanceled(); - } - else { - $tax = $orderItemTax*$item->getQty()/$orderItemQty; - $baseTax = $baseOrderItemTax*$item->getQty()/$orderItemQty; + } else { + $tax = ($orderItem->getPriceInclTax() - $orderItem->getPrice()) * $item->getQty(); + $baseTax = ($orderItem->getBasePriceInclTax() - $orderItem->getBasePrice()) * $item->getQty(); $hiddenTax = $orderItem->getHiddenTaxAmount()*$item->getQty()/$orderItemQty; $baseHiddenTax = $orderItem->getBaseHiddenTaxAmount()*$item->getQty()/$orderItemQty; diff --git a/app/code/core/Mage/Sales/Model/Order/Payment.php b/app/code/core/Mage/Sales/Model/Order/Payment.php index b55b7b0fc5..e930c1450c 100644 --- a/app/code/core/Mage/Sales/Model/Order/Payment.php +++ b/app/code/core/Mage/Sales/Model/Order/Payment.php @@ -1467,8 +1467,9 @@ protected function _generateTransactionId($type, $transactionBasedOn = false) */ protected function _isCaptureFinal($amountToCapture) { - $orderGrandTotal = sprintf('%.4F', $this->getOrder()->getBaseGrandTotal()); - if ($orderGrandTotal == sprintf('%.4F', ($this->getBaseAmountPaid() + $amountToCapture))) { + $amountToCapture = $this->_formatAmount($amountToCapture, true); + $orderGrandTotal = $this->_formatAmount($this->getOrder()->getBaseGrandTotal(), true); + if ($orderGrandTotal == $this->_formatAmount($this->getBaseAmountPaid(), true) + $amountToCapture) { if (false !== $this->getShouldCloseParentTransaction()) { $this->setShouldCloseParentTransaction(true); } diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Shipment/Packaging.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Shipment/Packaging.php index ca14766b1e..385c4f6661 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Shipment/Packaging.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Shipment/Packaging.php @@ -104,55 +104,86 @@ protected function _drawPackageBlock($page) $i = 1; foreach ($packages as $packageId => $package) { $page->setFillColor(new Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92)); - $page->drawRectangle(25, $this->y + 15, 275, $this->y - 35); - $page->drawRectangle(275, $this->y + 15, 570, $this->y - 35); + $page->drawRectangle(25, $this->y + 15, 190, $this->y - 35); + $page->drawRectangle(190, $this->y + 15, 350, $this->y - 35); + $page->drawRectangle(350, $this->y + 15, 570, $this->y - 35); $page->setFillColor(new Zend_Pdf_Color_GrayScale(1)); $page->drawRectangle(520, $this->y + 15, 570, $this->y - 5); $page->setFillColor(new Zend_Pdf_Color_GrayScale(0)); - $page->drawText('Package ' . $i, 525, $this->y , 'UTF-8'); + $packageText = Mage::helper('sales')->__('Package') . ' ' . $i; + $page->drawText($packageText, 525, $this->y , 'UTF-8'); $i ++; $package = new Varien_Object($package); $params = new Varien_Object($package->getParams()); $dimensionUnits = Mage::helper('usa')->getMeasureDimensionName($params->getDimensionUnits()); - $typeText = 'Type : ' . $params->getContainer(); - $lengthText = 'Length : ' . $params->getLength() .' '. $dimensionUnits; - $widthText = 'Width : ' . $params->getWidth() .' '. $dimensionUnits; - $heightText = 'Height : ' . $params->getHeight() .' '. $dimensionUnits; - $weightText = 'Total Weight : ' . $params->getWeight() .' ' - . Mage::helper('usa')->getMeasureWeightName($params->getWeightUnits()); - + $typeText = Mage::helper('sales')->__('Type') . ' : ' + . $packaging->getContainerTypeByCode($params->getContainer()); $page->drawText($typeText, 35, $this->y , 'UTF-8'); - $page->drawText($lengthText, 285, $this->y , 'UTF-8'); + + if ($params->getLength() != null) { + $lengthText = $params->getLength() .' '. $dimensionUnits; + } else { + $lengthText = '--'; + } + $lengthText = Mage::helper('sales')->__('Length') . ' : ' . $lengthText; + $page->drawText($lengthText, 200, $this->y , 'UTF-8'); + + if ($params->getDeliveryConfirmation() != null) { + $confirmationText = Mage::helper('sales')->__('Signature Confirmation') + . ' : ' + . $packaging->getDeliveryConfirmationTypeByCode($params->getDeliveryConfirmation()); + $page->drawText($confirmationText, 360, $this->y , 'UTF-8'); + } $this->y = $this->y - 10; - $page->drawText($weightText, 35, $this->y , 'UTF-8'); - $page->drawText($widthText, 285, $this->y , 'UTF-8'); + + $weightText = Mage::helper('sales')->__('Total Weight') . ' : ' . $params->getWeight() .' ' + . Mage::helper('usa')->getMeasureWeightName($params->getWeightUnits()); + $page->drawText($weightText, 35, $this->y , 'UTF-8'); + + if ($params->getWidth() != null) { + $widthText = $params->getWidth() .' '. $dimensionUnits; + } else { + $widthText = '--'; + } + $widthText = Mage::helper('sales')->__('Width') . ' : ' . $widthText; + $page->drawText($widthText, 200, $this->y , 'UTF-8'); $this->y = $this->y - 10; - $page->drawText($heightText, 285, $this->y , 'UTF-8'); - if ($sizeText = $this->_getSizeText($params)) { - $page->drawText($sizeText, 35, $this->y , 'UTF-8'); + if ($params->getHeight() != null) { + $heightText = $params->getHeight() .' '. $dimensionUnits; + } else { + $heightText = '--'; + } + $heightText = Mage::helper('sales')->__('Height') . ' : ' . $heightText; + $page->drawText($heightText, 200, $this->y , 'UTF-8'); + + $sizeText = $this->_getSizeText($params); + if ($sizeText) { $this->y = $this->y - 10; + $page->drawText($sizeText, 35, $this->y , 'UTF-8'); } - if ($params->getGirth()) { - $dimensionGirthUnits = Mage::helper('usa')->getMeasureDimensionName($params->getGirthDimensionUnits()); - $girthText = 'Girth : ' . $params->getGirth() .' '. $dimensionGirthUnits; - $page->drawText($girthText, 285, $this->y , 'UTF-8'); + if ($params->getGirth() != null) { $this->y = $this->y - 10; + $dimensionGirthUnits = Mage::helper('usa')->getMeasureDimensionName($params->getGirthDimensionUnits()); + $girthText = Mage::helper('sales')->__('Girth') + . ' : ' . $params->getGirth() . ' ' . $dimensionGirthUnits; + $page->drawText($girthText, 200, $this->y , 'UTF-8'); } + $this->y = $this->y - 10; $page->setFillColor(new Zend_Pdf_Color_GrayScale(1)); - $page->drawRectangle(25, $this->y+5, 570, $this->y - 25); + $page->drawRectangle(25, $this->y, 570, $this->y - 25); $this->y = $this->y - 10; $page->setFillColor(new Zend_Pdf_Color_GrayScale(0)); - $page->drawText('Items in the Package', 50, $this->y, 'UTF-8'); + $page->drawText(Mage::helper('sales')->__('Items in the Package'), 50, $this->y, 'UTF-8'); $page->setFillColor(new Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92)); $page->drawRectangle(50, $this->y - 5, 200, $this->y - 15); @@ -161,9 +192,9 @@ protected function _drawPackageBlock($page) $this->y = $this->y - 12; $page->setFillColor(new Zend_Pdf_Color_GrayScale(0)); - $page->drawText('Product', 55, $this->y, 'UTF-8'); - $page->drawText('Weight', 205, $this->y, 'UTF-8'); - $page->drawText('Qty', 355, $this->y, 'UTF-8'); + $page->drawText(Mage::helper('sales')->__('Product'), 55, $this->y, 'UTF-8'); + $page->drawText(Mage::helper('sales')->__('Weight'), 205, $this->y, 'UTF-8'); + $page->drawText(Mage::helper('sales')->__('Qty'), 355, $this->y, 'UTF-8'); foreach ($package->getItems() as $itemId => $item) { $item = new Varien_Object($item); @@ -188,16 +219,15 @@ protected function _drawPackageBlock($page) /** * Get package size from params either from system config * - * @param $params + * @param Varien_Object $params * @return string */ protected function _getSizeText($params) { + $sizeText = ''; $uspsModel = Mage::getSingleton('usa/shipping_carrier_usps'); - if ($params->getSize()) { - $sizeText = 'Size : ' . $params->getSize(); - } else { - $sizeText = 'Size : ' . $uspsModel->getConfigData('size'); + if ($params->getSize() != null) { + $sizeText = Mage::helper('sales')->__('Size') . ' : ' . $uspsModel->getCode('size', $params->getSize()); } return $sizeText; } diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index 599bec669c..837963f1ef 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -622,4 +622,18 @@ public function setShippingLabel($label) $this->setData('shipping_label', $label); return $this; } + + /** + * Get shipping label and decode by db adapter + * + * @return void + */ + public function getShippingLabel() + { + $label = $this->getData('shipping_label'); + if ($label) { + return $this->getResource()->getReadConnection()->decodeVarbinary($label); + } + return $label; + } } diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php index 5fbc890cbd..d0cbed14b3 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php @@ -85,9 +85,7 @@ protected function _initItem($address, $item) $quoteItem = $item; } $product = $quoteItem->getProduct(); - if (!$product->hasCustomerGroupId()) { - $product->setCustomerGroupId($quoteItem->getQuote()->getCustomerGroupId()); - } + $product->setCustomerGroupId($quoteItem->getQuote()->getCustomerGroupId()); /** * Quote super mode flag mean what we work with quote without restriction diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers.php b/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers.php index c553ce647a..039ea5252b 100755 --- a/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers.php +++ b/app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers.php @@ -76,8 +76,12 @@ public function aggregate($from = null, $to = null) $this->_clearTableByDateRange($this->getMainTable(), $from, $to, $subSelect); // convert dates from UTC to current admin timezone - $periodExpr = $adapter->getDatePartSql($adapter->getDateAddSql('source_table.created_at', - $this->_getStoreTimezoneUtcOffset(), Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $periodExpr = $adapter->getDatePartSql( + $this->getStoreTZOffsetQuery( + array('source_table' => $this->getTable('sales/order')), + 'source_table.created_at', $from, $to + ) + ); $helper = Mage::getResourceHelper('core'); $select = $adapter->select(); @@ -210,7 +214,7 @@ public function aggregate($from = null, $to = null) ); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'source_table.created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Invoiced.php b/app/code/core/Mage/Sales/Model/Resource/Report/Invoiced.php index 606b8ac7a6..419416af85 100755 --- a/app/code/core/Mage/Sales/Model/Resource/Report/Invoiced.php +++ b/app/code/core/Mage/Sales/Model/Resource/Report/Invoiced.php @@ -93,8 +93,12 @@ protected function _aggregateByInvoiceCreatedAt($from, $to) $this->_clearTableByDateRange($table, $from, $to, $subSelect); // convert dates from UTC to current admin timezone - $periodExpr = $adapter->getDatePartSql($adapter->getDateAddSql('source_table.created_at', - $this->_getStoreTimezoneUtcOffset(), Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $periodExpr = $adapter->getDatePartSql( + $this->getStoreTZOffsetQuery( + array('source_table' => $sourceTable), + 'source_table.created_at', $from, $to + ) + ); $columns = array( // convert dates from UTC to current admin timezone 'period' => $periodExpr, @@ -126,7 +130,7 @@ protected function _aggregateByInvoiceCreatedAt($from, $to) ->where('filter_source_table.order_id = source_table.order_id'); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'source_table.created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } $select->where('source_table.entity_id = (?)', new Zend_Db_Expr($filterSubSelect)); @@ -201,9 +205,10 @@ protected function _aggregateByOrderCreatedAt($from, $to) $this->_clearTableByDateRange($table, $from, $to, $subSelect); // convert dates from UTC to current admin timezone $periodExpr = $adapter->getDatePartSql( - $adapter->getDateAddSql('created_at', - $this->_getStoreTimezoneUtcOffset(), - Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $this->getStoreTZOffsetQuery( + $sourceTable, 'created_at', $from, $to + ) + ); $columns = array( 'period' => $periodExpr, @@ -242,7 +247,7 @@ protected function _aggregateByOrderCreatedAt($from, $to) ->where('state <> ?', Mage_Sales_Model_Order::STATE_CANCELED); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } $select->group(array( diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Order.php b/app/code/core/Mage/Sales/Model/Resource/Report/Order.php index 94f38137d7..0da95d358d 100755 --- a/app/code/core/Mage/Sales/Model/Resource/Report/Order.php +++ b/app/code/core/Mage/Sales/Model/Resource/Report/Order.php @@ -72,8 +72,9 @@ public function aggregate($from = null, $to = null) } $this->_clearTableByDateRange($this->getMainTable(), $from, $to, $subSelect); - $periodExpr = $adapter->getDatePartSql($adapter->getDateAddSql('o.created_at', - $this->_getStoreTimezoneUtcOffset(), Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $periodExpr = $adapter->getDatePartSql( + $this->getStoreTZOffsetQuery(array('o' => $this->getTable('sales/order')), 'o.created_at', $from, $to) + ); // Columns list $columns = array( // convert dates from UTC to current admin timezone @@ -200,7 +201,7 @@ public function aggregate($from = null, $to = null) )); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'o.created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } $select->group(array( diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Refunded.php b/app/code/core/Mage/Sales/Model/Resource/Report/Refunded.php index 9d95cd7a87..99cf198938 100755 --- a/app/code/core/Mage/Sales/Model/Resource/Report/Refunded.php +++ b/app/code/core/Mage/Sales/Model/Resource/Report/Refunded.php @@ -87,8 +87,9 @@ protected function _aggregateByOrderCreatedAt($from, $to) $this->_clearTableByDateRange($table, $from, $to, $subSelect); // convert dates from UTC to current admin timezone - $periodExpr = $adapter->getDatePartSql($adapter->getDateAddSql('created_at', - $this->_getStoreTimezoneUtcOffset(), Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $periodExpr = $adapter->getDatePartSql( + $this->getStoreTZOffsetQuery($sourceTable, 'created_at', $from, $to) + ); $columns = array( 'period' => $periodExpr, 'store_id' => 'store_id', @@ -105,7 +106,7 @@ protected function _aggregateByOrderCreatedAt($from, $to) ->where('base_total_refunded > ?', 0); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } $select->group(array( @@ -183,8 +184,12 @@ protected function _aggregateByRefundCreatedAt($from, $to) $this->_clearTableByDateRange($table, $from, $to, $subSelect); // convert dates from UTC to current admin timezone - $periodExpr = $adapter->getDatePartSql($adapter->getDateAddSql('source_table.created_at', - $this->_getStoreTimezoneUtcOffset(), Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $periodExpr = $adapter->getDatePartSql( + $this->getStoreTZOffsetQuery( + array('source_table' => $sourceTable), + 'source_table.created_at', $from, $to + ) + ); $columns = array( 'period' => $periodExpr, @@ -217,7 +222,7 @@ protected function _aggregateByRefundCreatedAt($from, $to) ->where('filter_source_table.order_id = source_table.order_id'); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'source_table.created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } $select->where('source_table.entity_id = (?)', new Zend_Db_Expr($filterSubSelect)); diff --git a/app/code/core/Mage/Sales/Model/Resource/Report/Shipping.php b/app/code/core/Mage/Sales/Model/Resource/Report/Shipping.php index 69c913d54e..c1e3d7189d 100755 --- a/app/code/core/Mage/Sales/Model/Resource/Report/Shipping.php +++ b/app/code/core/Mage/Sales/Model/Resource/Report/Shipping.php @@ -86,8 +86,9 @@ protected function _aggregateByOrderCreatedAt($from, $to) $this->_clearTableByDateRange($table, $from, $to, $subSelect); // convert dates from UTC to current admin timezone - $periodExpr = $adapter->getDatePartSql($adapter->getDateAddSql('created_at', - $this->_getStoreTimezoneUtcOffset(), Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $periodExpr = $adapter->getDatePartSql( + $this->getStoreTZOffsetQuery($sourceTable, 'created_at', $from, $to) + ); $ifnullBaseShippingCanceled = $adapter->getIfNullSql('base_shipping_canceled', 0); $ifnullBaseShippingRefunded = $adapter->getIfNullSql('base_shipping_refunded', 0); $columns = array( @@ -111,7 +112,7 @@ protected function _aggregateByOrderCreatedAt($from, $to) ->where('is_virtual = 0'); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } $select->group(array( @@ -191,8 +192,12 @@ protected function _aggregateByShippingCreatedAt($from, $to) $this->_clearTableByDateRange($table, $from, $to, $subSelect); // convert dates from UTC to current admin timezone - $periodExpr = $adapter->getDatePartSql($adapter->getDateAddSql('source_table.created_at', - $this->_getStoreTimezoneUtcOffset(), Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $periodExpr = $adapter->getDatePartSql( + $this->getStoreTZOffsetQuery( + array('source_table' => $sourceTable), + 'source_table.created_at', $from, $to + ) + ); $ifnullBaseShippingCanceled = $adapter->getIfNullSql('order_table.base_shipping_canceled', 0); $ifnullBaseShippingRefunded = $adapter->getIfNullSql('order_table.base_shipping_refunded', 0); $columns = array( @@ -223,7 +228,7 @@ protected function _aggregateByShippingCreatedAt($from, $to) ->where('filter_source_table.order_id = source_table.order_id'); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'source_table.created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } $select->where('source_table.entity_id = (?)', new Zend_Db_Expr($filterSubSelect)); diff --git a/app/code/core/Mage/Sales/Model/Service/Quote.php b/app/code/core/Mage/Sales/Model/Service/Quote.php index 8f4ce59820..fcbbfd2473 100644 --- a/app/code/core/Mage/Sales/Model/Service/Quote.php +++ b/app/code/core/Mage/Sales/Model/Service/Quote.php @@ -151,8 +151,14 @@ public function submitOrder() $order = $this->_convertor->addressToOrder($quote->getShippingAddress()); } $order->setBillingAddress($this->_convertor->addressToOrderAddress($quote->getBillingAddress())); + if ($quote->getBillingAddress()->getCustomerAddress()) { + $order->getBillingAddress()->setCustomerAddress($quote->getBillingAddress()->getCustomerAddress()); + } if (!$isVirtual) { $order->setShippingAddress($this->_convertor->addressToOrderAddress($quote->getShippingAddress())); + if ($quote->getShippingAddress()->getCustomerAddress()) { + $order->getShippingAddress()->setCustomerAddress($quote->getShippingAddress()->getCustomerAddress()); + } } $order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment())); diff --git a/app/code/core/Mage/Sales/controllers/DownloadController.php b/app/code/core/Mage/Sales/controllers/DownloadController.php index 36b66ef2d3..0c92232d34 100644 --- a/app/code/core/Mage/Sales/controllers/DownloadController.php +++ b/app/code/core/Mage/Sales/controllers/DownloadController.php @@ -143,5 +143,6 @@ public function downloadCustomOptionAction() } catch (Exception $e) { $this->_forward('noRoute'); } + exit(0); } } diff --git a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php index cc769b512d..d59a68bbaf 100644 --- a/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php +++ b/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php @@ -28,7 +28,7 @@ $installer = $this; $installer->getConnection() ->addColumn($installer->getTable('sales/shipment'), 'shipping_label', array( - 'type' => Varien_Db_Ddl_Table::TYPE_BLOB, + 'type' => Varien_Db_Ddl_Table::TYPE_VARBINARY, 'comment' => 'Shipping Label Content', 'length' => '2m' )); diff --git a/app/code/core/Mage/SalesRule/Model/Resource/Report/Rule.php b/app/code/core/Mage/SalesRule/Model/Resource/Report/Rule.php index c447bbe4e7..6cf42e7eda 100755 --- a/app/code/core/Mage/SalesRule/Model/Resource/Report/Rule.php +++ b/app/code/core/Mage/SalesRule/Model/Resource/Report/Rule.php @@ -86,8 +86,9 @@ protected function _aggregateByOrderCreatedAt($from, $to) $this->_clearTableByDateRange($table, $from, $to, $subSelect); // convert dates from UTC to current admin timezone - $periodExpr = $adapter->getDatePartSql($adapter->getDateAddSql('source_table.created_at', - $this->_getStoreTimezoneUtcOffset(), Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $periodExpr = $adapter->getDatePartSql( + $this->getStoreTZOffsetQuery($sourceTable, 'created_at', $from, $to) + ); $columns = array( 'period' => $periodExpr, @@ -133,7 +134,7 @@ protected function _aggregateByOrderCreatedAt($from, $to) ->where('coupon_code IS NOT NULL'); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } $select->group(array( diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php b/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php index 43317afd3f..8619721370 100644 --- a/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php +++ b/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php @@ -46,6 +46,8 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object protected $_customizableContainerTypes = array(); const USA_COUNTRY_ID = 'US'; + const CANADA_COUNTRY_ID = 'CA'; + const MEXICO_COUNTRY_ID = 'MX'; const HANDLING_TYPE_PERCENT = 'P'; const HANDLING_TYPE_FIXED = 'F'; diff --git a/app/code/core/Mage/Shipping/Model/Shipping.php b/app/code/core/Mage/Shipping/Model/Shipping.php index 373e0a1057..06478f08b8 100644 --- a/app/code/core/Mage/Shipping/Model/Shipping.php +++ b/app/code/core/Mage/Shipping/Model/Shipping.php @@ -284,7 +284,7 @@ public function requestToShipment(Mage_Sales_Model_Order_Shipment $orderShipment || !Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId) ) { Mage::throwException( - Mage::helper('sales')->__('The shipping label has not been created. Please configure your Store Information and Shipping Settings') + Mage::helper('sales')->__('Insufficient information to create shipping label(s). Please verify your Store Information and Shipping Settings.') ); } @@ -304,9 +304,9 @@ public function requestToShipment(Mage_Sales_Model_Order_Shipment $orderShipment $request->setShipperAddressStateOrProvinceCode($shipperRegionCode); $request->setShipperAddressPostalCode(Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $shipmentStoreId)); $request->setShipperAddressCountryCode(Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId)); - $request->setRecipientContactPersonName($order->getCustomerName()); - $request->setRecipientContactPersonFirstName($order->getCustomerFirstname()); - $request->setRecipientContactPersonLastName($order->getCustomerLastname()); + $request->setRecipientContactPersonName($address->getFirstname() . ' ' . $address->getLastname()); + $request->setRecipientContactPersonFirstName($address->getFirstname()); + $request->setRecipientContactPersonLastName($address->getLastname()); $request->setRecipientContactCompanyName($address->getCompany()); $request->setRecipientContactPhoneNumber($address->getTelephone()); $request->setRecipientEmail($address->getEmail()); diff --git a/app/code/core/Mage/Tag/Model/Resource/Tag.php b/app/code/core/Mage/Tag/Model/Resource/Tag.php index e51e277cb7..b938fe12d3 100755 --- a/app/code/core/Mage/Tag/Model/Resource/Tag.php +++ b/app/code/core/Mage/Tag/Model/Resource/Tag.php @@ -348,7 +348,7 @@ public function decrementProducts(array $tagsId) return $writeAdapter->update( $this->getTable('tag/summary'), - array('products' => 'products - 1'), + array('products' => new Zend_Db_Expr('products - 1')), array('tag_id IN (?)' => $tagsId) ); } diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation.php b/app/code/core/Mage/Tax/Model/Resource/Calculation.php index e678a68f97..aefd92714c 100755 --- a/app/code/core/Mage/Tax/Model/Resource/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Resource/Calculation.php @@ -254,7 +254,7 @@ protected function _getRates($request) ->from(array('main_table' => $this->getMainTable()), array( 'tax_calculation_rate_id', 'tax_calculation_rule_id', - 'customer_tax_class_id', + 'customer_tax_class_id', 'product_tax_class_id' ) ) @@ -263,8 +263,8 @@ protected function _getRates($request) $select->where('product_tax_class_id IN (?)', $productClassId); } $ifnullTitleValue = $this->_getReadAdapter()->getCheckSql( - 'title_table.value IS NULL', - 'rate.code', + 'title_table.value IS NULL', + 'rate.code', 'title_table.value' ); $ruleTableAliasName = $this->_getReadAdapter()->quoteIdentifier('rule.tax_calculation_rule_id'); @@ -389,17 +389,17 @@ public function getRateIds($request) * @param int $productTaxClassId * @return array */ - public function getRatesByCustomerTaxClass($customerTaxClassId, $productTaxClassId = null) + public function getRatesByCustomerTaxClass($customerTaxClass, $productTaxClass = null) { $adapter = $this->_getReadAdapter(); - $customerTaxClass = (int)$customerTaxClass; + $customerTaxClassId = (int)$customerTaxClass; $calcJoinConditions = array( 'calc_table.tax_calculation_rate_id = main_table.tax_calculation_rate_id', $adapter->quoteInto('calc_table.customer_tax_class_id = ?', $customerTaxClassId), ); - if ($productTaxClassId) { - $productTaxClass = (int)$productTaxClass; + if ($productTaxClass) { + $productTaxClassId = (int)$productTaxClass; $calcJoinConditions[] = $adapter->quoteInto('calc_table.product_tax_class_id = ?', $productTaxClassId); } diff --git a/app/code/core/Mage/Tax/Model/Resource/Report/Tax.php b/app/code/core/Mage/Tax/Model/Resource/Report/Tax.php index c03fe186bb..77f44533dd 100755 --- a/app/code/core/Mage/Tax/Model/Resource/Report/Tax.php +++ b/app/code/core/Mage/Tax/Model/Resource/Report/Tax.php @@ -71,8 +71,12 @@ public function aggregate($from = null, $to = null) $this->_clearTableByDateRange($this->getMainTable(), $from, $to, $subSelect); // convert dates from UTC to current admin timezone - $periodExpr = $writeAdapter->getDatePartSql($writeAdapter->getDateAddSql('e.created_at', - $this->_getStoreTimezoneUtcOffset(), Varien_Db_Adapter_Interface::INTERVAL_HOUR)); + $periodExpr = $writeAdapter->getDatePartSql( + $this->getStoreTZOffsetQuery( + array('e' => $this->getTable('sales/order')), + 'e.created_at', $from, $to + ) + ); $columns = array( 'period' => $periodExpr, @@ -95,7 +99,7 @@ public function aggregate($from = null, $to = null) )); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'e.created_at')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); } $select->group(array($periodExpr, 'e.store_id', 'code', 'tax.percent', 'e.status')); diff --git a/app/code/core/Mage/Tax/sql/tax_setup/install-1.6.0.0.php b/app/code/core/Mage/Tax/sql/tax_setup/install-1.6.0.0.php index 488bca01ea..215710269e 100644 --- a/app/code/core/Mage/Tax/sql/tax_setup/install-1.6.0.0.php +++ b/app/code/core/Mage/Tax/sql/tax_setup/install-1.6.0.0.php @@ -240,7 +240,8 @@ /** * Add tax_class_id attribute to the 'eav/attribute' table */ -$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'tax_class_id', array( +$catalogInstaller = Mage::getResourceModel('catalog/setup', 'catalog_setup'); +$catalogInstaller->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'tax_class_id', array( 'group' => 'Prices', 'type' => 'int', 'backend' => '', diff --git a/app/code/core/Mage/Usa/Helper/Data.php b/app/code/core/Mage/Usa/Helper/Data.php index e75e27f4c4..2df18bba84 100644 --- a/app/code/core/Mage/Usa/Helper/Data.php +++ b/app/code/core/Mage/Usa/Helper/Data.php @@ -110,11 +110,15 @@ public function getMeasureDimensionName($key) public function displayGirthValue($shippingMethod) { if (in_array($shippingMethod, array('usps_Priority Mail International', + 'usps_Priority Mail International Small Flat Rate Box', + 'usps_Priority Mail International Medium Flat Rate Box', + 'usps_Priority Mail International Large Flat Rate Box', 'usps_Express Mail Hold For Pickup', 'usps_Express Mail International', 'usps_First-Class Mail International Package', 'usps_First-Class Mail International', 'usps_Global Express Guaranteed (GXG)', + 'usps_USPS GXG Envelopes', 'usps_Global Express Guaranteed Non-Document Non-Rectangular', 'usps_Media Mail', 'usps_Parcel Post', diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php index ab0221208a..17a4a7e9bc 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php @@ -261,6 +261,9 @@ public function requestToShipment(Mage_Shipping_Model_Shipment_Request $request) if (!is_array($packages) || !$packages) { Mage::throwException(Mage::helper('usa')->__('No packages for request')); } + if ($request->getStoreId() != null) { + $this->setStore($request->getStoreId()); + } $data = array(); foreach ($packages as $packageId => $package) { $request->setPackageId($packageId); @@ -307,6 +310,9 @@ public function returnOfShipment($request) if (!is_array($packages) || !$packages) { Mage::throwException(Mage::helper('usa')->__('No packages for request')); } + if ($request->getStoreId() != null) { + $this->setStore($request->getStoreId()); + } $data = array(); foreach ($packages as $packageId => $package) { $request->setPackageId($packageId); diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php index 44351e48cb..e761a38591 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php @@ -127,25 +127,48 @@ public function collectRates(Mage_Shipping_Model_Rate_Request $request) } $requestDhl = clone $request; - $origCompanyName = Mage::getStoreConfig( - Mage_Core_Model_Store::XML_PATH_STORE_STORE_NAME, - $requestDhl->getStoreId() - ); - $countryId = Mage::getStoreConfig( - Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, - $requestDhl->getStoreId() - ); - $origState = Mage::getStoreConfig( - Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, - $requestDhl->getStoreId() - ); - $origCity = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, $requestDhl->getStoreId()); - $origPosta = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $requestDhl->getStoreId()); + $origCompanyName = $requestDhl->getOrigCompanyName(); + if (!$origCompanyName) { + $origCompanyName = Mage::getStoreConfig( + Mage_Core_Model_Store::XML_PATH_STORE_STORE_NAME, + $requestDhl->getStoreId() + ); + } + + $origCountryId = $requestDhl->getOrigCountryId(); + if (!$origCountryId) { + $origCountryId = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, + $requestDhl->getStoreId() + ); + } + $origState = $requestDhl->getOrigState(); + if (!$origState) { + $origState = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, + $requestDhl->getStoreId() + ); + } + $origCity = $requestDhl->getOrigCity(); + if (!$origCity) { + $origCity = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, + $requestDhl->getStoreId() + ); + } + + $origPostcode = $requestDhl->getOrigPostcode(); + if (!$origPostcode) { + $origPostcode = Mage::getStoreConfig( + Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, + $requestDhl->getStoreId() + ); + } $requestDhl->setOrigCompanyName($origCompanyName) - ->setCountryId($countryId) + ->setCountryId($origCountryId) ->setOrigState($origState) ->setOrigCity($origCity) - ->setOrigPostal($origPosta); + ->setOrigPostal($origPostcode); $this->setRequest($requestDhl); $this->_result = $this->_getQuotes(); $this->_updateFreeMethodQuote($request); @@ -642,11 +665,8 @@ protected function _createShipmentXml($shipment, $shipKey) $shipmentDetail = $shipment->addChild('ShipmentDetail'); if ($r->getAction() == 'GenerateLabel') { - if ($r->getIsReturn()) { - $referenceData = 'RMA #' - . $r->getOrderShipment()->getRma()->getIncrementId() - . ' P' - . $r->getPackageId(); + if ($this->_request->getReferenceData()) { + $referenceData = $this->_request->getReferenceData() . $this->_request->getPackageId(); } else { $referenceData = 'Order #' . $r->getOrderShipment()->getOrder()->getIncrementId() @@ -1341,7 +1361,7 @@ protected function _mapRequestToShipment(Varien_Object $request) $request->setOrigCountryId($request->getShipperAddressCountryCode()); $request->setOrigState($request->getShipperAddressStateOrProvinceCode()); $request->setOrigCity($request->getShipperAddressCity()); - $request->setOrigStreet($request->getShipperAddressStreet1()); + $request->setOrigStreet($request->getShipperAddressStreet1() . ' ' . $request->getShipperAddressStreet2()); $request->setOrigStreetLine2($request->getShipperAddressStreet2()); $request->setDestPersonName($request->getRecipientContactPersonName()); diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php index 966f63e82a..38d30f0b6f 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php @@ -204,6 +204,8 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) $r->setKey($this->getConfigData('key')); $r->setPassword($this->getConfigData('password')); + $r->setIsReturn($request->getIsReturn()); + $this->_rawRequest = $r; return $this; @@ -334,7 +336,18 @@ protected function _prepareRateResponse($response) } elseif (isset($response->RateReplyDetails)) { $allowedMethods = explode(",", $this->getConfigData('allowed_methods')); - foreach ($response->RateReplyDetails as $rate) { + if (is_array($response->RateReplyDetails)) { + foreach ($response->RateReplyDetails as $rate) { + $serviceName = (string)$rate->ServiceType; + if (in_array($serviceName, $allowedMethods)) { + $amount = (string)$rate->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount; + $costArr[$serviceName] = $amount; + $priceArr[$serviceName] = $this->getMethodPrice($amount, $serviceName); + } + } + asort($priceArr); + } else { + $rate = $response->RateReplyDetails; $serviceName = (string)$rate->ServiceType; if (in_array($serviceName, $allowedMethods)) { $amount = (string)$rate->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount; @@ -342,7 +355,6 @@ protected function _prepareRateResponse($response) $priceArr[$serviceName] = $this->getMethodPrice($amount, $serviceName); } } - asort($priceArr); } } @@ -609,6 +621,7 @@ public function getCode($type, $code='') 'FEDEX_2_DAY', 'STANDARD_OVERNIGHT', 'PRIORITY_OVERNIGHT', + 'FIRST_OVERNIGHT', ) ), 'from_us' => array( @@ -628,6 +641,7 @@ public function getCode($type, $code='') 'FEDEX_2_DAY', 'STANDARD_OVERNIGHT', 'PRIORITY_OVERNIGHT', + 'FIRST_OVERNIGHT', ) ), 'from_us' => array( @@ -658,6 +672,7 @@ public function getCode($type, $code='') 'FEDEX_2_DAY', 'STANDARD_OVERNIGHT', 'PRIORITY_OVERNIGHT', + 'FIRST_OVERNIGHT', ) ), 'from_us' => array( @@ -980,11 +995,8 @@ protected function _getAuthDetails() */ protected function _formShipmentRequest(Varien_Object $request) { - if ($request->getIsReturn()) { - $referenceData = 'RMA #' - . $request->getOrderShipment()->getRma()->getIncrementId() - . ' P' - . $request->getPackageId(); + if ($request->getReferenceData()) { + $referenceData = $request->getReferenceData() . $request->getPackageId(); } else { $referenceData = 'Order #' . $request->getOrderShipment()->getOrder()->getIncrementId() @@ -1120,7 +1132,7 @@ protected function _formShipmentRequest(Varien_Object $request) ), 'NumberOfPieces' => 1, 'CountryOfManufacture' => implode(',', array_unique($countriesOfManufacture)), - 'Description' => implode('\r\n', $itemsDesc), + 'Description' => implode(', ', $itemsDesc), 'Quantity' => $itemsQty, 'QuantityUnits' => 'pcs', 'UnitPrice' => array( @@ -1226,6 +1238,19 @@ public function rollBack($data) */ public function getContainerTypes(Varien_Object $params = null) { + if ($params == null) { + return $this->_getAllowedContainers($params); + } + $method = $params->getMethod(); + $countryShipper = $params->getCountryShipper(); + $countryRecipient = $params->getCountryRecipient(); + + if ($countryShipper == self::USA_COUNTRY_ID + && $countryRecipient == self::CANADA_COUNTRY_ID + && $method == 'FEDEX_GROUND' + ) { + return array('YOUR_PACKAGING' => Mage::helper('usa')->__('Your Packaging')); + } return $this->_getAllowedContainers($params); } diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php index e131a38e3f..c709ee452e 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php @@ -198,10 +198,9 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, $request->getStoreId() ); - - if (is_numeric($origRegionCode)) { - $origRegionCode = Mage::getModel('directory/region')->load($origRegionCode)->getCode(); - } + } + if (is_numeric($origRegionCode)) { + $origRegionCode = Mage::getModel('directory/region')->load($origRegionCode)->getCode(); } $r->setOrigRegionCode($origRegionCode); @@ -271,6 +270,8 @@ public function setRequest(Mage_Shipping_Model_Rate_Request $request) } $r->setUnitMeasure($unit); + $r->setIsReturn($request->getIsReturn()); + $this->_rawRequest = $r; return $this; @@ -526,7 +527,7 @@ public function getCode($type, $code='') '14' => Mage::helper('usa')->__('UPS Next Day Air Early A.M.'), '54' => Mage::helper('usa')->__('UPS Worldwide Express Plus'), '59' => Mage::helper('usa')->__('UPS Second Day Air A.M.'), - '65' => Mage::helper('usa')->__('UPS Saver'), + '65' => Mage::helper('usa')->__('UPS Worldwide Saver'), ), // Shipments Originating in Canada 'Shipments Originating in Canada' => array( @@ -665,6 +666,67 @@ public function getCode($type, $code='') 'LBS' => Mage::helper('usa')->__('Pounds'), 'KGS' => Mage::helper('usa')->__('Kilograms'), ), + 'containers_filter' => array( + array( + 'containers' => array('00'), // Customer Packaging + 'filters' => array( + 'within_us' => array( + 'method' => array( + '01', // Next Day Air + '13', // Next Day Air Saver + '12', // 3 Day Select + '59', // 2nd Day Air AM + '03', // Ground + '14', // Next Day Air Early AM + '02', // 2nd Day Air + ) + ), + 'from_us' => array( + 'method' => array( + '07', // Worldwide Express + '54', // Worldwide Express Plus + '08', // Worldwide Expedited + '65', // Worldwide Saver + ) + ) + ) + ), + array( + 'containers' => array('21', '03'), // UPS Express Box, UPS Tube + 'filters' => array( + 'within_us' => array( + 'method' => array( + '14', // Next Day Air Early AM + '02', // 2nd Day Air + ) + ), + 'from_us' => array( + 'method' => array( + '07', // Worldwide Express + '54', // Worldwide Express Plus + '08', // Worldwide Expedited + '65', // Worldwide Saver + ) + ) + ) + ), + array( + 'containers' => array('24', '25'), // UPS Worldwide 25 kilo, UPS Worldwide 10 kilo + 'filters' => array( + 'within_us' => array( + 'method' => array() + ), + 'from_us' => array( + 'method' => array( + '07', // Worldwide Express + '54', // Worldwide Express Plus + '08', // Worldwide Expedited + '65', // Worldwide Saver + ) + ) + ) + ), + ) ); if (!isset($codes[$type])) { @@ -755,12 +817,24 @@ protected function _getXmlQuotes() $xmlRequest .= "{$shipper}"; } + if ($r->getIsReturn()) { + $shipperCity = ''; + $shipperPostalCode = $params['19_destPostal']; + $shipperCountryCode = $params['22_destCountry']; + $shipperStateProvince = $params['destRegionCode']; + } else { + $shipperCity = $params['origCity']; + $shipperPostalCode = $params['15_origPostal']; + $shipperCountryCode = $params['14_origCountry']; + $shipperStateProvince = $params['origRegionCode']; + } + $xmlRequest .= <<< XMLRequest
- {$params['origCity']} - {$params['15_origPostal']} - {$params['14_origCountry']} - {$params['origRegionCode']} + {$shipperCity} + {$shipperPostalCode} + {$shipperCountryCode} + {$shipperStateProvince}
@@ -1266,7 +1340,7 @@ protected function _formShipmentRequest(Varien_Object $request) // UPS Print Return Label $returnPart->addChild('Code', '9'); } - $shipmentPart->addChild('Description', implode(' ', $itemsDesc)); + $shipmentPart->addChild('Description', substr(implode(' ', $itemsDesc), 0, 35));//empirical $shipperPart = $shipmentPart->addChild('Shipper'); if ($request->getIsReturn()) { @@ -1354,7 +1428,7 @@ protected function _formShipmentRequest(Varien_Object $request) $servicePart = $shipmentPart->addChild('Service'); $servicePart->addChild('Code', $request->getShippingMethod()); $packagePart = $shipmentPart->addChild('Package'); - $packagePart->addChild('Description', implode(' ', $itemsDesc)); + $packagePart->addChild('Description', substr(implode(' ', $itemsDesc), 0, 35));//empirical $packagePart->addChild('PackagingType') ->addChild('Code', $request->getPackagingType()); $packageWeight = $packagePart->addChild('PackageWeight'); @@ -1371,12 +1445,11 @@ protected function _formShipmentRequest(Varien_Object $request) } // ups support reference number only for domestic service - if ($this->_isUSCountry($request->getRecipientAddressCountryCode())) { - if ($request->getIsReturn()) { - $referenceData = 'RMA #' - . $request->getOrderShipment()->getRma()->getIncrementId() - . ' P' - . $request->getPackageId(); + if ($this->_isUSCountry($request->getRecipientAddressCountryCode()) + && $this->_isUSCountry($request->getShipperAddressCountryCode()) + ) { + if ($request->getReferenceData()) { + $referenceData = $request->getReferenceData() . $request->getPackageId(); } else { $referenceData = 'Order #' . $request->getOrderShipment()->getOrder()->getIncrementId() @@ -1412,6 +1485,24 @@ protected function _formShipmentRequest(Varien_Object $request) ->addChild('BillShipper') ->addChild('AccountNumber', $this->getConfigData('shipper_number')); + if ($request->getPackagingType() != $this->getCode('container', 'ULE') + && $request->getShipperAddressCountryCode() == Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID + && ($request->getRecipientAddressCountryCode() == 'CA' //Canada + || $request->getRecipientAddressCountryCode() == 'PR' //Puerto Rico + )) { + $invoiceLineTotalPart = $shipmentPart->addChild('InvoiceLineTotal'); + $invoiceLineTotalPart->addChild('CurrencyCode', $request->getBaseCurrencyCode()); + $monetaryValue = 0; + if ($request->getPackageItems()) { + foreach ($request->getPackageItems() as $packageItem) { + if (array_key_exists('price', $packageItem) && array_key_exists('qty', $packageItem)) { + $monetaryValue += $packageItem['price'] * $packageItem['qty']; + } + } + } + $invoiceLineTotalPart->addChild('MonetaryValue', ceil($monetaryValue)); + } + $labelPart = $xmlRequest->addChild('LabelSpecification'); $labelPart->addChild('LabelPrintMethod') ->addChild('Code', 'GIF'); @@ -1544,6 +1635,23 @@ protected function _doShipmentRequest(Varien_Object $request) */ public function getContainerTypes(Varien_Object $params = null) { + if ($params == null) { + return $this->_getAllowedContainers($params); + } + $method = $params->getMethod(); + $countryShipper = $params->getCountryShipper(); + $countryRecipient = $params->getCountryRecipient(); + + if (($countryShipper == self::USA_COUNTRY_ID + && $countryRecipient == self::CANADA_COUNTRY_ID) + || ($countryShipper == self::CANADA_COUNTRY_ID + && $countryRecipient == self::USA_COUNTRY_ID) + || ($countryShipper == self::MEXICO_COUNTRY_ID + && $countryRecipient == self::USA_COUNTRY_ID) + && $method == '11' // UPS Standard + ) { + return array('00' => Mage::helper('usa')->__('Customer Packaging')); + } return $this->_getAllowedContainers($params); } @@ -1563,7 +1671,7 @@ public function getContainerTypesAll() return $result; } - + /** * Return structured data of containers witch related with shipping methods * @@ -1586,15 +1694,15 @@ public function getDeliveryConfirmationTypes($countyDest = null) switch ($this->_getDeliveryConfirmationLevel($countyDest)) { case self::DELIVERY_CONFIRMATION_PACKAGE: $deliveryConfirmationTypes = array( - 1 => Mage::helper('usa')->__('No Signature'), + 1 => Mage::helper('usa')->__('Delivery Confirmation'), 2 => Mage::helper('usa')->__('Signature Required'), - 3 => Mage::helper('usa')->__('Adult Required'), + 3 => Mage::helper('usa')->__('Adult Signature Required'), ); break; case self::DELIVERY_CONFIRMATION_SHIPMENT: $deliveryConfirmationTypes = array( 1 => Mage::helper('usa')->__('Signature Required'), - 2 => Mage::helper('usa')->__('Adult Required'), + 2 => Mage::helper('usa')->__('Adult Signature Required'), ); } array_unshift($deliveryConfirmationTypes, Mage::helper('usa')->__('Not Required')); diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php index 00a6ae23cc..77ea9b2c70 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php @@ -336,6 +336,9 @@ protected function _getXmlQuotes() if (!$service) { $service = $r->getService(); } + if ($r->getContainer() == 'FLAT RATE BOX' || $r->getContainer() == 'FLAT RATE ENVELOPE') { + $service = 'PRIORITY'; + } $package->addChild('Service', $service); // no matter Letter, Flat or Parcel, use Parcel @@ -350,10 +353,14 @@ protected function _getXmlQuotes() // Because some methods don't accept VARIABLE and (NON)RECTANGULAR containers $package->addChild('Container', $r->getContainer()); $package->addChild('Size', $r->getSize()); - $package->addChild('Width', $r->getWidth()); - $package->addChild('Length', $r->getLength()); - $package->addChild('Height', $r->getHeight()); - $package->addChild('Girth', $r->getGirth()); + if ($r->getSize() == 'LARGE') { + $package->addChild('Width', $r->getWidth()); + $package->addChild('Length', $r->getLength()); + $package->addChild('Height', $r->getHeight()); + if ($r->getContainer() == 'NONRECTANGULAR' || $r->getContainer() == 'VARIABLE') { + $package->addChild('Girth', $r->getGirth()); + } + } $package->addChild('Machinable', $r->getMachinable()); $api = 'RateV4'; @@ -372,10 +379,20 @@ protected function _getXmlQuotes() $package->addChild('Country', $r->getDestCountryName()); $package->addChild('Container', $r->getContainer()); $package->addChild('Size', $r->getSize()); - $package->addChild('Width', $r->getWidth()); - $package->addChild('Length', $r->getLength()); - $package->addChild('Height', $r->getHeight()); - $package->addChild('Girth', $r->getGirth()); + $width = $length = $height = $girth = ''; + if ($r->getSize() == 'LARGE') { + $width = $r->getWidth(); + $length = $r->getLength(); + $height = $r->getHeight(); + if ($r->getContainer() == 'NONRECTANGULAR') { + $girth = $r->getGirth(); + } + } + $package->addChild('Width', $width); + $package->addChild('Length', $length); + $package->addChild('Height', $height); + $package->addChild('Girth', $girth); + $api = 'IntlRateV2'; } @@ -572,7 +589,7 @@ public function getCode($type, $code='') 'USPS GXG Envelopes' => 'EXPRESS', 'Express Mail International' => 'EXPRESS', 'Express Mail International Flat Rate Envelope' => 'EXPRESS', - 'Priority Mail' => 'PRIORITY', + 'Priority Mail' => 'EXPRESS', 'Priority Mail Small Flat Rate Box' => 'PRIORITY', 'Priority Mail Medium Flat Rate Box' => 'PRIORITY', 'Priority Mail Large Flat Rate Box' => 'PRIORITY', @@ -616,7 +633,6 @@ public function getCode($type, $code='') 'Priority Mail', 'Parcel Post', 'Media Mail', - 'Express Mail', 'First-Class Mail Large Envelope', ) ), @@ -690,7 +706,7 @@ public function getCode($type, $code='') 'USPS GXG Envelopes', 'Express Mail International', 'Priority Mail International', - 'Class Mail International Package', + 'First-Class Mail International Package', ) ) ) @@ -1326,6 +1342,9 @@ protected function _formIntlShipmentRequest(Varien_Object $request) case 'FLAT RATE ENVELOPE': $container = 'FLATRATEENV'; break; + case 'FLAT RATE BOX': + $container = 'FLATRATEBOX'; + break; case 'RECTANGULAR': $container = 'RECTANGULAR'; break; @@ -1348,20 +1367,17 @@ protected function _formIntlShipmentRequest(Varien_Object $request) } // the wrap node needs for remove xml declaration above $xmlWrap = new SimpleXMLElement(''); + $method = ''; if (stripos($shippingMethod, 'Priority') !== false) { + $method = 'Priority'; $rootNode = 'PriorityMailIntlRequest'; $xml = $xmlWrap->addChild($rootNode); } else if (stripos($shippingMethod, 'First-Class') !== false) { + $method = 'FirstClass'; $rootNode = 'FirstClassMailIntlRequest'; $xml = $xmlWrap->addChild($rootNode); - if (stripos($shippingMethod, 'Letter') !== false) { - $xml->addChild('FirstClassMailType', 'LETTER'); - } else if (stripos($shippingMethod, 'Flat') !== false) { - $xml->addChild('FirstClassMailType', 'FLAT'); - } else{ - $xml->addChild('FirstClassMailType', 'PARCEL'); - } } else { + $method = 'Express'; $rootNode = 'ExpressMailIntlRequest'; $xml = $xmlWrap->addChild($rootNode); } @@ -1374,30 +1390,27 @@ protected function _formIntlShipmentRequest(Varien_Object $request) $xml->addChild('FromFirstName', $request->getShipperContactPersonFirstName()); $xml->addChild('FromLastName', $request->getShipperContactPersonLastName()); $xml->addChild('FromFirm', $request->getShipperContactCompanyName()); - $xml->addChild('FromAddress1', $request->getShipperAddressStreet1()); - $xml->addChild('FromAddress2', $request->getShipperAddressStreet2()); + $xml->addChild('FromAddress1', $request->getShipperAddressStreet2()); + $xml->addChild('FromAddress2', $request->getShipperAddressStreet1()); $xml->addChild('FromCity', $request->getShipperAddressCity()); $xml->addChild('FromState', $request->getShipperAddressStateOrProvinceCode()); $xml->addChild('FromZip5', $fromZip5); $xml->addChild('FromZip4', $fromZip4); $xml->addChild('FromPhone', $request->getShipperContactPhoneNumber()); - if ($request->getIsReturn()) { - $referenceData = 'RMA #' - . $request->getOrderShipment()->getRma()->getIncrementId() - . ' P' - . $request->getPackageId(); - } else { - $referenceData = 'Order #' - . $request->getOrderShipment()->getOrder()->getIncrementId() - . ' P' - . $request->getPackageId(); + if ($method != 'FirstClass') { + if ($request->getReferenceData()) { + $referenceData = $request->getReferenceData() . ' P' . $request->getPackageId(); + } else { + $referenceData = $request->getOrderShipment()->getOrder()->getIncrementId() + . ' P' + . $request->getPackageId(); + } + $xml->addChild('FromCustomsReference', 'Order #' . $referenceData); } - $xml->addChild('FromCustomsReference', 'Order #' . $referenceData); - $xml->addChild('ToName', $request->getRecipientContactPersonName()); $xml->addChild('ToFirm', $request->getRecipientContactCompanyName()); - $xml->addChild('ToAddress1', $request->getRecipientAddressStreet1()); - $xml->addChild('ToAddress2', $request->getRecipientAddressStreet2()); + $xml->addChild('ToAddress1', $request->getRecipientAddressStreet2()); + $xml->addChild('ToAddress2', $request->getRecipientAddressStreet1()); $xml->addChild('ToCity', $request->getRecipientAddressCity()); $xml->addChild('ToProvince', $request->getRecipientAddressStateOrProvinceCode()); $xml->addChild('ToCountry', $this->_getCountryName($request->getRecipientAddressCountryCode())); @@ -1406,16 +1419,26 @@ protected function _formIntlShipmentRequest(Varien_Object $request) $xml->addChild('ToPhone', $request->getRecipientContactPhoneNumber()); $xml->addChild('ToFax'); $xml->addChild('ToEmail'); - $xml->addChild('NonDeliveryOption', 'Return'); - $xml->addChild('Container', $container); + if ($method != 'FirstClass') { + $xml->addChild('NonDeliveryOption', 'Return'); + } + if ($method == 'FirstClass') { + if (stripos($shippingMethod, 'Letter') !== false) { + $xml->addChild('FirstClassMailType', 'LETTER'); + } else if (stripos($shippingMethod, 'Flat') !== false) { + $xml->addChild('FirstClassMailType', 'FLAT'); + } else{ + $xml->addChild('FirstClassMailType', 'PARCEL'); + } + } + if ($method != 'FirstClass') { + $xml->addChild('Container', $container); + } $shippingContents = $xml->addChild('ShippingContents'); - $packageItems = $request->getPackageItems(); - // get countries of manufacture $countriesOfManufacture = array(); $productIds = array(); - foreach ($packageItems as $itemShipment) { $item = new Varien_Object(); $item->setData($itemShipment); @@ -1466,7 +1489,9 @@ protected function _formIntlShipmentRequest(Varien_Object $request) $xml->addChild('Agreement', 'y'); $xml->addChild('ImageType', 'PDF'); $xml->addChild('ImageLayout', 'ALLINONEFILE'); - + if ($method == 'FirstClass') { + $xml->addChild('Container', $container); + } // set size if ($packageParams->getSize()) { $xml->addChild('Size', $packageParams->getSize()); diff --git a/app/code/core/Mage/Wishlist/Model/Resource/Item/Collection.php b/app/code/core/Mage/Wishlist/Model/Resource/Item/Collection.php index ebfb26c330..8901212640 100755 --- a/app/code/core/Mage/Wishlist/Model/Resource/Item/Collection.php +++ b/app/code/core/Mage/Wishlist/Model/Resource/Item/Collection.php @@ -330,10 +330,17 @@ public function addDaysInWishlist() { $this->_addDaysInWishlist = true; - $dateDiff = Mage::getResourceHelper('wishlist') - ->getDaysInWishlist(); - $this->getSelect()->columns(array('days_in_wishlist' => $dateDiff)); + $adapter = $this->getConnection(); + $dateModel = Mage::getSingleton('core/date'); + $resHelper = Mage::getResourceHelper('core'); + + $offsetFromDb = (int) $dateModel->getGmtOffset(); + $startDate = $adapter->getDateAddSql('added_at', $offsetFromDb, Varien_Db_Adapter_Interface::INTERVAL_SECOND); + $nowDate = $dateModel->date(); + $dateDiff = $resHelper->getDateDiff($startDate, $adapter->formatDate($nowDate)); + + $this->getSelect()->columns(array('days_in_wishlist' => $dateDiff)); return $this; } diff --git a/app/code/core/Mage/Wishlist/sql/wishlist_setup/install-1.6.0.0.php b/app/code/core/Mage/Wishlist/sql/wishlist_setup/install-1.6.0.0.php index 569a278c1a..6037dd7376 100644 --- a/app/code/core/Mage/Wishlist/sql/wishlist_setup/install-1.6.0.0.php +++ b/app/code/core/Mage/Wishlist/sql/wishlist_setup/install-1.6.0.0.php @@ -1,4 +1,4 @@ -/getNewApplication(); + return (bool) !Mage::getSingleton('adminhtml/session')->getNewApplication(); } /** diff --git a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Accordion/Images.php b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Accordion/Images.php index b6b737d3c6..7ac9589ea0 100644 --- a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Accordion/Images.php +++ b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Accordion/Images.php @@ -85,9 +85,16 @@ protected function _prepareForm() ); break; case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD: + $this->addImage($fieldset, + 'conf[native][body][bannerIpadLandscapeImage]', + $this->__('Banner on Home Screen
(landscape mode)'), + $this->__('Recommended size 1024px x 344px. Note: Image size affects the performance of your app.'), + $this->_getDesignPreviewImageUrl('conf/native/body/bannerIpadLandscapeImage'), + true + ); $this->addImage($fieldset, 'conf[native][body][bannerIpadImage]', - $this->__('Banner on Home Screen'), + $this->__('Banner on Home Screen
(portrait mode)'), $this->__('Recommended size 768px x 294px. Note: Image size affects the performance of your app.'), $this->_getDesignPreviewImageUrl('conf/native/body/bannerIpadImage'), true diff --git a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Themes.php b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Themes.php index 99e4a642fb..a10067cab2 100644 --- a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Themes.php +++ b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Design/Themes.php @@ -178,6 +178,16 @@ public function getSaveThemeActionUrl() return $this->getUrl('*/*/saveTheme'); } + /** + * Get delete theme action url + * + * @return string + */ + public function getDeleteThemeActionUrl() + { + return $this->getUrl('*/*/deleteTheme'); + } + /** * Reset theme action url getter * diff --git a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/General.php b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/General.php index 9fe77c41a8..8de396d899 100644 --- a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/General.php +++ b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/General.php @@ -73,7 +73,7 @@ protected function _prepareForm() 'label' => $this->__('Store View'), 'title' => $this->__('Store View'), 'required' => true, - 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(true, false), + 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, false), )); } else { $storeElement = $fieldset->addField('store_id', 'hidden', array( @@ -86,6 +86,8 @@ protected function _prepareForm() if ($model->getId()) { $storeElement->setValue($model->getStoreId()); $storeElement->setDisabled(true); + } else if ($model->getStoreId()) { + $storeElement->setValue($model->getStoreId()); } $fieldset->addField('showdev', 'select', array( diff --git a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Payment.php b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Payment.php index 7f2c42b671..e61c124b6e 100644 --- a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Payment.php +++ b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Payment.php @@ -77,11 +77,12 @@ protected function _prepareForm() /** * PayPal MEP management */ - $isExpressCheckoutAvaliable = Mage::getModel('xmlconnect/payment_method_paypal_mep')->isAvailable(null); + $isExpressCheckoutAvailable = Mage::getModel('xmlconnect/payment_method_paypal_mep') + ->isAvailable(null); $paypalActive = 0; if (isset($data['conf[native][paypal][isActive]'])) { - $paypalActive = (int)($data['conf[native][paypal][isActive]'] && $isExpressCheckoutAvaliable); + $paypalActive = (int)($data['conf[native][paypal][isActive]'] && $isExpressCheckoutAvailable); } $fieldsetPaypal = $form->addFieldset('paypal_mep_checkout', array( 'legend' => $this->__('PayPal Mobile Embedded Payment (MEP)') @@ -93,15 +94,15 @@ protected function _prepareForm() $this->getUrl('adminhtml/system_config/edit', array('section' => 'paypal')) ); - $businessAccountNote = $this->__('MEP is PayPal`s native checkout experience for the iPhone. You can choose to use MEP alongside standard checkout, or use it as your only checkout method for Magento mobile. PayPal MEP requires a PayPal business account', $paypalConfigurationUrl); + $businessAccountNote = $this->__('MEP is PayPal\'s native checkout experience for the iPhone. You can choose to use MEP alongside standard checkout, or use it as your only checkout method for Magento mobile. PayPal MEP requires a PayPal business account', $paypalConfigurationUrl); $paypalActiveField = $fieldsetPaypal->addField('conf/native/paypal/isActive', 'select', array( 'label' => $this->__('Activate PayPal Checkout'), 'name' => 'conf[native][paypal][isActive]', - 'note' => (!$isExpressCheckoutAvaliable ? $activateMepMethodNote : $businessAccountNote), + 'note' => (!$isExpressCheckoutAvailable ? $activateMepMethodNote : $businessAccountNote), 'values' => $yesNoValues, 'value' => $paypalActive, - 'disabled' => !$isExpressCheckoutAvaliable + 'disabled' => !$isExpressCheckoutAvailable )); if (isset($data['conf[special][merchantLabel]'])) { @@ -117,15 +118,69 @@ protected function _prepareForm() 'value' => $merchantLabelValue )); + if (isset($data['config_data[payment][paypalmep/allowspecific]'])) { + $paypalMepAllow = (int) $data['config_data[payment][paypalmep/allowspecific]']; + } else { + $paypalMepAllow = 0; + } + $paypalMepAllowSpecific = $fieldsetPaypal->addField( + 'config_data/paypalmep/allowspecific', + 'select', + array( + 'name' => 'config_data[payment:paypalmep/allowspecific]', + 'label' => $this->__('Payment Applicable From'), + 'values' => array( + array('value' => 0, 'label' => $this->__('All Allowed Countries')), + array('value' => 1, 'label' => $this->__('Specific Countries')) + ), + 'value' => $paypalMepAllow + )); + + $countries = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray(true); + + if (empty($data['config_data[payment][paypalmep/allowspecific]'])) { + $countrySelected = array(); + } else { + $countrySelected = explode(',', $data['config_data[payment][paypalmep/applicable]']); + } + + $paypalMepApplicable = $fieldsetPaypal->addField( + 'config_data/paypalmep/applicable', + 'multiselect', + array( + 'name' => 'config_data[payment:paypalmep/applicable]', + 'label' => $this->__('Countries Payment Applicable From'), + 'values' => $countries, + 'value' => $countrySelected + )); + // field dependencies $this->setChild('form_after', $this->getLayout() ->createBlock('adminhtml/widget_form_element_dependence') + ->addFieldMap($paypalMepAllowSpecific->getHtmlId(), $paypalMepAllowSpecific->getName()) + ->addFieldMap($paypalMepApplicable->getHtmlId(), $paypalMepApplicable->getName()) ->addFieldMap($merchantlabelField->getHtmlId(), $merchantlabelField->getName()) ->addFieldMap($paypalActiveField->getHtmlId(), $paypalActiveField->getName()) + ->addFieldDependence( + $paypalMepApplicable->getName(), + $paypalMepAllowSpecific->getName(), + 1 + ) + ->addFieldDependence( + $paypalMepAllowSpecific->getName(), + $paypalActiveField->getName(), + 1 + ) + ->addFieldDependence( + $paypalMepApplicable->getName(), + $paypalActiveField->getName(), + 1 + ) ->addFieldDependence( $merchantlabelField->getName(), $paypalActiveField->getName(), - 1) + 1 + ) ); break; case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID: diff --git a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Social.php b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Social.php index b8d852f8ea..a1c6807a3a 100755 --- a/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Social.php +++ b/app/code/core/Mage/XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Social.php @@ -54,7 +54,8 @@ protected function _prepareForm() /** * Default values for social networks is DISABLED */ - $twitterStatus = $facebookStatus = $linkedinStatus = 0; + $twitterStatus = $facebookStatus = $linkedinStatus = 0; + $noteText = $this->__('Please click here to see how to setup and retrieve API credentials.'); /** * Twitter fieldset options @@ -112,6 +113,17 @@ protected function _prepareForm() ) ); + $fieldsetTwitter->addField( + 'twitterNote', + 'note', + array( + 'text' => sprintf( + $noteText, + Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_TWITTER_URL) + ), + ) + ); + /** * Facebook fieldset options */ @@ -151,6 +163,17 @@ protected function _prepareForm() ) ); + $fieldsetFacebook->addField( + 'facebookNote', + 'note', + array( + 'text' => sprintf( + $noteText, + Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_FACEBOOK_URL) + ), + ) + ); + /** * LinkedIn fieldset options */ @@ -207,6 +230,17 @@ protected function _prepareForm() ) ); + $fieldsetLinkedin->addField( + 'linkedinNote', + 'note', + array( + 'text' => sprintf( + $noteText, + Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_LINKEDIN_URL) + ), + ) + ); + /** * Set field dependencies */ diff --git a/app/code/core/Mage/XmlConnect/Block/Cart.php b/app/code/core/Mage/XmlConnect/Block/Cart.php index 3fd6a4e10b..06411a593d 100644 --- a/app/code/core/Mage/XmlConnect/Block/Cart.php +++ b/app/code/core/Mage/XmlConnect/Block/Cart.php @@ -42,7 +42,7 @@ protected function _toHtml() { $cartMessages = $this->getMessages(); $quote = $this->getQuote(); - $xmlObject = new Mage_XmlConnect_Model_Simplexml_Element(''); + $xmlObject = Mage::getModel('xmlconnect/simplexml_element', ''); $xmlObject->addAttribute('is_virtual', (int)$this->helper('checkout/cart')->getIsVirtualQuote()); $xmlObject->addAttribute('summary_qty', (int)$this->helper('checkout/cart')->getSummaryCount()); if (strlen($quote->getCouponCode())) { @@ -65,7 +65,9 @@ protected function _toHtml() $itemXml->addChild('name', $xmlObject->xmlentities(strip_tags($renderer->getProductName()))); $itemXml->addChild('code', 'cart[' . $item->getId() . '][qty]'); $itemXml->addChild('qty', $renderer->getQty()); - $icon = $renderer->getProductThumbnail()->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small')); + $icon = $renderer->getProductThumbnail()->resize( + Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small') + ); $iconXml = $itemXml->addChild('icon', $icon); @@ -78,8 +80,12 @@ protected function _toHtml() */ $exclPrice = $inclPrice = 0.00; if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) { - if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) { - $exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount() + $item->getWeeeTaxDisposition(); + if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') + && $item->getWeeeTaxAppliedAmount() + ) { + $exclPrice = $item->getCalculationPrice() + + $item->getWeeeTaxAppliedAmount() + + $item->getWeeeTaxDisposition(); } else { $exclPrice = $item->getCalculationPrice(); } @@ -87,7 +93,9 @@ protected function _toHtml() if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) { $_incl = $this->helper('checkout')->getPriceInclTax($item); - if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) { + if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') + && $item->getWeeeTaxAppliedAmount() + ) { $inclPrice = $_incl + $item->getWeeeTaxAppliedAmount(); } else { $inclPrice = $_incl - $item->getWeeeTaxDisposition(); @@ -126,15 +134,21 @@ protected function _toHtml() */ $exclPrice = $inclPrice = 0.00; if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) { - if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) { - $exclPrice = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition(); + if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') + && $item->getWeeeTaxAppliedAmount() + ) { + $exclPrice = $item->getRowTotal() + + $item->getWeeeTaxAppliedRowAmount() + + $item->getWeeeTaxRowDisposition(); } else { $exclPrice = $item->getRowTotal(); } } if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) { $_incl = $this->helper('checkout')->getSubtotalInclTax($item); - if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) { + if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') + && $item->getWeeeTaxAppliedAmount() + ) { $inclPrice = $_incl + $item->getWeeeTaxAppliedRowAmount(); } else { $inclPrice = $_incl - $item->getWeeeTaxRowDisposition(); @@ -176,7 +190,10 @@ protected function _toHtml() $_formatedOptionValue = $renderer->getFormatedOptionValue($_option); $optionXml = $itemOptionsXml->addChild('option'); $optionXml->addAttribute('label', $xmlObject->xmlentities(strip_tags($_option['label']))); - $optionXml->addAttribute('text', $xmlObject->xmlentities(strip_tags($_formatedOptionValue['value']))); + $optionXml->addAttribute( + 'text', + $xmlObject->xmlentities(strip_tags($_formatedOptionValue['value'])) + ); // if (isset($_formatedOptionValue['full_view'])) { // $label = strip_tags($_option['label']); // $value = strip_tags($_formatedOptionValue['full_view']); @@ -214,10 +231,15 @@ protected function _toHtml() /** * Cross Sell Products */ - $crossSellXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($this->getChildHtml('crosssell')); + if (count($this->getItems())) { + $crossellXml = $this->getChildHtml('crosssell'); + } else { + $crossellXml = ''; + } + + $crossSellXmlObj = Mage::getModel('xmlconnect/simplexml_element', $crossellXml); $xmlObject->appendChild($crossSellXmlObj); return $xmlObject->asNiceXml(); } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Cart/Crosssell.php b/app/code/core/Mage/XmlConnect/Block/Cart/Crosssell.php index 0d6f6efb19..a16aeb9807 100644 --- a/app/code/core/Mage/XmlConnect/Block/Cart/Crosssell.php +++ b/app/code/core/Mage/XmlConnect/Block/Cart/Crosssell.php @@ -28,27 +28,35 @@ * Shopping cart cross sell items xml renderer * * @category Mage - * @package Mage_Checkout + * @package Mage_XmlConnect * @author Magento Core Team */ class Mage_XmlConnect_Block_Cart_Crosssell extends Mage_Checkout_Block_Cart_Crosssell { - /** + /** * Render cross sell items xml * * @return string */ protected function _toHtml() { - $crossSellXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + if (is_object(Mage::getConfig()->getNode('modules/Enterprise_TargetRule'))) { + $blockRenderer = 'enterprise_targetrule/checkout_cart_crosssell'; + $blockName = 'targetrule.checkout.cart.crosssell'; + $this->getLayout()->createBlock($blockRenderer, $blockName); + $this->setItems($this->getLayout()->getBlock($blockName)->getItemCollection()); + } + + $crossSellXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); if (!$this->getItemCount()) { return $crossSellXmlObj->asNiceXml(); } - foreach ($this->getItems() as $_item) { + /** @var $product Mage_Catalog_Model_Product */ + foreach ($this->getItems() as $product) { $itemXmlObj = $crossSellXmlObj->addChild('item'); - $itemXmlObj->addChild('name', $crossSellXmlObj->xmlentities(strip_tags($_item->getName()))); - $icon = $this->helper('catalog/image')->init($_item, 'thumbnail') + $itemXmlObj->addChild('name', $crossSellXmlObj->xmlentities($product->getName())); + $icon = $this->helper('catalog/image')->init($product, 'thumbnail') ->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small')); $iconXml = $itemXmlObj->addChild('icon', $icon); @@ -56,26 +64,38 @@ protected function _toHtml() $file = Mage::helper('xmlconnect')->urlToPath($icon); $iconXml->addAttribute('modification_time', filemtime($file)); - $itemXmlObj->addChild('entity_id', $_item->getId()); - $itemXmlObj->addChild('entity_type', $_item->getTypeId()); - $itemXmlObj->addChild('has_options', (int)$_item->getHasOptions()); + $itemXmlObj->addChild('entity_id', $product->getId()); + $itemXmlObj->addChild('entity_type', $product->getTypeId()); + + /** + * If product type is grouped than it has options as its grouped items + */ + if ($product->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE) { + $product->setHasOptions(true); + } + + $itemXmlObj->addChild('has_options', (int)$product->getHasOptions()); + $itemXmlObj->addChild('in_stock', (int)$product->isInStock()); + if ($product->getTypeId() == Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE) { + $itemXmlObj->addChild('is_salable', 0); + } else { + $itemXmlObj->addChild('is_salable', (int)$product->isSalable()); + } if ($this->getChild('product_price')) { - $this->getChild('product_price')->setProduct($_item) - ->setProductXmlObj($itemXmlObj) - ->collectProductPrices(); + $this->getChild('product_price')->setProduct($product) + ->setProductXmlObj($itemXmlObj) + ->collectProductPrices(); } - if (!$_item->getRatingSummary()) { + if (!$product->getRatingSummary()) { Mage::getModel('review/review') - ->getEntitySummary($_item, Mage::app()->getStore()->getId()); + ->getEntitySummary($product, Mage::app()->getStore()->getId()); } - $itemXmlObj->addChild('rating_summary', round((int)$_item->getRatingSummary()->getRatingSummary() / 10)); - $itemXmlObj->addChild('reviews_count', $_item->getRatingSummary()->getReviewsCount()); + $itemXmlObj->addChild('rating_summary', round((int)$product->getRatingSummary()->getRatingSummary() / 10)); + $itemXmlObj->addChild('reviews_count', $product->getRatingSummary()->getReviewsCount()); } - return $crossSellXmlObj->asNiceXml(); } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Cart/Info.php b/app/code/core/Mage/XmlConnect/Block/Cart/Info.php index 01b55fc516..53c74a69f9 100644 --- a/app/code/core/Mage/XmlConnect/Block/Cart/Info.php +++ b/app/code/core/Mage/XmlConnect/Block/Cart/Info.php @@ -33,29 +33,42 @@ */ class Mage_XmlConnect_Block_Cart_Info extends Mage_XmlConnect_Block_Cart { - /** + /** * Render cart summary xml * * @return string */ protected function _toHtml() { + /** @var $quote Mage_Sales_Model_Quote */ $quote = $this->getQuote(); - $xmlObject = new Mage_XmlConnect_Model_Simplexml_Element(''); - $xmlObject->addChild('is_virtual', (int)$this->helper('checkout/cart')->getIsVirtualQuote()); - $xmlObject->addChild('summary_qty', (int)$this->helper('checkout/cart')->getSummaryCount()); - $xmlObject->addChild('virtual_qty', (int)$quote->getItemVirtualQty()); + /** @var $xmlObject Mage_XmlConnect_Model_Simplexml_Element */ + $xmlObject = Mage::getModel('xmlconnect/simplexml_element', ''); + + $xmlObject->addChild( + 'is_virtual', + (int)$this->helper('checkout/cart')->getIsVirtualQuote() + ); + $xmlObject->addChild( + 'summary_qty', + (int)$this->helper('checkout/cart')->getSummaryCount() + ); + $xmlObject->addChild( + 'virtual_qty', + (int)$quote->getItemVirtualQty() + ); + if (strlen($quote->getCouponCode())) { $xmlObject->addChild('has_coupon_code', 1); } $totalsXml = $this->getChildHtml('totals'); if ($totalsXml) { - $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($totalsXml); + /** @var $totalsXmlObj Mage_XmlConnect_Model_Simplexml_Element */ + $totalsXmlObj = Mage::getModel('xmlconnect/simplexml_element', $totalsXml); $xmlObject->appendChild($totalsXmlObj); } return $xmlObject->asNiceXml(); } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php b/app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php index bd3c9dd66c..65f8feb501 100644 --- a/app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php +++ b/app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php @@ -40,8 +40,10 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mep_Totals extends Mage_Checkout_Block_C */ protected function _toHtml() { + /** @var $paypalCart Mage_Paypal_Model_Cart */ $paypalCart = Mage::getModel('paypal/cart', array($this->getQuote())); - $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $totalsXmlObj Mage_XmlConnect_Model_Simplexml_Element */ + $totalsXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); foreach ($paypalCart->getTotals(true) as $code => $amount) { $currencyAmount = $this->helper('core')->currency($amount, false, false); $totalsXmlObj->addChild($code, sprintf('%01.2F', $currencyAmount)); diff --git a/app/code/core/Mage/XmlConnect/Block/Cart/Totals.php b/app/code/core/Mage/XmlConnect/Block/Cart/Totals.php index 8f06864452..1a1a5c5c7d 100644 --- a/app/code/core/Mage/XmlConnect/Block/Cart/Totals.php +++ b/app/code/core/Mage/XmlConnect/Block/Cart/Totals.php @@ -33,16 +33,16 @@ */ class Mage_XmlConnect_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Totals { - /** + /** * Render cart totals xml * * @return string */ protected function _toHtml() { - $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); - $taxConfig = Mage::getSingleton('tax/config'); - $displayInclTax = $displayBoth = false; + /** @var $totalsXmlObj Mage_XmlConnect_Model_Simplexml_Element */ + $totalsXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); +// $taxConfig = Mage::getSingleton('tax/config'); foreach ($this->getQuote()->getTotals() as $total) { $code = $total->getCode(); @@ -55,7 +55,7 @@ protected function _toHtml() switch ($code) { case 'subtotal': if ($renderer->displayBoth()) { - $title = $this->helper('xmlconnect')->__('Subtotal (Excl. Tax)'); + $title = $this->__('Subtotal (Excl. Tax)'); $this->_addTotalDataToXmlObj( $totalsXmlObj, $code . @@ -65,7 +65,7 @@ protected function _toHtml() ); $code = $code . '_incl_tax'; - $title = $this->helper('xmlconnect')->__('Subtotal (Incl. Tax)'); + $title = $this->__('Subtotal (Incl. Tax)'); $value = $total->getValueInclTax(); } break; @@ -93,11 +93,15 @@ protected function _toHtml() $grandTotalExlTax = $renderer->getTotalExclTax(); $displayBoth = $renderer->includeTax() && $grandTotalExlTax >= 0; if ($displayBoth) { - $title = $this->helper('xmlconnect')->__('Grand Total (Excl. Tax)'); - $this->_addTotalDataToXmlObj($totalsXmlObj, $code . '_excl_tax', $title, $grandTotalExlTax); - + $title = $this->__('Grand Total (Excl. Tax)'); + $this->_addTotalDataToXmlObj( + $totalsXmlObj, + $code . '_excl_tax', + $title, + $grandTotalExlTax + ); $code = $code . '_incl_tax'; - $title = $this->helper('xmlconnect')->__('Grand Total (Incl. Tax)'); + $title = $this->__('Grand Total (Incl. Tax)'); } break; default: @@ -127,9 +131,9 @@ protected function _addTotalDataToXmlObj($totalsXmlObj, $code, $title, $value) { $value = Mage::helper('xmlconnect')->formatPriceForXml($value); $totalXmlObj = $totalsXmlObj->addChild($code); - $totalXmlObj->addChild('title', $totalsXmlObj->xmlentities(strip_tags($title))); - $formatedValue = $this->getQuote()->getStore()->formatPrice($value, false); + $totalXmlObj->addChild('title', $totalsXmlObj->xmlentities($title)); + $formattedValue = $this->getQuote()->getStore()->formatPrice($value, false); $totalXmlObj->addChild('value', $value); - $totalXmlObj->addChild('formated_value', $formatedValue); + $totalXmlObj->addChild('formated_value', $formattedValue); } } diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog.php b/app/code/core/Mage/XmlConnect/Block/Catalog.php index 11a3ac0c7f..c261b001b4 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog.php @@ -32,17 +32,14 @@ class Mage_XmlConnect_Block_Catalog extends Mage_Core_Block_Template /** * Prefix that used in specifing filters on request - * */ const REQUEST_FILTER_PARAM_REFIX = 'filter_'; /** * Prefix that used in specifing sort order params on request - * */ const REQUEST_SORT_ORDER_PARAM_REFIX = 'order_'; - /** * Retrieve product sort fields as xml object * @@ -50,7 +47,7 @@ class Mage_XmlConnect_Block_Catalog extends Mage_Core_Block_Template */ public function getProductSortFeildsXmlObject() { - $ordersXmlObject = new Mage_XmlConnect_Model_Simplexml_Element(''); + $ordersXmlObject = Mage::getModel('xmlconnect/simplexml_element', ''); /* @var $category Mage_Catalog_Model_Category */ $category = Mage::getModel('catalog/category'); $sortOptions = $category->getAvailableSortByOptions(); @@ -67,5 +64,4 @@ public function getProductSortFeildsXmlObject() return $ordersXmlObject; } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Category.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Category.php index 14e3f01d01..6cc1d87231 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Category.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Category.php @@ -27,11 +27,10 @@ /** * Category list xml renderer * - * @category Mage - * @package Mage_XmlConnect + * @category Mage + * @package Mage_XmlConnect * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Category extends Mage_XmlConnect_Block_Catalog { /** @@ -41,14 +40,15 @@ class Mage_XmlConnect_Block_Catalog_Category extends Mage_XmlConnect_Block_Catal */ protected function _toHtml() { - $categoryXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $categoryXmlObj Mage_XmlConnect_Model_Simplexml_Element */ + $categoryXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $categoryId = $this->getRequest()->getParam('id', null); if ($categoryId === null) { $categoryId = Mage::app()->getStore()->getRootCategoryId(); } $productsXmlObj = $productListBlock = false; - + /** @var $categoryModel Mage_Catalog_Model_Category */ $categoryModel = Mage::getModel('catalog/category')->load($categoryId); if ($categoryModel->getId()) { $hasMoreProductItems = 0; @@ -70,20 +70,17 @@ protected function _toHtml() } } - /** @var $categoryCollection Mage_XmlConnect_Model_Mysql4_Category_Collection */ - $categoryCollection = Mage::getResourceModel('xmlconnect/category_collection'); - $categoryCollection->setStoreId(Mage::app()->getStore()->getId()) - ->setOrder('position', 'ASC') - ->addParentIdFilter($categoryId); + $categoryCollection = $categoryModel->getCategories($categoryId, 0, false, true); // subcategories are exists if (sizeof($categoryCollection)) { $itemsXmlObj = $categoryXmlObj->addChild('items'); - - foreach ($categoryCollection->getItems() as $item) { + foreach ($categoryCollection as $item) { $itemXmlObj = $itemsXmlObj->addChild('item'); + /** @var $item Mage_Catalog_Model_Category */ + $item = Mage::getModel('catalog/category')->load($item->getId()); $itemXmlObj->addChild('label', $categoryXmlObj->xmlentities(strip_tags($item->getName()))); - $itemXmlObj->addChild('entity_id', $item->getEntityId()); + $itemXmlObj->addChild('entity_id', $item->getId()); $itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products'); if (!is_null($categoryId)) { $itemXmlObj->addChild('parent_id', $item->getParentId()); @@ -101,7 +98,6 @@ protected function _toHtml() if ($productListBlock && $productsXmlObj) { $categoryXmlObj->appendChild($productsXmlObj); } - return $categoryXmlObj->asNiceXml(); } } diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Category/Info.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Category/Info.php index 8642516871..6abd9945e2 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Category/Info.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Category/Info.php @@ -27,14 +27,12 @@ /** * Category info xml renderer * - * @category Mage - * @package Mage_XmlConnect + * @category Mage + * @package Mage_XmlConnect * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Category_Info extends Mage_XmlConnect_Block_Catalog { - /** * Produce category info xml object * @@ -42,7 +40,7 @@ class Mage_XmlConnect_Block_Catalog_Category_Info extends Mage_XmlConnect_Block_ */ public function getCategoryInfoXmlObject() { - $infoXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $infoXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $category = $this->getCategory(); if ($category && is_object($category) && $category->getId()) { /** diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Filters.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Filters.php index a73c87f08a..1cf068c0d2 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Filters.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Filters.php @@ -27,14 +27,12 @@ /** * Filters xml renderer * - * @category Mage - * @package Mage_XmlConnect + * @category Mage + * @package Mage_XmlConnect * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Filters extends Mage_XmlConnect_Block_Catalog { - /** * Render filters list xml * @@ -43,7 +41,7 @@ class Mage_XmlConnect_Block_Catalog_Filters extends Mage_XmlConnect_Block_Catalo protected function _toHtml() { $categoryId = $this->getRequest()->getParam('category_id', null); - $categoryXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $categoryXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $filtersCollection = Mage::getResourceModel('xmlconnect/filter_collection')->setCategoryId($categoryId); $filtersXmlObj = $categoryXmlObj->addChild('filters'); @@ -67,5 +65,4 @@ protected function _toHtml() return $categoryXmlObj->asNiceXml(); } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product.php index 6adf92f6ba..b2f54fb82b 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product.php @@ -27,8 +27,8 @@ /** * Product data xml renderer * - * @category Mage - * @package Mage_XmlConnect + * @category Mage + * @package Mage_XmlConnect * @author Magento Core Team */ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalog @@ -38,12 +38,12 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo * * @param Mage_Catalog_Model_Product $product * @param string $itemNodeName - * * @return Mage_XmlConnect_Model_Simplexml_Element */ public function productToXmlObject(Mage_Catalog_Model_Product $product, $itemNodeName = 'item') { - $item = new Mage_XmlConnect_Model_Simplexml_Element('<' . $itemNodeName . '>'); + /** @var $item Mage_XmlConnect_Model_Simplexml_Element */ + $item = Mage::getModel('xmlconnect/simplexml_element', '<' . $itemNodeName . '>'); if ($product && $product->getId()) { $item->addChild('entity_id', $product->getId()); $item->addChild('name', $item->xmlentities(strip_tags($product->getName()))); @@ -132,16 +132,18 @@ protected function _getMinimalQty($product) /** * Render product info xml * + * @throws Mage_Core_Exception * @return string */ protected function _toHtml() { + /** @var $product Mage_Catalog_Model_Product */ $product = Mage::getModel('catalog/product') ->setStoreId(Mage::app()->getStore()->getId()) ->load($this->getRequest()->getParam('id', 0)); if (!$product) { - throw new Mage_Core_Exception($this->__('Selected product is unavailable.')); + Mage::throwException($this->__('Selected product is unavailable.')); } else { $this->setProduct($product); $productXmlObj = $this->productToXmlObject($product, 'product'); diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Attributes.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Attributes.php index df552c824e..3116c53520 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Attributes.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Attributes.php @@ -27,22 +27,22 @@ /** * Product additional attributes xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Product_Attributes extends Mage_Catalog_Block_Product_View_Attributes { - /** * Add additional information (attributes) to current product xml object * * @param Mage_Catalog_Model_Product $product * @param Mage_XmlConnect_Model_Simplexml_Element $productXmlObject - * */ - public function addAdditionalData(Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $productXmlObject) + public function addAdditionalData( + Mage_Catalog_Model_Product $product, + Mage_XmlConnect_Model_Simplexml_Element $productXmlObject + ) { if ($product && $productXmlObject && $product->getId()) { $this->_product = $product; @@ -50,12 +50,14 @@ public function addAdditionalData(Mage_Catalog_Model_Product $product, Mage_XmlC if (!empty($additionalData)) { $attributesXmlObj = $productXmlObject->addChild('additional_attributes'); foreach ($additionalData as $data) { - $_attrXmlObject = $attributesXmlObj->addChild('item'); - $_attrXmlObject->addChild('label', $this->htmlEscape($data['label'])); - $_attrXmlObject->addChild('value', Mage::helper('catalog/output')->productAttribute($product, $data['value'], $data['code'])); + $attribute = Mage::helper('catalog/output') + ->productAttribute($product, $data['value'], $data['code']); + /** @var $attrXmlObject Mage_XmlConnect_Model_Simplexml_Element */ + $attrXmlObject = $attributesXmlObj->addChild('item'); + $attrXmlObject->addCustomChild('label', $data['label']); + $attrXmlObject->addCustomChild('value', $attribute); } } } - } } diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Gallery.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Gallery.php index 1ea1ed5cc8..125070591b 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Gallery.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Gallery.php @@ -27,14 +27,12 @@ /** * Product images gallery block * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Product_Gallery extends Mage_XmlConnect_Block_Catalog { - /** * Generate images gallery xml * @@ -48,7 +46,7 @@ protected function _toHtml() ->load($productId); $collection = $product->getMediaGalleryImages(); - $imagesNode = new Mage_XmlConnect_Model_Simplexml_Element(''); + $imagesNode = Mage::getModel('xmlconnect/simplexml_element', ''); $helper = $this->helper('catalog/image'); foreach ($collection as $item) { diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/List.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/List.php index d6cf5dcbda..985e49ce41 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/List.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/List.php @@ -27,13 +27,12 @@ /** * Product list xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Catalog_Product_List extends Mage_XmlConnect_Block_Catalog_Product { - /** * Store product collection * @@ -55,7 +54,7 @@ class Mage_XmlConnect_Block_Catalog_Product_List extends Mage_XmlConnect_Block_C */ public function getProductsXmlObject() { - $productsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $productsXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $collection = $this->_getProductCollection(); if (!$collection) { diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options.php index 4bba8d0c4e..f6fd9d0a66 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options.php @@ -27,14 +27,12 @@ /** * Product Options xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Block_Catalog { - const OPTION_TYPE_SELECT = 'select'; const OPTION_TYPE_CHECKBOX = 'checkbox'; const OPTION_TYPE_TEXT = 'text'; @@ -69,7 +67,7 @@ public function addRenderer($type, $renderer) */ public function getProductCustomOptionsXmlObject(Mage_Catalog_Model_Product $product) { - $xmlModel = new Mage_XmlConnect_Model_Simplexml_Element(''); + $xmlModel = Mage::getModel('xmlconnect/simplexml_element', ''); $optionsNode = $xmlModel->addChild('options'); if (!$product->getId()) { diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Giftcard.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Giftcard.php index 1deaf29ac8..198a9f1dbf 100755 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Giftcard.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Giftcard.php @@ -167,7 +167,7 @@ public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObj */ if (count($amounts = $priceModel->getSortedAmounts($product))) { $amountNode = $optionsXmlObj->addChild('fixed_amounts'); - foreach ($amounts as $priceId => $price) { + foreach ($amounts as $price) { $amount = $amountNode->addChild('amount'); if ($configValue == $price) { $amount->addAttribute('selected', 1); diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Grouped.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Grouped.php index 021742ab7d..02e095ab99 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Grouped.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Grouped.php @@ -27,11 +27,10 @@ /** * Grouped product options xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Product_Options_Grouped extends Mage_XmlConnect_Block_Catalog_Product_Options { /** @@ -43,7 +42,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Options_Grouped extends Mage_XmlConn */ public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObject = false) { - $xmlModel = new Mage_XmlConnect_Model_Simplexml_Element(''); + $xmlModel = Mage::getModel('xmlconnect/simplexml_element', ''); $optionsNode = $xmlModel->addChild('options'); if (!$product->getId()) { diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price.php index af3c7ec22b..caa49b80e1 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price.php @@ -27,14 +27,12 @@ /** * Product Options xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Product_Price extends Mage_XmlConnect_Block_Catalog { - /** * Default product price renderer block factory name * diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Related.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Related.php index a1b6a18abc..c57fb3adef 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Related.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Related.php @@ -27,14 +27,12 @@ /** * Related products block * - * @category Mage - * @package Mage_XmlConnect + * @category Mage + * @package Mage_XmlConnect * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Product_Related extends Mage_XmlConnect_Block_Catalog_Product_List { - /** * Retrieve related products xml object based on current product * @@ -43,7 +41,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Related extends Mage_XmlConnect_Bloc */ public function getRelatedProductsXmlObj() { - $relatedXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $relatedXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); if ($this->getParentBlock()->getProduct()->getId() > 0) { $collection = $this->_getProductCollection(); if (!$collection) { diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review.php index 58f6dca3ed..58f067be56 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review.php @@ -27,11 +27,10 @@ /** * Review xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Product_Review extends Mage_XmlConnect_Block_Catalog { /** @@ -49,7 +48,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Review extends Mage_XmlConnect_Block public function reviewToXmlObject(Mage_Review_Model_Review $review, $itemNodeName = 'item') { $rating = 0; - $item = new Mage_XmlConnect_Model_Simplexml_Element('<' . $itemNodeName . '>'); + $item = Mage::getModel('xmlconnect/simplexml_element', '<' . $itemNodeName . '>'); if ($review->getId()) { $item->addChild('review_id', $review->getId()); $item->addChild('created_at', $this->formatDate($review->getCreatedAt())); diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review/List.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review/List.php index 47ce452d39..03fe02756a 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review/List.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Product/Review/List.php @@ -27,11 +27,10 @@ /** * Review block * - * @category Mage - * @package Mage_XmlConnect + * @category Mage + * @package Mage_XmlConnect * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Product_Review_List extends Mage_XmlConnect_Block_Catalog_Product_Review { /** @@ -48,7 +47,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Review_List extends Mage_XmlConnect_ */ public function getReviewsXmlObject() { - $reviewsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $reviewsXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $collection = $this->_getReviewCollection(); if (!$collection) { diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Search.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Search.php index 9dee661fe3..10442d6177 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Search.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Search.php @@ -27,11 +27,10 @@ /** * Product search results renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Search extends Mage_XmlConnect_Block_Catalog { /** @@ -43,13 +42,15 @@ class Mage_XmlConnect_Block_Catalog_Search extends Mage_XmlConnect_Block_Catalog */ protected function _toHtml() { - $searchXmlObject = new Mage_XmlConnect_Model_Simplexml_Element(''); - $filtersXmlObject = new Mage_XmlConnect_Model_Simplexml_Element(''); + $searchXmlObject = Mage::getModel('xmlconnect/simplexml_element', ''); + $filtersXmlObject = Mage::getModel('xmlconnect/simplexml_element', ''); $helper = Mage::helper('catalogsearch'); if (method_exists($helper, 'getEngine')) { $engine = Mage::helper('catalogsearch')->getEngine(); - $isLayeredNavigationAllowed = ($engine instanceof Varien_Object) ? $engine->isLeyeredNavigationAllowed() : true; + $isLayeredNavigationAllowed = ($engine instanceof Varien_Object) + ? $engine->isLeyeredNavigationAllowed() + : true; } else { $isLayeredNavigationAllowed = true; } diff --git a/app/code/core/Mage/XmlConnect/Block/Catalog/Search/Suggest.php b/app/code/core/Mage/XmlConnect/Block/Catalog/Search/Suggest.php index 0afb3ff789..b57cd4bc20 100644 --- a/app/code/core/Mage/XmlConnect/Block/Catalog/Search/Suggest.php +++ b/app/code/core/Mage/XmlConnect/Block/Catalog/Search/Suggest.php @@ -27,11 +27,10 @@ /** * Product search suggestions renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ - class Mage_XmlConnect_Block_Catalog_Search_Suggest extends Mage_CatalogSearch_Block_Autocomplete { const SUGGEST_ITEM_SEPARATOR = '::sep::'; @@ -43,10 +42,10 @@ class Mage_XmlConnect_Block_Catalog_Search_Suggest extends Mage_CatalogSearch_Bl */ protected function _toHtml() { - $suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $suggestXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); - if (!$this->getRequest()->getParam('q', false)) { - return $suggestXmlObj->asNiceXml(); + if (!$this->getRequest()->getParam(Mage_CatalogSearch_Helper_Data::QUERY_VAR_NAME, false)) { + return $suggestXmlObj->asNiceXml(); } $suggestData = $this->getSuggestData(); @@ -55,19 +54,15 @@ protected function _toHtml() } $items = ''; - foreach ($suggestData as $index => $item) { + foreach ($suggestData as $item) { $items .= $suggestXmlObj->xmlentities(strip_tags($item['title'])) - . self::SUGGEST_ITEM_SEPARATOR - . (int)$item['num_of_results'] - . self::SUGGEST_ITEM_SEPARATOR; -// $itemXmlObj = $suggestXmlObj->addChild('item'); -// $itemXmlObj->addChild('title', $suggestXmlObj->xmlentities(strip_tags($item['title']))); -// $itemXmlObj->addChild('count', (int)$item['num_of_results']); + . self::SUGGEST_ITEM_SEPARATOR + . (int)$item['num_of_results'] + . self::SUGGEST_ITEM_SEPARATOR; } - $suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('' . $items . ''); + $suggestXmlObj = Mage::getModel('xmlconnect/simplexml_element', '' . $items . ''); return $suggestXmlObj->asNiceXml(); } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Address/Billing.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Address/Billing.php index 1624c78cca..81b4c065bd 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Address/Billing.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Address/Billing.php @@ -27,10 +27,9 @@ /** * One page checkout billing addresses xml renderer * - * @category Mage - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Address_Billing extends Mage_Checkout_Block_Onepage_Billing { @@ -41,7 +40,7 @@ class Mage_XmlConnect_Block_Checkout_Address_Billing extends Mage_Checkout_Block */ protected function _toHtml() { - $billingXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $billingXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $addressId = $this->getAddress()->getId(); $address = $this->getCustomer()->getPrimaryBillingAddress(); diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Address/Shipping.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Address/Shipping.php index f843baa390..014a90d918 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Address/Shipping.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Address/Shipping.php @@ -27,10 +27,9 @@ /** * One page checkout shipping addresses xml renderer * - * @category Mage - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Address_Shipping extends Mage_Checkout_Block_Onepage_Shipping { @@ -41,7 +40,7 @@ class Mage_XmlConnect_Block_Checkout_Address_Shipping extends Mage_Checkout_Bloc */ protected function _toHtml() { - $shippingXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $shippingXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $addressId = $this->getAddress()->getId(); $address = $this->getCustomer()->getPrimaryShippingAddress(); diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Agreements.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Agreements.php index 433fdcdca6..ae42a039b9 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Agreements.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Agreements.php @@ -27,9 +27,9 @@ /** * One page checkout agreements xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Agreements extends Mage_Checkout_Block_Agreements { @@ -40,7 +40,7 @@ class Mage_XmlConnect_Block_Checkout_Agreements extends Mage_Checkout_Block_Agre */ protected function _toHtml() { - $agreementsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $agreementsXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); if ($this->getAgreements()) { foreach ($this->getAgreements() as $agreement) { $itemXmlObj = $agreementsXmlObj->addChild('item'); @@ -58,5 +58,4 @@ protected function _toHtml() return $agreementsXmlObj->asNiceXml(); } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review.php index e3870290bb..edf07c3e5f 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review.php @@ -27,10 +27,9 @@ /** * One page checkout order review xml renderer * - * @category Mage - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Order_Review extends Mage_Checkout_Block_Onepage_Review { @@ -41,14 +40,14 @@ class Mage_XmlConnect_Block_Checkout_Order_Review extends Mage_Checkout_Block_On */ protected function _toHtml() { - $orderXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $orderXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); /** * Order items */ $products = $this->getChildHtml('order_products'); if ($products) { - $productsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($products); + $productsXmlObj = Mage::getModel('xmlconnect/simplexml_element', $products); $orderXmlObj->appendChild($productsXmlObj); } @@ -57,7 +56,7 @@ protected function _toHtml() */ $totalsXml = $this->getChildHtml('totals'); if ($totalsXml) { - $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($totalsXml); + $totalsXmlObj = Mage::getModel('xmlconnect/simplexml_element', $totalsXml); $orderXmlObj->appendChild($totalsXmlObj); } @@ -66,11 +65,10 @@ protected function _toHtml() */ $agreements = $this->getChildHtml('agreements'); if ($agreements) { - $agreementsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($agreements); + $agreementsXmlObj = Mage::getModel('xmlconnect/simplexml_element', $agreements); $orderXmlObj->appendChild($agreementsXmlObj); } return $orderXmlObj->asNiceXml(); } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review/Info.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review/Info.php index 8d105d42fe..543718ecd6 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review/Info.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review/Info.php @@ -27,10 +27,9 @@ /** * One page checkout order info xml renderer * - * @category Mage - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Order_Review_Info extends Mage_Checkout_Block_Onepage_Review_Info { @@ -41,7 +40,7 @@ class Mage_XmlConnect_Block_Checkout_Order_Review_Info extends Mage_Checkout_Blo */ protected function _toHtml() { - $itemsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $itemsXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $quote = Mage::getSingleton('checkout/session')->getQuote(); /* @var $item Mage_Sales_Model_Quote_Item */ @@ -118,7 +117,6 @@ protected function _toHtml() } } - /** * Subtotal */ @@ -192,5 +190,4 @@ protected function _toHtml() return $itemsXmlObj->asNiceXml(); } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Authorizenet.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Authorizenet.php index 7543f57081..01684092f3 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Authorizenet.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Authorizenet.php @@ -27,9 +27,9 @@ /** * Credit Card (Authorize.net) Payment method xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Payment_Method_Authorizenet extends Mage_Payment_Block_Form_Ccsave { @@ -91,35 +91,38 @@ public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $ - '; + '; } + $cvnValidationText = $this->__('Credit card number does not match credit card type.'); + $expMonthText = $this->__('Expiration Date - Month'); + $expYearText = $this->__('Expiration Date - Year'); $xml = << - $ccTypes + {$ccTypes} - + - + - $ccMonths + {$ccMonths} - + - $ccYears + {$ccYears} - $verification + {$verification} EOT; - $fieldsetXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($xml); + $fieldsetXmlObj = Mage::getModel('xmlconnect/simplexml_element', $xml); $formXmlObj->appendChild($fieldsetXmlObj); } } diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Ccsave.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Ccsave.php index 42963b123c..3b2c1da1f7 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Ccsave.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Ccsave.php @@ -27,9 +27,9 @@ /** * CC Save Payment method xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Payment_Method_Ccsave extends Mage_Payment_Block_Form_Ccsave { @@ -135,7 +135,7 @@ public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $ $verification EOT; - $fieldsetXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($xml); + $fieldsetXmlObj = Mage::getModel('xmlconnect/simplexml_element', $xml); $formXmlObj->appendChild($fieldsetXmlObj); } } diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Authorizenet.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Authorizenet.php new file mode 100755 index 0000000000..993d574675 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Authorizenet.php @@ -0,0 +1,75 @@ + + */ +class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Authorizenet + extends Mage_Paygate_Block_Authorizenet_Info_Cc +{ + /** + * Add Authorizenet info to order XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj + * @return Mage_XmlConnect_Model_Simplexml_Element + */ + public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) + { + $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode()); + if (!$this->getHideTitle()) { + $orderItemXmlObj->addAttribute( + 'title', + $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()) + ); + } + + $cards = $this->getCards(); + $showCount = count($cards) > 1; + + foreach ($cards as $key => $card) { + $creditCard = $orderItemXmlObj->addCustomChild( + 'item', + null, + array( + 'label' => $showCount ? $this->__('Credit Card %s', $key + 1) : $this->__('Credit Card') + ) + ); + foreach ($card as $label => $value) { + $creditCard->addCustomChild( + 'item', + implode($this->getValueAsArray($value, true), PHP_EOL), + array( + 'label' => $label + ) + ); + } + } + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Ccsave.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Ccsave.php new file mode 100755 index 0000000000..e8264a56a6 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Ccsave.php @@ -0,0 +1,62 @@ + + */ +class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Ccsave extends Mage_Payment_Block_Info_Ccsave +{ + /** + * Add CC Save Payment info to order XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj + * @return Mage_XmlConnect_Model_Simplexml_Element + */ + public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) + { + $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode()); + $orderItemXmlObj->addAttribute( + 'title', + $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()) + ); + + if ($_specificInfo = $this->getSpecificInformation()) { + foreach ($_specificInfo as $label => $value) { + $orderItemXmlObj->addCustomChild( + 'item', + implode($this->getValueAsArray($value, true), PHP_EOL), + array( + 'label' => $label + ) + ); + } + } + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Checkmo.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Checkmo.php new file mode 100755 index 0000000000..c7984ea6df --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Checkmo.php @@ -0,0 +1,71 @@ + + */ +class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Checkmo extends Mage_Payment_Block_Info_Checkmo +{ + /** + * Add Check / Money order info to order XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj + * @return Mage_XmlConnect_Model_Simplexml_Element + */ + public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) + { + $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode()); + $orderItemXmlObj->addAttribute( + 'title', + $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()) + ); + + if ($this->getInfo()->getAdditionalData()) { + if ($this->getPayableTo()) { + $orderItemXmlObj->addCustomChild( + 'item', + $this->getPayableTo(), + array( + 'label' => Mage::helper('sales')->__('Make Check payable to:') + ) + ); + } + if ($this->getMailingAddress()) { + $orderItemXmlObj->addCustomChild( + 'item', + $this->getMailingAddress(), + array( + 'label' => Mage::helper('payment')->__('Send Check to:') + ) + ); + } + } + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Purchaseorder.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Purchaseorder.php new file mode 100755 index 0000000000..f2b9c038cb --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Purchaseorder.php @@ -0,0 +1,58 @@ + + */ +class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Purchaseorder extends Mage_Payment_Block_Info_Purchaseorder +{ + /** + * Add Purchase Order Payment info to order XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj + * @return Mage_XmlConnect_Model_Simplexml_Element + */ + public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) + { + $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode()); + $orderItemXmlObj->addAttribute( + 'title', + $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()) + ); + + $orderItemXmlObj->addCustomChild( + 'item', + $this->getInfo()->getPoNumber(), + array( + 'label' => Mage::helper('sales')->__('Purchase Order Number:') + ) + ); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/List.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/List.php index 32bf19c8a8..ffda4976be 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/List.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/List.php @@ -27,15 +27,14 @@ /** * One page checkout payment methods xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Payment_Method_List extends Mage_Payment_Block_Form_Container { - /** - * Prevent parent set childs + * Prevent parent set children * * @return Mage_XmlConnect_Block_Checkout_Payment_Method_List */ @@ -62,7 +61,8 @@ public function getQuote() */ protected function _toHtml() { - $methodsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $methodsXmlObj Mage_XmlConnect_Model_Simplexml_Element */ + $methodsXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); /** * Pre-defined array of methods that we are going to render @@ -185,7 +185,7 @@ protected function _toHtml() $methodItemXmlObj = $methodsXmlObj->addChild('method'); $methodItemXmlObj->addAttribute('post_name', 'payment[method]'); $methodItemXmlObj->addAttribute('code', $method->getCode()); - $methodItemXmlObj->addAttribute('label', $methodsXmlObj->xmlentities(strip_tags($method->getTitle()))); + $methodItemXmlObj->addAttribute('label', $methodsXmlObj->xmlentities($method->getTitle())); if ($this->getQuote()->getPayment()->getMethod() == $method->getCode()) { $methodItemXmlObj->addAttribute('selected', 1); } diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Paypal/Payflow.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Paypal/Payflow.php index 140ec5f327..4a53a76491 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Paypal/Payflow.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Paypal/Payflow.php @@ -27,9 +27,9 @@ /** * Credit Card (Payflow Pro) Payment method xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Payment_Method_Paypal_Payflow extends Mage_Payment_Block_Form_Ccsave { @@ -152,7 +152,7 @@ public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $ $verification EOT; - $fieldsetXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($xml); + $fieldsetXmlObj = Mage::getModel('xmlconnect/simplexml_element', $xml); $formXmlObj->appendChild($fieldsetXmlObj); } } diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Pbridge/Abstract.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Pbridge/Abstract.php index 5181f6c0fb..2f52acfd17 100755 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Pbridge/Abstract.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Pbridge/Abstract.php @@ -27,9 +27,9 @@ /** * Abstract Pbridge Payment method xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ abstract class Mage_XmlConnect_Block_Checkout_Payment_Method_Pbridge_Abstract extends Enterprise_Pbridge_Block_Payment_Form_Abstract @@ -72,11 +72,16 @@ public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $ return $paymentItemXmlObj; } + /** + * Create html page with iframe for devices + * + * @return string html + */ protected function createIframe() { $code = $this->getMethodCode(); $body = << +
{$this->getIframeBlock()->toHtml()}
EOT; diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Purchaseorder.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Purchaseorder.php index cbc2b84c2b..7ceb780d7a 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Purchaseorder.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Purchaseorder.php @@ -27,9 +27,9 @@ /** * Check / Money order Payment method xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Checkout_Payment_Method_Purchaseorder extends Mage_Payment_Block_Form_Purchaseorder { @@ -82,7 +82,7 @@ public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $ EOT; - $fieldsetXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($xml); + $fieldsetXmlObj = Mage::getModel('xmlconnect/simplexml_element', $xml); $formXmlObj->appendChild($fieldsetXmlObj); return $paymentItemXmlObj; diff --git a/app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Avaliable.php b/app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Available.php similarity index 61% rename from app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Avaliable.php rename to app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Available.php index 9b019bc173..1ed6166a72 100644 --- a/app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Avaliable.php +++ b/app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Available.php @@ -31,7 +31,8 @@ * @package Mage_XmlConnect * @author Magento Core Team */ -class Mage_XmlConnect_Block_Checkout_Shipping_Method_Avaliable extends Mage_Checkout_Block_Onepage_Shipping_Method_Available +class Mage_XmlConnect_Block_Checkout_Shipping_Method_Available + extends Mage_Checkout_Block_Onepage_Shipping_Method_Available { /** * Render shipping methods xml @@ -40,33 +41,51 @@ class Mage_XmlConnect_Block_Checkout_Shipping_Method_Avaliable extends Mage_Chec */ protected function _toHtml() { - $methodsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $methodsXmlObj Mage_XmlConnect_Model_Simplexml_Element */ + $methodsXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $_shippingRateGroups = $this->getShippingRates(); if ($_shippingRateGroups) { $store = $this->getQuote()->getStore(); $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates) { $methodXmlObj = $methodsXmlObj->addChild('method'); - $methodXmlObj->addAttribute('label', $methodsXmlObj->xmlentities(strip_tags($this->getCarrierName($code)))); + $methodXmlObj->addAttribute( + 'label', + $methodsXmlObj->xmlentities($this->getCarrierName($code)) + ); $ratesXmlObj = $methodXmlObj->addChild('rates'); $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate) { $rateXmlObj = $ratesXmlObj->addChild('rate'); - $rateXmlObj->addAttribute('label', $methodsXmlObj->xmlentities(strip_tags($_rate->getMethodTitle()))); + $rateXmlObj->addAttribute( + 'label', + $methodsXmlObj->xmlentities($_rate->getMethodTitle()) + ); $rateXmlObj->addAttribute('code', $_rate->getCode()); if ($_rate->getErrorMessage()) { - $rateXmlObj->addChild('error_message', $methodsXmlObj->xmlentities(strip_tags($_rate->getErrorMessage()))); + $rateXmlObj->addChild( + 'error_message', + $methodsXmlObj->xmlentities($_rate->getErrorMessage())); } else { - $price = Mage::helper('tax')->getShippingPrice($_rate->getPrice(), Mage::helper('tax')->displayShippingPriceIncludingTax(), $this->getAddress()); + $price = Mage::helper('tax')->getShippingPrice( + $_rate->getPrice(), + Mage::helper('tax')->displayShippingPriceIncludingTax(), + $this->getAddress() + ); $formattedPrice = $store->convertPrice($price, true, false); - $rateXmlObj->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml($store->convertPrice($price, false, false))); + $rateXmlObj->addAttribute( + 'price', + Mage::helper('xmlconnect')->formatPriceForXml( + $store->convertPrice($price, false, false) + ) + ); $rateXmlObj->addAttribute('formated_price', $formattedPrice); } } } } else { - Mage::throwException($this->__('Sorry, no quotes are available for this order at this time.')); + Mage::throwException($this->__('Shipping to this address is not possible.')); } return $methodsXmlObj->asNiceXml(); } diff --git a/app/code/core/Mage/XmlConnect/Block/Configuration.php b/app/code/core/Mage/XmlConnect/Block/Configuration.php index 4000eb2cbe..cc73ace607 100644 --- a/app/code/core/Mage/XmlConnect/Block/Configuration.php +++ b/app/code/core/Mage/XmlConnect/Block/Configuration.php @@ -27,9 +27,9 @@ /** * Application configuration renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Configuration extends Mage_Core_Block_Template @@ -113,7 +113,7 @@ protected function _buildRecursive($section, $subtree) */ protected function _toHtml() { - $xml = new Mage_XmlConnect_Model_Simplexml_Element(''); + $xml = Mage::getModel('xmlconnect/simplexml_element', ''); $this->_buildRecursive($xml, Mage::helper('xmlconnect')->excludeXmlConfigKeys($this->_app->getRenderConf())); return $xml->asNiceXml(); } diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Address/Form.php b/app/code/core/Mage/XmlConnect/Block/Customer/Address/Form.php index 9bdd28cd50..f204de994d 100644 --- a/app/code/core/Mage/XmlConnect/Block/Customer/Address/Form.php +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Address/Form.php @@ -27,9 +27,9 @@ /** * Customer address form xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Core_Block_Template { @@ -41,7 +41,7 @@ class Mage_XmlConnect_Block_Customer_Address_Form extends Mage_Core_Block_Templa protected function _toHtml() { $address = $this->getAddress(); - $xmlModel = new Mage_XmlConnect_Model_Simplexml_Element(''); + $xmlModel = Mage::getModel('xmlconnect/simplexml_element', ''); /** * Init address object and save its data to variables @@ -85,17 +85,19 @@ protected function _toHtml() if ($data['value']) { $regions = $this->_getRegionOptions($data['value']); } + $region = is_array($regions) && !empty($regions) ? 'region_id' : 'region'; $countryOptionsXml .= ' - + ' . $xmlModel->xmlentities($data['value']) . ''; if (is_array($regions) && !empty($regions)) { $countryOptionsXml .= ''; - foreach ($regions as $_key => $_data) { - $countryOptionsXml .= ''; + foreach ($regions as $_key => $regionData) { + $region = $regionId == $regionData['value'] ? ' selected="1"' : ''; + $countryOptionsXml .= ''; $countryOptionsXml .= - ' - ' . $xmlModel->xmlentities($_data['value']) . ''; + ' + ' . $xmlModel->xmlentities($regionData['value']) . ''; $countryOptionsXml .= ''; } $countryOptionsXml .= ''; @@ -121,7 +123,7 @@ protected function _toHtml() $countryOptionsXml - + diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Address/List.php b/app/code/core/Mage/XmlConnect/Block/Customer/Address/List.php index 45dd51c49d..aeb1e423f3 100644 --- a/app/code/core/Mage/XmlConnect/Block/Customer/Address/List.php +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Address/List.php @@ -27,9 +27,9 @@ /** * Customer address book xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Customer_Address_List extends Mage_Core_Block_Template { @@ -40,7 +40,7 @@ class Mage_XmlConnect_Block_Customer_Address_List extends Mage_Core_Block_Templa */ protected function _toHtml() { - $addressXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('
'); + $addressXmlObj = Mage::getModel('xmlconnect/simplexml_element', '
'); $customer = Mage::getSingleton('customer/session')->getCustomer(); $_billingAddssesId = $customer->getDefaultBilling(); @@ -81,7 +81,10 @@ protected function _toHtml() * @param Mage_XmlConnect_Model_Simplexml_Element $item * @return array */ - public function prepareAddressData(Mage_Customer_Model_Address $address, Mage_XmlConnect_Model_Simplexml_Element $item) + public function prepareAddressData( + Mage_Customer_Model_Address $address, + Mage_XmlConnect_Model_Simplexml_Element $item + ) { if (!$address) { return array(); diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Form.php b/app/code/core/Mage/XmlConnect/Block/Customer/Form.php index c828121523..b82d43db08 100644 --- a/app/code/core/Mage/XmlConnect/Block/Customer/Form.php +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Form.php @@ -27,9 +27,9 @@ /** * Customer form xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Customer_Form extends Mage_Core_Block_Template { @@ -42,7 +42,7 @@ protected function _toHtml() { $editFlag = (int)$this->getRequest()->getParam('edit'); $customer = $this->getCustomer(); - $xmlModel = new Mage_XmlConnect_Model_Simplexml_Element(''); + $xmlModel = Mage::getModel('xmlconnect/simplexml_element', ''); if ($editFlag == 1 && $customer && $customer->getId()) { $firstname = $xmlModel->xmlentities(strip_tags($customer->getFirstname())); @@ -92,5 +92,4 @@ protected function _toHtml() return $xml; } - } diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Details.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Details.php new file mode 100755 index 0000000000..51f73a472c --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Details.php @@ -0,0 +1,155 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Details extends Mage_Payment_Block_Info +{ + /** + * Render customer orders list xml + * + * @return string + */ + protected function _toHtml() + { + /** @var $orderXmlObj Mage_XmlConnect_Model_Simplexml_Element */ + $orderXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); + /** @var $order Mage_Sales_Model_Order */ + $order = Mage::registry('current_order'); + if (!($order instanceof Mage_Sales_Model_Order)) { + Mage::throwException($this->__('Model of order is not loaded.')); + } + $orderDate = $this->formatDate($order->getCreatedAtStoreDate(), 'long'); + $orderXmlObj->addCustomChild( + 'order', + null, + array( + 'label' => Mage::helper('sales')->__('Order #%s - %s', $order->getRealOrderId(), $order->getStatusLabel()), + 'order_date' => Mage::helper('sales')->__('Order Date: %s', $orderDate) + ) + ); + if (!$order->getIsVirtual()) { + $shipping = preg_replace( + array('@\r@', '@\n+@'), + array('', "\n"), + $order->getShippingAddress()->format('text') + ); + $billing = preg_replace( + array('@\r@', '@\n+@'), + array('', "\n"), + $order->getBillingAddress()->format('text') + ); + $orderXmlObj->addCustomChild('shipping_address', $shipping); + $orderXmlObj->addCustomChild('billing_address', $billing); + + if ($order->getShippingDescription()) { + $shippingMethodDescription = $order->getShippingDescription(); + } else { + $shippingMethodDescription = Mage::helper('sales')->__('No shipping information available'); + } + $orderXmlObj->addCustomChild('shipping_method', $shippingMethodDescription); + } + /** + * Pre-defined array of methods that we are going to render + */ + $methodArray = array( + 'ccsave' => 'Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Ccsave', + 'checkmo' => 'Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Checkmo', + 'purchaseorder' => 'Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Purchaseorder', + 'authorizenet' => 'Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Authorizenet', + ); + // TODO: create info blocks for Payment Bridge methods +// /** +// * Check if the Payment Bridge module is available and add methods for rendering +// */ +// if (is_object(Mage::getConfig()->getNode('modules/Enterprise_Pbridge'))) { +// $pbridgeMethodArray = array( +// 'pbridge_authorizenet' => 'Enterprise_Pbridge_Model_Payment_Method_Authorizenet', +// 'pbridge_paypal' => 'Enterprise_Pbridge_Model_Payment_Method_Paypal', +// 'pbridge_verisign' => 'Enterprise_Pbridge_Model_Payment_Method_Payflow_Pro', +// 'pbridge_paypaluk' => 'Enterprise_Pbridge_Model_Payment_Method_Paypaluk', +// ); +// $methodArray = $methodArray + $pbridgeMethodArray; +// } + + // TODO: it's need to create an info blocks for other payment methods (including Enterprise) + + $method = $this->helper('payment')->getInfoBlock($order->getPayment())->getMethod(); + $methodCode = $method->getCode(); + + $paymentNode = $orderXmlObj->addChild('payment_method'); + if (array_key_exists($methodCode, $methodArray)) { + $currentBlockRenderer = 'xmlconnect/checkout_payment_method_info_' . $methodCode; + $currentBlockName = 'xmlconnect.checkout.payment.method.info.' . $methodCode; + $this->getLayout()->addBlock($currentBlockRenderer, $currentBlockName); + $this->setChild($methodCode, $currentBlockName); + $renderer = $this->getChild($methodCode)->setInfo($order->getPayment()); + $renderer->addPaymentInfoToXmlObj($paymentNode); + } else { + $paymentNode->addAttribute('type', $methodCode); + $paymentNode->addAttribute('title', $orderXmlObj->xmlAttribute($method->getTitle())); + + $this->setInfo($order->getPayment()); + + $specificInfo = array_merge( + (array)$order->getPayment()->getAdditionalInformation(), + (array)$this->getSpecificInformation() + ); + if (!empty($specificInfo)) { + foreach ($specificInfo as $label => $value) { + if ($value) { + $paymentNode->addCustomChild( + 'item', + implode($this->getValueAsArray($value, true), PHP_EOL), + array('label' => $label) + ); + } + } + } + } + + $itemsBlock = $this->getLayout()->getBlock('xmlconnect.customer.order.items'); + if ($itemsBlock) { + /** @var $itemsBlock Mage_XmlConnect_Block_Customer_Order_Items */ + $itemsBlock->setItems($order->getItemsCollection()); + $itemsBlock->addItemsToXmlObject($orderXmlObj); + $totalsBlock = $this->getLayout()->getBlock('xmlconnect.customer.order.totals'); + if ($totalsBlock) { + $totalsBlock->setOrder($order); + $totalsBlock->addTotalsToXmlObject($orderXmlObj); + } + } else { + $orderXmlObj->addChild('ordered_items'); + } + + return $orderXmlObj->asNiceXml(); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Bundle.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Bundle.php new file mode 100644 index 0000000000..d5b500f052 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Bundle.php @@ -0,0 +1,468 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Bundle + extends Mage_Bundle_Block_Sales_Order_Items_Renderer +{ + /** + * Add item to XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj + * @return void + */ + public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) + { + /** @var $parentItem Mage_Sales_Model_Order_Item */ + $parentItem = $this->getItem(); + + $items = array_merge(array($parentItem), $parentItem->getChildrenItems()); + $_prevOptionId = ''; + + /** @var $weeeHelper Mage_Weee_Helper_Data */ + $weeeHelper = $this->helper('weee'); + /** @var $taxHelper Mage_Tax_Helper_Data */ + $taxHelper = $this->helper('tax'); + + /** @var $itemXml Mage_XmlConnect_Model_Simplexml_Element */ + $itemXml = $orderItemXmlObj->addChild('item'); + /** @var $optionsXml Mage_XmlConnect_Model_Simplexml_Element */ + $optionsXml = $itemXml->addChild('related_products'); + + $weeeTaxAppliedAmount = (float)$parentItem->getWeeeTaxAppliedAmount(); + $weeeTaxDisposition = (float)$parentItem->getWeeeTaxDisposition(); + $typeOfDisplay1 = $weeeHelper->typeOfDisplay($parentItem, 1, 'sales') + && $weeeTaxAppliedAmount; + $typeOfDisplay2 = $weeeHelper->typeOfDisplay($parentItem, 2, 'sales') + && $weeeTaxAppliedAmount; + $typeOfDisplay4 = $weeeHelper->typeOfDisplay($parentItem, 4, 'sales') + && $weeeTaxAppliedAmount; + $typeOfDisplay014 = $weeeHelper->typeOfDisplay($parentItem, array(0, 1, 4), 'sales') + && $weeeTaxAppliedAmount; + $weeeTaxes = $weeeHelper->getApplied($parentItem); + + /** @var $_item Mage_Sales_Model_Order_Item */ + foreach ($items as $_item) { + $isOption = $_item->getParentItem() ? true : false; + + /** @var $objectXml Mage_XmlConnect_Model_Simplexml_Element */ + if ($isOption) { + $objectXml = $optionsXml->addChild('item'); + } else { + $objectXml = $itemXml; + } + $objectXml->addAttribute('product_id', $_item->getProductId()); + $objectXml->addCustomChild('entity_type', $_item->getProductType()); + + if ($isOption) { + $attributes = $this->getSelectionAttributes($_item); + if ($_prevOptionId != $attributes['option_id']) { + $objectXml->addAttribute('label', $objectXml->xmlAttribute($attributes['option_label'])); + $_prevOptionId = $attributes['option_id']; + } + } + + $objectXml->addCustomChild('sku', Mage::helper('core/string')->splitInjection($_item->getSku())); + + if ($isOption) { + $name = $this->getValueHtml($_item); + } else { + $name = $_item->getName(); + } + $objectXml->addCustomChild('name', $name); + + // set prices exactly for the Bundle product, but not for related products + if (!$isOption) { + /** @var $priceXml Mage_XmlConnect_Model_Simplexml_Element */ + $priceXml = $objectXml->addChild('price'); + + // Price excluding tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) { + + if ($typeOfDisplay014) { + $price = $parentItem->getPrice() + $weeeTaxAppliedAmount + $weeeTaxDisposition; + } else { + $price = $parentItem->getPrice(); + } + + $config = array( + 'value' => $this->_formatPrice($price) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Excl. Tax'); + } + $exclPriceXml = $priceXml->addCustomChild( + 'excluding_tax', + null, + $config + ); + + // TODO: move repeated code into another place + if ($weeeTaxes) { + /** @var $weeeXml Mage_XmlConnect_Model_Simplexml_Element */ + if ($typeOfDisplay1) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount']), + array('label' => $tax['title']) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount_incl_tax']), + array('label' => $tax['title']) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $exclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice( + $parentItem->getPrice() + $weeeTaxAppliedAmount + $weeeTaxDisposition + ), + array('label' => $weeeHelper->__('Total')) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + + // Price including tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) { + $incl = $this->helper('checkout')->getPriceInclTax($parentItem); + + if ($typeOfDisplay014) { + $price = $incl + $weeeTaxAppliedAmount; + } else { + $price = $incl - $weeeTaxDisposition; + } + + $config = array( + 'value' => $this->_formatPrice($price) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Incl. Tax'); + } + + $inclPriceXml = $priceXml->addCustomChild( + 'including_tax', + null, + $config + ); + + if ($weeeTaxes) { + if ($typeOfDisplay1) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount']), + array('label' => $tax['title']) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount_incl_tax']), + array('label' => $tax['title']) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $inclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice( + $incl + $weeeTaxAppliedAmount + ), + array('label' => $weeeHelper->__('Total incl. tax')) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + } + + // set quantities + /** @var $qtyXml Mage_XmlConnect_Model_Simplexml_Element */ + if (($isOption && $this->isChildCalculated()) + || (!$isOption && !$this->isChildCalculated()) + ) { + $qtyXml = $objectXml->addChild('qty'); + if ($_item->getQtyOrdered() > 0) { + $qtyXml->addCustomChild( + 'value', + $_item->getQtyOrdered() * 1, + array('label' => Mage::helper('sales')->__('Ordered')) + ); + } + if ($_item->getQtyShipped() > 0 && !$this->isShipmentSeparately()) { + $qtyXml->addCustomChild( + 'value', + $_item->getQtyShipped() * 1, + array('label' => Mage::helper('sales')->__('Shipped')) + ); + } + if ($_item->getQtyCanceled() > 0) { + $qtyXml->addCustomChild( + 'value', + $_item->getQtyCanceled() * 1, + array('label' => Mage::helper('sales')->__('Canceled')) + ); + } + if ($_item->getQtyRefunded() > 0) { + $qtyXml->addCustomChild( + 'value', + $_item->getQtyRefunded() * 1, + array('label' => Mage::helper('sales')->__('Refunded')) + ); + } + } elseif ($_item->getQtyShipped() > 0 && $isOption && $this->isShipmentSeparately()) { + $qtyXml = $objectXml->addChild('qty'); + $qtyXml->addCustomChild( + 'value', + $_item->getQtyShipped() * 1, + array('label' => Mage::helper('sales')->__('Shipped')) + ); + } + + // set subtotals exactly for the Bundle product, but not for related products + if (!$isOption) { + /** @var $subtotalXml Mage_XmlConnect_Model_Simplexml_Element */ + $subtotalXml = $objectXml->addChild('subtotal'); + + // Subtotal excluding tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) { + if ($typeOfDisplay014) { + $subtotal = $parentItem->getRowTotal() + + $parentItem->getWeeeTaxAppliedRowAmount() + + $parentItem->getWeeeTaxRowDisposition(); + } else { + $subtotal = $parentItem->getRowTotal(); + } + + $config = array( + 'value' => $this->_formatPrice($subtotal) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Excl. Tax'); + } + $exclPriceXml = $subtotalXml->addCustomChild( + 'excluding_tax', + null, + $config + ); + + if ($weeeTaxes) { + /** @var $weeeXml Mage_XmlConnect_Model_Simplexml_Element */ + if ($typeOfDisplay1) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount']), + array('label' => $tax['title']) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount_incl_tax']), + array('label' => $tax['title']) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $exclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice( + $parentItem->getRowTotal() + + $parentItem->getWeeeTaxAppliedRowAmount() + + $parentItem->getWeeeTaxRowDisposition() + ), + array('label' => $weeeHelper->__('Total')) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + + // Subtotal including tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) { + $incl = $this->helper('checkout')->getSubtotalInclTax($parentItem); + + if ($typeOfDisplay014) { + $subtotal = $incl + $parentItem->getWeeeTaxAppliedRowAmount(); + } else { + $subtotal = $incl - $parentItem->getWeeeTaxRowDisposition(); + } + + $config = array( + 'value' => $this->_formatPrice($subtotal) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Incl. Tax'); + } + + $inclPriceXml = $subtotalXml->addCustomChild( + 'including_tax', + null, + $config + ); + + if ($weeeTaxes) { + if ($typeOfDisplay1) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount']), + array('label' => $tax['title']) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount_incl_tax']), + array('label' => $tax['title']) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $inclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice( + $incl + $parentItem->getWeeeTaxAppliedRowAmount() + ), + array('label' => $weeeHelper->__('Total incl. tax')) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + } + } + + if ($parentItem->getDescription()) { + $itemXml->addCustomChild( + 'description', + $parentItem->getDescription() + ); + } + + if ($options = $this->getItemOptions()) { + /** @var $optionsXml Mage_XmlConnect_Model_Simplexml_Element */ + $optionsXml = $itemXml->addChild('options'); + foreach ($options as $option) { + $formatedOptionValue = $this->getFormatedOptionValue($option); + if (isset($formatedOptionValue['full_view']) && isset($formatedOptionValue['value'])) { + $value = $formatedOptionValue['value']; + } elseif (isset($option['print_value'])) { + $value = $option['print_value']; + } else { + $value = $option['value']; + } + + if ($value) { + $optionsXml->addCustomChild( + 'option', + strip_tags($value), + array('label' => $option['label']) + ); + } + } + } + } + + /** + * Prepare option data for output + * + * @param Mage_Sales_Model_Order_Item $item + * @return string + */ + public function getValueHtml($item) + { + $attributes = $this->getSelectionAttributes($item); + if ($attributes) { + return sprintf('%d', $attributes['qty']) . ' x ' + . $item->getName() + . ' - ' . $this->_formatPrice($attributes['price']); + } else { + return $item->getName(); + } + } + + /** + * Format price using order currency + * + * @param float $price + * @return string + */ + protected function _formatPrice($price) + { + return $this->getOrder()->getOrderCurrency()->formatPrecision($price, 2, array(), false); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Default.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Default.php new file mode 100644 index 0000000000..7b7a692407 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Default.php @@ -0,0 +1,406 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Default + extends Mage_Sales_Block_Order_Item_Renderer_Default +{ + /** + * Add item to XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj + * @return void + */ + public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) + { + /** @var $item Mage_Sales_Model_Order_Item */ + $item = $this->getItem(); + + /** @var $itemXml Mage_XmlConnect_Model_Simplexml_Element */ + $itemXml = $orderItemXmlObj->addCustomChild( + 'item', + null, + array( + 'product_id' => $item->getProductId() + ) + ); + $itemXml->addCustomChild('name', $item->getName()); + + /** @var $weeeHelper Mage_Weee_Helper_Data */ + $weeeHelper = $this->helper('weee'); + /** @var $taxHelper Mage_Tax_Helper_Data */ + $taxHelper = $this->helper('tax'); + + $options = $this->getItemOptions(); + if ($options) { + /** @var $optionsXml Mage_XmlConnect_Model_Simplexml_Element */ + $optionsXml = $itemXml->addChild('options'); + foreach ($options as $option) { + $value = false; + $formatedOptionValue = $this->getFormatedOptionValue($option); + if (isset($formatedOptionValue['full_view']) && isset($formatedOptionValue['value'])) { + $value = $formatedOptionValue['value']; + } elseif (isset($option['print_value'])) { + $value = $option['print_value']; + } elseif (isset($option['value'])) { + $value = $option['value']; + } + if ($value) { + $optionsXml->addCustomChild( + 'option', + strip_tags($value), + array('label' => $option['label']) + ); + } + } + + $addtInfoBlock = $this->getProductAdditionalInformationBlock(); + if ($addtInfoBlock) { + // TODO: find how to set additional info block + // $addtInfoBlock->setItem($item)->toHtml(); + } + } + + $itemXml->addCustomChild('entity_type', $item->getProductType()); + $itemXml->addCustomChild('description', $item->getDescription()); + $itemXml->addCustomChild('sku', Mage::helper('core/string')->splitInjection($this->getSku())); + + /** @var $priceXml Mage_XmlConnect_Model_Simplexml_Element */ + $priceXml = $itemXml->addChild('price'); + $weeeTaxAppliedAmount = (float)$item->getWeeeTaxAppliedAmount(); + $weeeTaxDisposition = (float)$item->getWeeeTaxDisposition(); + $typeOfDisplay1 = $weeeHelper->typeOfDisplay($item, 1, 'sales') && $weeeTaxAppliedAmount; + $typeOfDisplay2 = $weeeHelper->typeOfDisplay($item, 2, 'sales') && $weeeTaxAppliedAmount; + $typeOfDisplay4 = $weeeHelper->typeOfDisplay($item, 4, 'sales') && $weeeTaxAppliedAmount; + $typeOfDisplay014 = $weeeHelper->typeOfDisplay($item, array(0, 1, 4), 'sales') && $weeeTaxAppliedAmount; + $weeeTaxes = $weeeHelper->getApplied($item); + + // Price excluding tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) { + if ($typeOfDisplay014) { + $price = $item->getPrice() + $weeeTaxAppliedAmount + $weeeTaxDisposition; + } else { + $price = $item->getPrice(); + } + + $config = array( + 'value' => $this->_formatPrice($price) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Excl. Tax'); + } + + /** @var $exclPriceXml Mage_XmlConnect_Model_Simplexml_Element */ + $exclPriceXml = $priceXml->addCustomChild( + 'excluding_tax', + null, + $config + ); + + // TODO: move repeated code into another place + if ($weeeTaxes) { + /** @var $weeeXml Mage_XmlConnect_Model_Simplexml_Element */ + if ($typeOfDisplay1) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount']), + array('label' => $tax['title']) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount_incl_tax']), + array('label' => $tax['title']) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $exclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice( + $item->getPrice() + $weeeTaxAppliedAmount + $weeeTaxDisposition + ), + array('label' => $weeeHelper->__('Total')) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + + // Price including tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) { + $incl = $this->helper('checkout')->getPriceInclTax($item); + + if ($typeOfDisplay014) { + $price = $incl + $weeeTaxAppliedAmount; + } else { + $price = $incl - $weeeTaxDisposition; + } + + $config = array( + 'value' => $this->_formatPrice($price) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Incl. Tax'); + } + + /** @var $inclPriceXml Mage_XmlConnect_Model_Simplexml_Element */ + $inclPriceXml = $priceXml->addCustomChild( + 'including_tax', + null, + $config + ); + + if ($weeeTaxes) { + /** @var $weeeXml Mage_XmlConnect_Model_Simplexml_Element */ + if ($typeOfDisplay1) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount']), + array('label' => $tax['title']) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount_incl_tax']), + array('label' => $tax['title']) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $inclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice($incl + $weeeTaxAppliedAmount), + array('label' => $weeeHelper->__('Total incl. tax')) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + + // Quantity: Ordered, Shipped, Cancelled, Refunded + /** @var $quantityXml Mage_XmlConnect_Model_Simplexml_Element */ + $quantityXml = $itemXml->addChild('qty'); + $qty = 1 * $item->getQtyOrdered(); + if ($qty > 0) { + $quantityXml->addCustomChild( + 'value', + $qty, + array('label' => $this->__('Ordered')) + ); + } + $qty = 1 * $item->getQtyShipped(); + if ($qty > 0) { + $quantityXml->addCustomChild( + 'value', + $qty, + array('label' => $this->__('Shipped')) + ); + } + $qty = 1 * $item->getQtyCanceled(); + if ($qty > 0) { + $quantityXml->addCustomChild( + 'value', + $qty, + array('label' => $this->__('Canceled')) + ); + } + $qty = 1 * $item->getQtyRefunded(); + if ($qty > 0) { + $quantityXml->addCustomChild( + 'value', + $qty, + array('label' => $this->__('Refunded')) + ); + } + + // Subtotal excluding tax + /** @var $subtotalXml Mage_XmlConnect_Model_Simplexml_Element */ + $subtotalXml = $itemXml->addChild('subtotal'); + + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) { + + if ($typeOfDisplay014) { + $subtotal = $item->getRowTotal() + + $item->getWeeeTaxAppliedRowAmount() + + $item->getWeeeTaxRowDisposition(); + } else { + $subtotal = $item->getRowTotal(); + } + + $config = array( + 'value' => $this->_formatPrice($subtotal) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Excl. Tax'); + } + + /** @var $exclPriceXml Mage_XmlConnect_Model_Simplexml_Element */ + $exclPriceXml = $subtotalXml->addCustomChild( + 'excluding_tax', + null, + $config + ); + + if ($weeeTaxes) { + if ($typeOfDisplay1) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount']), + array('label' => $tax['title']) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount_incl_tax']), + array('label' => $tax['title']) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $exclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice( + $item->getRowTotal() + + $item->getWeeeTaxAppliedRowAmount() + + $item->getWeeeTaxRowDisposition() + ), + array('label' => $weeeHelper->__('Total')) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + + // Subtotal including tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) { + $incl = $this->helper('checkout')->getSubtotalInclTax($item); + + if ($typeOfDisplay014) { + $subtotal = $incl + $item->getWeeeTaxAppliedRowAmount(); + } else { + $subtotal = $incl - $item->getWeeeTaxRowDisposition(); + } + + $config = array( + 'value' => $this->_formatPrice($subtotal) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Incl. Tax'); + } + + /** @var $inclPriceXml Mage_XmlConnect_Model_Simplexml_Element */ + $inclPriceXml = $subtotalXml->addCustomChild( + 'including_tax', + null, + $config + ); + + if ($weeeTaxes) { + if ($typeOfDisplay1) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount']), + array('label' => $tax['title']) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount_incl_tax']), + array('label' => $tax['title']) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $inclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice($incl + $item->getWeeeTaxAppliedRowAmount()), + array('label' => $weeeHelper->__('Total incl. tax')) + ); + } + } + } + } + + /** + * Format price using order currency + * + * @param float $price + * @return string + */ + protected function _formatPrice($price) + { + return $this->getOrder()->getOrderCurrency()->formatPrecision($price, 2, array(), false); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Downloadable.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Downloadable.php new file mode 100644 index 0000000000..2b9ca910ef --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Downloadable.php @@ -0,0 +1,451 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Downloadable + extends Mage_Downloadable_Block_Sales_Order_Item_Renderer_Downloadable +{ + /** + * Add item to XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj + * @return void + */ + public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) + { + /** @var $item Mage_Sales_Model_Order_Item */ + $item = $this->getItem(); + + /** @var $itemXml Mage_XmlConnect_Model_Simplexml_Element */ + $itemXml = $orderItemXmlObj->addCustomChild( + 'item', + null, + array( + 'product_id' => $item->getProductId() + ) + ); + $itemXml->addCustomChild('name', $item->getName()); + + /** @var $weeeHelper Mage_Weee_Helper_Data */ + $weeeHelper = $this->helper('weee'); + /** @var $taxHelper Mage_Tax_Helper_Data */ + $taxHelper = $this->helper('tax'); + + $options = $this->getItemOptions(); + if ($options) { + /** @var $optionsXml Mage_XmlConnect_Model_Simplexml_Element */ + $optionsXml = $itemXml->addChild('options'); + foreach ($options as $option) { + $formatedOptionValue = $this->getFormatedOptionValue($option); + if (isset($formatedOptionValue['full_view']) && isset($formatedOptionValue['value'])) { + $value = $formatedOptionValue['value']; + } elseif (isset($option['print_value'])) { + $value = $option['print_value']; + } else { + $value = $option['value']; + } + $optionsXml->addCustomChild( + 'option', + strip_tags($value), + array( + 'label' => $option['label'] + ) + ); + } + + $addtInfoBlock = $this->getProductAdditionalInformationBlock(); + if ($addtInfoBlock) { + // TODO: find how to set additional info block + // $addtInfoBlock->setItem($item)->toHtml(); + } + } + + $links = $this->getLinks(); + if ($links) { + $linksXml = $itemXml->addCustomChild( + 'links', + null, + array('label' => $this->getLinksTitle()) + ); + foreach ($links->getPurchasedItems() as $link) { + $linksXml->addCustomChild( + 'link', + $link->getLinkTitle() + ); + } + } + + $itemXml->addCustomChild('entity_type', $item->getProductType()); + $itemXml->addCustomChild('description', $item->getDescription()); + $itemXml->addCustomChild('sku', Mage::helper('core/string')->splitInjection($this->getSku())); + + /** @var $priceXml Mage_XmlConnect_Model_Simplexml_Element */ + $priceXml = $itemXml->addChild('price'); + $weeeTaxAppliedAmount = (float)$item->getWeeeTaxAppliedAmount(); + $weeeTaxDisposition = (float)$item->getWeeeTaxDisposition(); + $typeOfDisplay1 = $weeeHelper->typeOfDisplay($item, 1, 'sales') && $weeeTaxAppliedAmount; + $typeOfDisplay2 = $weeeHelper->typeOfDisplay($item, 2, 'sales') && $weeeTaxAppliedAmount; + $typeOfDisplay4 = $weeeHelper->typeOfDisplay($item, 4, 'sales') && $weeeTaxAppliedAmount; + $typeOfDisplay014 = $weeeHelper->typeOfDisplay($item, array(0, 1, 4), 'sales') && $weeeTaxAppliedAmount; + $weeeTaxes = $weeeHelper->getApplied($item); + + // Price excluding tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) { + if ($typeOfDisplay014) { + $price = $item->getPrice() + $weeeTaxAppliedAmount + $weeeTaxDisposition; + } else { + $price = $item->getPrice(); + } + + $config = array( + 'value' => $this->_formatPrice($price) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Excl. Tax'); + } + + /** @var $exclPriceXml Mage_XmlConnect_Model_Simplexml_Element */ + $exclPriceXml = $priceXml->addCustomChild( + 'excluding_tax', + null, + $config + ); + + if ($weeeTaxes) { + /** @var $weeeXml Mage_XmlConnect_Model_Simplexml_Element */ + if ($typeOfDisplay1) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount']), + array( + 'label' => $tax['title'] + ) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount_incl_tax']), + array( + 'label' => $tax['title'] + ) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $exclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice( + $item->getPrice() + $weeeTaxAppliedAmount + $weeeTaxDisposition + ), + array( + 'label' => $weeeHelper->__('Total') + ) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + + // Price including tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) { + $incl = $this->helper('checkout')->getPriceInclTax($item); + + if ($typeOfDisplay014) { + $price = $incl + $weeeTaxAppliedAmount; + } else { + $price = $incl - $weeeTaxDisposition; + } + + $config = array( + 'value' => $this->_formatPrice($price) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Incl. Tax'); + } + + /** @var $inclPriceXml Mage_XmlConnect_Model_Simplexml_Element */ + $inclPriceXml = $priceXml->addCustomChild( + 'including_tax', + null, + $config + ); + + if ($weeeTaxes) { + /** @var $weeeXml Mage_XmlConnect_Model_Simplexml_Element */ + if ($typeOfDisplay1) { + $weeeXml = $inclPriceXml->tddChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount']), + array( + 'label' => $tax['title'] + ) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $inclPriceXml->tddChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['amount_incl_tax']), + array( + 'label' => $tax['title'] + ) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $inclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice($incl + $weeeTaxAppliedAmount), + array( + 'label' => $weeeHelper->__('Total incl. tax') + ) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + + // Quantity: Ordered, Shipped, Cancelled, Refunded + /** @var $quantityXml Mage_XmlConnect_Model_Simplexml_Element */ + $quantityXml = $itemXml->addChild('qty'); + $qty = 1 * $item->getQtyOrdered(); + if ($qty > 0) { + $quantityXml->addCustomChild( + 'value', + $qty, + array( + 'label' => $this->__('Ordered') + ) + ); + } + $qty = 1 * $item->getQtyShipped(); + if ($qty > 0) { + $quantityXml->addCustomChild( + 'value', + $qty, + array( + 'label' => $this->__('Shipped') + ) + ); + } + $qty = 1 * $item->getQtyCanceled(); + if ($qty > 0) { + $quantityXml->addCustomChild( + 'value', + $qty, + array( + 'label' => $this->__('Canceled') + ) + ); + } + $qty = 1 * $item->getQtyRefunded(); + if ($qty > 0) { + $quantityXml->addCustomChild( + 'value', + $qty, + array( + 'label' => $this->__('Refunded') + ) + ); + } + + // Subtotal excluding tax + /** @var $subtotalXml Mage_XmlConnect_Model_Simplexml_Element */ + $subtotalXml = $itemXml->addChild('subtotal'); + + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) { + + if ($typeOfDisplay014) { + $subtotal = $item->getRowTotal() + + $item->getWeeeTaxAppliedRowAmount() + + $item->getWeeeTaxRowDisposition(); + } else { + $subtotal = $item->getRowTotal(); + } + + $config = array( + 'value' => $this->_formatPrice($subtotal) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Excl. Tax'); + } + + /** @var $exclPriceXml Mage_XmlConnect_Model_Simplexml_Element */ + $exclPriceXml = $subtotalXml->addCustomChild( + 'excluding_tax', + null, + $config + ); + + if ($weeeTaxes) { + if ($typeOfDisplay1) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount']), + array( + 'label' => $tax['title'] + ) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $exclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount_incl_tax']), + array( + 'label' => $tax['title'] + ) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $exclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice( + $item->getRowTotal() + + $item->getWeeeTaxAppliedRowAmount() + + $item->getWeeeTaxRowDisposition() + ), + array( + 'label' => $weeeHelper->__('Total') + ) + ); + } + if (isset($weeeXml)) { + unset($weeeXml); + } + } + } + + // Subtotal including tax + if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) { + $incl = $this->helper('checkout')->getSubtotalInclTax($item); + + if ($typeOfDisplay014) { + $subtotal = $incl + $item->getWeeeTaxAppliedRowAmount(); + } else { + $subtotal = $incl - $item->getWeeeTaxRowDisposition(); + } + + $config = array( + 'value' => $this->_formatPrice($subtotal) + ); + if ($taxHelper->displaySalesBothPrices()) { + $config['label'] = $this->__('Incl. Tax'); + } + + /** @var $inclPriceXml Mage_XmlConnect_Model_Simplexml_Element */ + $inclPriceXml = $subtotalXml->addCustomChild( + 'including_tax', + null, + $config + ); + + if ($weeeHelper->getApplied($item)) { + if ($typeOfDisplay1) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount']), + array( + 'label' => $tax['title'] + ) + ); + } + } elseif ($typeOfDisplay2 || $typeOfDisplay4) { + $weeeXml = $inclPriceXml->addChild('weee'); + foreach ($weeeTaxes as $tax) { + $weeeXml->addCustomChild( + 'tax', + $this->_formatPrice($tax['row_amount_incl_tax']), + array( + 'label' => $tax['title'] + ) + ); + } + } + + if ($typeOfDisplay2) { + if (!isset($weeeXml)) { + $weeeXml = $inclPriceXml->addChild('weee'); + } + $weeeXml->addCustomChild( + 'total', + $this->_formatPrice($incl + $item->getWeeeTaxAppliedRowAmount()), + array( + 'label' => $weeeHelper->__('Total incl. tax') + ) + ); + } + } + } + } + + /** + * Format price using order currency + * + * @param float $price + * @return string + */ + protected function _formatPrice($price) + { + return $this->getOrder()->getOrderCurrency()->formatPrecision($price, 2, array(), false); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Giftcard.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Giftcard.php new file mode 100644 index 0000000000..b635e7e374 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Giftcard.php @@ -0,0 +1,78 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Giftcard + extends Enterprise_GiftCard_Block_Sales_Order_Item_Renderer +{ + /** + * Prepare custom option for display, returns false if there's no value + * + * @param string $code + * @return mixed + */ + protected function _prepareCustomOption($code) + { + if ($option = $this->getOrderItem()->getProductOptionByCode($code)) { + return strip_tags($option); + } + return false; + } + + /** + * Prepare a string containing name and email + * + * @param string $name + * @param string $email + * @return mixed + */ + protected function _getNameEmailString($name, $email) + { + return $name . ' (' . $email . ')'; + } + + /** + * Add item to XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj + * @return void + */ + public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) + { + $item = $this->getOrderItem(); + $item->setProductOptions(array('additional_options' => $this->getItemOptions())); + + $defaultRenderer = $this->getLayout()->getBlock('xmlconnect.customer.order.items')->getItemRenderer(); + $defaultRenderer->setItem($item); + $defaultRenderer->addItemToXmlObject($orderItemXmlObj); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Grouped.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Grouped.php new file mode 100644 index 0000000000..4cbce05dc5 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Grouped.php @@ -0,0 +1,61 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Grouped + extends Mage_Sales_Block_Order_Item_Renderer_Grouped +{ + /** + * Default product type + */ + const DEFAULT_PRODUCT_TYPE = 'default'; + + /** + * Add item to XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj + * @return void + */ + public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) + { + if (!($item = $this->getItem()->getOrderItem())) { + $item = $this->getItem(); + } + if (!($productType = $item->getRealProductType())) { + $productType = self::DEFAULT_PRODUCT_TYPE; + } + $renderer = $this->getRenderedBlock()->getItemRenderer($productType); + $renderer->setItem($this->getItem()); + + $renderer->addItemToXmlObject($orderItemXmlObj); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Items.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Items.php new file mode 100644 index 0000000000..c34a128482 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Items.php @@ -0,0 +1,111 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Items extends Mage_Sales_Block_Order_Items +{ + /** + * Initialize default item renderer + */ + protected function _construct() + { + parent::_construct(); + $this->addItemRender('default', 'xmlconnect/customer_order_item_renderer_default'); + } + + /** + * Add renderer for item product type + * + * @param string $type + * @param string $block + * @param string $template + * @return Mage_Checkout_Block_Cart_Abstract + */ + public function addItemRender($type, $block, $template = '') + { + $this->_itemRenders[$type] = array( + 'block' => $block, + 'renderer' => null + ); + + return $this; + } + + /** + * Retrieve item renderer block + * + * @param string $type + * @return Mage_Core_Block_Abstract + */ + public function getItemRenderer($type = 'default') + { + if (!isset($this->_itemRenders[$type])) { + $type = 'default'; + } + + if (is_null($this->_itemRenders[$type]['renderer'])) { + $this->_itemRenders[$type]['renderer'] = $this->getLayout() + ->createBlock($this->_itemRenders[$type]['block']) + ->setRenderedBlock($this); + } + return $this->_itemRenders[$type]['renderer']; + } + + /** + * Render XML for items + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj + * @return void + */ + public function addItemsToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj) + { + $itemsXml = $orderXmlObj->addChild('ordered_items'); + + foreach ($this->getItems() as $item) { + if ($item->getParentItem()) { + // if Item is option of grouped product - do not render it + continue; + } + $type = $this->_getItemType($item); + + // TODO: take out all Enterprise renderers from layout update into array an realize checking of their using + // Check if the Enterprise_GiftCard module is available for rendering + if ($type == 'giftcard' && !is_object(Mage::getConfig()->getNode('modules/Enterprise_GiftCard'))) { + continue; + } + $renderer = $this->getItemRenderer($type)->setItem($item); + if (method_exists($renderer, 'addItemToXmlObject')) { + $renderer->addItemToXmlObject($itemsXml); + } + } + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/List.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/List.php index 15977b956d..27e12330be 100644 --- a/app/code/core/Mage/XmlConnect/Block/Customer/Order/List.php +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/List.php @@ -27,14 +27,14 @@ /** * Customer orders history xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Customer_Order_List extends Mage_Core_Block_Template { /** - * Linmitation for orders list + * Orders count limit */ const ORDERS_LIST_LIMIT = 10; @@ -45,12 +45,20 @@ class Mage_XmlConnect_Block_Customer_Order_List extends Mage_Core_Block_Template */ protected function _toHtml() { - $ordersXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $ordersXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $orders = Mage::getResourceModel('sales/order_collection') ->addFieldToSelect('*') - ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()) - ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())) + ->addFieldToFilter( + 'customer_id', + Mage::getSingleton('customer/session')->getCustomer()->getId() + ) + ->addFieldToFilter( + 'state', + array( + 'in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates() + ) + ) ->setOrder('created_at', 'desc'); $orders->getSelect()->limit(self::ORDERS_LIST_LIMIT, 0); @@ -63,13 +71,24 @@ protected function _toHtml() $item->addChild('number', $_order->getRealOrderId()); $item->addChild('date', $this->formatDate($_order->getCreatedAtStoreDate())); if ($_order->getShippingAddress()) { - $item->addChild('ship_to', $ordersXmlObj->xmlentities(strip_tags($_order->getShippingAddress()->getName()))); + $item->addChild( + 'ship_to', + $ordersXmlObj->xmlentities($_order->getShippingAddress()->getName()) + ); } - $item->addChild('total', $_order->getOrderCurrency()->formatPrecision($_order->getGrandTotal(), 2, array(), false, false)); + $item->addChild( + 'total', + $_order->getOrderCurrency()->formatPrecision( + $_order->getGrandTotal(), + 2, + array(), + false, + false + ) + ); $item->addChild('status', $_order->getStatusLabel()); } } - return $ordersXmlObj->asNiceXml(); } } diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals.php new file mode 100644 index 0000000000..55684e9a5b --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals.php @@ -0,0 +1,146 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Totals extends Mage_Sales_Block_Order_Totals +{ + /** + * Add order totals rendered to XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj + * @return void + */ + public function addTotalsToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj) + { + // all Enterprise renderers from layout update into array an realize checking of their using + $enterpriseBlocks = array( + 'reward.sales.order.total' => array( + 'module' => 'Enterprise_Reward', + 'block' => 'enterprise_reward/sales_order_total' + ), + 'customerbalance' => array( + 'module' => 'Enterprise_CustomerBalance', + 'block' => 'xmlconnect/customer_order_totals_customerbalance', + 'template' => 'customerbalance/order/customerbalance.phtml' + ), + 'customerbalance_total_refunded' => array( + 'module' => 'Enterprise_CustomerBalance', + 'block' => 'xmlconnect/customer_order_totals_customerbalance_refunded', + 'template' => 'customerbalance/order/customerbalance_refunded.phtml', + 'after' => '-', + 'action' => array( + 'method' => 'setAfterTotal', + 'value' => 'grand_total' + ) + ), + 'giftwrapping' => array( + 'module' => 'Enterprise_GiftWrapping', + 'block' => 'enterprise_giftwrapping/sales_totals' + ), + 'giftcards' => array( + 'module' => 'Enterprise_GiftCardAccount', + 'block' => 'xmlconnect/customer_order_totals_giftcards', + 'template' => 'giftcardaccount/order/giftcards.phtml' + ), + ); + + foreach ($enterpriseBlocks as $name => $block) { + // create blocks only for Enterprise/Pro modules which is in system + if (is_object(Mage::getConfig()->getNode('modules/' . $block['module']))) { + $blockInstance = $this->getLayout()->createBlock($block['block'], $name); + $this->setChild($name, $blockInstance); + if (isset($block['action']['method']) && isset($block['action']['value'])) { + $method = $block['action']['method']; + $blockInstance->$method($block['action']['value']); + } + } + } + + $this->_beforeToHtml(); + + $totalsXml = $orderXmlObj->addChild('totals'); + foreach ($this->getTotals() as $total) { + if ($total->getValue()) { + $total->setValue(strip_tags($total->getValue())); + } + if ($total->getBlockName()) { + $block = $this->getLayout()->getBlock($total->getBlockName()); + if (is_object($block)) { + if (method_exists($block, 'addToXmlObject')) { + $block->setTotal($total)->addToXmlObject($totalsXml); + } else { + $this->_addTotalToXml($total, $totalsXml); + } + } + } else { + $this->_addTotalToXml($total, $totalsXml); + } + } + } + + /** + * Add total to totals XML + * + * @param Varien_Object $total + * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml + * @return void + */ + private function _addTotalToXml($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml) + { + if ( + $total instanceof Varien_Object + && $total->getCode() + && $total->getLabel() + && $total->hasData('value') + ) { + $totalsXml->addCustomChild( + preg_replace('@[\W]+@', '_', trim($total->getCode())), + $this->_formatPrice($total), + array('label' => strip_tags($total->getLabel())) + ); + } + } + + /** + * Format price using order currency + * + * @param Varien_Object $total + * @return string + */ + protected function _formatPrice($total) + { + if (!$total->getIsFormated()) { + return $this->getOrder()->getOrderCurrency()->formatPrecision($total->getValue(), 2, array(), false); + } + return $total->getValue(); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance.php new file mode 100644 index 0000000000..53ade18541 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance.php @@ -0,0 +1,65 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Totals_Customerbalance + extends Enterprise_CustomerBalance_Block_Sales_Order_Customerbalance +{ + /** + * Add order total rendered to XML object + * + * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element + * @return void + */ + public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml) + { + $balance = $this->getSource()->getCustomerBalanceAmount(); + if ($balance) { + $totalsXml->addCustomChild( + $this->getTotal()->getCode(), + '-' . $this->_formatPrice($balance), + array('label' => Mage::helper('enterprise_giftcardaccount')->__('Store Credit')) + ); + } + } + + /** + * Format price using order currency + * + * @param float $amount + * @return string + */ + protected function _formatPrice($amount) + { + return $this->getOrder()->getOrderCurrency()->formatPrecision($amount, 2, array(), false); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance/Refunded.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance/Refunded.php new file mode 100644 index 0000000000..3843036ba6 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance/Refunded.php @@ -0,0 +1,65 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Totals_Customerbalance_Refunded + extends Enterprise_CustomerBalance_Block_Sales_Order_Customerbalance +{ + /** + * Add order total rendered to XML object + * + * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element + * @return void + */ + public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml) + { + $balance = $this->getSource()->getCustomerBalanceTotalRefunded(); + if ($balance) { + $totalsXml->addCustomChild( + $this->getTotal()->getCode(), + $this->_formatPrice($balance), + array('label' => Mage::helper('enterprise_giftcardaccount')->__('Refunded to Store Credit')) + ); + } + } + + /** + * Format price using order currency + * + * @param float $amount + * @return string + */ + protected function _formatPrice($amount) + { + return $this->getOrder()->getOrderCurrency()->formatPrecision($amount, 2, array(), false); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Giftcards.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Giftcards.php new file mode 100644 index 0000000000..12af538af5 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Giftcards.php @@ -0,0 +1,77 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Totals_Giftcards + extends Enterprise_GiftCardAccount_Block_Sales_Order_Giftcards +{ + /** + * Add order total rendered to XML object + * + * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element + * @return void + */ + public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml) + { + $cards = $this->getGiftCards(); + if ($cards) { + foreach ($cards as $card) { + $label = Mage::helper('enterprise_giftcardaccount')->__('Gift Card (%s)', $card->getCode()); + $totalsXml->addCustomChild( + $this->getTotal()->getCode(), + '-' . $this->_formatPrice($card->getAmount()), + array('label' => $label) + ); + } + } else { + $cardsAmount = $this->getSource()->getGiftCardsAmount(); + if ($cardsAmount > 0) { + $totalsXml->addCustomChild( + $this->getTotal()->getCode(), + '-' . $this->_formatPrice($cardsAmount), + array('label' => Mage::helper('enterprise_giftcardaccount')->__('Gift Card')) + ); + } + } + } + + /** + * Format price using order currency + * + * @param float $amount + * @return string + */ + protected function _formatPrice($amount) + { + return $this->getOrder()->getOrderCurrency()->formatPrecision($amount, 2, array(), false); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Tax.php b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Tax.php new file mode 100644 index 0000000000..563a2fa301 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Tax.php @@ -0,0 +1,92 @@ + + */ +class Mage_XmlConnect_Block_Customer_Order_Totals_Tax extends Mage_Tax_Block_Sales_Order_Tax +{ + /** + * Add order taxes rendered to XML object + * + * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXmlObj + * @return void + */ + public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXmlObj) + { + /** @var $taxesXmlObj Mage_XmlConnect_Model_Simplexml_Element */ + $taxesXmlObj = $totalsXmlObj->addChild('tax'); + + $fullInfo = $this->getOrder()->getFullTaxInfo(); + + if ($this->displayFullSummary() && !empty($fullInfo)) { + foreach ((array)$fullInfo as $info) { + if (isset($info['hidden']) && $info['hidden']) { + continue; + } + + foreach ((array)$info['rates'] as $rate) { + if (isset($info['amount'])) { + $config = array( + 'label' => $rate['title'] + ); + if (!is_null($rate['percent'])) { + $config['percent'] = '(' . (float)$rate['percent'] . '%)'; + } + $taxesXmlObj->addCustomChild( + 'item', + is_null($rate['percent']) ? '' : $this->_formatPrice($info['amount']), + $config + ); + } + } + } + } + + $taxesXmlObj->addCustomChild( + 'summary', + $this->_formatPrice($this->getSource()->getTaxAmount()), + array( + 'label' => $this->__('Tax') + ) + ); + } + + /** + * Format price using order currency + * + * @param float $amount + * @return string + */ + protected function _formatPrice($amount) + { + return $this->getOrder()->getOrderCurrency()->formatPrecision($amount, 2, array(), false); + } +} diff --git a/app/code/core/Mage/XmlConnect/Block/Home.php b/app/code/core/Mage/XmlConnect/Block/Home.php index 54e72600ca..f2f4aa48d6 100644 --- a/app/code/core/Mage/XmlConnect/Block/Home.php +++ b/app/code/core/Mage/XmlConnect/Block/Home.php @@ -27,13 +27,12 @@ /** * Home categories list renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Block_Home extends Mage_XmlConnect_Block_Catalog { - /** * Category list limitation */ @@ -46,24 +45,32 @@ class Mage_XmlConnect_Block_Home extends Mage_XmlConnect_Block_Catalog */ protected function _toHtml() { - /** @var $xmlModel Mage_XmlConnect_Model_Simplexml_Element */ + /** @var $homeXmlObj Mage_XmlConnect_Model_Simplexml_Element */ $homeXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); - /** @var $categoryCollection Mage_XmlConnect_Model_Mysql4_Category_Collection */ - $categoryCollection = Mage::getResourceModel('xmlconnect/category_collection'); - $categoryCollection->setStoreId(Mage::app()->getStore()->getId()) - ->addParentIdFilter(Mage::app()->getStore()->getRootCategoryId()) - ->setOrder('position', 'ASC') - ->setLimit(0, self::HOME_PAGE_CATEGORIES_COUNT); + $categoryCollection = array(); + $helper = Mage::helper('catalog/category'); + $i = 0; + foreach ($helper->getStoreCategories() as $child) { + if ($child->getIsActive()) { + $categoryCollection[] = $child; + $i++; + } + if ($i == self::HOME_PAGE_CATEGORIES_COUNT) { + break; + } + } if (sizeof($categoryCollection)) { $itemsXmlObj = $homeXmlObj->addChild('categories'); } - foreach ($categoryCollection->getItems() as $item) { + foreach ($categoryCollection as $item) { + /** @var $item Mage_Catalog_Model_Category */ + $item = Mage::getModel('catalog/category')->load($item->getId()); $itemXmlObj = $itemsXmlObj->addChild('item'); $itemXmlObj->addChild('label', $homeXmlObj->xmlentities(strip_tags($item->getName()))); - $itemXmlObj->addChild('entity_id', $item->getEntityId()); + $itemXmlObj->addChild('entity_id', $item->getId()); $itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products'); $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail') ->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('category')); @@ -72,10 +79,8 @@ protected function _toHtml() $file = Mage::helper('xmlconnect')->urlToPath($icon); - $iconXml->addAttribute('modification_time', filemtime($file)); } - $homeXmlObj->addChild('home_banner', '/current/media/catalog/category/banner_home.png'); return $homeXmlObj->asNiceXml(); diff --git a/app/code/core/Mage/XmlConnect/Block/Review/Form.php b/app/code/core/Mage/XmlConnect/Block/Review/Form.php index bd60c76e76..21dfdaee5e 100644 --- a/app/code/core/Mage/XmlConnect/Block/Review/Form.php +++ b/app/code/core/Mage/XmlConnect/Block/Review/Form.php @@ -48,41 +48,68 @@ class Mage_XmlConnect_Block_Review_Form extends Mage_Core_Block_Template protected function _toHtml() { $customer = Mage::getSingleton('customer/session')->getCustomer(); - $xmlModel = Mage::getModel('xmlconnect/simplexml_element', ''); + /** @var $xmlReview Mage_XmlConnect_Model_Simplexml_Element */ + $xmlReview = Mage::getModel('xmlconnect/simplexml_element', '
'); + $xmlReview->addAttribute('name', 'review_form'); + $xmlReview->addAttribute('method', 'post'); - $firstname = $ratingsXml = ''; + $nickname = ''; if ($customer->getId()) { - $firstname = $xmlModel->xmlentities(strip_tags($customer->getFirstname())); + $nickname = strip_tags($customer->getFirstname()); } if ($this->getRatings()) { + $ratingsFieldset = $xmlReview->addCustomChild( + 'fieldset', + null, + array( + 'label' => $this->__('How do you rate this product?') + ) + ); + foreach ($this->getRatings() as $rating) { - $ratingTitle = $xmlModel->xmlentities($rating->getRatingCode()); - $ratingCode = strtolower($rating->getRatingCode()); - $ratingCode = preg_replace('/[\W]+/', '_', $ratingCode); - $ratingsXml .= ' -
'; + $ratingField = $ratingsFieldset->addField( + 'ratings[' . $rating->getId() . ']', + 'radio', + array( + 'label' => $rating->getRatingCode(), + 'required' => 'true' + ) + ); foreach ($rating->getOptions() as $option) { - $ratingsXml .= ' - '; + $ratingField->addCustomChild('value', $option->getId()); } - $ratingsXml .= ' -
'; } } - $xml = << -
- - - -
{$ratingsXml} - -EOT; + $reviewFieldset = $xmlReview->addCustomChild('fieldset'); + $reviewFieldset->addField( + 'nickname', + 'text', + array( + 'label' => $this->__('Nickname'), + 'required' => 'true', + 'value' => $nickname + ) + ); + $reviewFieldset->addField( + 'title', + 'text', + array( + 'label' => $this->__('Summary of Your Review'), + 'required' => 'true' + ) + ); + $reviewFieldset->addField( + 'detail', + 'textarea', + array( + 'label' => $this->__('Review'), + 'required' => 'true' + ) + ); - return $xml; + return $xmlReview->asNiceXml(); } /** diff --git a/app/code/core/Mage/XmlConnect/Block/Wishlist.php b/app/code/core/Mage/XmlConnect/Block/Wishlist.php index 8dbef83c99..c8866a0804 100644 --- a/app/code/core/Mage/XmlConnect/Block/Wishlist.php +++ b/app/code/core/Mage/XmlConnect/Block/Wishlist.php @@ -27,11 +27,10 @@ /** * Customer wishlist xml renderer * - * @category Mage - * @package Mage_XmlConnect - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ - class Mage_XmlConnect_Block_Wishlist extends Mage_Wishlist_Block_Customer_Wishlist { /** @@ -41,7 +40,7 @@ class Mage_XmlConnect_Block_Wishlist extends Mage_Wishlist_Block_Customer_Wishli */ protected function _toHtml() { - $wishlistXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + $wishlistXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $hasMoreItems = 0; /** * Apply offset and count @@ -49,6 +48,7 @@ protected function _toHtml() $request= $this->getRequest(); $offset = (int)$request->getParam('offset', 0); $count = (int)$request->getParam('count', 0); + $offset = $offset < 0 ? 0 : $offset; $count = $count <= 0 ? 1 : $count; if ($offset + $count < $this->getWishlistItems()->getSize()) { $hasMoreItems = 1; @@ -63,13 +63,10 @@ protected function _toHtml() * @var Mage_Wishlist_Model_Mysql4_Product_Collection */ foreach ($this->getWishlistItems() as $item) { + /** @var $item Mage_Wishlist_Model_Item */ $itemXmlObj = $wishlistXmlObj->addChild('item'); - $itemXmlObj->addChild( - 'item_id', - /** @var $item Mage_Wishlist_Model_Item */ - $item->getWishlistItemId() - ); + $itemXmlObj->addChild('item_id', $item->getWishlistItemId()); $itemXmlObj->addChild('entity_id', $item->getProductId()); $itemXmlObj->addChild('entity_type_id', $item->getProduct()->getTypeId()); @@ -80,9 +77,9 @@ protected function _toHtml() * If product type is grouped than it has options as its grouped items */ if ($item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE) { - $item->setHasOptions(true); + $item->getProduct()->setHasOptions(true); } - $itemXmlObj->addChild('has_options', (int)$item->getHasOptions()); + $itemXmlObj->addChild('has_options', (int)$item->getProduct()->getHasOptions()); $icon = $this->helper('catalog/image')->init($item->getProduct(), 'small_image') ->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small')); @@ -100,13 +97,13 @@ protected function _toHtml() if ($this->getChild('product_price')) { $this->getChild('product_price')->setProduct($item->getProduct()) - ->setProductXmlObj($itemXmlObj) - ->collectProductPrices(); + ->setProductXmlObj($itemXmlObj) + ->collectProductPrices(); } if (!$item->getProduct()->getRatingSummary()) { Mage::getModel('review/review') - ->getEntitySummary($item->getProduct(), Mage::app()->getStore()->getId()); + ->getEntitySummary($item->getProduct(), Mage::app()->getStore()->getId()); } $ratingSummary = (int)$item->getProduct()->getRatingSummary()->getRatingSummary(); $itemXmlObj->addChild('rating_summary', round($ratingSummary / 10)); diff --git a/app/code/core/Mage/XmlConnect/Controller/Action.php b/app/code/core/Mage/XmlConnect/Controller/Action.php index 1f6d68ad45..fdf5625d18 100644 --- a/app/code/core/Mage/XmlConnect/Controller/Action.php +++ b/app/code/core/Mage/XmlConnect/Controller/Action.php @@ -35,36 +35,26 @@ abstract class Mage_XmlConnect_Controller_Action extends Mage_Core_Controller_Fr { /** * Message status `error` - * - * @var string */ const MESSAGE_STATUS_ERROR = 'error'; /** * Message status `warning` - * - * @var string */ const MESSAGE_STATUS_WARNING = 'warning'; /** * Message status `success` - * - * @var string */ const MESSAGE_STATUS_SUCCESS = 'success'; /** * Message type `alert` - * - * @var string */ const MESSAGE_TYPE_ALERT = 'alert'; /** * Message type `prompt` - * - * @var string */ const MESSAGE_TYPE_PROMPT = 'prompt'; @@ -154,6 +144,7 @@ public function postDispatch() */ protected function _message($text, $status, $type='', $action='') { + /** @var $message Mage_XmlConnect_Model_Simplexml_Element */ $message = Mage::getModel('xmlconnect/simplexml_element', ''); $message->addChild('status', $status); $message->addChild('text', $text); diff --git a/app/code/core/Mage/XmlConnect/Helper/Android.php b/app/code/core/Mage/XmlConnect/Helper/Android.php index 4a9d2945ad..17ad43f06b 100755 --- a/app/code/core/Mage/XmlConnect/Helper/Android.php +++ b/app/code/core/Mage/XmlConnect/Helper/Android.php @@ -35,57 +35,41 @@ class Mage_XmlConnect_Helper_Android extends Mage_Core_Helper_Abstract { /** * Submission title length - * - * @var int */ const SUBMISSION_TITLE_LENGTH = 30; /** * Submission description length - * - * @var int */ const SUBMISSION_DESCRIPTION_LENGTH = 4000; /** * Android preview banner widht - * - * @var int */ const PREVIEW_BANNER_WIDTH = 320; /** * Android preview banner image height - * - * @var int */ const PREVIEW_BANNER_HEIGHT = 258; /** * Tags identifier for title bar - * - * @var int */ const TAGS_ID_FOR_TITLE_BAR = 1; /** * Tags identifier for options menu - * - * @var int */ const TAGS_ID_FOR_OPTION_MENU = 2; /** * Country renderer for submission - * - * @var string */ const SUBMISSION_COUNTRY_RENDERER = 'androidmarket'; /** * Country columns for submission - * - * @var int */ const SUBMISSION_COUNTRY_COLUMNS = 2; @@ -103,16 +87,6 @@ class Mage_XmlConnect_Helper_Android extends Mage_Core_Helper_Abstract */ protected $_countryRenderer = null; - /** - * Get submit images that are required for application submit - * - * @return array - */ - public function getSubmitImages() - { - return $this->_imageIds; - } - /** * List of coutries that allowed in Ituens by Apple Store * @@ -123,37 +97,47 @@ public function getSubmitImages() * @var array */ protected $_allowedCountries = array( - 'Argentina' => 'AR', - 'Australia' => 'AU', - 'Austria' => 'AT', - 'Belgium' => 'BE', - 'Brazil' =>'BR', - 'Canada' => 'CA', - 'Denmark' => 'DK', - 'Finland' => 'FI', - 'France' => 'FR', - 'Germany' => 'DE', - 'Hong Kong SAR China' => 'HK', - 'Ireland' => 'IE', - 'Israel' => 'IL', - 'Italy' => 'IT', - 'Japan' => 'JP', - 'Mexico' => 'MX', - 'Netherlands' => 'NL', - 'New Zealand' => 'NZ', - 'Norway' => 'NO', - 'Portugal' => 'PT', - 'Russia' => 'RU', - 'Singapore' => 'SG', - 'Spain' => 'ES', - 'South Korea' => 'KR', - 'Sweden' => 'SE', - 'Switzerland' => 'CH', - 'Taiwan' => 'TW', - 'United Kingdom' => 'GB', - 'United States' => 'US', + 'Argentina' => 'AR', + 'Australia' => 'AU', + 'Austria' => 'AT', + 'Belgium' => 'BE', + 'Brazil' =>'BR', + 'Canada' => 'CA', + 'Denmark' => 'DK', + 'Finland' => 'FI', + 'France' => 'FR', + 'Germany' => 'DE', + 'Hong Kong SAR China' => 'HK', + 'Ireland' => 'IE', + 'Israel' => 'IL', + 'Italy' => 'IT', + 'Japan' => 'JP', + 'Mexico' => 'MX', + 'Netherlands' => 'NL', + 'New Zealand' => 'NZ', + 'Norway' => 'NO', + 'Portugal' => 'PT', + 'Russia' => 'RU', + 'Singapore' => 'SG', + 'Spain' => 'ES', + 'South Korea' => 'KR', + 'Sweden' => 'SE', + 'Switzerland' => 'CH', + 'Taiwan' => 'TW', + 'United Kingdom' => 'GB', + 'United States' => 'US', ); + /** + * Get submit images that are required for application submit + * + * @return array + */ + public function getSubmitImages() + { + return $this->_imageIds; + } + /** * Get default application tabs * diff --git a/app/code/core/Mage/XmlConnect/Helper/Catalog/Category/Image.php b/app/code/core/Mage/XmlConnect/Helper/Catalog/Category/Image.php index e24d48ad61..8165166a58 100644 --- a/app/code/core/Mage/XmlConnect/Helper/Catalog/Category/Image.php +++ b/app/code/core/Mage/XmlConnect/Helper/Catalog/Category/Image.php @@ -27,13 +27,15 @@ /** * Catalog image helper * - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Helper_Catalog_Category_Image extends Mage_Catalog_Helper_Image { /** * Init - * + * * @param Mage_Catalog_Model_Product $product * @param string $attributeName * @param string $imageFile @@ -60,10 +62,18 @@ public function initialize(Mage_Catalog_Model_Abstract $category, $attributeName $this->_getModel()->setDestinationSubdir($attributeName); $this->setProduct($category); - $this->setWatermark(Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_image")); - $this->setWatermarkImageOpacity(Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity")); - $this->setWatermarkPosition(Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_position")); - $this->setWatermarkSize(Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_size")); + $this->setWatermark( + Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_image") + ); + $this->setWatermarkImageOpacity( + Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity") + ); + $this->setWatermarkPosition( + Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_position") + ); + $this->setWatermarkSize( + Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_size") + ); if ($imageFile) { $this->setImageFile($imageFile); @@ -71,21 +81,23 @@ public function initialize(Mage_Catalog_Model_Abstract $category, $attributeName /* * add for work original size */ - $this->_getModel()->setBaseFile( $this->getProduct()->getData($this->_getModel()->getDestinationSubdir()) ); + $this->_getModel()->setBaseFile( + $this->getProduct()->getData($this->_getModel()->getDestinationSubdir()) + ); } return $this; } /** * Return placeholder image file path - * + * * @return string */ public function getPlaceholder() { if (!$this->_placeholder) { $attr = $this->_getModel()->getDestinationSubdir(); - $this->_placeholder = 'images/xmlconnect/catalog/category/placeholder/'.$attr.'.jpg'; + $this->_placeholder = 'images/xmlconnect/catalog/category/placeholder/' . $attr . '.jpg'; } return $this->_placeholder; } diff --git a/app/code/core/Mage/XmlConnect/Helper/Data.php b/app/code/core/Mage/XmlConnect/Helper/Data.php index 8616b76600..c90994cb7a 100644 --- a/app/code/core/Mage/XmlConnect/Helper/Data.php +++ b/app/code/core/Mage/XmlConnect/Helper/Data.php @@ -24,19 +24,22 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +/** + * XmlConnect default helper + * + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team + */ class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract { /** * Push title length - * - * @var int */ const PUSH_TITLE_LENGTH = 140; /** * Message title length - * - * @var int */ const MESSAGE_TITLE_LENGTH = 255; @@ -65,57 +68,41 @@ class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract /** * XML path to nodes to be excluded - * - * @var string */ const XML_NODE_CONFIG_EXCLUDE_FROM_XML = 'xmlconnect/mobile_application/nodes_excluded_from_config_xml'; /** * Default device type - * - * @var string */ const DEVICE_TYPE_DEFAULT = 'unknown'; /** * iPhone device identifier - * - * @var string */ const DEVICE_TYPE_IPHONE = 'iphone'; /** * iPad device identifier - * - * @var string */ const DEVICE_TYPE_IPAD = 'ipad'; /** * Android device identifier - * - * @var string */ const DEVICE_TYPE_ANDROID = 'android'; /** * Social network Twitter id - * - * @var string */ const SOCIAL_NETWORK_TWITTER = 'twitter'; /** * Social network Facebook id - * - * @var string */ const SOCIAL_NETWORK_FACEBOOK = 'facebook'; /** * Social network LinkedIn id - * - * @var string */ const SOCIAL_NETWORK_LINKEDIN = 'linkedin'; @@ -252,16 +239,16 @@ public function getUrl($route, $params = array()) */ public function getCountryOptionsArray($isItunes = false) { - Varien_Profiler::start('TEST: '.__METHOD__); + Varien_Profiler::start('TEST: ' . __METHOD__); $deviceType = $this->getDeviceType(); switch ($deviceType) { case self::DEVICE_TYPE_IPHONE: case self::DEVICE_TYPE_IPAD: - $cacheKey = 'XMLCONNECT_COUNTRY_ITUNES_SELECT_STORE_'.Mage::app()->getStore()->getCode(); + $cacheKey = 'XMLCONNECT_COUNTRY_ITUNES_SELECT_STORE_' . Mage::app()->getStore()->getCode(); $deviceCountries = $this->getDeviceHelper()->getItunesCountriesArray(); break; case self::DEVICE_TYPE_ANDROID: - $cacheKey = 'XMLCONNECT_COUNTRY_ANDROID_SELECT_STORE_'.Mage::app()->getStore()->getCode(); + $cacheKey = 'XMLCONNECT_COUNTRY_ANDROID_SELECT_STORE_' . Mage::app()->getStore()->getCode(); $deviceCountries = $this->getDeviceHelper()->getAndroidMarketCountriesArray(); break; default: @@ -285,7 +272,7 @@ public function getCountryOptionsArray($isItunes = false) Mage::app()->saveCache(serialize($options), $cacheKey, array('config')); } } - Varien_Profiler::stop('TEST: '.__METHOD__); + Varien_Profiler::stop('TEST: ' . __METHOD__); if (count($options)) { $options[] = array( @@ -469,7 +456,7 @@ public function getArrayAsXmlItemValues($dataArray, $selected) ' . ($k ? $k : '') . '
'; } - $result = implode('', $items); + $result = implode(PHP_EOL, $items); return $result; } @@ -620,14 +607,15 @@ public function getApplications() */ public static function isTemplateAllowedForApplication($application = null) { - return $application instanceof Mage_XmlConnect_Model_Application ? - in_array($application->getType(), array(self::DEVICE_TYPE_IPHONE)) : - false; + return $application instanceof Mage_XmlConnect_Model_Application + ? in_array($application->getType(), array(self::DEVICE_TYPE_IPHONE)) + : false; } /** * Send broadcast message * + * @throws Mage_Core_Exception * @param Mage_XmlConnect_Model_Queue $queue */ public function sendBroadcastMessage(Mage_XmlConnect_Model_Queue $queue) @@ -844,7 +832,8 @@ public function validateConfFieldNotEmpty($field, $native) if ( ($native === false) || (!isset($native['body']) || !is_array($native['body']) || !isset($native['body'][$field]) - || !Zend_Validate::is($native['body'][$field], 'NotEmpty'))) { + || !Zend_Validate::is($native['body'][$field], 'NotEmpty')) + ) { return false; } return true; diff --git a/app/code/core/Mage/XmlConnect/Helper/Image.php b/app/code/core/Mage/XmlConnect/Helper/Image.php index c24fd85701..a76cb536cf 100644 --- a/app/code/core/Mage/XmlConnect/Helper/Image.php +++ b/app/code/core/Mage/XmlConnect/Helper/Image.php @@ -24,8 +24,18 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +/** + * XmlConnect image helper + * + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team + */ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract { + /** + * Xml connect glue + */ const XMLCONNECT_GLUE = '_'; /** @@ -65,7 +75,7 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract /** * Process uploaded file - * setup filenames to the configuration + * setup file names to the configuration * * @param string $field * @param mixed &$target @@ -94,7 +104,9 @@ public function handleUpload($field, &$target) Mage::throwException(Mage::helper('xmlconnect')->__('File can\'t be uploaded.')); } elseif ($e->getMessage() == 'Disallowed file type.') { $filename = $_FILES[$field]['name']; - Mage::throwException(Mage::helper('xmlconnect')->__('Error while uploading file "%s". Disallowed file type. Only "jpg", "jpeg", "gif", "png" are allowed.', $filename)); + Mage::throwException( + Mage::helper('xmlconnect')->__('Error while uploading file "%s". Disallowed file type. Only "jpg", "jpeg", "gif", "png" are allowed.', $filename) + ); } else { Mage::logException($e); } @@ -138,17 +150,24 @@ protected function _getResizedFilename($fieldPath, $fileName, $default = false) if (!file_exists($originalSizeFileName)) { $oldFileName = $this->getOldUploadDir() . DS . $fileName; if (file_exists($oldFileName)) { - if (!(copy($oldFileName, $originalSizeFileName) && - (is_readable($customSizeFileName) || chmod($customSizeFileName, 0644)))) { - Mage::throwException(Mage::helper('xmlconnect')->__('Error while processing file "%s".', $fileName)); + if (!(copy($oldFileName, $originalSizeFileName) + && (is_readable($customSizeFileName) + || chmod($customSizeFileName, 0644))) + ) { + Mage::throwException( + Mage::helper('xmlconnect')->__('Error while processing file "%s".', $fileName) + ); } } else { Mage::throwException(Mage::helper('xmlconnect')->__('No such file "%s".', $fileName)); } } - if ((!$error) && copy($originalSizeFileName, $customSizeFileName) && - (is_readable($customSizeFileName) || chmod($customSizeFileName, 0644))) { + if (!$error + && copy($originalSizeFileName, $customSizeFileName) + && (is_readable($customSizeFileName) + || chmod($customSizeFileName, 0644)) + ) { $this->_handleResize($fieldPath, $customSizeFileName); } else { $fileName = ''; @@ -200,8 +219,9 @@ protected function _handleResize($fieldPath, $file) $height = $conf['height']; } - if (($width != $image->getOriginalWidth()) || - ($height != $image->getOriginalHeight()) ) { + if (($width != $image->getOriginalWidth()) + || ($height != $image->getOriginalHeight()) + ) { $image->keepTransparency(true); $image->keepFrame(true); $image->keepAspectRatio(true); @@ -220,17 +240,27 @@ protected function _forcedConvertPng($field) { $file =& $_FILES[$field]; - $file['name'] = preg_replace('/\.(gif|jpeg|jpg)$/i', '.png', $file['name']); + $dotPosition = strrpos($file['name'], '.'); + if ($dotPosition !== false) { + $file['name'] = substr($file['name'], 0 , $dotPosition); + } + $file['name'] .= '.png'; - list($x, $x, $fileType) = getimagesize($file['tmp_name']); - if ($fileType != IMAGETYPE_PNG ) { - switch( $fileType ) { + $fileType = exif_imagetype($file['tmp_name']); + if ($fileType != IMAGETYPE_PNG) { + switch ($fileType) { case IMAGETYPE_GIF: $img = imagecreatefromgif($file['tmp_name']); break; case IMAGETYPE_JPEG: $img = imagecreatefromjpeg($file['tmp_name']); break; + case IMAGETYPE_WBMP: + $img = imagecreatefromwbmp($file['tmp_name']); + break; + case IMAGETYPE_XBM: + $img = imagecreatefromxbm($file['tmp_name']); + break; default: return; } @@ -270,7 +300,7 @@ public function getCustomSizeDirPrefix() */ public function getFileDefaultSizeSuffixAsUrl($fileName) { - return 'custom'.'/'.$this->_getScreenSize().'/'.basename($fileName); + return 'custom' . '/' . $this->_getScreenSize() . '/' . basename($fileName); } /** @@ -282,7 +312,11 @@ public function getFileDefaultSizeSuffixAsUrl($fileName) */ public function getFileCustomDirSuffixAsUrl($confPath, $fileName) { - return 'custom'.'/'.$this->_getScreenSize().'/'.basename($this->_getResizedFilename($confPath, $fileName)); + return 'custom' + . '/' + . $this->_getScreenSize() + . '/' + . basename($this->_getResizedFilename($confPath, $fileName)); } /** @@ -293,10 +327,7 @@ public function getFileCustomDirSuffixAsUrl($confPath, $fileName) */ public function getImageSizeForContent($imageName) { - $size = 0; if (!isset($this->_content)) { - /** @var $app Mage_XmlConnect_Model_Application */ - $app = Mage::helper('xmlconnect')->getApplication(); $imageLimits = $this->getImageLimits($this->_getScreenSize()); if (($imageLimits['content']) && is_array($imageLimits['content'])) { $this->_content = $imageLimits['content']; @@ -330,8 +361,8 @@ public function getInterfaceImageLimits() */ public function getImageSizeForInterface($imagePath) { - $size = 0; if (!isset($this->_interfacePath[$imagePath])) { + /** @var $app Mage_XmlConnect_Model_Application */ $app = Mage::helper('xmlconnect')->getApplication(); if (!$app) { return 0; @@ -473,11 +504,11 @@ public function filterScreenSize($screenSize) } $sourcePath = empty($version) ? Mage_XmlConnect_Model_Application::APP_SCREEN_SOURCE_DEFAULT : $version; - $xmlPath = 'screen_size/'.self::XMLCONNECT_GLUE.$resolution.'/'.$sourcePath.'/source'; + $xmlPath = 'screen_size/' . self::XMLCONNECT_GLUE . $resolution . '/' . $sourcePath . '/source'; $source = Mage::getStoreConfig($xmlPath); if (!empty($source)) { - $screenSize = $resolution . (empty($version) ? '' : self::XMLCONNECT_GLUE.$version); + $screenSize = $resolution . (empty($version) ? '' : self::XMLCONNECT_GLUE . $version); } else { $screenSize = Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_DEFAULT; } @@ -514,13 +545,13 @@ public function getImageLimits($screenSize = Mage_XmlConnect_Model_Application:: } $sourcePath = empty($version) ? $defaultScreenSource : $version; - $xmlPath = 'screen_size/'.self::XMLCONNECT_GLUE.$resolution.'/'.$sourcePath; + $xmlPath = 'screen_size/' . self::XMLCONNECT_GLUE . $resolution . '/' . $sourcePath; $root = Mage::getStoreConfig($xmlPath); - $updates = array(); + if (!empty($root)) { - $screenSize = $resolution . (empty($version) ? '' : self::XMLCONNECT_GLUE.$version); + $screenSize = $resolution . (empty($version) ? '' : self::XMLCONNECT_GLUE . $version); $source = !empty($root['source']) ? $root['source'] : $defaultScreenSource; $updates = isset($root['updates']) && is_array($root['updates']) ? $root['updates'] : array(); } else { @@ -528,7 +559,7 @@ public function getImageLimits($screenSize = Mage_XmlConnect_Model_Application:: $source = $defaultScreenSource; } - $imageLimits = Mage::getStoreConfig('screen_size/'.$source); + $imageLimits = Mage::getStoreConfig('screen_size/' . $source); if (!is_array($imageLimits)) { $imageLimits = Mage::getStoreConfig('screen_size/default'); } @@ -615,7 +646,7 @@ public function &findPath(&$array, $path) protected function _zoom(&$item, $key, $value) { if (is_string($item)) { - $item = (int) round($item*$value); + $item = (int) round($item * $value); } } @@ -640,7 +671,7 @@ protected function _verifyDirExist($dir) public function getCustomSizeUploadDir($screenSize) { $screenSize = $this->filterScreenSize($screenSize); - $customDir = $this->getMediaPath('custom' . DS .$screenSize); + $customDir = $this->getMediaPath('custom' . DS . $screenSize); $this->_verifyDirExist($customDir); return $customDir; } @@ -698,8 +729,9 @@ public function getInterfaceImagesPathsConf() } /** - * Return 1) default interface image path for specified $imagePath - * 2) array of image paths + * Return + * - default interface image path for specified $imagePath + * - array of image paths * * @param string $imagePath * @return array|string @@ -709,6 +741,7 @@ public function getInterfaceImagesPaths($imagePath = null) $paths = array ( 'conf/native/navigationBar/icon' => 'smallIcon_1_6.png', 'conf/native/body/bannerImage' => 'banner_1_2.png', + 'conf/native/body/bannerIpadLandscapeImage' => 'banner_ipad_l.png', 'conf/native/body/bannerIpadImage' => 'banner_ipad.png', 'conf/native/body/bannerAndroidImage' => 'banner_android.png', 'conf/native/body/backgroundImage' => 'accordion_open.png', diff --git a/app/code/core/Mage/XmlConnect/Helper/Ipad.php b/app/code/core/Mage/XmlConnect/Helper/Ipad.php index d95fa54ab9..f7d60ed6ef 100755 --- a/app/code/core/Mage/XmlConnect/Helper/Ipad.php +++ b/app/code/core/Mage/XmlConnect/Helper/Ipad.php @@ -35,71 +35,61 @@ class Mage_XmlConnect_Helper_Ipad extends Mage_Core_Helper_Abstract { /** * Submission title length - * - * @var int */ const SUBMISSION_TITLE_LENGTH = 200; /** * Submission description length - * - * @var int */ const SUBMISSION_DESCRIPTION_LENGTH = 500; /** * Ipad landscape orientation identificator - * - * @var string */ const ORIENTATION_LANDSCAPE = 'landscape'; /** * Ipad portrait orientation identificator - * - * @var string */ const ORIENTATION_PORTRAIT = 'portrait'; /** - * Ipad preview banner widht - * - * @var int + * Ipad portrait preview banner widht */ - const PREVIEW_BANNER_WIDTH = 350; + const PREVIEW_PORTRAIT_BANNER_WIDTH = 350; /** - * Ipad preview banner image height - * - * @var int + * Ipad portrait preview banner image height */ - const PREVIEW_BANNER_HEIGHT = 135; + const PREVIEW_PORTRAIT_BANNER_HEIGHT = 135; + + /** + * Ipad landscape preview banner widht + */ + const PREVIEW_LANDSCAPE_BANNER_WIDTH = 467; + + /** + * Ipad landscape preview banner image height + */ + const PREVIEW_LANDSCAPE_BANNER_HEIGHT = 157; /** * Ipad landscape orientation preview image widht - * - * @var int */ const PREVIEW_LANDSCAPE_BACKGROUND_WIDTH = 467; /** * Ipad landscape orientation preview image height - * - * @var int */ const PREVIEW_LANDSCAPE_BACKGROUND_HEIGHT = 321; /** * Ipad portrait orientation preview image widht - * - * @var int */ const PREVIEW_PORTRAIT_BACKGROUND_WIDTH = 350; /** * Ipad portrait orientation preview image height - * - * @var int */ const PREVIEW_PORTRAIT_BACKGROUND_HEIGHT = 438; @@ -578,8 +568,12 @@ public function validateConfig($native) $errors[] = Mage::helper('xmlconnect')->__('Please upload an image for "Logo in Header" field from Design Tab.'); } + if (!Mage::helper('xmlconnect')->validateConfFieldNotEmpty('bannerIpadLandscapeImage', $native)) { + $errors[] = Mage::helper('xmlconnect')->__('Please upload an image for "Banner on Home Screen (landscape mode)" field from Design Tab.'); + } + if (!Mage::helper('xmlconnect')->validateConfFieldNotEmpty('bannerIpadImage', $native)) { - $errors[] = Mage::helper('xmlconnect')->__('Please upload an image for "Banner on Home Screen" field from Design Tab.'); + $errors[] = Mage::helper('xmlconnect')->__('Please upload an image for "Banner on Home Screen (portrait mode)" field from Design Tab.'); } if (!Mage::helper('xmlconnect')->validateConfFieldNotEmpty('backgroundIpadLandscapeImage', $native)) { @@ -658,25 +652,31 @@ public function getCountryClass() */ public function checkImages(array $data) { - if (isset($data['conf']['native']['navigationBar']['icon']) && - !file_exists($data['conf']['native']['navigationBar']['icon']) + if (isset($data['conf']['native']['navigationBar']['icon']) + && !file_exists($data['conf']['native']['navigationBar']['icon']) ) { $data['conf']['native']['navigationBar']['icon'] = ''; } - if (isset($data['conf']['native']['body']['bannerIpadImage']) && - !file_exists($data['conf']['native']['body']['bannerIpadImage']) + if (isset($data['conf']['native']['body']['bannerIpadLandscapeImage']) + && !file_exists($data['conf']['native']['body']['bannerIpadLandscapeImage']) + ) { + $data['conf']['native']['body']['bannerIpadLandscapeImage'] = ''; + } + + if (isset($data['conf']['native']['body']['bannerIpadImage']) + && !file_exists($data['conf']['native']['body']['bannerIpadImage']) ) { $data['conf']['native']['body']['bannerIpadImage'] = ''; } - if (isset($data['conf']['native']['body']['backgroundIpadLandscapeImage']) && - !file_exists($data['conf']['native']['body']['backgroundIpadLandscapeImage']) + if (isset($data['conf']['native']['body']['backgroundIpadLandscapeImage']) + && !file_exists($data['conf']['native']['body']['backgroundIpadLandscapeImage']) ) { $data['conf']['native']['body']['backgroundIpadLandscapeImage'] = ''; } - if (isset($data['conf']['native']['body']['backgroundIpadPortraitImage']) && - !file_exists($data['conf']['native']['body']['backgroundIpadPortraitImage']) + if (isset($data['conf']['native']['body']['backgroundIpadPortraitImage']) + && !file_exists($data['conf']['native']['body']['backgroundIpadPortraitImage']) ) { $data['conf']['native']['body']['backgroundIpadPortraitImage'] = ''; } @@ -707,7 +707,14 @@ public function checkRequiredConfigFields($data) && empty($data['body']['bannerIpadImage']) ) { Mage::throwException( - Mage::helper('xmlconnect')->__('Banner on Home Screen image missing.') + Mage::helper('xmlconnect')->__('Banner on Home Screen (portrait mode) image missing.') + ); + } + if (isset($data['body']['bannerIpadLandscapeImage']) + && empty($data['body']['bannerIpadLandscapeImage']) + ) { + Mage::throwException( + Mage::helper('xmlconnect')->__('Banner on Home Screen (landscape mode) image missing.') ); } if (isset($data['body']['backgroundIpadLandscapeImage']) diff --git a/app/code/core/Mage/XmlConnect/Helper/Iphone.php b/app/code/core/Mage/XmlConnect/Helper/Iphone.php index 1477ade214..9f81f57858 100644 --- a/app/code/core/Mage/XmlConnect/Helper/Iphone.php +++ b/app/code/core/Mage/XmlConnect/Helper/Iphone.php @@ -35,29 +35,21 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_Core_Helper_Abstract { /** * Submission title length - * - * @var int */ const SUBMISSION_TITLE_LENGTH = 12; /** * Submission description length - * - * @var int */ const SUBMISSION_DESCRIPTION_LENGTH = 500; /** * Country renderer for submission page - * - * @var string */ const SUBMISSION_COUNTRY_RENDERER = 'istore'; /** * Country columns for submission page - * - * @var int */ const SUBMISSION_COUNTRY_COLUMNS = 4; @@ -86,96 +78,96 @@ class Mage_XmlConnect_Helper_Iphone extends Mage_Core_Helper_Abstract * @var array */ protected $_allowedCountries = array( - 'Argentina' => 'AR', - 'Armenia' => 'AM', - 'Australia' => 'AU', - 'Austria' => 'AT', - 'Belgium' => 'BE', - 'Botswana' => 'BW', - 'Brazil' =>'BR', - 'Bulgaria' => 'BG', - 'Canada' => 'CA', - 'Chile' => 'CL', - 'China' => 'CN', - 'Colombia' => 'CO', - 'Costa Rica' => 'CR', - 'Croatia' => 'HR', - 'Czech Republic' => 'CZ', - 'Denmark' => 'DK', - 'Dominican Republic' => 'DO', - 'Ecuador' => 'EC', - 'Egypt' => 'EG', - 'El Salvador' => 'SV', - 'Estonia' => 'EE', - 'Finland' => 'FI', - 'France' => 'FR', - 'Germany' => 'DE', - 'Greece' => 'GR', - 'Guatemala' => 'GT', - 'Honduras' => 'HN', - 'Hong Kong SAR China' => 'HK', - 'Hungary' => 'HU', - 'India' => 'IN', - 'Indonesia' => 'ID', - 'Ireland' => 'IE', - 'Israel' => 'IL', - 'Italy' => 'IT', - 'Jamaica' => 'JM', - 'Japan' => 'JP', - 'Jordan' => 'JO', - 'Kazakstan' => 'KZ', - 'Kenya' => 'KE', - 'South Korea' => 'KR', - 'Kuwait' => 'KW', - 'Latvia' => 'LV', - 'Lebanon' => 'LB', - 'Lithuania' => 'LT', - 'Luxembourg' => 'LU', - 'Macau SAR China' => 'MO', - 'Macedonia' => 'MK', - 'Madagascar' => 'MG', - 'Malaysia' => 'MY', - 'Mali' => 'ML', - 'Malta' => 'MT', - 'Mauritius' => 'MU', - 'Mexico' => 'MX', - 'Moldova' => 'MD', - 'Netherlands' => 'NL', - 'New Zealand' => 'NZ', - 'Nicaragua' => 'NI', - 'Niger' => 'NE', - 'Norway' => 'NO', - 'Pakistan' => 'PK', - 'Panama' => 'PA', - 'Paraguay' => 'PY', - 'Peru'=> 'PE', - 'Philippines' => 'PH', - 'Poland' => 'PL', - 'Portugal' => 'PT', - 'Qatar' => 'QA', - 'Romania' => 'RO', - 'Russia' => 'RU', - 'Saudi Arabia' => 'SA', - 'Senegal' => 'SN', - 'Singapore' => 'SG', - 'Slovakia' => 'SK', - 'Slovenia' => 'SI', - 'South Africa' => 'ZA', - 'Spain' => 'ES', - 'Sri Lanka' => 'LK', - 'Sweden' => 'SE', - 'Switzerland' => 'CH', - 'Taiwan' => 'TW', - 'Thailand' => 'TH', - 'Tunisia' => 'TN', - 'Turkey' => 'TR', - 'Uganda' => 'UG', - 'United Arab Emirates' => 'AE', - 'United Kingdom' => 'GB', - 'United States' => 'US', - 'Uruguay' => 'UY', - 'Venezuela' => 'VE', - 'Vietnam' => 'VN', + 'Argentina' => 'AR', + 'Armenia' => 'AM', + 'Australia' => 'AU', + 'Austria' => 'AT', + 'Belgium' => 'BE', + 'Botswana' => 'BW', + 'Brazil' => 'BR', + 'Bulgaria' => 'BG', + 'Canada' => 'CA', + 'Chile' => 'CL', + 'China' => 'CN', + 'Colombia' => 'CO', + 'Costa Rica' => 'CR', + 'Croatia' => 'HR', + 'Czech Republic' => 'CZ', + 'Denmark' => 'DK', + 'Dominican Republic' => 'DO', + 'Ecuador' => 'EC', + 'Egypt' => 'EG', + 'El Salvador' => 'SV', + 'Estonia' => 'EE', + 'Finland' => 'FI', + 'France' => 'FR', + 'Germany' => 'DE', + 'Greece' => 'GR', + 'Guatemala' => 'GT', + 'Honduras' => 'HN', + 'Hong Kong SAR China' => 'HK', + 'Hungary' => 'HU', + 'India' => 'IN', + 'Indonesia' => 'ID', + 'Ireland' => 'IE', + 'Israel' => 'IL', + 'Italy' => 'IT', + 'Jamaica' => 'JM', + 'Japan' => 'JP', + 'Jordan' => 'JO', + 'Kazakstan' => 'KZ', + 'Kenya' => 'KE', + 'South Korea' => 'KR', + 'Kuwait' => 'KW', + 'Latvia' => 'LV', + 'Lebanon' => 'LB', + 'Lithuania' => 'LT', + 'Luxembourg' => 'LU', + 'Macau SAR China' => 'MO', + 'Macedonia' => 'MK', + 'Madagascar' => 'MG', + 'Malaysia' => 'MY', + 'Mali' => 'ML', + 'Malta' => 'MT', + 'Mauritius' => 'MU', + 'Mexico' => 'MX', + 'Moldova' => 'MD', + 'Netherlands' => 'NL', + 'New Zealand' => 'NZ', + 'Nicaragua' => 'NI', + 'Niger' => 'NE', + 'Norway' => 'NO', + 'Pakistan' => 'PK', + 'Panama' => 'PA', + 'Paraguay' => 'PY', + 'Peru' => 'PE', + 'Philippines' => 'PH', + 'Poland' => 'PL', + 'Portugal' => 'PT', + 'Qatar' => 'QA', + 'Romania' => 'RO', + 'Russia' => 'RU', + 'Saudi Arabia' => 'SA', + 'Senegal' => 'SN', + 'Singapore' => 'SG', + 'Slovakia' => 'SK', + 'Slovenia' => 'SI', + 'South Africa' => 'ZA', + 'Spain' => 'ES', + 'Sri Lanka' => 'LK', + 'Sweden' => 'SE', + 'Switzerland' => 'CH', + 'Taiwan' => 'TW', + 'Thailand' => 'TH', + 'Tunisia' => 'TN', + 'Turkey' => 'TR', + 'Uganda' => 'UG', + 'United Arab Emirates' => 'AE', + 'United Kingdom' => 'GB', + 'United States' => 'US', + 'Uruguay' => 'UY', + 'Venezuela' => 'VE', + 'Vietnam' => 'VN', ); /** diff --git a/app/code/core/Mage/XmlConnect/Helper/Theme.php b/app/code/core/Mage/XmlConnect/Helper/Theme.php index a3be3f7212..2414d0a2b5 100644 --- a/app/code/core/Mage/XmlConnect/Helper/Theme.php +++ b/app/code/core/Mage/XmlConnect/Helper/Theme.php @@ -24,6 +24,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +/** + * Theme helper + * + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team + */ class Mage_XmlConnect_Helper_Theme extends Mage_Adminhtml_Helper_Data { /** @@ -87,21 +94,83 @@ public function getAllThemesArray($flushCache = false) return $result; } + /** + * Get dropdown select image for theme + * + * @param string $themeId + * @return string Image url + */ + public function getThemeImageUrl($themeId) + { + $themeImage = array_key_exists($themeId, $this->getDefaultThemes()) ? $themeId : 'user_custom'; + return Mage::helper('xmlconnect/image')->getSkinImagesUrl('swatch_' . $themeImage . '.gif'); + } + + /** + * Get themes dropdown selector html + * + * @param string $themeId + * @return string + */ + public function getThemesSelector($themeId = '') + { + if (Mage::registry('current_app') !== null) { + $themeId = Mage::registry('current_app')->getData('conf/extra/theme'); + } + + if (!$themeId) { + $themeId = $this->getDefaultThemeName(); + } + + $currentTheme = $this->getThemeByName($themeId); + if ($currentTheme === null) { + $themeId = $this->getDefaultThemeName(); + $currentTheme = $this->getThemeByName($themeId); + } + + $themeList = ''; + foreach ($this->getAllThemes(true) as $theme) { + $themeList .= '
  • '; + $themeList .= '' . $theme->getLabel(); + $themeList .= ''; + $themeList .= ''; + $themeList .= '
  • '; + } + + $themesDdl = << +
  • + {$currentTheme->getLabel()} + + + + +
  • + + +EOT; + return $themesDdl; + } + /** * Reads directory media/xmlconnect/themes/* * * @param bool $flushCache Reads default color Themes - * @return array - (of Mage_XmlConnect_Model_Theme) + * @return array contains Mage_XmlConnect_Model_Theme */ public function getAllThemes($flushCache = false) { if (!$this->_themeArray || $flushCache) { - $saveLibxmlErrors = libxml_use_internal_errors(TRUE); - $this->_themeArray = array(); - $themeDir = Mage::getBaseDir('media') . DS . 'xmlconnect' . DS . 'themes'; + $saveLibxmlErrors = libxml_use_internal_errors(true); + $this->_themeArray = array(); + $themeDir = $this->getMediaThemePath(); $io = new Varien_Io_File(); + $io->checkAndCreateFolder($themeDir); $io->open(array('path' => $themeDir)); - try { $fileList = $io->ls(Varien_Io_File::GREP_FILES); if (!count($fileList)) { @@ -115,6 +184,7 @@ public function getAllThemes($flushCache = false) $this->_themeArray[$theme->getName()] = $theme; } } + asort($this->_themeArray); libxml_use_internal_errors($saveLibxmlErrors); } catch (Exception $e) { Mage::logException($e); @@ -123,20 +193,89 @@ public function getAllThemes($flushCache = false) return $this->_themeArray; } + /** + * Reads default theme directory + * + * @throws Mage_Core_Exception + * @return array contains Mage_XmlConnect_Model_Theme + */ + public function getDefaultThemes() + { + $saveLibxmlErrors = libxml_use_internal_errors(true); + $defaultThemeArray = array(); + $themeDir = $this->_getDefaultThemePath(); + $io = new Varien_Io_File(); + $io->open(array('path' => $themeDir)); + try { + $fileList = $io->ls(Varien_Io_File::GREP_FILES); + foreach ($fileList as $file) { + $src = $themeDir . DS . $file['text']; + if (is_readable($src)) { + $theme = Mage::getModel('xmlconnect/theme', $src); + $defaultThemeArray[$theme->getName()] = $theme; + } + } + libxml_use_internal_errors($saveLibxmlErrors); + } catch (Exception $e) { + Mage::logException($e); + } + if (!count($defaultThemeArray)) { + Mage::throwException( + Mage::helper('xmlconnect')->__('Can\'t load default themes.') + ); + } + return $defaultThemeArray; + } + + /** + * Create new custom theme + * + * @param $themeName string + * @param $data array + * @return Mage_XmlConnect_Model_Theme + */ + public function createNewTheme($themeName, $data) + { + /** @var $defaultTheme Mage_XmlConnect_Model_Theme */ + $defaultTheme = $this->getThemeByName($this->getDefaultThemeName()); + return $defaultTheme->createNewTheme($themeName, $data); + } + + /** + * Get default theme path: /xmlconnect/etc/themes/* + * + * @return string + */ + protected function _getDefaultThemePath() + { + return Mage::getModuleDir('etc', 'Mage_XmlConnect') . DS . 'themes'; + } + + /** + * Get media theme path: media/xmlconnect/themes/* + * + * @return string + */ + public function getMediaThemePath() + { + return Mage::getBaseDir('media') . DS . 'xmlconnect' . DS . 'themes'; + } + /** * Reset themes color changes * Copy /xmlconnect/etc/themes/* to media/xmlconnect/themes/* * * @throws Mage_Core_Exception + * @param null $theme * @return void */ public function resetTheme($theme = null) { - $themeDir = Mage::getBaseDir('media') . DS . 'xmlconnect' . DS . 'themes'; - $defaultThemeDir = Mage::getModuleDir('etc', 'Mage_XmlConnect') . DS . 'themes'; + $themeDir = $this->getMediaThemePath(); + $defaultThemeDir = $this->_getDefaultThemePath(); $io = new Varien_Io_File(); - $io->open(array('path'=>$defaultThemeDir)); + $io->open(array('path' => $defaultThemeDir)); $fileList = $io->ls(Varien_Io_File::GREP_FILES); foreach ($fileList as $file) { $f = $file['text']; @@ -198,6 +337,11 @@ public function getDefaultThemeName() public function getThemeId() { $themeId = Mage::helper('xmlconnect')->getApplication()->getData('conf/extra/theme'); + + if ($this->getThemeByName($themeId) === null) { + $themeId = null; + } + if (empty($themeId)) { $themeId = $this->getDefaultThemeName(); } @@ -224,4 +368,22 @@ public function getThemeLabel(array $themes, $themeId = false) } return $themeLabel; } + + /** + * Delete theme by id + * + * @param $themeId + * @return bool + */ + public function deleteTheme($themeId) + { + $result = false; + $io = new Varien_Io_File(); + $io->cd($this->getMediaThemePath()); + $themeFile = $themeId . '.xml'; + if ($io->fileExists($themeFile)) { + $result = $io->rm($themeFile); + } + return $result; + } } diff --git a/app/code/core/Mage/XmlConnect/Model/Application.php b/app/code/core/Mage/XmlConnect/Model/Application.php index 88cfa15cf0..acfe8712a1 100644 --- a/app/code/core/Mage/XmlConnect/Model/Application.php +++ b/app/code/core/Mage/XmlConnect/Model/Application.php @@ -42,8 +42,6 @@ * @method Mage_XmlConnect_Model_Application setActiveTo(string $value) * @method string getUpdatedAt() * @method Mage_XmlConnect_Model_Application setUpdatedAt(string $value) - * @method string getConfiguration() - * @method Mage_XmlConnect_Model_Application setConfiguration(string $value) * @method int getStatus() * @method Mage_XmlConnect_Model_Application setStatus(int $value) * @method int getBrowsingMode() @@ -57,50 +55,36 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract { /** * Application code cookie name - * - * @var string */ const APP_CODE_COOKIE_NAME = 'app_code'; /** * Device screen size name - * - * @var string */ const APP_SCREEN_SIZE_NAME = 'screen_size'; /** * Device screen size name - * - * @var string */ const APP_SCREEN_SIZE_DEFAULT = '320x480'; /** * Device screen size source name - * - * @var string */ const APP_SCREEN_SOURCE_DEFAULT = 'default'; /** * Application status "submitted" value - * - * @var int */ const APP_STATUS_SUCCESS = 1; /** * Application status "not submitted" value - * - * @var int */ const APP_STATUS_INACTIVE = 0; /** * Application prefix length of cutted part of deviceType and storeCode - * - * @var int */ const APP_PREFIX_CUT_LENGTH = 3; @@ -135,10 +119,18 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract /** * Main configuration of current application * + * @deprecated Serialized config storage has been removed * @var null|array */ protected $conf; + /** + * Configuration model + * + * @var Mage_XmlConnect_Model_ConfigData + */ + protected $_configModel; + /** * Social networking validation array * @@ -157,8 +149,6 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract /** * Submission/Resubmission key max length - * - * @var int */ const APP_MAX_KEY_LENGTH = 40; @@ -166,104 +156,92 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract * XML path to config with an email address * for contact to receive credentials * of Urban Airship notifications - * - * @var string */ const XML_PATH_CONTACT_CREDENTIALS_EMAIL = 'xmlconnect/mobile_application/urbanairship_credentials_email'; /** * XML path to config with Urban Airship Terms of Service URL - * - * @var string */ const XML_PATH_URBAN_AIRSHIP_TOS_URL = 'xmlconnect/mobile_application/urbanairship_terms_of_service_url'; /** * XML path to config with Urban Airship partner's login URL - * - * @var string */ const XML_PATH_URBAN_AIRSHIP_PARTNER_LOGIN_URL = 'xmlconnect/mobile_application/urbanairship_login_url'; /** * XML path to config with Urban Airship Push notifications product URL - * - * @var string */ const XML_PATH_URBAN_AIRSHIP_ABOUT_PUSH_URL = 'xmlconnect/mobile_application/urbanairship_push_url'; /** * XML path to config with Urban Airship Rich Push notifications product URL - * - * @var string */ const XML_PATH_URBAN_AIRSHIP_ABOUT_RICH_PUSH_URL = 'xmlconnect/mobile_application/urbanairship_rich_push_url'; /** * XML path to config copyright data - * - * @var string */ const XML_PATH_DESIGN_FOOTER_COPYRIGHT = 'design/footer/copyright'; /** * XML path to config restriction status * (EE module) - * - * @var string */ const XML_PATH_GENERAL_RESTRICTION_IS_ACTIVE = 'general/restriction/is_active'; /** * XML path to config restriction mode * (EE module) - * - * @var string */ const XML_PATH_GENERAL_RESTRICTION_MODE = 'general/restriction/mode'; /** * XML path to config secure base link URL - * - * @var string */ const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url'; /** * XML path to config for paypal business account - * - * @var string */ const XML_PATH_PAYPAL_BUSINESS_ACCOUNT = 'paypal/general/business_account'; /** * XML path to config for default cache time - * - * @var string */ const XML_PATH_DEFAULT_CACHE_LIFETIME = 'xmlconnect/mobile_application/cache_lifetime'; /** * XML path to How-To URL for twitter - * - * @var string */ const XML_PATH_HOWTO_TWITTER_URL = 'xmlconnect/social_networking/howto_twitter_url'; /** * XML path to How-To URL for facebook - * - * @var string */ const XML_PATH_HOWTO_FACEBOOK_URL = 'xmlconnect/social_networking/howto_facebook_url'; /** * XML path to How-To URL for linkedin - * - * @var string */ const XML_PATH_HOWTO_LINKEDIN_URL = 'xmlconnect/social_networking/howto_linkedin_url'; + /** + * Deprecated config flag + * + * @deprecated Serialized config storage has been removed + */ + const DEPRECATED_CONFIG_FLAG = 'deprecated'; + + /** + * Delete on update paths for config data + * + * @var array + */ + protected $_deleteOnUpdateConfig = array( + self::DEPRECATED_CONFIG_FLAG => 'native/pages' + ); + /** * Initialize application * @@ -272,6 +250,10 @@ class Mage_XmlConnect_Model_Application extends Mage_Core_Model_Abstract protected function _construct() { $this->_init('xmlconnect/application'); + $this->_configModel = Mage::getModel('xmlconnect/configData'); + $this->_configModel->setDeleteOnUpdate( + $this->getDeleteOnUpdateConfig() + ); } /** @@ -384,6 +366,7 @@ public function isCodePrefixed() /** * Load application configuration * + * @deprecated Serialized config storage has been removed * @return array */ public function prepareConfiguration() @@ -606,6 +589,16 @@ public function getPages() return array(); } + /** + * Get configuration model + * + * @return Mage_XmlConnect_Model_ConfigData + */ + public function getConfigModel() + { + return $this->_configModel; + } + /** * Processing object before save data * @@ -613,12 +606,82 @@ public function getPages() */ protected function _beforeSave() { - $conf = serialize($this->prepareConfiguration()); - $this->setConfiguration($conf); - $this->setUpdatedAt(date('Y-m-d H:i:s', time())); + $this->setUpdatedAt( + Mage::getSingleton('core/date')->gmtDate() + ); + return $this; + } + + /** + * Processing object after save data + * + * @return Mage_XmlConnect_Model_Application + */ + protected function _afterSave() + { + $this->_saveConfigData(); + $this->_saveDeprecatedConfig(); + parent::_afterSave(); + return $this; + } + + /** + * Save configuration data of application model + * + * @return Mage_XmlConnect_Model_Application + */ + protected function _saveConfigData() + { + $configuration = $this->getData('config_data'); + if (is_array($configuration)) { + $this->getConfigModel() + ->setConfigData($this->getId(), $configuration) + ->initSaveConfig(); + } + return $this; + } + + /** + * Save old deprecated config to application config data table + * + * @deprecated Serialized config storage has been removed + * @return Mage_XmlConnect_Model_Application + */ + private function _saveDeprecatedConfig() + { + $deprecatedConfig = $this->getData('conf'); + if (is_array($deprecatedConfig)) { + $this->getConfigModel()->saveConfig( + $this->getId(), + $this->convertOldConfing($deprecatedConfig), + self::DEPRECATED_CONFIG_FLAG + ); + } return $this; } + /** + * Convert deprecated configuration array to new standard + * + * @deprecated Serialized config storage has been removed + * @param array $conf + * @param bool $path + * @return array + */ + public function convertOldConfing(array $conf, $path = false) + { + $result = array(); + foreach ($conf as $key => $val) { + $key = $path ? $path . '/' . $key : $key; + if (is_array($val)) { + $result += $this->convertOldConfing($val, $key); + } else { + $result[$key] = $val; + } + } + return $result; + } + /** * Load configuration data (from serialized blob) * @@ -627,18 +690,85 @@ protected function _beforeSave() public function loadConfiguration() { static $isConfigurationLoaded = null; - if (is_null($isConfigurationLoaded)) { - $configuration = $this->getConfiguration(); - if (!empty($configuration)) { - $configuration = unserialize($configuration); - $this->setData('conf', $configuration); + if ($this->getId()) { + $this->_loadDeprecatedConfig() + ->_loadConfigData(); $isConfigurationLoaded = true; } } return $this; } + /** + * Load configuration data + * + * @internal re-factoring in progress + * @return Mage_XmlConnect_Model_Application + */ + protected function _loadConfigData() + { + $configuration = $this->getConfigModel() + ->getCollection() + ->addArrayFilter( + array( + 'application_id' => $this->getId(), + 'category' => 'payment' + ) + ) + ->toOptionArray(); + $this->setData('config_data', $configuration); + return $this; + } + + /** + * Load deprecated configuration + * + * @deprecated Serialized config storage has been removed + * @return Mage_XmlConnect_Model_Application + */ + private function _loadDeprecatedConfig() + { + $configuration = $this->_convertConfig( + $this->getConfigModel() + ->getCollection() + ->addArrayFilter( + array( + 'application_id' => $this->getId(), + 'category' => self::DEPRECATED_CONFIG_FLAG + ) + ) + ->toOptionArray() + ); + $this->setData('conf', $configuration); + return $this; + } + + /** + * Convert old config data array + * + * @deprecated Serialized config storage has been removed + * @param $config + * @return array + */ + protected function _convertConfig($config) + { + $result = array(); + foreach ($config as $values) { + foreach ($values as $path => $value) { + if (preg_match('@[^\w\/]@', $path)) { + Mage::throwException( + Mage::helper('xmlconnect')->__('Unsupported character in path: "%s"', $path) + ); + } + $keyArray = explode('/', $path); + $keys = '$result["' . implode('"]["', $keyArray) . '"]'; + eval($keys . ' = $value;'); + } + } + return $result; + } + /** * Load application by code * @@ -988,4 +1118,26 @@ public function getCacheLifetime() $lifetime = (int)$this->loadConfiguration()->getData('conf/native/cacheLifetime'); return $lifetime <= 0 ? '' : $lifetime; } + + /** + * Get delete on update paths for config data + * + * @return array + */ + public function getDeleteOnUpdateConfig() + { + return $this->_deleteOnUpdateConfig; + } + + /** + * Set delete on update paths for config data + * + * @param array $pathsToDelete + * @return Mage_XmlConnect_Model_Application + */ + public function setDeleteOnUpdateConfig(array $pathsToDelete) + { + $this->_deleteOnUpdateConfig = array_merge($this->_deleteOnUpdateConfig, $pathsToDelete); + return $this; + } } diff --git a/app/code/core/Mage/XmlConnect/Model/ConfigData.php b/app/code/core/Mage/XmlConnect/Model/ConfigData.php new file mode 100644 index 0000000000..3f0949cde7 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Model/ConfigData.php @@ -0,0 +1,221 @@ + + */ +class Mage_XmlConnect_Model_ConfigData extends Mage_Core_Model_Abstract +{ + /** + * Default category + */ + const DEFAULT_CATEGORY = 'default'; + + /** + * Configuration prefix + */ + const CONFIG_PREFIX = 'app_'; + + /** + * Delete on update paths array + * + * @var array + */ + protected $_deleteOnUpdate = array(); + + /** + * Configuration data + * + * @var array + */ + protected $_configuration = array(); + + /** + * Initialize configuration data + * + * @return void + */ + protected function _construct() + { + $this->_init('xmlconnect/configData'); + } + + /** + * Create an array that will be stored in configuration data + * + * Create an array: application id with a prefix as key and + * configuration data as value + * + * @param $applicationId + * @param $configData + * @return array + */ + protected function _assignConfig($applicationId, $configData) + { + return array(self::CONFIG_PREFIX . $applicationId => $configData); + } + + /** + * Prepare posted data to store at configuration. + * + * Posted data have to be in predefined format: + * - array('category:config/path/param' => 'value') + * where : is a separator of category + * - array('config/path/param' => 'value') + * if key doesn't have a separator category will be set as default + * + * @param $configuration posted data array + * @return array configuration data array + */ + protected function _prepareData($configuration) + { + $configData = array(); + foreach ($configuration as $key => $val) { + list($category, $path) = explode(':', $key, 2) + array('', ''); + if (empty($path)) { + $path = $category; + $category = self::DEFAULT_CATEGORY; + } + $val = is_array($val) ? implode(',', $val) : $val; + $configData[strtolower($category)][strtolower($path)] = $val; + } + return $configData; + } + + /** + * Prepare and set configuration data + * + * @param $applicationId + * @param array $configData + * @param bool $replace + * @return Mage_XmlConnect_Model_ConfigData + */ + public function setConfigData($applicationId, array $configData, $replace = true) + { + $configData = $this->_prepareData($configData); + $arrayToStore = $this->_assignConfig($applicationId, $configData); + if ($replace) { + $this->_configuration = array_merge($this->_configuration, $arrayToStore); + } else { + $this->_configuration = $this->_configuration + $arrayToStore; + } + return $this; + } + + /** + * Get configuration data + * + * @param bool $applicationId + * @return array + */ + public function getConfigData($applicationId = false) + { + if ($applicationId && isset($this->_configuration[self::CONFIG_PREFIX . $applicationId])) { + return $this->_configuration[self::CONFIG_PREFIX . $applicationId]; + } + return $this->_configuration; + } + + /** + * Save predefined configuration data + * + * @return Mage_XmlConnect_Model_ConfigData + */ + public function initSaveConfig() + { + foreach ($this->_configuration as $application => $data) { + $applicationId = str_ireplace(self::CONFIG_PREFIX, '', $application); + $this->_deleteOnUpdate($applicationId); + foreach ($data as $category => $config) { + $this->saveConfig( + $applicationId, + $config, + $category + ); + } + } + return $this; + } + + /** + * Save configuration data by given params + * + * @param $applicationId + * @param array $configData + * @param string $category + * @return Mage_XmlConnect_Model_ConfigData + */ + public function saveConfig($applicationId, array $configData, $category = self::DEFAULT_CATEGORY) + { + foreach ($configData as $path => $value) { + if (!is_scalar($value)) { + Mage::throwException( + Mage::helper('xmlconnect')->__('Unsupported value type received') + ); + } + $this->getResource()->saveConfig($applicationId, $category, $path, $value); + } + return $this; + } + + /** + * Get delete on update array paths + * + * @return array + */ + public function getDeleteOnUpdate() + { + return $this->_deleteOnUpdate; + } + + /** + * Set delete on update array paths + * + * @param array $pathsToDelete + * @return Mage_XmlConnect_Model_ConfigData + */ + public function setDeleteOnUpdate(array $pathsToDelete) + { + $this->_deleteOnUpdate = array_merge($this->_deleteOnUpdate, $pathsToDelete); + return $this; + } + + /** + * @param $applicationId + * @return Mage_XmlConnect_Model_ConfigData + */ + protected function _deleteOnUpdate($applicationId) + { + foreach ($this->_deleteOnUpdate as $category => $path) { + $this->getResource()->deleteConfig($applicationId, $category, $path); + } + return $this; + } +} diff --git a/app/code/core/Mage/XmlConnect/Model/Mysql4/Category/Collection.php b/app/code/core/Mage/XmlConnect/Model/Mysql4/ConfigData.php similarity index 85% rename from app/code/core/Mage/XmlConnect/Model/Mysql4/Category/Collection.php rename to app/code/core/Mage/XmlConnect/Model/Mysql4/ConfigData.php index fbffeace85..d86f5d2fc0 100644 --- a/app/code/core/Mage/XmlConnect/Model/Mysql4/Category/Collection.php +++ b/app/code/core/Mage/XmlConnect/Model/Mysql4/ConfigData.php @@ -25,12 +25,12 @@ */ /** - * Category resource collection + * Configuration data recourse model * * @category Mage - * @package Mage_XmlConnect + * @package Mage_Xmlconnect * @author Magento Core Team */ -class Mage_XmlConnect_Model_Mysql4_Category_Collection extends Mage_XmlConnect_Model_Resource_Category_Collection +class Mage_XmlConnect_Model_Mysql4_ConfigData extends Mage_XmlConnect_Model_Resource_ConfigData { } diff --git a/app/code/core/Mage/Wishlist/Model/Resource/Helper/Mysql4.php b/app/code/core/Mage/XmlConnect/Model/Mysql4/ConfigData/Collection.php similarity index 59% rename from app/code/core/Mage/Wishlist/Model/Resource/Helper/Mysql4.php rename to app/code/core/Mage/XmlConnect/Model/Mysql4/ConfigData/Collection.php index 38760decce..79608a5c10 100644 --- a/app/code/core/Mage/Wishlist/Model/Resource/Helper/Mysql4.php +++ b/app/code/core/Mage/XmlConnect/Model/Mysql4/ConfigData/Collection.php @@ -19,33 +19,19 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Wishlist + * @package Mage_XmlConnect * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - /** - * Resource helper for MySQL database engine + * Configuration data collection * * @category Mage - * @package Mage_Wishlist + * @package Mage_Xmlconnect * @author Magento Core Team */ -class Mage_Wishlist_Model_Resource_Helper_Mysql4 extends Mage_Core_Model_Resource_Helper_Mysql4 +class Mage_XmlConnect_Model_Mysql4_ConfigData_Collection + extends Mage_XmlConnect_Model_Resource_ConfigData_Collection { - /** - * Retrieve SQL fragment to calculate days in wishlist depending on current store settings - * - * @return Zend_Db_Expr - */ - public function getDaysInWishlist() - { - $offsetFromDb = (int) Mage::getSingleton('core/date')->getGmtOffset(); - $startDate = "DATE_ADD(added_at, INTERVAL " . $offsetFromDb . " SECOND)"; - - $nowDate = Mage::getSingleton('core/date')->date(); - - return $this->getDateDiff($startDate, $this->_getReadAdapter()->formatDate($nowDate)); - } } diff --git a/app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Mep.php b/app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Mep.php index 489bb2a744..249a23d465 100644 --- a/app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Mep.php +++ b/app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Mep.php @@ -25,10 +25,11 @@ */ /** - * * PayPal Mobile Embedded Payments Checkout Module * - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_Model_Payment_Method_Paypal_Mep extends Mage_Paypal_Model_Express { @@ -51,7 +52,7 @@ class Mage_XmlConnect_Model_Payment_Method_Paypal_Mep extends Mage_Paypal_Model_ protected $_canManageRecurringProfiles = false; /** - * Get config peyment action url + * Get config payment action url * Used to universalize payment actions when processing payment place * * @return string @@ -94,8 +95,20 @@ public function isAvailable($quote = null) */ public function capture(Varien_Object $payment, $amount) { - $transactionId = $payment->getAdditionalInformation(Mage_XmlConnect_Model_Paypal_Mep_Checkout::PAYMENT_INFO_TRANSACTION_ID); + $transactionId = $payment->getAdditionalInformation( + Mage_XmlConnect_Model_Paypal_Mep_Checkout::PAYMENT_INFO_TRANSACTION_ID + ); $payment->setTransactionId($transactionId); return $this; } + + /** + * Return title of the PayPal Mobile Embedded Payment method + * + * @return string + */ + public function getTitle() + { + return Mage::helper('xmlconnect')->__('PayPal MEP'); + } } diff --git a/app/code/core/Mage/XmlConnect/Model/Paypal/Mep/Checkout.php b/app/code/core/Mage/XmlConnect/Model/Paypal/Mep/Checkout.php index 70aa22861b..38d05eb318 100644 --- a/app/code/core/Mage/XmlConnect/Model/Paypal/Mep/Checkout.php +++ b/app/code/core/Mage/XmlConnect/Model/Paypal/Mep/Checkout.php @@ -36,8 +36,6 @@ class Mage_XmlConnect_Model_Paypal_Mep_Checkout /**#@+ * Keys for passthrough variables in sales/quote_payment and sales/order_payment * Uses additional_information as storage - * - * @var string */ const PAYMENT_INFO_PAYER_EMAIL = 'paypal_payer_email'; const PAYMENT_INFO_TRANSACTION_ID = 'paypal_mep_checkout_transaction_id'; @@ -136,11 +134,21 @@ public function saveShipping($data) $address = $this->_quote->getBillingAddress(); $this->_applyCountryWorkarounds($data); - if (!in_array($data['country_id'], Mage::getModel('paypal/config')->getSupportedBuyerCountryCodes())) { - return array( - 'error' => 1, - 'message' => Mage::helper('xmlconnect')->__('Buyer country is not allowed by store.') - ); + /** @var $model Mage_XmlConnect_Model_Application */ + $model = Mage::helper('xmlconnect')->getApplication(); + + $paypalMepAllowSpecific = $model->getData('config_data[payment:paypalmep/allowspecific]'); + if ($paypalMepAllowSpecific !== null) { + if ((int)$paypalMepAllowSpecific > 0) { + $allowedCountries = explode(',', $model->getData('config_data[payment][paypalmep/applicable]')); + $allowedCountries = array_map('trim', $allowedCountries); + if (!in_array(trim($data['country_id']), $allowedCountries)) { + return array( + 'error' => 1, + 'message' => Mage::helper('xmlconnect')->__('Buyer country is not allowed by store.') + ); + } + } } if (empty($data['firstname']) && empty($data['lastname'])) { @@ -186,11 +194,14 @@ public function saveShippingMethod($shippingMethod) if (empty($shippingMethod)) { return array('error' => 1, 'message' => Mage::helper('xmlconnect')->__('Invalid shipping method.')); } + $rate = $this->_quote->getShippingAddress()->getShippingRateByCode($shippingMethod); if (!$rate) { return array('error' => 1, 'message' => Mage::helper('xmlconnect')->__('Invalid shipping method.')); } - if (!$this->_quote->getIsVirtual() && $shippingAddress = $this->_quote->getShippingAddress()) { + + $shippingAddress = $this->_quote->getShippingAddress(); + if (!$this->_quote->getIsVirtual() && $shippingAddress) { if ($shippingMethod != $shippingAddress->getShippingMethod()) { $this->_ignoreAddressValidation(); $this->_quote->getShippingAddress() @@ -257,7 +268,9 @@ public function saveOrder() ->setLastOrderId($order->getId()) ->setLastRealOrderId($order->getIncrementId()); - if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) { + if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING + && Mage::getSingleton('customer/session')->isLoggedIn() + ) { try { $order->sendNewOrderEmail(); } catch (Exception $e) { diff --git a/app/code/core/Mage/XmlConnect/Model/Preview/Ipad.php b/app/code/core/Mage/XmlConnect/Model/Preview/Ipad.php index b420564712..60aa8cb210 100755 --- a/app/code/core/Mage/XmlConnect/Model/Preview/Ipad.php +++ b/app/code/core/Mage/XmlConnect/Model/Preview/Ipad.php @@ -69,15 +69,32 @@ public function getOrientation() */ public function getBannerImage() { - $configPath = 'conf/body/bannerIpadImage'; - $imageUrlOrig = $this->getData($configPath); - if ($imageUrlOrig) { - $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_BANNER_WIDTH; - $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_BANNER_HEIGHT; - $bannerImage = Mage::helper('xmlconnect/image') - ->getCustomSizeImageUrl($imageUrlOrig, $width, $height); - } else { - $bannerImage = $this->getPreviewImagesUrl('ipad/banner_image.png'); + $orientation = $this->getOrientation(); + switch ($orientation) { + case Mage_XmlConnect_Helper_Ipad::ORIENTATION_LANDSCAPE: + $configPath = 'conf/body/bannerIpadLandscapeImage'; + $imageUrlOrig = $this->getData($configPath); + if ($imageUrlOrig) { + $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BANNER_WIDTH; + $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BANNER_HEIGHT; + $bannerImage = Mage::helper('xmlconnect/image') + ->getCustomSizeImageUrl($imageUrlOrig, $width, $height); + } else { + $bannerImage = $this->getPreviewImagesUrl('ipad/banner_image_l.png'); + } + break; + case Mage_XmlConnect_Helper_Ipad::ORIENTATION_PORTRAIT: + $configPath = 'conf/body/bannerIpadImage'; + $imageUrlOrig = $this->getData($configPath); + if ($imageUrlOrig) { + $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BANNER_WIDTH; + $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BANNER_HEIGHT; + $bannerImage = Mage::helper('xmlconnect/image') + ->getCustomSizeImageUrl($imageUrlOrig, $width, $height); + } else { + $bannerImage = $this->getPreviewImagesUrl('ipad/banner_image.png'); + } + break; } return $bannerImage; } diff --git a/app/code/core/Mage/XmlConnect/Model/Queue.php b/app/code/core/Mage/XmlConnect/Model/Queue.php index 0fb342f070..329199428e 100755 --- a/app/code/core/Mage/XmlConnect/Model/Queue.php +++ b/app/code/core/Mage/XmlConnect/Model/Queue.php @@ -35,58 +35,42 @@ class Mage_XmlConnect_Model_Queue extends Mage_Core_Model_Template { /** * Status in queue identifier - * - * @var int */ const STATUS_IN_QUEUE = 0; /** * Status cenceled identifier - * - * @var int */ const STATUS_CANCELED = 1; /** * Status completed identifier - * - * @var int */ const STATUS_COMPLETED = 2; /** * Status deleted identifier - * - * @var int */ const STATUS_DELETED = 3; /** * Airmail message type - * - * @var string */ const MESSAGE_TYPE_AIRMAIL = 'airmail'; /** * Push notification message type - * - * @var string */ const MESSAGE_TYPE_PUSH = 'push'; /** * Notification type config path - * - * @var string */ const XML_PATH_NOTIFICATION_TYPE = 'xmlconnect/devices/%s/notification_type'; /** * Count of message in queue for cron * config path - * - * @var string */ const XML_PATH_CRON_MESSAGES_COUNT = 'xmlconnect/mobile_application/cron_send_messages_count'; diff --git a/app/code/core/Mage/XmlConnect/Model/Resource/Application.php b/app/code/core/Mage/XmlConnect/Model/Resource/Application.php index a656bdeb38..f5cc05038a 100755 --- a/app/code/core/Mage/XmlConnect/Model/Resource/Application.php +++ b/app/code/core/Mage/XmlConnect/Model/Resource/Application.php @@ -48,7 +48,7 @@ protected function _construct() * * @param int $applicationId * @param string $status - * @param Mage_XmlConnect_Model_Resource_Application $status + * @return Mage_XmlConnect_Model_Resource_Application */ public function updateApplicationStatus($applicationId, $status) { diff --git a/app/code/core/Mage/XmlConnect/Model/Resource/Category/Collection.php b/app/code/core/Mage/XmlConnect/Model/Resource/Category/Collection.php deleted file mode 100755 index 9376578d14..0000000000 --- a/app/code/core/Mage/XmlConnect/Model/Resource/Category/Collection.php +++ /dev/null @@ -1,96 +0,0 @@ - - */ -class Mage_XmlConnect_Model_Resource_Category_Collection extends Mage_Catalog_Model_Resource_Category_Collection -{ - /** - * Default parent category level - * - * @var int - */ - const PARENT_CATEGORIES_LEVEL = 2; - - /** - * Before collection load - * - * @return Mage_XmlConnect_Model_Resource_Category_Collection - */ - protected function _beforeLoad() - { - $this->addNameToResult(); - $this->addAttributeToSelect('thumbnail'); - $this->addIsActiveFilter(); - return parent::_beforeLoad(); - } - - /** - * Adding filter level - * - * @param string $level - * @return Mage_XmlConnect_Model_Resource_Category_Collection - */ - public function addLevelExactFilter($level) - { - $this->getSelect()->where('e.level = ?', $level); - return $this; - } - - /** - * Set limit collection - * - * @param int $offset - * @param int $count - * @return Mage_XmlConnect_Model_Resource_Category_Collection - */ - public function setLimit($offset, $count) - { - $this->getSelect()->limit($count, $offset); - return $this; - } - - /** - * Adding parentCategory filter - * - * @param int $parentId - * @return Mage_XmlConnect_Model_Resource_Category_Collection - */ - public function addParentIdFilter($parentId) - { - if (!is_null($parentId)) { - $this->getSelect()->where('e.parent_id = ?', (int)$parentId); - } else { - $this->addLevelExactFilter(self::PARENT_CATEGORIES_LEVEL); - } - return $this; - } -} diff --git a/app/code/core/Mage/XmlConnect/Model/Resource/ConfigData.php b/app/code/core/Mage/XmlConnect/Model/Resource/ConfigData.php new file mode 100644 index 0000000000..a4878549c5 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Model/Resource/ConfigData.php @@ -0,0 +1,107 @@ + + */ +class Mage_XmlConnect_Model_Resource_ConfigData extends Mage_Core_Model_Mysql4_Abstract +{ + /** + * Initialize configuration data + * + * @return void + */ + protected function _construct() + { + $this->_init('xmlconnect/configData', null); + } + + /** + * Save config value + * + * @param int $applicationId + * @param string $category + * @param string $path + * @param string $value + * @return Mage_XmlConnect_Model_Mysql4_ConfigData + */ + public function saveConfig($applicationId, $category, $path, $value) + { + $newData = array( + 'application_id' => $applicationId, + 'category' => $category, + 'path' => $path, + 'value' => $value + ); + + $this->_getWriteAdapter()->insertOnDuplicate( + $this->getMainTable(), + $newData, + array('value') + ); + return $this; + } + + /** + * Delete config value + * + * @param int $applicationId + * @param bool $category + * @param bool $path + * @param bool $pathLike + * @return Mage_XmlConnect_Model_Mysql4_ConfigData + */ + public function deleteConfig($applicationId, $category = false, $path = false, $pathLike = true) + { + try { + $this->_getWriteAdapter()->beginTransaction(); + $writeAdapter = $this->_getWriteAdapter(); + $deleteWhere[] = $writeAdapter->quoteInto('application_id=?', $applicationId); + if ($category) { + $deleteWhere[] = $writeAdapter->quoteInto('category=?', $category); + } + if ($path) { + $deleteWhere[] = $pathLike + ? $writeAdapter->quoteInto('path like ?', $path . '/%') + : $writeAdapter->quoteInto('path=?', $path); + } + $writeAdapter->delete($this->getMainTable(), $deleteWhere); + $this->_getWriteAdapter()->commit(); + } catch (Mage_Core_Exception $e) { + $this->_getWriteAdapter()->rollBack(); + throw $e; + } catch (Exception $e){ + $this->_getWriteAdapter()->rollBack(); + Mage::logException($e); + } + + return $this; + } +} diff --git a/app/code/core/Mage/XmlConnect/Model/Resource/ConfigData/Collection.php b/app/code/core/Mage/XmlConnect/Model/Resource/ConfigData/Collection.php new file mode 100644 index 0000000000..2001503570 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/Model/Resource/ConfigData/Collection.php @@ -0,0 +1,177 @@ + + */ +class Mage_XmlConnect_Model_Resource_ConfigData_Collection + extends Mage_Core_Model_Mysql4_Collection_Abstract +{ + /** + * Is application filter applied + * + * @var bool + */ + protected $_applicationFilter = false; + + /** + * Internal constructor + */ + protected function _construct() + { + $this->_init('xmlconnect/configData'); + } + + /** + * Add application filter + * + * @param $applicationId + * @return Mage_XmlConnect_Model_Mysql4_ConfigData_Collection + */ + public function addApplicationIdFilter($applicationId) + { + $this->_applicationFilter = true; + $this->getSelect() + ->where('application_id=?', $applicationId); + return $this; + } + + /** + * Add path filter + * + * @param $path + * @param bool $like + * @return Mage_XmlConnect_Model_Mysql4_ConfigData_Collection + */ + public function addPathFilter($path, $like = true) + { + if ($like) { + $this->getSelect() + ->where('path like ?', $path . '/%'); + } else { + $this->getSelect() + ->where('path=?', $path); + } + return $this; + } + + /** + * Add category filter + * + * @param $category + * @return Mage_XmlConnect_Model_Mysql4_ConfigData_Collection + */ + public function addCategoryFilter($category) + { + $this->getSelect()->where('category=?', $category); + return $this; + } + + /** + * Add value filter + * + * @param $value + * @return Mage_XmlConnect_Model_Mysql4_ConfigData_Collection + */ + public function addValueFilter($value) + { + $this->getSelect()->where('value=?', $value); + return $this; + } + + /** + * Add filter by array + * + * @param array $array + * @return Mage_XmlConnect_Model_Mysql4_ConfigData_Collection + */ + public function addArrayFilter(array $array) + { + foreach ($array as $key => $val) { + $method = 'add' . uc_words($key, '') . 'Filter'; + if (is_callable($this->$method($val))) { + return $this->$method($val); + } + } + return $this; + } + + /** + * Convert items array to array for select options + * + * return items array + * array( + * application_id => array( + * category => array( + * path + * ) + * ) + * ) + * + * @return array + */ + public function toOptionArray() + { + $result = array(); + foreach ($this as $item) { + $appId = $item->getData('application_id'); + $category = $item->getData('category'); + $path = $item->getData('path'); + $value = $item->getData('value'); + + if ($this->_applicationFilter) { + $result[$category][$path] = $value; + } else { + $result[$appId][$category][$path] = $value; + } + } + return $result; + } + + /** + * Get Application filter status + * + * @return boolean + */ + public function getApplicationFilter() + { + return $this->_applicationFilter; + } + + /** + * Set Application filter status + * + * @param boolean $applicationFilter + */ + public function setApplicationFilter($applicationFilter) + { + $this->_applicationFilter = $applicationFilter; + } +} diff --git a/app/code/core/Mage/XmlConnect/Model/Theme.php b/app/code/core/Mage/XmlConnect/Model/Theme.php index fa1d78aa89..674356bf51 100644 --- a/app/code/core/Mage/XmlConnect/Model/Theme.php +++ b/app/code/core/Mage/XmlConnect/Model/Theme.php @@ -33,16 +33,32 @@ */ class Mage_XmlConnect_Model_Theme { - protected $_file; - protected $_xml; - protected $_conf; + /** + * Current theme file + * + * @var string|null + */ + protected $_file = null; + + /** + * Loaded theme xml object + * + * @var SimpleXMLElement|null + */ + protected $_xml = null; + + /** + * Theme configuration + * + * @var array|null + */ + protected $_conf = null; /** * Load Theme xml from $file * * @param string $file * @throws Mage_Core_Exception - * @return void */ public function __construct($file) { @@ -53,8 +69,8 @@ public function __construct($file) if (!is_readable($file)) { Mage::throwException(Mage::helper('xmlconnect')->__('Can\'t read file "%s".', $file)); } - $text = file_get_contents($file); try { + $text = file_get_contents($file); $this->_xml = simplexml_load_string($text); } catch (Exception $e) { Mage::throwException(Mage::helper('xmlconnect')->__('Can\'t load XML.')); @@ -89,7 +105,17 @@ protected function _xmlToArray($xml) } /** - * Getter for theme name + * Get theme file + * + * @return null|string + */ + protected function _getThemeFile() + { + return $this->_file; + } + + /** + * Get theme name * * @return string */ @@ -99,7 +125,20 @@ public function getName() } /** - * Getter for theme Label + * Set theme name + * + * @param $name + * @return Mage_XmlConnect_Model_Theme + */ + public function setName($name) + { + $name = trim((string) $name); + $this->_xml->manifest->name = htmlentities($name, ENT_QUOTES, 'UTF-8'); + return $this; + } + + /** + * Get theme Label * * @return string */ @@ -108,6 +147,85 @@ public function getLabel() return (string) $this->_xml->manifest->label; } + /** + * Set theme Label + * + * @param $label + * @return Mage_XmlConnect_Model_Theme + */ + public function setLabel($label) + { + $label = trim((string) $label); + $this->_xml->manifest->label = htmlentities($label, ENT_QUOTES, 'UTF-8'); + return $this; + } + + /** + * Generate full file name for custome theme in media + * + * @return string + */ + protected function _createThemeName() + { + /** @var $themesHelper Mage_XmlConnect_Helper_Theme */ + $themesHelper = Mage::helper('xmlconnect/theme'); + /** @var $coreHelper Mage_Core_Helper_Data */ + $coreHelper = Mage::helper('core'); + + $themeFileName = $themesHelper->getMediaThemePath() + . DS + .$themesHelper->getCustomThemeName() + . '_' + . time() + . '_' + . $coreHelper->getRandomString(10, 'abcdefghijklmnopqrstuvwxyz0123456789') + . '.xml'; + return $themeFileName; + } + + /** + * Copy current theme to specified file + * + * @param $filePath + * @return string new file + */ + protected function _createCopy($filePath) + { + $currentThemeFileName = $this->_getThemeFile(); + + $io = new Varien_Io_File(); + if (!$io->cp($currentThemeFileName, $filePath)) { + Mage::throwException( + Mage::helper('xmlconnect')->__('Can\'t copy file "%s" to "%s".', $currentThemeFileName, $filePath) + ); + } else { + $io->chmod($filePath, 0755); + } + + return $filePath; + } + + /** + * Create a copy of current instance with specified data + * + * @param $themeName new theme label + * @param $data theme config array + * @return Mage_XmlConnect_Model_Theme + */ + public function createNewTheme($themeName, $data) + { + $filePath = $this->_createThemeName(); + $themeFileName = $this->_createCopy($filePath); + + /** @var $themeFileName Mage_XmlConnect_Model_Theme */ + $themeFileName = Mage::getModel('xmlconnect/theme', $filePath); + $themeFileName->setLabel($themeName); + $fileName = basename($filePath); + $themeFileName->setName(substr($fileName, 0, strlen($fileName)-4)); + $themeFileName->importAndSaveData($data); + return $themeFileName; + } + /** * Load data (flat array) for Varien_Data_Form * @@ -207,7 +325,9 @@ public function importAndSaveData($data) if (is_writeable($this->_file)) { file_put_contents($this->_file, $xml->asXML()); } else { - Mage::throwException(Mage::helper('xmlconnect')->__('Can\'t write to file "%s".', $this->_file)); + Mage::throwException( + Mage::helper('xmlconnect')->__('Can\'t write to file "%s".', $this->_file) + ); } } } diff --git a/app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php b/app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php index e83542e94d..9287cf7ebe 100644 --- a/app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php +++ b/app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php @@ -37,7 +37,7 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll * Initialize application * * @param string $paramName - * @param string $type + * @param bool|string $type * @return Mage_XmlConnect_Model_Application */ protected function _initApp($paramName = 'application_id', $type = false) @@ -350,7 +350,6 @@ protected function _processPostRequest() $app->setSuccess($success); if (!$app->getSuccess()) { - $message = ''; $message = isset($resultArray['message']) ? $resultArray['message']: ''; if (is_array($message)) { $message = implode(' ,', $message); @@ -376,7 +375,7 @@ public function saveAction() if ($data) { Mage::getSingleton('adminhtml/session')->setFormData($data); try { - $id = $this->getRequest()->getParam('application_id'); + $id = (int) $this->getRequest()->getParam('application_id'); if (!$id && isset($data['devtype'])) { $devArray = Mage::helper('xmlconnect')->getSupportedDevices(); @@ -441,47 +440,64 @@ public function saveAction() */ protected function _saveThemeAction($data, $paramId = 'saveTheme') { - try { - $themeName = $this->getRequest()->getParam($paramId, false); - if ($themeName) { - if ($themeName == Mage::helper('xmlconnect/theme')->getCustomThemeName()) { - $theme = Mage::helper('xmlconnect/theme')->getThemeByName($themeName); - if ($theme instanceof Mage_XmlConnect_Model_Theme) { - if ($paramId == 'saveTheme') { - $convertedConf = $this->_convertPost($data); - } else { - if (isset($data['conf'])) { - $convertedConf = $data['conf']; + $themeName = trim($this->getRequest()->getParam($paramId, false)); + if ($themeName) { + /** @var $themesHelper Mage_XmlConnect_Helper_Theme */ + $themesHelper = Mage::helper('xmlconnect/theme'); + try { + if (array_key_exists($themeName, $themesHelper->getAllThemes())) { + /** @var $theme Mage_XmlConnect_Model_Theme */ + $theme = $themesHelper->getThemeByName($themeName); + if ($theme instanceof Mage_XmlConnect_Model_Theme) { + if ($paramId == 'saveTheme') { + $convertedConf = $this->_convertPost($data); } else { + if (isset($data['conf'])) { + $convertedConf = $data['conf']; + } else { + $response = array( + 'error' => true, + 'message' => $this->__('Cannot save theme "%s". Incorrect data received', $themeName) + ); + } + } + if (!isset($response)) { + $theme->importAndSaveData($convertedConf); $response = array( - 'error' => true, - 'message' => $this->__('Cannot save theme "%s". Incorrect data received', $themeName) + 'message' => $this->__('Changes have been saved to theme.'), + 'themes' => $themesHelper->getAllThemesArray(true), + 'themeSelector' => $themesHelper->getThemesSelector($themeName), + 'selectedTheme' => $themeName ); } - } - if (!isset($response)) { - $theme->importAndSaveData($convertedConf); - $response = Mage::helper('xmlconnect/theme')->getAllThemesArray(true); + } elseif ($newThemeName) { + $response = array('error' => true, 'message' => $this->__('Cannot load theme "%s".', $themeName)); + } else { + $response = array('error' => true, 'message' => $this->__('Cannot load theme "%s".', $themeName)); } } else { - $response = array('error' => true, 'message' => $this->__('Cannot load theme "%s".', $themeName)); - } - } else { - $response = Mage::helper('xmlconnect/theme')->getAllThemesArray(true); + $convertedConf = $this->_convertPost($data); + $newTheme = $themesHelper->createNewTheme($themeName, $convertedConf); + $response = array( + 'message' => $this->__('Theme has been created.'), + 'themes' => $themesHelper->getAllThemesArray(true), + 'themeSelector' => $themesHelper->getThemesSelector($newTheme->getName()), + 'selectedTheme' => $newTheme->getName() + ); } - } else { - $response = array('error' => true, 'message' => $this->__('Theme name is not set.')); + } catch (Mage_Core_Exception $e) { + $response = array( + 'error' => true, + 'message' => $e->getMessage(), + ); + } catch (Exception $e) { + $response = array( + 'error' => true, + 'message' => $this->__('Can\'t save theme.') + ); } - } catch (Mage_Core_Exception $e) { - $response = array( - 'error' => true, - 'message' => $e->getMessage(), - ); - } catch (Exception $e) { - $response = array( - 'error' => true, - 'message' => $this->__('Can\'t save theme.') - ); + } else { + $response = array('error' => true, 'message' => $this->__('Theme name is not set.')); } if (is_array($response)) { $response = Mage::helper('core')->jsonEncode($response); @@ -517,6 +533,52 @@ protected function _convertPost($data) return $conf; } + /** + * Delete theme action + * + * @return void + */ + public function deleteThemeAction() + { + $themeId = $this->getRequest()->getParam('theme_id', false); + if ($themeId) { + try { + /** @var $themesHelper Mage_XmlConnect_Helper_Theme */ + $themesHelper = Mage::helper('xmlconnect/theme'); + $result = $themesHelper->deleteTheme($themeId); + if ($result) { + $response = array( + 'message' => $this->__('Theme has been delete.'), + 'themes' => $themesHelper->getAllThemesArray(true), + 'themeSelector' => $themesHelper->getThemesSelector(), + 'selectedTheme' => $themesHelper->getDefaultThemeName() + ); + } else { + $response = array( + 'error' => true, + 'message' => $this->__('Can\'t delete "%s" theme.', $themeId) + ); + } + } catch (Mage_Core_Exception $e) { + $response = array( + 'error' => true, + 'message' => $e->getMessage(), + ); + } catch (Exception $e) { + $response = array( + 'error' => true, + 'message' => $this->__('Can\'t delete "%s" theme.', $themeId) + ); + } + } else { + $response = array('error' => true, 'message' => $this->__('Theme name is not set.')); + } + if (is_array($response)) { + $response = Mage::helper('core')->jsonEncode($response); + $this->getResponse()->setBody($response); + } + } + /** * Save Theme action * diff --git a/app/code/core/Mage/XmlConnect/controllers/CartController.php b/app/code/core/Mage/XmlConnect/controllers/CartController.php index 597444319e..c8a3588fc0 100644 --- a/app/code/core/Mage/XmlConnect/controllers/CartController.php +++ b/app/code/core/Mage/XmlConnect/controllers/CartController.php @@ -27,7 +27,9 @@ /** * XmlConnect shopping cart controller * - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_CartController extends Mage_XmlConnect_Controller_Action { @@ -173,7 +175,9 @@ public function addAction() $subProduct = $product->getTypeInstance(true) ->getProductByAttributes($request->getSuperAttribute(), $product); - if ($requestedQty < ($requiredQty = $subProduct->getStockItem()->getMinSaleQty())) { + if (!empty($subProduct) + && $requestedQty < ($requiredQty = $subProduct->getStockItem()->getMinSaleQty()) + ) { $requestedQty = $requiredQty; } diff --git a/app/code/core/Mage/XmlConnect/controllers/CheckoutController.php b/app/code/core/Mage/XmlConnect/controllers/CheckoutController.php index dd28fc00fb..5e89b941f6 100644 --- a/app/code/core/Mage/XmlConnect/controllers/CheckoutController.php +++ b/app/code/core/Mage/XmlConnect/controllers/CheckoutController.php @@ -27,12 +27,12 @@ /** * XmlConnect checkout controller * + * @category Mage + * @package Mage_Checkout * @author Magento Core Team */ - class Mage_XmlConnect_CheckoutController extends Mage_XmlConnect_Controller_Action { - /** * Make sure customer is logged in * @@ -71,6 +71,7 @@ public function indexAction() $this->_message($this->__('Onepage checkout is disabled.'), self::MESSAGE_STATUS_ERROR); return; } + /** @var $quote Mage_Sales_Model_Quote */ $quote = $this->getOnepage()->getQuote(); if ($quote->getHasError()) { $this->_message($this->__('Cart has some errors.'), self::MESSAGE_STATUS_ERROR); @@ -398,7 +399,7 @@ public function saveOrderAction() try { if ($requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds()) { $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array())); - if ($diff = array_diff($requiredAgreements, $postedAgreements)) { + if (array_diff($requiredAgreements, $postedAgreements)) { $error = $this->__('Please agree to all the terms and conditions before placing the order.'); $this->_message($error, self::MESSAGE_STATUS_ERROR); return; @@ -409,7 +410,8 @@ public function saveOrderAction() } $this->getOnepage()->saveOrder(); - $message = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $message Mage_XmlConnect_Model_Simplexml_Element */ + $message = Mage::getModel('xmlconnect/simplexml_element', ''); $message->addChild('status', self::MESSAGE_STATUS_SUCCESS); $orderId = $this->getOnepage()->getLastOrderId(); diff --git a/app/code/core/Mage/XmlConnect/controllers/CustomerController.php b/app/code/core/Mage/XmlConnect/controllers/CustomerController.php index 72b33e306b..852dcc34b4 100644 --- a/app/code/core/Mage/XmlConnect/controllers/CustomerController.php +++ b/app/code/core/Mage/XmlConnect/controllers/CustomerController.php @@ -27,7 +27,9 @@ /** * XmlConnect customer controller * - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_CustomerController extends Mage_XmlConnect_Controller_Action { @@ -60,7 +62,7 @@ public function loginAction() } catch (Mage_Core_Exception $e) { switch ($e->getCode()) { case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED: - // TODO: resend configmation email message with action + // TODO: resend confirmation email message with action break; case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD: $message = $e->getMessage(); @@ -106,7 +108,7 @@ public function formAction() if ($editFlag == 1) { if (!$this->_getSession()->isLoggedIn()) { $this->_message($this->__('Customer not logged in.'), self::MESSAGE_STATUS_ERROR); - return ; + return; } $customer = $this->_getSession()->getCustomer(); } @@ -176,7 +178,8 @@ public function editAction() } if (!empty($errors)) { - $message = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $message Mage_XmlConnect_Model_Simplexml_Element */ + $message = Mage::getModel('xmlconnect/simplexml_element', ''); $message->addChild('status', self::MESSAGE_STATUS_ERROR); $message->addChild('text', implode(' ', $errors)); $this->getResponse()->setBody($message->asNiceXml()); @@ -263,7 +266,8 @@ public function saveAction() if ($customer->isConfirmationRequired()) { $customer->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl()); $message = $this->__('Account confirmation is required. Please check your email for the confirmation link.'); - $messageXmlObj = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $messageXmlObj Mage_XmlConnect_Model_Simplexml_Element */ + $messageXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $messageXmlObj->addChild('status', self::MESSAGE_STATUS_SUCCESS); $messageXmlObj->addChild('text', $message); $messageXmlObj->addChild('confirmation', 1); @@ -320,16 +324,24 @@ public function forgotPasswordAction() $newPassword = $customer->generatePassword(); $customer->changePassword($newPassword, false); $customer->sendPasswordReminderEmail(); - $this->_message($this->__('A new password has been sent.'), self::MESSAGE_STATUS_SUCCESS); - + $this->_message( + $this->__('A new password has been sent.'), + self::MESSAGE_STATUS_SUCCESS + ); return; } catch (Mage_Core_Exception $e) { $this->_message($e->getMessage(), self::MESSAGE_STATUS_ERROR); } catch (Exception $e) { - $this->_message($this->__('Problem changing or sending password.'), self::MESSAGE_STATUS_ERROR); + $this->_message( + $this->__('Problem changing or sending password.'), + self::MESSAGE_STATUS_ERROR + ); } } else { - $this->_message($this->__('This email address was not found in our records.'), self::MESSAGE_STATUS_ERROR); + $this->_message( + $this->__('This email address was not found in our records.'), + self::MESSAGE_STATUS_ERROR + ); } } else { $this->_message($this->__('Customer email not specified.'), self::MESSAGE_STATUS_ERROR); @@ -352,7 +364,8 @@ public function addressAction() $this->loadLayout(false); $this->renderLayout(); } else { - $message = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $message Mage_XmlConnect_Model_Simplexml_Element */ + $message = Mage::getModel('xmlconnect/simplexml_element', ''); $message->addChild('status', self::MESSAGE_STATUS_ERROR); $message->addChild('is_empty_address_book', 1); $this->getResponse()->setBody($message->asNiceXml()); @@ -431,7 +444,7 @@ public function saveAddressAction() { if (!$this->_getSession()->isLoggedIn()) { $this->_message($this->__('Customer not logged in.'), self::MESSAGE_STATUS_ERROR); - return ; + return; } // Save data @@ -475,7 +488,7 @@ public function saveAddressAction() if (true === $addressValidation) { $address->save(); - $message = new Mage_XmlConnect_Model_Simplexml_Element(''); + $message = Mage::getModel('xmlconnect/simplexml_element', ''); $message->addChild('status', self::MESSAGE_STATUS_SUCCESS); $message->addChild('text', $this->__('Address has been saved.')); $message->addChild('address_id', $address->getId()); @@ -515,6 +528,64 @@ public function orderListAction() $this->renderLayout(); } + /** + * Customer order details + * + * @return void + */ + public function orderDetailsAction() + { + try { + if (!$this->_getSession()->isLoggedIn()) { + $this->_message($this->__('Customer not logged in.'), self::MESSAGE_STATUS_ERROR); + return; + } + + $orderId = (int) $this->getRequest()->getParam('order_id'); + if (!$orderId) { + $this->_message($this->__('Order id not specified.'), self::MESSAGE_STATUS_ERROR); + return; + } + + $order = Mage::getModel('sales/order')->load($orderId); + + if ($this->_canViewOrder($order)) { + Mage::register('current_order', $order); + } else { + $this->_message($this->__('Order is not available.'), self::MESSAGE_STATUS_ERROR); + return; + } + $this->loadLayout(false); + $this->renderLayout(); + return; + } catch (Mage_Core_Exception $e) { + $this->_message($e->getMessage(), self::MESSAGE_STATUS_ERROR); + } catch (Exception $e) { + $this->_message($this->__('Unable to render an order.'), self::MESSAGE_STATUS_ERROR); + Mage::logException($e); + } + } + + /** + * Check order view availability + * + * @param Mage_Sales_Model_Order $order + * @return bool + */ + protected function _canViewOrder($order) + { + $customerId = Mage::getSingleton('customer/session')->getCustomerId(); + $availableStates = Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates(); + if ($order->getId() + && $order->getCustomerId() + && ($order->getCustomerId() == $customerId) + && in_array($order->getState(), $availableStates, true) + ) { + return true; + } + return false; + } + /** * Check if customer is loggined * @@ -522,7 +593,8 @@ public function orderListAction() */ public function isLogginedAction() { - $message = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $message Mage_XmlConnect_Model_Simplexml_Element */ + $message = Mage::getModel('xmlconnect/simplexml_element', ''); $message->addChild('is_loggined', (int)$this->_getSession()->isLoggedIn()); $this->getResponse()->setBody($message->asNiceXml()); } diff --git a/app/code/core/Mage/XmlConnect/controllers/Paypal/MepController.php b/app/code/core/Mage/XmlConnect/controllers/Paypal/MepController.php index 121aaf4057..7b35f5e25b 100644 --- a/app/code/core/Mage/XmlConnect/controllers/Paypal/MepController.php +++ b/app/code/core/Mage/XmlConnect/controllers/Paypal/MepController.php @@ -27,9 +27,10 @@ /** * XmlConnect checkout controller * + * @category Mage + * @package Mage_XmlConnect * @author Magento Core Team */ - class Mage_XmlConnect_Paypal_MepController extends Mage_XmlConnect_Controller_Action { /** @@ -55,7 +56,8 @@ public function preDispatch() { parent::preDispatch(); if (!Mage::getSingleton('customer/session')->isLoggedIn() - && !Mage::getSingleton('checkout/session')->getQuote()->isAllowedGuestCheckout()) { + && !Mage::getSingleton('checkout/session')->getQuote()->isAllowedGuestCheckout() + ) { $this->setFlag('', self::FLAG_NO_DISPATCH, true); $this->_message($this->__('Customer not logged in.'), self::MESSAGE_STATUS_ERROR); return ; @@ -71,13 +73,19 @@ public function indexAction() { try { $this->_initCheckout(); - $reservedOrderId = $this->_checkout->initCheckout(); - $this->_message($this->__('Checkout has been initialized.'), self::MESSAGE_STATUS_SUCCESS); + $this->_checkout->initCheckout(); + $this->_message( + $this->__('Checkout has been initialized.'), + self::MESSAGE_STATUS_SUCCESS + ); return; } catch (Mage_Core_Exception $e) { $this->_message($e->getMessage(), self::MESSAGE_STATUS_ERROR); } catch (Exception $e) { - $this->_message($this->__('Unable to start MEP Checkout.'), self::MESSAGE_STATUS_ERROR); + $this->_message( + $this->__('Unable to start MEP Checkout.'), + self::MESSAGE_STATUS_ERROR + ); Mage::logException($e); } } @@ -93,12 +101,26 @@ public function saveShippingAddressAction() $this->_message($this->__('Specified invalid data.'), self::MESSAGE_STATUS_ERROR); return; } + try { $this->_initCheckout(); $data = $this->getRequest()->getPost('shipping', array()); + + array_walk_recursive($data, create_function('&$val', '$val = trim($val);')); + + if (!empty($data['region']) && isset($data['country_id'])) { + $region = Mage::getModel('directory/region')->loadByCode($data['region'], $data['country_id']); + if ($region && $region->getId()) { + $data['region_id'] = $region->getId(); + } + } + $result = $this->_checkout->saveShipping($data); if (!isset($result['error'])) { - $this->_message($this->__('Shipping address has been set.'), self::MESSAGE_STATUS_SUCCESS); + $this->_message( + $this->__('Shipping address has been set.'), + self::MESSAGE_STATUS_SUCCESS + ); } else { if (!is_array($result['message'])) { $result['message'] = array($result['message']); @@ -107,8 +129,12 @@ public function saveShippingAddressAction() } } catch (Mage_Core_Exception $e) { $this->_message($e->getMessage(), self::MESSAGE_STATUS_ERROR); + Mage::logException($e); } catch (Exception $e) { - $this->_message($this->__('Unable to save shipping address.'), self::MESSAGE_STATUS_ERROR); + $this->_message( + $this->__('Unable to save shipping address.'), + self::MESSAGE_STATUS_ERROR + ); Mage::logException($e); } } @@ -127,7 +153,10 @@ public function shippingMethodsAction() } catch (Mage_Core_Exception $e) { $this->_message($e->getMessage(), self::MESSAGE_STATUS_ERROR); } catch (Exception $e) { - $this->_message($this->__('Unable to get shipping methods list.'), self::MESSAGE_STATUS_ERROR); + $this->_message( + $this->__('Unable to get shipping methods list.'), + self::MESSAGE_STATUS_ERROR + ); Mage::logException($e); } } @@ -143,12 +172,19 @@ public function saveShippingMethodAction() $this->_message($this->__('Specified invalid data.'), self::MESSAGE_STATUS_ERROR); return; } + try { $this->_initCheckout(); $data = $this->getRequest()->getPost('shipping_method', ''); + $this->_quote->getShippingAddress() + ->setShippingMethod($data) + ->setCollectShippingRates(true) + ->save(); + $result = $this->_checkout->saveShippingMethod($data); if (!isset($result['error'])) { - $message = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $message Mage_XmlConnect_Model_Simplexml_Element */ + $message = Mage::getModel('xmlconnect/simplexml_element', ''); $message->addChild('status', self::MESSAGE_STATUS_SUCCESS); $message->addChild('text', $this->__('Shipping method has been set.')); if ($this->_getQuote()->isVirtual()) { @@ -156,8 +192,15 @@ public function saveShippingMethodAction() } else { $quoteAddress = $this->_getQuote()->getShippingAddress(); } - $taxAmount = Mage::helper('core')->currency($quoteAddress->getBaseTaxAmount(), false, false); - $message->addChild('tax_amount', Mage::helper('xmlconnect')->formatPriceForXml($taxAmount)); + $taxAmount = Mage::helper('core')->currency( + $quoteAddress->getBaseTaxAmount(), + false, + false + ); + $message->addChild( + 'tax_amount', + Mage::helper('xmlconnect')->formatPriceForXml($taxAmount) + ); $this->getResponse()->setBody($message->asNiceXml()); } else { if (!is_array($result['message'])) { @@ -168,7 +211,10 @@ public function saveShippingMethodAction() } catch (Mage_Core_Exception $e) { $this->_message($e->getMessage(), self::MESSAGE_STATUS_ERROR); } catch (Exception $e) { - $this->_message($this->__('Unable to save shipping method.'), self::MESSAGE_STATUS_ERROR); + $this->_message( + $this->__('Unable to save shipping method.'), + self::MESSAGE_STATUS_ERROR + ); Mage::logException($e); } } @@ -204,6 +250,7 @@ public function saveOrderAction() $this->_message($this->__('Specified invalid data.'), self::MESSAGE_STATUS_ERROR); return; } + try { /** * Init checkout @@ -214,6 +261,13 @@ public function saveOrderAction() * Set payment data */ $data = $this->getRequest()->getPost('payment', array()); + + if (Mage::getSingleton('customer/session')->isLoggedIn()) { + $data['payer'] = Mage::getSingleton('customer/session') + ->getCustomer() + ->getEmail(); + } + $this->_checkout->savePayment($data); /** @@ -224,7 +278,8 @@ public function saveOrderAction() /** * Format success report */ - $message = new Mage_XmlConnect_Model_Simplexml_Element(''); + /** @var $message Mage_XmlConnect_Model_Simplexml_Element */ + $message = Mage::getModel('xmlconnect/simplexml_element', ''); $message->addChild('status', self::MESSAGE_STATUS_SUCCESS); $orderId = $this->_checkout->getLastOrderId(); diff --git a/app/code/core/Mage/XmlConnect/controllers/WishlistController.php b/app/code/core/Mage/XmlConnect/controllers/WishlistController.php index 9c9c7c6d5d..3037c58597 100644 --- a/app/code/core/Mage/XmlConnect/controllers/WishlistController.php +++ b/app/code/core/Mage/XmlConnect/controllers/WishlistController.php @@ -27,7 +27,9 @@ /** * XmlConnect wishlist controller * - * @author Magento Core Team + * @category Mage + * @package Mage_XmlConnect + * @author Magento Core Team */ class Mage_XmlConnect_WishlistController extends Mage_XmlConnect_Controller_Action { @@ -285,7 +287,7 @@ public function cartAction() $e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_IS_GROUPED_PRODUCT) { $item->delete(); - $message = new Mage_XmlConnect_Model_Simplexml_Element(''); + $message = Mage::getModel('xmlconnect/simplexml_element', ''); $message->addChild('status', self::MESSAGE_STATUS_SUCCESS); $message->addChild('has_required_options', 1); $message->addChild('product_id', $item->getProductId()); diff --git a/app/code/core/Mage/XmlConnect/etc/config.xml b/app/code/core/Mage/XmlConnect/etc/config.xml index d045ae52a9..42d5a5c103 100644 --- a/app/code/core/Mage/XmlConnect/etc/config.xml +++ b/app/code/core/Mage/XmlConnect/etc/config.xml @@ -46,6 +46,7 @@ xmlconnect_application
    xmlconnect_queue
    + xmlconnect_config_data
    @@ -198,6 +199,7 @@ 320 367 + 1024 344 768 294 1024 704 768 960 @@ -380,7 +382,10 @@ www.magentocommerce.com/products/index.php/mobile/activate/index/key/ http://www.magentocommerce.com/product/mobile http://www.magentocommerce.com/product/mobile#resubmission - https://go.urbanairship.com/partners/magento/ + http://urbanairship.com/products/push-notifications/ + http://urbanairship.com/products/rich-push/ + http://urbanairship.com/terms-of-service/ + https://go.urbanairship.com/partners/magento/ magentomobile@magento.com 3 @@ -405,6 +410,11 @@ http://www.flurry.com/product/analytics/index.html + + http://www.magentocommerce.com/product/mobile-social-networking-setup#twitter + http://www.magentocommerce.com/product/mobile-social-networking-setup#facebook + http://www.magentocommerce.com/product/mobile-social-networking-setup#linkedin + https://go.urbanairship.com/api/push/broadcast/ diff --git a/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/install-1.6.0.0.php b/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/install-1.6.0.0.php index 576a7044b9..f8c43f8ef5 100755 --- a/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/install-1.6.0.0.php +++ b/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/install-1.6.0.0.php @@ -58,8 +58,6 @@ ), 'Active To') ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( ), 'Updated At') - ->addColumn('configuration', Varien_Db_Ddl_Table::TYPE_BLOB, '64K', array( - ), 'Configuration Info') ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, @@ -85,6 +83,46 @@ ->setComment('Xmlconnect Application'); $installer->getConnection()->createTable($table); +/** + * Create table 'xmlconnect_config_data' + */ +$configTableName = $installer->getTable('xmlconnect/configData'); +$configTable = $installer->getConnection() + ->newTable($configTableName) + ->addColumn('application_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + ), 'Application Id') + ->addColumn('category', Varien_Db_Ddl_Table::TYPE_TEXT, 60, array( + 'nullable' => false, + 'default' => 'default', + ), 'Category') + ->addColumn('path', Varien_Db_Ddl_Table::TYPE_TEXT, 250, array( + 'nullable' => false, + ), 'Path') + ->addColumn('value', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array( + 'nullable' => false, + ), 'Value') + ->addIndex( + $installer->getIdxName( + $configTableName, + array('application_id', 'category', 'path'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('application_id', 'category', 'path'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) + ) + ->addForeignKey( + $installer->getFkName($configTableName, 'application_id', $appTableName, 'application_id'), + 'application_id', + $appTableName, + 'application_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->setComment('Xmlconnect Configuration Data'); +$installer->getConnection()->createTable($configTable); + /** * Create table 'xmlconnect_history' */ diff --git a/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-data-upgrade-1.4.0.13-1.4.0.14.php b/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-data-upgrade-1.4.0.13-1.4.0.14.php new file mode 100644 index 0000000000..09844425c0 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-data-upgrade-1.4.0.13-1.4.0.14.php @@ -0,0 +1,78 @@ + + */ + +/* @var $installer Mage_Core_Model_Resource_Setup */ +$installer = $this; + +$appTableName = $installer->getTable('xmlconnect/application'); + +$configField = $installer + ->getConnection() + ->tableColumnExists($appTableName, 'configuration'); + +if ($configField) { + /** @var $appModel Mage_XmlConnect_Model_Application */ + $appModel = Mage::getModel('xmlconnect/application'); + $select = $appModel->getResource() + ->getReadConnection() + ->select() + ->from( + $appTableName, + array('application_id', 'configuration') + ); + + $result = $appModel + ->getResource() + ->getReadConnection() + ->fetchAll($select); + + foreach ($result as $rows) { + if (empty($rows['configuration'])) { + continue; + } + $deprecatedConfig = unserialize($rows['configuration']); + $appModel->getConfigModel()->saveConfig( + $rows['application_id'], + $appModel->convertOldConfing($deprecatedConfig), + Mage_XmlConnect_Model_Application::DEPRECATED_CONFIG_FLAG + ); + } + + $installer + ->getConnection() + ->dropColumn( + $installer->getTable('xmlconnect/application'), + 'configuration' + ); +} diff --git a/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-upgrade-1.4.0.13-1.4.0.14.php b/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-upgrade-1.4.0.13-1.4.0.14.php new file mode 100644 index 0000000000..2bd7e40c01 --- /dev/null +++ b/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-upgrade-1.4.0.13-1.4.0.14.php @@ -0,0 +1,84 @@ + + */ + +/** @var $installer Mage_Core_Model_Resource_Setup */ +$installer = $this; +$installer->startSetup(); + +/** + * Create table 'xmlconnect_config_data' + */ +$configTableName = $installer->getTable('xmlconnect/configData'); +$configTable = $installer->getConnection() + ->newTable($configTableName) + ->addColumn('application_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + ), 'Application Id') + ->addColumn('category', Varien_Db_Ddl_Table::TYPE_TEXT, 60, array( + 'nullable' => false, + 'default' => 'default', + ), 'Category') + ->addColumn('path', Varien_Db_Ddl_Table::TYPE_TEXT, 250, array( + 'nullable' => false, + ), 'Path') + ->addColumn('value', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array( + 'nullable' => false, + ), 'Value') + ->addIndex( + $installer->getIdxName( + $configTableName, + array('application_id', 'category', 'path'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('application_id', 'category', 'path'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) + ) + ->addForeignKey( + $installer->getFkName( + $configTableName, + 'application_id', + $installer->getTable('xmlconnect/application'), + 'application_id' + ), + 'application_id', + $installer->getTable('xmlconnect/application'), + 'application_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->setComment('Xmlconnect Configuration Data'); +$installer->getConnection()->createTable($configTable); + +$installer->endSetup(); diff --git a/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php b/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php index f0118d3792..8a1ac12aad 100755 --- a/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php +++ b/app/code/core/Mage/XmlConnect/sql/xmlconnect_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php @@ -30,6 +30,7 @@ $installer->startSetup(); $appTableName = $installer->getTable('xmlconnect/application'); +$configTableName = $installer->getTable('xmlconnect/configData'); $historyTableName = $installer->getTable('xmlconnect/history'); $templateTableName = $installer->getTable('xmlconnect/template'); $queueTableName = $installer->getTable('xmlconnect/queue'); @@ -57,6 +58,11 @@ 'FK_TEMPLATE_ID' ); +$installer->getConnection()->dropForeignKey( + $configTableName, + 'FK_31EE36D814216200D7C0723145AC510E' +); + /** * Drop indexes */ @@ -75,6 +81,11 @@ 'UNQ_XMLCONNECT_APPLICATION_CODE' ); +$installer->getConnection()->dropIndex( + $configTableName, + 'UNQ_XMLCONNECT_CONFIG_DATA_APPLICATION_ID_CATEGORY_PATH' +); + /** * Modify fields for 'xmlconnect_notification_template' */ @@ -175,11 +186,6 @@ 'default' => null, 'comment' => 'Updated At' ), - 'configuration' => array( - 'type' => Varien_Db_Ddl_Table::TYPE_BLOB, - 'length' => '64k', - 'comment' => 'Configuration Info' - ), 'status' => array( 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, 'unsigned' => true, @@ -196,6 +202,39 @@ ), 'comment' => 'Xmlconnect Application' ), + /** + * Modify table 'xmlconnect_config_data' + */ + $configTableName => array( + 'columns' => array( + 'application_id' => array( + 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, + 'unsigned' => true, + 'nullable' => false, + 'comment' => 'Application Id' + ), + 'category' => array( + 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'length' => 60, + 'nullable' => false, + 'default' => 'default', + 'comment' => 'Category' + ), + 'path' => array( + 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'length' => 250, + 'nullable' => false, + 'comment' => 'Path' + ), + 'value' => array( + 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'length' => '64k', + 'nullable' => false, + 'comment' => 'Value' + ), + ), + 'comment' => 'Xmlconnect Configuration Data' + ), /** * Modify table 'xmlconnect_history' */ @@ -403,6 +442,17 @@ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ); +$installer->getConnection()->addIndex( + $configTableName, + $installer->getIdxName( + $configTableName, + array('application_id', 'category', 'path'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('application_id', 'category', 'path'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE +); + /** * Add foreign keys */ @@ -416,6 +466,14 @@ Varien_Db_Ddl_Table::ACTION_SET_NULL ); +$installer->getConnection()->addForeignKey( + $installer->getFkName($configTableName, 'application_id', $appTableName, 'application_id'), + $configTableName, + 'application_id', + $appTableName, + 'application_id' +); + $installer->getConnection()->addForeignKey( $installer->getFkName($historyTableName, 'application_id', $appTableName, 'application_id'), $historyTableName, diff --git a/app/design/adminhtml/default/default/layout/main.xml b/app/design/adminhtml/default/default/layout/main.xml index 5048d7d6ba..77af339d41 100644 --- a/app/design/adminhtml/default/default/layout/main.xml +++ b/app/design/adminhtml/default/default/layout/main.xml @@ -57,7 +57,6 @@ Default layout, loads most of the pages Magento Admin - @@ -99,6 +98,7 @@ Default layout, loads most of the pages jscalendar/calendar-setup.js jsextjs/ext-tree.jscan_load_ext_js + jsextjs/fix-defer.jscan_load_ext_js jsextjs/ext-tree-checkbox.jscan_load_ext_js js_cssextjs/resources/css/ext-all.csscan_load_ext_js js_cssextjs/resources/css/ytheme-magento.csscan_load_ext_js diff --git a/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/grid.phtml b/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/grid.phtml index 704f8cd10e..f920ade58b 100644 --- a/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/grid.phtml +++ b/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/grid.phtml @@ -48,7 +48,14 @@
    getName(); ?> diff --git a/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/packed.phtml b/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/packed.phtml index 4e304ed982..eedd20e925 100644 --- a/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/packed.phtml +++ b/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/packed.phtml @@ -42,6 +42,8 @@
    getContainerTypeByCode($params->getContainer()) ?> __('Length') ?> - getLength() != null ? $params->getLength() : '-' ?> - getMeasureDimensionName($params->getDimensionUnits()) ?> + getLength() != null): ?> + getLength() .' '. Mage::helper('usa')->getMeasureDimensionName($params->getDimensionUnits()) ?> + + -- + __('Signature Confirmation') ?>getDeliveryConfirmationTypeByCode($params->getDeliveryConfirmation()) ?>  
    __('Width') ?> - getWidth() != null ? $params->getWidth() : '-' ?> - getMeasureDimensionName($params->getDimensionUnits()) ?> + getWidth() != null): ?> + getWidth() .' '. Mage::helper('usa')->getMeasureDimensionName($params->getDimensionUnits()) ?> + + -- +   
    __('Height') ?> - getHeight() != null ? $params->getHeight() : '-' ?> - getMeasureDimensionName($params->getDimensionUnits()) ?> + getHeight() != null): ?> + getHeight() .' '. Mage::helper('usa')->getMeasureDimensionName($params->getDimensionUnits()) ?> + + -- + +   
          
    diff --git a/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/popup.phtml b/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/popup.phtml index 060bf122bd..c558e5d4b3 100644 --- a/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/popup.phtml +++ b/app/design/adminhtml/default/default/template/sales/order/shipment/packaging/popup.phtml @@ -27,7 +27,7 @@ getShipment()->getOrder()->getShippingMethod(); $sizeSource = Mage::getModel('usa/shipping_carrier_usps_source_size')->toOptionArray(); -$girthEnabled = Mage::helper('usa')->displayGirthValue($shippingMethod) && $this->isGirthAllowed(); +$girthEnabled = Mage::helper('usa')->displayGirthValue($shippingMethod) && $this->isGirthAllowed() ? 1 : 0; ?> - -
    - -
    - - - -
    - +
    + + + + + +
    + + +
    + +
    + getThemesSelector(); ?> +
    + +
    + + +
    + + +
    -

    -
    +
    + getColorFieldset(); -$id2observe = array(); +$colorFieldset = $this->getColorFieldset(); +$id2observe = array(); ?> - - - - - - - - - - - - + + +

    + + + +

    - - + + + + + + + + + + - - - -
    - -
    -
    + +
    + + + + + + + + +
    - - diff --git a/app/design/adminhtml/default/default/template/xmlconnect/mobile/notification_helper.phtml b/app/design/adminhtml/default/default/template/xmlconnect/mobile/notification_helper.phtml index 1049fb52f5..50fc3c3475 100644 --- a/app/design/adminhtml/default/default/template/xmlconnect/mobile/notification_helper.phtml +++ b/app/design/adminhtml/default/default/template/xmlconnect/mobile/notification_helper.phtml @@ -25,10 +25,28 @@ */ ?>
    - helper('xmlconnect')->__('After submitting the App, please contact %1$s to receive the Application Key, Application Secret and Application Master Secret.
    Upon receiving these credentials, please fill in the corresponding fields.
    In addition, please accept Urban Airship\'s Terms of Service: click here.', Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_CONTACT_CREDENTIALS_EMAIL), Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_URBAN_AIRSHIP_TOS_URL)); + echo $this->helper('xmlconnect')->__('As a Magento customer, Urban Airship is offering you unlimited Push Notifications and Rich Push for $100/year* along with a 60 day free trial.'); + echo '
    '; + echo $this->helper('xmlconnect')->__('*Subject to change'); + echo '

    '; + echo $this->helper('xmlconnect')->__('Extend the life of your app with Urban Airship Push Notifications.'); + echo '
    '; + echo $this->helper('xmlconnect')->__('Push Notifications allow you to send messages directly to the people who have installed your app on their device. Send messages to your full audience even when your app is closed. Push Notifications are one of the best ways to keep your app active by delivering valuable content directly to your customers. Learn more about Push Notifications - %1$s', Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_URBAN_AIRSHIP_ABOUT_PUSH_URL)); + echo '

    '; + echo $this->helper('xmlconnect')->__('Deeper Messaging and Engagement with Rich Push.'); + echo '
    '; + echo $this->helper('xmlconnect')->__('Rich Push allows you to create and send engaging experiences by adding HTML and other rich media components to your push notifications. Moving beyond alerts and badge updates, Rich Push takes users into the app while displaying content in a customizable WebKit view. Create branded messages that engage your users with new content and information, all without having to update your app. Learn more about Rich Push - %1$s', Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_URBAN_AIRSHIP_ABOUT_RICH_PUSH_URL)); + echo '

    '; + echo $this->helper('xmlconnect')->__('How to incorporate Urban Airship within your application:'); + echo '
    '; + echo $this->helper('xmlconnect')->__('After submitting the App to Magento, please contact %1$s to receive the Application Key, Application Secret and Application Master Secret.', Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_CONTACT_CREDENTIALS_EMAIL)); + echo '
    '; + echo $this->helper('xmlconnect')->__('Upon receiving these credentials, please fill in the corresponding fields.'); + echo '
    '; + echo $this->helper('xmlconnect')->__('In addition, click here to review Urban Airship\'s Terms of Service: click here.', Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_URBAN_AIRSHIP_TOS_URL)); + echo '

    '; + echo $this->helper('xmlconnect')->__('Login to Urabn Airship.', Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_URBAN_AIRSHIP_PARTNER_LOGIN_URL)); ?> -

    diff --git a/app/design/frontend/base/default/layout/bundle.xml b/app/design/frontend/base/default/layout/bundle.xml index f8e40059bc..9fecbe8c4b 100644 --- a/app/design/frontend/base/default/layout/bundle.xml +++ b/app/design/frontend/base/default/layout/bundle.xml @@ -286,6 +286,57 @@ Print pages + + + + bundlebundle/sales_order_items_renderer + + + + + + bundlebundle/sales_order_items_renderer + + + + + + bundlebundle/sales_order_items_renderer + + + + + + bundlebundle/sales_order_items_renderer + + + + + + bundlebundle/sales_order_items_renderer + + + + + + bundlebundle/sales_order_items_renderer + + + + + + bundlebundle/sales_order_items_renderer + + + + + + bundlebundle/sales_order_items_renderer + + + diff --git a/app/design/frontend/base/default/layout/catalog_msrp.xml b/app/design/frontend/base/default/layout/catalog_msrp.xml index 9dcd25acbe..df9143b648 100644 --- a/app/design/frontend/base/default/layout/catalog_msrp.xml +++ b/app/design/frontend/base/default/layout/catalog_msrp.xml @@ -50,6 +50,10 @@ Default layout, loads most of the pages + + + + diff --git a/app/design/frontend/base/default/layout/downloadable.xml b/app/design/frontend/base/default/layout/downloadable.xml index 3d0981af6a..680554f2c2 100644 --- a/app/design/frontend/base/default/layout/downloadable.xml +++ b/app/design/frontend/base/default/layout/downloadable.xml @@ -126,7 +126,7 @@ downloadabledownloadable/sales_order_item_renderer_downloadable - + downloadabledownloadable/catalog_product_configuration @@ -159,6 +159,45 @@ Print pages EOF Print pages --> + + + + downloadabledownloadable/sales_order_item_renderer_downloadable + + + + + + downloadabledownloadable/sales_order_item_renderer_downloadable + + + + + + downloadabledownloadable/sales_order_item_renderer_downloadable + + + + + + downloadabledownloadable/sales_order_item_renderer_downloadable + + + + + + downloadabledownloadable/sales_order_item_renderer_downloadable + + + + + + downloadabledownloadable/sales_order_item_renderer_downloadable + + + diff --git a/app/design/frontend/base/default/layout/page.xml b/app/design/frontend/base/default/layout/page.xml index dfd7329fcf..68aacdd5c7 100644 --- a/app/design/frontend/base/default/layout/page.xml +++ b/app/design/frontend/base/default/layout/page.xml @@ -36,7 +36,6 @@ Default layout, loads most of the pages - @@ -49,7 +48,7 @@ Default layout, loads most of the pages - + css/styles.css diff --git a/app/design/frontend/base/default/layout/persistent.xml b/app/design/frontend/base/default/layout/persistent.xml index 009c621a4e..717ffa5aa6 100644 --- a/app/design/frontend/base/default/layout/persistent.xml +++ b/app/design/frontend/base/default/layout/persistent.xml @@ -27,15 +27,6 @@ --> - - - -